/* Fretwise — layout: fixed left sidebar (desktop) / bottom tab bar (phone) around one calm working column.
   Neutral charcoal or paper-white surfaces, one amber accent for actions and root notes; the fretboard keeps its wood. */
:root {
  --bg: #f4f5f3;
  --surface: #ffffff;
  --surface-2: #eceeea;
  --line: #dfe2dc;
  --fg: #1a1d1b;
  --muted: #5f6762;
  --accent: #b45f06;         /* amber: actions, roots, current item */
  --accent-ink: #ffffff;
  --accent-soft: #fcefdf;
  --cool: #1f7a6c;           /* teal: chord tones, live listening */
  --cool-soft: #dcefeb;
  --good: #2c7a39;
  --good-soft: #def0df;
  --bad: #b3362b;
  --bad-soft: #f8e0dd;
  --on-strong: #ffffff;     /* text on teal/green/red dots */
  --shadow: 0 1px 2px rgb(20 24 22 / 0.05), 0 4px 16px rgb(20 24 22 / 0.04);
  /* fretboard: maple neck in light mode */
  --board: #e4c48f;
  --board-edge: #cfa865;
  --fret: #9a958c;
  --nut: #fbf8f1;
  --string: #6d6559;
  --inlay: #3b2a1e;
  --dot-tone: #2a2420;
  --dot-tone-ink: #fbf8f1;

  --font-display: 'Bricolage Grotesque', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --radius: 12px;
  --radius-lg: 16px;
  --maxw: 1040px;
  --side-w: 236px;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121413; --surface: #1a1d1b; --surface-2: #242826; --line: #2f3431;
    --fg: #eef0ec; --muted: #9ba49e; --accent: #f0a43a; --accent-ink: #1b1206; --accent-soft: #3a2a14;
    --cool: #5cc2ae; --cool-soft: #183632; --good: #7fcf88; --good-soft: #1c3320; --bad: #f28a7e; --bad-soft: #3e201c; --on-strong: #121413;
    --shadow: none;
    --board: #3a2219; --board-edge: #241510; --fret: #b9b4ab; --nut: #efe6d4; --string: #d6ccbb; --inlay: #e9dfcb;
    --dot-tone: #efe9de; --dot-tone-ink: #1a1d1b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121413; --surface: #1a1d1b; --surface-2: #242826; --line: #2f3431;
  --fg: #eef0ec; --muted: #9ba49e; --accent: #f0a43a; --accent-ink: #1b1206; --accent-soft: #3a2a14;
  --cool: #5cc2ae; --cool-soft: #183632; --good: #7fcf88; --good-soft: #1c3320; --bad: #f28a7e; --bad-soft: #3e201c; --on-strong: #121413;
  --shadow: none;
  --board: #3a2219; --board-edge: #241510; --fret: #b9b4ab; --nut: #efe6d4; --string: #d6ccbb; --inlay: #e9dfcb;
  --dot-tone: #efe9de; --dot-tone-ink: #1a1d1b;
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; z-index: 50; border-radius: 8px; }
.skip:focus { left: 8px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; align-self: flex-start;
  width: var(--side-w); height: 100vh; flex: none;
  display: flex; flex-direction: column; gap: 22px;
  padding: max(22px, env(safe-area-inset-top, 0px)) 14px 18px max(14px, env(safe-area-inset-left, 0px));
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
}
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); padding: 0 8px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--accent);
  display: grid; place-items: center; flex: none;
}
.brand-mark svg { width: 22px; height: 22px; fill: none; stroke: var(--accent-ink); stroke-width: 1.5; }
.brand-mark svg circle { fill: var(--accent-ink); stroke: none; }
.brand-name { font: 800 21px/1 var(--font-display); letter-spacing: -0.02em; }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; flex: none; display: block; }

