/* SingFermata design system.
   Spacing: 4 px scale only (--s-*). Corners: square everywhere; only the record dot and spinners are round.
   Type: IBM Plex Sans for text, IBM Plex Mono for readouts (notes, times, scores).
   Color: the UI is monochrome plus one signature blue, the song's "now": the note to sing,
   the playhead, the sung lyric, and the main action. Other color only carries meaning
   (green in tune, red off / recording). */
:root {
  /* spacing */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px;
  --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px; --s-20: 80px;
  /* radius */
  --r: 0;
  --r-lg: 0;
  --r-full: 0;
  /* type */
  --font: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --t-xs: 11px/16px var(--font);
  --t-sm: 12px/16px var(--font);
  --t-ui: 13px/20px var(--font);
  --t-body: 14px/20px var(--font);
  --t-lg: 16px/24px var(--font);
  --t-h2: 20px/28px var(--font);
  --t-h1: 28px/36px var(--font);
  --t-display: 40px/48px var(--font);
  /* color */
  --bg: #040405;
  --panel: #0d0e11;
  --panel-2: #17191d;
  --hover: #22252b;
  --line: #1c1e23;
  --line-strong: #2a2d34;
  --text: #f2f3f5;
  --muted: #8d929c;
  --accent: #4f6bff;
  --accent-hover: #6a82ff;
  --accent-soft: rgba(79, 107, 255, 0.14);
  --on-accent: #ffffff;
  --dark-text: #040405;
  --rec: #c8283b;
  --rec-hover: #e0334a;
  --rec-on: #ff4d5e;
  --good: #3ddc84;
  --warn: #ffb547;
  --bad: #ff6b7a;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  --ease: 120ms cubic-bezier(0.2, 0, 0, 1);
  --ease-slow: 300ms cubic-bezier(0.2, 0, 0, 1);
  /* canvases (read by roll.js) */
  --melody: rgba(255, 255, 255, 0.16);
  --melody-active: var(--accent);
  --guide: rgba(242, 243, 245, 0.3);
  --roll-bg: #0a0b0d;
  --roll-black: #060708;
  --roll-line: #17191d;
  --playhead: var(--accent);
  --region: rgba(255, 255, 255, 0.08);
  --lyric: rgba(255, 255, 255, 0.07);
  --lyric-active: rgba(79, 107, 255, 0.4);
  --wave: rgba(61, 220, 132, 0.5);
  color-scheme: dark;
}
:root.recording { --playhead: var(--rec-on); }

/* ---- base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: var(--t-body); -webkit-font-smoothing: antialiased; }
body { display: flex; flex-direction: column; }
.studio-page { overflow: hidden; user-select: none; font: var(--t-ui); }
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; transition: text-decoration-color var(--ease); }
a:hover { text-decoration-color: var(--text); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: 0.4; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font: var(--t-h1); font-weight: 600; letter-spacing: -0.02em; margin: 0 0 var(--s-2); }
h2 { font: var(--t-ui); font-weight: 600; margin: 0; color: var(--text); }
h3 { font: var(--t-ui); font-weight: 600; color: var(--text); margin: var(--s-6) 0 var(--s-3); padding-top: var(--s-6); border-top: 1px solid var(--line); }
h3:first-child { padding-top: 0; border-top: 0; }
h3:first-child { margin-top: 0; }
small, .muted { color: var(--muted); }
kbd { display: inline-block; min-width: 16px; text-align: center; background: var(--panel-2); border: 1px solid var(--line-strong); padding: 0 var(--s-1); font: var(--t-xs); font-family: var(--mono); color: var(--text); }
.i { width: 16px; height: 16px; flex: none; }
.empty { color: var(--muted); margin: 0; padding: var(--s-3) var(--s-4); }
.hint { color: var(--muted); font: var(--t-sm); margin: 0; }

/* ---- buttons */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); height: 32px; padding: 0 var(--s-4); border-radius: var(--r); background: var(--panel-2); color: var(--text); font-weight: 600; white-space: nowrap; transition: background var(--ease), color var(--ease); }
.btn:not(:disabled):hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:not(:disabled):hover { background: var(--accent-hover); }
.btn.primary:disabled:not(.loading) { background: var(--panel-2); color: var(--muted); opacity: 1; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:not(:disabled):hover { background: var(--panel-2); color: var(--text); }
.btn.sm { height: 28px; padding: 0 var(--s-3); font: var(--t-sm); font-weight: 600; }
.btn.lg { height: 40px; padding: 0 var(--s-5); }
.btn.block { width: 100%; }
/* loading: label hides, spinner shows, width stays put */
.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border: 2px solid var(--on-accent); border-top-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
.btn.loading:not(.primary)::after { border-color: var(--text); border-top-color: transparent; }
.btn.loading:disabled { opacity: 1; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r); color: var(--muted); transition: background var(--ease), color var(--ease); }
.icon-btn:not(:disabled):hover { background: var(--panel-2); color: var(--text); }
.icon-btn.sm { width: 24px; height: 24px; }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); }
.device-names { margin: 0 0 var(--s-4); }
.icon-btn.sm .i { width: 12px; height: 12px; }

