/* ============================================================
   PIANO OS v5 — os.css
   Terminal-meets-conservatory: dark navy-charcoal panels, backlit
   brass (amber) accents, mono numerals, thin rules, status dots.
   Single contract for all views. No framework, no external fonts.
   Sections:
     1. tokens      6. stats & pills     11. staff / hymns / badges
     2. base        7. tables & tags     12. coach / timeline / ring
     3. app bar     8. forms             13. heatmap
     4. layout      9. modal / toast     14. utilities
     5. cards      10. drills & quiz     15. print + responsive
   ============================================================ */

/* ── 1. TOKENS ───────────────────────────────────────────── */
:root {
  --bg:        #0d1117;   /* deep navy-charcoal */
  --bg2:       #131922;   /* panel */
  --bg3:       #1a2230;   /* elevated */
  --line:      #232c3a;   /* hairline border */
  --line2:     #33405466; /* stronger border (rgb w/ alpha) */
  --text:      #d5dbe6;
  --dim:       #8b94a7;
  --dim2:      #5d6779;
  --amber:     #e8a33d;   /* backlit brass */
  --amber-dim: #8a5f1e;
  --amber-bg:  #171204;
  --green:     #4fbf6e;   /* ready */
  --green-bg:  #0c1a10;
  --red:       #e05252;   /* danger / stopped */
  --red-bg:    #1c0e0e;
  --blue:      #5b9dd9;   /* info */
  --blue-bg:   #0c141c;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 3px;
  --pad: 14px;
  --appbar-h: 46px;
  --footer-h: 34px;
}

/* ── 2. BASE ─────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; scrollbar-color: var(--line) var(--bg); }
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  padding-bottom: var(--footer-h);
}
/* subtle CRT scanline texture — CSS only, ~3% */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.028) 0px, rgba(255, 255, 255, 0.028) 1px,
    transparent 1px, transparent 3px);
}
body.reduce-motion::before,
body.no-crt::before { content: none; }
#app { position: relative; z-index: 1; }

::selection { background: var(--amber-dim); color: #fff; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.3; font-weight: 600; }
h2 { font-size: 17px; letter-spacing: .04em; text-transform: uppercase; color: var(--text); }
h3 { font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
p { max-width: 90ch; }
img, svg, video, canvas { max-width: 100%; height: auto; }

/* thin scrollbar, amber thumb on dark */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--amber-dim); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--amber); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
a:focus-visible, .tab:focus-visible { outline-offset: -2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible,
.btn:focus-visible, .tab:focus-visible, .choice:focus-visible {
  outline: 2px solid var(--amber); outline-offset: 0;
}

code, pre, .u-mono, .stat-num, .kbd, .meter-badge, .key-badge {
  font-family: var(--font-mono);
}
code {
  font-size: .86em; background: var(--bg3); color: var(--amber);
  padding: 0 4px; border: 1px solid var(--line); border-radius: 2px;
}

.hidden { display: none !important; }

/* ── 3b. APP CLOCK (header right chips) ──────────────────── */
.app-clock {
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px; flex: none;
  border-left: 1px solid var(--line);
}
@media (max-width: 640px) { .app-clock { display: none; } }

/* ── 3c. APP BAR ──────────────────────────────────────────── */
.app-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  height: var(--appbar-h);
  display: flex; align-items: stretch;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(232, 163, 61, .04);
}
.app-bar .brand {
  display: flex; align-items: center; gap: 9px;
  padding: 0 14px; flex: none;
  border-right: 1px solid var(--line);
}
.brand-mark {
  width: 24px; height: 24px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--amber); color: var(--amber);
  font: 700 13px/1 var(--font-mono); border-radius: 2px;
}
.brand-name {
  font: 700 13px/1.2 var(--font-mono);
  letter-spacing: .14em; text-transform: uppercase; color: var(--text);
  white-space: nowrap;
}
.brand-version {
  font: 400 10px/1.2 var(--font-mono); color: var(--dim2);
  letter-spacing: .1em; white-space: nowrap;
}
.tab-nav {
  display: flex; flex: 1; min-width: 0;
  overflow-x: auto; scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 13px; min-height: var(--appbar-h);
  flex: none;
  font: 500 11px var(--font-mono);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--dim);
  border-bottom: 2px solid transparent;
  cursor: pointer; background: none; border-top: none; border-left: none; border-right: none;
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--bg3); text-decoration: none; }
.tab.active { color: var(--amber); border-bottom-color: var(--amber); background: linear-gradient(to bottom, transparent 70%, rgba(232, 163, 61, .06)); }
.tab .badge {
  min-width: 15px; padding: 0 4px; text-align: center;
  font: 700 9px/14px var(--font-mono);
  background: var(--amber); color: #14100a; border-radius: 2px;
}
.tab .badge.warn { background: var(--red); color: #fff; }

/* ── 4. LAYOUT ───────────────────────────────────────────── */
main.os-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: calc(var(--appbar-h) + 18px) 18px 40px;
}
.os-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  height: var(--footer-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: var(--bg2);
  border-top: 1px solid var(--line);
  font: 11px var(--font-mono); color: var(--dim);
  letter-spacing: .04em;
}
.os-footer .foot-status {
  margin-left: auto; display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.os-footer .foot-status .dot { flex: none; }
.view-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.view-head h2 { letter-spacing: .06em; }
.view-head .sub { color: var(--dim); font-size: 13px; }
.section-label {
  display: block;
  font: 600 10.5px var(--font-mono);
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--dim2);
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px; margin: 26px 0 12px;
}
.section-label:first-child { margin-top: 0; }

