@font-face {
  font-family: 'ABC Diatype';
  src: url('../fonts/ABCDiatype-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0a0a0a;
  --bg-2: #131313;
  --bg-3: #1e1e1e;
  --bg-4: #2e2e2e;
  --line: #383838;
  --line-2: #555555;
  --fg: #ffffff;
  --fg-dim: #c8c8c8;
  --fg-mute: #8a8a8a;
  --accent: #ffffff;
  --cyan: #00d4ff;
  --side-w: 320px;
  --r: 4px;
  --overlay-bg: rgba(0, 0, 0, 0.75);
  --overlay-bg-strong: rgba(20, 20, 20, 0.9);
  --modal-backdrop: rgba(0, 0, 0, 0.85);
}

body.light {
  --bg: #f5f5f5;
  --bg-2: #ffffff;
  --bg-3: #ececec;
  --bg-4: #dcdcdc;
  --line: #d2d2d2;
  --line-2: #a8a8a8;
  --fg: #0a0a0a;
  --fg-dim: #3a3a3a;
  --fg-mute: #6a6a6a;
  --accent: #000000;
  --overlay-bg: rgba(255, 255, 255, 0.85);
  --overlay-bg-strong: rgba(245, 245, 245, 0.92);
  --modal-backdrop: rgba(255, 255, 255, 0.88);
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: 'ABC Diatype', system-ui, -apple-system, sans-serif;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 12px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

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

.app {
  display: grid;
  grid-template-columns: 1fr var(--side-w);
  height: 100vh;
  width: 100vw;
}

/* ─── Stage ─────────────────────────────────────────────── */
.stage {
  position: relative;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 28px;
}

.canvas-wrap {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 0 0 1px var(--line), 0 18px 50px -20px rgba(0,0,0,0.55);
}

.drop-overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay-bg-strong);
  border: 2px dashed var(--accent);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  pointer-events: none;
}

.drop-overlay.active { display: flex; }

.drop-overlay-inner {
  text-align: center;
}

.drop-icon {
  font-size: 48px;
  font-weight: 100;
  color: var(--accent);
  margin-bottom: 12px;
  line-height: 1;
}

.drop-text {
  font-size: 14px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stage-info {
  position: absolute;
  bottom: 12px;
  left: 12px;
  color: var(--fg-mute);
  font-size: 11px;
  letter-spacing: 0.04em;
}

/* ─── Sidebar ──────────────────────────────────────────── */
.sidebar {
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.sidebar-header h1 {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.back-link {
  color: var(--fg-dim);
  text-decoration: none;
  font-size: 16px;
  padding: 2px 8px;
  border-radius: var(--r);
}

.back-link:hover { color: var(--fg); background: var(--bg-3); }

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
}

.tab {
  flex: 1;
  background: none;
  border: none;
  padding: 12px;
  color: var(--fg-mute);
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 11px;
  border-bottom: 2px solid transparent;
  transition: color 0.12s, border-color 0.12s;
}

.tab.active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

.tab:hover:not(.active) { color: var(--fg-dim); }

.tab-pane {
  flex: 1;
  overflow-y: auto;
  display: none;
  padding: 16px;
}

.tab-pane.active { display: block; }

.tab-pane::-webkit-scrollbar { width: 6px; }
.tab-pane::-webkit-scrollbar-track { background: transparent; }
.tab-pane::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

/* ─── Groups & controls ─────────────────────────────────── */
.group {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.group:last-child { border-bottom: none; }

.label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin-bottom: 8px;
}

.label-mini {
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--fg-mute);
  margin-bottom: 6px;
}

/* Sub-section heading inside a group (e.g. Audio → Reactivity). Carries a
   hairline divider so the two halves of a merged group stay visually distinct. */
.sub-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin: 16px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.row {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Dropzone */
.dropzone {
  border: 1px dashed var(--line-2);
  border-radius: var(--r);
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  margin-bottom: 8px;
}

.dropzone:hover {
  border-color: var(--fg-dim);
  background: var(--bg-3);
}

.dropzone.over {
  border-color: var(--accent);
  background: var(--bg-3);
}

.dropzone-label {
  font-size: 12px;
  margin-bottom: 4px;
}

.dropzone-hint {
  font-size: 10px;
  color: var(--fg-mute);
}

.source-row { gap: 6px; }
.source-row .btn-small { flex: 1; }

/* Segmented control */
.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  background: var(--bg-3);
  padding: 2px;
  border-radius: var(--r);
}

.seg button {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  padding: 6px 8px;
  color: var(--fg-mute);
  cursor: pointer;
  border-radius: 2px;
  font-size: 11px;
  letter-spacing: 0.02em;
  transition: background 0.1s, color 0.1s;
}

.seg button:hover:not(.active) { color: var(--fg-dim); }

.seg button.active {
  background: var(--bg-4);
  color: var(--fg);
}

/* Sliders */
.slider-row {
  margin-bottom: 10px;
}
.slider-row:last-child { margin-bottom: 0; }

.slider-row label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  color: var(--fg-dim);
  margin-bottom: 4px;
}