/* ---- top bar */
.topbar { flex: none; height: 56px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s-4); padding: 0 var(--s-4); background: var(--bg); border-bottom: 1px solid var(--line); }
.app-name { font: var(--t-body); font-weight: 600; color: var(--text); text-decoration: none; justify-self: start; display: flex; align-items: center; gap: var(--s-2); }
.logo { width: 20px; height: 20px; color: var(--accent); }
.topbar-center { justify-self: center; }
.tabs { display: flex; gap: var(--s-1); background: var(--panel); padding: var(--s-1); border-radius: var(--r-lg); }
.step { height: 28px; padding: 0 var(--s-4); border-radius: var(--r); color: var(--muted); font-weight: 600; transition: background var(--ease), color var(--ease); }
.step:not(:disabled):hover { color: var(--text); }
.step.active { background: var(--hover); color: var(--text); }
.topbar-right { display: flex; align-items: center; justify-content: flex-end; gap: var(--s-3); min-width: 0; }
.topbar-right form { margin: 0; }
.project-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; height: 28px; padding: 0 var(--s-2); cursor: text; transition: background var(--ease); }
.project-name:hover { background: var(--panel-2); }
.project-name-input { width: 280px; height: 28px; padding: 0 var(--s-2); font: inherit; font-weight: 600; color: var(--text); background: var(--panel-2); border: 1px solid var(--line-strong); outline: none; }
.project-name-input:focus { border-color: var(--accent); }
.user { color: var(--muted); padding-left: var(--s-3); border-left: 1px solid var(--line-strong); }

main { flex: 1 0 auto; }
.studio-page main { flex: 1; min-height: 0; }
.view { display: none; height: 100%; padding: var(--s-3) var(--s-4) var(--s-4); }
.view.active { display: block; }
.panel, .sidebar, .preview { background: var(--panel); border-radius: var(--r-lg); }

/* ---- dashboard */
.home { max-width: 1120px; margin: 0 auto; padding: var(--s-16) var(--s-4) var(--s-12); display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--s-16); align-items: start; }
.lede { color: var(--muted); font: var(--t-lg); margin: 0 0 var(--s-8); max-width: 560px; }
.file-list { display: flex; flex-direction: column; gap: var(--s-2); }
.drop { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-3) var(--s-4) var(--s-3) var(--s-3); background: var(--panel); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); transition: background var(--ease), border-color var(--ease); }
.drop:hover { background: var(--panel-2); border-color: var(--muted); }
.drop.over { background: var(--accent-soft); border-color: var(--accent); }
.drop.has-file { border-style: solid; }
.drop-icon { width: 40px; height: 40px; padding: 10px; background: var(--accent-soft); color: var(--accent); }
.drop.has-file .drop-icon { background: rgba(61, 220, 132, 0.12); color: var(--good); }
.drop-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.drop-label { font-weight: 600; }
.optional { color: var(--muted); font-weight: 400; margin-left: var(--s-1); }
.drop-file { color: var(--muted); font: var(--t-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drop.has-file .drop-file { color: var(--text); }
.drop-clear { display: none; }
.drop.has-file .drop-clear { display: inline-grid; }
.drop.has-file .drop-choose { display: none; }
.home-actions { display: flex; align-items: center; gap: var(--s-4); margin-top: var(--s-6); }
.progress { margin-top: var(--s-4); padding: var(--s-4); border-radius: var(--r-lg); background: var(--panel); display: flex; flex-direction: column; gap: var(--s-4); }
.progress-step { display: grid; grid-template-columns: 1fr auto; gap: var(--s-2); color: var(--muted); }
.progress-step.on, .progress-step.done { color: var(--text); }
.progress-step .pct { font: var(--t-sm); font-family: var(--mono); }
.progress-step.done .pct { color: var(--accent-hover); }
.progress-step .bar { grid-column: 1 / -1; height: 4px; border-radius: var(--r-full); background: var(--panel-2); overflow: hidden; }
.progress-step .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width var(--ease-slow); }
.progress .btn { align-self: flex-start; margin-left: calc(-1 * var(--s-2)); }
.recent-wrap { padding-top: var(--s-2); }
.recent-wrap h2 { display: flex; align-items: center; gap: var(--s-2); font: var(--t-lg); font-weight: 600; margin-bottom: var(--s-3); }
.recent-wrap .count { font: var(--t-xs); font-family: var(--mono); color: var(--accent); background: var(--accent-soft); padding: 0 var(--s-2); }
.recent { background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--r-lg); overflow: hidden; }
.recent-wrap .empty { padding: 0; }

