/* ============================================================
   Dither — Minimal Monochrome Theme
   ============================================================ */

:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --surface-2: #f4f4f0;
  --border: #e6e6df;
  --border-strong: #d4d4cb;
  --text: #0c0c0c;
  --text-muted: #6b6b66;
  --text-soft: #9a9a93;
  --accent: #0c0c0c;
  --accent-soft: #1a1a1a;
  --danger: #c0392b;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --sidebar-w: 340px;
  --topbar-h: 48px;

  --t: 160ms cubic-bezier(.2,.7,.2,1);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

/* Bulletproof hidden — overrides component CSS like .drop { display: flex } */
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; }
input, select, button { font: inherit; color: inherit; }
code { font-family: var(--font-mono); font-size: 0.9em; }

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}
.brand-name { font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { color: var(--text-soft); font-size: 11px; }

.status { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-muted); }
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

/* ===== LAYOUT ===== */
.layout {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  min-height: 0;
}

/* ===== STAGE ===== */
.stage {
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
  min-width: 0;
  /* min-height 0 lets the canvas letterbox instead of forcing its
     intrinsic height and overflowing the fixed-height layout */
  min-height: 0;
  position: relative;
}
.stage-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.stage-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-soft);
  letter-spacing: 0.02em;
}
.size-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.size-controls .select {
  width: auto;
  padding: 5px 8px;
  font-size: 11px;
}
.dim-input {
  width: 64px;
  padding: 5px 7px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  outline: none;
  transition: var(--t);
  -moz-appearance: textfield;
}
.dim-input:hover { border-color: var(--border-strong); }
.dim-input:focus { border-color: var(--accent); }
.dim-input::-webkit-outer-spin-button,
.dim-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.dim-sep { color: var(--text-soft); font-size: 11px; }

.canvas-wrap {
  flex: 1;
  min-height: 0; /* same flexbox min-size escape as .stage */
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background-image:
    linear-gradient(45deg, var(--surface-2) 25%, transparent 25%),
    linear-gradient(-45deg, var(--surface-2) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--surface-2) 75%),
    linear-gradient(-45deg, transparent 75%, var(--surface-2) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.canvas-wrap canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  background: transparent;
  object-fit: contain;
}
.canvas-empty {
  position: absolute;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: var(--text-soft);
  text-align: center;
  font-size: 12px;
  pointer-events: none;
}
.canvas-empty[hidden] { display: none; }
.canvas-empty p { margin: 0; max-width: 200px; }

/* Video HUD */
.video-hud {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.video-hud[hidden] { display: none; }
.video-hud .time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.video-hud input[type="range"] { flex: 1; }

/* ===== SEGMENTED CONTROL ===== */
.seg {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 1px;
}
.seg.seg-2 { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
.seg.seg-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; width: 100%; }
.seg.seg-4 { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; }
.seg.seg-5 { display: grid; grid-template-columns: repeat(5, 1fr); width: 100%; }
.seg.seg-5 .seg-btn { padding: 5px 4px; font-size: 10.5px; }
.seg-btn {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  transition: var(--t);
  white-space: nowrap;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active {
  background: var(--accent);
  color: #fff;
}

/* ===== ICON BUTTON ===== */
.icon-btn {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text);
  transition: var(--t);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn.sm { width: 24px; height: 24px; }

/* ===== SIDEBAR ===== */
.sidebar {
  border-left: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  overflow: hidden;
  /* Explicit height detaches the sidebar from grid-row auto-sizing,
     which otherwise expands to fit content and bypasses inner scroll. */
  height: calc(100vh - var(--topbar-h));
}
.sidebar-scroll {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 64px; /* breathing room past the last panel */
}
.sidebar-scroll::-webkit-scrollbar { width: 8px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ===== PANELS ===== */
.panel { border-bottom: 1px solid var(--border); }
.panel:last-child { border-bottom: 0; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  transition: var(--t);
}
.panel-head:hover { background: var(--surface-2); }
.panel-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.panel-title .muted { color: var(--text-soft); font-weight: 500; }
.chev {
  width: 8px; height: 8px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform var(--t);
}
.panel.open .chev { transform: rotate(45deg); }
.panel-body {
  display: none;
  padding: 6px 16px 20px;
  flex-direction: column;
  gap: 18px;
}
.panel.open .panel-body { display: flex; }

.hint { margin: 0; font-size: 11px; color: var(--text-muted); }
.hint code { background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }

/* ===== ROWS ===== */
.row { display: flex; flex-direction: column; gap: 8px; }
.row-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 1px; }

/* Source / mode / ink pane wrappers hold many rows but are single children
   of .panel-body — give their contents the same rhythm as the panel itself,
   so labels never crowd the control above them. */
[data-source-pane]:not([hidden]):not(.drop):not(.demo-row),
[data-mode-pane]:not([hidden]),
div[data-ink-pane]:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.lbl {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}
.val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
}

.toggle-row { flex-direction: row; align-items: center; justify-content: space-between; }
.color-row { flex-direction: row; align-items: center; justify-content: space-between; }

/* ===== INPUTS ===== */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 16px;
  background: transparent;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--border-strong);
  border-radius: 2px;
}
input[type="range"]::-moz-range-track {
  height: 2px;
  background: var(--border-strong);
  border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  background: var(--accent);
  border: 2px solid var(--surface);
  border-radius: 50%;
  margin-top: -5px;
  box-shadow: 0 0 0 1px var(--accent);
  transition: transform var(--t);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px;
  background: var(--accent);
  border: 2px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--accent);
}