/* responsive grids */
.grid2, .grid3, .grid4 {
  display: grid; gap: 12px; align-items: start; margin-bottom: 12px;
}
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .grid3, .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
}

/* ── 5. CARDS ────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
}
.card + .card { margin-top: 12px; }
.card.elevated { background: var(--bg3); border-color: var(--line2); }
.card.accent { border-left: 3px solid var(--amber); }
.card.accent-green { border-left: 3px solid var(--green); }
.card.accent-red { border-left: 3px solid var(--red); }
.card.accent-blue { border-left: 3px solid var(--blue); }
.card-title {
  font: 600 11px var(--font-mono);
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.card-title .n { margin-left: auto; font-weight: 400; color: var(--dim2); letter-spacing: 0; text-transform: none; }
.card-body { font-size: 14px; color: var(--text); }
.card-body p + p { margin-top: 8px; }

/* callout boxes */
.note-box {
  border: 1px solid var(--line); border-left: 3px solid var(--blue);
  background: var(--blue-bg);
  padding: 10px 12px; margin: 10px 0;
  font-size: 13.5px; border-radius: 0 var(--radius) var(--radius) 0;
}
.note-box .note-head {
  font: 600 10px var(--font-mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--blue); margin-bottom: 4px;
}
.note-warn {
  border-left-color: var(--red); background: var(--red-bg);
}
.note-warn .note-head { color: var(--red); }
.note-box.note-amber { border-left-color: var(--amber); background: var(--amber-bg); }
.note-box.note-amber .note-head { color: var(--amber); }

/* ── 6. STATS & PILLS ────────────────────────────────────── */
.stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}
.stat-label {
  font: 600 9.5px var(--font-mono);
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--dim2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-num {
  font: 700 24px/1.15 var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}
.stat-num .unit { font-size: 12px; font-weight: 400; color: var(--dim); margin-left: 2px; }
.stat-sub { font: 11px var(--font-mono); color: var(--dim); }
.stat.amber .stat-num { color: var(--amber); }
.stat.green .stat-num { color: var(--green); }
.stat.red .stat-num { color: var(--red); }
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { border-color: var(--amber-dim); }

/* status dots */
.dot {
  display: inline-block; width: 8px; height: 8px; flex: none;
  border-radius: 50%; vertical-align: middle;
  background: var(--dim2);
}
.dot-green  { background: var(--green); box-shadow: 0 0 6px rgba(79, 191, 110, .5); }
.dot-amber  { background: var(--amber); box-shadow: 0 0 6px rgba(232, 163, 61, .5); }
.dot-red    { background: var(--red);   box-shadow: 0 0 6px rgba(224, 82, 82, .5); }
.dot-blue   { background: var(--blue); }
.dot-dim    { background: var(--dim2); }
.dot.pulse  { animation: dot-pulse 2s ease-in-out infinite; }
@keyframes dot-pulse {
  0%, 100% { opacity: 1; } 50% { opacity: .35; }
}

/* pills / tags */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border: 1px solid var(--line); border-radius: 999px;
  font: 500 11px var(--font-mono);
  letter-spacing: .04em; color: var(--dim);
  background: var(--bg3);
  white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; }
