/* ============================================================
   VocalForge design system — dark pro-audio theme
   Tokens -> components. 8px rhythm, WCAG-aware contrast.
   ============================================================ */

/* White is the default theme; [data-theme="dark"] is the black theme.
   One sober blue accent, neutral greys, semantic colours for state only. */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --bg-raised: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --surface-3: #e8eaee;
  --border: #dfe2e7;
  --border-strong: #c6ccd5;
  --text: #121519;
  --text-muted: #4a5260;
  --text-faint: #687080;
  --accent: #2563eb;
  --accent-hover: #1d4fd8;
  --accent-strong: #173ea5;
  --accent-text: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, .10);
  --on-accent: #ffffff;
  --accent-2: var(--accent-strong);
  --accent-grad: var(--accent);
  --teal: #0f8f80;
  --amber: #b86e00;
  --danger: #d42c3c;
  --ok: #178a3e;
  --teal-soft: rgba(15, 143, 128, .10);
  --amber-soft: rgba(184, 110, 0, .10);
  --danger-soft: rgba(212, 44, 60, .08);
  --ok-soft: rgba(23, 138, 62, .10);
  --on-amber: #ffffff;
  --seg-active: #ffffff;
  --topbar-bg: rgba(255, 255, 255, .86);
  --overlay: rgba(245, 246, 248, .9);
  --scrollbar: #c6ccd5;

  /* canvas drawing colours (pitch editor, waveforms, timeline, meters) */
  --cv-bg: #fbfbfc;
  --cv-row-in: #edf2fc;
  --cv-row-out: #f5f6f8;
  --cv-row-alt: #f1f2f5;
  --cv-label: #7a8290;
  --cv-label-strong: #343a45;
  --cv-grid: #e1e4e9;
  --cv-loop: rgba(37, 99, 235, .08);
  --cv-loop-line: rgba(37, 99, 235, .45);
  --cv-curve: rgba(74, 82, 96, .55);
  --cv-curve-tuned: #178a3e;
  --cv-ghost: rgba(104, 112, 128, .18);
  --cv-playhead: #121519;
  --cv-text: #121519;
  --note-in: #2563eb;
  --note-off: #e08a00;
  --note-fixed: #1f9d4b;
  --note-moved: #d42c3c;
  --cv-wave: #2563eb;
  --cv-before: #b4bac4;
  --cv-breath: rgba(224, 138, 0, .14);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-2: 0 12px 32px rgba(16, 24, 40, .14);
  --focus: 0 0 0 3px rgba(37, 99, 235, .35);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0c;
  --bg-raised: #121214;
  --surface: #17171a;
  --surface-2: #1f1f23;
  --surface-3: #2a2a2f;
  --border: #2b2b30;
  --border-strong: #3d3d44;
  --text: #ededf0;
  --text-muted: #a3a3ad;
  --text-faint: #8a8a94;
  --accent: #2563eb;
  --accent-hover: #3271f0;
  --accent-strong: #5b8ff5;
  --accent-text: #79a9ff;
  --accent-soft: rgba(96, 150, 255, .14);
  --teal: #2bb3a3;
  --amber: #e8a33d;
  --danger: #f0596a;
  --ok: #43c46f;
  --teal-soft: rgba(43, 179, 163, .14);
  --amber-soft: rgba(232, 163, 61, .14);
  --danger-soft: rgba(240, 89, 106, .14);
  --ok-soft: rgba(67, 196, 111, .14);
  --on-amber: #241600;
  --seg-active: #2a2a2f;
  --topbar-bg: rgba(11, 11, 12, .86);
  --overlay: rgba(11, 11, 12, .88);
  --scrollbar: #3d3d44;

  --cv-bg: #101012;
  --cv-row-in: #181b22;
  --cv-row-out: #131315;
  --cv-row-alt: #151517;
  --cv-label: #74747e;
  --cv-label-strong: #c4c4cc;
  --cv-grid: #26262b;
  --cv-loop: rgba(121, 169, 255, .10);
  --cv-loop-line: rgba(121, 169, 255, .5);
  --cv-curve: rgba(163, 163, 173, .55);
  --cv-curve-tuned: #43c46f;
  --cv-ghost: rgba(163, 163, 173, .2);
  --cv-playhead: #f5f5f7;
  --cv-text: #ededf0;
  --note-in: #4f8ff7;
  --note-off: #f5a524;
  --note-fixed: #43c46f;
  --note-moved: #f0596a;
  --cv-wave: #5b8ff5;
  --cv-before: #4a4a52;
  --cv-breath: rgba(245, 165, 36, .14);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, .55);
  --focus: 0 0 0 3px rgba(96, 150, 255, .45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }

