@font-face {
  font-family: "Jersey 25";
  src: url("./fonts/Jersey25-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --page: #191b1e;
  --surface: #232529;
  --raised: #2e3136;
  --border: #3a3d42;
  --text: #f5f6f7;
  --muted: #b5bac2;
  --accent: #b7d8af;
  --accent-text: #17231a;
  --secondary-text: #d0d5dd;
  --amber: #ffd694;
  --rose: #ffb7c8;
  --page-gutter: clamp(1rem, 4vw, 2.25rem);
  font-family: "Jersey 25", system-ui, sans-serif;
  background: var(--page);
  color: var(--text);
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 18rem;
  min-height: 100vh;
  background: var(--page);
  font-size: 1.125rem;
  line-height: 1.55;
}

button, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { line-height: 1.4; }
h2 { font-size: clamp(1rem, 2.8vw, 1.5rem); }
h3 { font-size: 0.85rem; }
p { color: var(--muted); }

.topbar { border-bottom: 1px solid #33353a; background: #191b1e; }
.workspace { max-width: 72rem; margin-inline: auto; }
.topbar-inner, .workspace { padding-inline: var(--page-gutter); }
.topbar-inner {
  min-height: 4.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.device-controls, .instrument-actions, .actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.625rem;
}
.brand { color: var(--text); font-size: clamp(1.25rem, 1.9vw, 1.75rem); line-height: 1.2; text-decoration: none; }
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.625rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 0.625rem;
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 700;
  text-decoration: none;
  background: var(--raised);
}
.button:hover:not(:disabled) { background: #383b41; }
.button.primary { background: var(--accent); color: var(--accent-text); }
.button.primary:hover:not(:disabled) { background: #d3e9ce; }
.button.outline { border-color: #5d6169; background: transparent; }
.midi-key {
  padding: 0.06rem 0.38rem;
  border: 1px solid currentColor;
  border-radius: 0.3rem;
  font-size: 0.85rem;
  font-weight: 650;
  white-space: nowrap;
}
.button.outline:hover:not(:disabled) { background: var(--raised); }
.button.outline[aria-pressed="true"], .button.outline.is-connected { border-color: var(--accent); color: var(--accent); }
.button.quiet { background: transparent; color: var(--muted); }
.button.quiet:hover:not(:disabled) { color: var(--text); background: var(--raised); }
.button.quiet[aria-pressed="true"] { color: var(--accent); background: var(--raised); }

.device-controls .button {
  border-radius: 0.4rem;
  font-size: clamp(1.15rem, 1.65vw, 1.4rem);
}
.device-controls .button[aria-pressed="true"] { color: var(--text); background: transparent; }
.device-controls .button:hover:not(:disabled) { background: var(--raised); }

#midi-settings, #reset-progress {
  width: min(24rem, calc(100% - 2rem));
  padding: 1.45rem;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  background: var(--surface);
  color: var(--text);
}
#midi-settings::backdrop, #reset-progress::backdrop { background: #08090ba8; }
#midi-settings h2, #reset-progress h2 { margin-bottom: 0.65rem; font-size: 1.85rem; }
#midi-status, #midi-input-row, #reset-progress-detail, .midi-dialog-actions .button { font-size: 1.25rem; }
#midi-input-row { display: grid; gap: 0.4rem; margin-top: 1.25rem; }
#midi-input, .hub-form select {
  width: 100%;
  min-height: 2.65rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.38rem;
  background: var(--raised);
  color: var(--text);
}
.midi-dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.35rem; }

.guided-workspace {
  --game-text: clamp(1.4rem, 2.25vw, 1.75rem);
  --game-caption: clamp(1.25rem, 1.75vw, 1.5rem);
  position: relative;
  display: grid;
  place-items: center;
  min-height: calc(100svh - 4.3rem);
  padding: 2rem 1rem 5rem;
  text-align: center;
}
.game-play { width: min(100%, 48rem); }
.guided-workspace .button { font-size: var(--game-caption); }
.game-prompt { margin: 0; }
.guided-workspace h1:focus { outline: none; }
.game-lead {
  display: block;
  color: var(--muted);
  font-size: clamp(1.65rem, 2.15vw, 2rem);
  letter-spacing: 0;
  line-height: 1.35;
}
.game-lead:empty { display: none; }
.game-cue {
  display: block;
  margin-top: 0.2rem;
  font-size: clamp(5rem, 15vw, 8.25rem);
  line-height: 1.14;
}
.game-chord .game-cue {
  margin-top: 0.55rem;
  font-size: clamp(2.25rem, 6.5vw, 4.5rem);
  line-height: 1.18;
}
.game-detail { max-width: 50ch; margin: 1.05rem auto 0; font-size: var(--game-text); }
.game-progress {
  margin-top: 0.85rem;
  font-size: var(--game-caption);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.game-tones { margin-top: 0.85rem; color: var(--text); font-size: clamp(1.85rem, 3vw, 2.75rem); }
.game-beat { margin-top: 0.55rem; color: var(--text); font-size: clamp(1.7rem, 2.4vw, 2.2rem); font-variant-numeric: tabular-nums; }
.game-feedback { min-height: 1.55em; margin-top: 1rem; font-size: var(--game-text); }
.game-feedback.is-good { color: var(--accent); }
.game-feedback.is-off { color: var(--rose); }
.game-setup { display: grid; justify-items: center; gap: 0.55rem; margin-top: 0.35rem; font-size: var(--game-caption); }
.guided-workspace:has(.game-practice-top) {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  gap: 0.75rem;
  padding: 1rem var(--page-gutter) 5rem;
}
.game-practice-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
}
.game-practice-details {
  flex: 0 0 auto;
  font-size: var(--game-caption);
  line-height: 1.25;
  text-align: start;
}
.game-practice-parts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.25rem;
}
.game-practice-parts .button { padding-inline: 0.55rem; white-space: nowrap; }
.game-practice {
  display: block;
  width: max-content;
  margin: 1.25rem auto 0;
  color: var(--muted);
  font-size: var(--game-caption);
  text-decoration: underline;
  text-underline-offset: 0.22rem;
}
.game-practice:hover { color: var(--text); }
.game-play .game-practice { position: absolute; inset: auto 0 1.25rem; }
.game-report { max-width: 37rem; }
.game-report h1 { margin-top: 0.65rem; font-size: clamp(2rem, 5.5vw, 3.75rem); }
.game-report-results { display: grid; gap: 0.5rem; margin: 1.45rem auto 1.5rem; font-size: var(--game-text); }
.game-report-results strong { color: var(--text); }
.button.game-primary { background: var(--text); color: var(--page); }
.button.game-primary:hover:not(:disabled) { background: var(--secondary-text); }

