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

:root {
  /* ── Cores ─────────────────────────────────────────────────────────────── */
  --bg:          #0e0e0e;
  --bg-2:        #141414;
  --bg-3:        #1a1a1a;
  --bg-4:        #212121;
  --bg-5:        #2a2a2a;
  --border:      #2e2e2e;
  --border-soft: #242424;
  --text:        #ededed;
  --text-dim:    #a1a1a1;
  --text-muted:  #525252;
  --accent:      #D6A1D6;
  --accent-soft: rgba(214, 161, 214, 0.20);
  --accent-dim:  rgba(214, 161, 214, 0.10);
  --danger:      #f87171;
  --sidebar-w:   316px;

  /* ── Tipografia — escala 8px (Figma: Caption→Body→Heading) ─────────────── */
  --fs-2xs:  12px;   /* Caption XXS — micro labels, seções, hints  */
  --fs-xs:   14px;   /* Body SM / Caption SM — labels, corpo        */
  --fs-sm:   16px;   /* Body MD — logo, ícones de ação              */
  --fs-base: 20px;   /* Body LG / Heading SM — destaque             */
  --fs-lg:   24px;   /* Heading MD — ícones grandes                 */
  --fs-xl:   32px;   /* Heading LG — display                        */
  --fs-2xl:  40px;   /* Heading XL — extra grande                   */

  /* ── Espaçamento — grade de 8px ─────────────────────────────────────────── */
  --sp-1:  4px;    /* 0.5× micro gap              */
  --sp-2:  8px;    /* 1×   gap padrão             */
  --sp-3:  12px;   /* 1.5× gap médio              */
  --sp-4:  16px;   /* 2×   padding padrão         */
  --sp-5:  20px;   /* 2.5× padding médio          */
  --sp-6:  24px;   /* 3×   padding generoso       */
  --sp-8:  32px;   /* 4×   seção / bloco          */

  /* ── Border-radius — escala 8px ─────────────────────────────────────────── */
  --radius-xs:   4px;      /* badges, tags inline              */
  --radius-sm:   8px;      /* inputs, botões, controles        */
  --radius:      12px;     /* cards, painéis, selects          */
  --radius-lg:   16px;     /* dropzones, containers internos   */
  --radius-xl:   20px;     /* modais, elementos em destaque    */
  --radius-full: 9999px;   /* pílulas, switches                */

  /* ── Componentes ────────────────────────────────────────────────────────── */
  --input-h:     32px;
  --transition:  0.12s ease;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: var(--fs-xs);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ────────────────────────────────────────────────────────────────── */

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Outer shell — fills available space, centers the canvas box */
#canvas-outer {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #0a0a0a;
}

#canvas-container {
  position: relative;
  width: 100%;
  /* align-self: stretch makes it fill canvas-outer's full height in free mode,
     regardless of the parent's align-items: center */
  align-self: stretch;
  background: #000;
  cursor: grab;
  overflow: hidden;
}

/* Ratio-locked: JS sets explicit px dimensions, CSS re-centers and adds edge */
#canvas-container.ratio-locked {
  align-self: center;   /* override stretch — let JS dimensions control size */
  width: auto;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.07),
    0 12px 60px rgba(0,0,0,0.7);
}

#canvas-container:active { cursor: grabbing; }

#render-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Overlays */
#noise-overlay,
#vignette-overlay,
#light-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#noise-overlay  { mix-blend-mode: overlay; opacity: 0; }
#vignette-overlay { background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.85) 100%); }
#light-overlay  { opacity: 0; }

#lens-flare-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
}

/* Drop overlay */
#drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(108, 99, 255, 0.1);
  border: 1.5px dashed var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(2px);
}

#drop-overlay.hidden { display: none; }

.drop-message {
  color: #fff;
  font-size: var(--fs-base);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */

#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-2);
  border-left: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-2);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon-wrap {
  width: 24px;
  height: 24px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon {
  color: var(--accent);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-name {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: #f0ede6;
  line-height: 1;
  letter-spacing: -0.02em;
}

.logo-tagline {
  font-size: var(--fs-2xs);
  color: #555;
  margin-top: 3px;
  line-height: 1;
}

#sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-5) transparent;
}

#sidebar-scroll::-webkit-scrollbar { width: 3px; }
#sidebar-scroll::-webkit-scrollbar-thumb { background: var(--bg-5); border-radius: var(--radius-full); }

#sidebar-footer {
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  border-top: 1px solid var(--border-soft);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.footer-credit {
  font-size: var(--fs-2xs);
  color: var(--text-muted);
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}

/* ── Sections ──────────────────────────────────────────────────────────────── */

.panel-section {
  border-bottom: 1px solid var(--border-soft);
}

.section-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px var(--sp-4);
  cursor: pointer;
  user-select: none;
  background: var(--bg-2);
  transition: background var(--transition);
}

