/* =========================================================================
   TM Trainer — Design System v6
   RTL-first · light/dark · single accent (gold) on deep navy
   ========================================================================= */

/* ---------- 0. Fonts (self-hosted, no CDN) ---------- */
@font-face {
  font-family: Vazirmatn;
  src: url("/assets/fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("/assets/fonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("/assets/fonts/Vazirmatn-SemiBold.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("/assets/fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("/assets/fonts/Vazirmatn-ExtraBold.woff2") format("woff2");
  font-weight: 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("/assets/fonts/Vazirmatn-Black.woff2") format("woff2");
  font-weight: 900; font-style: normal; font-display: swap;
}

/* ---------- 1. Tokens ---------- */
:root {
  color-scheme: light;

  --bg:            #eef1f7;
  --bg-2:          #e6eaf3;
  --surface:       #ffffff;
  --surface-2:     #f5f7fc;
  --surface-3:     #e9edf6;
  --line:          #e0e5f0;
  --line-2:        #ccd4e4;

  --ink:           #0b1730;
  --ink-2:         #34435e;
  --ink-3:         #6c7c96;

  --primary:       #021e4e;
  --primary-2:     #0a3475;
  --primary-ink:   #ffffff;
  --primary-soft:  #e8eefa;

  --gold:          #f5c518;
  --gold-ink:      #4a3a00;
  --gold-soft:     #fff8dd;

  --teal:          #0f766e;
  --teal-soft:     #e3f5f2;
  --red:           #cf2e2e;
  --red-soft:      #fdeaea;

  --shadow-s: 0 1px 2px rgba(11, 23, 48, .06), 0 1px 1px rgba(11, 23, 48, .04);
  --shadow-m: 0 6px 18px -6px rgba(11, 23, 48, .16), 0 2px 6px -2px rgba(11, 23, 48, .08);
  --shadow-l: 0 24px 48px -18px rgba(11, 23, 48, .28), 0 8px 18px -10px rgba(11, 23, 48, .16);

  --r-s: 8px;
  --r-m: 12px;
  --r-l: 18px;
  --r-xl: 24px;

  --font: 'Vazirmatn', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;

  --hud-bg: linear-gradient(150deg, #062a63 0%, #02183c 55%, #010e26 100%);
  --hud-ink: #eaf1ff;
  --hud-muted: #9db4d8;

  --header-h: 62px;
  --dock-h: 78px;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg:            #060a13;
  --bg-2:          #0a1120;
  --surface:       #0d1526;
  --surface-2:     #121c31;
  --surface-3:     #18233b;
  --line:          #1d2942;
  --line-2:        #2a3a5a;

  --ink:           #e9effb;
  --ink-2:         #b7c4da;
  --ink-3:         #7c8aa5;

  --primary:       #f5c518;
  --primary-2:     #ffd94d;
  --primary-ink:   #1d1700;
  --primary-soft:  #241d00;

  --gold:          #f5c518;
  --gold-ink:      #1d1700;
  --gold-soft:     #241d00;

  --teal:          #2dd4bf;
  --teal-soft:     #062a26;
  --red:           #f87171;
  --red-soft:      #2b1111;

  --shadow-s: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-m: 0 8px 22px -8px rgba(0, 0, 0, .7), 0 2px 6px -2px rgba(0, 0, 0, .5);
  --shadow-l: 0 28px 60px -24px rgba(0, 0, 0, .85);

  --hud-bg: linear-gradient(150deg, #16233d 0%, #0b1425 60%, #070d18 100%);
  --hud-ink: #eef4ff;
  --hud-muted: #93a6c4;
}

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html, body { min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.65;
  padding-bottom: calc(var(--dock-h) + 18px + env(safe-area-inset-bottom, 0px));
  background-image:
    radial-gradient(1100px 520px at 88% -10%, color-mix(in srgb, var(--gold) 10%, transparent), transparent 62%),
    radial-gradient(900px 460px at 4% 0%, color-mix(in srgb, var(--primary) 8%, transparent), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: var(--primary-2); text-decoration-color: color-mix(in srgb, var(--primary-2) 40%, transparent); }
a:hover { text-decoration-color: currentColor; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
::selection { background: color-mix(in srgb, var(--gold) 45%, transparent); }

.numeric { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.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;
}
.hidden { display: none !important; }

/* ---------- 3. App bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--header-h);
  display: flex; align-items: center;
  gap: 14px;
  padding: 0 clamp(12px, 3vw, 26px);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  overflow: hidden;
  box-shadow: 0 3px 10px -2px rgba(2, 30, 78, .45), inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name {
  font-size: 15px; font-weight: 800; letter-spacing: -.2px; color: var(--ink);
  white-space: nowrap;
}
.brand-name span { color: var(--gold); -webkit-text-stroke: 0; }
.brand-sub { font-size: 10.5px; color: var(--ink-3); font-weight: 500; letter-spacing: .2px; }

.appbar-spacer { flex: 1 1 auto; }
.appbar-tools { display: flex; align-items: center; gap: 8px; }

/* select control */
.field {
  position: relative; display: inline-flex; align-items: center;
}
.field select {
  appearance: none; -webkit-appearance: none;
  height: 36px;
  padding: 0 12px 0 30px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  max-width: 210px;
  text-overflow: ellipsis;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field select:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--line-2)); }
.field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent); }
.field::after {
  content: ""; position: absolute; left: 11px; top: 50%;
  width: 7px; height: 7px; pointer-events: none;
  border-left: 1.8px solid var(--ink-3); border-bottom: 1.8px solid var(--ink-3);
  transform: translateY(-70%) rotate(-45deg);
}
html[dir="rtl"] .field::after { left: 11px; right: auto; }

.icon-btn {
  width: 36px; height: 36px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink-2);
  transition: background .15s, color .15s, border-color .15s, transform .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-2); }