/* themed scrollbars — slim grey sliders instead of the Windows defaults */
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 6px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
::-webkit-scrollbar-corner { background: transparent; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.grad {
  color: var(--accent-text);
}
.push-right { margin-left: auto; }
.hint { font-size: 13px; color: var(--text-faint); }
.mt { margin-top: 24px; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }

/* ---------------- top bar ---------------- */
.topbar {
  display: flex; align-items: center; gap: 32px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 100;
}
.logo { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 500; letter-spacing: .2px; }
.logo b { font-weight: 800; }
.logo svg { width: 26px; height: 26px; }

.steps { display: flex; gap: 8px; }
.step {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  color: var(--text-faint); font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
}
.step i {
  font-style: normal; font-size: 11px; font-weight: 700;
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-muted);
}
.step.is-active { color: var(--text); border-color: var(--border); background: var(--surface); }
.step.is-active i { background: var(--accent); color: var(--on-accent); }
.step.is-done i { background: var(--teal); color: var(--on-accent); }

.topbar-right { margin-left: auto; }
.pill {
  font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--border);
}
.pill-ok { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.pill-err { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

/* ---------------- layout ---------------- */
#app { max-width: 1240px; margin: 0 auto; padding: 32px 24px 80px; }

.screen { display: none; }
.screen.is-active { display: block; animation: fadein .3s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero { text-align: center; margin: 24px auto 40px; max-width: 720px; }
.hero h1 { font-size: clamp(30px, 5vw, 46px); font-weight: 800; letter-spacing: -.5px; margin: 0 0 12px; }
.hero p { color: var(--text-muted); font-size: 17px; margin: 0; }
.hero.small { margin-bottom: 28px; }
.hero.small h1 { font-size: clamp(26px, 4vw, 36px); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-1);
}
.card-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); margin: 0 0 18px;
}
.card-title .icn { width: 18px; height: 18px; color: var(--accent); }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font); font-size: 15px; font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 18px;
  min-height: 44px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .12s;
  touch-action: manipulation;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn .icn { width: 18px; height: 18px; flex: none; }
.btn.sq { padding: 10px; width: 44px; }
.btn.sm { min-height: 36px; padding: 6px 12px; }
.btn.sq.sm { width: 36px; padding: 6px; }

.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  box-shadow: var(--shadow-1);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-lg { font-size: 17px; padding: 14px 28px; border-radius: 14px; }

.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-faint); }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.danger-text { color: var(--danger); }

.btn-record {
  background: var(--danger-soft); border-color: var(--danger); color: var(--danger);
  font-size: 16px; padding: 12px 26px;
}
.btn-record:hover { background: var(--danger); color: #fff; }
.btn-record.is-recording { background: var(--danger); color: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 92, 122, .5); } 50% { box-shadow: 0 0 0 12px rgba(255, 92, 122, 0); } }

.btn-play {
  width: 52px; height: 52px; min-height: 52px; padding: 0; border-radius: 50%;
  background: var(--accent); border: none; color: var(--on-accent); flex: none;
  box-shadow: var(--shadow-1);
}
.btn-play:hover { background: var(--accent-hover); }
.btn-play.sm { width: 44px; height: 44px; min-height: 44px; }
.btn-play .icn { width: 22px; height: 22px; }

/* ---------------- record screen ---------------- */
.record-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .record-grid { grid-template-columns: 1fr; } }