.slider-row label .val {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

input[type=range] {
  width: 100%;
  height: 18px;
  background: transparent;
  -webkit-appearance: none;
  cursor: pointer;
}

input[type=range]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--line-2);
  border-radius: 1px;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--fg);
  border-radius: 50%;
  margin-top: -5px;
  cursor: pointer;
}

input[type=range]::-moz-range-track {
  height: 2px;
  background: var(--line-2);
  border-radius: 1px;
}

input[type=range]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--fg);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

/* Toggles */
.toggle-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  font-size: 11px;
  color: var(--fg-dim);
}

.toggle input {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}

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

.toggle input:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0;
  width: 5px;
  height: 9px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Buttons */
.btn-primary {
  width: 100%;
  background: var(--bg-3);
  color: var(--fg);
  border: 1px solid var(--line-2);
  padding: 9px;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 0.12s, border-color 0.12s;
  margin-bottom: 6px;
}

.btn-primary:last-child { margin-bottom: 0; }

.btn-primary:hover {
  background: var(--bg-4);
  border-color: var(--fg-mute);
}

.btn-primary:active { background: var(--line-2); }

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary.recording {
  background: #3a1a1a;
  border-color: #8a3333;
  color: #ff9090;
}

.btn-small {
  background: var(--bg-3);
  color: var(--fg-dim);
  border: 1px solid var(--line-2);
  padding: 6px 10px;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 11px;
  transition: background 0.1s, color 0.1s;
}

.btn-small:hover { background: var(--bg-4); color: var(--fg); }
.btn-small.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.select {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  padding: 7px;
  border-radius: var(--r);
  color: var(--fg);
  cursor: pointer;
}

.custom-res {
  margin-top: 6px;
}

.custom-res input[type=number] {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  padding: 6px;
  border-radius: var(--r);
  color: var(--fg);
}

.hint {
  font-size: 10px;
  color: var(--fg-mute);
  line-height: 1.5;
  margin-top: 6px;
}

/* Color */
.color-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: end;
}

.swap-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  color: var(--fg-dim);
  cursor: pointer;
  padding: 0;
}
.swap-btn:hover {
  color: var(--fg);
  border-color: var(--fg);
}

.swatch {
  width: 100%;
  height: 32px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  cursor: pointer;
  padding: 0;
}

.swatch:hover { border-color: var(--fg-dim); }

/* ─── Color picker popover ─────────────────────────────── */
.picker {
  position: fixed;
  width: 220px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 10px;
  z-index: 9000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.picker-sv {
  position: relative;
  width: 100%;
  height: 140px;
  border-radius: var(--r);
  cursor: crosshair;
  margin-bottom: 8px;
  overflow: hidden;
}

.picker-sv-grad-s {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, #fff, transparent);
}

.picker-sv-grad-v {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, #000, transparent);
}

.picker-sv-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}

.picker-hue {
  position: relative;
  width: 100%;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  cursor: crosshair;
  margin-bottom: 8px;
}

.picker-hue-handle {
  position: absolute;
  top: -2px;
  width: 4px;
  height: 16px;
  background: #fff;
  border: 1px solid #000;
  border-radius: 2px;
  transform: translateX(-50%);
  pointer-events: none;
}

.picker-hex {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  padding: 6px 8px;
  border-radius: var(--r);
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  margin-bottom: 8px;
}

.picker-hex:focus {
  outline: none;
  border-color: var(--fg-dim);
}

.picker-presets {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
}

.picker-preset {
  aspect-ratio: 1;
  border: 1px solid var(--line-2);
  border-radius: 2px;
  cursor: pointer;
  padding: 0;
}

.picker-preset:hover { border-color: var(--fg); }

/* ─── Variations modal ─────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--modal-backdrop);
  cursor: pointer;
}

.modal-inner {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 20px;
  max-width: min(900px, 92vw);
  max-height: 92vh;
  width: 900px;
}

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

.modal-header h2 {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-mute);
  font-weight: 500;
}

.modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.modal-tile {
  aspect-ratio: 1;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.12s, transform 0.12s;
}

.modal-tile:hover {
  border-color: var(--fg);
  transform: scale(1.01);
}

.modal-tile canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
  box-shadow: none;
}

.modal-tile-meta {
  position: absolute;
  bottom: 4px;
  left: 6px;
  font-size: 9px;
  color: var(--fg-mute);
  background: rgba(0,0,0,0.6);
  padding: 1px 5px;
  border-radius: 2px;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transition: opacity 0.12s;
}

.modal-tile:hover .modal-tile-meta { opacity: 1; }

/* ─── Toggle list (Invert / Outline / Gradient) ───────── */
.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chip {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--bg-3);
  color: var(--fg-dim);
  border: 1px solid var(--line);
  padding: 11px 14px;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-align: left;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.chip-icon {
  flex-shrink: 0;
  display: block;
}
.chip:hover {
  background: var(--bg-4);
  color: var(--fg);
}
.chip.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.chip.hidden { display: none; }