.icon-btn:active { transform: scale(.95); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------- 4. Layout ---------- */
.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 26px) 8px;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
@media (min-width: 1060px) {
  .layout { grid-template-columns: minmax(0, 1fr) 352px; align-items: start; gap: 18px; }
  .rail { position: sticky; top: calc(var(--header-h) + 16px); }
}
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ---------- 5. Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-s);
  overflow: hidden;
}
.card-hd {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 70%, transparent), transparent);
}
.card-ico {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
}
html[data-theme="dark"] .card-ico { background: color-mix(in srgb, var(--gold) 16%, transparent); }
.card-ico svg { width: 15px; height: 15px; }
.card-ttl { font-size: 13.5px; font-weight: 700; letter-spacing: -.1px; }
.card-hd-end { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.card-bd { padding: 16px; }

.hint { font-size: 11.5px; color: var(--ink-3); line-height: 1.7; }

/* ---------- 6. HUD (now playing) ---------- */
.hud {
  position: relative;
  border-radius: var(--r-l);
  background: var(--hud-bg);
  color: var(--hud-ink);
  box-shadow: var(--shadow-m), inset 0 1px 0 rgba(255, 255, 255, .07);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
}
html[data-theme="dark"] .hud { border-color: #24334f; }
.hud::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(600px 180px at 80% -30%, rgba(245, 197, 24, .22), transparent 70%),
    radial-gradient(400px 200px at 10% 120%, rgba(90, 160, 255, .18), transparent 70%);
  pointer-events: none;
}
.hud-top {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px 10px;
}
.hud-note {
  font-family: var(--mono);
  font-size: 40px; font-weight: 700; letter-spacing: -1.5px;
  line-height: 1; color: var(--gold);
  min-width: 86px;
  text-shadow: 0 2px 24px rgba(245, 197, 24, .35);
  transition: opacity .2s;
}
.hud-note.is-empty { color: var(--hud-muted); opacity: .55; }
.hud-facts { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hud-fact-main {
  font-size: 12.5px; font-weight: 700; color: var(--hud-ink);
  display: flex; align-items: center; gap: 8px;
}
.hud-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .14);
  color: var(--hud-ink);
  white-space: nowrap;
}
.hud-fact-sub { font-size: 11px; color: var(--hud-muted); }

.hud-beat {
  margin-inline-start: auto;
  display: flex; align-items: baseline; gap: 3px;
  font-variant-numeric: tabular-nums;
}
.hud-beat b { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.hud-beat i { font-style: normal; font-size: 13px; color: var(--hud-muted); }
.hud-beat > span { font-size: 13px; font-weight: 700; color: var(--hud-muted); }
.hud-beat small { font-size: 10px; color: var(--hud-muted); margin-inline-start: 6px; }

.hud-neck { position: relative; padding: 0 10px; }
#rt-canvas { width: 100%; height: 108px; display: block; }

.hud-bar { position: relative; height: 3px; background: rgba(255, 255, 255, .12); direction: ltr; }
.hud-bar > div {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold), #ffe89a);
  box-shadow: 0 0 12px rgba(245, 197, 24, .6);
  transition: width .08s linear;
}