/* ---- lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); transition: background var(--ease); }
.list li + li { border-top: 1px solid var(--line); }
.list li:hover { background: #111216; }
.list .row-main { flex: 1; min-width: 0; }
.list .row-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.take-name { display: block; max-width: 100%; padding: 0 var(--s-1); margin-left: calc(-1 * var(--s-1)); font: inherit; font-weight: 600; color: inherit; background: none; border: 0; text-align: left; cursor: text; transition: background var(--ease); }
.take-name:hover { background: var(--panel-2); }
.take-name-input { width: 100%; padding: 0 var(--s-1); margin-left: calc(-1 * var(--s-1)); font: inherit; font-weight: 600; color: var(--text); background: var(--panel-2); border: 1px solid var(--line-strong); outline: none; }
.take-name-input:focus { border-color: var(--accent); }
.list .row-meta { color: var(--muted); font: var(--t-sm); font-variant-numeric: tabular-nums; margin-top: var(--s-1); }
.list .row-actions { display: flex; gap: var(--s-1); opacity: 0; transition: opacity var(--ease); }
.list li:hover .row-actions, .list li:focus-within .row-actions { opacity: 1; }
.recent li { padding: 0 var(--s-2) 0 0; }
.recent .row-main { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); color: inherit; text-decoration: none; }
.recent .row-text { min-width: 0; }
.recent .row-icon { width: 32px; height: 32px; padding: 8px; background: var(--panel-2); color: var(--muted); transition: background var(--ease), color var(--ease); }
.recent li:hover .row-icon { background: var(--accent-soft); color: var(--accent); }
.tag { display: inline-block; font: var(--t-xs); font-weight: 600; color: var(--warn); background: rgba(255, 181, 71, 0.12); padding: 0 var(--s-2); margin-right: var(--s-2); }
.tag.ready { color: var(--good); background: rgba(61, 220, 132, 0.12); }
.row-progress { display: block; height: 2px; margin: var(--s-1) 0 var(--s-2); background: var(--panel-2); }
.row-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width var(--ease-slow); }
.my-stats { display: flex; gap: var(--s-4); margin: calc(-1 * var(--s-2)) 0 var(--s-3); color: var(--muted); font: var(--t-sm); }
.my-stats b { color: var(--text); font-family: var(--mono); font-weight: 500; }
.tag.bad { color: var(--bad); background: rgba(255, 107, 122, 0.12); }
.tag.muted-tag { color: var(--muted); background: var(--panel-2); }

/* ---- record */
.record-layout { display: grid; grid-template-columns: 1fr 304px; gap: var(--s-3); height: 100%; }
.stage { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.cards { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: var(--s-3); }
.card { background: var(--panel); border-radius: var(--r-lg); padding: var(--s-3) var(--s-4); display: flex; flex-direction: column; min-width: 0; }
.card-title { font: var(--t-sm); font-weight: 600; color: var(--muted); }
.card-sub { font: var(--t-sm); color: var(--muted); }
.hud-value { font: 500 32px/40px var(--mono); letter-spacing: -0.02em; }
.hud-value.good { color: var(--good); }
.hud-value.warn { color: var(--bad); }
.hud-value.target { color: var(--accent); }
.meter { margin-top: var(--s-1); display: flex; flex-direction: column; gap: var(--s-1); max-width: 240px; }
.meter-track { position: relative; height: 8px; border-radius: var(--r-full); background: var(--panel-2); }
.meter-zone { position: absolute; left: 25%; width: 50%; top: 0; bottom: 0; background: rgba(61, 220, 132, 0.2); border-radius: var(--r-full); }
.meter-center { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--muted); }
.meter-needle { position: absolute; top: -4px; width: 4px; height: 16px; background: var(--muted); left: 50%; transform: translateX(-2px); transition: left 0.08s linear; opacity: 0; }
.meter-needle.on { opacity: 1; }
.meter-scale { display: flex; justify-content: space-between; font: var(--t-xs); color: var(--muted); }
.key-name { font: 500 20px/28px var(--mono); margin: var(--s-1) 0 var(--s-2); white-space: nowrap; }
.key-name small { color: var(--muted); font: var(--t-body); margin-left: var(--s-2); }
.key-name.busy { color: var(--muted); font: var(--t-ui); line-height: 28px; }
.keyctl { display: flex; gap: var(--s-2); }