.mic-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.mic-row .icn { width: 16px; height: 16px; color: var(--text-faint); flex: none; }
.mic-label { font-size: 13px; font-weight: 600; color: var(--text-muted); flex: none; }
.mic-row select {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mic-active { margin: -4px 0 12px 26px; color: var(--teal); }

.rec-visual { position: relative; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
#rec-canvas { display: block; width: 100%; height: 120px; }
.rec-time {
  position: absolute; top: 10px; right: 12px; font-size: 15px; font-weight: 700;
  color: var(--text-muted); background: var(--overlay); padding: 2px 10px; border-radius: 6px;
}
.rec-controls { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }

.divider { display: flex; align-items: center; gap: 14px; margin: 22px 0; color: var(--text-faint); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 28px 20px; text-align: center;
  border: 2px dashed var(--border-strong); border-radius: var(--r-md);
  color: var(--text-muted); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.dropzone .icn.big { width: 34px; height: 34px; }

#wave-canvas { display: block; width: 100%; height: 140px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--r-md); }
.preview-row { display: flex; align-items: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }

/* ---------------- style screen ---------------- */
.style-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .style-grid { grid-template-columns: 1fr; } }

.genre-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.genre-card {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--r-md); cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font); text-align: left;
  transition: border-color .15s, background .15s, transform .12s;
  min-height: 64px;
}
.genre-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.genre-card.is-on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.genre-card b { font-size: 15px; font-weight: 700; }
.genre-card span { font-size: 12px; color: var(--text-faint); font-family: var(--mono); }

.chip-row { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  padding: 9px 18px; min-height: 40px; border-radius: 999px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-muted); font-family: var(--font); font-size: 14px; font-weight: 600;
  transition: all .15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.chip.chip-teal.is-on { background: var(--teal-soft); border-color: var(--teal); color: var(--teal); }

.advanced { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 16px; }
.advanced summary { cursor: pointer; color: var(--text-muted); font-weight: 600; font-size: 14px; }
.advanced summary:hover { color: var(--text); }
.adv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.adv-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); }

select, input[type="number"] {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text); font-family: var(--font); font-size: 14px;
  padding: 9px 12px; min-height: 40px;
}
select:hover, input[type="number"]:hover { border-color: var(--border-strong); }

input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 6px; border-radius: 3px;
  background: var(--surface-3); cursor: pointer; margin: 14px 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface); box-shadow: var(--shadow-1); cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: none;
}

.actions-row { display: flex; justify-content: space-between; margin-top: 28px; }

/* ---------------- loading ---------------- */
.loading {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--overlay); backdrop-filter: blur(6px);
  display: grid; place-items: center;
}
.loading-box { text-align: center; }
.loading-box h3 { margin: 20px 0 6px; font-size: 20px; }
.eq { display: flex; gap: 6px; justify-content: center; height: 48px; align-items: flex-end; }
.eq i {
  width: 8px; border-radius: 4px; background: var(--accent-grad);
  animation: eq 1s ease-in-out infinite;
}
.eq i:nth-child(1) { animation-delay: 0s; } .eq i:nth-child(2) { animation-delay: .15s; }
.eq i:nth-child(3) { animation-delay: .3s; } .eq i:nth-child(4) { animation-delay: .45s; }
.eq i:nth-child(5) { animation-delay: .6s; }
@keyframes eq { 0%, 100% { height: 12px; } 50% { height: 46px; } }

/* ---------------- studio ---------------- */
.transport { display: flex; align-items: center; gap: 16px; padding: 16px 20px; margin-bottom: 16px; flex-wrap: wrap; }
.time { font-size: 26px; font-weight: 700; min-width: 110px; }
.transport-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  padding: 6px 12px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
}
.transport-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: none; color: var(--text-muted);
  font-family: var(--font); font-size: 15px; font-weight: 600;
  padding: 12px 20px; cursor: pointer; min-height: 44px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--accent); }

.tabpane { display: none; }
.tabpane.is-active { display: block; animation: fadein .25s ease-out; }

.timeline-card { padding: 12px; margin-bottom: 16px; }
.timeline-scroll { overflow-x: auto; border-radius: var(--r-md); }
#timeline { display: block; background: var(--bg-raised); border-radius: var(--r-md); cursor: crosshair; }

