:root {
  --bg: #fbfaf7; --surface: #efede7; --text: #1d2126; --muted: #5d6670; --accent: #2f5f8f; --accent-text: #fff;
  --on: #d6e4f2; --error: #b3261e; --good: #2e9d5b; --bad: #d8432f; --line: #d5d2ca;
  color-scheme: light;
}
/* Dark: warm espresso browns, cream text, honey accent */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="pastel"]) {
    --bg: #1a1613; --surface: #26201b; --text: #efe6da; --muted: #b3a493; --accent: #e8b46b; --accent-text: #2a1a06;
    --on: #4a3a29; --error: #ffb4a0; --line: #3a312a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1613; --surface: #26201b; --text: #efe6da; --muted: #b3a493; --accent: #e8b46b; --accent-text: #2a1a06;
  --on: #4a3a29; --error: #ffb4a0; --line: #3a312a; color-scheme: dark;
}
* { box-sizing: border-box; }
/* hidden always hides, whatever display a class gives (e.g. the Target-note row in Free singing) */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { display: flex; flex-direction: column; height: 100dvh; }
main { flex: 1; overflow: auto; min-height: 0; }
.page { max-width: 760px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-left)) 24px; }
h1 { font-size: 1.5rem; font-weight: 500; margin: 8px 0 12px; }
h3 { margin: 0 0 8px; font-weight: 500; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .error { color: var(--error); }
.row { display: flex; gap: 8px; align-items: center; margin: 10px 0; } .wrap { flex-wrap: wrap; } .end { justify-content: flex-end; } .center { justify-content: center; }
.grow { flex: 1; min-width: 0; }
button, a.text { font: inherit; cursor: pointer; border-radius: 999px; padding: 8px 16px; border: 0; background: none; color: var(--accent); text-decoration: none; }
button:disabled { opacity: .45; cursor: default; }
button.filled { background: var(--accent); color: var(--accent-text); }
button.outlined { border: 1px solid var(--line); color: var(--text); }
button.icon-btn { padding: 6px 12px; font-size: 1.2rem; color: var(--text); }
button.chip { border: 1px solid var(--line); color: var(--text); padding: 6px 12px; border-radius: 8px; white-space: nowrap; }
button.chip.on { background: var(--on); border-color: transparent; }
/* Rows of chips wrap onto more lines (nothing hidden off-screen on a phone: the voice chips, the options under
   the music, takes, settings) */
.chips { display: flex; gap: 8px; row-gap: 10px; align-items: center; flex-wrap: wrap; padding: 5px 0; }
/* Touch targets: at least 44 px in the Comfortable layout. Chips look 36 px tall (they come in wrapped rows
   under the music) but answer a tap 46 px tall: an invisible margin that fills the 10 px gap between rows. */
button { min-height: 44px; }
button.icon-btn { min-width: 44px; }
button.chip { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; min-width: 44px; position: relative; }
.menu button { min-height: 46px; }
button.chip::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: max(100%, 46px); transform: translateY(-50%); }
button.chip[aria-disabled="true"] { opacity: .45; }
button.text.danger { color: var(--error); }
button.text.badge { padding: 0; font-size: .8rem; font-weight: 600; text-align: left; }
button.outlined.update { color: var(--accent); border-color: var(--accent); white-space: normal; text-align: center; flex: 0 1 11em; border-radius: 18px; }
header.bar h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
label.switch { cursor: pointer; }
label.switch input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
/* "A new version is ready · Reload" */
.updatebar { display: flex; align-items: center; gap: 10px; background: var(--on); color: var(--text); padding: 6px max(12px, env(safe-area-inset-left)); padding-top: max(6px, env(safe-area-inset-top)); }
/* a dot on the Scores tab when a downloaded piece has a corrected version */
nav button { position: relative; }
nav button.dot::before { content: ''; position: absolute; top: 4px; right: 12px; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--surface); }
textarea, select, input[type=text] { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
textarea { width: 100%; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 10px; padding: 8px 8px 8px 14px; cursor: pointer; min-height: 56px; }
.item .icon { width: 26px; font-size: 1.25rem; }
.item .title { font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; }
.item .sub { font-size: .8rem; color: var(--muted); }
.more { position: relative; }
.menu { position: absolute; right: 0; top: 100%; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; min-width: 140px; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.menu[hidden] { display: none; }
.menu button { text-align: left; color: var(--text); border-radius: 0; }
.card { background: var(--surface); border-radius: 12px; padding: 12px; margin: 12px 0; }
nav { display: flex; justify-content: space-around; background: var(--surface); padding: 4px 0 max(6px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
nav button { display: flex; flex-direction: column; align-items: center; color: var(--muted); font-size: .8rem; padding: 4px 18px; border-radius: 16px; }
nav button span { font-size: 1.3rem; }
nav button.on { color: var(--text); background: var(--on); }
/* Reading a score: the notation takes the screen. */
.reader { display: flex; flex-direction: column; height: 100%; }
header.bar { display: flex; align-items: center; gap: 4px; padding: 4px max(8px, env(safe-area-inset-left)); padding-top: max(4px, env(safe-area-inset-top)); }
header.bar .title { font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header.bar h1 { margin: 0; font-size: 1.3rem; }
/* (never squeezed to nothing when many panels are open: the page scrolls instead) */
iframe.score, iframe.pdf { flex: 1; width: 100%; border: 0; background: #fbfaf7; min-height: 160px; }
.controls { background: var(--surface); padding: 6px 10px 8px; border-top: 1px solid var(--line); }
.transport { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; row-gap: 4px; }
.transport button { flex: none; }
.transport input[type=range] { flex: 1 1 90px; width: auto; min-width: 70px; max-width: 160px; }
button.play { width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: 1.3rem; padding: 0; }
.bar-label { min-width: 74px; } .tempo-label { min-width: 40px; text-align: right; }
dialog { border: 0; border-radius: 16px; background: var(--surface); color: var(--text); max-width: min(92vw, 520px); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog.sheet { width: min(96vw, 620px); }
.mix-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.mix-row .name { min-width: 120px; text-align: left; color: var(--text); padding-left: 0; }
.octave { display: inline-flex; align-items: center; gap: 2px; font-size: .85rem; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; display: inline-block; margin: 0 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.tuner { text-align: center; }
.tuner-note { font-size: 4.5rem; font-weight: 300; margin-top: 10px; }
.tuner-cents { font-size: 1.2rem; margin-bottom: 14px; }
.gauge { position: relative; height: 26px; background: var(--surface); border-radius: 13px; margin: 10px auto; max-width: 520px; overflow: hidden; }
.gauge .zone { position: absolute; top: 0; bottom: 0; background: rgba(46,157,91,.35); }
.gauge .mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: var(--muted); }
.needle { position: absolute; top: 2px; bottom: 2px; width: 6px; margin-left: -3px; border-radius: 3px; background: var(--muted); left: 50%; transition: left .08s linear; }
.needle.good { background: var(--good); } .needle.off { background: var(--bad); }

/* ---- panels under the music: tuner strip, metronome, recorder, keyboard ---- */
.extras { background: var(--surface); border-top: 1px solid var(--line); }
.extras:empty { display: none; }
.extras > * { border-bottom: 1px solid var(--line); }
.row.tight { margin: 4px 0; gap: 6px; }
.col { display: flex; flex-direction: column; }
button.left { text-align: left; }
button.on-text { background: var(--on); }
button.small-play { width: 44px; height: 44px; font-size: 1rem; }
.tstrip { display: flex; gap: 8px; padding: 6px 10px; height: 96px; }
.ts-left { width: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ts-note { font-size: 1.7rem; font-weight: 600; }
.ts-cents { font-size: .8rem; color: var(--muted); }
.tstrip[data-tune="good"] .ts-note, .tstrip[data-tune="good"] .ts-cents { color: var(--good); }
.tstrip[data-tune="off"] .ts-note, .tstrip[data-tune="off"] .ts-cents { color: var(--bad); }
.ts-right { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ts-bar { position: relative; height: 12px; border-radius: 6px; background: var(--bg); overflow: hidden; flex: none; }
.ts-zone { position: absolute; top: 0; bottom: 0; background: rgba(46,157,91,.45); }
.ts-mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--muted); }
.ts-mark { position: absolute; top: 0; bottom: 0; width: 6px; margin-left: -3px; background: var(--muted); opacity: .3; left: 50%; transition: left .08s linear; }
.tstrip[data-tune="good"] .ts-mark { background: var(--good); } .tstrip[data-tune="off"] .ts-mark { background: var(--bad); }
.ts-graph { flex: 1; width: 100%; min-height: 0; background: var(--bg); border-radius: 8px; }
.ts-hint { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-hint:empty { display: none; }
/* Comparing with your part: target | how far from it | your note */
.ts-tgt { display: none; width: 68px; flex: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-width: 0; }
.ts-tlabel { font-size: .7rem; color: var(--muted); }
.ts-tnote { font-size: 1.5rem; font-weight: 600; line-height: 1.15; }
.ts-fold { font-size: .68rem; line-height: 1.1; color: var(--muted); overflow-wrap: anywhere; }
.ts-fold:empty { display: none; }
.ts-judge { display: none; align-items: baseline; gap: 8px; font-size: .9rem; font-weight: 600; min-height: 1.25em; line-height: 1.25; white-space: nowrap; overflow: hidden; }
.ts-dev { font-variant-numeric: tabular-nums; }
.tstrip[data-mode="target"] { height: 104px; }
.tstrip[data-mode="target"] .ts-tgt { display: flex; order: 1; }
.tstrip[data-mode="target"] .ts-right { order: 2; }
.tstrip[data-mode="target"] .ts-left { order: 3; width: 64px; flex: none; }
.tstrip[data-mode="target"] .ts-judge { display: flex; }
.tstrip[data-mode="target"] .ts-note { font-size: 1.5rem; }
.tstrip[data-tune="good"] .ts-judge { color: var(--good); } .tstrip[data-tune="off"] .ts-judge { color: var(--bad); }
/* "How it went" */
.run-card .run-pct { font-size: 1.15rem; font-weight: 600; margin: 4px 0 10px; }
.run-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.run-bar button { white-space: nowrap; }
/* Compare / With choir / Timing under a take */
.recorder .take-actions { padding: 2px 0 4px; }
.recorder .take-actions:empty { display: none; }
.recorder .timing { margin-left: 4px; white-space: nowrap; }
/* a take's player row wraps instead of pushing ⋮ off a narrow screen (it did in Pastel at 375 px) */
.recorder .take-player { flex-wrap: wrap; }
.recorder .take-player input[type=range] { flex: 1 1 0; min-width: 48px; }
.keyboard { padding: 4px 6px 6px; user-select: none; -webkit-user-select: none; }
.kb-head { display: flex; align-items: center; gap: 8px; row-gap: 10px; flex-wrap: wrap; padding: 5px 0; }
.kb-head select { padding: 4px; }
.kb-label { min-width: 90px; text-align: center; font-size: .85rem; }
.kb-keys { position: relative; height: 140px; touch-action: none; }
.key { position: absolute; top: 0; box-sizing: border-box; }
.key.white { height: 100%; background: #fbfaf7; border: 1px solid #8d8a82; border-radius: 0 0 6px 6px; display: flex; align-items: flex-end; justify-content: center; }
.key.white span { font-size: .7rem; color: #555; padding-bottom: 4px; pointer-events: none; }
.key.black { height: 60%; background: #222; border-radius: 0 0 4px 4px; z-index: 2; }
.key.white.down { background: #cfe0f2; } .key.black.down { background: #4a6c92; }
.metro { padding: 4px 10px; }
.lights { display: flex; gap: 6px; align-items: center; flex: 1; }
.light { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.light.first { width: 18px; height: 18px; }
.light.on { background: var(--accent); } .light.first.on { background: var(--bad); }
.bpm { min-width: 70px; }
.metro input[type=range] { flex: 1; }
.recorder { padding: 4px 10px 6px; }
.recorder .rec { background: #c62828; color: #fff; white-space: nowrap; }
.recorder input[type=range] { min-width: 60px; }
.photos { flex: 1; overflow: auto; background: #fbfaf7; padding: 8px 0; min-height: 0; }
.photos img { display: block; width: calc(100% * var(--z, 1)); max-width: none; margin: 0 auto 8px; }
/* Full screen: only the music (and the panels you chose), with a small floating bar. */
body.full nav, body.full header.bar, body.full .controls { display: none; }
.floatbar { position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: center; z-index: 20;
  background: var(--surface); border-radius: 999px; padding: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.floatbar[hidden] { display: none; }
body.full .tstrip { height: 25vh; }
body.full .ts-note { font-size: 2.6rem; } body.full .ts-left { width: 110px; }
/* tuner tab */
.tuner-graph { width: 100%; height: 200px; background: var(--surface); border-radius: 10px; margin: 10px 0; }
.target { text-align: center; min-width: 70px; }
.gate { position: relative; } .gate input { width: 100%; }
.level-mark { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--good); left: 0; pointer-events: none; }
details.card summary { cursor: pointer; font-weight: 500; }
.chips.center { justify-content: center; }

/* ---- PDF / photo reader (PDF.js) ---- */
.sheet-holder { flex: 1; min-height: 160px; display: flex; flex-direction: column; background: #e9e7e1; }
.sheetv { flex: 1; overflow: auto; min-height: 0; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-pages { margin: 0 auto; padding: 6px 0; min-width: 100%; box-sizing: border-box; }
.sheet-page { background: #fff; margin: 0 6px 8px; box-shadow: 0 1px 4px rgba(0,0,0,.18); position: relative; }
.sheet-page canvas, .sheet-page img { display: block; width: 100%; height: 100%; }
.page-label { min-width: 46px; text-align: center; color: var(--muted); }
.code-input { width: 100%; font-size: 1.2rem; letter-spacing: .03em; }

/* ---- Pastel theme ("1980s pastel · sketch"): pastel panels, thick ink outlines and hard shadows on graph paper.
   Everything here applies only with data-theme="pastel"; the other themes are untouched. ---- */
:root[data-theme="pastel"] {
  --bg: #fff5ee; --surface: #d9cff3; --text: #3e3a5c; --muted: #6a6590; --accent: #3e3a5c; --accent-text: #fff;
  --on: #f6b8d1; --error: #c2334d; --good: #2e9d5b; --bad: #d8432f; --line: #b3aad6;
  --ink: #3e3a5c; --lavender: #d9cff3; --mint: #bfe9d8; --sky: #c6e2f7; --gum: #f6b8d1; --lemon: #ffe9a3; --lcd: #cfe6c8;
  --grid: #f3dde3; --hard: 3px 3px 0 #3e3a5c; --lcd-font: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="pastel"] body {
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 18px 18px;
}
:root[data-theme="pastel"] h1, :root[data-theme="pastel"] h3 { font-weight: 700; }
/* buttons and chips: pills with an ink outline and a hard shadow */
:root[data-theme="pastel"] :where(button.filled, button.outlined, button.chip, header.bar button.text, .recorder .rec) {
  border: 2px solid var(--ink); background: #fff; color: var(--ink); border-radius: 999px; box-shadow: var(--hard); font-weight: 600;
}
:root[data-theme="pastel"] button.filled { background: var(--gum); }
:root[data-theme="pastel"] button.chip.on, :root[data-theme="pastel"] button.on-text { background: var(--gum); border-color: var(--ink); }
:root[data-theme="pastel"] :is(button.filled, button.outlined, button.chip, header.bar button.text, button.play, .recorder .rec):active:not(:disabled) {
  transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink);
}
:root[data-theme="pastel"] .chips { padding: 4px 5px 7px 2px; }
:root[data-theme="pastel"] .chips > .muted { color: var(--ink); font-weight: 700; }
:root[data-theme="pastel"] :is(textarea, select, input[type=text]) { border: 2px solid var(--ink); background: #fff; }
:root[data-theme="pastel"] input[type=range] { accent-color: #e0559a; }
/* cards and list rows */
:root[data-theme="pastel"] :is(.card, .item) { background: #fff; border: 2px solid var(--ink); border-radius: 16px; box-shadow: var(--hard); }
:root[data-theme="pastel"] .list { gap: 10px; padding: 0 3px 3px 0; }
:root[data-theme="pastel"] dialog { background: var(--bg); border: 2.5px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); }
:root[data-theme="pastel"] .menu { background: #fff; border: 2px solid var(--ink); box-shadow: var(--hard); }
/* lavender title bars */
:root[data-theme="pastel"] header.bar { background: var(--lavender); border-bottom: 2.5px solid var(--ink); padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; }
:root[data-theme="pastel"] .page > header.bar { border: 2px solid var(--ink); border-radius: 16px; box-shadow: var(--hard); margin: 0 3px 14px 0; padding: 6px 10px; }
:root[data-theme="pastel"] header.bar .title { font-weight: 700; }
:root[data-theme="pastel"] header.bar button.text { padding: 4px 14px; margin-right: 6px; }
/* lemon navigation, the current tab in a bubblegum pill */
:root[data-theme="pastel"] nav { background: var(--lemon); border-top: 2.5px solid var(--ink); }
:root[data-theme="pastel"] nav button { color: var(--ink); font-weight: 600; }
:root[data-theme="pastel"] nav button.on { background: none; }
:root[data-theme="pastel"] nav button span { display: inline-block; padding: 0 14px; border: 2px solid transparent; border-radius: 999px; }
:root[data-theme="pastel"] nav button.on span { background: var(--gum); border-color: var(--ink); }
/* the music: a white card on the paper (the notation itself stays white) */
:root[data-theme="pastel"] :is(iframe.score, iframe.pdf) {
  background: #fff; border: 2px solid var(--ink); border-radius: 14px; box-shadow: var(--hard);
  margin: 8px 11px 6px 8px; width: calc(100% - 19px);
}
:root[data-theme="pastel"] .sheet-holder { background: transparent; }
:root[data-theme="pastel"] .sheet-page { border: 2px solid var(--ink); box-shadow: var(--hard); margin: 0 11px 10px 8px; }
:root[data-theme="pastel"] .photos { background: transparent; }
/* controls: the transport is a sky-blue card; the Hear chips sit on the paper */
:root[data-theme="pastel"] .controls { background: transparent; border-top: 0; padding: 4px 11px 6px 8px; }
:root[data-theme="pastel"] .transport { background: var(--sky); border: 2px solid var(--ink); border-radius: 16px; box-shadow: var(--hard); padding: 6px 8px; margin-bottom: 4px; gap: 6px; flex-wrap: wrap; row-gap: 4px; }
:root[data-theme="pastel"] .transport input[type=range] { flex: 1 1 90px; width: auto; min-width: 60px; }
:root[data-theme="pastel"] .transport button.icon-btn {
  background: #fff; border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: .85rem; flex: none;
}
:root[data-theme="pastel"] button.play { background: var(--gum); color: var(--ink); border: 2.5px solid var(--ink); box-shadow: var(--hard); flex: none; }
:root[data-theme="pastel"] .bar-label {
  background: var(--lcd); border: 2px solid var(--ink); border-radius: 8px; padding: 3px 8px; text-align: center;
  font-family: var(--lcd-font); font-weight: 700; text-transform: uppercase; white-space: nowrap;
}
:root[data-theme="pastel"] .floatbar { background: var(--lavender); border: 2px solid var(--ink); box-shadow: var(--hard); }
/* panels under the music: pastel cards */
:root[data-theme="pastel"] .extras { background: transparent; border-top: 0; }
:root[data-theme="pastel"] .extras > * { border: 2px solid var(--ink); border-radius: 16px; box-shadow: var(--hard); margin: 6px 11px 6px 8px; }
:root[data-theme="pastel"] .tstrip { background: var(--mint); }
:root[data-theme="pastel"] .keyboard { background: #fff; }
:root[data-theme="pastel"] .metro { background: var(--lemon); }
:root[data-theme="pastel"] .recorder { background: var(--lavender); }
:root[data-theme="pastel"] .recorder .rec { background: #e8607a; color: #fff; }
/* tuner strip: an LCD readout and a white cents bar */
:root[data-theme="pastel"] .ts-left { background: var(--lcd); border: 2px solid var(--ink); border-radius: 8px; }
:root[data-theme="pastel"] .tstrip .ts-note, :root[data-theme="pastel"] .tstrip .ts-cents { color: var(--ink); font-family: var(--lcd-font); font-weight: 700; }
:root[data-theme="pastel"] .ts-note { font-size: 1.45rem; }
:root[data-theme="pastel"] .ts-bar { background: #fff; border: 2px solid var(--ink); height: 14px; }
:root[data-theme="pastel"] .ts-graph { background: rgba(255, 255, 255, .45); }
/* keyboard: ink-outlined keys, lavender black keys, bubblegum when pressed */
:root[data-theme="pastel"] .key.white { background: #fff; border: 2px solid var(--ink); border-radius: 0 0 8px 8px; }
:root[data-theme="pastel"] .key.white span { color: var(--muted); }
:root[data-theme="pastel"] .key.black { background: var(--lavender); border: 2px solid var(--ink); border-radius: 0 0 6px 6px; }
:root[data-theme="pastel"] :is(.key.white.down, .key.black.down) { background: var(--gum); }
:root[data-theme="pastel"] .kb-label { background: var(--lcd); border: 2px solid var(--ink); border-radius: 8px; padding: 2px 6px; font-family: var(--lcd-font); font-weight: 700; }
:root[data-theme="pastel"] .light { background: #fff; border: 2px solid var(--ink); }
:root[data-theme="pastel"] .light.on { background: var(--gum); }
:root[data-theme="pastel"] .light.first.on { background: #e8607a; }
/* tuner tab: the note in a big LCD; the gauge and graph outlined */
:root[data-theme="pastel"] .tuner-note {
  display: inline-block; min-width: 3em; padding: 0 .25em; background: var(--lcd); border: 3px solid var(--ink); border-radius: 16px;
  box-shadow: var(--hard); font-family: var(--lcd-font); font-weight: 700; font-size: 4rem;
}
:root[data-theme="pastel"] .tuner-cents { font-family: var(--lcd-font); font-weight: 700; }
:root[data-theme="pastel"] .gauge { background: #fff; border: 2px solid var(--ink); }
:root[data-theme="pastel"] .tuner-graph { background: var(--mint); border: 2px solid var(--ink); box-shadow: var(--hard); }

/* ---- Compact layout (Settings → Layout): smaller bars, chips and buttons, more room for the notes ---- */
/* The buttons look small, but each still answers a tap within at least 40 × 40 px (an invisible margin). */
/* (42 px boxes, so rounding to whole pixels never leaves less than 40; the gaps between rows and between the
   small round buttons are just wide enough for the margins not to overlap) */
:root[data-compact] button { min-height: 0; position: relative; }
:root[data-compact] button.icon-btn { min-width: 40px; }
:root[data-compact] button::after { content: ''; position: absolute; left: 50%; top: 50%; width: max(100%, 42px); height: max(100%, 42px); transform: translate(-50%, -50%); }
:root[data-compact] button.small-play { width: 38px; height: 38px; }
:root[data-compact] button.chip { min-width: 34px; }
:root[data-compact] .menu button { min-height: 42px; }
:root[data-compact] .transport { margin-bottom: 5px; }
/* the margins of the top row reach a little over the music: keep them on top of it */
:root[data-compact] .controls, :root[data-compact] header.bar { position: relative; z-index: 1; }
:root[data-compact] nav { position: relative; z-index: 2; }
:root[data-compact][data-theme="pastel"] .transport button.icon-btn { min-width: 0; margin: 0 5px; }
:root[data-compact] header.bar { padding-top: max(1px, env(safe-area-inset-top)); padding-bottom: 1px; gap: 2px; }
:root[data-compact] header.bar .title { font-size: .95rem; }
:root[data-compact] header.bar h1 { font-size: 1.05rem; }
:root[data-compact] header.bar button { padding: 3px 9px; }
:root[data-compact] header.bar button.icon-btn { font-size: 1rem; }
:root[data-compact] .controls { padding: 2px 8px 6px; }
:root[data-compact] .transport { gap: 6px; }
:root[data-compact] .transport button.icon-btn { padding: 2px 7px; font-size: 1rem; }
:root[data-compact] button.play { width: 34px; height: 34px; font-size: .95rem; }
:root[data-compact] .chips { gap: 8px; row-gap: 18px; padding: 9px 0; }
:root[data-compact] button.chip { padding: 2px 9px; font-size: .85rem; border-radius: 7px; }
:root[data-compact] .bar-label { min-width: 62px; font-size: .9rem; }
:root[data-compact] .tstrip { height: 64px; padding: 3px 8px; }
:root[data-compact] .tstrip[data-mode="target"] { height: 76px; }
:root[data-compact] .tstrip[data-mode="target"] .ts-note, :root[data-compact] .ts-tnote { font-size: 1.15rem; }
:root[data-compact] .ts-tlabel, :root[data-compact] .ts-fold { font-size: .62rem; }
:root[data-compact] .ts-judge { font-size: .8rem; }
:root[data-compact] .ts-bar { height: 9px; }
:root[data-compact] nav { padding: 1px 0 max(2px, env(safe-area-inset-bottom)); }
:root[data-compact] nav button { flex-direction: row; gap: 6px; padding: 3px 14px; font-size: .75rem; }
:root[data-compact] nav button span { font-size: 1rem; }
:root[data-compact] .keyboard { padding: 2px 6px 3px; }
:root[data-compact] .kb-head { gap: 8px; row-gap: 18px; padding: 9px 0; }
:root[data-compact] .kb-head button { padding: 2px 9px; font-size: .85rem; }
:root[data-compact] .kb-head select { padding: 1px 4px; font-size: .85rem; }
:root[data-compact] .kb-keys { height: 104px; }
:root[data-compact] .metro { padding: 2px 8px; }
/* Pastel keeps its look, just tighter */
:root[data-compact][data-theme="pastel"] header.bar { padding-top: max(2px, env(safe-area-inset-top)); padding-bottom: 2px; border-bottom-width: 2px; }
:root[data-compact][data-theme="pastel"] header.bar button.text { padding: 2px 10px; }
:root[data-compact][data-theme="pastel"] .controls { padding: 2px 9px 6px 6px; }
:root[data-compact][data-theme="pastel"] .transport { padding: 3px 6px; border-radius: 12px; gap: 4px; }
:root[data-compact][data-theme="pastel"] .transport button.icon-btn { width: 30px; height: 30px; padding: 0; font-size: .8rem; }
:root[data-compact][data-theme="pastel"] button.play { width: 36px; height: 36px; }
:root[data-compact][data-theme="pastel"] nav { border-top-width: 2px; }
:root[data-compact][data-theme="pastel"] nav button span { padding: 0 8px; }

/* "‹ Scores" back button: a filled pill so it reads as a button (Pastel has its own white pill) */
:root:not([data-theme="pastel"]) header.bar button.text {
  background: var(--on); color: var(--text); border: 1.5px solid var(--accent); font-weight: 600;
  padding: 5px 14px; margin-right: 8px; min-height: 36px;
}
:root:not([data-theme="pastel"]) header.bar button.text:hover { filter: brightness(1.08); }
:root[data-compact]:not([data-theme="pastel"]) header.bar button.text { padding: 3px 11px; min-height: 28px; margin-right: 6px; }

/* Score view: the transport (▶) and the top bar always stay on screen. With many panels open (pitch strip,
   metronome, recorder, keyboard) the panel area shrinks and scrolls on its own; the music keeps at least 140 px. */
section.reader { overflow: hidden; }
section.reader > header.bar, section.reader > .controls { flex-shrink: 0; }
section.reader > iframe.score, section.reader > iframe.pdf { min-height: 140px; }
section.reader > .extras { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

/* Folded controls ("▾" at the end of the play row): only the play row stays, with the open panels.
   The tempo slider, the chip rows and the tab bar hide. */
section.reader.folded .hear,
section.reader.folded .transport input[type=range],
section.reader.folded .transport .tempo-label,
section.reader.folded .controls [data-extra] { display: none !important; }
body:has(section.reader.folded) > nav { display: none; }
button.fold { margin-left: 2px; }
