/* FrameMint Studio — Flagship Minimalist Workspace Styles */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

button,
input {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--header-height);
  padding: 0 18px;
  background: var(--bg-header);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--border-subtle);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(16, 185, 129, 0.25));
}

.app-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.025em;
  white-space: nowrap;
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--mint-soft);
  border: 1px solid var(--mint-border);
  color: var(--mint-text);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 30px;
  padding: 0 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.12s ease;
}

.header-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.header-btn:active {
  transform: scale(0.98);
}

.header-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.header-btn-ghost:hover {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

/* Main Workspace */
.studio-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  flex: 1;
  height: calc(100vh - var(--header-height));
  min-height: 0;
  overflow: hidden;
}

/* Left Inspector Sidebar with Pinned Export Dock */
.controls-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  overflow: hidden;
}

.controls-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.controls-scroll::-webkit-scrollbar {
  width: 6px;
}

.controls-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.controls-scroll::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
}

.controls-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

.control-section {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.controls-scroll .control-section:last-child {
  border-bottom: none;
}

/* Always-visible Export Dock at Bottom of Inspector */
.control-section-export {
  flex-shrink: 0;
  gap: 10px;
  padding: 13px 16px 15px;
  border-top: 1px solid var(--border-strong);
  border-bottom: none;
  background: var(--bg-panel-dock);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 -10px 26px rgba(0, 0, 0, 0.22);
}

.export-dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.export-scale-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.export-scale-inline .segmented-group {
  width: 146px;
  flex-shrink: 0;
}

.section-title {
  margin: 0;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.control-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Segmented Controls — Refined Tactile Pill Rail */
.segmented-group {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
}

/* Symmetrical 3 + 2 Frame Grid (6 columns: top 3 span 2, bottom 2 span 3) */
.segmented-frame-grid {
  grid-auto-flow: row;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}

.segmented-frame-grid .seg-btn {
  grid-column: span 2;
}

.segmented-frame-grid .seg-btn-wide {
  grid-column: span 3;
}

.segmented-aspect {
  grid-auto-flow: row;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 29px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: calc(var(--radius-md) - 3px);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.seg-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.seg-btn.is-active {
  background: var(--seg-active-bg);
  border-color: var(--seg-active-border);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Swatch Grid */
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
}

.swatch-btn {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 9px;
  border: 1.5px solid var(--border-subtle);
  background-color: var(--bg-surface);
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.swatch-btn:hover {
  transform: translateY(-1.5px) scale(1.03);
  border-color: var(--border-strong);
}

.swatch-btn.is-active {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-panel), 0 0 0 3.5px var(--accent);
  transform: scale(1.04);
}

/* Sub Controls & Inputs */
.sub-controls {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.color-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
}

.color-input {
  width: 26px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.text-input {
  width: 100%;
  height: 33px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input::placeholder {
  color: var(--text-muted);
}

.text-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

/* Toggle Switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}

.toggle-input {
  appearance: none;
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.toggle-input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-secondary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.18s ease;
}

.toggle-input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-input:checked::after {
  transform: translateX(16px);
  background: #ffffff;
}

/* Sliders */
.slider-control {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.slider-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  padding: 1px 6px;
  border-radius: 5px;
}

.range-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-hover);
  cursor: pointer;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--cta-bg);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.range-input::-webkit-slider-thumb:hover {
  transform: scale(1.16);
}

.range-input::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--cta-bg);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

/* Export Dock Details */
.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
}

.meta-label {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.meta-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.watermark-note {
  margin: 0;
  font-size: 11px;
  color: var(--mint-text);
  font-weight: 600;
  letter-spacing: 0.005em;
}

.export-actions {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 8px;
}

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.btn-primary {
  border: 1px solid transparent;
  background: var(--cta-bg);
  color: var(--cta-text);
  box-shadow: var(--cta-shadow);
}

.btn-primary:hover:not(:disabled) {
  background: var(--cta-hover);
  transform: translateY(-0.5px);
}

.btn-primary:active:not(:disabled),
.btn-secondary:active:not(:disabled) {
  transform: scale(0.985);
}

.btn-secondary {
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-surface-hover);
}

.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.36;
  cursor: not-allowed;
  box-shadow: none;
}

/* Preview Stage */
.preview-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background-color: var(--bg-stage);
  background-image:
    radial-gradient(ellipse 68% 58% at 50% 48%, var(--bg-stage-glow), transparent 72%),
    radial-gradient(var(--bg-stage-dot) 1px, transparent 1px);
  background-size: 100% 100%, 20px 20px;
  padding: 14px 24px 22px;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 32px;
  margin-bottom: 10px;
}

.stage-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stage-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.stage-btn:hover {
  background: var(--bg-surface-hover);
  transform: translateY(-0.5px);
}

.drop-zone {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 360px;
  border-radius: var(--radius-lg);
  border: 1px dashed transparent;
  padding: 12px;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.drop-zone[data-drag-active="true"] {
  border-color: var(--accent-hover);
  background: var(--accent-soft);
}

.canvas-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: calc(100vh - var(--header-height) - 96px);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-subtle);
}

#preview-canvas {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - var(--header-height) - 96px);
  width: auto;
  height: auto;
}

/* Empty State Overlay */
.empty-state {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.empty-card {
  width: min(440px, 100%);
  padding: 32px 26px;
  border-radius: var(--radius-lg);
  background: var(--bg-empty-card);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: var(--mint-soft);
  border: 1px solid var(--mint-border);
  color: var(--mint-text);
}

.empty-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.empty-subtitle {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.empty-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.empty-paste-hint {
  margin: 4px 0 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Drag Drop Overlay */
.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  border: 2px dashed var(--accent-hover);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.drop-zone[data-drag-active="true"] .drop-overlay {
  opacity: 1;
  visibility: visible;
}

.drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 700;
}

/* Privacy & Terms Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-card {
  width: min(500px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  padding: 22px 24px;
  border-radius: var(--radius-lg);
  background: var(--bg-modal);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 14px;
}

.modal-close:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.6;
}

.modal-block {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-block-title {
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-block p {
  margin: 0;
}

/* Toast Notifications */
.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-panel);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  font-size: 12px;
  font-weight: 600;
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
}

.toast[data-variant="success"],
.toast-success {
  border-color: var(--mint-border);
}

.toast[data-variant="error"],
.toast-error {
  border-color: var(--danger);
}

.toast[data-variant="info"] {
  border-color: var(--accent-border);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive Rules (Zero Horizontal Overflow on Narrow Viewports & JA Labels) */
@media (max-width: 960px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .studio-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    height: auto;
    min-height: auto;
    overflow: visible;
  }

  .controls-panel {
    order: 2;
    height: auto;
    max-height: none;
    overflow: visible;
    border-right: none;
    border-top: 1px solid var(--border-subtle);
  }

  .controls-scroll {
    overflow: visible;
  }

  .control-section-export {
    position: sticky;
    bottom: 0;
    z-index: 20;
  }

  .preview-stage {
    order: 1;
    padding: 12px;
  }

  .drop-zone {
    min-height: 280px;
    padding: 6px;
  }

  .canvas-wrapper,
  #preview-canvas {
    max-height: 55vh;
  }
}

@media (max-width: 600px) {
  .app-header {
    height: auto;
    padding: 8px 12px;
    flex-wrap: wrap;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .swatch-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .segmented-aspect {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