/* ---------------- mixer ---------------- */
.mixer { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 14px; }
.strip {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.strip-name { font-size: 13px; font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 6px; }
.strip-name .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.strip .fader { writing-mode: vertical-lr; direction: rtl; width: 6px; height: 110px; margin: 4px 0; }
.strip .fader::-webkit-slider-thumb { cursor: grab; }
.strip-btns { display: flex; gap: 6px; }
.mini-btn {
  width: 34px; height: 30px; border-radius: 6px; font-size: 11px; font-weight: 800;
  font-family: var(--mono); cursor: pointer;
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text-muted);
}
.mini-btn.mute.is-on { background: var(--danger); border-color: var(--danger); color: #fff; }
.mini-btn.solo.is-on { background: var(--amber); border-color: var(--amber); color: var(--on-amber); }
.strip .pan { width: 90%; margin: 0; }
.strip-pan-label { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 1px; }
.strip-gain { font-size: 11px; color: var(--text-faint); }

/* ---------------- drum machine ---------------- */
.dm-card { overflow-x: auto; }
.dm-toolbar { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.inline-field { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.inline-field input[type="number"] { width: 76px; }
.inline-field input[type="range"] { width: 110px; margin: 0; }
.dm-actions { display: flex; gap: 10px; }

.dm-grid { display: grid; gap: 5px; min-width: 760px; }
.dm-row { display: grid; grid-template-columns: 96px repeat(16, 1fr); gap: 5px; align-items: center; }
.dm-label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-align: right; padding-right: 10px; }
.dm-cell {
  aspect-ratio: 1.25; min-height: 34px; border-radius: 6px; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface-2); transition: background .1s, border-color .1s;
  padding: 0;
}
.dm-cell:nth-child(4n + 2) { border-left: 2px solid var(--border-strong); }
.dm-cell:hover { border-color: var(--border-strong); }
.dm-cell.on { background: var(--accent); border-color: var(--accent); }
.dm-cell.accent { background: var(--accent-strong); border-color: var(--accent-strong); box-shadow: inset 0 0 0 2px var(--on-accent); }
.dm-cell.playing { outline: 2px solid var(--text); outline-offset: 1px; }
.dm-hint { margin: 12px 2px 0; }

/* ---------------- keyboard ---------------- */
.keys-card { overflow-x: auto; }
.keys-toolbar { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.kb { position: relative; height: 220px; min-width: 700px; user-select: none; }
.kb-key {
  position: absolute; top: 0; border-radius: 0 0 8px 8px; cursor: pointer;
  border: 1px solid var(--border-strong);
  transition: background .06s;
}
.kb-key.white { background: linear-gradient(#f4f5f9, #dcdfe8); height: 100%; z-index: 1; }
.kb-key.black { background: linear-gradient(#2a2f3f, #14161d); height: 60%; z-index: 2; }
.kb-key.white.held { background: linear-gradient(#d6e4ff, #a9c4ff); }
.kb-key.black.held { background: linear-gradient(#3b74e8, #2154c4); }
.kb-key .kb-hint {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 11px; color: #4a5260; pointer-events: none;
}
.kb-key.black .kb-hint { color: #b8bcc6; }

/* ---------------- tuner ---------------- */
/* ---- tune screen: header, A/B switch, mode tabs, auto/manual panels ---- */
.screen-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.screen-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.btn-back { padding-left: 10px; padding-right: 14px; }

.ab-switch {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; cursor: pointer;
  background: var(--bg-raised); border: 1px solid var(--border);
  font-family: var(--font); min-height: 40px; align-items: center;
}
.ab-switch:disabled { cursor: not-allowed; opacity: .55; }
.ab-opt {
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--text-muted); transition: background .15s, color .15s;
}
.ab-switch[aria-checked="false"] .ab-opt[data-ab="tuned"],
.ab-switch[aria-checked="true"] .ab-opt[data-ab="original"] { background: var(--surface-3); color: var(--text); }
.ab-switch[aria-checked="false"]:not(:disabled) .ab-opt[data-ab="tuned"] { background: var(--ok-soft); color: var(--ok); }
.ab-switch:disabled .ab-opt[data-ab="tuned"] { background: none; color: var(--text-muted); }
.ab-switch:disabled .ab-opt[data-ab="original"] { background: var(--surface-3); color: var(--text); }
.ab-switch:not(:disabled):hover { border-color: var(--border-strong); }

.tuner-head {
  display: flex; align-items: center; gap: 16px 20px; flex-wrap: wrap;
  padding-bottom: 18px; margin-bottom: 20px; border-bottom: 1px solid var(--border);
}
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--r-md); background: var(--bg-raised); border: 1px solid var(--border); }
.seg-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border: none; border-radius: 9px; background: transparent; cursor: pointer;
  font-family: var(--font); font-size: 15px; font-weight: 600; color: var(--text-muted);
  transition: background .15s, color .15s;
}
.seg-btn .icn { width: 18px; height: 18px; }
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { background: var(--seg-active); color: var(--text); box-shadow: var(--shadow-1); }
.seg-btn.is-active .icn { color: var(--accent); }

.field-inline { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--text-muted); }

.tuner-panel { display: grid; gap: 20px; }
.row-label { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-right: 4px; }
.preset-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip-ghost { border-style: dashed; cursor: default; color: var(--text-muted); }
.chip-ghost:hover { border-color: var(--border); color: var(--text-muted); }

.ctl-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 28px; }
@media (max-width: 860px) { .ctl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .ctl-grid { grid-template-columns: 1fr; } }
.ctl { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ctl-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.ctl-top output { font-size: 12px; color: var(--text); }
.ctl select { width: 100%; margin-top: 4px; }
.ctl input[type="range"] { width: 100%; margin: 10px 0 4px; }
.ctl-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); opacity: .8; }

.more { border-top: 1px dashed var(--border); padding-top: 14px; }
.more summary { cursor: pointer; width: max-content; font-size: 14px; font-weight: 600; color: var(--text-muted); }
.more summary:hover { color: var(--text); }
.more[open] summary { margin-bottom: 16px; }

.panel-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap;
  padding-top: 18px; border-top: 1px solid var(--border);
}
.panel-actions .hint { margin: 0; max-width: 62ch; color: var(--text-muted); font-size: 13px; }
.panel-actions .hint b { color: var(--text); font-weight: 600; }
.manual-row { display: flex; align-items: center; gap: 16px 24px; flex-wrap: wrap; }
.ctl-inline { width: 240px; }

.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 20px; flex-wrap: wrap; margin: 24px 0 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--text-muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 12px; height: 8px; border-radius: 3px; }
.sw-line { width: 16px; height: 2px; border-radius: 1px; background: var(--cv-curve); }
.sw-line.sw-tuned { background: var(--cv-curve-tuned); }
.sw-in { background: var(--note-in); }
.sw-off { background: var(--note-off); }
.sw-fixed { background: var(--note-fixed); }
.sw-breath { background: var(--note-off); opacity: .45; }

@media (max-width: 640px) {
  .topbar { gap: 12px; padding: 12px 16px; }
  .logo span { display: none; }
  .step { padding: 6px 10px; }
  .pill { white-space: nowrap; }
  .btn, .seg-btn { white-space: nowrap; }
  .seg-btn { padding: 8px 10px; }
  .screen-title { font-size: 19px; }
  .transport .ab-switch { order: 5; }
  .transport-actions { width: 100%; }
  .transport-actions .btn { flex: 1; }
  .seg { width: 100%; }
  .seg-btn { flex: 1; justify-content: center; }
  .tuner-head .field-inline { flex: 1; }
  .tuner-head .field-inline select { flex: 1; min-width: 0; }
  .tuner-head #tuner-revert { margin-left: 0; }
  .panel-actions .btn { width: 100%; }
  .ctl-inline { width: 100%; }
}
.tuner-status { margin: 0; font-size: 14px; color: var(--text-muted); }
.tuner-status.err-text { color: var(--danger); }
.tuner-scroll { overflow: auto; border-radius: var(--r-md); max-height: 460px; background: var(--bg-raised); border: 1px solid var(--border); }
#tuner-canvas { display: block; }

/* ---------------- login / projects ---------------- */
.err-text { color: var(--danger); }
.login-box { width: min(380px, 92vw); }
.login-tag { text-align: center; margin: 0 0 16px; }
.login-seg { width: 100%; margin-bottom: 16px; }
.login-seg .seg-btn { flex: 1; justify-content: center; }
.login-foot { text-align: center; margin: 12px 0 0; }
.login-foot a { color: var(--accent); font-weight: 600; }
.recent-card { margin: 0 auto 24px; }
.topbar .logo, .steps .step { cursor: pointer; }
.recent-card .card-title { display: flex; align-items: center; gap: 8px; }
.recent-all { margin-left: auto; }
.project-row.is-clickable { cursor: pointer; }
.project-row.is-clickable:hover { border-color: var(--accent); }
.login-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 14px; }
.login-field input {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text); font-family: var(--font); font-size: 15px; padding: 11px 12px; min-height: 44px;
}
.login-field input:focus-visible { border-color: var(--accent); }
#btn-login { margin-top: 6px; }