.stage-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.roll-wrap { position: relative; flex: 1; min-height: 200px; overflow: hidden; }
#roll { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#roll:active { cursor: grabbing; }
.roll-wrap.editing #roll { cursor: default; }
.roll-note { position: absolute; top: var(--s-3); left: 50%; transform: translateX(-50%); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--text); padding: var(--s-2) var(--s-3); border-radius: var(--r); font: var(--t-sm); white-space: nowrap; }
.rec-badge { position: absolute; top: var(--s-3); right: var(--s-3); display: flex; align-items: center; gap: var(--s-2); color: #fff; font: var(--t-sm); font-weight: 600; background: var(--rec-on); padding: var(--s-1) var(--s-2); border-radius: var(--r); }
.rec-badge i { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.roll-btn { position: absolute; top: var(--s-3); left: var(--s-12); display: flex; align-items: center; gap: var(--s-2); height: 28px; padding: 0 var(--s-3); border-radius: var(--r); background: var(--panel-2); color: var(--text); font: var(--t-sm); font-weight: 600; transition: background var(--ease); }
.roll-btn .i { width: 12px; height: 12px; }
.roll-btn:hover { background: var(--hover); }
.edit-bar { position: absolute; top: var(--s-2); left: var(--s-12); right: var(--s-3); display: flex; align-items: center; gap: var(--s-1); background: var(--panel); box-shadow: inset 0 0 0 1px var(--line-strong); border-radius: var(--r); padding: var(--s-1) var(--s-1) var(--s-1) var(--s-3); font: var(--t-sm); color: var(--muted); }
.edit-bar span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lyrics { position: relative; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: center; min-height: 72px; padding: var(--s-3) 160px; text-align: center; }
.lyr-cur { font: var(--t-h2); font-weight: 600; color: var(--muted); }
.lyr-cur .sung { color: var(--accent); }
.lyr-next { font: var(--t-ui); color: var(--muted); margin-top: var(--s-1); }
/* pinyin: above each character (ruby, takes the sung color with it), or above the whole line */
.lyrics ruby { ruby-position: over; }
.lyrics rt { font: 500 10px/12px var(--font); letter-spacing: 0; }
.lyr-cur rt { font: 500 12px/14px var(--font); }
.lyr-pinyin { font: var(--t-sm); font-weight: 600; color: var(--muted); margin-bottom: var(--s-1); }
.lyr-next .lyr-pinyin { font: var(--t-xs); margin-bottom: 0; }
.lyr-tools { position: absolute; right: var(--s-3); top: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: var(--s-1); opacity: 0; transition: opacity var(--ease); }
.lyrics:hover .lyr-tools { opacity: 1; }
.lyr-add { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--muted); padding: var(--s-1) var(--s-3); border-radius: var(--r); font-weight: 600; transition: background var(--ease), color var(--ease); }
.lyr-add:hover { background: var(--panel-2); color: var(--text); }
.lyr-add .muted { font: var(--t-sm); }
.lyrics.empty { min-height: 0; padding: var(--s-2); }
.lyrics.empty .lyr-lines, .lyrics.empty .lyr-tools { display: none; }
.lyrics:not(.empty) .lyr-add { display: none; }

.transport { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); background: var(--panel); border-radius: var(--r-lg); }
.tbtn { height: 36px; padding: 0 var(--s-4); border-radius: var(--r); display: inline-flex; align-items: center; gap: var(--s-2); background: var(--panel-2); font-weight: 600; flex: none; white-space: nowrap; transition: background var(--ease); }
.tbtn:hover { background: var(--hover); }
/* white, not blue: next to the blue playhead and note it would read as part of the song */
.tbtn.play { background: var(--text); color: var(--dark-text); min-width: 96px; justify-content: center; }
.tbtn.play:hover { background: #fff; }
.tbtn .i-pause, .tbtn .when-playing, .tbtn .when-on { display: none; }
.tbtn.playing .i-play, .tbtn.playing .when-stopped { display: none; }
.tbtn.playing .i-pause, .tbtn.playing .when-playing { display: inline; }
.tbtn.rec { background: var(--rec); color: #fff; min-width: 152px; justify-content: center; }
.tbtn.rec:hover { background: var(--rec-hover); }
.tbtn.rec i { width: 10px; height: 10px; border-radius: 50%; background: #fff; }
.tbtn.rec.on { background: var(--rec-on); }
.tbtn.rec.on i { border-radius: 0; }
.tbtn.rec.on .when-idle { display: none; }
.tbtn.rec.on .when-on { display: inline; }
.time { font: 500 13px/20px var(--mono); color: var(--muted); white-space: nowrap; margin: 0 var(--s-1); }
.time span:first-child { color: var(--text); }
.time .sep { margin: 0 var(--s-1); }
.seek { flex: 1; min-width: 80px; }
.mini-slider { display: flex; align-items: center; gap: var(--s-2); color: var(--muted); font: var(--t-sm); white-space: nowrap; margin-left: var(--s-2); }
.mini-slider input { width: 84px; }
.mic-level { width: 6px; height: 28px; background: var(--panel-2); position: relative; overflow: hidden; flex: none; }
.mic-level i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--good); }

.sidebar { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.side-head { padding: var(--s-4) var(--s-4) var(--s-2); }
.takes { flex: 1; overflow: auto; }
.takes .score { font-family: var(--mono); color: var(--warn); font-weight: 600; }
.takes .score.good { color: var(--good); }
.side-foot { padding: var(--s-4); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--s-3); }

/* ---- finish */
.finish-layout { display: grid; grid-template-columns: 312px 1fr; gap: var(--s-3); height: 100%; }
.controls { padding: var(--s-5); overflow: auto; display: block; }
.control { margin-bottom: var(--s-4); }
.control-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s-1); }
.value { color: var(--muted); font: var(--t-sm); font-family: var(--mono); }
.ticks { display: flex; justify-content: space-between; font: var(--t-xs); color: var(--muted); }
.help { display: block; margin-top: var(--s-1); font: var(--t-sm); }
.head-end { display: inline-flex; align-items: center; gap: var(--s-2); }
.presets { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-4); }
.chip { font: var(--t-sm); padding: var(--s-1) var(--s-3); border: 1px solid var(--line); border-radius: var(--r); background: transparent; color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin: var(--s-1) 0 var(--s-4); cursor: pointer; }
.toggle input { display: none; }
.toggle small { display: block; font: var(--t-sm); }
.switch { width: 36px; height: 20px; border-radius: var(--r-full); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-strong); position: relative; flex: none; transition: background var(--ease); }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 12px; height: 12px; background: var(--muted); transition: left var(--ease), background var(--ease); }
.toggle input:checked + .switch { background: var(--accent); box-shadow: none; }
.toggle input:checked + .switch::after { left: 20px; background: var(--on-accent); }
.use-takes { list-style: none; margin: 0 calc(-1 * var(--s-2)); padding: 0; }
.use-takes label { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2); border-radius: var(--r); cursor: pointer; transition: background var(--ease); }
.use-takes label:hover { background: var(--panel-2); }
.use-takes small { margin-left: auto; font-family: var(--mono); }
.use-takes .other-key { opacity: 0.4; }
.use-takes .empty { padding: var(--s-1) var(--s-2); }
.preview { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.preview-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-4) var(--s-3); }
.status { color: var(--good); font: var(--t-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.status.busy { color: var(--muted); }
.status.busy::before { content: ""; display: inline-block; width: 8px; height: 8px; border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; margin-right: var(--s-2); animation: spin 0.8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }
.overview-wrap { flex: 1; min-height: 160px; position: relative; margin: 0 var(--s-3); }
#overview { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; border-radius: var(--r); }
.preview .transport { border-radius: 0; border-top: 1px solid var(--line); }
.spacer { flex: 1; }
.check { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-2); color: var(--text); margin-bottom: var(--s-3); cursor: pointer; }
.check small { flex-basis: 100%; padding-left: var(--s-6); font: var(--t-sm); }
.transport .check { margin: 0; color: var(--muted); }

/* ---- form controls */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 20px; background: transparent; margin: 0; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; background: var(--panel-2); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 16px; background: var(--text); margin-top: -6px; }
input[type=range]::-moz-range-track { height: 4px; background: var(--panel-2); }
input[type=range]::-moz-range-thumb { width: 12px; height: 16px; border: 0; border-radius: 0; background: var(--text); }
input[type=range]:disabled { opacity: 0.4; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
select { width: 100%; height: 36px; background: var(--bg); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--r); padding: 0 var(--s-2); font: inherit; }
input[type=text], input[type=password], input[type=email] { height: 40px; background: var(--bg); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--r); padding: 0 var(--s-3); font: var(--t-body); transition: border-color var(--ease), box-shadow var(--ease); }
input[type=text]:focus, input[type=password]:focus, input[type=email]:focus, select:focus { border-color: var(--muted); outline: none; }