.pill.pill-green { color: var(--green); border-color: rgba(79, 191, 110, .4); }
.pill.pill-amber { color: var(--amber); border-color: rgba(232, 163, 61, .4); }
.pill.pill-red   { color: var(--red);   border-color: rgba(224, 82, 82, .4); }
.pill.pill-blue  { color: var(--blue);  border-color: rgba(91, 157, 217, .4); }
.tag {
  display: inline-block; padding: 0 6px;
  border: 1px solid var(--line); border-radius: 2px;
  font: 500 9.5px/16px var(--font-mono);
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--dim); white-space: nowrap;
}
.tag.tag-green { color: var(--green); border-color: rgba(79, 191, 110, .4); }
.tag.tag-amber { color: var(--amber); border-color: rgba(232, 163, 61, .4); }
.tag.tag-red   { color: var(--red);   border-color: rgba(224, 82, 82, .4); }
.tag.tag-blue  { color: var(--blue);  border-color: rgba(91, 157, 217, .4); }

/* keyboard hint */
.kbd {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid var(--line2, var(--line)); border-bottom-width: 2px;
  border-radius: 3px;
  font: 600 10.5px/17px var(--font-mono);
  color: var(--dim); background: var(--bg3);
}

/* progress bar */
.bar {
  height: 6px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  display: block; height: 100%; width: 0%;
  background: var(--amber); border-radius: 999px;
  transition: width .35s ease;
}
.bar-fill.green { background: var(--green); }
.bar-fill.red   { background: var(--red); }
.bar-fill.blue  { background: var(--blue); }
.bar.thin { height: 4px; }
.bar.big  { height: 10px; }

/* ── 7. TABLES ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.table {
  width: 100%; border-collapse: collapse;
  font: 12.5px/1.5 var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.table th {
  text-align: left; padding: 8px 12px;
  font: 600 9.5px var(--font-mono);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--dim2);
  background: var(--bg3);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--dim); vertical-align: top;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(26, 34, 48, .6); }
.table td:first-child { color: var(--text); }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg3); color: var(--text);
  font: 500 12.5px var(--font-mono);
  letter-spacing: .04em; cursor: pointer;
  white-space: nowrap; text-decoration: none;
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover { border-color: var(--dim2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--amber); border-color: var(--amber); color: #14100a;
  font-weight: 700;
}
.btn-primary:hover { background: #f0b055; border-color: #f0b055; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--dim); }
.btn-ghost:hover { color: var(--text); border-color: var(--line); background: var(--bg3); }
.btn-danger {
  background: transparent; border-color: rgba(224, 82, 82, .5); color: var(--red);
}
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn.sm { min-height: 28px; padding: 3px 10px; font-size: 11px; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.btn[disabled]:hover { border-color: var(--line); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── 8. FORMS ────────────────────────────────────────────── */
.input, .select, .textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  font: 13px var(--font-ui); color: var(--text);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--amber); }
.input::placeholder, .textarea::placeholder { color: var(--dim2); }
.select {
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
  padding-right: 30px; cursor: pointer;
}
.select option { background: var(--bg2); color: var(--text); }
.textarea { min-height: 90px; resize: vertical; font: 12.5px/1.6 var(--font-mono); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > label {
  font: 600 10px var(--font-mono);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--dim2);
}
.field .hint { font-size: 11.5px; color: var(--dim2); }

/* in-content tab switcher (distinct from top app-bar .tab) */
.tabs {
  display: flex; gap: 0; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 14px;
  background: var(--bg2);
}
.tabs .tab {
  min-height: 36px; padding: 6px 14px;
  border-bottom: none; border-right: 1px solid var(--line);
  letter-spacing: .1em;
}
.tabs .tab:last-child { border-right: none; }
.tabs .tab.active {
  color: var(--amber); background: var(--bg3);
  box-shadow: inset 0 -2px 0 var(--amber);
}

