:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-2: #eef3f2;
  --text: #1f2d2b;
  --muted: #687a77;
  --border: #dfe8e6;
  --accent: #2a9d8f;
  --accent-soft: #dcf1ee;
  --accent-text: #ffffff;
  --teal: #7c9cf0;          /* secondary (beat lights) */
  --good: #2f9e6b;
  --bad: #e07a8a;
  --wood: #f1e2c6;          /* light maple fretboard */
  --wood-dark: #e6d1ab;
  --fret-wire: #b9b2a6;
  --string: #9a9488;
  --inlay: #d8ccb6;
  --shadow: 0 1px 2px rgba(30, 60, 55, .04), 0 8px 24px rgba(30, 60, 55, .06);
  --radius: 18px;
  color-scheme: light;
}

/* Dark theme: follows the system unless the user picked Light,
   and always applies when the user picked Dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131a1f;
    --surface: #1a232a;
    --surface-2: #222d35;
    --text: #e8f0ef;
    --muted: #93a5a8;
    --border: #2c3a43;
    --accent: #5cc8b8;
    --accent-soft: #1f3a3a;
    --accent-text: #0f1f1d;
    --teal: #8fa8f5;
    --good: #5fcf98;
    --bad: #f0919f;
    --wood: #3a3128;
    --wood-dark: #30281f;
    --fret-wire: #7d7569;
    --string: #c9bfa9;
    --inlay: #6a5f50;
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .2);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131a1f;
  --surface: #1a232a;
  --surface-2: #222d35;
  --text: #e8f0ef;
  --muted: #93a5a8;
  --border: #2c3a43;
  --accent: #5cc8b8;
  --accent-soft: #1f3a3a;
  --accent-text: #0f1f1d;
  --teal: #8fa8f5;
  --good: #5fcf98;
  --bad: #f0919f;
  --wood: #3a3128;
  --wood-dark: #30281f;
  --fret-wire: #7d7569;
  --string: #c9bfa9;
  --inlay: #6a5f50;
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .2);
  color-scheme: dark;
}
body { transition: background-color .25s, color .25s; }
.theme-btn {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.theme-btn:hover { border-color: var(--accent); color: var(--accent); }
.theme-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background-image: radial-gradient(900px 400px at 85% -10%, var(--accent-soft), transparent 70%);
  background-repeat: no-repeat;
  min-height: 100vh;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin-bottom: .35rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 1.25rem 0 .5rem; }
.sub { color: var(--muted); margin: .3rem 0 0; }
.small { font-size: .9rem; }
kbd {
  font: 600 .8em ui-monospace, monospace;
  border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; padding: 0 .35em; background: var(--surface);
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1160px; margin: 0 auto; padding: .6rem 16px;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: .45rem;
  font-weight: 750; font-size: 1.15rem; color: var(--text); text-decoration: none;
}
.brand-logo { width: 34px; height: 34px; margin: -5px 0; display: block; }
/* Logo swaps with the theme: same rules as the colour tokens (system setting unless overridden). */
.brand-logo.for-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo.for-light { display: none; }
  :root:not([data-theme="light"]) .brand-logo.for-dark { display: block; }
}
:root[data-theme="dark"] .brand-logo.for-light { display: none; }
:root[data-theme="dark"] .brand-logo.for-dark { display: block; }
.tabs { display: flex; gap: .25rem; background: var(--surface-2); padding: .25rem; border-radius: 999px; }
.tab {
  border: 0; background: none; padding: .4rem .9rem; border-radius: 999px;
  font-weight: 600; color: var(--muted);
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.status { margin-left: auto; display: flex; gap: .4rem; }
.pill {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: .25rem .7rem; font-size: .85rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pill::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: .4rem; vertical-align: 1px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* ---------- Layout ---------- */
main { max-width: 1160px; margin: 0 auto; padding: 1.5rem 16px 3rem; }
.panel { display: none; }
.panel.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem;
}
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 0 16px 2rem; }

