:root {
  --bg: #0e1117;
  --panel: #161b24;
  --panel-2: #1d2531;
  --line: #2a3340;
  --text: #e6edf3;
  --muted: #8a97a8;
  --accent: #4ea1ff;
  --accent-2: #2f7fe0;
  --good: #46d39a;
  --target: #46d39a;
  --root: #1fae7c;
  --scale: #3a5a73;
  --tension: #f0a14b;
  --live: #4ea1ff;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #18222f 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  min-height: 100vh;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
  background: rgba(13,17,23,.7); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 22px; color: var(--accent); }
.brand h1 { font-size: 18px; margin: 0; letter-spacing: .3px; }
.tabs { display: flex; gap: 6px; }
.tab {
  background: transparent; color: var(--muted); border: 1px solid transparent;
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 14px;
}
.tab:hover { color: var(--text); }
.tab.active { color: #fff; background: var(--panel-2); border-color: var(--line); }
.midi { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #50606f; box-shadow: 0 0 0 3px rgba(80,96,111,.15); }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px rgba(70,211,154,.18); }

/* ---------- layout ---------- */
main { max-width: 980px; margin: 0 auto; padding: 22px 18px 60px; }
.panel { display: none; }
.panel.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px;
}
.controls label { display: inline-flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.controls .inline { display: inline-flex; gap: 14px; align-items: center; }
.controls .chk { flex-direction: row; align-items: center; gap: 7px; color: var(--text); font-size: 13px; }
select, input[type=range] { accent-color: var(--accent); }
select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 9px; font-size: 14px; min-width: 80px;
}
input[type=range] { width: 130px; }
.val { color: var(--text); font-size: 13px; }

button { font: inherit; cursor: pointer; }
.primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #fff;
  border: none; padding: 11px 22px; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow); }
.primary:hover { filter: brightness(1.07); }
.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; }
.ghost:hover { border-color: var(--accent); }
.ghost:disabled { opacity: .4; cursor: not-allowed; }
.mini { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); padding: 6px 12px; border-radius: 8px; font-size: 13px; }
.mini:hover { border-color: var(--accent); }
.hidden { display: none !important; }

/* ---------- trainer stage ---------- */
.stage { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.chord-display { display: flex; align-items: center; justify-content: center; gap: 36px; min-height: 150px; }
.now { text-align: center; }
.now-label, .next-label { color: var(--muted); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; }
.chord-name { font-size: 84px; font-weight: 700; line-height: 1; letter-spacing: -1px; }
.chord-next { font-size: 40px; font-weight: 600; color: var(--muted); }
.next { text-align: center; opacity: .9; padding-left: 30px; border-left: 1px solid var(--line); }
.feedback { height: 22px; color: var(--muted); font-size: 14px; margin-top: 8px; }
.feedback.good { color: var(--good); font-weight: 600; }
.buttons { display: flex; gap: 10px; justify-content: center; margin: 18px 0 8px; flex-wrap: wrap; }
.stats { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 12px; text-align: center; margin: 12px 0 0; }

/* ---------- piano keyboard (SVG) ---------- */
.keyboard-wrap { width: 100%; overflow-x: auto; padding: 6px 0; }
.piano { width: 100%; height: auto; max-height: 175px; display: block; }
.key { stroke: #0a0d12; stroke-width: 1; cursor: pointer; }
.key.white { fill: #f3f6fa; }
.key.black { fill: #20262f; }
.key.white:hover { fill: #e3edf7; }
.key.black:hover { fill: #2c3543; }
.key.hl-scale { fill: var(--scale); }
.key.hl-tension { fill: var(--tension); }
.key.hl-target { fill: var(--target); }
.key.hl-root { fill: var(--root); }
.key.hl-live { fill: var(--live); }
.key-label { fill: #93a1b0; font-size: 9px; pointer-events: none; font-family: system-ui, sans-serif; }

/* ---------- progressions ---------- */
.why { color: var(--muted); font-size: 13px; text-align: center; margin: 12px 0; font-style: italic; }
.cards { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 8px 0 18px; }
.card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 18px; min-width: 92px; text-align: center; cursor: pointer; transition: .15s;
}
.card:hover { border-color: var(--accent); }
.card.current { border-color: var(--accent); background: #223149; box-shadow: 0 0 0 2px rgba(78,161,255,.3); transform: translateY(-2px); }
.card .roman { color: var(--muted); font-size: 12px; letter-spacing: 1px; }
.card .cname { font-size: 24px; font-weight: 700; margin-top: 4px; }

/* ---------- learn ---------- */
.learn-block { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.learn-block h2 { margin: 0 0 6px; font-size: 17px; }
.muted { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.scale-notes { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 14px; }
.chip { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 11px; font-weight: 600; }
.dia-table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.dia-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.dia-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.dia-table tbody tr:hover { background: var(--panel-2); }
.dia-table .rn { color: var(--accent); font-weight: 700; width: 70px; }
.improv-info { color: var(--text); font-size: 14px; margin: 8px 0 12px; }
.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: middle; margin: 0 2px; }
.swatch.chord { background: var(--target); }
.swatch.tension { background: var(--tension); }
.theory-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.card-note { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.card-note h3 { margin: 0 0 8px; font-size: 15px; color: var(--accent); }
.card-note p { margin: 0 0 12px; font-size: 13px; color: #c3cdd9; }
.card-note .mini { margin: 0 6px 6px 0; }

/* ---------- footer ---------- */
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; border-top: 1px solid var(--line); }

@media (max-width: 640px) {
  .chord-name { font-size: 60px; }
  .chord-display { gap: 18px; }
  .next { padding-left: 16px; }
}
