:root {
  color-scheme: light;
  --ink: #1d241f;
  --muted: #70786f;
  --paper: #f4efe6;
  --card: #fffdf8;
  --line: #d9d1c4;
  --green: #285f4b;
  --green-dark: #174735;
  --lime: #d6f06e;
  --orange: #e96b3a;
  --wood-1: #8f5d39;
  --wood-2: #6f4229;
  --shadow: 0 18px 45px rgba(49, 38, 25, 0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, rgba(214, 240, 110, 0.15), transparent 26rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding-bottom: 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  border-bottom: 1px solid rgba(29, 36, 31, 0.12);
}

.instrument-switch { display: flex; width: fit-content; margin: 22px auto -8px; padding: 4px; background: #e8e2d7; border: 1px solid #d8d0c3; border-radius: 8px; }
.instrument-switch label { cursor: pointer; }
.instrument-switch input { position: absolute; opacity: 0; pointer-events: none; }
.instrument-switch span { display: block; min-width: 128px; padding: 8px 12px; color: var(--muted); border-radius: 5px; font-size: 12px; font-weight: 700; text-align: center; white-space: nowrap; transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease; }
.instrument-switch input:checked + span { color: var(--card); background: var(--green); box-shadow: 0 1px 3px rgba(23, 71, 53, 0.25); }
.instrument-switch input:focus-visible + span { outline: 2px solid var(--orange); outline-offset: 2px; }

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--lime);
  background: var(--green-dark);
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 23px;
  font-style: italic;
  font-weight: 700;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: 0.02em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 9px; letter-spacing: 0.14em; }

.round-count { display: flex; align-items: baseline; gap: 10px; color: var(--muted); font-size: 12px; }
.round-count strong { color: var(--ink); font-family: Georgia, serif; font-size: 25px; font-weight: 500; }