/* ---------- Controls ---------- */
.input {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: .5rem .75rem;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search { width: min(280px, 100%); }
.input.tiny { width: 4.2em; padding: .2rem .35rem; text-align: center; }
.btn {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 12px; padding: .55rem 1rem; font-weight: 600;
  transition: transform .05s, background .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.big { padding: .75rem 1.4rem; font-size: 1.05rem; min-width: 7.5rem; }
.btn.running { background: var(--text); border-color: var(--text); color: var(--bg); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chip {
  border: 1px solid var(--border); background: var(--surface);
  padding: .3rem .8rem; border-radius: 999px; font-weight: 600; font-size: .9rem;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.seg { display: inline-flex; background: var(--surface-2); padding: .2rem; border-radius: 12px; }
.seg button { border: 0; background: none; padding: .4rem .85rem; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.check { display: flex; align-items: center; gap: .5rem; cursor: pointer; user-select: none; }
.check input { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; }
.field { display: grid; gap: .3rem; margin-bottom: .9rem; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field.inline { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0 0; }
.field.inline .input { flex: 1; min-width: 0; }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: none; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 99px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent); box-shadow: var(--shadow);
}
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }

/* ---------- Chords ---------- */
.chord-layout { display: grid; grid-template-columns: 1fr 360px; gap: 1.25rem; align-items: start; }
.chord-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .75rem; }
.chord-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: .6rem .5rem .4rem; text-align: center; transition: border-color .15s, transform .1s;
}
.chord-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.chord-card.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.chord-card .cname { font-weight: 750; font-size: 1.05rem; }
.chord-card .diagram { width: 100%; max-width: 104px; display: block; margin: 0 auto; }
.empty { color: var(--muted); grid-column: 1 / -1; padding: 2rem 0; text-align: center; }

.chord-detail { position: sticky; top: 76px; }
.cd-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.cd-name { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; }
.badge { font-size: .75rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.inter { background: var(--accent-soft); color: var(--accent); }
.cd-full { color: var(--muted); margin-top: -.1rem; }
.cd-diagram { max-width: 220px; margin: .5rem auto; }
.cd-diagram .diagram { width: 100%; display: block; }
.cd-play { display: flex; gap: .5rem; justify-content: center; margin-bottom: .5rem; }
.steps { margin: .25rem 0 0; padding-left: 1.25rem; }
.steps li { margin-bottom: .4rem; }
.steps li::marker { color: var(--accent); font-weight: 700; }
.tone-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.tone { border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: .2rem .6rem; font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .82rem; color: var(--muted); margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.legend b { color: var(--accent); }

/* Chord diagram SVG */
.d-fret { stroke: var(--muted); stroke-opacity: .45; stroke-width: 1; }
.d-string { stroke: var(--text); stroke-opacity: .75; }
.d-nut { fill: var(--text); }
.d-dot { fill: var(--accent); }
.d-fing { fill: var(--accent-text); font: 700 10px system-ui, sans-serif; }
.d-open { fill: none; stroke: var(--text); stroke-width: 1.4; }
.d-mute { fill: var(--muted); font: 600 12px system-ui, sans-serif; }
.d-base { fill: var(--muted); font: 600 9px system-ui, sans-serif; }
.d-lbl { fill: var(--muted); font: 600 8.5px system-ui, sans-serif; }

/* ---------- Fretboard ---------- */
.fretboard-card { padding: 1rem; }
.fretboard-scroll { overflow-x: auto; padding-bottom: .25rem; }
.fretboard {
  --cols: 26px 46px repeat(12, minmax(48px, 1fr));
  min-width: 720px;
}
.fb-row, .fb-marks { display: grid; grid-template-columns: var(--cols); }
.fb-body { background: linear-gradient(180deg, var(--wood), var(--wood-dark)); border-radius: 6px; position: relative; }
.fb-body .fb-row:first-child .fb-label { border-top-left-radius: 6px; }
.fb-label {
  display: grid; place-items: center; font-weight: 700; font-size: .8rem;
  color: var(--muted); background: var(--bg);
}
.fb-cell {
  position: relative; height: 36px; border: 0; background: none; padding: 0;
  border-right: 3px solid var(--fret-wire);
  display: grid; place-items: center;
}
.fb-cell.open { background: var(--bg); border-right: 7px solid var(--inlay); }
.fb-cell::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  height: var(--thick, 1px); transform: translateY(-50%);
  background: var(--string); box-shadow: 0 1px 1px rgba(0,0,0,.35);
}
.fb-cell.open::before { background: var(--muted); opacity: .45; box-shadow: none; }
.fb-note {
  position: relative; z-index: 1;
  min-width: 30px; height: 24px; padding: 0 4px; border-radius: 12px;
  display: grid; place-items: center;
  font-size: .78rem; font-weight: 700;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  transition: transform .1s, background .15s, opacity .15s;
}
.fb-cell:hover .fb-note { transform: scale(1.12); }
.fb-note.sharp { background: var(--surface-2); color: var(--muted); }
.fb-note.hide { opacity: 0; }
.fb-cell:hover .fb-note.hide { opacity: .9; }
.fb-note.hit { background: var(--accent); border-color: var(--accent); color: var(--accent-text); opacity: 1; }
.fb-note.dim { opacity: .18; }
.fb-note.good { background: var(--good); border-color: var(--good); color: #fff; opacity: 1; }
.fb-note.bad { background: var(--bad); border-color: var(--bad); color: #fff; opacity: 1; }
.fb-row.target .fb-label { color: var(--accent); }
.fb-row.target .fb-cell:not(.open) { background: rgba(255, 255, 255, .06); }
.fb-marks { margin-top: .35rem; }
.fb-mark { text-align: center; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.fb-mark .dots { display: flex; justify-content: center; gap: 3px; height: 8px; margin-bottom: 1px; }
.fb-mark .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); opacity: .8; }
.fb-controls { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin-top: .9rem; }

.notes-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; margin-top: 1.25rem; }
.quiz-row { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
.quiz-score { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.quiz-feedback { min-height: 1.5rem; margin-top: .5rem; font-weight: 600; }
.quiz-feedback.good { color: var(--good); }
.quiz-feedback.bad { color: var(--bad); }
.quiz-card .sub b { color: var(--accent); font-size: 1.1rem; }
.tuning { display: flex; gap: .4rem; margin-top: .9rem; }
.tuning button {
  flex: 1; border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 10px; padding: .55rem 0; font-weight: 800;
}
.tuning button small { display: block; font-weight: 600; color: var(--muted); font-size: .7rem; }
.tuning button:hover, .chromatic button:hover { border-color: var(--accent); }
.chromatic { display: grid; grid-template-columns: repeat(6, 1fr); gap: .35rem; margin-top: .9rem; }
.chromatic button {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 9px; padding: .35rem 0; font-weight: 700; font-size: .85rem;
}
.chromatic button.acc { background: var(--surface-2); color: var(--muted); font-size: .75rem; }

/* ---------- Metronome ---------- */
.metro-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1.25rem; align-items: start; }
.metro-main { text-align: center; padding: 2rem 1.5rem; }
.beats { display: flex; justify-content: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1.75rem; min-height: 26px; }
.beat {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface-2); border: 2px solid var(--border);
  transition: transform .06s, background .06s;
}
.beat.accent { border-color: var(--accent); }
.beat.lit { background: var(--teal); border-color: var(--teal); transform: scale(1.2); }
.beat.accent.lit { background: var(--accent); border-color: var(--accent); }
.bpm-display { display: flex; align-items: center; justify-content: center; gap: .6rem; }
.bpm { min-width: 9rem; }
.bpm-num { font-size: 5rem; font-weight: 800; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; transition: transform .08s; }
.bpm-num.pulse { transform: scale(1.04); }
.bpm-label { color: var(--muted); font-weight: 600; margin-top: .3rem; }
.round {
  width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2); font-weight: 700;
}
.round.sm { width: 40px; height: 40px; font-size: .85rem; }
.round:hover { border-color: var(--accent); }
#bpmSlider { margin: 1.75rem 0 1.5rem; }
.metro-actions, .timer-actions { display: flex; justify-content: center; gap: .6rem; flex-wrap: wrap; }
.trainer { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.trainer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .6rem; }
.trainer-grid label { display: grid; gap: .25rem; }
.trainer-grid span { font-size: .78rem; font-weight: 700; color: var(--muted); }
.trainer-grid .input { width: 100%; text-align: center; padding: .4rem .3rem; }
.beat { border-color: color-mix(in srgb, var(--muted) 45%, transparent); }

/* ---------- Timer ---------- */
.timer-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1.25rem; align-items: start; }
.timer-main { padding: 2rem 1.5rem; }
.ring-wrap { position: relative; width: min(280px, 100%); margin: 0 auto 1.5rem; aspect-ratio: 1; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.time { font-size: 3.6rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1; }
.time-label { color: var(--muted); font-weight: 600; margin-top: .4rem; }
.done .ring-fg { stroke: var(--good); }
.presets { display: flex; justify-content: center; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.25rem; }
.presets[hidden] { display: none; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .75rem; }
.stat { background: var(--surface-2); border-radius: 12px; padding: .7rem .5rem; text-align: center; }
.stat-num { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .78rem; color: var(--muted); font-weight: 600; }
.sessions { list-style: none; margin: 0; padding: 0; }
.sessions li { display: flex; justify-content: space-between; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.sessions li:last-child { border-bottom: 0; }
.sessions .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sessions .when { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sessions .none { color: var(--muted); }

/* ---------- Theory / key explorer ---------- */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap; margin-bottom: .2rem; }
.head-controls { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.seg.sm button { padding: .25rem .65rem; font-size: .85rem; }
.chips.tight { margin: 0; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 700; font-size: .82rem; }
.link:hover { text-decoration: underline; }
.key-card { margin-bottom: 1.25rem; }
.key-top { display: flex; align-items: center; justify-content: center; gap: 1.25rem; }
.key-current { text-align: center; min-width: 0; }
.key-big { font-size: 2.4rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.key-info { color: var(--muted); margin-top: .3rem; }
.key-info b { color: var(--text); }
.key-info .badge { background: var(--accent-soft); color: var(--accent); margin-right: .25rem; }
#keySlider { margin: 1.1rem 0 .2rem; }
.key-ticks { display: grid; grid-template-columns: repeat(12, 1fr); }
.key-ticks button {
  border: 0; background: none; padding: .3rem 0; border-radius: 8px;
  font-weight: 700; font-size: .85rem; color: var(--muted);
}
.key-ticks button:hover { color: var(--text); background: var(--surface-2); }
.key-ticks button.on { color: var(--accent-text); background: var(--accent); }
.key-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: .75rem; }
.key-foot .sub { margin: 0; }

.theory-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; align-items: start; }
.dia-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .5rem; margin-top: .8rem; }
.dia {
  border: 1px solid var(--border); border-radius: 14px; padding: .6rem .4rem; text-align: center;
  cursor: pointer; background: var(--surface); transition: border-color .15s, transform .1s, background .15s;
}
.dia:hover { border-color: var(--accent); transform: translateY(-2px); }
.dia.flash { background: var(--accent-soft); }
.dia-roman { font: 800 1.05rem Georgia, "Times New Roman", serif; color: var(--accent); }
.dia.minor .dia-roman { color: var(--teal); }
.dia-name { font-weight: 800; font-size: 1.15rem; }
.dia-notes { font-size: .75rem; color: var(--muted); }
.dia .link { margin-top: .2rem; font-size: .75rem; }

.prog { display: flex; gap: .8rem; align-items: flex-start; padding: .75rem 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.prog:last-child { border-bottom: 0; padding-bottom: 0; }
.prog-play {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--accent); font-size: .85rem;
}
.prog:hover .prog-play, .prog.playing .prog-play { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.prog-name { font-weight: 800; }
.prog-name .sub { font-weight: 600; margin-left: .3rem; font-family: Georgia, serif; }
.prog-chords { display: flex; flex-wrap: wrap; gap: .3rem; margin: .35rem 0 .2rem; }
.pc { padding: .1rem .55rem; border-radius: 8px; background: var(--surface-2); font-weight: 700; font-size: .9rem; transition: background .1s, color .1s; }
.pc.now { background: var(--accent); color: var(--accent-text); }

.sr-card { margin-bottom: 1.25rem; }
.sr-card h3:first-of-type { margin-top: .75rem; }
.sr-item { border: 1px solid var(--border); border-radius: 14px; padding: .55rem .75rem .6rem; margin-bottom: .5rem; cursor: pointer; transition: border-color .15s, background .15s; }
.sr-item:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
.sr-item.open { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface)); cursor: default; }
.sr-item.open .sr-head, .sr-item.open .sr-track { cursor: pointer; }
.sr-head { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; }
.sr-deg { font: 800 .95rem Georgia, serif; color: var(--accent); min-width: 2.2rem; }
.sr-title { font-weight: 800; }
.sr-aka { color: var(--muted); font-size: .85rem; }
.sr-steps { margin-left: auto; font: 600 .75rem ui-monospace, monospace; color: var(--muted); letter-spacing: .03em; }
.sr-play { color: var(--accent); font-size: .75rem; margin-left: .25rem; }
.sr-steps + .sr-play { margin-left: .25rem; }
.sr-head .sr-play:first-child, .sr-aka + .sr-play, .sr-title + .sr-play { margin-left: auto; }
.sr-scroll { overflow-x: auto; }
.sr-track {
  display: grid; grid-template-columns: repeat(var(--n), minmax(30px, 1fr));
  min-width: calc(var(--n) * 30px); position: relative; padding: 2px 0;
}
.sr-track::before {
  content: ""; position: absolute; left: 12px; right: 12px; top: 17px; height: 4px; border-radius: 4px;
  background: repeating-linear-gradient(90deg, var(--border) 0 2px, var(--surface-2) 2px calc(100% / var(--n)));
}
.sr-note { position: relative; display: grid; justify-items: center; }
.sr-note b {
  display: grid; place-items: center; min-width: 28px; height: 30px; padding: 0 3px;
  border: 1.5px solid var(--text); border-radius: 7px; background: var(--surface);
  font-size: .85rem; font-weight: 800;
}
.sr-note.root b { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.sr-note small { font-size: .72rem; font-weight: 700; color: var(--muted); margin-top: 1px; }
.sr-expand { margin-top: .75rem; padding-top: .75rem; border-top: 1px dashed var(--border); cursor: default; }
.sr-expand > .sub:first-child { margin: 0 0 .6rem; color: var(--text); }
.sr-expand .fretboard-scroll { background: var(--surface); border-radius: 10px; padding: .5rem; }
.sr-expand .fb-cell { height: 32px; }
.fb-hint { margin-top: .5rem; }

/* ---------- Ear training ---------- */
.ear-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1.25rem; align-items: start; }
.ear-main { padding: 1.5rem; }
.ear-controls { display: flex; gap: 1rem; flex-wrap: wrap; }
.ear-controls .field { flex: 1; min-width: 150px; }
.ear-controls .field[hidden] { display: none; }
.ear-actions { display: flex; justify-content: center; gap: .6rem; margin: .5rem 0 1rem; }
.ear-actions .btn[hidden] { display: none; }
.ear-feedback { text-align: center; min-height: 3.2rem; font-size: 1.05rem; }
.ear-feedback .hint { display: block; color: var(--text); font-weight: 600; font-size: .95rem; margin-top: .2rem; }
.ear-feedback .sub { display: block; }
.ear-feedback.good { color: var(--good); font-weight: 800; }
.ear-feedback.bad { color: var(--bad); font-weight: 800; }
.ear-answers { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .5rem; margin-top: 1rem; }
.ear-ans {
  border: 1px solid var(--border); background: var(--surface); border-radius: 12px;
  padding: .7rem .5rem; display: grid; gap: .1rem; transition: border-color .15s, background .15s, transform .05s;
}
.ear-ans:hover { border-color: var(--accent); }
.ear-ans:active { transform: scale(.97); }
.ear-ans small { color: var(--muted); font-size: .75rem; }
.ear-ans.right { background: var(--good); border-color: var(--good); color: #fff; }
.ear-ans.wrong { background: var(--bad); border-color: var(--bad); color: #fff; }
.ear-ans.right small, .ear-ans.wrong small { color: rgba(255,255,255,.85); }
.stats.two { grid-template-columns: 1fr 1fr; }
.acc-row { display: grid; grid-template-columns: 7.5rem 1fr 3rem; align-items: center; gap: .5rem; font-size: .88rem; margin-bottom: .35rem; }
.acc-bar { height: 8px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.acc-bar i { display: block; height: 100%; background: var(--good); border-radius: 8px; }
.acc-bar i.low { background: var(--bad); }
.acc-num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
#earReset { margin-top: .5rem; }
.tips { margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: .9rem; }
.tips li { margin-bottom: .3rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .chord-layout, .metro-layout, .timer-layout, .ear-layout, .theory-grid { grid-template-columns: 1fr; }
  .tabs { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .tab { white-space: nowrap; }
  .sr-steps { margin-left: 0; width: 100%; }
  .chord-detail { position: static; order: -1; }
  .notes-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .topbar-inner { gap: .5rem; }
  .tab { padding: .4rem .7rem; font-size: .9rem; }
  .key-big { font-size: 1.8rem; }
  .key-ticks button { font-size: .7rem; }
  h1 { font-size: 1.35rem; }
  .bpm-num { font-size: 3.6rem; }
  .bpm { min-width: 6rem; }
  .round { width: 44px; height: 44px; }
  .round.sm { width: 34px; height: 34px; }
  .time { font-size: 2.8rem; }
  .chord-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}

/* =========================================================
   Shared: tab icons, sub-navigation, vertical fretboard
   ========================================================= */
.tab svg { display: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.show-sm { display: none; }
.fb-label, .fb-cell.open { background: var(--surface); }
.fb-cell.target:not(.open) { background: color-mix(in srgb, var(--accent) 14%, transparent); }

.subnav { display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; margin: -.25rem 0 1.25rem; padding: 2px; }
.subnav::-webkit-scrollbar { display: none; }
.subnav button {
  flex: none; white-space: nowrap; border: 1px solid var(--border); background: var(--surface);
  border-radius: 12px; padding: .5rem .9rem; font-weight: 700; color: var(--muted);
}
.subnav button:hover { color: var(--text); border-color: var(--accent); }
.subnav button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.subpanel { display: none; }
.subpanel.active { display: block; animation: fade .2s ease; }
.center { text-align: center; }

.fretboard.vertical { min-width: 0; max-width: 380px; margin: 0 auto; --vcols: 30px repeat(6, 1fr); }
.fbv-head, .fbv-row { display: grid; grid-template-columns: var(--vcols); }
.fbv-head .fb-label { padding-bottom: 4px; }
.fbv-body { background: linear-gradient(90deg, var(--wood), var(--wood-dark)); border-radius: 6px; overflow: hidden; }
.fbv-num {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--surface); color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums;
}
.fbv-num .dots { height: auto; gap: 2px; margin: 0; }
.fbv-num .dots i { width: 5px; height: 5px; }
.fretboard.vertical .fb-cell { height: 38px; border-right: 0; border-bottom: 3px solid var(--fret-wire); }
.fretboard.vertical .fb-cell.open { border-right: 0; border-bottom: 7px solid var(--inlay); }
.fretboard.vertical .fb-cell::before {
  left: 50%; right: auto; top: 0; bottom: 0; width: var(--thick, 1px); height: auto;
  transform: translateX(-50%); box-shadow: 1px 0 1px rgba(0, 0, 0, .25);
}
.fretboard.vertical .fb-note { min-width: 28px; height: 24px; font-size: .72rem; }
.sr-expand .fretboard.vertical { max-width: 340px; }

/* ---------- Lessons ---------- */
.lessons-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.lesson-nav { position: sticky; top: 76px; padding: 1rem; }
.lesson-progress { display: grid; gap: .35rem; margin-bottom: .75rem; font-size: .8rem; font-weight: 700; color: var(--muted); }
.lp-bar { height: 8px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.lp-bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 8px; transition: width .3s; }
.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.lesson-list button {
  width: 100%; display: flex; align-items: center; gap: .6rem; text-align: left;
  border: 0; background: none; padding: .45rem .5rem; border-radius: 10px;
}
.lesson-list button:hover { background: var(--surface-2); }
.lesson-list button.on { background: var(--accent-soft); }
.ln {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: .78rem; font-weight: 800; background: var(--surface-2); color: var(--muted);
}
.lesson-list button.on .ln { background: var(--accent); color: var(--accent-text); }
.lesson-list button.done .ln { background: var(--good); color: #fff; }
.lt { flex: 1; font-weight: 700; font-size: .9rem; line-height: 1.25; }
.lm { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.lesson { padding: 1.75rem; }
.lesson-meta { font-size: .8rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
.lesson-title { font-size: 1.6rem; margin: .3rem 0 1rem; }
.lesson-text { font-size: 1.02rem; line-height: 1.65; }
.lesson-text p { margin: 0 0 .9rem; }
.lesson-text ul { margin: 0 0 1rem; padding-left: 1.2rem; }
.lesson-text li { margin-bottom: .35rem; }
.note-line { background: var(--surface-2); border-radius: 10px; padding: .6rem .8rem; font-weight: 700; letter-spacing: .02em; }
.pattern { font-size: 1.35rem; font-weight: 800; color: var(--accent); letter-spacing: .06em; text-align: center; background: var(--accent-soft); border-radius: 12px; padding: .6rem; }
.callout { background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 10px; padding: .7rem .9rem; margin: 0 0 1rem; font-size: .95rem; }
.try-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
.try {
  border: 1.5px solid var(--accent); background: var(--surface); color: var(--accent);
  border-radius: 999px; padding: .4rem .9rem; font-weight: 700; font-size: .9rem;
}
.try:hover { background: var(--accent); color: var(--accent-text); }
.try.sm { padding: .15rem .6rem; font-size: .8rem; }
.mini-table { border-collapse: collapse; margin: 0 0 1rem; font-size: .95rem; }
.mini-table th, .mini-table td { padding: .35rem .8rem .35rem 0; text-align: left; border-bottom: 1px solid var(--border); }
.mini-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.mini-table.tab td { font: 700 .95rem ui-monospace, monospace; padding: .2rem .9rem; border-bottom: 1px dashed var(--border); }
.mini-table.tab td:first-child { color: var(--muted); }
.lesson-foot { display: flex; justify-content: space-between; gap: .6rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.btn:disabled { opacity: .4; cursor: default; }

/* ---------- Circle of fifths ---------- */
.circle-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.circle-card svg { width: 100%; max-width: 460px; display: block; margin: 0 auto; }
.cw { cursor: pointer; outline: none; }
.cw path { fill: var(--surface-2); stroke: var(--surface); stroke-width: 2; transition: fill .15s; }
.cw.min path { fill: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }
.cw:hover path, .cw:focus-visible path { fill: var(--accent-soft); }
.cw.in path { fill: color-mix(in srgb, var(--accent) 28%, var(--surface)); }
.cw.tonic path { fill: var(--accent); }
.cw text { pointer-events: none; text-anchor: middle; font-family: inherit; }
.cw-name { font-size: 15px; font-weight: 800; fill: var(--text); }
.cw-name.sm { font-size: 11px; font-weight: 700; }
.cw-sub { font-size: 9px; font-weight: 800; fill: var(--muted); }
.cw.in .cw-sub { fill: var(--accent); }
.cw.tonic text { fill: var(--accent-text); }
.cw-center { fill: var(--surface); stroke: var(--border); }
.cw-key { text-anchor: middle; font-size: 28px; font-weight: 800; fill: var(--text); }
.cw-keysub { text-anchor: middle; font-size: 11px; font-weight: 700; fill: var(--muted); }
.circle-chords { display: flex; flex-wrap: wrap; gap: .4rem; }
.cc {
  border: 1px solid var(--border); background: var(--surface); border-radius: 12px;
  padding: .35rem .7rem; font-weight: 800; display: grid; justify-items: center; min-width: 56px;
}
.cc span { font: 700 .75rem Georgia, serif; color: var(--accent); }
.cc.minor span { color: var(--teal); }
.cc.tonic { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cc:hover { border-color: var(--accent); }
#circleInfo .btn { margin-top: 1rem; }

/* ---------- Chord finder ---------- */
.finder-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.finder-strings { display: grid; grid-template-columns: repeat(6, 1fr); gap: .35rem; margin: .75rem 0; }
.fs { border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding: .3rem 0; display: grid; line-height: 1.2; }
.fs b { font-size: .75rem; color: var(--muted); }
.fs span { font-weight: 800; font-size: 1.05rem; }
.fs.off span { color: var(--bad); }
#finderBoard .fb-cell.muted::before { opacity: .25; }
#finderBoard .fb-cell:not(.picked):hover::after {
  content: ""; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); opacity: .3; position: relative; z-index: 1;
}
.finder-result { position: sticky; top: 76px; text-align: center; }
.finder-result .tone-row { justify-content: center; }
.finder-name { font-size: 2.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.finder-name.muted-name { font-size: 1.6rem; color: var(--muted); }
.finder-diagram { max-width: 170px; margin: 1rem auto .25rem; }
.finder-diagram .diagram { width: 100%; }
.tone small { display: block; font-size: .65rem; color: var(--muted); text-align: center; }
code { font: 700 .9em ui-monospace, monospace; background: var(--surface-2); padding: .05rem .35rem; border-radius: 5px; }

/* ---------- Transpose & capo ---------- */
.transpose-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.tp-input { width: 100%; margin-top: .75rem; font: 600 1rem/1.6 ui-monospace, "Cascadia Mono", monospace; resize: vertical; }
.tp-controls { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; margin-top: .9rem; }
.tp-controls .field { margin: 0; }
.stepper { display: flex; align-items: center; gap: .5rem; }
.tp-shift { min-width: 3ch; text-align: center; font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.tp-keynote { text-transform: none; letter-spacing: 0; color: var(--accent); font-size: .85rem; }
.tp-output {
  margin: 0; background: var(--surface-2); border-radius: 12px; padding: .9rem 1rem; min-height: 4rem;
  font: 600 1rem/1.7 ui-monospace, "Cascadia Mono", monospace; white-space: pre-wrap; word-break: break-word;
}
.tp-output b { color: var(--accent); }
.capo-opt { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.capo-opt:first-child { padding-top: .25rem; }
.capo-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.capo-score { width: 70px; height: 7px; border-radius: 7px; background: var(--surface-2); overflow: hidden; }
.capo-score i { display: block; height: 100%; background: var(--good); }
.pc.easy { border: 0; cursor: pointer; background: color-mix(in srgb, var(--good) 20%, var(--surface)); color: var(--text); }
.pc.easy:hover { background: var(--good); color: #fff; }

@media (max-width: 900px) {
  .lessons-layout, .circle-layout, .finder-layout, .transpose-layout { grid-template-columns: minmax(0, 1fr); }
  .lesson-nav, .finder-result { position: static; }
}

/* ---------- Live coach ---------- */
.live-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.live-stage-card { padding: .75rem; }
.live-stage {
  position: relative; border-radius: 12px; overflow: hidden; background: #0d1114;
  min-height: 260px; aspect-ratio: 16 / 9; display: grid; place-items: center;
}
.live-video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
#liveCanvas { width: 100%; height: 100%; object-fit: contain; display: block; cursor: crosshair; }
.live-overlay {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 1.5rem; text-align: center;
  background: radial-gradient(circle at 50% 40%, #1f2b31, #0d1114); color: #e8f0ef;
}
.live-overlay[hidden], .live-banner[hidden], .live-toast[hidden] { display: none; }
.live-overlay .sub { color: #a9b8ba; max-width: 420px; margin: .4rem auto 1rem; }
.live-overlay h2 { font-size: 1.3rem; }
.live-icon { font-size: 2.6rem; margin-bottom: .4rem; }
.live-banner {
  position: absolute; top: 10px; left: 10px; right: 10px; display: flex; align-items: center; gap: .6rem;
  background: rgba(15, 25, 28, .88); color: #fff; padding: .6rem .8rem; border-radius: 12px; font-size: .95rem;
  backdrop-filter: blur(6px);
}
.live-banner .link { margin-left: auto; color: #8ee3d8; }
.lb-step { background: #2ec4b6; color: #062320; font-weight: 800; border-radius: 8px; padding: .1rem .5rem; font-size: .8rem; }
.live-toast {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 20px);
  background: rgba(15, 25, 28, .9); color: #fff; padding: .5rem .9rem; border-radius: 999px; font-size: .88rem; font-weight: 600;
  text-align: center;
}
.live-controls { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .75rem; }
.live-settings { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; margin-top: .6rem; font-size: .92rem; }
.live-strict { display: flex; align-items: center; gap: .4rem; margin-left: auto; font-weight: 600; color: var(--muted); }
.live-strict .input { padding: .3rem .5rem; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
#liveCanvas { touch-action: none; }
.fc-text small.seen { color: var(--muted); font-weight: 600; }
.live-side { position: sticky; top: 76px; }
.live-diagram { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: .25rem 0 .5rem; }
.live-diagram .diagram { width: 120px; }
.ld-name { font-size: 2.4rem; font-weight: 800; letter-spacing: -.02em; }
.live-status { font-weight: 700; padding: .55rem .75rem; border-radius: 10px; background: var(--surface-2); margin-bottom: .6rem; }
.live-status.good { background: color-mix(in srgb, var(--good) 22%, var(--surface)); color: var(--text); }
.live-status.warn { background: var(--accent-soft); }
.finger-checks { list-style: none; margin: 0 0 .75rem; padding: 0; display: grid; gap: .35rem; }
.finger-checks li { display: flex; align-items: flex-start; gap: .6rem; padding: .45rem .55rem; border: 1px solid var(--border); border-radius: 10px; font-size: .9rem; }
.finger-checks li.ok { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, var(--surface)); }
.finger-checks li.bad { border-color: color-mix(in srgb, var(--bad) 60%, var(--border)); }
.fc-num { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-text); font-weight: 800; font-size: .8rem; }
.finger-checks li.ok .fc-num { background: var(--good); }
.finger-checks li.bad .fc-num { background: var(--bad); }
.fc-text { flex: 1; line-height: 1.35; }
.fc-text small { display: block; color: var(--bad); font-weight: 700; }
.fc-mark { color: var(--good); font-weight: 800; }
.live-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.live-help { margin-top: .9rem; font-size: .9rem; }
.live-help summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.live-help ol.tips { padding-left: 1.2rem; margin-top: .5rem; }
.live-link { width: 100%; margin: .25rem 0 .5rem; }

@media (max-width: 900px) {
  .live-layout { grid-template-columns: minmax(0, 1fr); }
  .live-side { position: static; }
}

/* =========================================================
   Phones: bottom tab bar, swipeable chord strip, compact controls
   ========================================================= */
@media (max-width: 700px) {
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  /* backdrop-filter would trap the fixed bottom bar inside the header */
  .topbar { backdrop-filter: none; background: var(--bg); }
  .topbar-inner { padding: .55rem 16px; min-height: 52px; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; order: 0; width: auto;
    display: grid; grid-template-columns: repeat(8, 1fr); gap: 1px; overflow: visible;
    border-radius: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); box-shadow: 0 -4px 20px rgba(0, 0, 0, .06);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0;
    padding: 6px 0 5px; font-size: .62rem; border-radius: 12px; white-space: nowrap;
  }
  .tab svg { display: block; }
  .tab.active { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
  .hide-sm { display: none; }
  .show-sm { display: inline; }
  main { padding-top: 1.1rem; }
  .card { padding: 1rem; border-radius: 16px; }
  .panel-head { margin-bottom: .8rem; }
  .panel-head .seg { width: 100%; }
  .panel-head .seg button { flex: 1; }
  .search { width: 100%; }

  /* Chords: swipeable strip on top, details below */
  .chord-layout { display: flex; flex-direction: column; gap: .75rem; }
  .chord-detail { order: 1; }
  .chord-grid {
    grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 86px;
    overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
    margin: 0 -16px; padding: 4px 16px 6px;
  }
  .chord-grid::-webkit-scrollbar { display: none; }
  .chord-card { scroll-snap-align: center; padding: .35rem .25rem .15rem; }
  .chord-card .cname { font-size: .95rem; }
  .chord-card:hover { transform: none; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px .75rem; padding: 2px 16px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .chips.tight { margin: 0; padding: 2px 0; }
  .cd-diagram { max-width: 190px; }

  /* Notes */
  .fretboard-card { padding: .75rem; }
  .fb-controls { justify-content: center; }

  /* Metronome & timer */
  .metro-main, .timer-main { padding: 1.4rem 1rem; }
  .bpm-label { white-space: nowrap; font-size: .85rem; }
  .bpm-display { gap: .4rem; }
  .metro-actions .btn.big, .timer-actions .btn.big { flex: 1; min-width: 0; padding: .75rem .4rem; }
  .ring-wrap { width: min(240px, 100%); }
  .field.inline { flex-direction: column; align-items: stretch; gap: .3rem; }

  /* Theory */
  .key-top { gap: .6rem; }
  .key-foot { flex-direction: column; align-items: stretch; }
  .sr-item { padding: .5rem .6rem; }
  .lesson { padding: 1.2rem 1rem; }
  .lesson-title { font-size: 1.3rem; }
  .lesson-text { font-size: .98rem; }
  .lesson-nav { padding: .75rem; }
  .lesson-list { display: flex; gap: .35rem; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .lesson-list button { padding: 0; width: auto; }
  .lesson-list .lt, .lesson-list .lm { display: none; }
  .ln { width: 34px; height: 34px; font-size: .85rem; }
  .lesson-foot .btn { flex: 1; }
  .finder-name { font-size: 2.1rem; }
  .ear-main { padding: 1rem; }
  .ear-answers { grid-template-columns: 1fr 1fr; }
  .acc-row { grid-template-columns: 6.5rem 1fr 2.6rem; }
  .foot { display: none; }
  .tab { font-size: .62rem; }
  .tab svg { width: 21px; height: 21px; }
  .live-stage { aspect-ratio: 4 / 3; min-height: 0; }
  .live-stage-card { padding: .5rem; }
  .live-controls .btn { flex: 1 1 auto; padding: .5rem .6rem; font-size: .9rem; }
  .live-controls .check { margin-left: 0; }
  .live-banner { font-size: .82rem; top: 6px; left: 6px; right: 6px; }
  .theme-btn { width: 34px; height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.lb-hint { opacity: .7; font-size: .85em; }

/* =========================================================
   Song → chords (beta)
   ========================================================= */
.song-input { display: grid; gap: 1rem; margin-bottom: 1.25rem; }
.song-input.busy .song-drop, .song-input.busy .song-url { opacity: .5; pointer-events: none; }
.song-drop {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  border: 2px dashed var(--border); border-radius: 14px; padding: 1.1rem 1.25rem;
  transition: border-color .15s, background .15s;
}
.song-drop > div:nth-child(2) { flex: 1; min-width: 12rem; }
.song-drop .sub { margin: .15rem 0 0; }
.song-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.song-drop-icon { font-size: 2rem; line-height: 1; }
.song-drop .btn { cursor: pointer; }
.song-url .field { margin-bottom: .3rem; }
.song-url .sub { margin: 0; }
.song-url-row { display: flex; gap: .5rem; }
.song-url-row .input { flex: 1; min-width: 0; }
.song-input.compact .song-url .sub, .song-input.compact .song-drop .sub { display: none; }
.song-progress-text { display: flex; justify-content: space-between; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.song-progress-text span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.song-error {
  border-radius: 12px; padding: .7rem .9rem; font-weight: 600;
  background: color-mix(in srgb, var(--bad) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent);
}

.song-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.25rem; margin-bottom: 1.25rem; }
.song-title { min-width: 0; }
.song-name { font-size: 1.3rem; font-weight: 800; overflow-wrap: anywhere; }
.song-facts { display: flex; flex-wrap: wrap; gap: .25rem 1rem; color: var(--muted); font-size: .9rem; margin-top: .2rem; }
.song-facts b { color: var(--text); }
.song-opts { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.song-capo { display: flex; align-items: center; gap: .4rem; font-weight: 600; font-size: .9rem; color: var(--muted); }
.song-capo .input { padding: .35rem .5rem; }
.song-capo-tip { flex-basis: 100%; margin: 0; }

.song-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; margin-bottom: 1.25rem; }
.song-now { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1rem; align-items: start; }
.song-label { font-size: .75rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.song-now-name { font-size: 2.6rem; font-weight: 800; line-height: 1.1; min-height: 1.1em; }
.song-next-name { font-size: 1.5rem; font-weight: 800; color: var(--muted); min-height: 1.1em; }
.song-sounds { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); }
.song-now-diagram .diagram { width: 100%; max-width: 210px; display: block; }
.song-next-diagram .diagram { width: 100%; max-width: 130px; display: block; opacity: .75; }
.song-beats { display: flex; gap: .5rem; justify-content: center; margin: .75rem 0; }
.song-beats i { width: 12px; height: 12px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); transition: background .05s; }
.song-beats i:first-child { width: 16px; height: 16px; margin-top: -2px; }
.song-beats i.on { background: var(--accent); border-color: var(--accent); }
.song-transport { display: flex; align-items: center; gap: .75rem 1rem; flex-wrap: wrap; }
.song-time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.song-transport .check { margin-left: auto; }

.song-timeline {
  position: relative; height: 42px; margin-top: 1rem; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); cursor: pointer; touch-action: none; user-select: none;
}
.song-tl-seg {
  position: absolute; top: 0; bottom: 0; border-right: 1px solid var(--surface);
  background: color-mix(in srgb, var(--accent) 22%, var(--surface));
  font-size: .75rem; font-weight: 700; padding: 0 .3rem; line-height: 42px; white-space: nowrap; overflow: hidden;
}
.song-tl-seg:nth-child(even) { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.song-tl-seg.nc { background: var(--surface-2); }
.song-tl-seg.now { background: var(--accent); color: var(--accent-text); }
.song-playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--text); pointer-events: none; }

.song-chords h2 { margin-top: 0; }
.song-chord-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .6rem; margin-top: .75rem; }
.song-chord { padding: .5rem .4rem; }
.song-chord-meta { font-size: .72rem; color: var(--muted); font-weight: 600; }
.song-chord .song-sounds { font-size: .7rem; }

.song-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .4rem; margin-top: .75rem; max-height: 420px; overflow-y: auto; padding: 2px; }
.song-bar {
  display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; min-height: 2.6rem;
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: .4rem .6rem;
  font-weight: 800; text-align: left;
}
.song-bar:hover { border-color: var(--accent); }
.song-bar.pickup { border-style: dashed; }
.song-bar.now { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.song-bar .cont { opacity: .45; }
.song-bar .nc { font-weight: 600; opacity: .55; font-size: .85rem; }
.song-disclaimer { margin-top: 1rem; }

@media (max-width: 900px) {
  .song-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .song-now-name { font-size: 2rem; }
  .song-url-row { flex-direction: column; }
  .song-transport .check { margin-left: 0; }
  .song-opts { width: 100%; }
}