/* ── 9. MODAL & TOAST ────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 14px 14px;
  overflow-y: auto;
  background: rgba(4, 7, 12, .72);
  backdrop-filter: blur(2px);
}
.modal {
  width: min(640px, 100%);
  background: var(--bg2);
  border: 1px solid var(--line2, var(--line));
  border-radius: var(--radius);
  box-shadow: 0 12px 48px rgba(0, 0, 0, .7);
  padding: 18px;
}
.modal-title {
  font: 700 13px var(--font-mono);
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--amber); margin-bottom: 12px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.toast-stack {
  position: fixed; right: 14px; bottom: calc(var(--footer-h) + 12px); z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(380px, calc(100vw - 28px));
}
.toast {
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--line); border-left: 3px solid var(--amber);
  border-radius: 0 var(--radius) var(--radius) 0;
  font: 12px/1.5 var(--font-mono); color: var(--text);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .55);
  animation: toast-in .22s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast.kind-green  { border-left-color: var(--green); }
.toast.kind-red    { border-left-color: var(--red); }
.toast.kind-blue   { border-left-color: var(--blue); }

/* empty state */
.empty-state {
  padding: 42px 20px;
  text-align: center;
  color: var(--dim2);
  font: 12.5px/1.7 var(--font-mono);
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty-state .glyph {
  display: block; font-size: 22px; color: var(--dim2);
  margin-bottom: 10px; letter-spacing: .2em;
}

/* ── 10. DRILLS & QUIZ ───────────────────────────────────── */
.drill-card {
  background: var(--bg2);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--pad);
  display: flex; flex-direction: column; gap: 10px;
}
.drill-card .drill-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.drill-card .drill-name {
  font: 600 13.5px var(--font-ui); color: var(--text);
}
.drill-card .drill-desc { font-size: 12.5px; color: var(--dim); }
.drill-card .drill-meta {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto;
}
.drill-card .drill-stats {
  display: flex; gap: 14px; flex-wrap: wrap;
  font: 11px var(--font-mono); color: var(--dim2);
  border-top: 1px solid var(--line); padding-top: 8px;
}
.drill-card.running { border-color: var(--amber-dim); box-shadow: 0 0 0 1px rgba(232, 163, 61, .15); }

.choice-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 12px;
}
.choice {
  min-height: 64px;
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
  background: var(--bg3);
  border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text);
  font: 600 16px var(--font-mono);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.choice:hover { border-color: var(--amber-dim); }
.choice.correct {
  border-color: var(--green); background: var(--green-bg);
  color: var(--green); box-shadow: 0 0 0 1px rgba(79, 191, 110, .4);
}
.choice.wrong {
  border-color: var(--red); background: var(--red-bg);
  color: var(--red); box-shadow: 0 0 0 1px rgba(224, 82, 82, .4);
}
.choice[disabled] { cursor: default; }

/* ── 10b. DRILL RUNTIME (d-* classes emitted by drills.js) ── */
.drl {
  background: var(--bg2);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--pad);
  display: flex; flex-direction: column; gap: 6px;
  max-width: 720px; margin: 0 auto;
}
.d-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
}
.d-title { font: 700 16px var(--font-ui); color: var(--text); }
.d-sub   { font: 400 12.5px var(--font-ui); color: var(--dim); margin-top: 3px; max-width: 46ch; }
.d-stats { display: flex; gap: 14px; flex: none; }
.d-stat  { text-align: right; min-width: 52px; }
.d-stat span { display: block; font: 500 10px var(--font-ui); color: var(--dim2); text-transform: uppercase; letter-spacing: .08em; }
.d-stat b { font: 700 16px var(--font-mono); color: var(--text); }
.d-stat.hot b { color: var(--amber); }
.d-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.d-hint { font: 400 11.5px var(--font-ui); color: var(--dim2); }
.d-stage {
  min-height: 220px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 0;
  background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.d-stage .d-fb { min-height: 22px; }
.d-fb { font: 600 14px var(--font-ui); color: var(--dim); text-align: center; }
.d-fb.correct  { color: var(--green); }
.d-fb.wrong    { color: var(--red); }
.d-fb.done     { color: var(--amber); }
.d-center { text-align: center; }
.d-ansrow { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; }
.d-ans {
  min-width: 44px; padding: 9px 10px;
  font: 700 15px var(--font-mono);
}
.d-seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.d-seg button {
  background: transparent; color: var(--dim);
  border: none; padding: 6px 12px;
  font: 600 12px var(--font-ui); cursor: pointer;
}
.d-seg button + button { border-left: 1px solid var(--line); }
.d-seg button.on { background: var(--amber-bg); color: var(--amber); }
.d-btn {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 16px; font: 600 13px var(--font-ui);
  cursor: pointer; transition: border-color .12s, background .12s;
}
.d-btn:hover { border-color: var(--amber-dim); }
.d-btn.primary { background: var(--amber-bg); border-color: var(--amber-dim); color: var(--amber); }
.d-btn.correct { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.d-btn.wrong   { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.d-panel {
  display: flex; align-items: center; justify-content: center;
  min-height: 180px; width: 100%;
  background: var(--bg3); border: 1px solid var(--line); border-radius: var(--radius);
}
.d-sum { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.d-staffwrap { display: flex; justify-content: center; width: 100%; }
.d-staffwrap svg { max-width: 100%; height: auto; }
.d-error {
  width: 100%; padding: 10px 12px; margin-top: 8px;
  background: var(--red-bg); border: 1px solid var(--red); border-radius: var(--radius);
  color: var(--red); font: 500 12.5px var(--font-ui);
}
.d-kbwrap { display: flex; justify-content: center; width: 100%; overflow-x: auto; }
.d-kbline { display: flex; gap: 2px; }
.d-legend { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; font: 400 11.5px var(--font-ui); color: var(--dim2); }

/* ── 11. STAFF, HYMNS & BADGES ───────────────────────────── */
.staff-canvas {
  display: block; width: 100%; max-width: 640px;
  background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius);
  margin: 10px auto;
}
.staff-controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }

.hymn-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg2);
  border: 1px solid var(--line); border-left: 3px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) 0;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.hymn-row + .hymn-row { margin-top: 6px; }