.nav-side { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--muted); font: 600 15px var(--font-body);
  padding: 10px 12px; border-radius: 10px; min-height: 44px;
  transition: background .15s, color .15s;
}
.nav a svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { color: var(--fg); background: var(--surface-2); }
.nav a.on { color: var(--accent); background: var(--accent-soft); }

.side-settings {
  margin-top: auto; display: flex; flex-direction: column; gap: 10px;
  padding: 14px 10px 4px; border-top: 1px solid var(--line);
}
.side-label { font: 600 11.5px var(--font-body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.side-settings .seg { display: flex; }
.side-settings .seg button { flex: 1; }
.side-settings select { width: 100%; }
.side-more { align-self: flex-start; }

.topbar {
  display: none; position: sticky; top: 0; z-index: 20;
  align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { padding: 0; }
.inst-btn {
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
  background: var(--surface); color: var(--fg); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; min-height: 40px; font: 600 14px var(--font-body); cursor: pointer;
}
.inst-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .15s; }
.inst-btn[aria-expanded="true"] svg { transform: rotate(180deg); }

.settings { border-bottom: 1px solid var(--line); background: var(--surface); }
.settings-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: end;
  padding-block: 18px 20px;
  padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px));
}
.settings-head { flex-basis: 100%; display: flex; align-items: center; justify-content: space-between; }
.settings-head h2 { font-size: 20px; }

.nav-tabbar { display: none; }

