/* Ottava — ebony & brass.
   The hardware control-surface soul stays: graphite panels, ivory type,
   silkscreen uppercase labels — now with a single warm brass accent (the
   materials of a piano: ebony, ivory, brass). The roll is the hero.
   Two themes: ebony (default) and ivory, switched via [data-theme]. */

:root {
  --bg: #12141b;
  --panel: #191c25;
  --raised: #222634;
  --raised-hi: #2a2f3f;
  --line: #2e3342;
  --ivory: #f0ebdf;
  /* Both secondary text tones clear WCAG AA (4.5:1) on bg, panel and raised;
     dim is the cooler of the two (it was #6e7583, 3.3:1 on raised). */
  --muted: #9a937f;
  --dim: #8a91a0;
  --accent: #e9b44c;
  --accent-deep: #b27d24;
  --accent-ink: #241a07;
  --ok: #3dd68c;
  --bad: #ff5c5c;
  --bar-grad-a: #1f2430;
  --bar-grad-b: #171b24;
  --transport-a: #1c202b;
  --transport-b: #171b24;
  --tabs-bg: #161a22;
  --mon-bg: #10131a;
  --btn-border: #3a4250;
  --shadow: rgba(0, 0, 0, 0.5);
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --bg: #f4f1e8;
  --panel: #ece8dc;
  --raised: #ffffff;
  --raised-hi: #fdf8ec;
  --line: #d8d2c2;
  --ivory: #23262e;
  /* AA (4.5:1) on every surface down to the tab strip (were #7a7460 and
     #767b8a, about 3.5:1 on the panels). */
  --muted: #67614f;
  --dim: #5a5f6d;
  --accent: #b27d24;
  --accent-deep: #8a5f14;
  --accent-ink: #fff8e8;
  --ok: #178a56;
  --bad: #c93b3b;
  --bar-grad-a: #f9f6ee;
  --bar-grad-b: #efeadd;
  --transport-a: #f4f0e5;
  --transport-b: #ece7d9;
  --tabs-bg: #e2ddcf;
  --mon-bg: #eee9dc;
  --btn-border: #c9c2af;
  --shadow: rgba(60, 50, 20, 0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ivory);
  font: 13px/1.45 -apple-system, "Segoe UI", "Helvetica Neue", Helvetica, sans-serif;
  user-select: none;
}

body { display: flex; flex-direction: column; }