/* ---- advanced sheet */
.sheet { position: fixed; inset: 56px 0 0 0; background: rgba(0, 0, 0, 0.6); display: flex; justify-content: flex-end; z-index: 10; }
.sheet-panel { width: 360px; height: 100%; background: var(--panel); border-left: 1px solid var(--line); padding: var(--s-4) var(--s-5) var(--s-6); overflow: auto; box-shadow: var(--shadow); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-5); }
.sheet-head h2 { font: var(--t-lg); font-weight: 600; color: var(--text); text-transform: none; letter-spacing: 0; }
.field { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); color: var(--muted); }

.toast { position: fixed; top: 72px; left: 50%; transform: translateX(-50%); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow); border-radius: var(--r); padding: var(--s-3) var(--s-4); display: flex; gap: var(--s-3); align-items: center; z-index: 20; max-width: min(640px, calc(100% - var(--s-8))); animation: drop 160ms cubic-bezier(0.2, 0, 0, 1); }
.toast.error { background: var(--rec); box-shadow: var(--shadow); }
.toast button { font-weight: 600; text-decoration: underline; }
.toast .toast-close { text-decoration: none; font-size: 1.25rem; line-height: 1; padding: 0 var(--s-1); margin-left: var(--s-2); }
@keyframes drop { from { opacity: 0; transform: translate(-50%, calc(-1 * var(--s-2))); } }

