:root {
  --bg: #0f1115;
  --bg-soft: #171a21;
  --bg-raise: #1e222b;
  --line: #2a2f3a;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --accent: #6ea8fe;
  --accent-dim: #2b4a7d;
  --good: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #1a2030 0%, var(--bg) 60%);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 940px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 32px);
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.02em; }

kbd {
  font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 3px 5px;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.link-btn {
  background: none; border: 0; color: var(--muted);
  font: inherit; font-size: 13px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; padding: 4px;
}
.link-btn:hover { color: var(--accent); }

/* ── Home ──────────────────────────────────────────────────────────────── */

.home-header { text-align: center; padding: 44px 0 30px; }
.home-header h1 {
  font-size: clamp(30px, 6vw, 46px);
  background: linear-gradient(180deg, #ffffff, #93a4c4);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.tagline { color: var(--muted); margin: 12px 0 0; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 6px;
  text-align: left; cursor: pointer;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  color: inherit; font: inherit;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
/* A soft accent wash that lifts in on hover. */
.card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(420px 160px at 50% -40%, rgba(110, 168, 254, .18), transparent 70%);
  opacity: 0; transition: opacity .16s ease;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-dim);
  background: var(--bg-raise);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .38);
}
.card:hover::after { opacity: 1; }
.card > * { position: relative; }
.card-icon { font-size: 26px; line-height: 1; }
.card-title { font-size: 19px; font-weight: 650; }
.card-sub { color: var(--muted); font-size: 14px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.card--warn { opacity: .65; }

.tag {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 9px;
}
.tag--mic { color: var(--warn); border-color: rgba(251, 191, 36, .35); }
.card-stat { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.home-heading {
  font-size: 12px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--muted); margin: 34px 0 14px; font-weight: 600;
}
.card--tool .card-foot { margin-top: 8px; }

.home-footer { text-align: center; padding: 34px 0 12px; }

/* ── Exercise header ───────────────────────────────────────────────────── */

.ex-header {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}
.ex-title { flex: 1; min-width: 0; }
.ex-title h2 { font-size: 20px; }
.ex-subtitle { display: block; color: var(--muted); font-size: 13px; }

.icon-btn {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text);
  font-size: 17px; cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.icon-btn:hover { background: var(--bg-raise); border-color: var(--accent-dim); }
.icon-btn:focus-visible, .card:focus-visible, .btn:focus-visible, .answer-btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.icon-btn.is-active { border-color: var(--accent); color: var(--accent); }

.ex-stats { display: flex; gap: 6px; font-variant-numeric: tabular-nums; font-size: 13px; }
.stat {
  color: var(--muted); background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px;
  font-weight: 550;
}
.stat--pct { color: var(--text); border-color: var(--accent-dim); }
.stat--streak { border-color: rgba(251, 191, 36, .28); }

/* ── Mode bar ──────────────────────────────────────────────────────────── */

.ex-modes { margin: -6px 0 24px; }

.mode-bar {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 4px; padding: 4px;
  width: fit-content; max-width: 100%; margin: 0 auto;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .3);
}

.mode-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; background: transparent; color: var(--muted);
  border-radius: 999px; padding: 9px 18px;
  font: inherit; font-size: 14px; font-weight: 550;
  white-space: nowrap; cursor: pointer;
  transition: color .15s ease, background .15s ease, box-shadow .15s ease;
}
.mode-btn:hover:not(:disabled):not(.is-on) { color: var(--text); background: rgba(255, 255, 255, .045); }
.mode-btn.is-on {
  color: #fff;
  background: linear-gradient(180deg, #3f72bd, var(--accent-dim));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 3px 12px rgba(43, 74, 125, .5);
}
.mode-btn:disabled { opacity: .45; cursor: not-allowed; }
.mode-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.mode-label-short { display: none; }

.mode-flag {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--warn); border: 1px solid rgba(251, 191, 36, .35);
  border-radius: 999px; padding: 2px 7px;
}

/* ── Settings ──────────────────────────────────────────────────────────── */

.settings-panel {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 20px 18px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.settings-section { padding-top: 14px; }
.settings-section + .settings-section { border-top: 1px solid var(--line); margin-top: 14px; }
.settings-heading { font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin-bottom: 10px; }
.settings-grid { display: flex; flex-direction: column; gap: 14px; }
.settings-row {
  display: grid; grid-template-columns: minmax(140px, 220px) 1fr;
  gap: 8px 18px; align-items: center;
}
.settings-label { font-size: 14px; color: var(--text); }
.settings-help { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--muted); }

