/* ---------- tokens ---------- */
:root {
  --bg: #f4f5f9; --bg2: #e9ebf2; --surface: #ffffff; --surface2: #f2f3f8; --line: rgba(20, 24, 40, .09);
  --text: #121521; --muted: #5d6478; --faint: #9aa0b3; --good: #12a874; --bad: #e5484d; --warn: #f5a524;
  --shadow: 0 1px 2px rgba(16, 20, 40, .06), 0 8px 24px rgba(16, 20, 40, .07);
  --wood1: #6b4a32; --wood2: #4a3121; --fret: #c9c2b4; --string: #e6dccb; --inlay: rgba(255, 255, 255, .55);
  --ebony: #24201e; --key-w: #fdfdfd; --key-b: #1b1d26; --key-line: #c9ccd6;
  --accent: #f59e0b; --accent2: #f97316; --accent-ink: #1a1203; --accent-soft: rgba(245, 158, 11, .14);
  --tone: #3b82f6; --tone-ink: #fff;
  --radius: 20px; --tab-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d13; --bg2: #11141c; --surface: #161a24; --surface2: #1d2230; --line: rgba(255, 255, 255, .08);
    --text: #f1f3f9; --muted: #a2a9bd; --faint: #6b7287; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
    --key-w: #e9eaef; --key-line: #9ea3b3; --accent-soft: rgba(245, 158, 11, .16); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d13; --bg2: #11141c; --surface: #161a24; --surface2: #1d2230; --line: rgba(255, 255, 255, .08);
  --text: #f1f3f9; --muted: #a2a9bd; --faint: #6b7287; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  --key-w: #e9eaef; --key-line: #9ea3b3; color-scheme: dark;
}
:root[data-inst="keyboard"] { --accent: #7c6cf6; --accent2: #a855f7; --accent-ink: #fff; --accent-soft: rgba(124, 108, 246, .16); --tone: #f59e0b; --tone-ink: #1a1203; }
:root[data-inst="bass"] { --accent: #14b8a6; --accent2: #06b6d4; --accent-ink: #032420; --accent-soft: rgba(20, 184, 166, .16); --tone: #f472b6; --tone-ink: #fff; }
:root[data-inst="ukulele"] { --accent: #fb7185; --accent2: #f472b6; --accent-ink: #2a0610; --accent-soft: rgba(251, 113, 133, .16); --tone: #22c55e; --tone-ink: #04210f; }
:root[data-inst="violin"] { --accent: #ef4444; --accent2: #f59e0b; --accent-ink: #fff; --accent-soft: rgba(239, 68, 68, .14); --tone: #38bdf8; --tone-ink: #04202d; }

/* ---------- base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; touch-action: manipulation; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
select, input { font: inherit; color: inherit; }
svg { display: block; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.grow { flex: 1; min-width: 0; }

/* ---------- shell ---------- */
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; position: relative; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.brand-icon {
  width: 38px; height: 38px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--accent-ink); box-shadow: 0 6px 18px var(--accent-soft);
}
.brand-icon svg { width: 22px; height: 22px; }
.brand { min-width: 0; flex: 1; }
.brand h1 { font-size: 17px; line-height: 1.15; margin: 0; font-weight: 750; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow); flex: none; }
.icon-btn svg { width: 21px; height: 21px; }
.xp-pill { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 99px; background: var(--surface); box-shadow: var(--shadow); font-weight: 700; font-size: 13px; flex: none; }
.xp-pill svg { width: 16px; height: 16px; color: var(--accent); }

main { padding: 8px 16px calc(var(--tab-h) + 96px + var(--safe-b)); }
.view { display: none; animation: fadeIn .28s ease; }
.view.on { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center;
  padding: 6px 8px calc(6px + var(--safe-b)); background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.8) blur(20px); backdrop-filter: saturate(1.8) blur(20px); border-top: 1px solid var(--line);
}
.tabbar .inner { display: flex; width: 100%; max-width: 560px; }
.tab { flex: 1; min-width: 0; height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 16px; color: var(--faint); font-size: 11px; font-weight: 650; transition: color .2s; position: relative; }
.tab svg { width: 24px; height: 24px; transition: transform .25s cubic-bezier(.3, 1.6, .5, 1); }
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.tab.on { color: var(--accent); }
.tab.on svg { transform: translateY(-1px) scale(1.08); }
.tab.on::before { content: ""; position: absolute; top: 2px; width: 34px; height: 4px; border-radius: 4px; background: var(--accent); opacity: .9; }
.tab .dot { position: absolute; top: 9px; right: calc(50% - 18px); width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 2px var(--surface); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; border: 1px solid var(--line); }
.card + .card, .card + .section, .section + .card { margin-top: 14px; }
.card.flat { box-shadow: none; }
.card.hero { background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--accent) 26%, var(--surface)) 0%, var(--surface) 60%); }
.section { margin-top: 22px; }
.section-title { font-size: 13px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 4px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h2 { font-size: 22px; line-height: 1.2; letter-spacing: -.02em; margin: 0; font-weight: 780; }
h3 { font-size: 17px; margin: 0; font-weight: 720; letter-spacing: -.01em; }
.label { font-size: 12.5px; color: var(--muted); font-weight: 650; margin-bottom: 8px; display: block; }

/* ---------- controls ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; scroll-snap-type: x proximity; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip { flex: none; height: 38px; padding: 0 14px; border-radius: 99px; background: var(--surface2); color: var(--text); font-weight: 650; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); transition: background .15s, color .15s, transform .1s; scroll-snap-align: start; white-space: nowrap; }
.chip:active { transform: scale(.96); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 4px 14px var(--accent-soft); }
.chip.key { min-width: 46px; justify-content: center; padding: 0 10px; }
.seg { display: flex; background: var(--surface2); border-radius: 14px; padding: 4px; gap: 4px; border: 1px solid var(--line); }
.seg button { flex: 1; min-width: 0; height: 38px; border-radius: 10px; font-weight: 680; font-size: 14px; color: var(--muted); transition: all .18s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 4px 10px rgba(0, 0, 0, .06); }
.seg.big button { height: 44px; font-size: 15px; }
.btn { height: 52px; border-radius: 16px; padding: 0 22px; font-weight: 750; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--accent-ink); box-shadow: 0 8px 22px var(--accent-soft); transition: transform .12s, filter .2s; }
.btn:active { transform: scale(.97); }
.btn svg { width: 20px; height: 20px; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface2); color: var(--text); box-shadow: none; border: 1px solid var(--line); }
.btn.sm { height: 40px; border-radius: 12px; padding: 0 14px; font-size: 14px; }
.btn.danger { background: color-mix(in srgb, var(--bad) 14%, var(--surface)); color: var(--bad); box-shadow: none; }
.play-fab { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--accent-ink); box-shadow: 0 12px 30px var(--accent-soft), inset 0 -3px 0 rgba(0, 0, 0, .12); transition: transform .15s; flex: none; position: relative; }
.play-fab svg { width: 32px; height: 32px; }
.play-fab:active { transform: scale(.94); }
.play-fab.live::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--accent); animation: ring 1.4s ease-out infinite; }
@keyframes ring { from { transform: scale(.9); opacity: .9; } to { transform: scale(1.25); opacity: 0; } }
select.select { appearance: none; -webkit-appearance: none; width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23888' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center; padding: 0 36px 0 14px; font-weight: 600; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 36px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: linear-gradient(90deg, var(--accent) var(--p, 50%), var(--surface2) var(--p, 50%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; margin-top: -10px; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .3); border: 0; }
input[type=range]::-moz-range-track { height: 6px; border-radius: 6px; background: var(--surface2); }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 8px rgba(0, 0, 0, .3); }
.switch { width: 50px; height: 30px; border-radius: 99px; background: var(--surface2); border: 1px solid var(--line); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); transition: transform .22s cubic-bezier(.3, 1.4, .5, 1); }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(20px); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.toggle-row + .toggle-row { border-top: 1px solid var(--line); }
.mix { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mix button { height: 64px; border-radius: 14px; background: var(--surface2); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); min-width: 0; }
.mix button svg { width: 22px; height: 22px; }
.mix button.on { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.mix button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }

/* ---------- today ---------- */
.hello { display: flex; align-items: center; gap: 14px; }
.hello .ring { width: 74px; height: 74px; flex: none; position: relative; }
.hello .ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; font-weight: 800; }
.hello .ring small { position: absolute; bottom: 11px; left: 0; right: 0; text-align: center; font-size: 9.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.streak-badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 15px; color: var(--accent); }
.streak-badge svg { width: 18px; height: 18px; }
.xpbar { height: 8px; border-radius: 8px; background: var(--surface2); overflow: hidden; margin-top: 8px; }
.xpbar i { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.steps { list-style: none; margin: 0; padding: 0; }
.step { display: flex; gap: 12px; align-items: center; padding: 12px 0; }
.step + .step { border-top: 1px solid var(--line); }
.step .ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.step .ico svg { width: 22px; height: 22px; }
.step .txt { flex: 1; min-width: 0; }
.step .txt b { display: block; font-size: 15px; }
.step .txt span { display: block; font-size: 13px; color: var(--muted); line-height: 1.35; }
.step .mins { font-size: 12px; color: var(--faint); font-weight: 700; }
.step.done .ico { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.step.done .txt b { text-decoration: line-through; text-decoration-color: var(--faint); color: var(--muted); }
.step .go { height: 38px; padding: 0 14px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--line); font-weight: 700; font-size: 13.5px; flex: none; }
.step .chk { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; color: transparent; }
.step.done .chk { background: var(--good); border-color: var(--good); color: #fff; }
.step .chk svg { width: 18px; height: 18px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.stat b { display: block; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.stat span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.heat .d { aspect-ratio: 1; border-radius: 8px; background: var(--surface2); display: grid; place-items: center; font-size: 11px; color: var(--faint); font-weight: 650; }
.heat .d.l1 { background: color-mix(in srgb, var(--accent) 30%, var(--surface2)); color: var(--text); }
.heat .d.l2 { background: color-mix(in srgb, var(--accent) 60%, var(--surface2)); color: var(--accent-ink); }
.heat .d.l3 { background: var(--accent); color: var(--accent-ink); }
.heat .d.today { outline: 2px solid var(--text); outline-offset: 1px; }
.heat .h { font-size: 11px; color: var(--faint); text-align: center; font-weight: 700; }
.legend { display: flex; align-items: center; gap: 5px; justify-content: flex-end; font-size: 11px; color: var(--faint); margin-top: 10px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--surface2); display: inline-block; }
.legend i.l1 { background: color-mix(in srgb, var(--accent) 30%, var(--surface2)); }
.legend i.l2 { background: color-mix(in srgb, var(--accent) 60%, var(--surface2)); }
.legend i.l3 { background: var(--accent); }
.footer { text-align: center; color: var(--faint); font-size: 12px; margin: 26px 0 8px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--warn) 14%, var(--surface)); font-size: 13px; color: var(--text); }
.notice svg { width: 18px; height: 18px; flex: none; color: var(--warn); margin-top: 1px; }

/* ---------- ear ---------- */
.ear-stage { text-align: center; padding: 22px 16px 18px; }
.ear-stage .play-fab { margin: 6px auto 14px; width: 96px; height: 96px; }
.ear-stage .play-fab svg { width: 40px; height: 40px; }
.ear-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 750; font-size: 14px; }
.ear-top .flame { color: var(--accent); display: inline-flex; gap: 4px; align-items: center; }
.ear-top .flame svg { width: 17px; height: 17px; }
.progress { height: 6px; border-radius: 6px; background: var(--surface2); overflow: hidden; margin: 12px 0 4px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 6px; transition: width .4s; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt { min-height: 58px; border-radius: 16px; background: var(--surface); border: 1.5px solid var(--line); box-shadow: var(--shadow); font-weight: 700; font-size: 15px; padding: 8px 10px; line-height: 1.2; transition: transform .1s, background .2s, border-color .2s; word-break: break-word; }
.opt:active { transform: scale(.97); }
.opt.ok { background: color-mix(in srgb, var(--good) 16%, var(--surface)); border-color: var(--good); color: var(--good); animation: pop .35s; }
.opt.no { background: color-mix(in srgb, var(--bad) 13%, var(--surface)); border-color: var(--bad); color: var(--bad); animation: shake .4s; }
.opt.dim { opacity: .55; }
.opt.wide { grid-column: 1 / -1; }
@keyframes pop { 40% { transform: scale(1.05); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.feedback { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; font-weight: 700; }
.feedback.ok { background: color-mix(in srgb, var(--good) 14%, var(--surface)); color: var(--good); }
.feedback.no { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); color: var(--bad); }
.feedback svg { width: 22px; height: 22px; flex: none; }
.big-score { font-size: 56px; font-weight: 850; letter-spacing: -.03em; line-height: 1; }
.xp-float { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); font-size: 28px; font-weight: 850; color: var(--accent); pointer-events: none; animation: floatUp 1s ease forwards; z-index: 60; text-shadow: 0 4px 18px var(--accent-soft); }
@keyframes floatUp { from { opacity: 0; transform: translate(-50%, 10px) scale(.8); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } to { opacity: 0; transform: translate(-50%, -60px) scale(1); } }

/* ---------- jam ---------- */
.stage { position: relative; overflow: hidden; padding: 18px 16px; background: linear-gradient(150deg, color-mix(in srgb, var(--accent) 22%, var(--surface)) 0%, var(--surface) 70%); }
.stage .now { font-size: 64px; font-weight: 850; letter-spacing: -.04em; line-height: 1; margin: 6px 0 4px; min-height: 64px; }
.stage .roman { font-size: 15px; font-weight: 750; color: var(--muted); }
.stage .nextc { font-size: 14px; color: var(--muted); font-weight: 650; }
.stage .nextc b { color: var(--text); font-size: 18px; }
.beats { display: flex; gap: 8px; margin-top: 14px; }
.beats i { flex: 1; height: 8px; border-radius: 8px; background: var(--surface2); transition: background .08s; }
.beats i.on { background: var(--accent); }
.beats i.on.first { background: var(--accent2); }
.prog-strip { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-top: 14px; padding-bottom: 2px; }
.prog-strip::-webkit-scrollbar { display: none; }
.prog-strip span { flex: none; min-width: 48px; height: 34px; padding: 0 10px; border-radius: 10px; background: color-mix(in srgb, var(--surface2) 80%, transparent); display: grid; place-items: center; font-weight: 750; font-size: 13.5px; color: var(--muted); border: 1px solid var(--line); }
.prog-strip span.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.custom-prog { min-height: 46px; display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border-radius: 14px; background: var(--surface2); border: 1px dashed var(--line); }
.custom-prog span { height: 30px; padding: 0 10px; border-radius: 9px; background: var(--surface); display: grid; place-items: center; font-weight: 750; font-size: 13px; }
.style-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.style-grid .chip { justify-content: center; height: 44px; border-radius: 14px; padding: 0 6px; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }
.tempo-row { display: flex; align-items: center; gap: 12px; }
.tempo-row b { font-size: 26px; font-weight: 820; min-width: 52px; text-align: right; }
.sticky-play { position: fixed; right: max(16px, calc(50% - 264px)); bottom: calc(var(--tab-h) + 18px + var(--safe-b)); z-index: 25; }

/* ---------- diagrams ---------- */
.diagram { width: 100%; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.diagram text { font-family: inherit; font-weight: 750; pointer-events: none; }
.fb-wrap { border-radius: 16px; overflow: hidden; background: linear-gradient(180deg, var(--wood1), var(--wood2)); padding: 4px 0; }
.fb-wrap.violin { background: linear-gradient(180deg, #2f2a27, var(--ebony)); }
.mk circle { transition: transform .15s; transform-box: fill-box; transform-origin: center; }
.mk.root circle { fill: var(--accent); stroke: rgba(0, 0, 0, .25); }
.mk.root text { fill: var(--accent-ink); }
.mk.tone circle { fill: var(--tone); stroke: rgba(0, 0, 0, .2); }
.mk.tone text { fill: var(--tone-ink); }
.mk.scale circle { fill: #f6f1e7; stroke: rgba(0, 0, 0, .25); }
.mk.scale text { fill: #2a2118; }
.mk.faint circle { fill: rgba(255, 255, 255, .14); stroke: none; }
.mk.faint text { fill: rgba(255, 255, 255, .75); font-weight: 600; }
.mk.hl circle { animation: hit .5s ease; }
@keyframes hit { 30% { transform: scale(1.35); } }
.piano-wrap { overflow-x: auto; border-radius: 14px; background: var(--key-b); padding: 6px 6px 8px; scrollbar-width: thin; }
.piano .w { fill: var(--key-w); stroke: var(--key-line); }
.piano .b { fill: var(--key-b); stroke: #000; }
.piano .w.root, .piano .b.root { fill: var(--accent); }
.piano .w.tone, .piano .b.tone { fill: var(--tone); }
.piano .w.scale { fill: color-mix(in srgb, var(--accent) 38%, var(--key-w)); }
.piano .b.scale { fill: color-mix(in srgb, var(--accent) 55%, var(--key-b)); }
.piano .w.down, .piano .b.down { filter: brightness(.85); }
.piano text { font-size: 11px; }
.piano text.on-w { fill: #333; }
.piano text.on-b { fill: #fff; }
.piano text.on-root { fill: var(--accent-ink); }
.piano text.on-tone { fill: var(--tone-ink); }
.chart text { fill: var(--text); }
.chart .grid { stroke: var(--muted); }
.chart .nut { fill: var(--text); }
.chart .dot { fill: var(--text); }
.chart .dot.root { fill: var(--accent); }
.chart .lbl { fill: var(--surface); font-size: 10px; }
.chart .lbl.root { fill: var(--accent-ink); }
.voicings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vcard { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 10px 8px 8px; text-align: center; box-shadow: var(--shadow); transition: transform .1s; min-width: 0; }
.vcard:active { transform: scale(.97); }
.vcard .cap { font-size: 12px; color: var(--muted); font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 2px; }
.vcard .cap svg { width: 14px; height: 14px; color: var(--accent); }
.vcard.wide { grid-column: 1 / -1; }
.info-row { display: flex; gap: 8px; flex-wrap: wrap; }
.info-row .pill { padding: 6px 10px; border-radius: 10px; background: var(--surface2); font-weight: 700; font-size: 13.5px; }
.info-row .pill.r { background: var(--accent); color: var(--accent-ink); }
.title-big { font-size: 40px; font-weight: 850; letter-spacing: -.03em; line-height: 1; }
.legend-dots { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); font-weight: 650; }
.legend-dots i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

/* ---------- tools ---------- */
.tuner-note { font-size: 86px; font-weight: 850; letter-spacing: -.04em; line-height: 1; text-align: center; min-height: 86px; transition: color .2s; }
.tuner-note.ok { color: var(--good); }
.tuner-hz { text-align: center; color: var(--muted); font-weight: 650; min-height: 22px; }
.gauge { width: 100%; max-width: 360px; margin: 0 auto; }
.gauge .tick { stroke: var(--faint); }
.gauge .tick.mid { stroke: var(--good); }
.gauge .needle { stroke: var(--text); transition: transform .12s linear; transform-origin: 160px 170px; }
.gauge .zone { fill: color-mix(in srgb, var(--good) 18%, transparent); }
.tuner-status { text-align: center; font-weight: 750; min-height: 24px; }
.tuner-status.ok { color: var(--good); }
.tuner-status.off { color: var(--warn); }
.strings { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.strings .chip { min-width: 52px; justify-content: center; }
.strings .chip.near { outline: 2px solid var(--good); outline-offset: 1px; }
.bpm-big { font-size: 78px; font-weight: 850; letter-spacing: -.04em; line-height: 1; text-align: center; }
.tempo-name { text-align: center; color: var(--muted); font-weight: 650; font-style: italic; }
.metro-dots { display: flex; justify-content: center; gap: 10px; margin: 16px 0; flex-wrap: wrap; }
.metro-dots i { width: 22px; height: 22px; border-radius: 50%; background: var(--surface2); border: 1px solid var(--line); transition: transform .08s, background .08s; }
.metro-dots i.acc { width: 26px; height: 26px; }
.metro-dots i.on { background: var(--accent); transform: scale(1.18); border-color: transparent; }
.metro-dots i.on.acc { background: var(--accent2); }
.round-btn { width: 56px; height: 56px; border-radius: 18px; background: var(--surface2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 26px; font-weight: 700; flex: none; }
.round-btn:active { transform: scale(.95); }

/* ---------- overlays ---------- */
.toast-host { position: fixed; left: 0; right: 0; top: calc(12px + var(--safe-t)); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-weight: 700; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: toastIn .3s cubic-bezier(.2, 1.2, .4, 1); max-width: 100%; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px) scale(.96); } }
.scrim { position: fixed; inset: 0; background: rgba(5, 7, 12, .5); z-index: 70; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 71; max-width: 560px; margin: 0 auto; background: var(--surface); border-radius: 26px 26px 0 0; padding: 10px 16px calc(20px + var(--safe-b)); max-height: 88vh; overflow-y: auto; animation: up .32s cubic-bezier(.2, .9, .3, 1); box-shadow: 0 -10px 40px rgba(0, 0, 0, .3); }
@keyframes up { from { transform: translateY(100%); } }
.sheet .grab { width: 40px; height: 5px; border-radius: 5px; background: var(--line); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.timer-pill { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + 18px + var(--safe-b)); z-index: 26; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 99px; background: var(--text); color: var(--bg); box-shadow: 0 10px 30px rgba(0, 0, 0, .3); font-weight: 750; font-size: 14px; max-width: calc(100% - 120px); animation: toastIn .3s; }
.timer-pill .t { font-variant-numeric: tabular-nums; }
.timer-pill .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.timer-pill button { height: 34px; padding: 0 12px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 13px; flex: none; }
.np-pill { position: fixed; left: 16px; bottom: calc(var(--tab-h) + 18px + var(--safe-b)); z-index: 26; height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 14px 0 10px; border-radius: 99px; background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); font-weight: 750; font-size: 13px; }
.np-pill svg { width: 20px; height: 20px; color: var(--accent); }
.eq-anim { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.eq-anim i { width: 3px; background: var(--accent); border-radius: 2px; animation: eq 0.9s ease-in-out infinite; }
.eq-anim i:nth-child(2) { animation-delay: .2s; } .eq-anim i:nth-child(3) { animation-delay: .4s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
@media (min-width: 600px) { main { padding-left: 20px; padding-right: 20px; } }