/* ─── Color combo presets ─────────────────────────────── */
.combo-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}
.combo {
  display: flex;
  height: 38px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  background: transparent;
  transition: border-color 0.12s, transform 0.12s;
}
.combo:hover {
  border-color: var(--fg);
  transform: scale(1.02);
}
.combo span {
  flex: 1;
  display: block;
}

/* ─── Strips presets + controls ───────────────────────── */
.strips-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.strips-presets button {
  background: var(--bg-3);
  color: var(--fg);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 12px 10px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: -0.02em;
  text-align: left;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.strips-presets button:hover {
  border-color: var(--fg);
  background: var(--bg-4);
}
.strips-presets button.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.select-inline {
  padding: 5px 7px;
  font-size: 11px;
  margin-top: 2px;
}

.slider-row.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.slider-row.toggle-row label {
  margin-bottom: 0;
  flex: 1;
}

.mini-toggle {
  width: 32px;
  height: 18px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  padding: 0;
  cursor: pointer;
  position: relative;
  transition: background 0.12s, border-color 0.12s;
}
.mini-toggle span {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  background: var(--fg-mute);
  border-radius: 50%;
  transition: transform 0.14s, background 0.14s;
}
.mini-toggle[aria-pressed="true"] {
  background: var(--fg);
  border-color: var(--fg);
}
.mini-toggle[aria-pressed="true"] span {
  background: var(--bg);
  transform: translateX(14px);
}

/* ─── Tooltips (JS-driven, position: fixed avoids scroll clipping) ── */
.tooltip {
  position: fixed;
  background: var(--fg);
  color: var(--bg);
  padding: 7px 9px;
  border-radius: 4px;
  border: 1px solid var(--line-2);
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.01em;
  text-transform: none;
  font-family: inherit;
  max-width: 240px;
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.12s, transform 0.12s;
}
.tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}
[data-tip] {
  cursor: help;
}
[data-tip] input {
  cursor: pointer;
}

/* ─── Source preview ────────────────────────────────── */
.source-preview-wrap {
  margin-top: 10px;
}
.source-preview {
  position: relative;
  width: 100%;
  height: 130px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.source-preview canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: none;
}
.source-preview-empty {
  color: var(--fg-mute);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.source-preview canvas + .source-preview-empty,
.source-preview.has-content .source-preview-empty {
  display: none;
}

/* ─── Rect editor overlay ──────────────────────────────── */
.rect-editor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
}
.rect-editor.active {
  display: block;
  pointer-events: auto;
}
.rect-handle {
  position: absolute;
  border: 1px dashed var(--cyan);
  background: rgba(0, 212, 255, 0.05);
  cursor: move;
  box-sizing: border-box;
  transition: background 0.1s, border-color 0.1s;
}
.rect-handle:hover {
  border-style: solid;
  background: rgba(0, 212, 255, 0.12);
}
.rect-handle .grip {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: var(--cyan);
  cursor: nwse-resize;
  border-radius: 1px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}

/* ─── Canvas overlay action button (Edit rectangles) ─── */
.canvas-action {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--overlay-bg);
  color: var(--fg);
  border: 1px solid var(--line-2);
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  z-index: 40;
}
.canvas-action:hover {
  background: var(--overlay-bg);
  filter: brightness(1.15);
  border-color: var(--cyan);
}
.canvas-action.active {
  background: var(--cyan);
  color: #000;
  border-color: var(--cyan);
}

