/* Nocturne — a lacquered grand piano in the browser */

:root {
  --page: #1d1a17;
  --page-2: #26221e;
  --text: #ece5d6;
  --muted: #aca291;
  --line: rgba(236, 229, 214, 0.14);
  --brass: #c8a25a;
  --brass-strong: #e2bf78;
  --on-brass: #1d1a17;
  --trail: 214, 176, 102;
  --felt: #8c1c2c;
  --felt-dark: #5e0f1b;
  --lacquer-1: #0e0c0b;
  --lacquer-2: #2b2521;
  --ivory: #f4efe2;
  --ivory-shade: #ddd5c2;
  --ivory-lip: #cfc5ae;
  --ebony-1: #2d2723;
  --ebony-2: #0d0b0a;
  --label: #5d5446;
  --hint-bg: rgba(200, 162, 90, 0.2);
  --hint-text: #6a4c14;
  --mm-white: #d9d1bf;
  --mm-black: #2a2420;
  --surface: #2a2622;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  --lane: rgba(236, 229, 214, 0.035);
  --lane-mine: rgba(200, 162, 90, 0.10);
  --flag: rgba(226, 150, 60, 0.10);
  --other-note: #8d8577;
  --play-other: #8fa7c2;
  --mine2: #6fb3a2; --mine2-strong: #93d1c1;
  --mine3: #c98aa6; --mine3-strong: #e3a9c2;
  --trail-2: 111, 179, 162; --trail-3: 201, 138, 166; --trail-other: 143, 167, 194;
  --sing-hit: 88, 214, 156; --sing-close: 236, 178, 76; --sing-miss: 238, 104, 112;

  --key-w: 22px;
  --lane-h: clamp(110px, 22vh, 220px);
  --felt-h: 9px;
  --keys-h: clamp(150px, 36vh, 320px);
  --font-ui: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Bodoni Moda', 'Didot', 'Bodoni 72', Georgia, serif;
  color-scheme: dark;
}

:root[data-theme='light'] {
  --page: #e4e2de;
  --page-2: #d6d3ce;
  --text: #24201c;
  --muted: #5c554c;
  --line: rgba(36, 32, 28, 0.16);
  --brass: #8a6526;
  --brass-strong: #6e4f1b;
  --on-brass: #fff;
  --trail: 176, 128, 48;
  --trail-2: 47, 128, 108; --trail-3: 160, 82, 118; --trail-other: 92, 122, 160;
  --sing-hit: 22, 138, 92; --sing-close: 168, 106, 10; --sing-miss: 196, 48, 62;
  --lacquer-1: #f7f6f4;
  --lacquer-2: #dedbd6;
  --mm-white: #fbfaf7;
  --mm-black: #3a3430;
  --surface: #f7f6f3;
  --shadow: 0 18px 44px rgba(40, 32, 24, 0.18);
  --lane: rgba(36, 32, 28, 0.04);
  --lane-mine: rgba(138, 101, 38, 0.12);
  --flag: rgba(214, 120, 30, 0.12);
  --other-note: #9a9184;
  --play-other: #6f8fb5;
  --mine2: #2f7f6d; --mine2-strong: #1f6556;
  --mine3: #9a4f72; --mine3-strong: #7d3a5a;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--page-2), transparent 70%),
    var(--page);
  color: var(--text);
  font: 500 14px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: 2px solid var(--brass-strong); outline-offset: 2px; }

/* ── Top bar ───────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px 28px;
  padding: 14px clamp(16px, 3vw, 36px);
  flex-wrap: wrap;
}
.wordmark {
  margin: 0;
  font: 400 30px/1 var(--font-display);
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, var(--brass-strong) 0%, var(--brass) 55%, #9c7a3c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
:root[data-theme='light'] .wordmark { background: none; color: var(--brass); }

.controls {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin-left: auto;
}
.ctl { display: flex; align-items: center; gap: 8px; }
.ctl-label { color: var(--muted); font-size: 12.5px; }
.ctl-value { min-width: 2.6em; font-variant-numeric: tabular-nums; font-size: 13px; }
.ctl-range input { width: 92px; accent-color: var(--brass); cursor: pointer; }
.dyn { font: italic 500 17px/1 var(--font-display); text-align: center; min-width: 1.8em; }
.range-out { min-width: 5.6em; text-align: center; }

.step, .icon-btn {
  display: inline-grid; place-items: center;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.step { width: 28px; height: 28px; border-radius: 50%; font: 600 16px/1 var(--font-ui); padding: 0; }
.step:hover, .icon-btn:hover { border-color: var(--brass); background: color-mix(in srgb, var(--brass) 12%, transparent); }

.ctl-icons { display: flex; gap: 6px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.pedal {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 6px 14px 6px 8px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--brass) 60%, transparent);
  background: transparent;
  color: var(--text);
  font: 600 13px var(--font-ui);
  cursor: pointer;
  user-select: none;
  touch-action: none;
}
.pedal-shape {
  width: 22px; height: 14px;
  border-radius: 3px 3px 9px 9px;
  background: linear-gradient(180deg, var(--brass-strong), var(--brass));
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.25);
  transition: transform .08s;
}
.pedal[aria-pressed='true'] { background: var(--brass); color: var(--on-brass); border-color: var(--brass); }
.pedal[aria-pressed='true'] .pedal-shape { transform: translateY(2px) scaleY(.8); background: var(--on-brass); }

.popover {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 20;
  width: 280px;
  padding: 14px 16px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.popover fieldset { border: 0; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; }
.popover legend { font-weight: 700; font-size: 12.5px; margin-bottom: 4px; padding: 0; }
.popover label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.popover input { accent-color: var(--brass); }
.midi-line { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }

/* ── The instrument ───────────────────────────── */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 0 clamp(16px, 3vw, 36px) 12px;
  min-width: 0;
}