/* ---- overlays (studio) */
.drop { cursor: pointer; }
.drop input { display: none; }
.overlay { position: fixed; inset: 56px 0 0 0; background: var(--bg); display: grid; place-items: center; z-index: 5; padding: var(--s-4); }
.overlay-card { width: min(480px, 100%); background: var(--panel); border-radius: var(--r-lg); padding: var(--s-6); display: flex; flex-direction: column; gap: var(--s-4); }
.overlay-card h2 { font: var(--t-lg); font-weight: 600; color: var(--text); text-transform: none; letter-spacing: 0; }
.overlay-card p { margin: 0; }
.overlay-card .btn { align-self: flex-start; margin-left: calc(-1 * var(--s-2)); }
.overlay-card .btn.primary { margin-left: 0; }
.overlay-card .file-list { margin: var(--s-1) 0; }
.rights { margin: var(--s-4) 0 0; color: var(--muted); }
.overlay-card .rights { margin: 0; }

/* song loading: a waveform traced slowly left to right, like a seismograph, in blue */
.loading-card { align-items: center; text-align: center; }
.overlay-card .eta { margin: calc(-1 * var(--s-2)) 0 0; font: var(--t-sm); min-height: 16px; }
.wave-skeleton { display: block; width: 100%; height: 72px; overflow: visible; }
.wave-base { stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.wave-trace { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: miter; stroke-linecap: square; vector-effect: non-scaling-stroke;
  stroke-dasharray: 1; stroke-dashoffset: 1; animation: trace 12s linear infinite; }
@keyframes trace { 92% { stroke-dashoffset: 0; opacity: 1; } 100% { stroke-dashoffset: 0; opacity: 0; } }
.loading-bar { width: 100%; height: 4px; background: var(--panel-2); overflow: hidden; }
.loading-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width var(--ease-slow); }
.loading-card #loading-pct { font: var(--t-sm); font-family: var(--mono); }

/* skeleton shimmer for content that is on its way */
#preview-skeleton { position: absolute; inset: 0; pointer-events: none; }
.skeleton { display: block; background: var(--accent-soft); animation: pulse 1.6s ease-in-out infinite; }

/* ---- site pages */
.footer { flex: none; border-top: 1px solid var(--line); }
.footer-inner { padding: var(--s-5) var(--s-4); display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); font: var(--t-sm); color: var(--muted); }
.footer nav { display: flex; gap: var(--s-6); }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--text); }
.prose { max-width: 640px; margin: 0 auto; padding: var(--s-16) var(--s-4) var(--s-12); }
.prose h1 { margin-bottom: var(--s-4); }
.prose h2 { font: var(--t-lg); font-weight: 600; color: var(--text); text-transform: none; letter-spacing: 0; margin: var(--s-8) 0 var(--s-2); }
.prose p { color: var(--muted); margin: 0; line-height: 24px; }
.prose p + p { margin-top: var(--s-3); }
.prose .lede { color: var(--text); }
/* legal documents: numbered sections, contents list */
.legal h1 { margin-bottom: var(--s-1); }
.legal-meta { font: var(--t-sm); margin-bottom: var(--s-8) !important; }
.legal h2 { scroll-margin-top: var(--s-6); padding-top: var(--s-8); margin-top: var(--s-8); border-top: 1px solid var(--line); }
.legal strong { color: var(--text); font-weight: 600; }
.legal ul, .legal ol { color: var(--muted); margin: var(--s-3) 0; padding-left: var(--s-6); line-height: 24px; }
.legal li + li { margin-top: var(--s-1); }
.legal ul + p, .legal ol + p { margin-top: var(--s-3); }
.toc { margin-top: var(--s-6); padding: var(--s-4) var(--s-5); background: var(--panel); border-radius: var(--r-lg); }
.toc ol { columns: 2; column-gap: var(--s-8); margin: 0; font: var(--t-ui); line-height: 24px; }
.toc li { break-inside: avoid; margin: 0 !important; }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--text); }