/* ─── Sticky action bar at the bottom of the sidebar ── */
.sticky-actions {
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.sticky-actions .btn-primary {
  flex: 1;
  margin-bottom: 0;
}

.btn-variations {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-variations .dice {
  transition: transform 0.2s;
}
.btn-variations:hover .dice {
  transform: rotate(-12deg);
}

/* ─── Audio group ──────────────────────────────────────── */
.audio-status {
  float: right;
  font-size: 10px;
  color: var(--fg-mute);
  letter-spacing: 0.04em;
}
.audio-status.live { color: var(--cyan); }

.audio-tracks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.audio-tracks button {
  background: var(--bg-3);
  border: none;
  color: var(--fg-dim);
  padding: 8px 4px;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 0.01em;
  transition: background 0.1s, color 0.1s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audio-tracks button:hover { color: var(--fg); }
.audio-tracks button.active {
  background: var(--bg-4);
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--line-2);
}

.audio-transport {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.audio-play {
  flex: 0 0 28px;
  height: 28px;
  background: var(--bg-3);
  border: none;
  border-radius: var(--r);
  color: var(--fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.audio-play:hover { background: var(--bg-4); }
.audio-seek {
  flex: 1;
  margin: 0;
}
.audio-time {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--fg-mute);
  font-variant-numeric: tabular-nums;
}

.sound-analysis { margin-top: 6px; }
.audio-viz {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 8px;
  background: var(--bg-3);
  border-radius: var(--r);
}

.audio-drop {
  margin-top: 8px;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: var(--r);
  text-align: center;
  font-size: 10px;
  color: var(--fg-mute);
  letter-spacing: 0.05em;
  text-transform: lowercase;
  transition: border-color 0.1s, color 0.1s, background 0.1s;
}
.audio-drop.over {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(0, 212, 255, 0.06);
}

/* ─── Modulator panel ─────────────────────────────────── */
.mod-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mod-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px 8px;
  background: var(--bg-2);
  border-radius: var(--r);
  box-shadow: inset 0 0 0 1px transparent;
  transition: box-shadow 0.12s;
}
.mod-row-head {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.02em;
}
.mod-row-head .mod-depth-val {
  color: var(--fg-mute);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.audio-strips-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: var(--bg-3);
  border: none;
  color: var(--fg-dim);
  padding: 8px 10px;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 0.02em;
  margin-bottom: 10px;
  text-align: left;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}
.audio-strips-toggle:hover { color: var(--fg); }
.audio-strips-toggle .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-2);
  flex-shrink: 0;
  transition: background 0.12s, box-shadow 0.12s;
}
.audio-strips-toggle.active {
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.audio-strips-toggle.active .dot {
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
}

.noise-type-label {
  color: var(--cyan);
  font-size: 11px;
  letter-spacing: 0.04em;
}
.noise-hint {
  font-size: 10px;
  color: var(--fg-mute);
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}
.noise-hint b { color: var(--fg-dim); font-weight: 700; }

.mod-hint {
  color: var(--fg-mute);
  font-size: 10px;
  letter-spacing: 0.02em;
  margin-left: 8px;
}
.mod-depth-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mod-row .mod-depth { flex: 1; width: 100%; margin: 0; }

/* ─── Modulation matrix controls ───────────────────────── */
.mod-src, .mod-tgt {
  flex: 1;
  min-width: 0;
  background: var(--bg-3);
  color: var(--fg);
  border: none;
  border-radius: var(--r);
  padding: 4px 6px;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.02em;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.mod-src:hover, .mod-tgt:hover { background: var(--bg-4); }
.mod-src:focus, .mod-tgt:focus { outline: 1px solid var(--fg-mute); }
.mod-arrow { color: var(--fg-mute); font-size: 11px; flex-shrink: 0; }
.mod-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  color: var(--fg-mute);
  border-radius: var(--r);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.mod-icon:hover { background: var(--bg-3); color: var(--fg); }
.mod-depth-val {
  color: var(--fg-mute);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  min-width: 26px;
  text-align: right;
}
.mod-adv-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 6px 2px 2px;
  border-top: 1px solid var(--bg-4);
}
.mod-adv-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 80px;
  font-size: 10px;
  color: var(--fg-mute);
}
.mod-adv-field input { width: 100%; margin: 0; }
.mod-adv-check {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--fg-dim);
  cursor: pointer;
}
.mod-add {
  width: 100%;
  margin-top: 8px;
  padding: 7px 10px;
  background: var(--bg-3);
  border: 1px dashed var(--bg-4);
  color: var(--fg-mute);
  border-radius: var(--r);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.02em;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.mod-add:hover { background: var(--bg-4); color: var(--fg); border-color: var(--fg-mute); }
.mod-actions { display: flex; gap: 6px; margin-top: 8px; }
.mod-actions .mod-add { flex: 1; margin-top: 0; }
.sub-hint { color: var(--fg-mute); font-size: 10px; letter-spacing: 0; text-transform: none; }

/* ─── Mobile fallback ──────────────────────────────────── */
@media (max-width: 720px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 40vh 1fr;
  }
  .sidebar {
    border-left: none;
    border-top: 1px solid var(--line);
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .stage {
    min-height: 0;
  }
  /* The 3 track buttons can wrap on very narrow phones; let the grid breathe. */
  .audio-tracks {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  /* Bigger touch targets for the audio toggle dots. */
  .audio-strips-toggle {
    padding: 12px 10px;
  }
  /* Source preview can be shorter on mobile to free room for controls. */
  .source-preview {
    height: 140px;
  }
}