.hymn-row:hover { background: var(--bg3); border-left-color: var(--amber-dim); }
.hymn-row .hymn-title { font: 600 13.5px var(--font-ui); color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hymn-row .hymn-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; flex: none; }
.hymn-row.status-new        { border-left-color: var(--dim2); }
.hymn-row.status-learning   { border-left-color: var(--amber); }
.hymn-row.status-ready      { border-left-color: var(--green); }
.hymn-row.status-repertoire { border-left-color: var(--blue); }

.meter-badge, .key-badge {
  display: inline-flex; align-items: center;
  min-width: 30px; padding: 1px 7px;
  border: 1px solid var(--line); border-radius: 2px;
  font: 600 11px/18px var(--font-mono);
  color: var(--dim); background: var(--bg3);
  white-space: nowrap; letter-spacing: .02em;
}
.key-badge { color: var(--amber); border-color: rgba(232, 163, 61, .35); }
.meter-badge.sub { color: var(--dim2); font-size: 10px; }

/* ── 12. COACH, TIMELINE & RING ──────────────────────────── */
.verdict {
  background: var(--bg2);
  border: 1px solid var(--line); border-left: 3px solid var(--amber);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 16px;
  font-size: 14px;
}
.verdict .verdict-head {
  display: flex; align-items: center; gap: 8px;
  font: 700 11px var(--font-mono);
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--amber); margin-bottom: 8px;
}
.verdict .verdict-body { color: var(--text); }
.verdict .verdict-body p + p { margin-top: 8px; }
.verdict.verdict-harsh { border-left-color: var(--red); }
.verdict.verdict-harsh .verdict-head { color: var(--red); }
.verdict.verdict-good { border-left-color: var(--green); }
.verdict.verdict-good .verdict-head { color: var(--green); }
.verdict ul { margin: 8px 0 0 18px; }
.verdict li { margin-bottom: 4px; }

.timeline {
  border-left: 2px solid var(--line);
  margin: 8px 0 8px 6px;
  padding-left: 18px;
}
.tl-item { position: relative; padding: 4px 0 16px; }
.tl-item::before {
  content: "";
  position: absolute; left: -23.5px; top: 10px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--dim2);
}
.tl-item.done::before { border-color: var(--green); background: var(--green); }
.tl-item.current::before { border-color: var(--amber); background: var(--amber); box-shadow: 0 0 8px rgba(232, 163, 61, .6); }
.tl-item .tl-date { font: 10px var(--font-mono); color: var(--dim2); letter-spacing: .08em; text-transform: uppercase; }
.tl-item .tl-title { font: 600 13.5px var(--font-ui); color: var(--text); }
.tl-item .tl-body { font-size: 12.5px; color: var(--dim); margin-top: 2px; }
.tl-item.current .tl-title { color: var(--amber); }
.tl-item.done .tl-title { color: var(--dim); }