.section-header:hover { background: var(--bg-3); }

.section-title {
  flex: 1;
  font-weight: 600;
  font-size: var(--fs-2xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.section-badge {
  font-size: var(--fs-2xs);
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-4);
  color: var(--text-muted);
  border: 1px solid var(--border);
  letter-spacing: 0.04em;
}

.section-reset {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--fs-xs);
  padding: var(--sp-1);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  transition: color var(--transition), background var(--transition);
}
.section-reset:hover { color: var(--text); background: var(--bg-4); }

.section-chevron {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  display: inline-flex;
  align-items: center;
  transition: transform var(--transition);
}
.section-chevron.rotated { transform: rotate(-90deg); }

.section-body {
  padding: 14px var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #111111; /* fallback */
}

/* Tons distintos por accordion — padrão zigzag escuro/claro */
.panel-section:nth-child(1) .section-body { background: #0c0c0c; } /* Imagem     */
.panel-section:nth-child(2) .section-body { background: #1e1e1e; } /* Transform  */
.panel-section:nth-child(3) .section-body { background: #0f0f0f; } /* Blur/DOF  */
.panel-section:nth-child(4) .section-body { background: #1b1b1b; } /* Background */
.panel-section:nth-child(5) .section-body { background: #0d0d0d; } /* Effects    */
.panel-section:nth-child(6) .section-body { background: #181818; } /* Export     */
.panel-section:nth-child(7) .section-body { background: #111111; } /* Presets    */

.section-body.collapsed { display: none; }

.section-disabled .section-body { opacity: 0.4; pointer-events: none; }
.section-disabled .section-header { cursor: default; }

/* ── Controls ──────────────────────────────────────────────────────────────── */

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-xs);
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: -0.01em;
}

.control-value {
  margin-left: auto;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-2xs);
  min-width: 30px;
  text-align: right;
}

.control-unit {
  color: var(--text-muted);
  font-size: var(--fs-2xs);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* Native range — hidden once JS wraps it; keep as fallback */
input[type="range"] {
  -webkit-appearance: none;
  flex: 1;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--bg-5);
  cursor: pointer;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}

/* ── Ruler / camera-dial slider ────────────────────────────────────────────── */

.ruler-wrap {
  flex: 1;
  min-width: 0; /* prevent flex overflow */
}

.ruler-canvas {
  display: block;
  width: 100%;
  height: 26px;
  cursor: ew-resize;
  border-radius: var(--radius-sm);
  background: var(--bg-5);
  user-select: none;
  touch-action: none;
}

/* ── Number input + custom spinners ────────────────────────────────────────── */

/* Hide browser native spinners on all platforms */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Wrapper becomes the visual box */
.num-wrap {
  display: flex;
  width: 54px;
  flex-shrink: 0;
  height: var(--input-h);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.num-wrap:hover          { border-color: var(--text-muted); }
.num-wrap:focus-within   { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* Input inside wrapper — no individual border */
input[type="number"] {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: var(--fs-2xs);
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  padding: 0 2px;
  text-align: center;
  outline: none;
}

/* Spinner column */
.num-spinners {
  display: flex;
  flex-direction: column;
  width: 16px;
  flex-shrink: 0;
  border-left: 1px solid var(--border-soft);
}

.num-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color var(--transition), background var(--transition);
}

.num-btn i { font-size: 7px; pointer-events: none; }

.num-btn:first-child { border-bottom: 1px solid var(--border-soft); }

.num-btn:hover  { color: var(--accent); background: var(--accent-dim); }
.num-btn:active { background: var(--accent-soft); }

/* Color input */
input[type="color"] {
  -webkit-appearance: none;
  width: 32px;
  height: var(--input-h);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  cursor: pointer;
  padding: 3px;
  transition: border-color var(--transition);
}

input[type="color"]:hover { border-color: var(--text-muted); }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: var(--radius-xs); }

/* ── Switch (Toggle) ─────────────────────────────────────────────────────────── */

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 22px;
}

.toggle-label {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

/* The label acts as the clickable wrapper */
.switch {
  flex-shrink: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}

/* Hide native checkbox — keep it accessible/functional */
.switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* Track */
.switch-track {
  position: relative;
  width: 32px;
  height: 16px;
  border-radius: 9999px;
  background: var(--bg-5);
  border: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}

.switch:hover .switch-track {
  border-color: var(--text-muted);
}

.switch input:checked + .switch-track {
  background: var(--accent);
  border-color: var(--accent);
}

/* Thumb */
.switch-thumb {
  position: absolute;
  top: 50%;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-dim);
  transform: translateY(-50%);
  transition: transform var(--transition), background var(--transition), left var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.switch input:checked + .switch-track .switch-thumb {
  left: calc(100% - 14px);
  background: #1a0a1a;
}

/* Focus ring (keyboard nav) */
.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Select */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: var(--bg-3);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 256 256'%3E%3Cpath fill='%23525252' d='M213.66 101.66a8 8 0 0 1-11.32 0L128 27.31 53.66 101.66a8 8 0 0 1-11.32-11.32l80-80a8 8 0 0 1 11.32 0l80 80a8 8 0 0 1 0 11.32Zm-11.32 52.68L128 228.69 53.66 154.34a8 8 0 0 0-11.32 11.32l80 80a8 8 0 0 0 11.32 0l80-80a8 8 0 0 0-11.32-11.32Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: var(--fs-xs);
  font-family: inherit;
  min-height: 32px;
  padding: 8px 30px 8px var(--sp-3);
  outline: none;
  cursor: pointer;
  flex: 1;
  transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}

select:hover {
  border-color: var(--text-muted);
  background-color: var(--bg-4);
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
  background-color: var(--bg-4);
  outline: none;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */

.btn-primary {
  width: 100%;
  height: 40px;
  background: var(--accent);
  color: #1a0a1a; /* dark purple — 8.8:1 contrast on #D6A1D6 (WCAG AA ✓) */
  border: none;
  border-radius: var(--radius);
  font-size: var(--fs-xs);
  font-family: inherit;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
}
.btn-primary:hover:not(:disabled) { opacity: 0.88; }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* Export actions row */
.export-actions {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.export-actions .btn-primary {
  width: auto;
  flex: 1;
}

/* Icon-only square button */
.btn-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-sm);
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.btn-icon:hover:not(:disabled) {
  color: var(--text);
  background: var(--bg-5);
  border-color: var(--text-muted);
}
.btn-icon:disabled { opacity: 0.5; cursor: not-allowed; }

/* Copy button states */
.btn-icon.is-loading i { animation: spin 0.7s linear infinite; }
.btn-icon.is-success {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}
.btn-icon.is-error {
  color: #e05a5a;
  border-color: rgba(224,90,90,0.5);
  background: rgba(224,90,90,0.08);
}

@keyframes spin { to { transform: rotate(360deg); } }

.btn-secondary {
  width: 100%;
  height: 32px;
  background: var(--bg-4);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--fs-xs);
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-secondary:hover { background: var(--bg-5); color: var(--text); border-color: var(--text-muted); }

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--fs-sm);
  padding: var(--sp-1) 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  transition: color var(--transition), background var(--transition);
}
.btn-ghost:hover { color: var(--text-dim); background: var(--bg-4); }

.hidden { display: none !important; }

/* ── Dropzone ──────────────────────────────────────────────────────────────── */

.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 22px var(--sp-3);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--bg-3);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.dropzone-icon {
  font-size: var(--fs-lg);
  margin-bottom: var(--sp-2);
  color: var(--text-muted);
  display: flex;
  justify-content: center;
  transition: color var(--transition);
}
.dropzone:hover .dropzone-icon,
.dropzone.dragover .dropzone-icon { color: var(--accent); }

.dropzone-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0;
  transition: color var(--transition);
}
.dropzone:hover .dropzone-label,
.dropzone.dragover .dropzone-label { color: var(--text); }