@media (max-width: 959px) {
  .sidebar { display: none; }
  .topbar { display: flex; }
  .nav-tabbar {
    display: grid; grid-template-columns: repeat(6, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px max(6px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
  }
  .nav-tabbar a {
    flex-direction: column; gap: 3px; padding: 6px 2px; min-height: 52px;
    font-size: 11.5px; font-weight: 600; justify-content: center; text-align: center;
  }
  .nav-tabbar a.on { background: transparent; }
  .nav-tabbar a.on svg { background: var(--accent-soft); border-radius: 999px; padding: 3px 12px; width: 48px; height: 28px; }
  .main-col { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  .settings-inner { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
}

/* ---------- page ---------- */
.view {
  flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto;
  padding-block: 36px 72px;
  padding-left: max(28px, env(safe-area-inset-left, 0px));
  padding-right: max(28px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 28px;
}
@media (max-width: 959px) {
  .view { padding-block: 22px 40px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); gap: 22px; }
}
.view:focus { outline: none; }
.foot { color: var(--muted); font-size: 13px; text-align: center; padding: 18px 16px 24px; }
.foot p { margin: 0; }

h1, h2, h3 { text-wrap: balance; margin: 0; color: var(--fg); }
h1 { font: 800 clamp(30px, 4vw, 42px)/1.1 var(--font-display); letter-spacing: -0.025em; }
h2 { font: 700 23px/1.2 var(--font-display); letter-spacing: -0.015em; }
h3 { font: 650 17px/1.35 var(--font-body); font-weight: 650; }
p { margin: 0; }
.view-head { display: flex; flex-direction: column; gap: 8px; }
.lede { color: var(--muted); font-size: 17.5px; line-height: 1.55; max-width: 62ch; }
.crumb {
  display: inline-flex; align-items: center; gap: 4px; width: fit-content;
  font: 600 14px var(--font-body); text-decoration: none; color: var(--muted);
  padding: 4px 10px 4px 6px; margin-left: -6px; border-radius: 8px;
}
.crumb:hover { color: var(--fg); background: var(--surface-2); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.mono { font-family: var(--font-mono); }
.eyebrow { font: 600 12px var(--font-body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }

/* ---------- layout helpers ---------- */
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 16px; }
.grid-2 > *, .grid-3 > * { min-width: 0; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px; display: flex; flex-direction: column; gap: 16px; min-width: 0;
}
.panel > h2 { font-size: 20px; }
@media (max-width: 600px) { .panel { padding: 16px; border-radius: var(--radius); } }
.controls {
  display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: end;
  padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2);
}
.panel .controls { background: transparent; padding: 0; }

/* ---------- cards (section index) ---------- */
.card-group { display: flex; flex-direction: column; gap: 12px; }
.group-title { font: 600 13px var(--font-body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 248px), 1fr)); gap: 12px; }
.card {
  position: relative;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px 16px; text-decoration: none; color: var(--fg);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); transform: translateY(-1px); }
.card h3 { padding-right: 18px; }
.card::after {
  content: ''; position: absolute; right: 16px; top: 20px; width: 7px; height: 7px;
  border-right: 2px solid var(--muted); border-top: 2px solid var(--muted); transform: rotate(45deg); opacity: 0.5;
}
.card:hover::after { border-color: var(--accent); opacity: 1; }
.card p { color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.card .chips { margin-top: auto; padding-top: 6px; }
.card.done h3::after { content: ' ✓'; color: var(--good); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 600 12px/1.5 var(--font-body);
  padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.cool { background: var(--cool-soft); color: var(--cool); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 15px var(--font-body); padding: 10px 16px; border-radius: 10px; cursor: pointer;
  background: var(--surface); color: var(--fg); border: 1px solid var(--line);
  text-decoration: none; min-height: 44px; line-height: 1.2;
  transition: background .15s, border-color .15s, filter .15s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--fg); }
.btn.small { padding: 6px 12px; font-size: 14px; min-height: 36px; border-radius: 8px; }
.btn.big { font-size: 17px; padding: 13px 22px; min-height: 52px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn.good { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.btn.bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn kbd { opacity: 0.7; }

.answers { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.answers .btn { min-height: 52px; }

.seg {
  display: inline-flex; background: var(--surface-2); border-radius: 10px;
  padding: 3px; gap: 2px; flex-wrap: wrap;
}
.seg button {
  font: 600 14px var(--font-body); border: 0; background: transparent; color: var(--muted);
  padding: 7px 13px; min-height: 36px; border-radius: 8px; cursor: pointer;
}
.seg button:hover { color: var(--fg); }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 500; }
.field > span { font: 600 12px var(--font-body); letter-spacing: 0.05em; text-transform: uppercase; }
select, input[type="text"], input[type="number"], input[type="url"], input[type="search"], input[type="password"] {
  font: 500 15px var(--font-body); color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-height: 44px;
}
select:hover, input:hover { border-color: var(--muted); }
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
input[type="range"] { accent-color: var(--accent); min-width: 140px; }
input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; min-height: 36px; }

/* ---------- quiz bits ---------- */
.prompt { font: 700 clamp(26px, 4vw, 34px)/1.15 var(--font-display); letter-spacing: -0.02em; }
.big-note { font: 800 clamp(64px, 13vw, 112px)/0.95 var(--font-display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.feedback { min-height: 1.6em; font-weight: 600; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }
.score-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stat {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface-2); border-radius: 10px; padding: 8px 14px;
}
.stat b { font: 700 22px/1.2 var(--font-display); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 500; }

.meter { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .2s; }

/* ---------- fretboard ---------- */
.fb-wrap { overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; border-radius: 8px; }
.fb { display: block; width: 100%; height: auto; user-select: none; }
/* Upright neck on phones: fills the width, no sideways scrolling; capped so it never gets huge. */
.fb-wrap.upright { overflow-x: visible; }
.fb-wrap.upright .fb { max-width: 420px; margin: 0 auto; }
.fb-board { fill: var(--board); stroke: var(--board-edge); stroke-width: 1; }
.fb-fret { stroke: var(--fret); stroke-width: 2.4; }
.fb-nut { stroke: var(--nut); stroke-width: 7; }
.fb-string { stroke: var(--string); }
.fb-inlay { fill: var(--inlay); opacity: 0.32; }
.fb-strname { font: 600 13px var(--font-mono); fill: var(--muted); }
.fb-num { font: 500 11px var(--font-mono); fill: var(--muted); opacity: 0.7; }
.fb-num.strong { opacity: 1; font-weight: 600; }
.fb-hit { fill: transparent; }
.fb-hit.clickable { cursor: pointer; }
.fb-hit.clickable:hover { fill: color-mix(in srgb, var(--accent) 22%, transparent); }
.fb-ghostname { font: 500 10px var(--font-mono); fill: var(--fg); opacity: 0.45; pointer-events: none; }
.fb-dot { pointer-events: none; }
.fb-dot text { font: 600 11px var(--font-mono); }
.fb-dot circle { stroke-width: 1.5; }
.fb-dot.tone circle { fill: var(--dot-tone); stroke: var(--dot-tone); }
.fb-dot.tone text { fill: var(--dot-tone-ink); }
.fb-dot.root circle { fill: var(--accent); stroke: var(--accent); }
.fb-dot.root text { fill: var(--accent-ink); }
.fb-dot.accent circle { fill: var(--cool); stroke: var(--cool); }
.fb-dot.accent text { fill: var(--on-strong); }
.fb-dot.hit circle { fill: var(--good); stroke: var(--good); }
.fb-dot.hit text { fill: var(--on-strong); }
.fb-dot.miss circle { fill: var(--bad); stroke: var(--bad); }
.fb-dot.miss text { fill: var(--on-strong); }
.fb-dot.ghost circle { fill: transparent; stroke: var(--dot-tone); stroke-dasharray: 3 2; opacity: 0.7; }
.fb-dot.ghost text { fill: var(--dot-tone); }
.fb-dot.active circle { fill: var(--fg); stroke: var(--accent); stroke-width: 3; }
.fb-dot.active text { fill: var(--bg); }
.fb-dot.flash { animation: pop .7s ease-out forwards; transform-box: fill-box; transform-origin: center; }
@keyframes pop { 0% { transform: scale(0.6); opacity: 1; } 70% { opacity: 1; } 100% { transform: scale(1.25); opacity: 0; } }

/* ---------- chord diagrams ---------- */
.chord-box { display: block; }
.cb-title { font: 700 19px var(--font-display); fill: var(--fg); }
.cb-bg { fill: var(--surface-2); }
.cb-fret { stroke: var(--fret); stroke-width: 1.5; }
.cb-nut { stroke: var(--fg); stroke-width: 5; }
.cb-string { stroke: var(--string); stroke-width: 1.3; }
.cb-dot { fill: var(--fg); }
.cb-barre { fill: var(--fg); }
.cb-finger { font: 600 11px var(--font-mono); fill: var(--bg); }
.cb-open { fill: none; stroke: var(--fg); stroke-width: 1.6; }
.cb-mute { font: 600 15px var(--font-body); fill: var(--muted); }
.cb-base { font: 500 11px var(--font-mono); fill: var(--muted); }
.cb-label { font: 600 11px var(--font-mono); fill: var(--accent); }
.chord-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.chord-tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer;
  font: inherit; color: inherit; transition: border-color .15s;
}
.chord-tile:hover { border-color: var(--accent); }

/* ---------- lessons / prose ---------- */
.prose { max-width: 68ch; display: flex; flex-direction: column; gap: 14px; font-size: 17px; line-height: 1.7; }
.prose h2 { margin-top: 18px; }
.prose h3 { margin-top: 6px; }
.prose ul, .prose ol { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; }
.prose code, code { font-family: var(--font-mono); font-size: 0.88em; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }
.tab {
  font: 14px/1.4 var(--font-mono); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; margin: 0; white-space: pre;
}
.callout {
  background: var(--accent-soft); border-radius: var(--radius); padding: 14px 18px;
  display: flex; flex-direction: column; gap: 6px; max-width: 68ch;
}
.callout b:first-child { color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; }
.callout.cool { background: var(--cool-soft); }
.callout.cool b:first-child { color: var(--cool); }
.figure {
  display: flex; flex-direction: column; gap: 10px; margin: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 16px;
}
.figure figcaption, .figure .caption { font-size: 14px; color: var(--muted); }
table { border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }

kbd { font: 11px var(--font-mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--surface); color: var(--muted); }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px);
  background: var(--fg); color: var(--bg); padding: 11px 18px; border-radius: 10px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 40; max-width: calc(100vw - 32px);
}
@media (max-width: 959px) { #toast { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px)); } }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- home ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 32px; align-items: center;
}
.hero > * { min-width: 0; }
.hero h1 { font-size: clamp(34px, 4.6vw, 50px); line-height: 1.05; }
.hero h1 em { font-style: normal; color: var(--accent); }
@media (max-width: 860px) { .hero { grid-template-columns: minmax(0, 1fr); gap: 22px; } }

/* Empty status lines shouldn't leave gaps; feedback lines keep their height to avoid jumps. */
.panel > p:empty:not(.feedback), .stack > p:empty:not(.feedback) { display: none; }

/* ---------- shared simplifiers ---------- */
.grow { flex: 1 1 200px; min-width: 0; }

/* Numbered steps for guided pages (the number is the real order). */
.step-head { display: flex; align-items: center; gap: 12px; }
.step-num {
  width: 30px; height: 30px; border-radius: 999px; flex: none; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font: 700 15px var(--font-body);
}

/* Fold-outs keep secondary options out of the way until needed. */
.fold > summary, .fold-panel > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px;
  font-weight: 600; color: var(--muted); min-height: 36px;
}
.fold > summary::-webkit-details-marker, .fold-panel > summary::-webkit-details-marker { display: none; }
.fold > summary::before, .fold-panel > summary::before {
  content: ''; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s; flex: none; margin-right: 2px;
}
.fold[open] > summary::before, .fold-panel[open] > summary::before { transform: rotate(45deg); }
.fold > summary:hover { color: var(--fg); }
.fold[open] { display: flex; flex-direction: column; gap: 12px; }
.fold-panel > summary { flex-wrap: wrap; color: var(--fg); }
.fold-panel > summary h2 { font-size: 20px; }
.fold-panel[open] > summary { margin-bottom: 4px; }