/* ---------- 7. Notation ---------- */
.score-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  padding: 10px 0;
  min-height: 240px;
  overflow-x: auto;
  direction: ltr;
  text-align: left;
  color: #0b1730;
  box-shadow: inset 0 0 0 1px rgba(11, 23, 48, .02);
}
.score-panel.is-empty { display: grid; place-items: center; }
.score-empty {
  text-align: center; padding: 28px 16px; color: #5b6a85;
  font-size: 12.5px; line-height: 1.9; direction: rtl;
}
.score-empty b { display: block; font-size: 14px; color: #0b1730; margin-bottom: 6px; }

/* abcjs: always dark ink on paper */
.abcjs-container { direction: ltr; text-align: left; }
.abcjs-container svg { background: #fff !important; }
.abcjs-container svg path,
.abcjs-container svg rect,
.abcjs-container svg line,
.abcjs-container svg polyline,
.abcjs-container svg polygon,
.abcjs-container svg circle,
.abcjs-container svg ellipse {
  stroke: #10151f !important;
  fill: #10151f !important;
  stroke-width: 1.4 !important;
}
.abcjs-container svg line.abcjs-staff,
.abcjs-container svg .staff-line,
.abcjs-container svg .abcjs-bar {
  stroke: #2b3342 !important;
  fill: #2b3342 !important;
  stroke-width: 1.3 !important;
}
.abcjs-container svg text {
  fill: #172033 !important;
  font-family: var(--font) !important;
  font-weight: 600 !important;
}
.abcjs-container svg .abcjs-chord text,
.abcjs-container svg text.abcjs-chord,
.abcjs-container svg g.abcjs-chord text { fill: #a52121 !important; font-weight: 700 !important; }
.abcjs-container svg text.abcjs-title { fill: #0b1730 !important; font-weight: 800 !important; }
.abcjs-container svg .abcjs-clef,
.abcjs-container svg .abcjs-key-signature,
.abcjs-container svg .abcjs-time-signature { fill: #10151f !important; stroke: #10151f !important; }

/* score header extras */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700;
  border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--ink-2);
  white-space: nowrap;
}
.pill.live {
  border-color: color-mix(in srgb, var(--teal) 45%, transparent);
  background: var(--teal-soft); color: var(--teal);
}
.pill.live::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; animation: blink 1.4s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* ---------- 8. Editor ---------- */
.disclosure {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-m);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12.5px; font-weight: 700; color: var(--ink-2);
  transition: background .15s, border-color .15s;
}
.disclosure:hover { background: var(--surface-3); }
.disclosure .chev { transition: transform .2s; }
.disclosure[aria-expanded="true"] .chev { transform: rotate(180deg); }
.disclosure .meta { margin-inline-start: auto; font-size: 11px; font-weight: 600; color: var(--ink-3); }

.editor { margin-top: 10px; display: grid; gap: 10px; }
textarea {
  width: 100%; min-height: 190px;
  direction: ltr; text-align: left;
  font-family: var(--mono); font-size: 12px; line-height: 1.7;
  padding: 12px 14px;
  border-radius: var(--r-m);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--ink);
  resize: vertical;
}
textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }

/* ---------- 9. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px;
  border-radius: 10px;
  font-size: 12.5px; font-weight: 700;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s, transform .1s, box-shadow .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); color: var(--primary-ink); box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset; }
.btn-primary:hover { background: var(--primary-2); }
.btn-ghost { background: var(--surface); border-color: var(--line-2); color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-soft { background: var(--surface-2); border-color: var(--line); color: var(--ink-2); }
.btn-soft:hover { background: var(--surface-3); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 11.5px; border-radius: 8px; }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--red) 16%, var(--surface)); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-3); border-radius: 10px;
}
.seg button {
  height: 28px; padding: 0 10px; border-radius: 8px;
  font-size: 11.5px; font-weight: 700; color: var(--ink-3);
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-s); }

/* ---------- 10. Inputs ---------- */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 24px; background: transparent; cursor: pointer;
  direction: ltr;
  --p: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(to right,
    var(--primary) 0 var(--p),
    color-mix(in srgb, var(--ink-3) 26%, transparent) var(--p) 100%);
}
input[type="range"]::-moz-range-track {
  height: 6px; border-radius: 999px;
  background: color-mix(in srgb, var(--ink-3) 26%, transparent);
}
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--primary); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; margin-top: -6px;
  border-radius: 50%; background: #fff;
  border: 2px solid var(--primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  transition: transform .12s;
}
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.08); }
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 2px solid var(--primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}