.select {
  background: var(--bg-raise); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; font: inherit; font-size: 14px; min-width: 180px;
}

.range-wrap { display: flex; align-items: center; gap: 12px; }
.range { flex: 1; accent-color: var(--accent); max-width: 260px; }
.range-out { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 62px; }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--bg-raise); border: 1px solid var(--line);
  border-radius: 999px; transition: .16s;
}
.slider::before {
  content: ""; position: absolute; height: 16px; width: 16px;
  left: 3px; top: 3px; background: var(--muted);
  border-radius: 50%; transition: .16s;
}
.switch input:checked + .slider { background: var(--accent-dim); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); background: var(--accent); }

.multi { display: flex; flex-direction: column; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--bg-raise); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 11px; font: inherit; font-size: 13px; cursor: pointer;
  transition: .12s;
}
.chip:hover { border-color: var(--accent-dim); color: var(--text); }
.chip--on { background: var(--accent-dim); border-color: var(--accent); color: #fff; }
.chip-presets { display: flex; gap: 10px; }

/* ── Exercise body ─────────────────────────────────────────────────────── */

.ex-body { display: flex; flex-direction: column; gap: 22px; }
/* Tools use only part of the round layout; empty regions should not take space. */
.prompt:empty, .controls:empty { display: none; }
.feedback:empty { min-height: 0; }

.prompt { text-align: center; }
.prompt-main { font-size: clamp(20px, 4vw, 28px); font-weight: 650; letter-spacing: -.02em; }
.prompt-sub { color: var(--muted); font-size: 14px; margin-top: 6px; }

.controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-raise); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; font: inherit; font-size: 14px; font-weight: 550;
  cursor: pointer; transition: .12s;
}
.btn:hover:not(:disabled) { border-color: var(--accent-dim); background: #262b36; }
.btn:disabled { opacity: .45; cursor: default; }
.btn--primary { background: var(--accent-dim); border-color: var(--accent); }
.btn--primary:hover:not(:disabled) { background: #35598f; }
.btn--ghost { background: transparent; color: var(--muted); }

/* ── Answers ───────────────────────────────────────────────────────────── */

.answer-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, auto-fit), minmax(112px, 1fr));
  gap: 10px;
}
.answer-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 10px 12px; font: inherit; cursor: pointer;
  transition: .12s;
}
.answer-btn:hover:not(:disabled) {
  border-color: var(--accent); background: var(--bg-raise);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .32);
}
.answer-btn:disabled { cursor: default; }
.answer-label { font-size: 18px; font-weight: 650; }
.answer-sub { font-size: 12px; color: var(--muted); }
.answer-btn kbd { position: absolute; top: 6px; right: 6px; opacity: .5; }
.answer-btn.is-correct { border-color: var(--good); background: rgba(74, 222, 128, .12); }
.answer-btn.is-wrong { border-color: var(--bad); background: rgba(248, 113, 113, .12); }

.hint-line { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 0; }

/* Progression slots */
.slots { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 18px; }
.slot {
  min-width: 76px; padding: 14px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--bg-soft); border: 1px dashed var(--line);
  border-radius: var(--radius); cursor: pointer;
  transition: .12s;
}
.slot:hover { border-color: var(--accent-dim); }
.slot-main { font-size: 20px; font-weight: 650; }
.slot .slot-main { color: var(--muted); }
.slot--filled { border-style: solid; }
.slot--filled .slot-main { color: var(--text); }
.slot--next { border-color: var(--accent); border-style: solid; box-shadow: 0 0 0 3px rgba(110, 168, 254, .12); }
.slot--right { border-style: solid; border-color: var(--good); background: rgba(74, 222, 128, .1); }
.slot--right .slot-main { color: var(--good); }
.slot--wrong { border-style: solid; border-color: var(--bad); background: rgba(248, 113, 113, .1); }
.slot--wrong .slot-main { color: var(--bad); text-decoration: line-through; }
.slot-truth { font-size: 13px; color: var(--good); font-weight: 600; }