/* auth / landing */
.auth-page { max-width: 1120px; margin: 0 auto; padding: var(--s-16) var(--s-4) var(--s-12); display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--s-16); align-items: start; }
.pitch h1 { font: var(--t-display); font-weight: 600; letter-spacing: -0.02em; margin: 0 0 var(--s-4); max-width: 560px; }
.pitch .lede { margin-bottom: var(--s-8); }
.visual { background: var(--roll-bg); border-radius: var(--r-lg); overflow: hidden; margin-bottom: var(--s-8); }
.visual svg { display: block; width: 100%; height: auto; }
/* colour keys for the piano roll (the Finish tab legend) */
.swatch { flex: none; width: 16px; height: 8px; background: var(--melody); }
.swatch.now { background: var(--accent); }
.swatch.voice { height: 3px; background: var(--good); }
.auth { width: 100%; }
.auth { padding-top: var(--s-2); }
.auth h1 { font: var(--t-h2); font-weight: 600; margin-bottom: var(--s-1); }
.auth > .muted { margin: 0; }
.form { background: var(--panel); border-radius: var(--r-lg); padding: var(--s-6); margin: var(--s-6) 0 var(--s-4); }
.form .field { color: var(--text); font: var(--t-ui); font-weight: 600; }
.form .field small { font-weight: 400; color: var(--muted); }
.form .btn { margin-top: var(--s-2); height: 40px; }
.form .check { color: var(--muted); font: var(--t-ui); }
.form-error, .form .form-error { color: var(--bad); font-weight: 400; margin: 0 0 var(--s-4); }
.form .field .form-error { margin: 0; }
.auth-alt { font: var(--t-ui); color: var(--muted); margin: 0; text-align: center; }

/* staff metrics: stat tiles, one-series daily bars (small multiples), funnel, tables */
.metrics { max-width: 1120px; margin: 0 auto; padding: var(--s-10) var(--s-4) var(--s-12); display: grid; gap: var(--s-10); }
.metrics-head { display: flex; align-items: baseline; gap: var(--s-4); flex-wrap: wrap; }
.metrics-head h1 { margin: 0; }
.metrics h2 { font: var(--t-lg); font-weight: 600; margin: 0 0 var(--s-1); }
.metrics section > .muted { margin: 0 0 var(--s-3); font: var(--t-sm); }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; }
.stat { background: var(--panel); padding: var(--s-4); display: grid; gap: var(--s-1); }
.stat-label { color: var(--muted); font: var(--t-sm); }
.stat-value { font: 600 28px/36px var(--mono); font-variant-numeric: tabular-nums; }
.stat-value small { font: var(--t-sm); color: var(--muted); }
.stat-sub { color: var(--muted); font: var(--t-xs); }
.bad-text { color: var(--bad); font-weight: 600; }
.chart-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); }
.chart { margin: 0; background: var(--panel); padding: var(--s-4); }
.chart figcaption { display: flex; justify-content: space-between; gap: var(--s-2); font: var(--t-ui); font-weight: 600; margin-bottom: var(--s-3); }
.chart figcaption .muted { font: var(--t-xs); font-weight: 400; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 96px; border-bottom: 1px solid var(--line-strong); }
.bar-col { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; }
.bar-col i { display: block; width: 100%; min-height: 0; background: var(--accent); }
.bar-col:hover i { background: var(--accent-hover); }
.bar-col:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + var(--s-1)); left: 50%; transform: translateX(-50%);
  white-space: nowrap; background: var(--panel-2); color: var(--text); font: var(--t-xs); font-family: var(--mono); padding: 2px var(--s-2); box-shadow: var(--shadow); z-index: 2; pointer-events: none; }
/* the outermost bars' tooltips open inward so they stay inside the card */
.bar-col:nth-child(-n+5):hover::after { left: 0; transform: none; }
.bar-col:nth-last-child(-n+5):hover::after { left: auto; right: 0; transform: none; }
.bars-axis { display: flex; justify-content: space-between; color: var(--muted); font: var(--t-xs); margin-top: var(--s-1); }
.metrics-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-10); }
.funnel { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.funnel li { display: grid; grid-template-columns: 140px 1fr 72px; align-items: center; gap: var(--s-3); font: var(--t-ui); }
.funnel-bar { height: 12px; background: var(--panel-2); }
.funnel-bar i { display: block; height: 100%; background: var(--accent); }
.funnel-n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.funnel-n small { color: var(--muted); }
.table { width: 100%; border-collapse: collapse; font: var(--t-ui); }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--line-strong); }
.table td { padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--line); }
.table .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.metrics section { overflow-x: auto; }
.daily-table summary { cursor: pointer; color: var(--muted); font: var(--t-ui); margin-bottom: var(--s-3); }