/* One quiet motion rule for the whole surface; killed for reduced-motion. */
button, select, .tab, .led, .lib-card, input[type="search"], input[type="text"] {
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease,
              box-shadow 0.15s ease, filter 0.15s ease, transform 0.12s ease;
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.lbl {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.mono { font-family: var(--mono); font-size: 12px; }
.dim { color: var(--dim); font-weight: 400; letter-spacing: 0; text-transform: none; }
.big { font-size: 15px; }

/* ---------------------------------------------------------------- header */
.bar {
  display: flex;
  flex-wrap: wrap; /* a narrow window wraps the controls instead of clipping them */
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 16px 11px 84px; /* room for macOS traffic lights */
  background: linear-gradient(var(--bar-grad-a), var(--bar-grad-b));
  border-bottom: 1px solid var(--line);
  -webkit-app-region: drag;
}
.bar select, .bar .led, .bar button { -webkit-app-region: no-drag; }
/* Windows/Linux: a real title bar exists, so no traffic-light inset or drag region */
.standard-titlebar .bar { padding-left: 16px; -webkit-app-region: no-drag; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { display: block; border-radius: 6px; }
.brand .name { font-size: 13px; font-weight: 700; letter-spacing: 0.22em; }
.brand .model {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.led {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #4a3030;
  box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.7);
}
.led.on { background: var(--ok); box-shadow: 0 0 8px rgba(61, 214, 140, 0.8); }

.devices {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
  gap: 6px 8px; margin-left: auto;
}

.icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

select {
  appearance: none;
  background: var(--raised);
  color: var(--ivory);
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  padding: 5px 24px 5px 9px;
  font-family: var(--mono);
  font-size: 11px;
  max-width: 220px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 55%, calc(100% - 9px) 55%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ------------------------------------------------------------------ tabs */
.tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.tabs {
  display: flex;
  gap: 2px;
  background: var(--tabs-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: none;
}
.tab:hover { color: var(--ivory); }
.tab.active {
  background: var(--raised-hi);
  color: var(--ivory);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.tab:focus-visible { outline: 2px solid var(--accent); }

.song-name {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: auto;
}
.library-btn { white-space: nowrap; }

/* ------------------------------------------------------------------ roll */
.roll-wrap { flex: 1; min-height: 240px; position: relative; }
#roll { display: block; cursor: pointer; }

/* ------------------------------------------------------------- transport */
.transport {
  background: linear-gradient(var(--transport-a), var(--transport-b));
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  min-height: 86px;
}
.panel { display: none; align-items: flex-end; gap: 22px; flex-wrap: wrap; }
.panel.active { display: flex; }

.ctl { display: flex; flex-direction: column; gap: 6px; }
.ctl.grow { flex: 1; min-width: 220px; }
.row { display: flex; align-items: center; gap: 8px; }

button {
  background: linear-gradient(var(--raised-hi), var(--raised));
  color: var(--ivory);
  border: 1px solid var(--btn-border);
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 1px 2px var(--shadow);
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.38; cursor: default; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button.accent {
  background: linear-gradient(#f0c45c, #d99e2f);
  border-color: var(--accent-deep);
  color: #241a07;
}
[data-theme="light"] button.accent {
  background: linear-gradient(#c8922e, #a9761e);
  color: #fff8e8;
}
button.danger { border-color: #6e3a3a; color: #ff9d9d; }
[data-theme="light"] button.danger { border-color: #c98a8a; color: #a12727; }
button.mini { padding: 3px 9px; font-size: 10px; }
button.recording {
  background: linear-gradient(#ff6b6b, #d84545);
  border-color: #9c3232;
  color: #2a0d0d;
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 50% { filter: brightness(1.25); } }

input[type="range"] { accent-color: var(--accent); width: 100%; min-width: 130px; }
.chk { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ivory); }
.chk input { accent-color: var(--accent); }

input[type="number"] {
  background: var(--raised);
  color: var(--ivory);
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  padding: 5px 6px;
  font-family: var(--mono);
  font-size: 12px;
  width: 58px;
  text-align: center;
}
input[type="number"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.met-toggle.on, #btn-loop-toggle.on, #btn-play-click.on {
  color: var(--accent);
  border-color: var(--accent-deep);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 0 6px rgba(233, 180, 76, 0.3);
}
/* Visual beat pulse — a dot that lights on each click so the beat is seen as
   well as heard (silent practice, visual learners, hard-of-hearing). */
.met-beat {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--line);
  border: 1px solid var(--line);
  vertical-align: middle;
  transition: background 0.09s ease-out, box-shadow 0.09s ease-out, transform 0.09s ease-out;
}
.met-beat.beat-on { background: var(--accent); box-shadow: 0 0 6px rgba(233, 180, 76, 0.5); }
.met-beat.beat-down { background: var(--accent); box-shadow: 0 0 10px rgba(233, 180, 76, 0.85); transform: scale(1.35); }
@media (prefers-reduced-motion: reduce) { .met-beat { transition: none; } .met-beat.beat-down { transform: none; } }

/* progress dashboard */
#dlg-progress { max-width: min(640px, calc(100vw - 48px)); }
.prog-body { padding: 16px; max-height: min(62vh, 560px); overflow-y: auto; }
.prog-empty { color: var(--dim); text-align: center; padding: 34px 0; }
.prog-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.prog-tile { background: var(--raised); border: 1px solid var(--line); border-radius: 10px; padding: 12px 8px; text-align: center; }
.prog-tile .pv { font-size: 22px; font-weight: 700; color: var(--accent); }
.prog-tile .pl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; margin-top: 3px; }
.prog-row { display: grid; grid-template-columns: 1.2fr 2fr auto; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.prog-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prog-barwrap { height: 8px; background: var(--raised); border-radius: 999px; overflow: hidden; }
.prog-bar { height: 100%; background: linear-gradient(90deg, var(--accent-deep), var(--accent)); border-radius: 999px; }
.prog-meta { font-family: var(--mono); font-size: 10.5px; color: var(--muted); white-space: nowrap; }
@media (max-width: 560px) {
  .prog-tiles { grid-template-columns: repeat(2, 1fr); }
  .prog-row { grid-template-columns: 1fr auto; }
  .prog-barwrap { display: none; }
}

/* streak + gamification */
.streak {
  font-family: var(--mono); font-size: 11px; color: var(--accent);
  background: rgba(233, 180, 76, 0.12); border: 1px solid rgba(233, 180, 76, 0.35);
  border-radius: 999px; padding: 1px 8px; -webkit-app-region: no-drag;
}
.gm-banner { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; }
.gm-level { text-align: center; min-width: 56px; }
.gm-lv { font-size: 18px; font-weight: 800; color: var(--accent); letter-spacing: 0.04em; }
.gm-xp { font-size: 10px; color: var(--muted); font-family: var(--mono); }
.gm-mid { display: flex; flex-direction: column; gap: 5px; }
.gm-barwrap { height: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.gm-bar { height: 100%; background: linear-gradient(90deg, var(--accent-deep), var(--accent)); }
.gm-nextxp { font-size: 10px; color: var(--dim); font-family: var(--mono); }
.gm-side { display: flex; gap: 16px; }
.gm-stat { text-align: center; }
.gm-num { display: block; font-size: 15px; font-weight: 700; }
.gm-lbl { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
@media (max-width: 560px) { .gm-banner { grid-template-columns: 1fr; text-align: center; } .gm-side { justify-content: center; } }

/* achievements */
.ach-head { margin: 18px 0 8px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 10px; }
.ach { background: var(--raised); border: 1px solid var(--line); border-radius: 10px; padding: 12px 6px; text-align: center; opacity: 0.45; filter: grayscale(0.8); }
.ach.got { opacity: 1; filter: none; border-color: var(--accent-deep); }
.ach-ic { font-size: 24px; line-height: 1; }
.ach-nm { font-size: 9.5px; color: var(--muted); margin-top: 6px; }
.ach.got .ach-nm { color: var(--ivory); }

.hint {
  flex-basis: 100%;
  font-size: 11px;
  color: var(--dim);
}

/* --------------------------------------------------------------- monitor */
.monitor {
  border-top: 1px solid var(--line);
  background: var(--mon-bg);
  padding: 6px 16px 8px;
}
.mon-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
#mon {
  height: 64px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--dim);
}
#mon .hex { color: var(--accent-deep); }
#mon .mon-noise { color: var(--dim); opacity: 0.7; font-style: italic; }
#mon::-webkit-scrollbar { width: 8px; }
#mon::-webkit-scrollbar-thumb { background: var(--raised); border-radius: 4px; }

/* ----------------------------------------------------------------- toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 118px;
  transform: translate(-50%, 12px);
  background: var(--raised-hi);
  border: 1px solid var(--btn-border);
  color: var(--ivory);
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: 0 6px 24px var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 70vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 40;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------- dialogs */
dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ivory);
  box-shadow: 0 24px 80px var(--shadow);
  padding: 0;
  max-width: min(860px, calc(100vw - 64px));
  width: 100%;
  margin: auto; /* the global * reset zeroes the UA margin that centres a dialog */
}
/* The trainers open non-modal (show()), so the keyboard below stays playable:
   float them top-centre, clear of the header, instead of in the page flow. */
dialog[open]:not(:modal) {
  position: fixed;
  top: 60px;
  inset-inline: 0;
  margin: 0 auto;
  max-height: calc(100vh - 76px);
  overflow-y: auto;
}
dialog::backdrop { background: rgba(8, 9, 12, 0.62); }
[data-theme="light"] dialog::backdrop { background: rgba(60, 52, 30, 0.35); }

.dlg-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.dlg-title { font-weight: 700; letter-spacing: 0.16em; font-size: 12px; text-transform: uppercase; }
.dlg-head input[type="search"] {
  flex: 1;
  background: var(--raised);
  border: 1px solid var(--btn-border);
  border-radius: 999px;
  color: var(--ivory);
  font-size: 12px;
  padding: 6px 14px;
  outline: none;
}
.dlg-head input[type="search"]:focus-visible { outline: 2px solid var(--accent); }
.dlg-foot { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 11px; }

/* song library grid */
.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  padding: 14px 16px;
  max-height: min(52vh, 560px);
  overflow-y: auto;
}
.lib-card {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lib-card { position: relative; }
.lib-card:hover { border-color: var(--accent-deep); }
.lib-sort { max-width: 158px; }
.lib-fav {
  position: absolute; top: 8px; right: 10px;
  background: none; border: 0; box-shadow: none; padding: 2px;
  color: var(--dim); font-size: 15px; line-height: 1; cursor: pointer;
}
.lib-fav:hover { color: var(--muted); filter: none; }
.lib-fav.on { color: var(--accent); }

/* settings */
#dlg-settings { max-width: min(460px, calc(100vw - 48px)); }
.set-body { padding: 10px 16px; display: flex; flex-direction: column; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; }
.set-row > label, .set-row > span { font-size: 13.5px; color: var(--ivory); }
.set-row input[type="text"], .set-row select { max-width: 200px; }
.set-row input[type="range"] { max-width: 200px; min-width: 140px; }
.set-sep { height: 1px; background: var(--line); margin: 8px 0; }
.lib-card .t { font-weight: 600; font-size: 13px; line-height: 1.3; }
.lib-card .meta { font-family: var(--mono); font-size: 10.5px; color: var(--dim); }
.lib-card .stats { font-family: var(--mono); font-size: 10.5px; color: var(--muted); min-height: 14px; }
.lib-card .row { margin-top: 4px; }
.lib-empty { grid-column: 1 / -1; color: var(--dim); text-align: center; padding: 28px 0; }

.badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 1px 6px;
  width: fit-content;
}
.badge.easy   { background: rgba(61, 214, 140, 0.14); color: var(--ok); border: 1px solid rgba(61, 214, 140, 0.4); }
.badge.medium { background: rgba(233, 180, 76, 0.12); color: var(--accent); border: 1px solid rgba(233, 180, 76, 0.4); }
.badge.hard   { background: rgba(255, 92, 92, 0.12); color: var(--bad); border: 1px solid rgba(255, 92, 92, 0.4); }
.badge.mine   { background: rgba(110, 117, 131, 0.14); color: var(--dim); border: 1px solid var(--line); }
.badge.daily  { background: var(--accent); color: #1a1205; border: 1px solid var(--accent); font-weight: 700; }

/* Daily challenge — the song of the day, pinned atop the library */
.lib-card.lib-daily {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 6px 20px rgba(233, 180, 76, 0.12);
  background: linear-gradient(180deg, rgba(233, 180, 76, 0.09), var(--raised) 58%);
}
.lib-card.lib-daily:hover { border-color: var(--accent); }
.lib-card.lib-daily.done { opacity: 0.8; }

/* Today's practice — the tabs-row button (brass while steps are left), the
   dialog's four steps, and the strip across a drill it opened */
.today-btn { white-space: nowrap; }
.today-btn.left { border-color: var(--accent-deep); color: var(--accent); }
.today-btn .mono { font-size: inherit; margin-left: 3px; }
#dlg-today { max-width: min(560px, calc(100vw - 48px)); }
.today-sub { margin-left: auto; font-size: 12px; }
.today-steps { list-style: none; padding: 10px 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.today-step {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 12px;
  background: none;
  border: 1px solid transparent;
  border-radius: 10px;
  box-shadow: none;
  text-align: left;
  font-size: 13.5px;
  font-weight: 500;
}
.today-step:hover { background: var(--raised); filter: none; }
.today-step.next { background: var(--raised); border-color: var(--accent-deep); }
.ts-ic { width: 22px; flex: none; text-align: center; font-size: 15px; color: var(--muted); }
.today-step.next .ts-ic { color: var(--accent); }
.today-step.done .ts-ic { color: var(--ok); }
.ts-tx { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.ts-t { font-size: 12.5px; }
.ts-d { color: var(--ivory); }
.today-step.done .ts-d { color: var(--muted); }
.ts-xp { flex: none; font-family: var(--mono); font-size: 11.5px; color: var(--accent); }
/* On ivory, brass text needs the deeper shade to reach AA (5.3:1, not 3.4:1). */
[data-theme="light"] .today-btn.left, [data-theme="light"] .ts-xp,
[data-theme="light"] .gm-lv, [data-theme="light"] .wk-num { color: var(--accent-deep); }
.ts-go { flex: none; font-size: 18px; line-height: 1; color: var(--muted); }
.today-foot { display: flex; flex-direction: column; gap: 6px; }
.today-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.today-banner[hidden] { display: none; }
.today-banner .tb-tx { flex: 1; }
.today-banner.done .tb-tx { color: var(--ok); }
.lib-card.lib-daily.done .stats { color: var(--ok); }

/* Keyboard shortcuts overlay */
.sc-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 16px; }
.sc-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); margin-bottom: 8px; }
.sc-row { display: flex; align-items: center; gap: 12px; padding: 5px 0; }
.sc-keys { display: flex; gap: 4px; flex-wrap: wrap; min-width: 150px; }
.sc-desc { font-size: 12.5px; color: var(--ivory, var(--fg)); }
.sc-note { font-size: 11.5px; margin-top: 2px; }
kbd {
  font-family: var(--mono);
  font-size: 11px;
  min-width: 18px;
  text-align: center;
  padding: 3px 6px;
  border-radius: 5px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  color: var(--ivory, var(--fg));
  line-height: 1;
}

/* supported keyboards */
.kb-note { padding: 12px 16px 4px; font-size: 11.5px; line-height: 1.5; }
.kb-note strong { color: var(--ivory); }
.kb-list { padding: 8px 16px 14px; max-height: min(52vh, 520px); overflow-y: auto; }
.kb-section { margin: 12px 0 6px; }
.kb-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--raised);
  margin-bottom: 6px;
}
.kb-name { font-size: 12.5px; font-weight: 600; }
.kb-badges { display: flex; gap: 6px; flex-shrink: 0; }

/* bluetooth button state */
#btn-bluetooth.on { color: var(--accent); border-color: var(--accent-deep); box-shadow: 0 0 8px rgba(233, 180, 76, 0.45); }
#btn-listen.on { color: var(--accent); border-color: var(--accent-deep); box-shadow: 0 0 8px rgba(233, 180, 76, 0.45); }
.mic-meter { display: inline-block; width: 34px; height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; vertical-align: middle; }
.mic-meter > i { display: block; height: 100%; width: 100%; transform-origin: left; transform: scaleX(0); background: var(--accent); transition: transform 0.06s linear; }
.mic-note { font-size: 11px; color: var(--accent); min-width: 2.4em; display: inline-block; vertical-align: middle; }

#dlg-ear { max-width: min(420px, calc(100vw - 32px)); }
#dlg-sheet { max-width: min(780px, calc(100vw - 32px)); }
#dlg-sight { max-width: min(560px, calc(100vw - 32px)); }
#dlg-rhythm { max-width: min(560px, calc(100vw - 32px)); }
#dlg-prog { max-width: min(560px, calc(100vw - 32px)); }
.prog-view { text-align: center; padding: 18px 0 6px; }
.prog-key { color: var(--muted); font-size: 13px; letter-spacing: 0.1em; margin-bottom: 8px; }
.prog-roman { font-size: 30px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted); }
.prog-roman .prog-cur { color: var(--accent); text-decoration: underline; }
.rhythm-tap { font-weight: 700; letter-spacing: 0.1em; padding: 10px 22px; background: var(--accent); color: var(--ebony, #12141b); border: none; }
.rhythm-tap:active { transform: translateY(1px); }
#btn-sheet-play { margin-left: auto; }
#sheet-body svg { max-width: none; } /* keep natural width so the staff can scroll */
.sheet-body { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 0; margin: 8px 0; min-height: 100px; }
.ear-body { padding: 6px 16px 14px; } /* lines up with the .dlg-head title */
.ear-body #ear-msg { display: block; padding: 14px 0; }
.ear-body .row { align-items: center; gap: 10px; }

/* circle of fifths */
.cof-wrap { display: grid; grid-template-columns: minmax(0, 320px) 1fr; gap: 18px; align-items: start; }
.cof-wrap .hint { grid-column: 1 / -1; }
.cof-body { min-width: 0; }
.cof-svg { width: 100%; height: auto; display: block; }
.cof-svg .cof-wedge:hover { fill: var(--raised); }
.cof-maj { fill: var(--ivory); font-size: 15px; font-weight: 500; }
.cof-maj.cof-sel { font-size: 18px; font-weight: 700; fill: var(--accent); }
.cof-min { fill: var(--muted); font-size: 11px; }
.cof-side { display: flex; flex-direction: column; gap: 12px; }
.cof-key { font-size: 20px; font-weight: 600; color: var(--accent); }
.cof-sig { font-size: 13px; color: var(--ivory); margin-top: 2px; }
.cof-chords { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.cof-chord { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 10px; background: var(--raised); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; color: var(--ivory); min-width: 40px; }
.cof-chord b { color: var(--accent); font-size: 12px; }
#btn-circle-play { align-self: flex-start; }
@media (max-width: 620px) { .cof-wrap { grid-template-columns: 1fr; } }

/* scales & modes */
.scale-ctl { align-items: center; gap: 10px; }
.scale-type-sel { min-width: 180px; }
#btn-scale-play { margin-left: auto; }
.scale-blurb { font-style: italic; margin: 8px 0 4px; }
.scale-notes { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.scale-deg { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 44px; padding: 6px 0; background: var(--raised); border: 1px solid var(--line); border-radius: 8px; }
.scale-deg.tonic { background: color-mix(in srgb, var(--accent-deep) 40%, transparent); }
.scale-deg .deg-n { color: var(--muted); font-size: 11px; }
.scale-deg .deg-name { color: var(--ivory); font-size: 15px; font-weight: 600; }
.scale-steps { margin: 6px 0; }
.scale-steps .mono { color: var(--accent); letter-spacing: 1px; }

/* chord ID */
.cid-body { text-align: center; }
.cid-name { font-size: 44px; font-weight: 700; color: var(--accent); padding: 18px 0 6px; min-height: 58px; }
.cid-name.empty { font-size: 22px; color: var(--muted); }
.cid-notes { font-family: ui-monospace, monospace; font-size: 15px; color: var(--muted); padding-bottom: 8px; }

/* chord dictionary (reuses .scale-notes / .scale-deg chips) */
.chordlib-symbol { font-size: 34px; font-weight: 700; color: var(--accent); margin: 10px 0 4px; }

/* sheet practice readout */
.sheet-msg { min-height: 18px; padding: 2px 2px 6px; }
.sheet-msg:empty { display: none; }

/* spaced-repetition review */
.rv-banner { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.rv-banner .rv-count { font-size: 18px; font-weight: 600; }
.rv-banner .rv-count.due { color: var(--accent); }
.rv-banner .rv-count.clear { color: var(--muted); }
.rv-review { text-align: center; padding: 10px 0 16px; }
.rv-review .rv-prompt { color: var(--muted); font-size: 13px; }
.rv-review .rv-name { color: var(--accent); font-size: 28px; font-weight: 700; margin: 8px 0 16px; }
.rv-grades { display: flex; gap: 8px; }
.rv-grades button { flex: 1; padding: 14px 0; font-weight: 600; border: none; border-radius: 8px; cursor: pointer; color: var(--bg); }
.rv-again { background: var(--bad); }
.rv-hard { background: var(--accent-deep); }
.rv-good { background: var(--accent); }
.rv-easy { background: var(--ok); }
.rv-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.rv-item.due { border-color: var(--accent); }
.rv-item .rv-when { color: var(--muted); font-family: ui-monospace, monospace; font-size: 12px; white-space: nowrap; }
.rv-item.due .rv-when { color: var(--accent); }
.rv-item .rv-del { background: none; border: none; color: var(--muted); cursor: pointer; }
.rv-item .rv-del:hover { color: var(--bad); }

/* jam mode */
.jam-ctl { align-items: center; gap: 10px; flex-wrap: wrap; }
.jam-ctl #jam-bpm { width: 64px; }
#btn-jam-play { margin-left: auto; }
.jam-prog { font-size: 30px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted); margin: 14px 0; text-align: center; }
.jam-prog .jam-chord { padding: 2px 8px; }
.jam-prog .jam-cur { color: var(--accent); background: color-mix(in srgb, var(--accent-deep) 35%, transparent); border-radius: 6px; }
.jam-scale { text-align: center; color: var(--ivory); font-family: ui-monospace, monospace; font-size: 15px; }

/* practice journal */
.jr-stats { color: var(--muted); font-size: 12px; }
.jr-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.jr-add #jr-focus { flex: 2 1 160px; }
.jr-add #jr-notes { flex: 3 1 200px; }
.jr-add #jr-min { width: 64px; }
.jr-add input { background: var(--raised); color: var(--ivory); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.jr-list { max-height: 46vh; overflow-y: auto; }
.jr-entry { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.jr-entry .jr-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.jr-entry .jr-focus { color: var(--ivory); font-weight: 600; }
.jr-entry .jr-meta { color: var(--accent); font-family: ui-monospace, monospace; font-size: 12px; white-space: nowrap; }
.jr-entry .jr-date { color: var(--muted); font-size: 12px; }
.jr-entry .jr-notes { color: var(--ivory); font-size: 13px; margin-top: 4px; }
.jr-entry .jr-del { float: right; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.jr-entry .jr-del:hover { color: var(--bad); }
.jr-empty { color: var(--muted); text-align: center; padding: 20px; font-size: 14px; }

/* note-names drill */
.notename-keys { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0; }
.notename-keys button { width: 56px; height: 48px; font-size: 18px; font-weight: 700; background: var(--raised); color: var(--ivory); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.notename-keys button:hover:not(:disabled) { border-color: var(--accent); }
.notename-keys button.correct { background: var(--ok); color: var(--bg); border-color: var(--ok); }
.notename-keys button.wrong { background: var(--bad); color: var(--bg); border-color: var(--bad); }
.notename-keys button:disabled { cursor: default; }

/* key-signatures drill */
.keysig-sig { min-height: 90px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; padding: 10px; }
.keysig-label { color: var(--muted); font-size: 13px; }
.keysig-acc { display: flex; gap: 10px; }
.keysig-acc span { color: var(--accent); font-size: 30px; font-weight: 700; }
.keysig-none { color: var(--muted); font-size: 18px; }
.keysig-keys { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 8px 0; }
.keysig-keys button { min-width: 84px; height: 46px; padding: 0 12px; font-size: 15px; font-weight: 600; background: var(--raised); color: var(--ivory); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.keysig-keys button:hover:not(:disabled) { border-color: var(--accent); }
.keysig-keys button.correct { background: var(--ok); color: var(--bg); border-color: var(--ok); }
.keysig-keys button.wrong { background: var(--bad); color: var(--bg); border-color: var(--bad); }
.keysig-keys button:disabled { cursor: default; }

/* build-an-interval drill */
.interval-prompt { text-align: center; padding: 18px 0 6px; }
.interval-prompt .iv-small { color: var(--muted); font-size: 13px; }
.interval-prompt .iv-name { color: var(--accent); font-size: 30px; font-weight: 700; }
.interval-prompt .iv-ref { color: var(--ivory); font-size: 22px; font-weight: 600; }
.interval-prompt .cb-sym { color: var(--accent); font-size: 40px; font-weight: 700; }

/* chromatic tuner */
.tuner-body { text-align: center; }
.tuner-note { font-size: 64px; font-weight: 700; color: var(--ivory); padding: 10px 0 4px; min-height: 76px; transition: color 0.12s; }
.tuner-note.in-tune { color: var(--ok); }
.tuner-meter { position: relative; height: 44px; margin: 8px 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tuner-center { position: absolute; left: 50%; top: 4px; bottom: 4px; width: 2px; background: var(--ok); opacity: 0.6; transform: translateX(-50%); }
.tuner-needle { position: absolute; left: 50%; top: 2px; bottom: 2px; width: 4px; border-radius: 2px; background: var(--accent); transform: translateX(-50%); transition: left 0.08s linear; }
.tuner-read { margin-top: 6px; }
.tuner-read #tuner-cents { color: var(--accent); font-size: 18px; }
#btn-bluetooth.busy { animation: pulse 1.1s ease-in-out infinite; }

/* link-style button */
.linklike {
  background: none;
  border: 0;
  box-shadow: none;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px;
  cursor: pointer;
}
.linklike:hover { text-decoration: underline; filter: none; }

/* ------------------------------------------------------------- Pro / plans */
.pro-badge {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent-ink);
  background: linear-gradient(#f0c45c, #d99e2f);
  border-radius: 4px;
  padding: 1px 5px;
  align-self: center;
}
.upgrade-btn {
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  border-color: var(--accent-deep);
  background: transparent;
  box-shadow: none;
}
.upgrade-btn:hover { background: rgba(233, 180, 76, 0.12); filter: none; }

/* Practice-tools launcher: one header button → a dialog of labelled cards. */
.tools-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 12px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
}
#dlg-tools { max-width: min(760px, calc(100vw - 48px)); }
.tools-hint { flex: 1; font-size: 11px; }
.tools-body { padding: 2px 16px 16px; max-height: min(70vh, 640px); overflow-y: auto; }
.tools-sec {
  margin: 14px 0 8px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted);
}
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.tool {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 10px 12px; border-radius: 10px;
  background: var(--raised); border-color: var(--line); box-shadow: none;
}
.tool:hover { border-color: var(--accent-deep); filter: none; }
.tool-ic { flex: none; width: 28px; font-size: 18px; text-align: center; }
.tool-tx { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tool-tx b { font-size: 13px; font-weight: 600; }
.tool-tx small {
  font-size: 11px; font-weight: 400; color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.lib-nudge { text-align: left; cursor: pointer; border-style: dashed; }
.lib-nudge:hover { border-color: var(--accent); }

#dlg-plans { max-width: 420px; }
.plans-wrap { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 28px 30px 22px; }
.plans-hero { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.plans-title { font-size: 17px; font-weight: 700; letter-spacing: 0.2em; display: flex; align-items: center; gap: 8px; }
.plans-tag { color: var(--accent); font-size: 12.5px; font-weight: 600; }
.plans-reason { font-size: 12px; color: var(--muted); line-height: 1.55; background: var(--raised); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.plans-card { width: 100%; background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.plans-cycle { display: inline-flex; background: var(--tabs-bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.plans-cycle button { border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 600; padding: 5px 14px; border-radius: 999px; box-shadow: none; }
.plans-cycle button.active { background: var(--raised-hi); color: var(--ivory); }
.plans-priceline { display: flex; align-items: baseline; gap: 3px; }
.plans-price { font-size: 30px; font-weight: 700; }
.plans-per { font-size: 13px; color: var(--muted); }
.plans-sub { font-size: 11px; }
.plans-features { list-style: none; text-align: left; width: 100%; display: flex; flex-direction: column; gap: 6px; margin: 4px 0; }
.plans-features li { font-size: 12px; padding-left: 20px; position: relative; color: var(--ivory); line-height: 1.4; }
.plans-features li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 700; }
.plans-subscribe { width: 100%; padding: 10px; font-size: 13px; }
.plans-redeem { display: flex; gap: 6px; width: 100%; margin-top: 8px; }
.plans-redeem input { flex: 1; background: var(--panel); border: 1px solid var(--btn-border); border-radius: 7px; color: var(--ivory); font-size: 12px; padding: 7px 10px; outline: none; }
.plans-redeem input:focus-visible { outline: 2px solid var(--accent); }
.plans-active { color: var(--ok); font-size: 12.5px; font-weight: 600; }
.plans-fine { font-size: 10.5px; line-height: 1.5; }
.plans-close { margin-top: 2px; }

/* about */
.about-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 30px 34px 24px;
  max-width: 460px;
  margin: 0 auto;
}
.about-name { font-size: 17px; font-weight: 700; letter-spacing: 0.24em; }
.about-tag { color: var(--accent); font-size: 12.5px; font-weight: 600; }
/* Small brass text on the ivory theme's panels needs the deeper brass for AA. */
[data-theme="light"] .about-tag,
[data-theme="light"] .plans-tag { color: var(--accent-deep); }
.about-body { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.about-links { justify-content: center; }
.about-credits { font-size: 11px; line-height: 1.7; }
.about-close { margin-top: 6px; }

/* onboarding */
#dlg-onboard { max-width: 460px; }
/* The [hidden] attribute is display:none, but a bare `.ob-step { display:flex }`
   would override it and show every step at once — so hidden steps are hidden
   with a higher-specificity rule that wins. */
.ob-step[hidden] { display: none; }
.ob-step {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 30px 34px 24px;
  text-align: center;
  align-items: center;
}
.ob-step h1 { font-size: 17px; letter-spacing: 0.06em; }
.ob-step p { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.ob-label { font-size: 11px; color: var(--muted); }
.ob-step input[type="text"] {
  background: var(--raised);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--ivory);
  font-size: 13px;
  padding: 8px 12px;
  width: 240px;
  text-align: center;
  outline: none;
}
.ob-step input[type="text"]:focus-visible { outline: 2px solid var(--accent); }
.ob-step select { width: 240px; max-width: 240px; font-size: 12px; padding: 7px 24px 7px 10px; }
.ob-status { color: var(--accent); font-size: 12px; }
.ob-nav { display: flex; gap: 10px; margin-top: 8px; }
.ob-levels { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.ob-level {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  padding: 10px 14px;
}
.ob-level span { font-size: 11px; color: var(--dim); font-weight: 400; }
.ob-level.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* Learn-mode lesson progress bar + restart */
.learn-progress {
  height: 4px;
  background: var(--raised);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
  width: 100%;
}
#learn-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  transition: width .15s;
}
#btn-lesson-restart {
  padding: 8px 12px;
  font-size: 15px;
  line-height: 1;
}

/* Practice calendar — "don't break the chain" */
.cal-wrap {
  background: var(--panel);
  border: 1px solid var(--line, #2a2f3f);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 12px 0;
}
.cal-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.cal-title { font-weight: 600; font-size: 14px; }
.cal-sub { font-size: 12px; color: var(--dim); }
.cal-months {
  display: flex;
  gap: 3px;
  margin-bottom: 3px;
  padding-left: 0;
}
.cal-mon {
  width: 13px;
  font-size: 9px;
  color: var(--dim);
  white-space: nowrap;
  overflow: visible;
  line-height: 1;
}
.cal-grid { display: flex; gap: 3px; }
.cal-col { display: flex; flex-direction: column; gap: 3px; }
.cal-cell {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: var(--raised);
  display: inline-block;
}
.cal-cell[data-lv="1"] { background: rgba(233, 180, 76, .30); }
.cal-cell[data-lv="2"] { background: rgba(233, 180, 76, .55); }
.cal-cell[data-lv="3"] { background: rgba(233, 180, 76, .80); }
.cal-cell[data-lv="4"] { background: var(--accent); }
.cal-future { background: transparent; }
.cal-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  margin-top: 10px;
  font-size: 11px;
  color: var(--dim);
}
.cal-legend .cal-cell { width: 11px; height: 11px; }

/* This week beside last week, on the progress dashboard */
.wk-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.wk-stat { display: flex; flex-direction: column; gap: 1px; }
.wk-num { font-size: 20px; font-weight: 700; color: var(--accent); }
.wk-lbl { font-size: 11px; color: var(--muted); }
.wk-vs { font-size: 11px; color: var(--ivory); margin-top: 2px; }
.wk-vs.down { color: var(--muted); }