.project-bar { display: flex; align-items: center; gap: 8px; }
.project-name { font-size: 13px; font-weight: 700; color: var(--text-muted); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projects-box { width: min(560px, 94vw); max-height: 80vh; overflow-y: auto; }
.projects-list { display: flex; flex-direction: column; gap: 8px; }
.project-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 10px 14px;
}
.project-row-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.project-row-info b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tune-jump-card { text-align: center; padding: 40px 24px; }
.tune-jump-card p { margin: 0 0 18px; }

/* ---------------- loading progress bar ---------------- */
.load-progress { display: flex; align-items: center; gap: 12px; margin: 18px auto 6px; width: min(360px, 80vw); }
.load-bar-track { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.load-bar {
  height: 100%; width: 0%; border-radius: 4px;
  background: var(--accent-grad);
  transition: width .35s ease-out;
}
#loading-pct { font-size: 13px; font-weight: 700; color: var(--text-muted); min-width: 40px; text-align: right; }

/* ---------------- fx panel + neon ---------------- */
.fx-card { margin-top: 16px; }
.fx-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 14px; }
.fx-controls { display: flex; gap: 28px; flex-wrap: wrap; align-items: center; }
.fx-group { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.fx-group .inline-field input[type="range"] { width: 90px; }

.fx-neon { display: flex; gap: 14px; flex-wrap: wrap; min-height: 26px; align-items: center; }
.neon-tag {
  font-family: var(--font); font-size: 12px; font-weight: 600; letter-spacing: .02em;
  padding: 3px 10px; border-radius: 999px; border: 1px solid currentColor;
  background: color-mix(in srgb, currentColor 10%, transparent);
  animation: neon-in .2s ease-out;
}
@keyframes neon-in { from { opacity: 0; } to { opacity: 1; } }
.neon-violet { color: var(--accent-text); }
.neon-teal   { color: var(--teal); }
.neon-pink   { color: var(--danger); }
.neon-amber  { color: var(--amber); }
.neon-red    { color: var(--danger); }
.neon-blue   { color: var(--accent-text); }
.neon-off    { color: var(--text-faint); background: none; }
.dyn-graph-wrap { margin-top: 16px; }
#dyn-graph {
  display: block; width: 100%; height: 110px;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--r-md);
}
.dyn-legend { display: flex; gap: 18px; align-items: center; margin-top: 6px; }
.dyn-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
#gr-readout { margin-left: auto; color: var(--amber); }

