/* Chord Trainer — graphite chrome, brass accent (shares Sightreader's palette). */

:root {
  --bg: #111317; --surface-1: #181b20; --surface-2: #20242b; --surface-3: #2a2f37;
  --line: #2b3038; --line-2: #3a404a;
  --text: #f0ede6; --text-2: #a8a69f; --text-3: #6f6e69; --ink: #1a1917;
  --accent: #e2b04a; --accent-2: #b07a12; --accent-soft: rgba(226, 176, 74, 0.16);
  --good: #2fbf8f; --good-soft: rgba(47, 191, 143, 0.18);
  --bad: #e5534b; --bad-soft: rgba(229, 83, 75, 0.16);
  --blue: #3987e5; --blue-soft: rgba(57, 135, 229, 0.2);
  --key-white: #f3efe6; --key-black: #16181c; --key-edge: #2a2e36;
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --rail: 84px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45; display: flex; height: 100dvh; -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; -webkit-user-select: none; user-select: none; overscroll-behavior: none; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; border: 0; background: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h2, h3 { margin: 0; letter-spacing: -0.01em; }
b { font-weight: 700; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.grow { flex: 1; }
[hidden] { display: none !important; }

/* ---- Rail ---- */
.rail { width: var(--rail); flex: none; display: flex; flex-direction: column; align-items: center; padding: 14px 0 12px; gap: 10px; background: var(--surface-1); border-right: 1px solid var(--line); }
.rail-brand { margin-bottom: 10px; }
.rail-tabs { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 0 10px; }
.rail-tabs button { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; padding: 10px 0 8px; border-radius: var(--r-md); color: var(--text-3); font-size: 11px; font-weight: 600; transition: background 0.15s, color 0.15s; }
.rail-tabs button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rail-tabs button.on { background: var(--surface-3); color: var(--text); }
.rail-tabs button:not(.on):hover { color: var(--text-2); }
.rail-foot { margin-top: auto; width: 100%; padding: 0 8px; position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.midi-status { display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; font-size: 10.5px; color: var(--text-3); line-height: 1.2; cursor: pointer; padding: 6px; border-radius: var(--r-sm); }
.midi-status:hover { background: var(--surface-2); }
.midi-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); box-shadow: 0 0 0 3px rgba(255,255,255,0.04); }
.midi-status[data-state="ok"] .dot { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.midi-status[data-state="none"] .dot { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.midi-status.pedal .dot { box-shadow: 0 0 0 3px var(--accent-soft); background: var(--accent); }
.midi-text { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.midi-menu { position: absolute; left: calc(100% + 6px); bottom: 0; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 6px; display: flex; flex-direction: column; min-width: 190px; z-index: 20; box-shadow: 0 12px 32px rgba(0,0,0,0.4); }
.midi-menu button { text-align: left; padding: 8px 10px; border-radius: var(--r-sm); font-size: 13px; color: var(--text-2); }
.midi-menu button.on { color: var(--text); background: var(--surface-3); }
.midi-menu button:hover { background: var(--surface-3); }
.version { font-size: 9.5px; color: var(--text-3); }

/* ---- Layout ---- */
main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
.view { display: none; flex: 1; min-height: 0; flex-direction: column; padding: 12px 20px 10px; gap: 8px; }
.view.on { display: flex; }
.mode-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.piano-slot { flex: none; }
.return-bar { position: absolute; top: 10px; right: 20px; z-index: 5; }
.piano-wrap { flex: none; display: flex; flex-direction: column; gap: 4px; }
.piano-wrap #piano { width: 100%; }
.piano-svg { width: 100%; height: clamp(110px, 20vh, 190px); display: block; border-radius: var(--r-md); background: var(--surface-1); }
.session-line { font-size: 12px; color: var(--text-3); text-align: right; min-height: 16px; }

/* ---- Piano keys ---- */
.key rect { stroke: var(--key-edge); stroke-width: 1; transition: fill 0.08s; }
.key.white rect { fill: var(--key-white); }
.key.black rect { fill: var(--key-black); }
.key .klabel { font-size: 11px; font-weight: 600; fill: rgba(0,0,0,0.45); pointer-events: none; }
.key.black .klabel { fill: rgba(255,255,255,0.55); font-size: 10px; }
.key .kfinger { font-size: 12px; font-weight: 800; fill: var(--ink); pointer-events: none; }
.key.black .kfinger { fill: #fff; }
.key.t-target rect { fill: #f6d98a; }
.key.black.t-target rect { fill: #b98a2a; }
.key.t-stay rect { fill: #cfe7d9; }
.key.black.t-stay rect { fill: #3e7a62; }
.key.t-move rect { fill: #f3b36a; }
.key.black.t-move rect { fill: #b5611c; }
.key.t-lh rect { fill: #c8d8f2; }
.key.black.t-lh rect { fill: #2c5a9a; }
.key.t-ghost rect { fill: #ddd7c8; }
.key.held rect { fill: #86b7f0 !important; }
.key.black.held rect { fill: #3a7fd0 !important; }
.key.hit rect { fill: var(--good) !important; }
.key.wrong rect { fill: var(--bad) !important; }
.key.sus rect { opacity: 0.85; stroke: var(--blue); stroke-width: 2; }
.key.held .klabel, .key.hit .klabel, .key.wrong .klabel { fill: #fff; }
.arrow { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; opacity: 0.75; }
.arrow-head { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0.75; }

/* ---- Top bar and controls ---- */
.mode-top { display: flex; align-items: center; gap: 12px; min-height: 40px; flex-wrap: wrap; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.hint-keys { color: var(--text-3); font-size: 11.5px; margin-right: 6px; white-space: nowrap; }
.seg { position: relative; display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.seg button { padding: 7px 15px; border-radius: 999px; color: var(--text-2); font-weight: 600; font-size: 13.5px; transition: color 0.15s, background 0.15s; white-space: nowrap; }
.seg button.on { color: var(--ink); background: var(--accent); }
.seg.seg-small button { padding: 5px 11px; font-size: 12.5px; }
button.primary { background: var(--accent); color: var(--ink); font-weight: 700; padding: 8px 18px; border-radius: 999px; }
button.primary:hover { background: #ecbf5e; }
button.ghost { background: var(--surface-2); color: var(--text-2); font-weight: 600; padding: 8px 14px; border-radius: 999px; }
button.ghost:hover { background: var(--surface-3); color: var(--text); }
button.ghost.on { color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-2); }
button.ghost.small, button.small { padding: 5px 11px; font-size: 12.5px; }
button.ghost.rec { color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
button.link { color: var(--accent); font-weight: 600; padding: 2px 4px; }
button.link:hover { text-decoration: underline; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { padding: 5px 11px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: 12.5px; }
.chip.on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-2); }
.chip:hover { color: var(--text); }
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.tog { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px 5px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.tog-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); }
.tog.on { color: var(--text); } .tog.on .tog-dot { background: var(--good); }
input.text, input[type=number] { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 5px 9px; color: var(--text); font-size: 13px; }
input.text { min-width: 220px; }
.options { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.opt-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.opt-label { width: 84px; flex: none; color: var(--text-3); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.opt-note { color: var(--text-3); font-size: 12px; }
.opt-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 12.5px; margin-left: 8px; }

/* ---- Stage and prompt ---- */
.stage { flex: 1; min-height: 0; display: flex; gap: 16px; overflow: hidden; }
.ex-root { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.idle { text-align: center; color: var(--text-2); max-width: 560px; margin: 0 auto; font-size: 15px; line-height: 1.5; }
.prompt-card { position: relative; background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 26px 16px; text-align: center; transition: border-color 0.15s, box-shadow 0.15s; }
.prompt-card.ok, .ok > .prompt-card { border-color: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.prompt-card.bad, .bad > .prompt-card { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.prompt-sub { color: var(--text-2); font-size: 14px; min-height: 20px; }
.prompt-main { font-size: clamp(44px, 8vh, 76px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin: 4px 0; }
.prompt-main .cur { color: var(--accent); }
.prompt-main .done { color: var(--text-3); }
.prompt-main .todo { color: var(--text-3); opacity: 0.55; }
.prompt-main .arrow-sep { color: var(--text-3); font-size: 0.5em; margin: 0 10px; vertical-align: middle; }
.prompt-notes { color: var(--text-2); font-size: 16px; min-height: 22px; letter-spacing: 0.02em; }
.prompt-feedback { margin-top: 6px; min-height: 22px; font-size: 14.5px; color: var(--text-2); }
.ok-text { color: var(--good); font-weight: 700; }
.bad-text { color: var(--bad); font-weight: 700; }
.song-link { color: var(--text-3); font-size: 13px; }
.prompt-timer { height: 4px; background: var(--surface-3); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.prompt-timer .bar { height: 100%; width: 100%; background: var(--accent); }
.run-meta { display: flex; gap: 18px; justify-content: center; color: var(--text-3); font-size: 13px; }

/* ---- Summary ---- */
.summary { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 26px; max-width: 640px; margin: 0 auto; width: 100%; }
.summary h2 { font-size: 18px; margin-bottom: 12px; }
.sum-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.sum-label { color: var(--text-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.sum-value { font-size: 26px; font-weight: 800; }
.sum-lines { display: flex; flex-direction: column; gap: 4px; color: var(--text-2); font-size: 14px; }
.sum-k { display: inline-block; width: 90px; color: var(--text-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.sum-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ---- Recognition ---- */
.rec-panel { flex: 1; background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 26px; display: flex; flex-direction: column; gap: 8px; justify-content: center; align-items: center; text-align: center; transition: opacity 0.2s; }
.rec-panel.stale { opacity: 0.6; }
.rec-empty { color: var(--text-3); font-size: 16px; }
.rec-notes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.rec-notes span { background: var(--surface-3); border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.rec-main { font-size: clamp(40px, 7vh, 68px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.rec-detail { display: flex; gap: 16px; color: var(--text-2); font-size: 14px; flex-wrap: wrap; justify-content: center; }
.rec-formula { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.rec-formula span, .tone { display: inline-flex; flex-direction: column; align-items: center; background: var(--surface-2); border-radius: var(--r-sm); padding: 4px 10px; font-weight: 700; font-size: 15px; min-width: 42px; }
.rec-formula span em, .tone em { font-style: normal; font-size: 10.5px; color: var(--text-3); font-weight: 700; }
.rec-formula span.dim { opacity: 0.4; }
.rec-alts { color: var(--text-2); font-size: 13.5px; display: flex; gap: 6px 10px; flex-wrap: wrap; justify-content: center; }
.rec-sugg { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; align-items: center; font-size: 14px; }
.sugg-row { display: flex; gap: 10px; align-items: baseline; }

/* ---- Progressions ---- */
.stage:has(.prog-strip) { flex-direction: column; gap: 10px; }
.prog-strip { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; }
.prog-chord { position: relative; background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 16px; min-width: 88px; text-align: center; cursor: pointer; transition: border-color 0.15s, transform 0.15s; }
.prog-chord.cur { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); transform: translateY(-2px); }
.prog-chord.done { opacity: 0.7; }
.prog-chord.playing { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.pc-sym { font-size: 20px; font-weight: 800; }
.pc-num { font-size: 11.5px; color: var(--text-3); }
.pc-mark { position: absolute; top: 4px; right: 8px; font-size: 11px; color: var(--good); }
.prog-arrow { color: var(--text-3); }
.prog-main { flex: 1; min-height: 0; display: flex; gap: 16px; align-items: stretch; }
.prog-main .prompt-card { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.vl-panel { width: 320px; flex: none; display: flex; flex-direction: column; justify-content: center; gap: 6px; font-size: 13.5px; color: var(--text-2); }
.vl-panel:empty { display: none; }
.vl-row { display: flex; gap: 10px; align-items: baseline; background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 12px; }
.vl-row.alt { border-color: var(--accent-2); }
.vl-row.good { border-color: var(--good); }
.vl-k { width: 74px; flex: none; color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }

/* ---- Songs ---- */
.song-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.song-stage { gap: 16px; }
.song-left { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.song-side { width: 300px; flex: none; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.side-block:empty { display: none; }
.side-block { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.side-title { color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; margin-bottom: 2px; }
.side-sub { color: var(--text-3); font-size: 12px; margin-top: 6px; }
.link-row { text-align: left; padding: 6px 8px; border-radius: var(--r-sm); color: var(--text-2); font-size: 13.5px; }
.link-row:hover { background: var(--surface-2); color: var(--text); }
.link-row b { color: var(--accent); }
.link-row.small { padding: 3px 8px; font-size: 13px; }
.harm-row { display: flex; gap: 10px; align-items: baseline; font-size: 13px; color: var(--text-2); }
.song-head { display: flex; flex-direction: column; gap: 2px; }
.song-title { font-size: 20px; font-weight: 800; }
.song-level { color: var(--text-2); font-size: 13.5px; }
.focus-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.focus-tags span { background: var(--surface-2); border-radius: 999px; padding: 2px 9px; font-size: 11.5px; color: var(--text-3); }
.section-tabs { display: flex; gap: 6px; }
.stab { padding: 5px 12px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: 13px; }
.stab.on { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.bar-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.bar { display: flex; align-items: center; gap: 3px; background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px 6px 3px 4px; }
.bar-num { font-size: 10.5px; color: var(--text-3); width: 16px; text-align: center; }
.bar-chord { padding: 3px 9px; border-radius: 6px; font-weight: 700; font-size: 14px; color: var(--text-2); }
.bar-chord.cur { background: var(--accent); color: var(--ink); }
.bar-chord.inloop:not(.cur) { box-shadow: inset 0 0 0 1px var(--accent-2); }
.song-card { flex: 1; display: flex; flex-direction: column; justify-content: center; min-height: 0; }
.song-card .prompt-main { font-size: clamp(36px, 7vh, 64px); }

/* ---- Explore ---- */
.rec-panel.big { font-size: 15px; }
.explorer { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.chips.wrap { max-width: 100%; }
.xp-body { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 22px; display: flex; flex-direction: column; gap: 10px; }
.xp-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.xp-sym { font-size: 40px; font-weight: 800; letter-spacing: -0.02em; }
.xp-name { color: var(--text-2); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.xp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.xp-k { width: 84px; flex: none; color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.pill { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; background: var(--surface-2); border-radius: var(--r-sm); padding: 6px 11px; color: var(--text); font-weight: 700; font-size: 13px; }
.pill .muted { font-weight: 500; font-size: 12px; }
.pill:hover { background: var(--surface-3); }
.harm-card { background: var(--surface-2); border-radius: var(--r-md); padding: 10px 14px; display: flex; flex-direction: column; gap: 4px; border: 1px solid transparent; }
.harm-card.ok { border-color: var(--good); }
.hc-name { font-weight: 800; }
.hc-notes { display: flex; gap: 16px; color: var(--text-2); font-size: 14px; }
.hc-actions { display: flex; gap: 6px; margin-top: 4px; }

/* ---- Toast ---- */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px); background: var(--surface-3); color: var(--text); padding: 9px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s var(--ease-out); z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,0.4); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .vl-panel, .song-side { width: 100%; }
  .prog-main, .song-stage { flex-direction: column; }
  .hint-keys { display: none; }
}