/* SVG progress ring — .ring wraps an <svg>; .ring-track/.ring-arc stroke it */
.ring { display: inline-block; position: relative; width: 84px; height: 84px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.ring .ring-track { fill: none; stroke: var(--bg3); stroke-width: 6; }
.ring .ring-arc { fill: none; stroke: var(--amber); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.ring .ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: 700 16px var(--font-mono); color: var(--text);
  font-variant-numeric: tabular-nums;
}
.ring .ring-label small { font: 500 8.5px var(--font-mono); letter-spacing: .1em; color: var(--dim2); text-transform: uppercase; }
.ring.green .ring-arc { stroke: var(--green); }
.ring.red .ring-arc { stroke: var(--red); }

/* ── 13. HEATMAP (practice calendar) ─────────────────────── */
.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 12px);
  grid-auto-columns: 12px;
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.heat-cell {
  width: 12px; height: 12px;
  border-radius: 2px;
  background: var(--bg3);
  border: 1px solid var(--line);
  cursor: default;
}
.heat-cell.h1 { background: rgba(232, 163, 61, .22); border-color: rgba(232, 163, 61, .3); }
.heat-cell.h2 { background: rgba(232, 163, 61, .42); border-color: rgba(232, 163, 61, .45); }
.heat-cell.h3 { background: rgba(232, 163, 61, .65); border-color: rgba(232, 163, 61, .6); }
.heat-cell.h4 { background: var(--amber); border-color: var(--amber); }
.heat-cell.today { outline: 1px solid var(--text); outline-offset: 1px; }
.heatmap-legend { display: flex; align-items: center; gap: 4px; font: 10px var(--font-mono); color: var(--dim2); margin-top: 6px; }

/* ── 14. UTILITIES ───────────────────────────────────────── */
.u-right { text-align: right; }
.u-center { text-align: center; }
.u-dim { color: var(--dim); }
.u-dimmer { color: var(--dim2); }
.u-small { font-size: 12px; }
.u-smaller { font-size: 11px; }
.u-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.u-caps {
  text-transform: uppercase; letter-spacing: .12em;
  font-size: .92em; font-weight: 600;
}
.u-red { color: var(--red); }
.u-green { color: var(--green); }
.u-amber { color: var(--amber); }
.u-blue { color: var(--blue); }
.u-bold { font-weight: 700; }

/* spacing scale */
.u-mt1 { margin-top: 4px; }  .u-mt2 { margin-top: 8px; }
.u-mt3 { margin-top: 14px; } .u-mt4 { margin-top: 22px; }
.u-mb1 { margin-bottom: 4px; }  .u-mb2 { margin-bottom: 8px; }
.u-mb3 { margin-bottom: 14px; } .u-mb4 { margin-bottom: 22px; }

/* flex helpers */
.u-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }      /* row, wraps */
.u-gap.tight { gap: 5px; }
.u-stack { display: flex; flex-direction: column; gap: 8px; }
.u-stack.tight { gap: 5px; }
.u-grow { flex: 1 1 auto; min-width: 0; }
.u-spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── 15. PRINT ───────────────────────────────────────────── */
/* ── 16. VIEW LAYER (ui.js output) ───────────────────────── */
/* generic sub text outside view-head */
.sub { color: var(--dim); font-size: 12.5px; line-height: 1.55; }
.sub.why   { color: var(--dim2); font-style: italic; }
.sub.tip   { color: var(--amber); }
.sub.gap   { color: var(--dim); margin: 2px 0 0; }
.sub.pacing::before { content: '⏱ '; }
.sub.est::before { content: '⏳ '; }
.sub.checkpoint { color: var(--green); }
.sub.checkpoint::before { content: '✔ '; }
.verdict-text { color: var(--text); }