/* Section pages: group filter and calmer cards */
.group-filter { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; align-self: flex-start; scrollbar-width: none; }
.group-filter button { white-space: nowrap; }
.card p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Account link (sidebar + settings) and account page */
.acct-link {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg);
  padding: 8px 10px; border-radius: 10px; border: 1px dashed var(--line); min-height: 48px;
}
.acct-link:hover { background: var(--surface-2); border-color: var(--accent); }
.acct-link.in { border-style: solid; }
.acct-dot {
  width: 30px; height: 30px; border-radius: 999px; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font: 700 15px var(--font-body);
}
.acct-link.in .acct-dot { background: var(--accent); color: var(--accent-ink); }
.acct-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.acct-text b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-text span { font-size: 12px; color: var(--muted); }
.settings-account { flex-basis: 100%; max-width: 320px; }
.acct-head { display: flex; align-items: center; gap: 14px; }
.acct-avatar {
  width: 48px; height: 48px; border-radius: 999px; flex: none; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font: 800 22px var(--font-display);
}
.acct-form { display: flex; flex-direction: column; gap: 14px; max-width: 380px; }
.acct-form .seg { align-self: flex-start; }
.acct-form input { width: 100%; }

/* Back to the app list, and MIDI settings */
.all-apps { font: 600 13px var(--font-body); color: var(--muted); text-decoration: none; padding: 2px 8px; border-radius: 6px; width: fit-content; }
.all-apps:hover { color: var(--fg); background: var(--surface-2); }
.all-apps.icon { font-size: 18px; padding: 4px 8px; }
.midi-field { min-width: 220px; max-width: 320px; }
.midi-field select { width: 100%; }
.topbar .row { flex-wrap: nowrap; }