.hero { padding: 48px 0 44px; text-align: center; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.pulse-dot { width: 7px; height: 7px; background: var(--orange); border-radius: 50%; box-shadow: 0 0 0 5px rgba(233, 107, 58, 0.12); }

.note-stage { display: grid; grid-template-columns: 1fr 178px 1fr; align-items: center; gap: 44px; }

.note-card {
  position: relative;
  display: grid;
  width: 178px;
  height: 178px;
  place-items: center;
  color: var(--card);
  background: var(--green-dark);
  border: 6px solid var(--card);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(29, 36, 31, 0.15), 0 18px 32px rgba(23, 71, 53, 0.2);
}

.note-card::after { content: ""; position: absolute; inset: 8px; border: 1px solid rgba(214, 240, 110, 0.35); border-radius: 50%; }
.note-card span { font-family: Georgia, "Times New Roman", serif; font-size: 112px; line-height: 1; transform: translateY(-3px); }
.note-card.accidental span { font-size: 72px; letter-spacing: -0.06em; transform: translate(-3px, -2px); }
.note-card.pop span { animation: note-pop 320ms ease; }
@keyframes note-pop { 0% { opacity: 0; transform: scale(0.65) rotate(-8deg); } 100% { opacity: 1; transform: scale(1) rotate(0) translateY(-3px); } }

.side-action {
  display: inline-flex;
  width: 150px;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.side-action:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(29, 36, 31, 0.1); }
.side-action:active { transform: translateY(0); }
.reveal-action { justify-self: end; background: var(--card); }
.next-action { justify-self: start; color: white; background: var(--green); border-color: var(--green); }
.action-icon { font-size: 18px; font-weight: 400; }
.hero-beat-display { display: flex; min-height: 62px; align-items: center; flex-direction: column; justify-content: center; gap: 13px; margin-top: 22px; color: var(--muted); }
.hero-beat-display strong { font-size: 15px; font-weight: 700; text-align: center; }



.section-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 21px; }
.section-kicker { margin: 0 0 4px; color: var(--orange); font-size: 10px; font-weight: 800; letter-spacing: 0.16em; }
.section-heading h1 { margin: 0; font-family: Georgia, serif; font-size: 24px; font-weight: 500; }
.answer-status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.answer-status > span:first-child { color: #b9b7ae; font-size: 9px; }
.answer-status.visible { color: var(--green); }
.answer-status.visible > span:first-child { color: var(--lime); filter: drop-shadow(0 0 3px rgba(40, 95, 75, 0.45)); }

.keyboard-section {
  padding: 27px 28px 22px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid rgba(29, 36, 31, 0.1);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.keyboard-scroll {
  overflow-x: auto;
  padding: 8px 4px 18px;
  scrollbar-color: #b7b0a4 transparent;
  scrollbar-width: thin;
}
.keyboard-scroll:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 3px;
  border-radius: 4px;
}

.piano-keyboard {
  overflow: visible;
  --white-key-w: clamp(28px, 4.6vw, 52px);
  --white-key-h: clamp(140px, 28vw, 210px);
  --black-key-w: calc(var(--white-key-w) * 0.62);
  --black-key-h: calc(var(--white-key-h) * 0.72);
  position: relative;
  display: flex;
  width: max-content;
  min-width: 100%;
  height: var(--white-key-h);
  margin: 0 auto;
  padding: 0;
  justify-content: center;
  user-select: none;
}

.piano-key {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  box-sizing: border-box;
  border-radius: 0 0 6px 6px;
  transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
}

.piano-key.white {
  position: relative;
  width: var(--white-key-w);
  height: var(--white-key-h);
  z-index: 1;
  flex: 0 0 var(--white-key-w);
  color: var(--muted);
  background: linear-gradient(#fffef9, #f3eee4);
  border: 1px solid #cfc6b6;
  border-right-width: 0;
  box-shadow: inset 0 -8px 12px rgba(49, 38, 25, 0.06);
}
.piano-key.white.last-white {
  border-right-width: 1px;
}
.piano-key.white .key-label {
  margin-bottom: 10px;
  font-family: Georgia, serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.55;
}

.piano-key.black {
  position: absolute;
  top: 0;
  left: 0; /* px from keyboard.js _layoutBlacks — straddles white-key gaps */
  right: auto;
  width: var(--black-key-w);
  height: var(--black-key-h);
  z-index: 5;
  padding: 0;
  color: #d6f06e;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.12) 0%, transparent 18%, transparent 82%, rgba(0,0,0,0.35) 100%),
    linear-gradient(#2f2f2c, #171715 78%, #0a0a09);
  border: 1px solid #050505;
  border-top: none;
  border-radius: 0 0 4px 4px;
  box-shadow:
    0 8px 12px rgba(0, 0, 0, 0.4),
    inset 0 -3px 0 rgba(255, 255, 255, 0.06),
    inset 1px 0 0 rgba(255, 255, 255, 0.08);
}
.piano-key.black .key-label {
  margin-bottom: 10px;
  font-family: Georgia, serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: -0.04em;
  opacity: 0;
}

.piano-key .answer-mark {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 4;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: var(--green-dark);
  background: var(--lime);
  border: 2px solid #fff7dc;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(20, 40, 30, 0.35);
  font-family: Georgia, serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.06em;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}
.piano-key.black .answer-mark {
  top: 55%;
  width: 22px;
  height: 22px;
  font-size: 11px;
}

.piano-keyboard.show-answer .piano-key.match .answer-mark {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.piano-keyboard.show-answer .piano-key.white.match {
  background: linear-gradient(#f7ffe8, #e5f5c0);
  box-shadow: inset 0 -8px 12px rgba(40, 95, 75, 0.12), 0 0 0 2px rgba(214, 240, 110, 0.55);
}
.piano-keyboard.show-answer .piano-key.black.match {
  background: linear-gradient(#4a5f38, #2a3d22 70%, #1a2814);
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.35), 0 0 0 2px rgba(214, 240, 110, 0.7);
}
.piano-keyboard.show-answer .piano-key.black.match .key-label {
  opacity: 0.85;
}

.octave-divider {
  position: absolute;
  bottom: -14px;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
  pointer-events: none;
}

.keyboard-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}
























.hint-line { width: 22px; height: 1px; background: var(--orange); }

.controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.control-card { position: relative; padding: 22px 24px 19px; overflow: hidden; background: var(--card); border: 1px solid rgba(29, 36, 31, 0.1); border-radius: 16px; }
.control-title-row { display: grid; grid-template-columns: 42px 1fr auto; gap: 13px; align-items: center; }
.control-icon { display: grid; width: 42px; height: 42px; place-items: center; color: var(--green); background: #e5eee6; border-radius: 11px; font-size: 21px; }
.accidental-card .control-icon { font-family: Georgia, serif; font-size: 17px; font-weight: 700; }
.string-count-card .control-icon { font-size: 26px; line-height: 1; }
.string-count-card h2 { white-space: nowrap; }
.control-card h2 { margin: 0 0 4px; font-size: 14px; }
.control-card p { margin: 0; color: var(--muted); font-size: 11px; }

.switch { position: relative; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { display: block; width: 45px; height: 25px; padding: 3px; background: #d7d4cc; border-radius: 20px; transition: background 180ms ease; }
.switch-thumb { display: block; width: 19px; height: 19px; background: white; border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,0.25); transition: transform 180ms ease; }
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--orange); outline-offset: 3px; }

.setting-row { display: flex; align-items: center; justify-content: space-between; margin-top: 19px; padding-top: 15px; border-top: 1px solid #ebe6dd; color: var(--muted); font-size: 12px; opacity: 0.45; pointer-events: none; transition: opacity 180ms ease; }
.setting-row.enabled { opacity: 1; pointer-events: auto; }
.number-field { display: flex; height: 31px; align-items: center; overflow: hidden; color: var(--ink); background: var(--paper); border: 1px solid #ddd6cb; border-radius: 8px; }
.number-field button { width: 29px; height: 100%; padding: 0; background: transparent; border: 0; cursor: pointer; }
.number-field button:hover { background: #e8e1d6; }
.number-field input { width: 30px; padding: 0; text-align: center; background: transparent; border: 0; outline: 0; font-weight: 700; appearance: textfield; }
.number-field input::-webkit-inner-spin-button { display: none; }
.number-field span { padding-right: 4px; color: var(--muted); font-size: 10px; }
.speed-fields { display: flex; align-items: center; gap: 8px; }
.equals { color: var(--muted); font-size: 13px; }
.timer-track { position: absolute; right: 0; bottom: 0; left: 0; height: 3px; background: transparent; }
.timer-track span { display: block; width: 0; height: 100%; background: var(--orange); }

.metronome-card { grid-column: 1 / -1; }
.metronome-card .control-icon { font-family: Georgia, serif; font-size: 25px; }
.metronome-settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 19px; padding-top: 15px; border-top: 1px solid #ebe6dd; }
.metronome-settings label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; }
.metronome-settings select { width: 100%; height: 36px; padding: 0 10px; color: var(--ink); background: var(--paper); border: 1px solid #ddd6cb; border-radius: 8px; cursor: pointer; outline: none; }
.metronome-settings select:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.metronome-cycle-summary { display: grid; gap: 7px; color: var(--muted); font-size: 11px; }
.metronome-cycle-summary strong { display: flex; height: 36px; align-items: center; padding: 0 10px; color: var(--green-dark); background: #edf2e8; border: 1px solid #dbe4d5; border-radius: 8px; font-size: 12px; }
.sound-volume-settings { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 4px; padding-top: 15px; border-top: 1px solid #ebe6dd; }
.sound-volume-settings label { display: grid; gap: 9px; color: var(--muted); font-size: 11px; }
.sound-volume-settings label > span { display: flex; justify-content: space-between; gap: 10px; }
.sound-volume-settings output { color: var(--green); font-weight: 700; }
.sound-volume-settings input[type="range"] { width: 100%; height: 5px; margin: 5px 0; accent-color: var(--green); cursor: pointer; }
.sound-volume-settings input[type="range"]:focus-visible { outline: 2px solid var(--orange); outline-offset: 5px; }
.beat-dots { display: flex; gap: 10px; align-items: center; }
.beat-dot { width: 11px; height: 11px; background: #d1cdc4; border-radius: 50%; transition: background 80ms ease, transform 80ms ease; }
.beat-dot.active { background: var(--orange); transform: scale(1.35); }
.beat-dot.accent { box-shadow: 0 0 0 3px rgba(233, 107, 58, 0.14); }

.speak-now {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 19px;
  color: var(--green-dark);
  background: #edf2e8;
  border: 1px solid #dbe4d5;
  border-radius: 9px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  transition: background 160ms ease, transform 160ms ease;
}
.speak-now:hover { background: #e1eadb; transform: translateY(-1px); }
.speak-now:active { transform: translateY(0); }
.speak-now span { color: var(--orange); font-size: 10px; }

.voice-source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}
.voice-source-row select {
  min-width: 112px;
  height: 32px;
  padding: 0 30px 0 10px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #ddd6cb;
  border-radius: 8px;
  cursor: pointer;
  outline: none;
}
.voice-source-row select:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

.string-count-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 19px; }
.string-count-options label { cursor: pointer; }
.string-count-options input { position: absolute; opacity: 0; pointer-events: none; }
.string-count-options span { display: grid; min-height: 34px; place-items: center; color: var(--muted); background: var(--paper); border: 1px solid #ddd6cb; border-radius: 8px; font-size: 11px; transition: color 160ms ease, background 160ms ease, border-color 160ms ease; }
.string-count-options input:checked + span { color: var(--card); background: var(--green); border-color: var(--green); }
.string-count-options input:focus-visible + span { outline: 2px solid var(--orange); outline-offset: 2px; }

footer { display: flex; align-items: center; justify-content: center; gap: 8px; padding-top: 25px; color: var(--muted); font-size: 10px; }
footer > span { margin-right: 3px; color: var(--ink); font-weight: 700; }
footer a { margin-left: 8px; color: var(--muted); text-underline-offset: 2px; }
footer a:hover { color: var(--green); }
kbd { padding: 3px 6px; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; font-family: inherit; font-size: 9px; }

.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; }

@media (max-width: 760px) {
  .app-shell { width: min(100% - 24px, 1180px); }
  .topbar { min-height: 74px; }
  .round-count span { display: none; }
  .instrument-switch { width: 100%; }
  .instrument-switch label { flex: 1; min-width: 0; }
  .instrument-switch span { min-width: 0; padding-inline: 6px; font-size: 11px; }
  .hero { padding: 35px 0 31px; }
  .note-stage { grid-template-columns: 1fr 132px 1fr; gap: 12px; }
  .note-card { width: 132px; height: 132px; }
  .note-card span { font-size: 84px; }
  .note-card.accidental span { font-size: 54px; }
  .side-action { width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 50%; }
  .side-action span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .reveal-action { justify-self: end; }
  .next-action { justify-self: start; }
  
  
  
  
  .controls { grid-template-columns: 1fr; }
  .metronome-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metronome-cycle-summary { grid-column: 1 / -1; }
  .sound-volume-settings { grid-template-columns: 1fr; gap: 14px; }
  footer { flex-wrap: wrap; }
}

@media (min-width: 761px) and (max-width: 1040px) {
  .controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ===== Trainer shell additions ===== */
.app-shell.trainer { width: min(1240px, calc(100% - 32px)); }

.topbar { gap: 16px; flex-wrap: wrap; padding: 8px 0; }

.midi-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
  min-width: 220px;
}
.midi-btn {
  white-space: nowrap;
}
.midi-select {
  min-width: 160px;
  max-width: 240px;
  height: 34px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.midi-status {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.midi-status.ok { color: var(--green); font-weight: 700; }
.midi-status.bad { color: var(--orange); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(29,36,31,0.08); }
.btn.primary { color: #fff; background: var(--green); border-color: var(--green); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.mode-nav {
  display: flex;
  gap: 6px;
  margin: 18px 0 8px;
  padding: 6px;
  overflow-x: auto;
  background: #e8e2d7;
  border: 1px solid #d8d0c3;
  border-radius: 12px;
  scrollbar-width: thin;
}
.mode-nav-btn {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.mode-nav-btn:hover { background: rgba(255,255,255,0.55); color: var(--ink); }
.mode-nav-btn.active {
  color: var(--card);
  background: var(--green);
  box-shadow: 0 1px 3px rgba(23,71,53,0.25);
}

.mode-panel-wrap { margin: 10px 0 16px; }
.mode-panel {
  padding: 22px 24px 18px;
  background: var(--card);
  border: 1px solid rgba(29,36,31,0.1);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.mode-hero { text-align: center; padding: 8px 0 12px; }
.mode-sub { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.prompt-card {
  display: inline-grid;
  min-width: 120px;
  min-height: 120px;
  place-items: center;
  margin: 0 auto;
  padding: 12px 22px;
  color: var(--card);
  background: var(--green-dark);
  border: 6px solid var(--card);
  border-radius: 28px;
  box-shadow: 0 0 0 1px rgba(29,36,31,0.15), 0 18px 32px rgba(23,71,53,0.2);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 64px;
  line-height: 1;
}
.prompt-card.chord { min-width: 160px; font-size: 52px; border-radius: 24px; }
.prompt-card .roman {
  display: block;
  margin-bottom: 4px;
  color: var(--lime);
  font-size: 18px;
  letter-spacing: 0.08em;
}
.inv-badge {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 14px;
  color: var(--green-dark);
  background: var(--lime);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}
.mode-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #ebe6dd;
}
.mode-toolbar label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.mode-toolbar select {
  height: 34px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #ddd6cb;
  border-radius: 8px;
  cursor: pointer;
}
.field-label { font-weight: 700; color: var(--muted); }
.chip-toggle {
  padding: 6px 12px;
  background: var(--paper);
  border: 1px solid #ddd6cb;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
}
.chip-toggle input { accent-color: var(--green); }
.progress-pill {
  padding: 6px 12px;
  color: var(--green-dark);
  background: #edf2e8;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.seq-dots, .beat-dots { display: flex; gap: 8px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.seq-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #d1cdc4;
}
.seq-dot.active { background: var(--orange); transform: scale(1.3); }
.seq-dot.done { background: var(--green); }
.score-line { margin: 10px 0 0; color: var(--green); font-size: 13px; font-weight: 700; }
.prog-steps { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.prog-step {
  padding: 6px 10px;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid #ddd6cb;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}
.prog-step.active { color: #fff; background: var(--green); border-color: var(--green); }

.key-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}
.key-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.12);
}
.lg.target { background: #e5f5c0; }
.lg.bass { background: #e8c39a; }
.lg.pressed { background: #cfe0ff; }
.lg.correct { background: #8fd6a8; }
.lg.wrong { background: #f0a090; }

/* Piano key interactive + highlight states */
.piano-key { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.piano-key:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; z-index: 5; }

.piano-key.white.pressed {
  background: linear-gradient(#e8f0ff, #d5e2fb);
  transform: translateY(2px);
  box-shadow: inset 0 -4px 8px rgba(40,70,120,0.12);
}
.piano-key.black.pressed {
  background: linear-gradient(#4a5878, #2a3450 70%, #1a2238);
  transform: translateY(1px);
}

.piano-key.white.target,
.piano-keyboard.show-answer .piano-key.white.target {
  background: linear-gradient(#f7ffe8, #e5f5c0);
  box-shadow: inset 0 -8px 12px rgba(40,95,75,0.12), 0 0 0 2px rgba(214,240,110,0.55);
}
.piano-key.black.target,
.piano-keyboard.show-answer .piano-key.black.target {
  background: linear-gradient(#4a5f38, #2a3d22 70%, #1a2814);
  box-shadow: 0 6px 10px rgba(0,0,0,0.35), 0 0 0 2px rgba(214,240,110,0.7);
}
.piano-key.black.target .key-label { opacity: 0.85; }

.piano-key.white.bass {
  background: linear-gradient(#fff0de, #f0d2b0);
  box-shadow: inset 0 -8px 12px rgba(120,70,30,0.12), 0 0 0 2px rgba(233,140,60,0.55);
}
.piano-key.black.bass {
  background: linear-gradient(#6a4a28, #3d2a16 70%, #24180c);
  box-shadow: 0 6px 10px rgba(0,0,0,0.35), 0 0 0 2px rgba(233,140,60,0.7);
}

.piano-key.white.correct {
  background: linear-gradient(#e5ffe8, #b8f0c4) !important;
  box-shadow: 0 0 0 2px rgba(80,180,110,0.7) !important;
}
.piano-key.black.correct {
  background: linear-gradient(#3a6a48, #1e4030) !important;
  box-shadow: 0 0 0 2px rgba(120,220,150,0.8) !important;
}
.piano-key.white.wrong {
  background: linear-gradient(#ffe8e2, #f5c4b8) !important;
  box-shadow: 0 0 0 2px rgba(220,90,70,0.55) !important;
}
.piano-key.black.wrong {
  background: linear-gradient(#6a3830, #3a1e18) !important;
  box-shadow: 0 0 0 2px rgba(240,120,100,0.7) !important;
}

.piano-key.target .answer-mark,
.piano-key.bass .answer-mark,
.piano-keyboard.show-answer .piano-key.target .answer-mark,
.piano-keyboard.show-answer .piano-key.bass .answer-mark {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.piano-key.bass .answer-mark {
  background: #f0b060;
  color: #4a2a10;
}

@media (max-width: 760px) {
  .midi-bar { order: 3; width: 100%; justify-content: flex-start; }
  .prompt-card { min-width: 96px; min-height: 96px; font-size: 48px; }
  .prompt-card.chord { font-size: 36px; min-width: 120px; }
  .mode-toolbar { justify-content: flex-start; }
}

/* ── Proficiency (熟练度) heatmap ───────────────────────────────── */
.mode-nav-btn[data-mode="proficiency"] {
  margin-left: 4px;
  border-left: 1px solid rgba(29, 36, 31, 0.12);
  padding-left: 14px;
}

.proficiency-panel {
  padding-bottom: 28px;
}

.prof-layout { position: relative; }
.prof-title {
  margin: 6px 0 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.prof-header {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}
.prof-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.prof-stat {
  min-width: 88px;
  padding: 10px 14px;
  background: #f3eee4;
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
}
.prof-stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.prof-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
  color: var(--green-dark);
}

.prof-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin: 8px 0 12px;
}
.prof-controls label { display: grid; gap: 4px; }
.field-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.prof-controls select,
.mode-toolbar select {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
}

.prof-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.prof-legend span { display: inline-flex; align-items: center; gap: 6px; }
.prof-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(29, 36, 31, 0.12);
}
.prof-swatch.empty { background: #efe9df; }
.prof-swatch.sparse { background: #d5cbb8; }
.prof-swatch.fair { background: #8faf6a; }
.prof-swatch.master { background: var(--green-dark); }
.prof-swatch.weak { background: var(--orange); }

.prof-heatmap-wrap {
  overflow-x: auto;
  margin: 0 0 18px;
  padding: 8px;
  background: #f7f2e9;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.prof-heatmap {
  display: grid;
  gap: 3px;
  min-width: max-content;
}
.prof-hcell {
  display: grid;
  place-items: center;
  min-height: 26px;
  padding: 2px 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
}
.prof-hcell.head.row {
  justify-content: end;
  padding-right: 8px;
  color: var(--ink);
  font-size: 12px;
}
.prof-hcell.corner { font-size: 9px; }

.prof-cell {
  position: relative;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border: 1px solid rgba(29, 36, 31, 0.08);
  border-radius: 6px;
  background: #efe9df;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.prof-cell:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(49, 38, 25, 0.15);
  z-index: 1;
}
.prof-cell.empty { background: #efe9df; }
.prof-cell.sparse { background: #d5cbb8; }
.prof-cell.fair { background: #8faf6a; color: #fff; }
.prof-cell.master { background: var(--green-dark); color: var(--lime); }
.prof-cell.weak { background: var(--orange); color: #fff; }
.prof-cell-n {
  font-size: 9px;
  font-weight: 800;
  opacity: 0.9;
  pointer-events: none;
}

.prof-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.prof-card {
  padding: 14px 16px;
  background: #faf6ef;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.prof-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 800;
}
.prof-rollup { display: grid; gap: 6px; max-height: 280px; overflow: auto; }
.prof-rollup-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.prof-rollup-root { font-weight: 800; }
.prof-bar {
  height: 8px;
  background: #e8e2d7;
  border-radius: 999px;
  overflow: hidden;
}
.prof-bar i { display: block; height: 100%; border-radius: inherit; }
.prof-rollup-meta { color: var(--muted); font-size: 11px; white-space: nowrap; }

.prof-weak-list,
.prof-confused {
  margin: 0;
  padding: 0 0 0 18px;
  font-size: 13px;
}
.prof-weak-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.prof-weak-sym {
  padding: 0;
  border: 0;
  background: none;
  color: var(--green-dark);
  font-weight: 800;
  cursor: pointer;
  text-align: left;
  font-family: Georgia, serif;
  font-size: 15px;
}
.prof-weak-sym:hover { color: var(--orange); }
.btn.tiny {
  min-height: 28px;
  padding: 0 10px;
  font-size: 11px;
}
.prof-empty { color: var(--muted); list-style: none; margin-left: -18px; }
.prof-confused li { margin-bottom: 6px; color: var(--muted); }

.prof-drawer {
  position: absolute;
  top: 8px;
  right: 8px;
  width: min(320px, calc(100% - 16px));
  z-index: 5;
}
.prof-drawer-inner {
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.prof-drawer-close { float: right; }
.prof-dl {
  display: grid;
  gap: 8px;
  margin: 12px 0 16px;
}
.prof-dl > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 1px dashed rgba(29, 36, 31, 0.08);
  font-size: 13px;
}
.prof-dl dt { color: var(--muted); }
.prof-dl dd { margin: 0; font-weight: 700; }
.prof-recent { font-family: ui-monospace, monospace; font-size: 11px; letter-spacing: 0.04em; }

@media (max-width: 900px) {
  .prof-columns { grid-template-columns: 1fr; }
}

/* Dual-site nav + compact cloud auth (topbar) */
.site-nav-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.55);
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
}
.site-nav-link:hover {
  background: var(--green);
  color: var(--card);
  border-color: var(--green);
}

.cloud-auth {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 1;
  min-width: 0;
  max-width: 420px;
}
.cloud-auth-guest {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.cloud-auth-authed {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cloud-auth-guest[hidden],
.cloud-auth-authed[hidden] { display: none !important; }
.cloud-input {
  width: 110px;
  min-width: 72px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  font-size: 11px;
}
.cloud-input:focus {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}
.cloud-auth .btn.tiny {
  min-height: 28px;
  padding: 0 8px;
  font-size: 11px;
  white-space: nowrap;
}
.cloud-auth .btn.tiny.ghost {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--muted);
}
.cloud-auth-email {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}
.cloud-auth-status {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cloud-auth-status.ok { color: var(--green); font-weight: 700; }
.cloud-auth-status.bad { color: var(--orange); }
.cloud-auth-status.muted { color: var(--muted); }

.app-shell.trainer .cloud-auth { max-width: 380px; }
.app-shell.trainer .cloud-input { width: 96px; height: 26px; font-size: 10px; }
.app-shell.trainer .site-nav-link { min-height: 26px; padding: 0 8px; font-size: 10px; }
.app-shell.trainer .midi-bar { flex: 0 1 auto; min-width: 0; gap: 6px; }
.app-shell.trainer .midi-select { min-width: 100px; max-width: 160px; height: 26px; font-size: 11px; }
.app-shell.trainer .midi-btn { min-height: 26px; padding: 0 8px; font-size: 11px; }
.app-shell.trainer .midi-status { font-size: 10px; }

@media (max-width: 900px) {
  .cloud-auth { order: 4; width: 100%; max-width: none; }
  .site-nav-link { order: 2; }
}

/* ===== One-screen layout (no page / keyboard scroll) ===== */
html, body {
  height: 100%;
  overflow: hidden;
}
body {
  min-height: 100dvh;
}
.app-shell.trainer {
  width: min(1240px, calc(100% - 24px));
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  padding: 0 0 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.app-shell.trainer .topbar {
  min-height: 52px;
  flex-shrink: 0;
  padding: 4px 0;
  gap: 10px;
}
.app-shell.trainer .brand-mark { width: 32px; height: 32px; font-size: 18px; }
.app-shell.trainer .brand strong { font-size: 13px; }
.app-shell.trainer .brand small { font-size: 8px; margin-top: 1px; }
.app-shell.trainer .round-count strong { font-size: 20px; }
.app-shell.trainer .mode-nav {
  margin: 6px 0 4px;
  padding: 4px;
  flex-shrink: 0;
  flex-wrap: wrap;
  overflow-x: hidden;
}
.app-shell.trainer .mode-nav-btn {
  min-height: 28px;
  padding: 0 10px;
  font-size: 11px;
}
.app-shell.trainer .mode-panel-wrap {
  margin: 4px 0 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.app-shell.trainer .mode-panel {
  padding: 12px 16px 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.app-shell.trainer .mode-hero { padding: 2px 0 6px; }
.app-shell.trainer .prompt-card {
  min-width: 88px;
  min-height: 72px;
  font-size: 40px;
  border-width: 4px;
  border-radius: 18px;
  padding: 8px 16px;
}
.app-shell.trainer .prompt-card.chord {
  min-width: 120px;
  font-size: 36px;
  border-radius: 16px;
}
.app-shell.trainer .keyboard-section {
  flex-shrink: 0;
  padding: 10px 14px 8px;
  border-radius: 14px;
}
.app-shell.trainer .section-heading {
  margin-bottom: 8px;
  align-items: center;
}
.app-shell.trainer .section-heading h1 {
  font-size: 16px;
}
.app-shell.trainer .section-kicker { font-size: 10px; }
.app-shell.trainer .keyboard-scroll {
  overflow-x: hidden;
  overflow-y: hidden;
  padding: 4px 0 6px;
}
.app-shell.trainer .piano-keyboard {
  width: 100%;
  max-width: 100%;
  --white-key-w: calc(100% / 28);
  --white-key-h: clamp(72px, 16vh, 140px);
  --black-key-w: calc(var(--white-key-w) * 0.62);
  --black-key-h: calc(var(--white-key-h) * 0.72);
  height: var(--white-key-h);
}
.app-shell.trainer .piano-key.white {
  width: auto;
  flex: 1 1 0;
  min-width: 0;
}
.app-shell.trainer .piano-key.white .key-label {
  margin-bottom: 4px;
  font-size: 9px;
}
.app-shell.trainer .keyboard-hint,
.app-shell.trainer footer {
  display: none;
}
@media (max-height: 720px) {
  .app-shell.trainer .prompt-card { min-height: 56px; font-size: 32px; }
  .app-shell.trainer .prompt-card.chord { font-size: 28px; }
  .app-shell.trainer .piano-keyboard { --white-key-h: clamp(64px, 14vh, 110px); }
}


/* Sibling site switch (piano ↔ bass) */
.brand-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.sibling-site {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 10px 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.65);
  color: var(--green-dark);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.sibling-site:hover {
  background: var(--green);
  color: var(--card);
  border-color: var(--green);
}
.sibling-icon {
  font-size: 16px;
  line-height: 1;
}
.sibling-label { white-space: nowrap; }
.app-shell.trainer .sibling-site {
  min-height: 28px;
  padding: 0 8px 0 6px;
  font-size: 11px;
}
.app-shell.trainer .sibling-icon { font-size: 14px; }


/* ===== Auth gate (login required) ===== */
.auth-lock-banner {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 14px;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(233, 107, 58, 0.16), rgba(214, 240, 110, 0.22));
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
}
.auth-lock-banner[hidden] { display: none !important; }
.auth-lock-banner strong {
  color: var(--orange);
  font-size: 14px;
  letter-spacing: 0.02em;
}
.auth-lock-banner span { color: var(--muted); }

body.auth-locked .mode-nav,
body.auth-locked .mode-panel-wrap,
body.auth-locked .keyboard-section,
body.auth-locked .round-count {
  pointer-events: none;
  user-select: none;
  opacity: 0.42;
  filter: grayscale(0.25);
}
body.auth-locked .midi-bar {
  /* MIDI connect stays usable for setup, but practice scoring is gated in JS */
  opacity: 0.85;
}

/* ===== Global metronome (floating bar) ===== */
.global-metro {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 12px;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(49, 38, 25, 0.12);
  backdrop-filter: blur(8px);
  font-size: 12px;
  pointer-events: auto;
}
.global-metro-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cfc6b8;
  box-shadow: none;
  flex-shrink: 0;
  transition: background 80ms ease, box-shadow 80ms ease, transform 80ms ease;
}
.global-metro.is-running .global-metro-pulse {
  background: var(--green);
}
.global-metro-pulse.on {
  transform: scale(1.25);
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(233, 107, 58, 0.18);
}
.global-metro-pulse.on.accent {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(40, 95, 75, 0.2);
}
.global-metro-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.global-metro-field input,
.global-metro-field select {
  width: auto;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #ddd6cb;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  outline: none;
}
.global-metro-bpm { width: 58px; font-variant-numeric: tabular-nums; }
.global-metro-sig { width: 64px; cursor: pointer; }
.global-metro-field input:focus-visible,
.global-metro-field select:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}
.global-metro-toggle {
  min-width: 56px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
}
.global-metro.is-paused-for-practice .global-metro-toggle {
  opacity: 0.85;
}
@media (max-width: 640px) {
  .global-metro {
    right: 8px;
    left: 8px;
    bottom: 8px;
    justify-content: center;
    border-radius: 14px;
    gap: 8px;
    flex-wrap: wrap;
  }
}