.hub-screen { width: min(100%, 33rem); }
.hub-screen h1 { margin-bottom: 1.15rem; font-size: clamp(2.5rem, 6vw, 3.75rem); }
.hub-menu-list { display: grid; gap: 0.65rem; width: min(100%, 19rem); margin-inline: auto; }
.hub-menu-list .button { min-height: 3rem; }
.hub-form label { display: grid; gap: 0.25rem; color: var(--muted); font-size: var(--game-caption); text-align: left; }
.hub-form .button { margin-top: 0.5rem; }
.hub-progress { width: min(100%, 44rem); font-size: var(--game-caption); }
.hub-progress h1 { margin-bottom: 0.2rem; }
.hub-progress section { margin-top: 1.4rem; text-align: left; }
.hub-progress h2 { font-size: var(--game-text); }
.hub-progress ul { padding: 0; margin: 0.3rem 0 0; list-style: none; }
.hub-progress li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 1.5rem;
  padding-block: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.hub-progress p { color: var(--muted); }
.hub-progress > p + p { margin-top: 0.55rem; }
.hub-progress > .button { margin-top: 1.35rem; }

.workspace { padding-block: 2.35rem 2rem; }

.lesson-chooser {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
  width: min(100%, 65rem);
  margin-bottom: 1.25rem;
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: #1b1d20;
}
.lesson-chooser button {
  display: grid;
  gap: 0.2rem;
  align-content: center;
  min-width: 0;
  padding: 0.5rem 0.72rem;
  border: 1px solid transparent;
  border-radius: 0.54rem;
  text-align: left;
  font-weight: 720;
  line-height: 1.2;
  color: var(--text);
  background: transparent;
}
.lesson-chooser button:hover { background: var(--raised); }
.lesson-chooser button[aria-pressed="true"] { border-color: #575c64; background: #34383e; color: var(--accent); }
.lesson-chooser small { font-size: 0.81rem; font-weight: 550; color: var(--muted); }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 1.5rem; }
h1 { font-size: clamp(1.4rem, 3.5vw, 2.6rem); }
.intro p { font-size: clamp(0.72rem, 1.5vw, 0.85rem); margin-block: 0.55rem 0; }
.session-settings {
  display: flex;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: #222428bd;
}
.session-settings div { padding: 0.58rem 0.9rem; }
.session-settings div + div { border-left: 1px solid var(--border); }
.session-settings dt { color: var(--muted); font-size: 0.8rem; }
.session-settings dd { font-size: 0.98rem; font-weight: 720; white-space: nowrap; }
.device-status { margin-top: 0.75rem; color: var(--secondary-text); font-size: 0.9rem; }
.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.3rem;
  padding: 0.32rem;
  margin-block: 1.55rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: #1b1d20;
}
.steps button {
  min-width: 0;
  padding: 0.52rem 0.25rem;
  min-height: 2.75rem;
  border: 1px solid transparent;
  border-radius: 0.54rem;
  color: var(--muted);
  font-size: 0.91rem;
  font-weight: 720;
  background: transparent;
}
.steps button:hover { color: var(--text); background: var(--raised); }
.steps button[aria-current="step"] { color: var(--accent); background: #34383e; border-color: #575c64; }

.panel { border: 1px solid var(--border); border-radius: 1rem; background: var(--surface); box-shadow: 0 0.55rem 1.8rem #0e101240; }
.stage { padding: clamp(1rem, 3vw, 1.5rem); background: var(--surface); }
.stage-title { scroll-margin-top: 1rem; }
.stage-title:focus { outline: none; }
.stage-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(15rem, 1fr); gap: clamp(1rem, 3vw, 2rem); }
.stage-main { min-width: 0; }
.stage-blurb { margin-block: 0.55rem 0.95rem; max-width: 44ch; }
.stage-blurb b { color: var(--text); }
.actions { margin-top: 0.85rem; }
.lesson-nav { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.lesson-nav button {
  background: transparent;
  color: var(--muted);
  padding: 0.35rem 0.55rem;
  min-height: 2.2rem;
  border: 1px solid var(--border);
  border-radius: 0.525rem;
  font-size: 0.85rem;
  font-weight: 690;
}
.lesson-nav button:hover { color: var(--text); border-color: var(--muted); }
.lesson-nav button[aria-pressed="true"] { color: var(--secondary-text); background: #35383f; border-color: #686d76; }
.done-mark { color: var(--accent); margin-left: 0.25rem; }
.feedback { color: var(--muted); font-size: 0.92rem; margin-top: 0.65rem; min-height: 1.4em; }
.feedback.is-good { color: var(--accent); }
.feedback.is-off { color: var(--rose); }
.feedback.is-guide { color: var(--secondary-text); }
.landmark-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  padding: 0;
  margin: 0.65rem 0 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.9rem;
}
.landmark-legend li { display: grid; justify-items: center; gap: 0.18rem; }
.black-key-cluster { display: flex; gap: 0.14rem; }
.black-key-cluster i {
  width: 0.64rem;
  height: 1.02rem;
  border: 2px solid var(--secondary-text);
  border-radius: 0.12rem 0.12rem 0.2rem 0.2rem;
  background: #202226;
}
.landmark-trio .black-key-cluster i { border-color: var(--amber); }
.natural-groups { display: grid; gap: 0.75rem; }
.natural-keys { display: flex; flex-wrap: wrap; gap: 0.26rem; margin-top: 0.4rem; }
.natural-keys .button { min-width: 2.06rem; min-height: 2.1rem; padding: 0.24rem 0.36rem; gap: 0.12rem; }
.natural-keys .done-mark { margin-left: 0; }
.note-prompt-header { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 1rem; }
.note-prompt-header h2 { font-size: clamp(1.75rem, 5vw, 2.55rem); }
.note-prompt-header p { font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.side-panel, .beat-panel {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: #1d1f23a8;
  padding: 1rem;
  align-self: start;
}
.side-panel h3, .beat-panel h3 { color: var(--muted); font-weight: 675; }
.chord-map { display: grid; gap: 0.58rem; margin-top: 0.75rem; }
.chord-map > div { display: grid; grid-template-columns: 2.3rem 3rem 1fr; gap: 0.45rem; align-items: center; }
.degree {
  display: inline-grid;
  place-items: center;
  min-height: 1.95rem;
  min-width: 2.1rem;
  padding-inline: 0.3rem;
  border-radius: 0.43rem;
  background: #3b3e44;
  color: var(--secondary-text);
  font-weight: 760;
  font-size: 0.88rem;
}
.chord-map dd { color: var(--text); font-size: 0.95rem; }
.chord-map .chord-word { color: var(--muted); }
.pitch-list { display: flex; gap: 0.4rem; margin-top: 0.58rem; }
.pitch-list span {
  min-width: 2rem;
  padding: 0.2rem 0.42rem;
  text-align: center;
  border-radius: 0.4rem;
  border: 1px solid #67835b;
  background: #2e3e31;
  color: var(--accent);
  font-weight: 720;
}
.listening-steps {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.55rem;
  width: min(100%, 29rem);
  padding: 0;
  margin: 0.9rem 0 0;
  list-style: none;
}
.listening-steps li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.62rem 0.7rem;
  min-width: 0;
  min-height: 3.25rem;
  border: 1px solid var(--border);
  border-radius: 0.58rem;
  background: #1d1f23;
  line-height: 1.25;
}
.listening-steps li[aria-current="true"] { border-color: #91b97b; background: #28382b; color: var(--accent); }
.listening-steps li > span:not(.degree) { color: var(--muted); font-size: 0.875rem; }
.listening-steps li > strong { font-size: 1.08rem; }
.cue-label { display: block; color: var(--secondary-text); margin-top: 0.65rem; font-size: 0.9rem; font-weight: 660; }
.cue-word { display: flex; align-items: center; gap: 0.75rem; margin-block: 0.16rem; font-size: clamp(1.35rem, 4vw, 2.7rem); line-height: 1.25; }
.cue-word .degree { letter-spacing: 0; }
.cue-word.is-next { color: var(--accent); }
.cue-direction { margin-top: 0.5rem; }
.beat-heading { display: flex; justify-content: space-between; gap: 0.6rem; align-items: baseline; }
.beat-heading p { font-size: 0.85rem; }
.beats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; margin-block: 0.85rem 0.6rem; }
.beat {
  display: grid;
  place-items: center;
  height: 2.7rem;
  border: 1px solid #50535a;
  border-radius: 0.45rem;
  background: #2c2f34;
  color: var(--muted);
  font-weight: 740;
  font-variant-numeric: tabular-nums;
}
.beat:first-child { border-color: #666b74; }
.beat.is-current { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }
.beat-help { font-size: 0.875rem; }

.rhythm-tempo {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.35rem 1rem;
  max-width: 22rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.rhythm-tempo output { color: var(--accent); font-weight: 750; font-variant-numeric: tabular-nums; }
.rhythm-tempo input { grid-column: 1 / -1; width: 100%; margin: 0; accent-color: var(--accent); }
.rhythm-tempo input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.rhythm-phase { min-height: 1.25em; color: var(--text); font-weight: 725; }
.rhythm-cue-slot { display: grid; align-items: center; height: 3.65rem; }
.rhythm-cue-slot .beats { width: 100%; margin: 0; }
.rhythm-silent { text-align: center; font-size: 0.9rem; }
.rhythm-pad {
  width: 100%;
  min-height: 5.3rem;
  padding: 0.65rem;
  border: 1px solid #81858d;
  border-radius: 0.7rem;
  background: #35383f;
  color: var(--text);
  font-size: 1.48rem;
  font-weight: 760;
  touch-action: manipulation;
  user-select: none;
}
.rhythm-pad:not(:disabled):hover { border-color: var(--accent); }
.rhythm-pad:not(:disabled):active, .rhythm-pad.is-tapped {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}
.rhythm-input-help { margin-top: 0.5rem; text-align: center; font-size: 0.85rem; }

.rhythm-review-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.rhythm-review-filters select { max-width: 100%; }
.rhythm-tendency { color: var(--text); }
.rhythm-quiet-result, .rhythm-advice, .rhythm-chart-key { margin-top: 0.48rem; font-size: 0.9rem; }
.rhythm-advice { color: var(--secondary-text); }
.rhythm-chart, .rhythm-comparison { margin-top: 1.05rem; }
.rhythm-chart-key { margin-bottom: 0.65rem; }
.rhythm-chart-row {
  display: grid;
  grid-template-columns: minmax(5.9rem, max-content) minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.28rem;
}
.rhythm-bar-label { color: var(--muted); font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.rhythm-track {
  position: relative;
  height: 3.3rem;
  margin-inline: 0.35rem;
  padding: 0 0.2rem;
  border-block: 1px solid #41444a;
  background: #23252a;
}
.was-quiet .rhythm-track { background: #2b2e33; border-block-color: #51555e; }
.rhythm-reference {
  position: absolute;
  top: 1.18rem;
  bottom: 0.35rem;
  left: var(--x);
  width: 1px;
  background: #7d8189;
}
.rhythm-reference b {
  position: absolute;
  left: 0;
  top: -1.05rem;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.69rem;
}
.rhythm-reference.is-playing { background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.rhythm-reference.is-playing b { color: var(--accent); }
.rhythm-hit, .rhythm-extra, .rhythm-miss {
  position: absolute;
  left: var(--x);
  transform: translateX(-50%);
}
.rhythm-hit, .rhythm-extra { border-radius: 50%; }
.rhythm-hit { top: 1.72rem; width: 0.54rem; height: 0.54rem; background: var(--accent); }
.rhythm-hit.early { background: var(--secondary-text); }
.rhythm-hit.late { background: var(--amber); }
.rhythm-extra { top: 2.4rem; width: 0.49rem; height: 0.49rem; border: 1.5px solid var(--text); }
.rhythm-miss { top: 1.32rem; color: var(--rose); font-size: 1.03rem; font-weight: 750; }
.rhythm-comparison .history-control { width: fit-content; max-width: 100%; }
.rhythm-table-scroll { overflow-x: auto; margin-top: 0.6rem; }
.rhythm-comparison table { width: 100%; border-collapse: collapse; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.rhythm-comparison th, .rhythm-comparison td { padding: 0.4rem 0.55rem; border-top: 1px solid var(--border); text-align: right; }
.rhythm-comparison th { color: var(--muted); font-weight: 650; }
.rhythm-comparison th:first-child { text-align: left; }

.instrument { margin-top: 0.9rem; padding: clamp(0.85rem, 2.8vw, 1.3rem); }
.instrument-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.8rem; margin-bottom: 0.8rem; }
.instrument-header h2 { font-size: 1.34rem; }
.instrument-header p { margin-top: 0.2rem; font-size: 0.93rem; }
.instrument-actions { justify-content: flex-end; flex: none; }
.piano-scroll { overflow-x: auto; border-radius: 0.53rem; background: #121416; scrollbar-color: #62666e #232529; }
.piano {
  --white-keys: 11;
  display: flex;
  position: relative;
  min-width: 16.5rem;
  height: clamp(8.5rem, 16vw, 10.5rem);
  isolation: isolate;
  user-select: none;
}
.piano-key {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 0.35rem 0.1rem 0.45rem;
  border: 1px solid #25272b;
  border-radius: 0 0 0.43rem 0.43rem;
  touch-action: pan-x pan-y;
}
.piano-key.white {
  flex: 1 1 0;
  min-width: 0;
  color: #313338;
  background: linear-gradient(#e5e7eb 50%, #f8f9fa);
  box-shadow: inset 0 -4px #cdd1d6;
}
.piano-key.black {
  position: absolute;
  top: 0;
  left: calc(var(--boundary) * 100% / var(--white-keys));
  transform: translateX(-50%);
  width: calc(100% / var(--white-keys) * 0.61);
  height: 61%;
  z-index: 1;
  background: linear-gradient(#191b1e, #2b2e32);
  color: #f0f1f3;
  box-shadow: inset 0 -4px #111315, 0 2px 4px #0b0d10a8;
}
.piano-key .pitch { font-size: 0.92rem; font-weight: 800; }
.piano-key.black .pitch { display: none; }
.piano-key:hover { filter: brightness(0.94); }
.piano-key:focus-visible { outline: 2px solid #48535d; outline-offset: -3px; }
.piano-key.black:focus-visible { outline-color: var(--secondary-text); }
.piano-key.white.is-target { background: linear-gradient(#e8f7df, #caf3b0); box-shadow: inset 0 -4px #94bc7b; }
.piano-key.black.is-landmark { box-shadow: inset 0 0 0 2px #b4bdca, inset 0 -5px #616873, 0 2px 4px #0b0d10a8; }
.piano-key.black.is-landmark-three { box-shadow: inset 0 0 0 2px #f2c581, inset 0 -5px #846845, 0 2px 4px #0b0d10a8; }
.piano-key:is(.white, .black).is-selected { background: var(--secondary-text); color: #242629; box-shadow: inset 0 -4px #9da3ad; }
.piano-key:is(.white, .black).is-sounding { background: var(--accent); color: var(--accent-text); box-shadow: inset 0 -4px #7eae65; }
.instrument-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem 0.65rem; margin-top: 0.55rem; color: var(--muted); font-size: 0.875rem; }
.octave-controls { display: flex; align-items: center; gap: 0.4rem; }
.octave-controls .button { min-height: 2.1rem; padding: 0.25rem 0.55rem; font-size: 0.875rem; }
#keyboard-range { min-width: 4.1rem; text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }

.review-header { display: flex; justify-content: space-between; align-items: start; gap: 1rem; flex-wrap: wrap; }
.review-date { margin-top: 0.35rem; font-size: 0.88rem; }
.review-totals { display: flex; flex-wrap: wrap; gap: 0.55rem; margin: 1rem 0; }
.review-totals div { min-width: 7rem; padding: 0.5rem 0.75rem; border-radius: 0.6rem; border: 1px solid var(--border); background: #25272b; }
.review-totals dt { font-size: 0.84rem; color: var(--muted); }
.review-totals dd { font-size: 1.35rem; font-weight: 760; }
.result-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--border); }
.result-list li {
  display: grid;
  grid-template-columns: minmax(10rem, 1.15fr) minmax(9rem, 1fr) minmax(7.5rem, 0.7fr) auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}
.result-call { display: flex; align-items: center; gap: 0.6rem; }
.result-call strong { display: block; }
.result-call small, .result-notes { color: var(--muted); font-size: 0.84rem; }
.result-time, .result-accuracy { font-size: 0.9rem; font-weight: 700; }
.result-time.is-good, .result-accuracy.is-good { color: var(--accent); }
.result-time.is-off { color: var(--amber); }
.result-accuracy.is-off { color: var(--rose); }
.result-accuracy.is-helped { color: var(--amber); }
.note-result-name { justify-self: start; }
.result-list.note-results li { grid-template-columns: 2.65rem minmax(0, 1fr) minmax(8rem, 0.8fr); }
.result-retry { justify-self: end; }
.history-control { display: grid; gap: 0.25rem; font-size: 0.85rem; color: var(--muted); }
.history-control select {
  appearance: none;
  padding: 0.48rem 2rem 0.48rem 0.7rem;
  min-height: 2.65rem;
  width: 100%;
  border: 1px solid #646973;
  border-radius: 0.55rem;
  background: #25272b;
  color: var(--text);
}
.history-select { position: relative; }
.history-select::after {
  content: '';
  position: absolute;
  right: 0.8rem;
  top: 0.98rem;
  width: 0.48rem;
  height: 0.48rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  pointer-events: none;
}

@media (min-width: 47.01rem) and (max-height: 49rem) {
  .topbar-inner { min-height: 3.65rem; }
  .workspace { padding-top: 1.2rem; }
  h1 { font-size: clamp(1.4rem, 3.3vw, 2.35rem); }
  .steps { margin-block: 1rem 0.72rem; }
  .steps button { min-height: 2.35rem; }
  .stage { padding: 1rem 1.2rem; }
  .stage-blurb { margin-block: 0.4rem 0.62rem; }
  .lesson-nav { margin-bottom: 0.6rem; }
  .side-panel, .beat-panel { padding: 0.8rem; }
  .chord-map { gap: 0.38rem; }
  .instrument { padding: 0.9rem 1.1rem; margin-top: 0.72rem; }
  .instrument-header { margin-bottom: 0.65rem; }
  .piano { height: 8.45rem; }
}

@media (max-width: 47rem) {
  .intro { align-items: start; flex-direction: column; gap: 0.75rem; }
  .workspace { padding-top: 1.5rem; }
  .stage-grid { grid-template-columns: 1fr; }
  .stage.is-live { position: sticky; z-index: 3; top: 0.5rem; }
  .chord-map { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chord-map > div { grid-template-columns: auto 1fr; gap: 0.2rem 0.3rem; }
  .chord-map dd:last-child { grid-column: 1 / -1; }
  .instrument-header { flex-wrap: wrap; }
  .instrument-actions { justify-content: flex-start; flex: 1 1 auto; }
  .natural-groups { grid-template-columns: minmax(0, 1fr) minmax(0, 1.33fr); }
  .natural-keys .button { min-width: 1.54rem; }
  .result-list li { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 0.85rem; }
  .result-retry { justify-self: start; }
}
@media (max-width: 29rem) {
  .guided-workspace { min-height: calc(100svh - 3.6rem); }
  .topbar-inner { gap: 0.45rem; min-height: 3.55rem; padding-block: 0.4rem; }
  .brand { max-width: 8.6rem; }
  .device-controls { flex-wrap: nowrap; justify-content: flex-end; gap: 0.25rem; }
  .device-controls .button { padding-inline: 0.36rem; min-height: 2.5rem; font-size: 1.05rem; white-space: nowrap; }
  .workspace { padding-top: 0.8rem; }
  .lesson-chooser { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 0.8rem; }
  .lesson-chooser button { padding: 0.38rem 0.45rem; font-size: 0.7rem; }
  .lesson-chooser small { line-height: 1.15; }
  .intro { gap: 0.5rem; }
  .session-settings div { padding: 0.28rem 0.68rem; }
  .session-settings dt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .session-settings dd { font-size: 0.875rem; }
  .steps { margin-block: 0.95rem 0.75rem; }
  .steps button { min-height: 2.35rem; padding-inline: 0.1rem; font-size: 0.85rem; }
  .lesson-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.25rem; margin-bottom: 0.7rem; }
  .stage[data-active-lesson="jazz-changes"] .lesson-nav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .lesson-nav button { padding: 0.3rem 0.2rem; font-size: 0.82rem; line-height: 1.4; }
  .stage-grid:has(.lesson-nav) .side-panel { display: none; }
  .stage-blurb { margin-block: 0.45rem 0.4rem; }
  .listening-steps li { align-items: flex-start; flex-direction: column; gap: 0.28rem; padding: 0.45rem; }
  .natural-groups { padding: 0.65rem; }
  .natural-groups h3 { font-size: 0.88rem; }
  .result-list.note-results li { grid-template-columns: 2.25rem minmax(0, 1fr); }
  .note-results .result-notes { grid-column: 2; }
  .rhythm-chart-row { grid-template-columns: 4.55rem minmax(0, 1fr); gap: 0.25rem; }
  .rhythm-reference b { font-size: 0.68rem; }
  .instrument-header:has(#stack-mode[aria-pressed="false"]) {
    display: grid;
    grid-template: "title actions" auto "help help" auto / 1fr auto;
    align-items: center;
    gap: 0.25rem 0.5rem;
  }
  .instrument-header:has(#stack-mode[aria-pressed="false"]) > div:first-child { display: contents; }
  .instrument-header h2 { grid-area: title; }
  .instrument-header p { grid-area: help; }
  .instrument-actions { grid-area: actions; }
  .piano { height: 7.5rem; }
  .octave-controls { order: -1; flex-wrap: wrap; gap: 0.28rem; }
  .octave-controls .button { padding-inline: 0.38rem; }
}