.select, .text-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text);
  outline: none;
  transition: var(--t);
}
.select:hover, .text-input:hover { border-color: var(--border-strong); }
.select:focus, .text-input:focus { border-color: var(--accent); }
.text-input-multi {
  resize: vertical;
  min-height: 64px;
  max-height: 200px;
  font-family: var(--font-sans);
  line-height: 1.45;
}

/* Color */
.color-input { display: flex; align-items: center; gap: 8px; }
.color-input input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 24px; height: 24px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}
.color-input input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-input input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }
.color-input input[type="color"]::-moz-color-swatch { border: none; border-radius: 2px; }
.hex {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Switch */
.switch { position: relative; display: inline-block; width: 30px; height: 17px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--border-strong);
  border-radius: 999px;
  transition: var(--t);
}
.switch .track::after {
  content: "";
  position: absolute;
  width: 13px; height: 13px;
  left: 2px; top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: var(--t);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(13px); }

/* ===== DROPZONE ===== */
.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 20px 12px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  transition: var(--t);
  color: var(--text-muted);
}
.drop:hover { border-color: var(--accent); color: var(--text); }
.drop.is-drag { border-color: var(--accent); background: var(--surface-2); color: var(--text); }
.drop-text { font-size: 12px; font-weight: 500; color: var(--text); }
.drop-sub { font-size: 10px; color: var(--text-soft); letter-spacing: 0.02em; }
.drop.drop-sm { padding: 10px 12px; flex-direction: row; gap: 8px; justify-content: flex-start; }
.drop.drop-sm .drop-text { font-size: 11px; flex: 1; text-align: left; }
.drop input[type="file"] { display: none; }

/* ===== CONTEXT-AWARE (INERT) CONTROLS ===== */
/* Controls that do nothing in the current source/mode context are dimmed
   but stay interactive — the row's title attribute explains why. */
.is-inert {
  opacity: 0.35;
  transition: opacity 0.15s ease;
  cursor: help;
}
.is-inert:hover { opacity: 0.65; }

/* ===== DEMO IMAGES ===== */
.demo-row { margin-top: 10px; }
.demo-row .lbl { display: block; margin-bottom: 6px; }
.demo-thumbs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.demo-thumb {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  overflow: hidden;
  transition: var(--t);
}
.demo-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}
.demo-thumb span {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0 4px 4px;
  text-align: center;
}
.demo-thumb:hover,
.demo-thumb.is-active { border-color: var(--accent); }
.demo-thumb:hover span,
.demo-thumb.is-active span { color: var(--text); }

/* ===== SHAPE PICKERS ===== */
.shape-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}
.shape-tile {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--t);
  padding: 0;
  position: relative;
  overflow: hidden;
}
.shape-tile:hover { border-color: var(--accent); }
.shape-tile.is-active {
  border-color: var(--accent);
  background: var(--accent);
}
.shape-tile canvas, .shape-tile img {
  width: 70%; height: 70%; object-fit: contain;
}
.shape-tile.is-active canvas { filter: invert(1); }

.stepped-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.stepped-tile {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  cursor: pointer;
  position: relative;
  transition: var(--t);
  padding: 4px;
  overflow: hidden;
}
.stepped-tile:hover { border-color: var(--accent); }
.stepped-tile.is-drag { border-color: var(--accent); background: var(--surface-2); }
.stepped-tile canvas, .stepped-tile img { width: 70%; height: 60%; object-fit: contain; pointer-events: none; }
.stepped-tile .step-num {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-soft);
  line-height: 1;
}
.stepped-tile input[type="file"] { display: none; }
.stepped-reset {
  position: absolute;
  top: 2px; right: 2px;
  width: 14px; height: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.stepped-tile:hover .stepped-reset { display: flex; }
.stepped-reset:hover { color: var(--danger); border-color: var(--danger); }

/* Built-in palette popover (for stepped tiles) */
.shape-popover {
  position: absolute;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  display: grid;
  grid-template-columns: repeat(6, 24px);
  gap: 4px;
}
.shape-popover button {
  width: 24px; height: 24px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  cursor: pointer;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.shape-popover button:hover { border-color: var(--accent); }
.shape-popover button canvas { width: 70%; height: 70%; }
.shape-popover .pop-upload {
  grid-column: span 6;
  height: auto;
  padding: 6px;
  font-size: 11px;
  color: var(--text);
}

/* Buttons */
.btn-secondary {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: var(--t);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-secondary:hover { border-color: var(--accent); background: var(--surface-2); }
.btn-primary {
  width: 100%;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  transition: var(--t);
}
.btn-primary:hover { background: #000; }
.rec-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  display: inline-block;
}
.is-recording .rec-dot {
  animation: rec-pulse 1s ease-in-out infinite;
}
@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.btn-link {
  background: none;
  border: 0;
  color: var(--text);
  font-size: 11px;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}
.btn-link:hover { color: var(--accent); }

/* ===== GRADIENT STOPS ===== */
.gradient-stops {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  align-items: center;
}
.gradient-stops[hidden] { display: none; }
.gradient-stops input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}
.gradient-stops input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.gradient-stops input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }
.gradient-stops input[type="color"]::-moz-color-swatch { border: none; border-radius: 2px; }
.grad-dir-select { grid-column: span 4; }
.grad-presets {
  grid-column: span 4;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11px;
}

/* ===== PRESET ACTIONS ===== */
.preset-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 6px;
}
.preset-actions .btn-secondary { flex: 1; }