/* Chord-tone tracker */
.tone-track { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tone-pill {
  display: flex; flex-direction: column; align-items: center;
  min-width: 72px; padding: 8px 12px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px;
  font-size: 13px; color: var(--muted);
}
.tone-pill.is-current { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 3px rgba(110, 168, 254, .12); }
.tone-pill.is-done { border-color: var(--good); color: var(--good); }
.tone-degree { font-weight: 600; }
.tone-note { font-size: 11px; opacity: .8; min-height: 14px; }

/* ── Pitch dial ────────────────────────────────────────────────────────── */

.dial {
  position: relative;
  display: block;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  aspect-ratio: 5 / 4;
  max-height: 460px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: radial-gradient(120% 90% at 50% 0%, #12151d 0%, #08090d 70%);
  overflow: hidden;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;            /* the pad owns vertical gestures */
  overscroll-behavior: contain;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .05);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.dial:hover { border-color: var(--accent-dim); }
.dial:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.dial.is-dialing { cursor: grabbing; border-color: var(--accent); }
.dial.is-locked { cursor: default; }

.dial-scope {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  pointer-events: none;
}

.dial-face {
  position: absolute; inset: 0;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: 22px;
  pointer-events: none;
}

.dial-readout { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 6px; min-width: 0; }
.dial-value {
  font-size: clamp(38px, 8vw, 68px); font-weight: 650; letter-spacing: -.03em;
  line-height: .95; font-variant-numeric: tabular-nums;
  color: #fff; text-shadow: 0 2px 20px rgba(0, 0, 0, .6);
}
.dial-unit { font-size: 15px; font-weight: 600; color: var(--muted); }
.dial-note {
  flex-basis: 100%;
  font-size: 14px; font-weight: 600; color: var(--accent); letter-spacing: .02em;
}

.dial-commit {
  pointer-events: auto;
  flex: none;
  width: 62px; height: 62px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: #fff; color: #0b0d12;
  font-size: 22px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
  transition: transform .14s ease, background .14s ease, opacity .14s ease;
}
.dial-commit:hover:not(:disabled) { transform: scale(1.07); }
.dial-commit:active:not(:disabled) { transform: scale(.96); }
.dial-commit:disabled { opacity: 0; pointer-events: none; }
.dial-commit[hidden] { display: none; }
.dial-commit:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.dial-arrow { line-height: 1; transform: translateY(-1px); }

.dial-hint {
  position: absolute; top: 20px; left: 22px; right: 22px;
  margin: 0; font-size: 12px; letter-spacing: .04em;
  color: var(--muted); pointer-events: none;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .9);
}

/* ── Tuner panel ───────────────────────────────────────────────────────── */

.pt-panel { display: flex; flex-direction: column; gap: 18px; max-width: 470px; margin: 0 auto; width: 100%; }

.pt-head {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 12px;
}
.pt-cell { text-align: center; min-width: 0; }
.pt-cell:first-child { text-align: left; }
.pt-cell:last-child { text-align: right; }

.pt-value {
  font-size: clamp(26px, 5vw, 38px); font-weight: 600; letter-spacing: -.02em;
  line-height: 1; font-variant-numeric: tabular-nums;
}
.pt-value.is-good { color: var(--good); }
.pt-caption {
  margin-top: 6px; font-size: 11px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted);
}

.pt-note { font-size: clamp(56px, 13vw, 92px); font-weight: 600; line-height: .9; letter-spacing: -.03em; }
.pt-note-oct { font-size: .42em; font-weight: 500; bottom: -.05em; margin-left: .04em; color: var(--text); }