.lag-btn {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  padding: 4px 8px; min-height: 28px; margin-left: -6px; margin-right: 6px;
  border-radius: 8px; cursor: pointer;
  background: var(--surface-3); border: 1px solid var(--border); color: var(--teal);
}
.lag-btn:hover { border-color: var(--teal); }
.neon-click  { cursor: pointer; }
.neon-click:hover { text-decoration: line-through; }

.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
#btn-fx-bypass[aria-pressed="true"] { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

/* ---------------- toast ---------------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--surface-3); border: 1px solid var(--border-strong);
  color: var(--text); font-size: 14px; font-weight: 600;
  padding: 12px 22px; border-radius: var(--r-md); box-shadow: var(--shadow-2);
  z-index: 1200; max-width: 90vw;
}
.toast.err { border-color: var(--danger); color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.studio-ref { cursor: pointer; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- busy buttons ---------------- */
.btn[aria-busy="true"]:disabled { opacity: .9; cursor: progress; }
.spin {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- theme switch ---------------- */
.topbar-right { display: flex; align-items: center; gap: 10px; }
.theme-btn { width: 36px; min-height: 36px; padding: 6px; border-radius: 999px; }
.theme-btn .icn { width: 18px; height: 18px; }
.theme-btn .ic-moon { display: none; }
:root[data-theme="dark"] .theme-btn .ic-sun { display: none; }
:root[data-theme="dark"] .theme-btn .ic-moon { display: block; }
.logo svg { color: var(--accent); }