/* stat strip inside cards */
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.stat-row .stat {
  flex: 1 1 90px; min-width: 90px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-label { font: 500 10px var(--font-ui); color: var(--dim2); text-transform: uppercase; letter-spacing: .08em; }
.stat-value { font: 700 17px var(--font-mono); color: var(--text); }
.stat-hint  { font: 400 10.5px var(--font-ui); color: var(--dim2); }

/* line list (simple title+text rows) */
.line-list { list-style: none; margin: 8px 0 0; padding: 0; }
.line-list li {
  display: flex; gap: 8px; align-items: baseline;
  padding: 6px 0; border-bottom: 1px solid var(--line);
}
.line-list li:last-child { border-bottom: none; }
.line-list .glyph { color: var(--amber); flex: none; font-family: var(--font-mono); }
.line-list .li-body { flex: 1; min-width: 0; }
.line-list .li-body b { color: var(--text); font: 600 13px var(--font-ui); margin-right: 6px; }
.line-list .li-body .sub { display: block; }
.line-list .li-right { flex: none; font-family: var(--font-mono); }

/* material links */
.mat-list { list-style: none; margin: 8px 0; padding: 0; }
.mat-list li { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; flex-wrap: wrap; }
.mat-list a { color: var(--amber); text-decoration: none; border-bottom: 1px dotted rgba(232, 163, 61, .4); }
.mat-list a:hover { color: var(--text); border-bottom-color: var(--amber); }
.mat-list li > span:last-child { color: var(--text); font-size: 13px; }
.tag-docs { color: var(--blue); border-color: rgba(91, 157, 217, .4); }
.tag-tool { color: var(--green); border-color: rgba(79, 191, 110, .4); }
.tag-buy  { color: var(--red); border-color: rgba(224, 82, 82, .4); }
.tag-app  { color: var(--amber); border-color: rgba(232, 163, 61, .4); }
.tag-core { color: var(--amber); border-color: rgba(232, 163, 61, .5); }
.tag-warn { color: var(--red); border-color: rgba(224, 82, 82, .5); }

/* pillars (coach) */
.pillar-row { display: flex; align-items: center; gap: 10px; margin: 7px 0; }
.pillar-name {
  flex: 0 0 92px; font: 600 12px var(--font-ui); color: var(--dim);
  text-transform: capitalize;
}
.pillar-track {
  flex: 1; height: 8px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 4px; overflow: hidden;
}
.pillar-fill { height: 100%; width: 0; transition: width .4s ease; }
.pillar-fill.low  { background: var(--red); }
.pillar-fill.mid  { background: var(--amber); }
.pillar-fill.high { background: var(--green); }
.pillar-val { flex: 0 0 30px; text-align: right; font: 700 13px var(--font-mono); color: var(--text); }

/* readiness banner + big index ring */
.readiness-banner { display: flex; gap: 16px; align-items: center; }
.readiness-banner h3 { margin: 0 0 4px; }
.readiness-banner .ring {
  width: 74px; height: 74px;
  border: 3px solid var(--line); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font: 700 22px var(--font-mono); color: var(--text); flex: none;
}
.readiness-banner .ring-ok  { border-color: var(--green); color: var(--green); }
.readiness-banner .ring-mid { border-color: var(--amber); color: var(--amber); }
.readiness-banner .ring-low { border-color: var(--red); color: var(--red); }

/* today: session blocks */
.block-list { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.block-row { display: flex; gap: 12px; align-items: flex-start; }
.block-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: none; }
.dot-warmup  { background: var(--dim2); }
.dot-reading { background: var(--blue); }
.dot-hymn    { background: var(--amber); }
.dot-tech    { background: var(--green); }
.dot-piece   { background: var(--dim); }
.dot-theory  { background: var(--blue); }
.dot-x       { background: var(--dim2); }
.block-body b { color: var(--text); font: 700 12px var(--font-ui); letter-spacing: .05em; display: block; }
.block-body .sub { display: block; margin-top: 2px; }
.block-body .sub.why { display: block; margin-top: 1px; }

/* forms (log session / profile) */
.log-form { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.log-form .frow { display: flex; gap: 12px; flex-wrap: wrap; }
.log-form label {
  display: flex; flex-direction: column; gap: 4px;
  font: 500 11px var(--font-ui); color: var(--dim2); text-transform: uppercase; letter-spacing: .07em;
}
.log-form input, .log-form select {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); font: 500 13px var(--font-ui);
  padding: 7px 9px; min-width: 90px;
}
.log-form input:focus, .log-form select:focus { border-color: var(--amber); outline: none; }
.log-form .btn { align-self: flex-start; }
label.chk { display: inline-flex; align-items: center; gap: 7px; font: 500 13px var(--font-ui); color: var(--text); cursor: pointer; }
label.chk input { accent-color: var(--amber); }
.btn.primary { background: var(--amber-bg); border-color: var(--amber-dim); color: var(--amber); }
.btn.primary:hover { border-color: var(--amber); }
.btn.danger { background: var(--red-bg); border-color: rgba(224, 82, 82, .5); color: var(--red); }
.btn.danger:hover { border-color: var(--red); }

/* gym */
.drill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 12px; }
.drill-grid .drill-card .btn { margin-top: auto; align-self: flex-start; }
.drill-mount { margin-top: 12px; }

/* coach: gates + audit */
.gate-row { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid var(--line); }
.gate-row:last-child { border-bottom: none; }
.gate-mark { font: 700 14px var(--font-mono); flex: none; width: 18px; }
.gate-mark.pass { color: var(--green); }
.gate-mark.fail { color: var(--red); }
.audit-row { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); }
.audit-row:last-child { border-bottom: none; }
.audit-row .sev-high { color: var(--red); border-color: rgba(224, 82, 82, .5); }
.audit-row .sev-med  { color: var(--amber); border-color: rgba(232, 163, 61, .5); }
.audit-row .sev-low  { color: var(--dim); }
.audit-row .sev-good { color: var(--green); border-color: rgba(79, 191, 110, .4); }
.audit-msg { color: var(--text); font-size: 13px; line-height: 1.5; }