.pt-stage {
  position: relative;
  border-radius: 18px;
  background: #23262a;
  border: 1px solid var(--line);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  max-height: 520px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.pt-panel.is-tuned .pt-stage {
  border-color: rgba(74, 222, 128, .45);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, .12);
}
.pt-scope { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.pt-transpose {
  position: absolute; top: 14px; left: 14px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px;
  border: 0; background: rgba(20, 22, 26, .72); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background .14s ease;
}
.pt-transpose:hover { background: rgba(40, 44, 52, .9); }
.pt-transpose:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pt-transpose-icon { color: var(--muted); }

/* ── Tap tempo ─────────────────────────────────────────────────────────── */

.tap-tempo-pad {
  position: relative;
  width: 100%;
  max-width: 560px;
  min-height: 360px;
  margin: 0 auto;
  padding: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    radial-gradient(420px 260px at 50% 42%, rgba(110, 168, 254, .16), transparent 70%),
    linear-gradient(155deg, #151924, #090b10);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .42), inset 0 1px 0 rgba(255, 255, 255, .05);
  color: inherit;
  font: inherit;
  text-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: border-color .12s ease, box-shadow .12s ease, transform .08s ease;
}
.tap-tempo-pad:hover { border-color: var(--accent-dim); }
.tap-tempo-pad:active { transform: scale(.995); }
.tap-tempo-pad:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.tap-tempo-pad.is-tapped {
  border-color: var(--accent);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, .42),
    0 0 0 4px rgba(110, 168, 254, .12),
    inset 0 0 80px rgba(110, 168, 254, .1);
}
.tap-tempo-kicker, .metronome-kicker {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--muted);
}
.tap-tempo-readout {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-variant-numeric: tabular-nums;
}
.tap-tempo-value {
  min-width: 2ch;
  font-size: clamp(76px, 17vw, 126px);
  font-weight: 650;
  line-height: .92;
  letter-spacing: -.055em;
  text-align: center;
  color: #fff;
  text-shadow: 0 4px 30px rgba(0, 0, 0, .55);
}
.tap-tempo-unit, .metronome-unit {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: .08em;
  color: var(--muted);
}
.tap-tempo-status {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.tap-tempo-detail {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tap-stability {
  display: flex;
  gap: 5px;
  height: 14px;
  align-items: flex-end;
}
.tap-stability-bar {
  display: block;
  width: 18px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  transition: height .14s ease, background .14s ease;
}
.tap-stability-bar.is-on {
  height: 10px;
  background: var(--good);
}
.tap-tempo-hint, .metronome-hint {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* ── Metronome ─────────────────────────────────────────────────────────── */

.metronome-stage {
  position: relative;
  width: 100%;
  max-width: 560px;
  min-height: 390px;
  margin: 0 auto;
  padding: 34px 30px 54px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    radial-gradient(460px 280px at 50% 35%, rgba(74, 222, 128, .08), transparent 72%),
    linear-gradient(155deg, #151a20, #090b0e);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .42), inset 0 1px 0 rgba(255, 255, 255, .05);
  transition: border-color .08s linear, box-shadow .08s linear, background .08s linear;
}
.metronome-stage.is-tick {
  border-color: rgba(110, 168, 254, .65);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, .42),
    0 0 0 4px rgba(110, 168, 254, .1),
    inset 0 0 70px rgba(110, 168, 254, .08);
}
.metronome-stage.is-downbeat {
  border-color: rgba(74, 222, 128, .8);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, .42),
    0 0 0 4px rgba(74, 222, 128, .12),
    inset 0 0 80px rgba(74, 222, 128, .11);
}
.metronome-stage.is-subdivision {
  border-color: rgba(110, 168, 254, .35);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .42), inset 0 0 45px rgba(110, 168, 254, .045);
}
.metronome-tempo {
  width: 100%;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 58px;
  align-items: center;
  gap: 14px;
}
.metronome-step {
  width: 58px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg-raise);
  color: var(--text);
  font: inherit;
  font-size: 30px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, transform .08s ease;
}
.metronome-step:hover:not(:disabled) { border-color: var(--accent); background: #262c36; }
.metronome-step:active:not(:disabled) { transform: scale(.94); }
.metronome-step:disabled { opacity: .35; cursor: default; }
.metronome-step:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.metronome-readout {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 9px;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.metronome-bpm {
  font-size: clamp(72px, 16vw, 116px);
  font-weight: 650;
  line-height: .9;
  letter-spacing: -.055em;
  color: #fff;
  text-shadow: 0 4px 30px rgba(0, 0, 0, .55);
}
.metronome-range {
  width: min(100%, 390px);
  accent-color: var(--accent);
}
.metronome-meta, .metronome-status {
  font-size: 13px;
  color: var(--muted);
}
.metronome-status { font-weight: 600; color: var(--text); }
.metronome-beats {
  min-height: 42px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 9px;
}
.metronome-beat {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg-raise);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  transition: transform .08s linear, color .08s linear, border-color .08s linear, background .08s linear;
}
.metronome-beat.is-accent { border-color: rgba(74, 222, 128, .4); }
.metronome-beat.is-current {
  transform: scale(1.13);
  border-color: var(--accent);
  background: var(--accent-dim);
  color: #fff;
}
.metronome-beat.is-accent.is-current {
  border-color: var(--good);
  background: rgba(74, 222, 128, .2);
  color: var(--good);
}

/* ── Feedback ──────────────────────────────────────────────────────────── */

.feedback { min-height: 62px; display: flex; justify-content: center; }
.feedback-box {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 12px 20px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg-soft);
  animation: pop .18s ease-out;
}
.feedback--good { border-color: rgba(74, 222, 128, .5); background: rgba(74, 222, 128, .08); }
.feedback--bad { border-color: rgba(248, 113, 113, .5); background: rgba(248, 113, 113, .08); }
.feedback--warn { border-color: rgba(251, 191, 36, .5); background: rgba(251, 191, 36, .08); }
.feedback-msg { font-weight: 600; }
.feedback--good .feedback-msg { color: var(--good); }
.feedback--bad .feedback-msg { color: var(--bad); }
.feedback--warn .feedback-msg { color: var(--warn); }
.feedback-detail { font-size: 13px; color: var(--muted); }