.cabinet {
  position: relative;
  border-radius: 22px 22px 14px 14px;
  padding: 0 14px 16px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.07) 0, rgba(255,255,255,0) 22%),
    linear-gradient(180deg, var(--lacquer-2), var(--lacquer-1) 60%);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.08);
  isolation: isolate;
}
:root[data-theme='light'] .cabinet { box-shadow: var(--shadow), inset 0 1px 0 #fff, inset 0 0 0 1px rgba(0,0,0,.06); }

.desk {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: var(--lane-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
  z-index: 2;
  text-align: center;
  padding: 0 24px;
}
.chord { display: grid; gap: 6px; }
.chord-name {
  font: 400 clamp(34px, 6vh, 56px)/1 var(--font-display);
  color: var(--text);
  text-shadow: 0 2px 24px rgba(0,0,0,.35);
}
.chord-notes { color: var(--muted); font-size: 13px; letter-spacing: .04em; word-spacing: .3em; min-height: 1.2em; }
.desk-hint { margin: 0; color: var(--muted); max-width: 44ch; transition: opacity .3s; }
.played .desk-hint, .no-chord .chord { display: none; }
.felt { display: none; }

.keyboard-scroll {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 0 0 8px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  overscroll-behavior-x: contain;
}
.keyboard-scroll:focus-visible { outline: 1px solid color-mix(in srgb, var(--brass) 45%, transparent); outline-offset: 3px; }

.keyboard {
  position: relative;
  width: max(100%, calc(var(--white-count) * var(--key-w)));
  height: calc(var(--lane-h) + var(--felt-h) + var(--keys-h));
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
/* Red felt strip, as on a real key slip */
.keyboard::before {
  content: '';
  position: absolute; left: 0; right: 0;
  top: var(--lane-h); height: var(--felt-h);
  background: linear-gradient(180deg, var(--felt), var(--felt-dark));
  box-shadow: 0 1px 0 rgba(0,0,0,.4);
  z-index: 1;
}
.trails {
  position: absolute; left: 0; top: 0;
  width: 100%; height: var(--lane-h);
  pointer-events: none;
}

.key {
  position: absolute;
  top: calc(var(--lane-h) + var(--felt-h));
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  transition: transform .05s ease-out, box-shadow .12s, background .12s;
  --vel: .6;
}
.key.white {
  height: var(--keys-h);
  z-index: 1;
  border-radius: 0 0 5px 5px;
  background: linear-gradient(180deg, var(--ivory-shade) 0, var(--ivory) 7%, var(--ivory) 94%, var(--ivory-shade) 100%);
  box-shadow:
    inset -1px 0 0 rgba(0,0,0,.2),
    inset 1px 0 0 rgba(255,255,255,.7),
    inset 0 -7px 0 var(--ivory-lip),
    0 3px 3px rgba(0,0,0,.35);
  padding-bottom: 14px;
}
.key.black {
  height: calc(var(--keys-h) * .63);
  z-index: 2;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(180deg, var(--ebony-2) 0, var(--ebony-1) 12%, var(--ebony-2) 92%);
  box-shadow:
    inset 1px 0 0 rgba(255,255,255,.08),
    inset 0 -8px 0 #3a332e,
    inset 0 -9px 0 rgba(255,255,255,.12),
    0 4px 6px rgba(0,0,0,.55);
  padding-bottom: 14px;
}

/* Pressed: key sinks, lip shortens, brass light glows from beneath */
.key.white.down {
  transform: translateY(2px);
  background: linear-gradient(180deg, #d8ccae 0, #f0e3c4 10%, #f3e6c8 100%);
  box-shadow:
    inset -1px 0 0 rgba(0,0,0,.2),
    inset 0 -3px 0 var(--ivory-lip),
    inset 0 10px 14px rgba(0,0,0,.12),
    0 0 calc(10px + var(--vel) * 22px) rgba(var(--trail), calc(.35 + var(--vel) * .4));
}
.key.black.down {
  transform: translateY(2px);
  background: linear-gradient(180deg, #000 0, #3b3127 20%, #2a221c 100%);
  box-shadow:
    inset 0 -4px 0 #3a332e,
    0 0 calc(8px + var(--vel) * 18px) rgba(var(--trail), calc(.4 + var(--vel) * .4));
}
/* Released under the sustain pedal: still ringing */
.key.ringing::after {
  content: '';
  position: absolute; left: 22%; right: 22%; bottom: 4px; height: 2px; border-radius: 2px;
  background: rgb(var(--trail));
  box-shadow: 0 0 6px rgb(var(--trail));
}

.label {
  font-size: 10px; font-weight: 600; line-height: 1;
  color: var(--label);
  display: none;
}
:root[data-labels='all'] .key.white .label,
:root[data-labels='c'] .key.is-c .label { display: block; }

.hint {
  display: none;
  min-width: 15px; height: 15px; margin-bottom: 6px; padding: 0 3px;
  border-radius: 4px;
  font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
  background: var(--hint-bg); color: var(--hint-text);
}
.key.black .hint { background: rgba(255,255,255,.1); color: #e8d4a8; }
.key.mapped .hint { display: block; }
.no-hints .key .hint { display: none; }
.key.white.mapped { background: linear-gradient(180deg, var(--ivory-shade) 0, var(--ivory) 7%, var(--ivory) 88%, #ead9b2 100%); }

/* ── Start overlay ────────────────────────────── */
.start {
  position: absolute; inset: 0; z-index: 10;
  display: grid; place-items: center;
  border-radius: inherit;
  background: color-mix(in srgb, var(--page) 55%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity .35s ease, visibility .35s;
}
.start.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.start-card { display: grid; justify-items: center; gap: 16px; padding: 24px; text-align: center; }
.start-title { margin: 0; font: 400 clamp(26px, 4vw, 40px)/1.1 var(--font-display); }
.btn-primary {
  border: 0; border-radius: 999px;
  padding: 12px 28px;
  background: var(--brass); color: var(--on-brass);
  font: 700 15px var(--font-ui);
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.btn-primary:hover { background: var(--brass-strong); }
.load { display: grid; justify-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.load-bar { width: 200px; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.load-bar span { display: block; height: 100%; width: 0; background: var(--brass); transition: width .2s; }

/* ── Below the piano: playing controls on either side of the keyboard navigator ── */
.below { display: grid; justify-items: center; gap: 8px; }
.keybar { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px 22px; flex-wrap: wrap; }
.minimap-wrap { width: min(720px, 100%); flex: 0 1 720px; min-width: 200px; }
.minimap {
  display: block; width: 100%; height: 30px;
  border-radius: 5px;
  cursor: grab;
  touch-action: none;
}
.status { margin: 0; color: var(--muted); font-size: 12.5px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.status .sep { width: 4px; height: 4px; border-radius: 50%; background: var(--line); }
#status-midi.ok { color: var(--brass-strong); }
.link-btn {
  border: 0; background: none; padding: 2px 0; cursor: pointer;
  color: var(--brass-strong); font: 600 12.5px var(--font-ui);
  text-decoration: underline; text-underline-offset: 3px;
}
/* the hidden attribute always wins over a component's own display (e.g. the rehearsal panel's grid) */
[hidden] { display: none !important; }
.credit { text-align: center; color: var(--muted); font-size: 11.5px; padding: 6px 16px 14px; }

/* ── Help dialog ──────────────────────────────── */
.help {
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px 26px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.help::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(3px); }
.help h2 { margin: 0 0 16px; font: 400 28px/1.1 var(--font-display); }
.help-keys { display: grid; gap: 5px; margin-bottom: 16px; }
.help-row { display: flex; gap: 4px; flex-wrap: wrap; }
.help-row:last-child { padding-left: 14px; }
.kc {
  width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 5px; font-size: 11.5px; font-weight: 700;
  background: var(--ivory); color: #3b342b; box-shadow: inset 0 -3px 0 var(--ivory-lip);
}
.kc.dim { background: #26201c; color: #e8d4a8; box-shadow: inset 0 -3px 0 #4a413a; }
.help table { width: 100%; border-collapse: collapse; }
.help th { text-align: left; font-weight: 500; white-space: nowrap; padding: 6px 16px 6px 0; vertical-align: top; }
.help td { padding: 6px 0; color: var(--muted); }
.help tr + tr { border-top: 1px solid var(--line); }
kbd {
  display: inline-block; min-width: 22px; padding: 1px 6px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  font: 600 12px var(--font-ui); text-align: center;
}
.help-note { color: var(--muted); margin: 14px 0 18px; }
.help form { display: flex; justify-content: flex-end; }

/* ── Library button / title ───────────────────── */
.score-switch { display: flex; align-items: center; gap: 12px; min-width: 0; }
.library-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 10px;
  border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text);
  font: 600 13px var(--font-ui); cursor: pointer;
}
.library-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.library-btn:hover { border-color: var(--brass); }
.score-title { font: 400 19px/1.2 var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }

/* ── Rehearsal panel ─────────────────────────── */
.rehearse {
  border-radius: 18px; border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  display: grid; grid-template-rows: auto 1fr auto; min-height: 0;
}
.rehearsing { --lane-h: 100px; --keys-h: clamp(120px, 22vh, 200px); }
.rehearsing .stage { justify-content: flex-start; padding-top: 4px; }
.rehearsing .desk-hint { display: none; }
.rehearsing .chord-name { font-size: 28px; }
/* Rehearsing: the falling notes keep the middle; song facts on the left, the chord on the right */
.song-info { display: none; }
.rehearsing .desk { flex-direction: row; justify-content: space-between; align-items: center; padding: 0 22px; }
.rehearsing .chord { justify-items: end; text-align: right; gap: 4px; }
.rehearsing .song-info {
  display: grid; grid-template-columns: auto auto; gap: 1px 10px; margin: 0; align-content: center;
  font-size: 12px; text-align: left; color: var(--text);
}
.song-info dt { color: var(--muted); }
.song-info dd { margin: 0; font-weight: 600; }
.song-info small { color: var(--muted); font-weight: 500; font-size: 11.5px; }
.chord-notes .vn { margin-left: .9em; white-space: nowrap; word-spacing: normal; }
.chord-notes .vn b { color: var(--muted); font-weight: 600; font-size: 11px; margin-right: .15em; }
.chord-notes .vn.mine { color: var(--brass-strong); font-weight: 700; }
.chord-notes .vn.mine2 { color: var(--mine2-strong); font-weight: 700; }
.chord-notes .vn.mine3 { color: var(--mine3-strong); font-weight: 700; }
.chord-notes .vn.mine b, .chord-notes .vn.mine2 b, .chord-notes .vn.mine3 b { color: inherit; }
.rehearsing .below .status { display: none; }
.transport {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.btn-play {
  width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--brass); color: var(--on-brass); cursor: pointer; flex: none;
}
.btn-play svg { width: 22px; height: 22px; fill: currentColor; }
.btn-play .i-pause, .btn-play.playing .i-play { display: none; }
.btn-play.playing .i-pause { display: block; }
.tbtn {
  border: 1px solid var(--line); background: transparent; color: var(--text);
  border-radius: 999px; padding: 6px 12px; font: 600 12.5px var(--font-ui); cursor: pointer; white-space: nowrap;
}
.tbtn:hover { border-color: var(--brass); }
.tbtn.icon { display: inline-grid; place-items: center; padding: 0; width: 34px; height: 30px; }
.tbtn.icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tbtn:disabled { opacity: .45; cursor: default; }
.tbtn.toggle[aria-pressed='true'] { background: color-mix(in srgb, var(--brass) 22%, transparent); border-color: var(--brass); }
.tbtn.ghost { border-color: transparent; color: var(--muted); }
.tselect { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 10px; font: 600 12.5px var(--font-ui); cursor: pointer; }
.metro { display: flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 999px; padding: 0 4px 0 12px; font: 600 12.5px var(--font-ui); color: var(--text); }
.metro-icon { display: none; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.metro select { border: 0; background: transparent; color: var(--muted); font: 600 12.5px var(--font-ui); padding: 6px 2px; cursor: pointer; }
.metro select option { background: var(--surface); color: var(--text); }
.metro.on { background: color-mix(in srgb, var(--brass) 22%, transparent); border-color: var(--brass); }
.metro.on select { color: var(--text); }
.metro:focus-within { outline: 2px solid var(--brass); outline-offset: 2px; }
.tsep { width: 1px; height: 22px; background: var(--line); }
#r-close { margin-left: auto; }
.pos { font-variant-numeric: tabular-nums; min-width: 92px; }
.pos strong { font: 400 22px var(--font-display); }
.pos-label, .pos-of { color: var(--muted); font-size: 12.5px; }
.tctl { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.tctl input { width: 110px; accent-color: var(--brass); }
/* Tempo: printed tempo | practice speed slider | what you hear */
.tempo { display: flex; align-items: center; gap: 8px; padding: 3px 4px 3px 12px; border: 1px solid var(--line); border-radius: 999px; }
.tempo-printed { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12.5px; padding-right: 10px; border-right: 1px solid var(--line); }
.tempo-printed input { width: 46px; border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 8px; padding: 3px 5px; font: 600 13px var(--font-ui); }
.tempo-speed { display: flex; }
.tempo-speed input { width: 96px; accent-color: var(--brass); cursor: pointer; }
.tempo-out {
  border: 0; background: none; color: var(--muted); font: 600 12.5px var(--font-ui); font-variant-numeric: tabular-nums;
  min-width: 6.8em; text-align: left; padding: 4px 4px; border-radius: 6px; cursor: default; white-space: nowrap;
}
.tempo-out.changed { color: var(--brass-strong); cursor: pointer; }
.tempo-out.changed:hover { text-decoration: underline; text-underline-offset: 3px; }
.tctl output { color: var(--text); min-width: 3.2em; font-variant-numeric: tabular-nums; }

.workspace { display: grid; grid-template-columns: 210px 1fr; min-height: 230px; height: clamp(230px, 34vh, 380px); }
.mixer { border-right: 1px solid var(--line); overflow: hidden; }
.mix-row {
  display: flex; flex-direction: column; justify-content: center; gap: 5px; padding: 0 10px 0 14px;
  border-top: 1px solid var(--line); box-sizing: border-box; overflow: hidden;
}
.mix-row.mine { background: var(--lane-mine); }
.mix-row.mine.m2 .star, .mix-row.mine.m2 .mix-name { color: var(--mine2-strong); }
.mix-row.mine.m3 .star, .mix-row.mine.m3 .mix-name { color: var(--mine3-strong); }
.rename { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 13px; opacity: 0; flex: none; }
.mix-row:hover .rename, .rename:focus-visible { opacity: 1; }
@media (hover: none) { .rename { opacity: .7; } }
.rename-input { width: 100%; border: 1px solid var(--brass); background: var(--surface); color: var(--text); border-radius: 6px; padding: 3px 6px; font: 600 13px var(--font-ui); }
.add-mine { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 6px; width: 24px; height: 22px; font: 700 13px var(--font-ui); cursor: pointer; padding: 0; flex: none; }
.add-mine:hover { color: var(--text); border-color: var(--brass); }
.mix-row:not(.mine) .make-mine { display: none; }
.mix-head { display: flex; align-items: center; gap: 4px; min-height: 22px; }
.mix-name { font-weight: 700; font-size: 13px; display: flex; gap: 6px; align-items: center; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mix-row.mine .mix-name { color: var(--brass-strong); font-size: 14px; }
.star { color: var(--brass-strong); }
.mix-name.as-btn { display: block; border: 0; background: none; color: var(--text); padding: 0; cursor: pointer; font: 700 13px var(--font-ui); text-align: left; }
.mix-name.as-btn:hover { color: var(--brass-strong); text-decoration: underline; text-underline-offset: 3px; }
.mix-ctl { display: flex; align-items: center; gap: 6px; }
.mix-ctl input { flex: 1; min-width: 0; width: auto; accent-color: var(--brass); }
.mbtn {
  min-width: 26px; height: 24px; border-radius: 6px; border: 1px solid var(--line); background: transparent;
  color: var(--muted); font: 700 11px var(--font-ui); cursor: pointer; padding: 0 8px;
}
.mbtn[aria-pressed='true'] { background: var(--brass); color: var(--on-brass); border-color: var(--brass); }
.line-pick { display: flex; gap: 2px; }
.lbl-short { display: none; }
.line-pick button {
  border: 1px solid var(--line); background: transparent; color: var(--muted); font: 600 11px var(--font-ui);
  padding: 3px 8px; cursor: pointer; border-radius: 6px;
}
.line-pick button[aria-checked='true'] { color: var(--on-brass); background: var(--brass); border-color: var(--brass); }
.unison-sw { display: none; align-items: center; gap: 6px; align-self: flex-start; border: 0; background: none; padding: 2px 0;
  color: var(--muted); font: 600 11px var(--font-ui); cursor: pointer; }
.singing .unison-sw { display: inline-flex; }
.unison-sw i { width: 24px; height: 14px; border-radius: 7px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.unison-sw i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--text); transition: transform .15s; }
.unison-sw[aria-checked='true'] { color: var(--text); }
.unison-sw[aria-checked='true'] i { background: var(--brass); }
.unison-sw[aria-checked='true'] i::after { transform: translateX(10px); background: var(--on-brass); }
.unison-sw:focus-visible { outline: 2px solid var(--brass-strong); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { .unison-sw i, .unison-sw i::after { transition: none; } }
.make-mine { align-self: flex-start; border: 0; background: none; color: var(--muted); font: 600 11px var(--font-ui); padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.mix-row:not(:hover) .make-mine { opacity: 0; }
.make-mine:focus-visible { opacity: 1; }
.lane-wrap { position: relative; min-width: 0; min-height: 0; }
.lanes { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }

.rfoot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.presets button {
  display: grid; text-align: left; border: 1px solid var(--line); background: transparent; color: var(--text);
  border-radius: 10px; padding: 6px 12px; font: 700 13px var(--font-ui); cursor: pointer;
}
.presets small { font-weight: 500; font-size: 11px; color: var(--muted); }
.presets button[aria-checked='true'] { border-color: var(--brass); background: color-mix(in srgb, var(--brass) 18%, transparent); }
.rfoot-right { display: flex; gap: 8px; align-items: center; }
.pitch-help { display: flex; gap: 8px; margin-right: auto; }
.review-btn {
  border: 1px solid var(--line); background: transparent;
  color: var(--text); border-radius: 999px; padding: 7px 14px; font: 700 12.5px var(--font-ui); cursor: pointer;
}
.review-btn.flagged { border-color: color-mix(in srgb, #e2963c 60%, transparent); background: color-mix(in srgb, #e2963c 14%, transparent); }
.ed-nav { display: flex; align-items: center; gap: 6px; margin-right: auto; }
.ed-nav h2 { margin: 0 4px; display: flex; align-items: baseline; gap: 8px; }
.ed-goto { width: 3.2ch; font: inherit; color: inherit; background: transparent; border: 0; border-bottom: 1px dashed var(--line); padding: 0; -moz-appearance: textfield; }
.ed-goto::-webkit-inner-spin-button, .ed-goto::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ed-goto:hover, .ed-goto:focus { border-bottom-color: var(--brass); outline: none; }
.ed-nav .icon-btn { font-size: 20px; }
.ed-nav .icon-btn:disabled { opacity: .35; cursor: default; }
.ed-menu-wrap { position: relative; }
.ed-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 300px; padding: 8px; display: grid; gap: 2px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.35);
}
.ed-menu[hidden] { display: none; }
.ed-mi { text-align: left; background: none; border: 0; color: var(--text); font: 500 13px var(--font-ui); padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.ed-mi:hover:not(:disabled), .ed-mi:focus-visible { background: color-mix(in srgb, var(--brass) 16%, transparent); outline: none; }
.ed-mi:disabled { opacity: .4; cursor: default; }
.ed-mi.danger { color: #e07a5f; }
a.ed-mi { text-decoration: none; display: block; }
.ed-menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.ed-mrow { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 13px; }
.ed-mrow select, .ed-mrow input { margin-left: auto; background: var(--page); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font: inherit; }
.ed-mrow input { width: 5.5em; }
.ed-mhelp { margin: 0 10px 4px; color: var(--muted); font-size: 11.5px; }
.ed-repeats { border: 0; margin: 0; padding: 0; }
.ed-repeats legend { padding: 4px 10px; font-weight: 700; font-size: 12.5px; }
.ed-repeats input[type=checkbox] { accent-color: var(--brass); }
.ed-repeats .ed-mrow { justify-content: flex-start; }
.ed-repeats select { margin-left: auto; }
.ed-marks { flex-wrap: wrap; gap: 4px 12px; }
.ed-marks label { display: flex; gap: 6px; align-items: center; }
.ed-menu { max-height: min(80vh, 640px); overflow-y: auto; }
.sym { font-family: 'Apple Symbols', 'Noto Music', serif; }

/* keys lit by the score: mine in brass, others in a soft blue */
.key.white.play-mine { background: linear-gradient(180deg, #d8c08a 0, #ecd29a 12%, #f0dcae 100%); }
.key.black.play-mine { background: linear-gradient(180deg, #000 0, #6e5427 25%, #4d3a1b 100%); }
.key.white.play-mine2 { background: linear-gradient(180deg, #a9cfc4 0, #c6e3da 12%, #d6ece5 100%); }
.key.black.play-mine2 { background: linear-gradient(180deg, #000 0, #2d6a5c 25%, #1f4c41 100%); }
.key.white.play-mine3 { background: linear-gradient(180deg, #ddb3c6 0, #ecc9d8 12%, #f2d8e3 100%); }
.key.black.play-mine3 { background: linear-gradient(180deg, #000 0, #73405a 25%, #552e42 100%); }
.key.white.play-other { background: linear-gradient(180deg, #b9c6d4 0, #d6e0ea 12%, #e4ebf2 100%); }
.key.black.play-other { background: linear-gradient(180deg, #000 0, #36485c 25%, #26323f 100%); }

/* ── Sheets (library, wizard, editor) ────────── */
.sheet {
  width: min(1100px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  border: 1px solid var(--line); border-radius: 18px; padding: 0;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(3px); }
.sheet-head { display: flex; align-items: center; gap: 14px; padding: 18px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.sheet-head h2 { margin: 0; font: 400 26px/1.1 var(--font-display); margin-right: auto; }
.sheet-head input[type=search] {
  border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 999px;
  padding: 8px 14px; font: 500 13px var(--font-ui); width: min(260px, 100%);
}
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; padding: 20px 22px 24px; overflow: auto; max-height: calc(100dvh - 160px); }
.card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 4px; align-content: start; }
.card h3 { margin: 0; font: 400 21px/1.2 var(--font-display); }
.card-sub, .card-meta { margin: 0; color: var(--muted); font-size: 12.5px; }
.card-flag { margin: 4px 0 0; color: var(--brass-strong); font-size: 12.5px; font-weight: 600; }
.card-actions { display: flex; gap: 8px; margin-top: 12px; }
.card-actions .btn-primary { padding: 8px 18px; font-size: 13px; }
.btn-primary:disabled { opacity: .5; cursor: default; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 40px 20px; max-width: 52ch; margin: 0 auto; }
.empty p:first-child { color: var(--text); font: 400 22px var(--font-display); }

.wiz-body { padding: 20px 22px 24px; overflow: auto; max-height: calc(100dvh - 150px); }
.steps { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.steps li::before { content: counter(s); width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); font-size: 11px; }
.steps li + li::after { content: none; }
.steps li.current { color: var(--text); font-weight: 700; }
.steps li.current::before, .steps li.done::before { background: var(--brass); color: var(--on-brass); border-color: var(--brass); }
.drop {
  display: grid; place-items: center; gap: 6px; text-align: center; padding: 34px 20px; cursor: pointer;
  border: 2px dashed color-mix(in srgb, var(--brass) 50%, transparent); border-radius: 14px; color: var(--muted);
}
.drop strong { color: var(--text); font-size: 15px; }
.drop.over { background: color-mix(in srgb, var(--brass) 12%, transparent); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 2px solid var(--brass-strong); outline-offset: 2px; }
.thumbs { list-style: none; padding: 0; margin: 16px 0; display: flex; gap: 12px; flex-wrap: wrap; }
.thumbs li { width: 120px; display: grid; gap: 4px; justify-items: center; font-size: 12px; color: var(--muted); cursor: grab; }
.thumbs img { width: 120px; height: 160px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.thumb-actions { display: flex; gap: 4px; }
.thumb-actions button { border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 6px; width: 28px; height: 24px; cursor: pointer; }
.field { display: grid; gap: 6px; max-width: 420px; }
.field label { font-weight: 700; font-size: 13px; }
.field input { border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 10px; padding: 10px 12px; font: 500 14px var(--font-ui); }
.field-err { color: #e07a5f; margin: 0; font-size: 12.5px; min-height: 1em; }
.wiz-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.wiz-lead { margin: 0 0 14px; max-width: 64ch; }
.wiz-alt { margin: 10px 0 0; max-width: 72ch; font-size: .9rem; color: var(--muted, inherit); }
.progress-bar { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--brass); transition: width .3s; }
.page-status { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 6px; }
.page-status li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.page-status li strong { color: var(--text); min-width: 56px; }
.page-status small { width: 100%; padding-left: 66px; }
.page-status .ps-done { color: var(--brass-strong); }
.page-status .ps-failed { color: #e07a5f; }
.wiz-msg { color: var(--muted); }
.voice-pick { border: 0; padding: 0; margin: 0 0 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.voice-pick legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.voice-pick > div { display: flex; gap: 8px; flex-wrap: wrap; }
.voice-pick label { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
.voice-pick label:has(input:checked) { border-color: var(--brass); background: color-mix(in srgb, var(--brass) 14%, transparent); }
.voice-pick input { accent-color: var(--brass); }

.editor { display: none; }
.editor[open] { display: flex; flex-direction: column; overflow-y: auto; }
/* on short screens the editor scrolls, its action row stays at the bottom edge */
.editor .ed-actions { position: sticky; bottom: 0; z-index: 2; background: var(--surface); border-top: 1px solid var(--line); margin-top: 10px; }
.editor .ed-photo { position: relative; flex: none; height: clamp(200px, 34vh, 380px); background: color-mix(in srgb, var(--page) 88%, #000); box-shadow: inset 0 0 24px rgba(0,0,0,.25); border-bottom: 1px solid var(--line); overflow: hidden; cursor: grab; touch-action: none; }
.editor .ed-photo.dragging { cursor: grabbing; }
.editor .ed-photo:focus-visible { outline: 2px solid var(--brass-strong); outline-offset: -2px; }
.editor .ed-photo img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; user-select: none; }
/* the photo itself: a little softer in the dark theme so it doesn't glare */
:root:not([data-theme='light']) .editor .ed-photo img { filter: brightness(.86) sepia(.08) contrast(1.05); }
.editor .ed-photo img { border-radius: 2px; box-shadow: 0 2px 14px rgba(0,0,0,.35); }
.ed-mark { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; border-left: 2px solid var(--brass); border-right: 2px solid var(--brass); background: rgba(200, 162, 90, .1); }
.ed-zoom { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 4px; }
.ed-zoom .tbtn { background: var(--surface); min-width: 34px; }
.ed-flag { margin: 0; color: var(--brass-strong); font-size: 13px; flex-basis: 100%; }
.ed-canvas { display: block; width: 100%; height: clamp(180px, 34vh, 300px); flex: none; outline: none; cursor: pointer; }
.ed-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--brass-strong); }
.ed-tools { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 22px 0; }
.ed-group { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.ed-group + .ed-group { padding-left: 14px; border-left: 1px solid var(--line); }
.ed-tools .tbtn { padding: 5px 10px; font-size: 12.5px; }
.ed-tools .tbtn:disabled { opacity: .38; cursor: default; }
.ed-tools .tbtn[aria-pressed='true'] { background: var(--brass); color: var(--on-brass); border-color: var(--brass); }
.ed-tools .note-len { min-width: 34px; padding: 2px 7px; display: inline-flex; align-items: center; justify-content: center; }
.len-ico { width: 18px; height: 22px; display: block; }
#ed-flat, #ed-sharp { min-width: 34px; font-size: 17px; line-height: 1; padding: 3px 8px; }
.ed-tools [hidden] { display: none; }
.ed-note { margin: 8px 22px 0; min-height: 1.3em; font-size: 13px; color: var(--text); }
.ed-check { margin: 6px 22px 0; font-size: 13px; color: var(--brass-strong); }
.ed-check.bad { color: #e07a5f; }
.ed-actions { display: flex; gap: 8px; align-items: center; padding: 14px 22px 18px; }
.ed-actions .grow { flex: 1; }

.share { width: min(560px, calc(100vw - 32px)); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { accent-color: var(--brass); margin-top: 3px; }
a.btn-primary { text-decoration: none; display: inline-block; }
.small { font-size: 12.5px; color: var(--muted); }
.small a, .wiz-lead a { color: var(--brass-strong); }
#lib-import-label { cursor: pointer; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  display: flex; gap: 14px; align-items: center; padding: 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--page); font-weight: 600; font-size: 13px; box-shadow: var(--shadow);
}
/* shown in the browser's top layer (popover), so it is never hidden behind an open dialog */
.toast[popover] { inset: auto auto 24px 50%; margin: 0; border: 0; overflow: visible; }
.toast[popover]:not(:popover-open) { display: none; }
.toast button { border: 0; background: none; color: var(--brass); font: 700 13px var(--font-ui); cursor: pointer; text-decoration: underline; }
:root[data-theme='light'] .toast button { color: #e2bf78; }

/* ── Round knobs (optional, Settings → Volume controls) ── */
.knob { display: none; width: 30px; height: 30px; flex: none; cursor: grab; touch-action: none; border-radius: 50%; }
.knob:active { cursor: grabbing; }
.knob svg { width: 100%; height: 100%; display: block; }
.knob .k-track { fill: none; stroke: var(--line); stroke-width: 3; stroke-linecap: round; }
.knob .k-val { fill: none; stroke: var(--brass); stroke-width: 3; stroke-linecap: round; }
.knob .k-cap { fill: var(--surface); stroke: color-mix(in srgb, var(--text) 25%, transparent); stroke-width: 1; }
.knob .k-ptr { stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.knobs .knob { display: block; }
.knobs #volume, .knobs .mix-ctl input[type=range] { display: none; }
.knobs .mix-ctl .knob { width: 28px; height: 28px; flex: none; }

/* ── Responsive ───────────────────────────────── */
@media (max-width: 1400px) {
  .metro .metro-text, .tempo-printed > span:first-child {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .metro-icon { display: block; }
  .metro { padding-left: 10px; }
}
@media (max-width: 1100px) {
  .controls { margin-left: 0; width: 100%; }
  .ctl-icons { margin-left: auto; }
}
@media (max-width: 760px) {
  .workspace { grid-template-columns: 120px 1fr; }
  .mix-ctl input { width: 52px; }
  .line-pick button { padding: 3px 5px; }
  .score-title { display: none; }
  .mix-row .lbl-full { display: none; }      /* narrow voice column: M, S, 1., 2. */
  .mix-row .lbl-short { display: inline; }
}
@media (max-width: 640px) {
  .topbar { gap: 10px; padding-top: 10px; }
  .wordmark { font-size: 26px; }
  .controls { gap: 10px 14px; }
  .ctl-range input { width: 74px; }
  .ctl-icons { position: absolute; top: -44px; right: 0; }
  .popover { top: 0; }
  :root { --lane-h: clamp(90px, 18vh, 170px); --keys-h: clamp(140px, 26vh, 210px); }
  .cabinet { padding: 0 8px 10px; border-radius: 16px 16px 10px 10px; }
}

/* Rehearsing on small screens: the piano-only controls give way to the music */
@media (max-width: 760px), (max-height: 520px) and (orientation: landscape) {
  .rehearsing .controls .ctl-range:nth-of-type(2),
  .rehearsing .keybar .ctl-stepper { display: none; }
  .keybar { gap: 8px 12px; }
  .minimap-wrap { order: -1; flex-basis: 100%; min-width: 0; }
  .transport { gap: 6px 8px; padding: 8px 10px; }
  .tempo-printed > span:first-child { display: none; }
  .tempo-speed input { width: 84px; }
  .mix-row.mine .mix-ctl input { width: 44px; }
  .tctl input[type=range] { width: 84px; }
  #r-close { order: -1; margin-left: auto; }
  .tsep { display: none; }
  .mix-row { padding: 0 6px 0 8px; }
  .mix-row:not(.mine) .mix-ctl input { display: none; }
  .mix-ctl input { width: 64px; }
  .line-pick button { padding: 3px 4px; font-size: 10.5px; }
  .presets button { padding: 5px 9px; }
  .presets small { display: none; }
  .rfoot { padding: 8px 10px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .topbar { flex-wrap: wrap; }
  .controls { flex-wrap: wrap; }
  .score-switch { flex: none; }
  .workspace { height: auto; min-height: 200px; }
}

/* Touch-only devices have no letter keys to show */
@media (hover: none) and (pointer: coarse) { .key .hint { display: none !important; } .keybar .ctl-stepper:first-child { display: none; } }

/* Phones held sideways: the keys get the height */
@media (max-height: 520px) and (orientation: landscape) {
  :root { --lane-h: 64px; --keys-h: max(150px, calc(100dvh - 150px)); }
  .topbar { padding-top: 8px; padding-bottom: 8px; gap: 8px 16px; flex-wrap: nowrap; }
  .wordmark { font-size: 22px; }
  .controls { flex-wrap: nowrap; gap: 12px; width: auto; margin-left: auto; }
  .ctl-label, .ctl-range output { display: none; }
  .ctl-range input { width: 64px; }
  .ctl-icons { position: static; }
  .stage { justify-content: flex-start; }
  .desk-hint { display: none; }
  .rehearsing .song-info { display: none; }
  .chord-name { font-size: 26px; }
  .chord-notes { display: none; }
  .credit { display: none; }
}

/* ── Sing along (GOAL-4) ─────────────────────── */
/* on the sing-along stage the other voices step back: one compact line each in the mixer */
.singing .mix-row:not(.mine) { flex-direction: row; align-items: center; gap: 6px; opacity: .75; }
.singing .mix-row:not(.mine) .mix-head { flex: 1; min-width: 0; }
.singing .mix-row:not(.mine) .mix-ctl input, .singing .mix-row:not(.mine) .knob,
.singing .mix-row:not(.mine) .add-mine, .singing .mix-row:not(.mine) .rename { display: none; }
.singing .mix-row:not(.mine) .mbtn { width: auto; min-width: 24px; height: 22px; padding: 0 6px; font-size: 11px; white-space: nowrap; }   /* full words (LV "Klusināt" is long): never overlapping */
.sing-group { display: flex; align-items: center; gap: 6px; }
.mic-meter { height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
.mic-meter i { display: block; height: 100%; width: 0; background: rgb(var(--sing-hit)); box-shadow: 0 0 6px rgba(var(--sing-hit), .8); transition: width .06s linear; }
.mic-meter[data-level='quiet'] i { background: var(--muted); box-shadow: none; }
.mic-meter[data-level='loud'] i { background: rgb(var(--sing-miss)); }
.sing-btn {
  --streak: 0;
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid color-mix(in srgb, rgb(var(--sing-hit)) 55%, var(--line)); border-radius: 999px;
  padding: 7px 15px 7px 11px; background: transparent; color: var(--text);
  font: 700 13px var(--font-ui); cursor: pointer; white-space: nowrap;
}
.sing-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.sing-btn:hover { border-color: rgb(var(--sing-hit)); }
.sing-btn[aria-pressed='true'] {
  background: color-mix(in srgb, rgb(var(--sing-hit)) 20%, transparent); border-color: rgb(var(--sing-hit));
  box-shadow: 0 0 calc(6px + var(--streak) * 1.4px) calc(var(--streak) * 0.25px) rgba(var(--sing-hit), calc(0.25 + var(--streak) * 0.04));
  transition: box-shadow .4s ease;
}
/* listening: a softly pulsing ring while the microphone is open */
.sing-btn.listening::after {
  content: ''; position: absolute; inset: -4px; border-radius: inherit; pointer-events: none;
  border: 2px solid rgba(var(--sing-hit), .7); animation: sing-pulse 1.6s ease-out infinite;
}
@keyframes sing-pulse { 0% { opacity: .9; transform: scale(.97); } 100% { opacity: 0; transform: scale(1.12); } }
.sing-chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; background: transparent; color: var(--text);
  font: 600 12px var(--font-ui); cursor: pointer; white-space: nowrap;
}
.sing-chip[data-state='headphones'], .sing-chip[data-state='synced'] { border-color: rgb(var(--sing-hit)); box-shadow: inset 0 0 0 1px rgba(var(--sing-hit), .35), 0 0 10px rgba(var(--sing-hit), .25); }
.sing-chip[data-state='speakers'], .sing-chip[data-state='changed'], .sing-chip[data-state='bluetooth'] { border-color: rgb(var(--sing-close)); color: var(--text); background: rgba(var(--sing-close), .12); }
.sing-chip[data-state='nomic'] { border-color: rgb(var(--sing-miss)); background: rgba(var(--sing-miss), .1); }

/* the piano key nearest the sung pitch */
/* the sung key: a ring inside every key; black keys also glow outward (they sit on top already, so
   raising a white key would cover its black neighbours) */
.key.sung { box-shadow: inset 0 0 0 2px rgb(var(--sing-hit)), inset 0 0 12px 2px rgba(var(--sing-hit), .45) !important; }
.key.black.sung { box-shadow: inset 0 0 0 2px rgb(var(--sing-hit)), 0 0 14px 2px rgba(var(--sing-hit), .65) !important; z-index: 3; }

.sing-card {
  position: absolute; right: 12px; top: 34px; z-index: 4; max-width: min(420px, calc(100% - 24px));
  padding: 12px 14px; border-radius: 14px; border: 1px solid rgba(var(--sing-hit), .45);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px);
  box-shadow: var(--shadow), 0 0 22px rgba(var(--sing-hit), .18); font-size: 13px;
}
.sing-card p { margin: 0 0 6px; padding-right: 26px; }
.sing-card-close { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; padding: 0; }
.sing-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sing-dir { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-weight: 800; font-size: 12px; color: var(--page); }
.sing-dir.low, .sing-dir.high { background: rgb(var(--sing-miss)); }

.sing-setup { width: min(620px, calc(100vw - 32px)); }
.sing-setup .steps { padding: 14px 22px 0; }
.sing-setup .wiz-actions { gap: 8px; }
.privacy { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: rgba(var(--sing-hit), .08); font-size: 13.5px; }
.privacy svg { flex: none; width: 20px; height: 20px; fill: none; stroke: rgb(var(--sing-hit)); stroke-width: 1.8; }
.sing-msg { min-height: 1.2em; color: var(--muted); font-size: 13px; }
.mic-pick { margin-bottom: 6px; }
.mic-pick .field { font-weight: 700; font-size: 13px; max-width: none; }
.mic-pick select { width: 100%; }
#sing-mic-info { font-size: 12.5px; margin: 6px 0 0; }
#sing-mic-info[data-warn='1'] { color: var(--text); padding: 8px 10px; border-radius: 10px; background: rgba(var(--sing-close), .14); border: 1px solid rgba(var(--sing-close), .5); }
.hp-art { display: grid; place-items: center; margin: 4px 0 8px; }
.hp-art svg { width: 76px; height: 76px; fill: none; stroke: rgb(var(--sing-hit)); stroke-width: 2.4; stroke-linecap: round;
  filter: drop-shadow(0 0 8px rgba(var(--sing-hit), .55)); }
.sing-leak { padding: 10px 12px; border-radius: 12px; font-size: 13.5px; }
.sing-leak:empty { display: none; }
.sing-leak[data-result='good'] { background: rgba(var(--sing-hit), .12); border: 1px solid rgba(var(--sing-hit), .5); }
.sing-leak[data-result='bad'] { background: rgba(var(--sing-close), .12); border: 1px solid rgba(var(--sing-close), .55); }
.sing-sync { margin-top: 10px; font-size: 13.5px; }
.meter { height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 8px 0; }
.meter i { display: block; height: 100%; width: 0; border-radius: inherit; background: rgb(var(--sing-hit)); box-shadow: 0 0 12px rgba(var(--sing-hit), .8); transition: width .08s linear; }
.meter i[data-level='quiet'] { background: var(--muted); box-shadow: none; }
.meter i[data-level='loud'] { background: rgb(var(--sing-miss)); }
.field select { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px; padding: 9px 10px; font: 500 14px var(--font-ui); }
.sing-setup .field { margin-top: 14px; font-weight: 700; font-size: 13px; }

.sing-unison { margin-top: 14px; font-size: 13px; color: var(--muted); }
/* sing along follows one line of a divided part: "Both" is not offered while singing */
html.singing .line-pick.divided [data-line='both'] { display: none; }
.sing-which { font-weight: 600; opacity: .8; }
.sing-line { width: min(520px, calc(100vw - 32px)); }
.sing-line-body { padding: 16px 22px 22px; }
.sing-line-body .wiz-lead { margin: 0; }
.line-choices { display: grid; gap: 10px; margin-top: 14px; }
.line-choice { display: flex; gap: 8px; align-items: stretch; }
.line-choose {
  flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 12px; padding: 12px 16px; font: 500 13px var(--font-ui);
}
.line-choose strong { font-size: 16px; }
.line-choose span { color: var(--muted); }
.line-choose:hover, .line-choose:focus-visible { border-color: var(--brass); box-shadow: 0 0 0 3px rgba(var(--sing-hit), .18); }
.line-listen { align-self: center; white-space: nowrap; }

.sing-score { width: min(640px, calc(100vw - 32px)); }
.sing-score-body { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; padding: 22px; }
.score-ring { --p: 0; position: relative; width: 150px; height: 150px; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring circle { fill: none; stroke-width: 9; }
.score-ring .track { stroke: var(--line); }
.score-ring .fill { stroke: rgb(var(--sing-hit)); stroke-linecap: round; stroke-dasharray: calc(var(--p) * 1) 100;
  filter: drop-shadow(0 0 6px rgba(var(--sing-hit), .9)); }
.score-num { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.score-num strong { font: 400 48px/1 var(--font-display); }
.score-num span { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.score-ring.burst::after {
  content: ''; position: absolute; inset: -10px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(var(--sing-hit), .55), transparent 70%); animation: sing-burst 1.1s ease-out forwards;
}
@keyframes sing-burst { from { opacity: 1; transform: scale(.7); } to { opacity: 0; transform: scale(1.45); } }
.score-facts p { margin: 0 0 6px; }
.sing-best { font-weight: 800; color: rgb(var(--sing-hit)); }
.sing-calm { color: var(--text); }
.muted { color: var(--muted); }
.score-sections { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.score-sections li { display: grid; grid-template-columns: 8.5em 1fr 2.2em; gap: 8px; align-items: center; font-size: 12.5px; }
.score-sections .sbar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.score-sections i { --w: 0; display: block; height: 100%; width: calc(var(--w) * 1%); border-radius: inherit; background: rgb(var(--sing-hit)); box-shadow: 0 0 8px rgba(var(--sing-hit), .7); }
.score-sections li.weak i { background: rgb(var(--sing-close)); box-shadow: 0 0 8px rgba(var(--sing-close), .6); }
.score-sections li.weak span:first-child { font-weight: 800; }
.score-sections b { text-align: right; }
.sing-score-actions { gap: 8px; padding: 0 22px; flex-wrap: wrap; margin-top: 0; }
.sing-history { padding: 16px 22px 22px; }
.sing-history h3 { margin: 0 0 8px; font: 400 19px var(--font-display); }
.hist-chart { width: 100%; max-width: 420px; height: auto; aspect-ratio: 280 / 70; display: block; }
.hist-chart path { fill: none; stroke: rgba(var(--sing-hit), .8); stroke-width: 2; }
.hist-chart circle { fill: rgb(var(--sing-hit)); }
.hist-chart circle.best { filter: drop-shadow(0 0 5px rgba(var(--sing-hit), 1)); }
.hist-chart circle.cur { stroke: var(--text); stroke-width: 1.5; }
.hist-chart .best-label { fill: rgb(var(--sing-hit)); font: 700 10px var(--font-ui); }
.hist-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 2px; font-size: 13px; max-height: 200px; overflow: auto; }
.hist-list li { display: grid; grid-template-columns: 9.5em 2.5em 1fr auto; gap: 8px; align-items: center; }
.hist-undo { margin: 8px 0 0; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.card-sing { color: rgb(var(--sing-hit)) !important; font-weight: 600; }
:root[data-theme='light'] .card-sing { color: rgb(12, 100, 64) !important; }   /* small text on the light card: AA contrast */
@media (max-width: 560px) {
  .sing-score-body { grid-template-columns: 1fr; justify-items: center; }
  .score-sections li { grid-template-columns: 7em 1fr 2.2em; }
}
@media (max-width: 760px) {
  .sing-group { display: none; }    /* phones: not supported yet (see the explanation in the tips) */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .key.white.down, .key.black.down { box-shadow: inset 0 -3px 0 var(--ivory-lip); }
  .key.black.down { box-shadow: inset 0 -4px 0 #3a332e; }
}
/* light theme: a darker red, readable on the light surface (WCAG AA) */
:root[data-theme='light'] .ed-mi.danger, :root[data-theme='light'] .ed-check.bad { color: #a8381c; }

/* ── accounts (server mode) ── */
.account { position: relative; }
.account-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 999px; padding: 3px 12px 3px 3px; font: 600 13px var(--font-ui); cursor: pointer; }
.account-btn:hover, .account-btn[aria-expanded='true'] { border-color: var(--brass); }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--brass); color: var(--on-brass); font-weight: 700; }
.account-name { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu { right: 0; left: auto; width: 260px; padding: 8px; display: grid; gap: 2px; }
.account-menu form { margin: 0; display: grid; }
.account-who { margin: 4px 10px 8px; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.people { width: min(720px, calc(100vw - 32px)); }
.people-body { padding: 16px 22px 22px; }
.people-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 14px 0; font-weight: 600; font-size: 13px; }
.people-add input, .people-copy input { flex: 1; min-width: 12em; background: var(--page); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font: 500 14px var(--font-ui); }
.people-link { border: 1px solid var(--brass); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; background: color-mix(in srgb, var(--brass) 8%, transparent); }
.people-link p { margin: 0 0 8px; font-size: 13px; }
.people-copy { display: flex; gap: 8px; }
.people-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.people-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.people-list .who { display: grid; }
.people-list .actions { display: flex; gap: 6px; }
.tbtn.danger { color: #e07a5f; }
:root[data-theme='light'] .tbtn.danger { color: #a8381c; }
@media (max-width: 640px) { .people-list li { grid-template-columns: 1fr; } .account-name { display: none; } .account-btn { padding: 3px; } }
/* sign-in and sign-in-link pages */
.auth-page { min-height: 100dvh; display: grid; place-items: center; margin: 0; padding: 16px; background: var(--page); color: var(--text); font-family: var(--font-ui); }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px 28px 30px; box-shadow: var(--shadow); }
.auth-card .wordmark { margin: 0 0 18px; font: 400 34px/1 var(--font-display); color: var(--brass); }
.auth-card h1 { margin: 0 0 10px; font: 400 26px/1.15 var(--font-display); }
.auth-card p { line-height: 1.5; }
.auth-card .muted { color: var(--muted); }
.auth-card form { margin-top: 18px; }
.auth-card .btn-primary { width: 100%; padding: 12px; font-size: 15px; }
.auth-note { border-left: 3px solid var(--brass); padding-left: 10px; }

.people-invite { display: flex; gap: 10px; align-items: center; margin: 14px 0 4px; font-size: 13px; }
.people-list li.pending { border-style: dashed; }
/* Sign in with Google (Google's button guidance: white, the G logo, "Sign in with Google") */
.btn-google { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 18px 0 8px; padding: 11px 16px; border-radius: 999px;
  background: #fff; color: #1f1f1f; border: 1px solid #747775; font: 600 15px var(--font-ui); text-decoration: none; }
.btn-google:hover { background: #f4f6f8; }
.btn-google:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }
.btn-google svg { width: 20px; height: 20px; }

/* small primary button: keeps the dark text on gold (the general .small text style is grey) */
.btn-primary.small { padding: 7px 16px; font-size: 13px; color: var(--on-brass); }

/* privacy policy and terms */
.auth-foot { margin: 22px 0 0; font-size: 12.5px; color: var(--muted); text-align: center; }
.auth-foot a, .legal-card a, .credit a { color: var(--brass-strong); }
.legal-page { place-items: start center; }
.legal-card { width: min(760px, 100%); margin: 24px auto 48px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px clamp(18px, 4vw, 44px) 40px; }
.legal-card .wordmark { margin: 0 0 6px; font: 400 32px/1 var(--font-display); }
.legal-card .wordmark a { color: var(--brass); text-decoration: none; }
.legal-nav { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.legal-nav [aria-current] { color: var(--text); font-weight: 700; text-decoration: none; }
.legal-card h1 { font: 400 32px/1.15 var(--font-display); margin: 8px 0 4px; }
.legal-card h2 { font: 700 16px/1.3 var(--font-ui); margin: 26px 0 6px; }
.legal-card p, .legal-card li { line-height: 1.6; font-size: 15px; max-width: 70ch; }
.legal-card ul { padding-left: 1.2em; }
.legal-meta { color: var(--muted); font-size: 13px !important; margin-top: 0; }

.voices-check { width: min(560px, calc(100vw - 32px)); }
.voices-list { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 6px; }
.voices-list label { display: flex; align-items: center; gap: 10px; justify-content: space-between; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.voices-list select { background: var(--page); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; }