/* switch */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: color-mix(in srgb, var(--ink-3) 35%, transparent);
  transition: background .2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 1px solid rgba(11, 23, 48, .12);
  box-shadow: 0 1px 4px rgba(11, 23, 48, .28);
  transition: transform .2s;
}
.switch input:checked + .track { background: var(--teal); }
.switch input:checked + .track::after { transform: translateX(-18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- 11. Tempo ---------- */
.tempo-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.tempo-value { display: flex; align-items: baseline; gap: 5px; }
.tempo-value b {
  font-size: 42px; font-weight: 800; letter-spacing: -2px; line-height: 1;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.tempo-value span { font-size: 11px; font-weight: 700; color: var(--ink-3); letter-spacing: .4px; }
.tempo-tag {
  font-size: 11px; font-weight: 700; color: var(--primary);
  background: var(--primary-soft); padding: 3px 9px; border-radius: 999px;
}
html[data-theme="dark"] .tempo-tag { background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--gold); }

.tempo-scale { display: flex; justify-content: space-between; font-size: 10px; color: var(--ink-3); font-weight: 600; margin-top: -2px; direction: ltr; }
.step-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.step-row button {
  height: 32px; border-radius: 9px; font-size: 11.5px; font-weight: 700;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink-2);
  transition: background .15s, color .15s, border-color .15s;
}
.step-row button:hover { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 35%, transparent); }