@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Tuner ─────────────────────────────────────────────────────────────── */

.tuner {
  --zone-width: 40%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
}
.tuner-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.tuner-caption { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.tuner-target { font-size: 20px; font-weight: 650; }
.tuner-read { text-align: center; }
.tuner-note { font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tuner-note.is-good { color: var(--good); }
.tuner-note.is-off { color: var(--warn); }
.tuner-cents { font-size: 12px; color: var(--muted); }
.tuner-level { width: 84px; height: 6px; background: var(--bg-raise); border-radius: 999px; overflow: hidden; }
.tuner-level-fill { height: 100%; width: 0; background: var(--accent); transition: width .08s linear; }

.tuner-meter {
  position: relative; height: 40px;
  background: var(--bg-raise); border-radius: 8px; overflow: hidden;
}
.tuner-zone {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: calc(var(--zone-width) * 2); transform: translateX(-50%);
  background: rgba(74, 222, 128, .13);
}
.tuner-center { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: var(--line); }
.tuner-needle {
  position: absolute; top: 4px; bottom: 4px; left: 50%;
  width: 4px; margin-left: -2px; border-radius: 2px;
  background: var(--accent);
  transition: left .07s linear;
}
.tuner--blind .tuner-meter { display: none; }
.tuner--blind .tuner-note { font-size: 24px; color: var(--muted); }
.tuner--blind .tuner-progress { height: 12px; margin-top: 2px; }
.tuner--blind .tuner-head { margin-bottom: 8px; }

.tuner-progress { height: 6px; background: var(--bg-raise); border-radius: 999px; margin-top: 10px; overflow: hidden; }
.tuner-progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--good)); transition: width .09s linear; }

/* ── Toast ─────────────────────────────────────────────────────────────── */

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: min(90vw, 460px);
  background: var(--bg-raise); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 18px; font-size: 14px;
  box-shadow: var(--shadow); z-index: 50;
  animation: pop .18s ease-out;
}
.toast--warn { border-color: rgba(251, 191, 36, .5); }
.toast--error { border-color: rgba(248, 113, 113, .5); }

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 620px) {
  .settings-row { grid-template-columns: 1fr; }
  .answer-grid { grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); }
  .answer-btn kbd { display: none; }
  .btn kbd { display: none; }

  /* Give the stats a row of their own instead of stacking them into a column. */
  .ex-header { flex-wrap: wrap; row-gap: 12px; padding-bottom: 12px; margin-bottom: 14px; }
  .ex-stats { order: 1; flex: 1 1 100%; justify-content: center; font-size: 12px; }
  .ex-subtitle { display: none; }
  .ex-body { gap: 14px; }

  /* Full width, so a label that wraps onto its own row still looks deliberate. */
  .ex-modes { margin: -2px 0 14px; }
  .mode-bar { width: 100%; border-radius: 16px; }
  .mode-btn { flex: 1 1 auto; justify-content: center; padding: 9px 8px; font-size: 13px; }
  /* Short labels keep all the modes on one row, which buys the pad its height. */
  .mode-label { display: none; }
  .mode-label-short { display: inline; }

  .prompt-main { font-size: 21px; }
  .prompt-sub { font-size: 12px; margin-top: 4px; }

  /* Bounding the width against the viewport height keeps the pad taller than it
     is wide, which is what keeps the ribbon vertical. */
  .dial { aspect-ratio: 3 / 4; max-width: min(100%, 46vh); max-height: 52vh; }
  .dial-face { padding: 16px; }
  .dial-commit { width: 54px; height: 54px; }
  .dial-value { font-size: clamp(32px, 11vw, 46px); }

  .pt-note { font-size: clamp(48px, 17vw, 72px); }
  .pt-value { font-size: clamp(22px, 7vw, 30px); }
  .pt-stage { aspect-ratio: 4 / 5; max-height: 56vh; }

  .tap-tempo-pad { min-height: min(430px, 58vh); }
  .tap-tempo-value { font-size: clamp(68px, 24vw, 104px); }

  .metronome-stage { min-height: min(440px, 60vh); padding: 28px 16px 52px; gap: 17px; }
  .metronome-tempo { grid-template-columns: 48px minmax(0, 1fr) 48px; gap: 8px; }
  .metronome-step { width: 48px; height: 48px; font-size: 25px; }
  .metronome-bpm { font-size: clamp(64px, 23vw, 96px); }
  .metronome-beats { gap: 6px; }
  .metronome-beat { width: 30px; height: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