/* ===== PALETTE PRESETS ===== */
.palette-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.palette-chip {
  height: 24px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  position: relative;
  padding: 0;
  background: none;
  overflow: hidden;
  display: flex;
  transition: var(--t);
}
.palette-chip:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}
.palette-chip .swatch-bg,
.palette-chip .swatch-fg {
  flex: 1;
  height: 100%;
}
.palette-chip .palette-name {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  opacity: 0;
  transition: var(--t);
  pointer-events: none;
  letter-spacing: 0.02em;
}
.palette-chip:hover .palette-name { opacity: 1; }

/* ===== DUAL RANGE ===== */
.dual-range {
  position: relative;
  height: 16px;
}
.dual-range input[type="range"] {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: none;
  width: 100%;
}
.dual-range input[type="range"]::-webkit-slider-thumb { pointer-events: auto; }
.dual-range input[type="range"]::-moz-range-thumb { pointer-events: auto; }
.dual-range input[type="range"]::-webkit-slider-runnable-track { background: transparent; }
.dual-range input[type="range"]::-moz-range-track { background: transparent; }
.dual-range::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 7px;
  height: 2px;
  background: var(--border-strong);
  border-radius: 2px;
}

/* ===== AUDIO ===== */
.audio-wave {
  width: 100%;
  height: 56px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  display: block;
}
.audio-controls {
  display: flex; align-items: center; gap: 8px;
}
.audio-controls input[type="range"] { flex: 1; }
.audio-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}
.audio-status {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-soft);
}

/* ===== MOD MATRIX ROWS ===== */
#mod-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.mod-row {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mod-row.is-disabled { opacity: 0.45; }
.mod-row-top {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 4px;
  align-items: center;
}
.mod-row-top .select { padding: 4px 6px; font-size: 11px; }
.mod-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-sm);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 4px 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--t);
}
.mod-pill:hover { border-color: var(--accent); color: var(--text); }
.mod-pill.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.mod-remove {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-sm);
  width: 22px; height: 22px;
  font-size: 11px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: var(--t);
}
.mod-remove:hover { color: var(--danger); border-color: var(--danger); }
.meter {
  height: 3px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
}
.mod-amount {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mod-amount input[type="range"] { flex: 1; }
.mod-amount .val { min-width: 32px; text-align: right; }

/* ===== RESPONSIVE ===== */
/* Narrow / stacked layout: the artboard gets a fixed share of the
   viewport and the page itself scrolls — you can always scroll past the
   canvas to reach every control panel. */
@media (max-width: 880px) {
  :root { --sidebar-w: 100%; }
  body { overflow: auto; }
  .layout { display: block; height: auto; }
  .stage { height: auto; }
  .canvas-wrap { flex: none; height: 62vh; }
  .sidebar {
    border-left: 0;
    border-top: 1px solid var(--border);
    height: auto;
    overflow: visible;
  }
  .sidebar-scroll {
    position: static;
    overflow: visible;
    padding-bottom: 32px;
  }
}

/* ===== PRESET THUMBNAILS (LEI-38) ===== */
.preset-thumbs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}
.preset-thumb {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  overflow: hidden;
  transition: var(--t);
}
.preset-thumb canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
}
.preset-thumb span {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0 4px 4px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preset-thumb:hover,
.preset-thumb.is-active { border-color: var(--accent); }
.preset-thumb:hover span,
.preset-thumb.is-active span { color: var(--text); }

/* ===== UNDO / REDO (LEI-54) ===== */
.history-controls {
  display: flex;
  gap: 6px;
  margin-left: auto;
  margin-right: 16px;
}
.hist-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--t);
}
.hist-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
}
.hist-btn:disabled { opacity: 0.35; cursor: default; }