/* ---------- 12. Metronome ---------- */
.metro-status { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.metro-state { font-size: 11.5px; font-weight: 700; color: var(--ink-3); }
.metro-state.on { color: var(--teal); }
.dots {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: color-mix(in srgb, var(--ink-3) 30%, transparent);
  transition: transform .1s ease-out, background .12s, box-shadow .12s;
}
.dot.on { background: var(--teal); transform: scale(1.35); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 22%, transparent); }
.dot.on.accent { background: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 28%, transparent); }
.metro-bpm {
  font-size: 11px; font-weight: 800; color: var(--ink-2);
  font-variant-numeric: tabular-nums; margin-inline-start: 2px;
}
.metro-ctrl { display: grid; gap: 10px; padding-top: 12px; border-top: 1px dashed var(--line); }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.check-row input { width: 15px; height: 15px; accent-color: var(--teal); }
.inline-slider { display: flex; align-items: center; gap: 10px; }
.inline-slider output { min-width: 34px; text-align: center; font-size: 12px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- 13. Sound ---------- */
.snd-row { display: grid; gap: 6px; }
.snd-row + .snd-row { margin-top: 14px; }
.snd-label { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; font-weight: 700; color: var(--ink-2); }
.snd-label span { color: var(--ink-3); font-weight: 600; font-variant-numeric: tabular-nums; }
.snd-note { font-size: 10.5px; color: var(--ink-3); margin-top: 8px; line-height: 1.6; }

/* ---------- 14. Record ---------- */
.wave {
  position: relative;
  height: 62px; border-radius: var(--r-m);
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
  margin-bottom: 12px;
}
.wave canvas { width: 100%; height: 100%; display: block; }
.wave-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 10.5px; color: var(--ink-3); text-align: center; padding: 0 12px;
}
.wave-playhead {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--gold); display: none; pointer-events: none;
}
.rec-actions { display: flex; align-items: center; gap: 8px; }
.btn-rec {
  flex: 1 1 auto;
  height: 44px; border-radius: 12px;
  background: var(--red); color: #fff;
  font-size: 13px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--red) 80%, transparent);
}
.btn-rec:hover { filter: brightness(1.06); }
.btn-rec.on { background: #7f1d1d; animation: recpulse 1.4s infinite; }
@keyframes recpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(207, 46, 46, .5); }
  50% { box-shadow: 0 0 0 9px rgba(207, 46, 46, 0); }
}
.rec-timer {
  display: grid; place-items: center;
  min-width: 86px; padding: 0 12px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink);
}
.practice {
  margin-top: 14px; padding: 12px;
  border-radius: var(--r-m);
  border: 1px dashed color-mix(in srgb, var(--gold) 55%, var(--line));
  background: var(--gold-soft);
}
html[data-theme="dark"] .practice { background: color-mix(in srgb, var(--gold) 7%, transparent); }
.practice h4 { font-size: 11.5px; font-weight: 800; color: var(--ink); display: flex; align-items: center; gap: 6px; }
.practice p { font-size: 10.5px; color: var(--ink-3); line-height: 1.7; margin: 4px 0 9px; }
.btn-practice {
  width: 100%; height: 36px; border-radius: 9px;
  background: var(--gold); color: var(--gold-ink);
  font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.btn-practice:hover { filter: brightness(1.04); }
.btn-practice.on { background: #7f1d1d; color: #fff; animation: recpulse 1.4s infinite; }

.rec-list { display: grid; gap: 7px; margin-top: 12px; max-height: 260px; overflow-y: auto; }
.rec-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center; gap: 9px;
  padding: 8px 9px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2);
}
.rec-item .nm { font-size: 11.5px; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-item .mt { font-size: 10px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rec-btns { display: flex; gap: 3px; }
.rec-btns button {
  width: 27px; height: 27px; border-radius: 7px;
  display: grid; place-items: center;
  color: var(--ink-3); border: 1px solid transparent;
  transition: background .15s, color .15s;
}
.rec-btns button:hover { background: var(--surface-3); color: var(--ink); }
.rec-btns button.danger:hover { background: var(--red-soft); color: var(--red); }
.rec-btns button.on { background: var(--primary); color: var(--primary-ink); }
.rec-btns svg { width: 13px; height: 13px; }
.rec-pos { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.rec-pos span { font-size: 9.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty-mini { font-size: 11px; color: var(--ink-3); text-align: center; padding: 14px 6px; }

.cmp {
  display: none; margin-top: 10px; padding: 10px 11px;
  border-radius: 10px; border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--line));
  background: var(--primary-soft); color: var(--ink);
  font-size: 11px; font-weight: 600;
}
.cmp.show { display: block; }
.cmp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cmp select { height: 30px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); padding: 0 8px; font-size: 11px; }

/* ---------- 15. Tabs / help ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 12px; }
.tabs button {
  flex: 1; height: 32px; border-radius: 9px;
  font-size: 12px; font-weight: 700; color: var(--ink-3);
  transition: background .15s, color .15s, box-shadow .15s;
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-s); }
.tabpane { display: none; margin-top: 12px; }
.tabpane.active { display: block; animation: fade .2s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.prose { font-size: 12px; color: var(--ink-2); line-height: 1.85; }
.prose h4 { font-size: 12.5px; font-weight: 800; color: var(--ink); margin: 14px 0 6px; }
.prose h4:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-inline-start: 18px; }
.prose li { margin-bottom: 3px; }
.prose code {
  font-family: var(--mono); font-size: 11px; direction: ltr; display: inline-block;
  background: var(--surface-3); padding: 1px 5px; border-radius: 5px; color: var(--ink);
}
.prose pre {
  font-family: var(--mono); font-size: 11px; direction: ltr; text-align: left;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 12px; border-radius: 10px; overflow-x: auto; margin: 8px 0; line-height: 1.7;
}
.kv { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 11.5px; }
.kv:last-child { border-bottom: 0; }
kbd {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 6px;
  background: var(--surface-3); border: 1px solid var(--line-2);
  border-bottom-width: 2px; color: var(--ink-2); white-space: nowrap;
}
.notice {
  display: flex; gap: 10px; padding: 12px 14px;
  border-radius: var(--r-m);
  background: var(--gold-soft);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--line));
  color: var(--ink-2); font-size: 11.5px; line-height: 1.8;
}
html[data-theme="dark"] .notice { background: color-mix(in srgb, var(--gold) 7%, transparent); }
.notice svg { width: 16px; height: 16px; flex: none; color: color-mix(in srgb, var(--gold) 80%, #8a6a00); margin-top: 2px; }
.notice b { color: var(--ink); }

.foot {
  text-align: center; font-size: 10.5px; color: var(--ink-3);
  padding: 14px 0 4px;
}
.foot b { color: var(--ink-2); font-weight: 700; }

/* ---------- 16. Transport dock ---------- */
.dock {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 70;
  height: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.5) blur(18px);
  -webkit-backdrop-filter: saturate(1.5) blur(18px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 30px -18px rgba(11, 23, 48, .35);
}
.dock-in {
  width: 100%; max-width: 1240px; margin: 0 auto;
  padding: 0 clamp(12px, 3vw, 26px);
  display: flex; align-items: center; gap: 10px;
}
.play-btn {
  width: 52px; height: 52px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary); color: var(--primary-ink);
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--primary) 80%, transparent);
  transition: transform .12s, background .15s;
}
.play-btn:hover { background: var(--primary-2); }
.play-btn:active { transform: scale(.95); }
.play-btn svg { width: 21px; height: 21px; }
.play-btn.playing { background: var(--red); }