/* admin panel: built on the metrics layout above */
.admin { gap: var(--s-6); }
.admin a:not(.btn) { text-decoration: underline; text-underline-offset: 2px; }
.admin .metrics-head a { font: var(--t-sm); }
.panel-tabs { display: flex; flex-wrap: wrap; gap: var(--s-1); border-bottom: 1px solid var(--line-strong); }
.panel-tabs a, .panel-tabs a:not(.btn) { padding: var(--s-2) var(--s-3); color: var(--muted); font: var(--t-ui); font-weight: 600; text-decoration: none; margin-bottom: -1px; border-bottom: 2px solid transparent; }
.panel-tabs a:hover { color: var(--text); }
.panel-tabs a[aria-current] { color: var(--text); border-bottom-color: var(--accent); }
.panel-msg { margin: 0 0 var(--s-1); padding: var(--s-2) var(--s-3); font: var(--t-ui); background: var(--panel); border-left: 2px solid var(--good); }
.panel-msg.error { border-left-color: var(--bad); }
.panel-msg.info { border-left-color: var(--muted); }
.panel-search { display: flex; gap: var(--s-2); max-width: 420px; }
.panel-search input[type=text] { flex: 1; min-width: 0; height: 32px; }
.panel-filters { display: flex; flex-wrap: wrap; gap: var(--s-3); font: var(--t-ui); }
.panel-filters a, .panel-filters a:not(.btn) { color: var(--muted); text-decoration: none; }
.panel-filters a[aria-current] { color: var(--text); font-weight: 600; }
.panel-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.panel-actions + .panel-delete { margin-top: var(--s-4); }
.panel-delete label { display: block; margin-bottom: var(--s-2); color: var(--muted); font: var(--t-ui); }
.panel-delete label b { color: var(--text); }
.panel-tools { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.panel-tools li { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); background: var(--panel); padding: var(--s-3) var(--s-4); }
.panel-tools b { display: block; font: var(--t-ui); font-weight: 600; }
.panel-tools .muted { font: var(--t-xs); }
.panel-pager { display: flex; align-items: center; gap: var(--s-3); font: var(--t-sm); }
.panel-secret code { font: 500 18px/28px var(--mono); background: var(--panel); padding: var(--s-2) var(--s-3); user-select: all; word-break: break-all; }
.btn.danger { color: var(--bad); }
.btn.danger:not(:disabled):hover { background: rgba(255, 107, 122, 0.12); color: var(--bad); }

/* ---- responsive */
@media (max-width: 960px) {
  .auth-page { grid-template-columns: minmax(0, 1fr); gap: var(--s-12); padding-top: var(--s-10); }
  .home { grid-template-columns: minmax(0, 1fr); max-width: 640px; gap: var(--s-16); }
  .recent-wrap { padding-top: 0; }
  .pitch h1 { font: 600 36px/44px var(--font); letter-spacing: -0.02em; }
  .auth { max-width: 440px; order: -1; }
  .studio-page { overflow: auto; }
  .record-layout, .finish-layout { grid-template-columns: 1fr; height: auto; }
  .stage-panel { min-height: 360px; }
  .sidebar { max-height: 420px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .lyrics { padding: var(--s-3) var(--s-4) var(--s-12); }
  .lyr-tools { top: auto; bottom: var(--s-2); transform: none; opacity: 1; }
  .transport { flex-wrap: wrap; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid, .metrics-cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .topbar { grid-template-columns: auto 1fr; }
  .topbar-center { grid-column: 1 / -1; grid-row: 2; padding-bottom: var(--s-2); }
  .topbar-center:empty { display: none; }
  .studio-page .topbar { height: auto; padding-top: var(--s-2); }
  .studio-page .toast { top: 104px; }          /* below the two-row top bar */
  .project-name, .user { display: none; }
  .home, .prose { padding-top: var(--s-10); }
  h1 { font: 600 24px/32px var(--font); }
  .pitch h1 { font: 600 32px/40px var(--font); }
  .toc ol { columns: 1; }
  .home-actions { flex-direction: column; align-items: stretch; }
  .home-actions .btn { width: 100%; }
  .list .row-actions { opacity: 1; }
  .footer-inner { flex-direction: column-reverse; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .wave-trace { animation: none; stroke-dashoffset: 0; }
}

/* scrolling still works (wheel, touch, keys); the bar itself is hidden */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }

.finish-legend { display: flex; gap: var(--s-4); margin: 0 var(--s-3) var(--s-2); color: var(--muted); font: var(--t-sm); }
.finish-legend .swatch { display: inline-block; margin-right: var(--s-2); vertical-align: middle; }
.swatch.raw { height: 3px; background: rgba(242, 243, 245, 0.35); }