.dropzone-sublabel {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: 1.5;
  margin: 2px 0 0;
  transition: color var(--transition);
}
.dropzone:hover .dropzone-sublabel,
.dropzone.dragover .dropzone-sublabel { color: var(--text-dim); }

.dropzone-formats {
  font-size: var(--fs-2xs);
  color: var(--text-muted);
  margin-top: var(--sp-1);
  letter-spacing: 0.03em;
  transition: color var(--transition);
}
.dropzone:hover .dropzone-formats,
.dropzone.dragover .dropzone-formats { color: var(--text-dim); }

.dropzone.has-image {
  border-style: solid;
  border-color: var(--accent);
  padding: var(--sp-3);
  background: var(--accent-dim);
}

#image-name {
  font-size: var(--fs-2xs);
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  display: block;
}

/* ── Color row ─────────────────────────────────────────────────────────────── */

.color-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.color-row label { font-size: var(--fs-2xs); color: var(--text-muted); min-width: 14px; }


/* ── Gradient presets swatches ─────────────────────────────────────────────── */

#gradient-presets {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--sp-1);
}

.gradient-swatch {
  height: 24px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.gradient-swatch:hover {
  transform: scaleY(1.12);
  border-color: rgba(255,255,255,0.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

/* ── Preset grid ───────────────────────────────────────────────────────────── */

#preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}

.preset-btn {
  position: relative;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: var(--fs-2xs);
  font-family: inherit;
  font-weight: 500;
  padding: var(--sp-2) var(--sp-3);
  cursor: pointer;
  text-align: left;
  letter-spacing: -0.01em;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-btn:hover { border-color: var(--accent); background: var(--accent-dim); color: var(--text); }

.preset-del {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--danger);
  font-size: var(--fs-2xs);
  padding: 1px 2px;
  opacity: 0;
  transition: opacity var(--transition);
  display: inline-flex;
  align-items: center;
}

.preset-btn:hover .preset-del { opacity: 1; }

.save-preset-row {
  display: flex;
  gap: var(--sp-2);
}

.save-preset-row input[type="text"] {
  flex: 1;
  height: var(--input-h);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: var(--fs-2xs);
  font-family: inherit;
  padding: 0 var(--sp-2);
  outline: none;
  transition: border-color var(--transition);
}

.save-preset-row input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.save-preset-row button {
  height: var(--input-h);
  padding: 0 var(--sp-3);
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: var(--fs-2xs);
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--transition), color var(--transition);
}
.save-preset-row button:hover { border-color: var(--accent); color: var(--accent); }

/* ── Export section ────────────────────────────────────────────────────────── */

.export-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.export-row label { font-size: var(--fs-2xs); color: var(--text-dim); flex-shrink: 0; min-width: 74px; letter-spacing: -0.01em; }

/* ── Keyboard shortcut hints ───────────────────────────────────────────────── */

.shortcut-hints {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  row-gap: 6px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: var(--fs-2xs);
  color: var(--text-muted);
}

kbd {
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-2xs);
  padding: 1px 5px;
  font-family: 'Geist Mono', 'Fira Code', monospace;
  color: var(--text-dim);
  letter-spacing: 0;
}

/* ── Sub-controls ──────────────────────────────────────────────────────────── */

.sub-controls {
  padding-left: var(--sp-3);
  border-left: 1.5px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Floating canvas button ────────────────────────────────────────────────── */

.btn-canvas-float {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 40;
  width: 30px;
  height: 30px;
  background: rgba(10, 10, 10, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.25);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-2xs);
  opacity: 0;
  transition: color 0.15s ease, background 0.15s ease,
              border-color 0.15s ease, opacity 0.15s ease;
}

#canvas-container:hover .btn-canvas-float,
.btn-canvas-float.is-dirty {
  opacity: 1;
}

.btn-canvas-float:hover {
  color: rgba(255, 255, 255, 0.85);
  background: rgba(20, 20, 20, 0.85);
  border-color: rgba(255, 255, 255, 0.18);
}

/* ── Modal ─────────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 100%;
  max-width: 360px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-box p {
  font-size: var(--fs-xs);
  color: #888;
  line-height: 1.65;
  margin-bottom: 12px;
}

.modal-box s {
  color: #444;
  text-decoration: line-through;
  text-decoration-color: #555;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #1f1f1f;
  padding-top: 14px;
  margin-top: 8px;
  gap: 12px;
}

.modal-tagline {
  font-family: 'Geist Mono', monospace;
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #444;
}

.modal-credit {
  font-size: var(--fs-2xs);
  color: #555;
  white-space: nowrap;
}

.modal-link {
  font-family: 'Gochi Hand', cursive;
  font-size: var(--fs-sm);
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}

.modal-link:hover {
  color: #e8bde8;
}

/* ── Responsive: mobile ────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  #app { flex-direction: column; }

  #canvas-outer { flex: none; height: 55vh; }

  #sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-soft);
    flex: 1;
    overflow-y: auto;
  }

  #sidebar-scroll { overflow: visible; }
}
