:root {
  --bg: #121316; --bg2: #1a1c21; --panel: rgba(38, 40, 48, .72); --panel-solid: #24262d;
  --line: rgba(255, 255, 255, .08); --text: #ececf1; --muted: #9a9ca8;
  --accent: #6aa8ff; --accent2: #b58cff; --good: #5fd48a; --warn: #ffc25c; --bad: #ff6b72;
  --r: 16px; --r-sm: 10px; --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font); color: var(--text); background: radial-gradient(1200px 700px at 20% -10%, #1f2330 0%, var(--bg) 60%);
  -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; overflow: hidden; user-select: none;
}
button { font: inherit; color: inherit; }
header.titlebar {
  display: flex; align-items: center; gap: 14px; padding: 10px 18px; border-bottom: 1px solid var(--line);
  background: rgba(24, 25, 30, .7); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.lights { display: flex; gap: 7px; } .lights i { width: 12px; height: 12px; border-radius: 50%; display: block; }
.lights i:nth-child(1) { background: #ff5f57; } .lights i:nth-child(2) { background: #febc2e; } .lights i:nth-child(3) { background: #28c840; }
.title { font-weight: 600; letter-spacing: .2px; margin-left: 6px; }
.spacer { flex: 1; }
nav.tabs { display: flex; gap: 4px; padding: 4px; background: rgba(0, 0, 0, .28); border-radius: 12px; flex-wrap: wrap; }
nav.tabs button { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; color: var(--muted); cursor: pointer; transition: .18s; }
nav.tabs button:hover { color: var(--text); }
nav.tabs button.active { background: #3a3d48; color: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
main { flex: 1; min-height: 0; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
h1, h2, h3 { margin: 0 0 8px; font-weight: 600; } h2 { font-size: 20px; } h3 { font-size: 15px; color: var(--muted); font-weight: 500; }
p { color: var(--muted); line-height: 1.5; margin: 6px 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: #2f323c; padding: 8px 16px; border-radius: 999px; cursor: pointer; transition: .15s; }
.btn:hover { background: #3a3e4a; } .btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #7ab4ff, #4e8ef0); border-color: transparent; color: #08111f; font-weight: 600; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn.on { background: #4a4f60; border-color: var(--accent); }
select, input[type=range] { accent-color: var(--accent); }
select { background: #2f323c; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font: inherit; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile { text-align: left; cursor: pointer; border: 1px solid var(--line); border-radius: var(--r); padding: 18px; background: linear-gradient(160deg, #2b2e38, #22242b); transition: .18s; }
.tile:hover { transform: translateY(-3px); border-color: var(--accent); }
.tile .ico { font-size: 28px; } .tile b { display: block; margin: 8px 0 4px; font-size: 16px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #353845; font-size: 12px; color: var(--muted); }
.stat { text-align: center; min-width: 90px; } .stat b { display: block; font-size: 26px; } .stat span { font-size: 12px; color: var(--muted); }
.big { font-size: 56px; font-weight: 700; text-align: center; }
.choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-top: 12px; }
.choice { padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: #2c2f39; cursor: pointer; font-size: 16px; transition: .15s; }
.choice:hover { background: #383c49; } .choice.right { background: #1f5a38; border-color: var(--good); } .choice.wrong { background: #5a2528; border-color: var(--bad); }
.bar { height: 8px; border-radius: 8px; background: #2c2f39; overflow: hidden; } .bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .1s linear; }
.feedback { min-height: 26px; font-weight: 600; } .good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
canvas.stave { width: 100%; background: #f2efe8; border-radius: 14px; display: block; }
canvas.game { width: 100%; background: #14161c; border-radius: 14px; display: block; border: 1px solid var(--line); }
footer.dock {
  display: block; padding: 12px 18px 16px; border-top: 1px solid var(--line); background: rgba(20, 21, 26, .85);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.dock-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.seg { display: flex; background: rgba(0, 0, 0, .3); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 4px 11px; border-radius: 999px; cursor: pointer; font-size: 13px; }
.seg button.active { background: #4a4f60; color: #fff; }
.midi-dot { width: 9px; height: 9px; border-radius: 50%; background: #555; display: inline-block; margin-right: 6px; } .midi-dot.ok { background: var(--good); box-shadow: 0 0 8px var(--good); }

/* Piano */
.piano { width: 100%; }
.piano-keys { position: relative; height: clamp(110px, 17vh, 170px); touch-action: none; }
.key { position: absolute; top: 0; cursor: pointer; transition: background .08s, transform .08s; }
.key.white { height: 100%; background: linear-gradient(180deg, #f6f6f8 0%, #e4e4ea 85%, #cfcfd8 100%); border: 1px solid #9a9aa4; border-top: 0; border-radius: 0 0 8px 8px; box-shadow: inset 0 -4px 6px rgba(0, 0, 0, .12); z-index: 1; }
.key.white span { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; font-size: 10px; color: #777; pointer-events: none; }
.key.black { height: 62%; background: linear-gradient(180deg, #3a3b42, #14151a); border-radius: 0 0 6px 6px; z-index: 2; box-shadow: 0 4px 6px rgba(0, 0, 0, .55), inset 0 -3px 4px rgba(255, 255, 255, .08); }
.key.white.down { background: linear-gradient(180deg, #b8d4ff, #8dbbff); transform: translateY(1px); }
.key.black.down { background: linear-gradient(180deg, #4b7fd0, #254a8c); }
.key.target { box-shadow: inset 0 0 0 3px var(--warn); } .key.hit { background: linear-gradient(180deg, #b6f0cb, #6fdc9a) !important; }
.key.miss { background: linear-gradient(180deg, #ffc4c7, #ff8d93) !important; }
.hidden { display: none !important; }
.legend { font-size: 12px; color: var(--muted); }
@media (max-width: 720px) { .title { display: none; } main { padding: 12px; } }

/* Practice range selector */
.piano { position: relative; }
.range-strip { position: relative; height: 24px; margin-bottom: 6px; border-radius: 9px; background: rgba(255, 255, 255, .05); border: 1px dashed rgba(255, 255, 255, .14); cursor: ew-resize; touch-action: none; display: flex; align-items: center; justify-content: center; }
.range-strip.active { border-style: solid; border-color: rgba(106, 168, 255, .5); }
.range-hint { font-size: 11px; color: var(--muted); pointer-events: none; }
.range-strip.active .range-hint { color: var(--accent); }
.range-frame { position: absolute; top: -2px; bottom: -3px; border: 2px solid var(--accent); border-radius: 12px; background: rgba(106, 168, 255, .07); pointer-events: none; box-shadow: 0 0 18px rgba(106, 168, 255, .25); z-index: 5; }
.key.outside { opacity: .38; filter: saturate(.6); }
.range-strip.active .range-hint { display: none; }

.card h1 { font-size: 20px; line-height: 1.3; }
.card details { border-top: 1px solid var(--line); padding: 9px 0; } .card details summary { cursor: pointer; font-weight: 500; color: var(--text); }
.card details p { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