/* path: lines, stages, subjects, concepts */
.line-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.line-head h3 { margin: 0; }
.line-pulpit  h3 { color: var(--amber); }
.line-atelier h3 { color: var(--green); }
.line-engine  h3 { color: var(--blue); }
.stage-row {
  border: 1px solid var(--line); border-left: 3px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 10px 12px; margin: 8px 0; cursor: pointer;
  background: var(--bg);
}
.stage-row:hover { background: var(--bg3); }
.stage-row.open { border-left-color: var(--amber); }
.stage-title { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stage-title b { color: var(--text); }
.stage-title .pillar-track { max-width: 180px; height: 6px; flex: 1 1 120px; }
.subject {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin: 10px 0 10px 14px;
  background: var(--bg2);
}
.subject h4 { margin: 0 0 4px; color: var(--text); font: 700 13.5px var(--font-ui); }
.mod-title { font: 600 12px var(--font-ui); color: var(--amber); margin: 12px 0 4px; text-transform: uppercase; letter-spacing: .06em; }
.concept { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.concept:last-child { border-bottom: none; }
.concept input[type="checkbox"] { accent-color: var(--amber); margin-top: 3px; flex: none; }
.concept-body { flex: 1; min-width: 0; }
.concept-body b { color: var(--text); font: 600 13px var(--font-ui); }
.concept-body .sub { display: block; margin-top: 2px; }
.concept.done .concept-body b { color: var(--dim); text-decoration: line-through; }
.concept.done .concept-body .sub { color: var(--dim2); }

/* hymn detail helpers */
.hymn-row { cursor: pointer; }

/* responsive view tweaks */
@media (max-width: 640px) {
  .readiness-banner { flex-direction: column; text-align: center; }
  .pillar-name { flex-basis: 76px; }
  .block-row { gap: 8px; }
}

@media print {
  :root { --bg: #fff; --bg2: #fff; --bg3: #f4f4f4; --line: #bbb; --line2: #999;
          --text: #000; --dim: #444; --dim2: #666; }
  body { background: #fff !important; color: #000 !important; padding: 0; font-size: 12px; }
  body::before { content: none !important; }
  .app-bar, .os-footer, .tab-nav, .toast-stack, .modal-backdrop, .btn, .btn-row,
  .staff-controls, .no-print { display: none !important; }
  main.os-main { padding: 0; max-width: none; }
  .card, .drill-card, .verdict, .table-wrap { border: 1px solid #999; background: #fff; break-inside: avoid; }
  .table th { background: #eee; color: #000; }
  .table td { color: #222; }
  .stat-num { color: #000; }
  .bar { background: #eee; } .bar-fill { background: #555; }
  .heat-cell { border-color: #ccc; }
  .heat-cell.h1 { background: #f0e0c8; } .heat-cell.h2 { background: #e6c690; }
  .heat-cell.h3 { background: #d9a850; } .heat-cell.h4 { background: #b07c1e; }
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 900px) {
  main.os-main { padding-left: 12px; padding-right: 12px; }
  .brand-version { display: none; }
  .brand-name { letter-spacing: .08em; }
  .stat-num { font-size: 20px; }
  .table { font-size: 11.5px; }
  .table th, .table td { padding: 7px 9px; }
}
@media (max-width: 640px) {
  main.os-main { padding-left: 10px; padding-right: 10px; padding-top: calc(var(--appbar-h) + 12px); }
  body { font-size: 15px; }
  .app-bar { flex-wrap: nowrap; }
  .app-bar .brand { padding: 0 10px; gap: 6px; }
  .brand-mark { width: 20px; height: 20px; font-size: 11px; }
  .brand-name { font-size: 11px; letter-spacing: .06em; }
  .tab { padding: 0 10px; letter-spacing: .06em; font-size: 10px; }
  .os-footer { font-size: 10px; gap: 10px; padding: 0 10px; }
  /* stats stack vertically, one per row, horizontal inside */
  .stat { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
  .stat-num { font-size: 18px; }
  .choice-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .choice { min-height: 56px; font-size: 14px; padding: 8px; }
  .hymn-row { flex-wrap: wrap; }
  .hymn-row .hymn-meta { width: 100%; justify-content: flex-start; }
  .hymn-row .hymn-title { white-space: normal; }
  .staff-canvas { max-width: 100%; }
  .view-head h2 { font-size: 15px; }
  .card { padding: 12px; }
  .u-spread { flex-direction: column; align-items: flex-start; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
body.reduce-motion * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