.dock-btn {
  width: 40px; height: 40px; flex: none; border-radius: 11px;
  display: grid; place-items: center;
  color: var(--ink-3); border: 1px solid var(--line);
  background: var(--surface);
  transition: background .15s, color .15s, border-color .15s;
}
.dock-btn:hover { color: var(--ink); background: var(--surface-2); }
.dock-btn.active { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 40%, transparent); background: var(--primary-soft); }
.dock-btn svg { width: 17px; height: 17px; }

.dock-progress {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; gap: 3px;
}
.dock-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.dock-meta b { color: var(--ink-2); font-weight: 800; font-size: 12.5px; letter-spacing: .2px; font-variant-numeric: tabular-nums; }
.track { height: 5px; border-radius: 999px; background: color-mix(in srgb, var(--ink-3) 22%, transparent); overflow: hidden; direction: ltr; }
.track > div { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 55%, var(--gold))); transition: width .08s linear; }

.dock-tempo {
  display: flex; align-items: center; gap: 2px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--surface);
  overflow: hidden; flex: none;
}
.dock-tempo button { width: 30px; height: 38px; color: var(--ink-3); display: grid; place-items: center; }
.dock-tempo button svg { width: 15px; height: 15px; }
.dock-tempo button:hover { background: var(--surface-2); color: var(--ink); }
.dock-tempo span {
  min-width: 46px; text-align: center; font-size: 13px; font-weight: 800;
  font-variant-numeric: tabular-nums; color: var(--ink);
}

/* ---------- 17. Toast ---------- */
.toasts {
  position: fixed; inset-inline: 0;
  bottom: calc(var(--dock-h) + 16px + env(safe-area-inset-bottom, 0px));
  z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 12px;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-size: 11.5px; font-weight: 700;
  box-shadow: var(--shadow-l);
  animation: toastIn .22s ease-out;
  max-width: min(92vw, 460px);
}
.toast.err { background: var(--red); color: #fff; }
.toast.ok { background: var(--teal); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

/* ---------- 18. Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  background: color-mix(in srgb, #010817 82%, transparent);
  backdrop-filter: blur(6px);
  padding: 20px; text-align: center;
}
.overlay-card {
  background: var(--surface); border-radius: var(--r-xl);
  padding: 26px 24px; max-width: 340px; width: 100%;
  box-shadow: var(--shadow-l); border: 1px solid var(--line);
}
.overlay h3 { font-size: 15px; font-weight: 800; margin-bottom: 6px; }
.overlay p { font-size: 11.5px; color: var(--ink-3); line-height: 1.8; margin-bottom: 16px; }
.count-num {
  font-size: 88px; font-weight: 900; line-height: 1; letter-spacing: -4px;
  color: var(--gold); font-variant-numeric: tabular-nums;
  margin: 6px 0 10px;
}

/* ---------- 19. Responsive ---------- */
@media (max-width: 760px) {
  :root { --header-h: 56px; --dock-h: 72px; }
  .brand-text { display: none; }
  .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .appbar { gap: 6px; padding: 0 10px; }
  .appbar-tools { gap: 6px; min-width: 0; flex: 1 1 auto; }
  .appbar-tools .field { min-width: 0; flex: 1 1 0; }
  .appbar-tools .field.hide-sm { display: none; }
  .appbar-tools .field select {
    width: 100%; max-width: none; font-size: 11.5px; height: 34px;
    padding-inline-start: 8px; padding-inline-end: 22px;
  }
  .appbar-tools .field::after { left: 9px; width: 6px; height: 6px; }
  .icon-btn { width: 34px; height: 34px; }
  .hud-note { font-size: 32px; min-width: 62px; }
  .hud-beat b { font-size: 21px; }
  #rt-canvas { height: 88px; }
  .card-bd { padding: 13px; }
  .card-hd { padding: 11px 13px; }
  .tempo-value b { font-size: 36px; }
  .dock-tempo, .dock-btn.desktop-only { display: none; }
  .play-btn { width: 48px; height: 48px; }
  .wrap { padding-top: 12px; }
  .tabs button { font-size: 11px; }
  .dock-in { gap: 7px; padding: 0 10px; }
}
@media (max-width: 380px) {
  .hud-fact-sub { display: none; }
  .dock-meta span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
