:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --text: #1d1b16;
  --muted: #6b665c;
  --border: #e3ded3;
  --accent: #8a5a2b;
  --accent-text: #ffffff;
  --ok-bg: #eef3ea;
  --ok-text: #2c4a22;
  --folded-bg: #e3edfb;
  --folded-text: #1f4f99;
  --out-bg: #fbe5e5;
  --out-text: #a1262d;
  --playing: #f2c14e;
  --focus: #1f4f99;    /* keyboard focus ring: clear against both backgrounds */
  --playing-ring: #9a6b00; /* "now playing" outline: --playing is too pale on white (4.7:1 here) */
  --score-bg: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17150f;
    --card: #222019;
    --text: #efe9dd;
    --muted: #a59f92;
    --border: #3a362d;
    --accent: #d39b5f;
    --accent-text: #1a140c;
    --ok-bg: #26301f;
    --ok-text: #c5dcb8;
    --folded-bg: #1d2b42;
    --folded-text: #a8c6f5;
    --out-bg: #3d1f21;
    --out-text: #f3b2b5;
    --playing: #b8892a;
    --focus: #a8c6f5;
    --playing-ring: #b8892a;
  }
}

* { box-sizing: border-box; }

/* The page has its own light and dark colours: browsers that darken pages themselves (Chrome's
   automatic dark mode) leave it alone, and the whole window, not just the content, is the page's
   background. */
:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Page layout: content on the left, tuner/metronome dock on the right (wide screens)
   or along the bottom (phones). */
.layout {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px;
}
header { padding-top: 20px; }
.content { min-width: 0; }

@media (min-width: 1000px) {
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    /* The sidebar starts at the top of the page, beside the header, so it all fits on screen. */
    grid-template-areas: "header dock" "content dock";
    grid-template-rows: auto 1fr; /* (a short page leaves the spare height under its content, not the header) */
    column-gap: 20px;
    align-items: start;
  }
  header { grid-area: header; }
  .content { grid-area: content; }
  .dock {
    grid-area: dock; position: sticky; top: 12px; margin-top: 20px; max-height: calc(100vh - 32px); overflow-y: auto;
    display: flex; flex-direction: column; gap: 10px;
  }
  /* Most important first: tuner, metronome, fingerings, then play (kept in view at the bottom). */
  .dock-body { display: contents; }
  #tuner-card { order: 1; }
  #metronome-card { order: 2; }
  .fingering-open { order: 3; }
  .fingering-peek { order: 4; }
  #dock-player { order: 5; position: sticky; bottom: 0; z-index: 2; box-shadow: 0 -6px 16px var(--bg); }
  .dock-body .card { margin: 0; }
}

@media (max-width: 999px) {
  /* The page is at least as tall as the screen, with the music stretching to fill it, so the dock
     sits at the bottom like a footer even before a song is open (sticky only keeps it on screen
     once the page is longer than the screen). */
  .layout { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
  .content { flex: 1 0 auto; }
  /* "sticky", not "fixed": a fixed bar can drift up the page on phones (when the browser's
     toolbars slide in and out, or when an extension puts a filter over the page). A sticky bar
     is part of the page, so it always sits at the bottom of what's on screen. */
  .dock {
    position: sticky; bottom: 0; z-index: 10;
    margin: 0 -16px; /* stretch across the page's side padding */
    background: var(--card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 20px rgb(0 0 0 / 0.12);
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  }
  .dock-body { display: none; }
  .dock[data-open="true"] .dock-body {
    display: grid; gap: 10px;
    max-height: 62vh; overflow-y: auto; margin-top: 8px;
    overscroll-behavior: contain;
  }
  .dock-body .card { margin: 0; }
}
@media (min-width: 640px) and (max-width: 999px) {
  .dock[data-open="true"] .dock-body { grid-template-columns: 1fr 1fr; align-items: start; }
}
h1 { margin: 0; font-size: 1.6rem; }
h2 { margin: 0 0 12px; font-size: 1.1rem; }
/* Headings in a book face (installed on most devices), the rest in the system's own. */
h1, h2, h3 { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif; font-weight: 700; letter-spacing: -0.005em; }
h3 { margin: 20px 0 8px; font-size: 1rem; }
.sub, .hint { color: var(--muted); margin: 4px 0 0; font-size: 0.9rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin: 16px 0;
}

.hidden { display: none !important; }

button, select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
}

button:hover { border-color: var(--accent); }

/* Links in the accent colour (not the browser's blue). */
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
/* Quieter buttons for things used now and then (Keep screen on, Tap, Copy letters): no box until
   pointed at, so the main actions stand out. */
button.quiet:not([aria-pressed="true"]) { background: transparent; border-color: transparent; color: var(--muted); }
button.quiet:not([aria-pressed="true"]):hover { border-color: var(--border); color: var(--text); }

/* Dropdowns drawn like the buttons (not the system's), with a chevron in the accent colour; sliders
   in the accent colour too. */
select {
  appearance: none; -webkit-appearance: none; padding-right: 34px;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a5a2b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d39b5f' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
}
input[type="range"] { accent-color: var(--accent); }

/* The Tuner at rest: its heading and one line ("Tap Start and play a note"); the meter and the
   pitch trace once it's listening. */
#tuner-display[data-state="idle"] :is(.meter, .meter-scale, .tuner-names) { display: none; }
#tuner-card:has(#tuner-display[data-state="idle"]) #tuner-trace { display: none; }
#tuner-display[data-state="idle"] .tuner-readout { min-height: 0; padding: 0; justify-content: flex-start; }
#tuner-display[data-state="idle"] .tuner-advice { font-weight: 400; color: var(--muted); }
#tuner-display[data-state="idle"] { margin: 0 0 4px; }

/* Icons (index.html's sprite): line drawings in the text colour, beside or instead of words. */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 1.1em; height: 1.1em; flex: none; vertical-align: -0.18em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button .ic + span, button span + .ic { margin-left: 6px; }
#download-button .ic, .edit-more .ic { width: 0.95em; height: 0.95em; }
.edit-more.open .ic { transform: rotate(180deg); }
.ic.chevron.up { transform: rotate(180deg); }
#dock-toggle-label { display: inline-flex; align-items: center; gap: 4px; }
#dock-toggle-label .ic { width: 0.75em; height: 0.75em; stroke-width: 3; }

/* "How to read this" and the like: a chevron in the accent colour for the browser's triangle. */
details > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: ""; flex: none; width: 0.5em; height: 0.5em; margin: 0 2px;
  border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(-45deg); transition: transform 120ms;
}
details[open] > summary::before { transform: rotate(45deg); }
.mini .ic { width: 22px; height: 22px; }
.tab-line { display: inline-flex; align-items: center; gap: 8px; }
.tile-name .ic { margin-right: 6px; color: var(--accent); }
.tile[aria-pressed="true"] .tile-name .ic { color: inherit; }

.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  font-weight: 600;
}

.file-button input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-button span {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 10px;
  cursor: pointer;
}
.file-button input:focus-visible + span { outline: 3px solid var(--focus); }

.samples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
/* Phones (music first, see phone-layout.js): the title with the Sheet music / Letter tab switch
   beside it, the music straight after; the playing controls and practice are in the bar's panel. */
.music-first #result-card .result-head { align-items: center; margin-bottom: 10px; }
.music-first #summary { display: none; }
.music-first .reading-tabs .long-word { display: none; } /* "Sheet" / "Letter", to fit beside the title */
.dock[data-open="true"] .dock-practice-note { display: none; } /* (the panel shows it all) */
.music-first #reading-modes { margin: 0 0 10px; min-width: 0; width: 100%; grid-template-columns: repeat(3, 1fr); } /* (a row of its own) */
.music-first .reading-tabs button { min-height: 44px; padding: 4px 8px; font-size: 1rem; }
.music-first #result-card .score-head { margin-top: 0; }
.dock-play-panel { display: grid; gap: 10px; }
.dock-play-panel .player { gap: 8px 14px; }
.dock-play-panel .player :is(.play-toggle, .count-badge) { display: none; } /* (in the bar) */
.dock-play-panel .player .volume, .dock-play-panel .player .tempo { flex: 1 1 100%; order: 1; }
/* The sound switches at the top: the song's mute and Mute metronome on one row, ↺ Original (when the
   tempo's changed) on its own row under them, as they don't all fit side by side. */
.dock-play-panel .player { column-gap: 6px; }
.dock-play-panel .player .mute-toggle { flex: none; }
.dock-play-panel .player :is(.ps-silent, .tempo-reset) {
  min-height: 44px; padding: 0 10px; font-size: 0.88rem; white-space: nowrap;
}
.dock-play-panel .player .ps-silent { flex: 1 1 auto; }
.dock-play-panel .player .tempo-reset { flex: 1 1 100%; }
.dock-play-panel .play-from { margin: 0; }
/* Playing from the start (nothing set): the line isn't needed. */
.play-from.from-start { display: none; }
.dock-play-panel .practice { margin: 0; padding: 0; border: 0; background: none; }
.dock-practice-note {
  display: block; width: 100%; min-height: 32px; margin: 0 0 6px; padding: 4px 10px; text-align: left;
  font-size: 0.8rem; font-weight: 700; color: var(--accent); background: var(--card);
  border: 1px solid var(--border); border-radius: 10px;
}
.dock-practice-note.hidden { display: none; }
@media (min-width: 1000px) { .dock-practice-note, .practice-coach { display: none !important; } }
/* Once, on phones: a note pointing down at the bar's Practice button. */
/* (It floats just above the bar, like the other pop-ups: in the bar, it made the page taller as it
   appeared, moving everything.) */
.practice-coach {
  position: absolute; left: 12px; right: 12px; bottom: calc(100% + 2px); z-index: 12;
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 10px 12px;
  background: var(--accent); color: var(--accent-text); border-radius: 12px; font-size: 0.85rem;
}
.practice-coach.hidden { display: none; }
.dock:has(.fingering-peek:not(.hidden)) .practice-coach { display: none; } /* (don't stack up) */
.practice-coach p { margin: 0; flex: 1; }
.dock:has(.practice-coach:not(.hidden)) .follow-button { bottom: calc(100% + 76px); }
.dock:has(.practice-coach:not(.hidden)) .toast { bottom: calc(100% + 130px); }
.practice-coach button { background: var(--accent-text); color: var(--accent); border: 0; flex: 0 0 auto; }
.practice-coach::after {
  content: ""; position: absolute; right: 30px; bottom: -8px;
  border: 8px solid transparent; border-bottom: 0; border-top-color: var(--accent);
}

/* Phones: the bar's Practice button says what it opens; mute moves into its panel (next to the
   volume) to make room. */
@media (max-width: 999px) {
  #mini-mute { display: none; }
  .dock-toggle { flex: 0 0 auto; gap: 4px; padding: 6px 10px; font-weight: 700; }
  .dock-toggle .practice-word { font-size: 0.85rem; }
}
/* (Before shell.js labels the bar's last button: the word for this layout.) */
body:not(.music-first) #dock-toggle-label .practice-word, body.music-first #dock-toggle-label .toggle-word { display: none; }

/* A song's tabs: Music and Song setup. */
.song-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 16px 0 0; }
.song-tabs.hidden { display: none; }
.song-tabs [role="tab"] {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px; padding: 6px 10px; font-weight: 700; background: var(--card);
  border: 1px solid var(--border); border-bottom: 3px solid var(--border); border-radius: 12px;
}
.song-tabs [role="tab"][aria-selected="true"] { border-color: var(--accent); border-bottom-color: var(--accent); color: var(--text); }
.song-tabs [role="tab"][aria-selected="false"] { color: var(--muted); }
.song-tabs .tab-sub { font-size: 0.75rem; font-weight: 500; color: var(--muted); }
.song-tabs .tab-sub:empty { display: none; }
#status:empty { margin: 0; min-height: 0; } /* (kept in the page, so screen readers hear new messages) */
.tab-panel[hidden] { display: none; }

/* Sheet music read from a PDF or screenshot: its original pages, to compare. */
.upload-kinds { margin-top: 6px; }
.original-toggle { margin: 10px 0 0; }
.original-pages { margin: 10px 0 0; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.original-pages .hint { margin: 0 0 8px; }
.original-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.original-head .hint { flex: 1 1 220px; }
.original-head button { flex: none; margin-bottom: 8px; }
.original-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; }
.original-actions .hidden { display: none; }

/* The original pages pinned beside the music: they stay put while the music scrolls. */
.pinned-pages { display: flex; flex-direction: column; background: var(--card); min-width: 0; }
.pinned-pages.hidden { display: none; }
.pinned-bar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; font-size: 0.85rem; flex: none; }
.pinned-bar b { flex: 1; }
.pinned-view { flex: 1; overflow: auto; overscroll-behavior: contain; background: #fff; display: grid; gap: 8px; align-content: start; }
.pinned-view .page-copy { width: var(--pin-zoom, 100%); flex: none; } /* (the page, zoomed: its outline goes with it) */
.pinned-view img { display: block; width: 100%; max-width: none; height: auto; }
.pin-divider { display: none; }
@media (max-width: 999px) {
  /* Phones: across the top of the screen, the music scrolling under it. */
  .pinned-pages { position: fixed; top: 0; left: 0; right: 0; z-index: 15; height: var(--pin-h, 38vh);
    border-bottom: 1px solid var(--border); box-shadow: 0 4px 14px rgb(0 0 0 / 0.12); }
  .pin-divider { display: flex; flex: none; height: 22px; align-items: center; justify-content: center; background: var(--bg);
    cursor: row-resize; touch-action: none; }
  .pin-divider span { width: 44px; height: 5px; border-radius: 3px; background: var(--muted); opacity: 0.6; }
  body.pages-pinned { padding-top: var(--pin-top, 0px); }
}
@media (min-width: 1000px) {
  /* Wide screens: their own column, left of the music. */
  body.pages-pinned .layout { max-width: 1760px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 340px;
    grid-template-areas: "pages header dock" "pages content dock"; }
  body.pages-pinned .layout[data-chart="open"] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 520px; }
  .pinned-pages { grid-area: pages; position: sticky; top: 12px; margin-top: 20px; height: calc(100vh - 32px);
    border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
}
/* Anything scrolled into view lands below the pinned pages (phones). */
html { scroll-padding-top: var(--pin-top, 0px); }
/* Phones while editing: and above the edit tools at the foot of the screen. */
html:has(body.music-first.editing) { scroll-padding-bottom: calc(var(--edit-bar-h, 240px) + 8px); }
.original-pages-list { display: grid; gap: 10px; max-height: 70vh; overflow-y: auto; }
.original-pages-list img { width: 100%; height: auto; background: #fff; border: 1px solid var(--border); border-radius: 6px; }
/* A page copy, holding the outline of the passage being checked (placed by the reader's bar positions). */
.page-copy { position: relative; }
.page-copy img { display: block; }
.page-outline { position: absolute; pointer-events: none; border: 3px solid #e0a000; border-radius: 6px; background: rgb(240 176 77 / 0.18); }

/* Song setup: hear the whole piece / this key. */
.listen-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 8px 0 0; }
.listen-row .hint { margin: 0; }
.whole-seek { flex: 1 1 100%; }
.whole-seek.hidden { display: none; }

/* Long rests in the letter tab: one marker for empty bars, and ✂ where a rest was shortened. */
button.rest-dot.long-rest {
  width: auto; min-height: 28px; padding: 2px 10px; border: 1px dashed var(--border); border-radius: 8px;
  font-size: 0.8rem; color: var(--muted); cursor: pointer;
}
button.rest-dot.long-rest::before { content: none; }
.long-rest-bar .chip { font-size: 0.8rem; }
.rest-cut {
  display: inline-flex; align-items: center; align-self: center; margin: 0 4px; padding: 1px 6px;
  font-size: 0.75rem; color: var(--muted); border: 1px dashed var(--border); border-radius: 6px;
}

/* ABC notation: paste a tune. */
.abc-open { margin: 10px 0 0; display: block; }
.abc-panel { display: grid; gap: 8px; margin-top: 10px; }
.abc-panel.hidden { display: none; }
.abc-panel label { font-size: 0.9rem; }
.abc-panel textarea {
  width: 100%; font: 1rem/1.4 ui-monospace, Menlo, monospace; padding: 8px 10px; /* (16px: no zoom on iPhone) */
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text);
}
.abc-tunes { display: grid; gap: 4px; }
.abc-tunes.hidden { display: none; }
.abc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.abc-actions .status { margin: 0; }
.chip-button { font-size: 0.9rem; }

.status { margin: 12px 0 0; min-height: 1.2em; color: var(--muted); }
.status.error { color: var(--out-text); }

.field { margin-bottom: 14px; }
.field label, .field .label { display: block; font-weight: 600; margin-bottom: 6px; }
.field select { width: 100%; }

.key-row { display: flex; gap: 8px; }
.key-row select { flex: 1; min-width: 0; }
.step { width: 48px; font-size: 1.2rem; padding: 0; }

/* A set of choices: one joined control, the one chosen filled in. */
.segmented { display: flex; gap: 0; }
.segmented button { flex: 1 1 0; min-width: 0; padding: 8px 10px; font-size: 0.9rem; border-radius: 0; }
.segmented button + button { border-left-width: 0; }
.segmented button:first-child { border-radius: 10px 0 0 10px; }
.segmented button:last-child { border-radius: 0 10px 10px 0; }
/* (Choices of the letter tab's style and the note names: each part sized to its words.) */
#view-modes, .segmented.naming-modes { display: inline-flex; }
:is(#view-modes, .naming-modes) button { flex: 0 0 auto; padding: 8px 16px; white-space: nowrap; }
.segmented button.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.result-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; }
/* The song's name, with a quiet pencil to rename it in place (library.js). */
.title-line { display: flex; align-items: center; gap: 2px; min-width: 0; }
.title-line h2 { margin-bottom: 0; }
.title-rename { flex: 0 0 auto; width: 36px; height: 36px; padding: 0 !important; justify-content: center; background: none; border: none; color: var(--muted); }
.title-rename:hover { color: var(--text); background: var(--bg); }
.title-rename .ic { width: 16px; height: 16px; }
/* The title and credits, edited in place (library.js). */
.details-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; flex: 1 1 100%; max-width: 760px; padding: 14px; margin: 0 0 12px; border: 1px solid var(--border); border-radius: 14px; }
.details-edit :is(label, .details-field) { display: grid; gap: 3px; min-width: 0; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.details-edit .full { grid-column: 1 / -1; }
.details-edit :is(input, select) { min-width: 0; min-height: 40px; font: inherit; font-size: 0.95rem; font-weight: 400; color: var(--text); padding: 7px 10px; border-radius: 9px; border: 1px solid color-mix(in srgb, var(--border), var(--text) 15%); background-color: var(--bg); }
.details-edit select { padding-right: 34px; } /* (room for the dropdown's chevron) */
.details-by { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px; }
.details-found { font-size: 0.8rem; color: var(--muted); }
.details-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.details-chip { font-size: 0.8rem !important; padding: 3px 10px !important; min-height: 0 !important; border-radius: 999px !important; border: 1px dashed color-mix(in srgb, var(--border), var(--text) 20%) !important; background: none !important; color: var(--text); max-width: 100%; overflow-wrap: anywhere; text-align: left; }
.details-actions { display: flex; gap: 8px; justify-content: flex-end; }
@media (max-width: 560px) { .details-edit { grid-template-columns: 1fr; } }
/* Who made the music, over the letter tab (controls.js). */
.tab-credits { margin: 4px 4px 12px; text-align: right; font-size: 0.82rem; line-height: 1.45; color: var(--muted); }
@media (hover: none) { .title-edit-hint { display: none; } }  /* (the keyboard's Done saves) */
.summary { margin: 0 0 12px; color: var(--muted); font-size: 0.9rem; }

.player { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.player .primary { min-width: 110px; }
.tempo { display: flex; flex-direction: column; flex: 1; min-width: 160px; font-size: 0.85rem; color: var(--muted); }
.tempo input { width: 100%; accent-color: var(--accent); }
.volume { display: flex; align-items: center; gap: 6px; flex: 0 1 150px; min-width: 110px; }
.volume input { width: 100%; accent-color: var(--accent); }
.volume-label { font-size: 0.85rem; color: var(--muted); }
/* The Player (wide screens): Play, mute and volume on one line; Practice as a row of names, what each
   does in its tooltip. (No tempo: that's the metronome card's. Linked, it sets the song's speed too;
   unlinked, the song keeps the speed it had.) */
.player-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
#dock-player .fingering-open { width: auto; min-height: 32px; padding: 4px 12px; font-size: 0.85rem; }
.player-head h2 { margin: 0; font-size: 1.05rem; }
.player-head .hint { margin: 0; }
#dock-player .player { gap: 8px 12px; }
#dock-player .player .volume { flex: 1 1 120px; }
#dock-player .player :is(.tempo, .tempo-reset) { display: none; }
#dock-player .practice { margin: 12px 0 0; padding: 0; border: 0; background: none; }
#dock-player .practice-heading { margin: 0 0 6px; font-size: 0.9rem; }
#dock-player .practice-tiles { display: flex; flex-wrap: wrap; gap: 6px; }
#dock-player .practice .tile { min-height: 32px; padding: 4px 10px; flex-direction: row; align-items: center; }
#dock-player .practice .tile[aria-pressed="true"] { padding: 3px 9px; }
#dock-player .practice .tile-name { font-size: 0.85rem; font-weight: 600; }
#dock-player .practice .tile-what {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.link-note { margin: 4px 0 0; }
/* What each Practice option that's on does, under their names (wide screens), its settings on its line. */
.practice-explain { display: grid; gap: 6px; margin: 8px 0 0; font-size: 0.85rem; line-height: 1.4; }
.practice-explain[hidden], .explain-line.hidden { display: none; }
.explain-line p { margin: 0; }
/* The option pointed at, explained in a small bubble at it (practice-explain.js places it). */
.option-tip {
  position: fixed; z-index: 60; display: none; margin: 0; padding: 7px 10px; pointer-events: none;
  font-size: 0.85rem; line-height: 1.4; color: var(--text);
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 18px rgb(0 0 0 / 0.16);
}
.option-tip.shown { display: block; }
/* (The arrow: up at the option, or down at it when the bubble is above.) */
.option-tip::before {
  content: ""; position: absolute; left: var(--arrow, 50%); top: -6px; width: 10px; height: 10px; margin-left: -5px;
  background: var(--card); border-left: 1px solid var(--border); border-top: 1px solid var(--border); transform: rotate(45deg);
}
.option-tip.above::before { top: auto; bottom: -6px; transform: rotate(225deg); }
.option-tip.left::before { left: auto; right: -6px; top: var(--arrow, 50%); margin: -5px 0 0; transform: rotate(135deg); }
.explain-line .practice-options { margin: 4px 0 0; }
.explain-line .practice-options .label { display: none; } /* (the line names it already) */
/* Phones: play, mute and volume on one line, the tempo slider underneath. */
@media (max-width: 520px) {
  .player .volume { flex: 1 1 100px; }
  .player .tempo { flex-basis: 100%; }
}

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 16px 0 8px; font-size: 0.85rem; color: var(--muted); align-items: center; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 5px; vertical-align: -1px; }
.dot.ok { background: var(--ok-bg); border: 1px solid var(--ok-text); }
.dot.folded { background: var(--folded-bg); border: 1px solid var(--folded-text); }
.dot.out { background: var(--out-bg); border: 1px solid var(--out-text); }

.letters { display: flex; flex-direction: column; gap: 8px; }
.phrase { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px; border-bottom: 1px dashed var(--border); }
.phrase:last-child { border-bottom: 0; }

.note {
  min-width: 46px;
  min-height: 40px;
  padding: 6px 8px;
  border-radius: 8px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--ok-bg);
  color: var(--ok-text);
  border: 1px solid transparent;
}
.note.folded { background: var(--folded-bg); color: var(--folded-text); }
.note.out { background: var(--out-bg); color: var(--out-text); }
.note.dropped { background: transparent; color: var(--muted); text-decoration: line-through; border: 1px dashed var(--border); font-weight: 400; }
.note.playing { outline: 3px solid var(--playing-ring); outline-offset: 1px; }
.note small { display: block; font-weight: 400; font-size: 0.7rem; opacity: 0.8; }

.downloads { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.downloads button { font-size: 0.9rem; }

.score {
  position: relative;
  background: var(--score-bg);
  border-radius: 10px;
  /* Sideways only (wide music): never a scroll area of its own up and down, which caught swipes on
     phones (the hidden copy being drawn can be taller) so the page wouldn't scroll back up. */
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  min-height: 80px;
}
/* The hidden drawing surface: the next version of the score is drawn here, then swapped in. */
.score-view.back { position: absolute; left: 0; right: 0; top: 0; visibility: hidden; pointer-events: none;
  overflow: hidden; } /* (an old, wider drawing in it mustn't make the music scroll sideways) */
@media print { .score-view.back { display: none; } }
@media screen { .print-sheet { display: none; } }

@media (max-width: 520px) {
}

/* ---------- header ---------- */
.header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
button.small { min-height: 36px; padding: 6px 10px; font-size: 0.85rem; }
button.toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }


.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }


/* ---------- compact tool cards (song, tuner, metronome) ---------- */
/* Sized so all of them fit on screen at once while you read the music. */
.card.tool { padding: 10px 12px; }
.card.tool .card-head { margin-bottom: 4px; }
.card.tool h2 { font-size: 1rem; }
button.primary.small, .card.tool button.small { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }
.tool-row { display: flex; align-items: center; gap: 10px; }
.tool-text { display: flex; flex-direction: column; min-width: 0; font-size: 0.85rem; }
.tool-text .hint { margin: 0; font-size: 0.75rem; }
.compact-row { justify-content: space-between; margin-top: 6px; font-size: 0.85rem; }
.compact-row .hint { margin: 0; }

/* tuner */
.tuner-readout { display: flex; align-items: center; gap: 12px; min-height: 58px; }
.tuner-names { display: flex; flex-direction: column; align-items: flex-start; min-width: 92px; }
.tuner-note { font-size: 2.5rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.tuner-alt { font-size: 0.9rem; color: var(--muted); font-weight: 600; min-height: 1.1em; }
.tuner-side { display: flex; flex-direction: column; min-width: 0; font-size: 0.8rem; color: var(--muted); }
.tuner-advice { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.tuner-range, .tuner-hz { font-variant-numeric: tabular-nums; }
.tuner-display[data-state="intune"] .tuner-note { color: var(--ok-text); }
.tuner-display[data-state="close"] .tuner-note { color: var(--accent); }
.tuner-display[data-state="off"] .tuner-note { color: var(--out-text); }
.tuner-display[data-state="idle"] .tuner-note,
.tuner-display[data-state="listening"] .tuner-note { color: var(--muted); }

.meter { position: relative; height: 22px; margin: 6px 2px 2px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); overflow: hidden; }
.meter-zone { position: absolute; top: 0; bottom: 0; left: 45%; width: 10%; background: var(--ok-bg); }
.meter-center { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: var(--ok-text); opacity: 0.6; }
.meter-needle {
  position: absolute; top: 2px; bottom: 2px; left: 50%; width: 6px; margin-left: -3px;
  border-radius: 3px; background: var(--text); transition: left 90ms linear, opacity 200ms; opacity: 0;
}
.tuner-display[data-state="intune"] .meter-needle,
.tuner-display[data-state="close"] .meter-needle,
.tuner-display[data-state="off"] .meter-needle { opacity: 1; }
.meter-scale { display: flex; justify-content: space-between; font-size: 0.68rem; color: var(--muted); padding: 0 2px; }

.trace { display: block; width: 100%; height: 48px; margin-top: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.stepper { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.step.small-step { width: 36px; min-height: 32px; height: 32px; font-size: 1rem; }
#tuner-error:empty { display: none; }

/* metronome */
.bpm-row { display: flex; align-items: center; gap: 10px; }
.bpm-row .step { width: 40px; min-height: 40px; height: 40px; }
.bpm-value { text-align: center; min-width: 64px; display: flex; align-items: baseline; gap: 4px; justify-content: center; }
.bpm-value span { font-size: 2rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.bpm-value small { color: var(--muted); font-size: 0.75rem; }
/* The beat lights stay on one line however many beats (up to 12): each shrinks to fit rather than wrap. */
.beats { display: flex; flex-wrap: nowrap; align-items: center; justify-content: flex-end; gap: 5px; flex: 1; min-width: 0; }
.beats:has(.beat:nth-child(9)) { gap: 3px; } /* (many beats: tighter) */
/* The metronome card: up to 6 beats beside the tempo; more on a line of their own under it. */
.bpm-row { flex-wrap: wrap; }
#metro-beats:has(.beat:nth-child(7)) { flex: 1 0 100%; justify-content: center; margin-top: 4px; }
/* A beat light: an empty ring (no fill: on a white card the page colour showed as a grey disc), filled when it's the beat. */
/* A beat light: a ring (drawn as a little vector circle: CSS rings this small drew stray marks inside
   on some phones), filled when it's the beat. */
.beat { display: block; flex: 0 1 14px; min-width: 5px; aspect-ratio: 1; transition: transform 60ms; }
.beat svg { display: block; width: 100%; height: 100%; overflow: visible; }
.beat circle { fill: none; stroke: var(--muted); stroke-width: 3; transition: fill 60ms; }
.beat.accent { flex-basis: 18px; }
.beat.on { transform: scale(1.15); }
.beat.on circle { fill: var(--accent); stroke: var(--accent); }
.beats.flash .beat.on circle { fill: var(--playing); stroke: var(--playing); }
#bpm-slider { width: 100%; margin: 6px 0; accent-color: var(--accent); }

.metro-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.metro-controls button { flex: 1 1 auto; }
.select-label { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--muted); }
.select-label select { min-height: 36px; padding: 4px 8px; }
.check { display: flex; align-items: center; gap: 6px; min-height: 32px; font-size: 0.85rem; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
#match-song { margin-top: 6px; width: 100%; }

/* Short screens: drop the pitch line so everything still fits. */
@media (max-height: 760px) {
  .trace { display: none; }
}

/* ---------- dock (compact bar on phones) ---------- */
.dock-bar { display: flex; gap: 8px; align-items: stretch; }
.mini { min-height: 52px; padding: 6px 10px; display: flex; align-items: center; gap: 8px; }
.mini-tuner { flex: 1; min-width: 0; }  /* the tuner gets whatever width is left: the most */
.mini-metro { flex: 0 0 auto; justify-content: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.mini-metro small { font-weight: 400; color: var(--muted); font-size: 0.75rem; }
.dock-toggle { flex: 0 0 auto; font-size: 0.85rem; }
.mini.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mini-note { font-weight: 700; min-width: 42px; text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 0.9rem; }
.mini-cents { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 30px; }
.mini-meter { position: relative; flex: 1; height: 10px; border-radius: 5px; background: var(--bg); border: 1px solid var(--border); min-width: 40px; }
.mini-meter::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--ok-text); opacity: 0.5; }
.mini-meter i { position: absolute; top: 1px; bottom: 1px; left: 50%; width: 6px; margin-left: -3px; border-radius: 3px; background: var(--muted); opacity: 0; transition: left 90ms linear; }
.mini-tuner[data-state="intune"] .mini-meter i { background: var(--ok-text); opacity: 1; }
.mini-tuner[data-state="close"] .mini-meter i { background: var(--accent); opacity: 1; }
.mini-tuner[data-state="off"] .mini-meter i { background: var(--out-text); opacity: 1; }
.mini-tuner[data-state="intune"] .mini-note { color: var(--ok-text); }
.mini-tuner[data-state="off"] .mini-note { color: var(--out-text); }
.mini-beat { display: block; width: 14px; height: 14px; flex: 0 0 auto; }
.mini-beat svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mini-beat circle { fill: none; stroke: var(--muted); stroke-width: 3; }
.mini-beat.on circle { fill: var(--accent); stroke: var(--accent); }
.mini-beat.on.accent { transform: scale(1.35); } /* beat one: bigger, not just another colour */
.mini-beat.on.accent circle { fill: var(--playing-ring); stroke: var(--playing-ring); }

/* ---------- view options + legend ---------- */
.view-options { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin: 16px 0 6px; }
.segmented.two { min-width: 260px; }
.small-check { margin: 0; font-size: 0.9rem; }
.legend-box { margin: 8px 0 12px; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.legend-box summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.legend-box .legend { margin: 10px 0 6px; }
.legend-list { margin: 6px 0 0; padding-left: 18px; font-size: 0.85rem; color: var(--muted); }
.legend-list li { margin: 3px 0; }
.legend-list b { color: var(--text); }

/* ---------- bars & beats view ---------- */
.bars { display: flex; flex-wrap: wrap; gap: 14px 0; }
.bar {
  position: relative;
  display: flex; flex-direction: column;
  padding: 0 6px 0 8px;
  border-left: 2px solid var(--muted);
  min-width: 0;
  max-width: 100%; /* (only a bar too busy for a whole line runs onto a second row: never off the screen) */
}
.bar:last-child { border-right: 4px double var(--muted); }
.bar-num { font-size: 0.7rem; color: var(--muted); height: 14px; line-height: 14px; margin-left: -2px; }
.bar-items { display: flex; flex-wrap: wrap; gap: 10px 4px; align-items: flex-end; }

.item { display: flex; flex-direction: column; align-items: stretch; min-width: 46px; position: relative; }
.item .marks {
  font-size: 0.7rem; font-style: italic; color: var(--accent); white-space: nowrap;
  height: 16px; line-height: 16px; overflow: visible;
}
.item .marks .phrase-tag { font-style: normal; font-weight: 600; color: var(--muted); margin-right: 4px; }
.item .chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 52px; padding: 4px 6px; border-radius: 8px; border: 1px solid transparent;
  background: var(--ok-bg); color: var(--ok-text); font: inherit; cursor: pointer;
  position: relative;
}
.item .chip .pitch { font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.item .chip .len { font-size: 0.8rem; font-weight: 600; opacity: 0.85; font-variant-numeric: tabular-nums; }
.item.folded .chip { background: var(--folded-bg); color: var(--folded-text); }
.item.out .chip { background: var(--out-bg); color: var(--out-text); }
.item.rest .chip { background: transparent; border: 1px dashed var(--border); color: var(--muted); cursor: default; }
.item.rest .chip .pitch { font-weight: 400; font-size: 0.85rem; }
.item.dropped .chip .pitch { text-decoration: line-through; }
.item.tied .chip { border-left: 3px solid currentColor; }
.item.tied .chip .pitch { opacity: 0.6; font-weight: 600; }
.item .chip.playing { outline: 3px solid var(--playing-ring); outline-offset: 1px; }
.item .count, .item .lyric { font-size: 0.72rem; color: var(--muted); text-align: center; line-height: 1.3; min-height: 1.3em; }
.item .lyric { font-style: italic; color: var(--text); }
.item .count { position: relative; height: 1.3em; margin-top: 11px; } /* (room above for the playing note's hold bar) */
.item .count span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.item .count .click { color: var(--text); font-weight: 700; }
/* Counts a note or rest is held through: lighter, each after a dot. */
.item .count .count-held { opacity: 0.6; }
.item .count .count-held.beat { font-weight: 600; }
.item .count .count-held::before { content: "·"; position: absolute; right: 100%; padding-right: 3px; opacity: 0.7; }
.hide-counts .item .count { display: none; }
.hide-counts .item .lyric { margin-top: 11px; } /* (the counts' room for the hold bar, when they're hidden) */

/* slur: a curved line over the notes */
.item.slur-start::before, .item.slur-continue::before, .item.slur-stop::before {
  content: ""; position: absolute; top: 14px; left: -3px; right: -3px; height: 8px;
  border-top: 2px solid var(--accent);
}
.item.slur-start::before { left: 30%; border-left: 2px solid var(--accent); border-top-left-radius: 10px; }
.item.slur-stop::before { right: 30%; border-right: 2px solid var(--accent); border-top-right-radius: 10px; }

.breath {
  align-self: flex-start; margin: 16px -2px 0 -2px; font-size: 1.4rem; line-height: 1;
  font-weight: 700; color: var(--accent); width: 8px; text-align: center;
}
.fermata { font-style: normal; font-weight: 600; }

@media (max-width: 520px) {
  .item { min-width: 40px; }
  .item .chip { min-height: 48px; padding: 4px 3px; }
  .item .chip .pitch { font-size: 0.95rem; }
}

@media (min-width: 1000px) {
  .dock-bar { display: none; }  /* the full tools are always shown in the sidebar */
}

/* ---------- play from here ---------- */
/* Always as tall as the "From the start" button, so nothing shifts when it appears. */
.play-from { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 12px 0 0; min-height: 36px; font-size: 0.85rem; color: var(--muted); }
.play-from button { min-height: 32px; padding: 4px 12px; }
.play-from.set { color: var(--text); }

/* Practice: loop some bars, count in. */
/* Practice: a panel of tiles (Loop, Count in, Follow me), each saying what it does. */
.practice { margin: 14px 0 0; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.practice-heading { margin: 0 0 8px; font-size: 0.95rem; }
.practice-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.practice .tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 64px;
  padding: 8px 10px; text-align: left; background: var(--card); border: 1px solid var(--border); border-radius: 10px;
}
.practice .tile-name { font-weight: 700; font-size: 0.95rem; }
.practice .tile-what { font-size: 0.78rem; color: var(--muted); line-height: 1.3; }
/* On: a bold border and a tick, not colour alone. */
.practice .tile[aria-pressed="true"] { border: 2px solid var(--accent); padding: 7px 9px; }
.practice .tile[aria-pressed="true"] .tile-name::after { content: " ✓"; color: var(--accent); }
.practice .tile:disabled { opacity: 0.6; }
.practice-options { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 10px 0 0; font-size: 0.85rem; }
.practice-options.hidden { display: none; }
.practice-options .label { font-weight: 700; }
.practice-options label:not(.check) { display: inline-flex; align-items: center; gap: 6px; }
.practice select { min-height: 32px; padding: 2px 6px; }
.follow-options .hint { flex-basis: 100%; margin: 0; font-size: 0.8rem; }
/* Phones: the same buttons as a list, a full-width row each with a switch on the right (three
   narrow tiles wrapped their descriptions over several lines). */
@media (max-width: 560px) {
  .practice { padding: 4px 12px; }
  .practice-heading { margin: 8px 0 2px; }
  .practice-tiles { grid-template-columns: 1fr; gap: 0; }
  .practice .tile, .practice .tile[aria-pressed="true"] {
    display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: center;
    min-height: 52px; padding: 8px 0; border: 0; border-radius: 0; background: none;
    border-top: 1px solid var(--border);
  }
  .practice .tile:first-child { border-top: 0; }
  .practice .tile-name { grid-column: 1; }
  .practice .tile-what { grid-column: 1; }
  .practice .tile[aria-pressed="true"] .tile-name::after { content: none; }
  /* The switch: off grey, on in the accent colour with the knob to the right. */
  .practice .tile::after {
    content: ""; grid-column: 2; grid-row: 1 / span 2; width: 40px; height: 24px; border-radius: 12px;
    background: var(--border);
    background-image: radial-gradient(circle at 12px 50%, #fff 9px, transparent 9.5px);
    box-shadow: inset 0 0 0 1px var(--muted);
  }
  .practice .tile[aria-pressed="true"]::after {
    background-color: var(--accent);
    background-image: radial-gradient(circle at 28px 50%, #fff 9px, transparent 9.5px);
    box-shadow: none;
  }
  .practice .tile:disabled { opacity: 0.55; }
  .practice-options { margin: 4px 0 10px; }
}
/* Follow me, holding: how much of the note you're on you've held. */
#letters .fill-bar {
  position: absolute; left: 0; bottom: -6px; height: 3px; border-radius: 2px; width: 0;
  background: var(--playing-ring); pointer-events: none;
}
.sheet-fill {
  position: absolute; z-index: 4; height: 5px; border-radius: 3px; pointer-events: none;
  background: rgb(154 107 0 / 0.2); overflow: hidden;
}
.sheet-fill i { display: block; height: 100%; width: 0; background: #9a6b00; }
/* The ?debug=follow log. */
.follow-log {
  position: fixed; left: 8px; bottom: 80px; z-index: 50; width: min(420px, calc(100vw - 16px));
  background: rgb(0 0 0 / 0.82); color: #fff; border-radius: 8px; padding: 6px 8px;
  font: 11px/1.35 ui-monospace, Menlo, monospace;
}
.follow-log-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.follow-log-head button { min-height: 26px; padding: 2px 8px; font-size: 0.75rem; }
.follow-log pre { margin: 4px 0 0; white-space: pre-wrap; }
.count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 44px; border-radius: 50%;
  background: var(--playing-ring); color: #fff; font-weight: 800; font-size: 1.4rem;
}
/* Over the corner of the Play button, so nothing moves while it counts. */
.player, .dock .tool-row { position: relative; }
.count-badge { position: absolute; left: 88px; top: -12px; z-index: 3; box-shadow: 0 0 0 3px var(--card); }
.dock .count-badge { min-width: 30px; height: 30px; font-size: 1rem; left: 62px; top: -12px; }
/* The looped notes: a line underneath (not colour alone: the controls say which bars). */
#letters .in-loop { box-shadow: 0 3px 0 var(--focus); }
.bar-num button {
  font: inherit; font-size: 0.7rem; color: var(--muted); background: none; border: 0; padding: 0 4px;
  min-height: 0; height: 14px; line-height: 14px; border-radius: 4px; cursor: pointer;
}
.bar-num button:hover { color: var(--accent); background: var(--bg); }
.item .chip.start-here, .note.start-here, .rest-dot.start-here { box-shadow: 0 0 0 2px var(--accent); }
.item .chip.start-here::after, .note.start-here::after {
  content: "▶"; position: absolute; top: -7px; left: -5px; font-size: 0.6rem; line-height: 1;
  color: var(--accent-text); background: var(--accent); border-radius: 50%; padding: 2px 2px 2px 3px;
}
.note { position: relative; }

/* The row above the sheet music; its own bottom margin keeps a gap before the score. */
.score-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 20px 0 12px; }
.score-head h3 { margin: 0; }
.score-head .check, .score-head .switch { margin: 0; }

/* ---------- playback controls in the dock ---------- */
.mini-play { flex: 0 0 46px; justify-content: center; font-size: 1.1rem; padding: 0; background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.mini-play:disabled { background: var(--bg); color: var(--muted); border-color: var(--border); cursor: default; }
@media (max-width: 999px) { .wide-only { display: none !important; } }
#dock-play-from:empty { display: none; }

/* "Follow playback" appears when you scroll away during playback */
.follow-button {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 11;
  bottom: calc(100% + 10px); white-space: nowrap;
  background: var(--accent); color: var(--accent-text); border-color: var(--accent);
  border-radius: 999px; padding: 8px 18px; font-weight: 600;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.25);
}
@media (min-width: 1000px) {
  .follow-button { position: fixed; bottom: 24px; left: calc(50% - 180px); }
}
body.follow-shown .app-footer { padding-bottom: 80px; }
/* (and the Practice tip, floating over the foot of the page) */
body:has(.practice-coach:not(.hidden)) .app-footer { padding-bottom: 76px; }
body.follow-shown:has(.practice-coach:not(.hidden)) .app-footer { padding-bottom: 156px; }
/* A new version is ready (shell.js): a note at the top, with Reload. */
.update-note {
  position: fixed; top: calc(env(safe-area-inset-top) + 10px); left: 50%; transform: translateX(-50%); z-index: 70;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; width: max-content; max-width: calc(100vw - 24px);
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 6px 18px rgb(0 0 0 / 0.18); font-size: 0.9rem;
}
.update-note.hidden { display: none; }

/* ---------- compact headers + two-line phone dock ---------- */
.card.tool .card-head { gap: 8px; }
.card.tool .card-head h2 { margin-right: auto; }
.card.tool .card-head .stepper { gap: 4px; font-size: 0.8rem; color: var(--muted); }
.metro-controls { flex-wrap: wrap; row-gap: 6px; }
.metro-controls .check, .metro-controls .switch { white-space: nowrap; }

.mini-tuner, .mini-metro { flex-direction: column; align-items: stretch; justify-content: center; gap: 4px; }
.mini-top { display: flex; align-items: baseline; gap: 6px; min-width: 0; white-space: nowrap; }
.mini-metro .mini-top { justify-content: center; }
.mini-tuner .mini-meter { flex: 0 0 8px; height: 8px; }
.mini-metro .mini-beat { align-self: center; width: 10px; height: 10px; }
.mini-icon { font-size: 0.8rem; }

@media (max-width: 999px) {
  .dock[data-open="true"] .dock-body { max-height: 48vh; }
}
@media (max-width: 639px) {
  /* Phones: keep the open panel short so most of the screen is still music. */
  .trace, .meter-scale { display: none; }
  .tuner-readout { min-height: 48px; }
  .tuner-note { font-size: 2rem; }
  .card.tool .card-head .stepper span { font-size: 0.75rem; }
  .bpm-value span { font-size: 1.6rem; }
  .bpm-row .step { width: 36px; min-height: 36px; height: 36px; }
  #bpm-slider { margin: 2px 0; }
}
.card.tool .card-head button { white-space: nowrap; }

/* ---------- reading view: tab / sheet music / both ---------- */
.segmented.three { margin-bottom: 12px; }
#result-card:is([data-reading="tab"], [data-reading="ocarina"]) .sheet-part { display: none; }
#result-card[data-reading="ocarina"] :is(#view-modes, .view-options .naming-modes, #naming-hint) { display: none !important; } /* (the letter tab's style, and note names: the ocarina tab shows none) */
#result-card[data-reading="sheet"] .tab-part { display: none; }
#result-card[data-reading="sheet"] .score-head { margin-top: 12px; }
.reading-tabs { margin-bottom: 12px; }
#score { cursor: pointer; }
@media (max-width: 520px) {
  .segmented.three button { font-size: 0.85rem; padding: 8px 2px; }
}

/* ---------- tempo link ---------- */
.info-button { min-height: 32px; width: 32px; padding: 0; border-radius: 50%; font-size: 1rem; line-height: 1; }
.info-text { margin: 4px 0 8px; padding: 8px 10px; font-size: 0.8rem; line-height: 1.4; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.card.tool .card-head .toggle[aria-pressed="false"] { background: var(--bg); color: var(--text); border-color: var(--border); }

.toast {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 12;
  bottom: calc(100% + 64px); width: max-content; max-width: min(520px, calc(100vw - 32px));
  background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px;
  font-size: 0.9rem; box-shadow: 0 6px 20px rgb(0 0 0 / 0.3); cursor: pointer;
}
@media (min-width: 1000px) { .toast { position: fixed; bottom: 80px; left: calc(50% - 180px); } }

/* ---------- mute ---------- */
.mute-toggle { min-width: 44px; padding: 0 10px; font-size: 1.1rem; }
.mute-toggle[aria-pressed="true"] { background: var(--out-bg); border-color: var(--out-text); }
.mini-mute { flex: 0 0 44px; justify-content: center; padding: 0; }
.mini-skip { flex: 0 0 44px; justify-content: center; align-items: center; padding: 0; }
.skip-rest:not(.mini) { white-space: nowrap; }
/* Skip ahead: in the Player on wide screens (not also above the music); on phones in the bar and the
   panel's "Playing from" line. */
.music-first .player-skip, body:not(.music-first) #play-from .skip-rest { display: none; }
#dock-player .player-skip { flex-basis: 100%; }
.mini-mute:disabled { opacity: 0.5; cursor: default; }
.mini-play, .mini-mute { align-items: center; }

/* Narrow phones: make room for the note names in the dock. */
@media (max-width: 420px) {
  .dock-bar { gap: 6px; }
  .mini-tuner .mini-icon, .toggle-word, .mini-metro small { display: none; }
  .mini { padding: 6px 8px; }
  .dock-toggle { flex: 0 0 auto; justify-content: center; padding: 6px 8px; }
  .mini-note { min-width: 0; }
}

/* ---------- download menu ---------- */
.menu { position: relative; }
.menu-list {
  position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 20; width: min(330px, calc(100vw - 48px));
  display: flex; flex-direction: column; padding: 6px; gap: 2px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.25);
}
.menu-list.hidden { display: none; }
/* One line each (the name, its kind on the right; what it is in its tooltip), in two groups. */
.menu-list { width: min(280px, calc(100vw - 48px)); gap: 0; }
.menu-list button {
  text-align: left; border: 0; background: none; min-height: 36px; padding: 6px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.menu-list button:hover, .menu-list button:focus-visible { background: var(--bg); }
.menu-list small { color: var(--muted); font-size: 0.78rem; }
.menu-group { padding: 8px 10px 2px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* ---------- print / save as PDF ---------- */
@media print {
  :root, :root:not([data-theme="light"]) {
    --bg: #ffffff; --card: #ffffff; --text: #000000; --muted: #444444; --border: #999999;
    --accent: #6b4420; --accent-text: #ffffff;
    --ok-bg: #ffffff; --ok-text: #000000; --folded-bg: #eef3fb; --folded-text: #123a75;
    --out-bg: #fbe9e9; --out-text: #8a1c22; --playing: transparent; --playing-ring: transparent;
  }
  @page { margin: 14mm; }
  body { background: #fff; padding: 0 !important; font-size: 11pt; }
  .layout { display: block; max-width: none; padding: 0; }
  header, #upload-card, #options-card, .dock, .follow-button, .toast, #reading-modes, .player, .tune-from, .which-part,
  .play-from, .view-options, .edit-bar, .downloads, .score-head .check, .score-head .switch, .screen-only, .legend-box summary,
  .song-tabs, #status, #practice, .original-toggle, .original-pages, .pinned-pages, .drawer, .drawer-backdrop,
  .big-note, .skip-link, .naming-modes, .title-rename { display: none !important; }
  /* Only the music, whichever tab was showing. */
  #panel-setup { display: none !important; }
  #panel-music { display: block !important; }
  .layout { min-height: 0 !important; }
  /* The sheet music, one line of music per piece: pages break between lines, not through them. */
  body[data-printing="sheet"] #score { display: none !important; }
  .print-row { break-inside: avoid; page-break-inside: avoid; }
  .print-row svg { display: block; width: 100%; height: auto; }
  .tab-line, .phrase, .bar { break-inside: avoid; page-break-inside: avoid; }
  /* The letter tab's holds, bar lines, rest dots and underlines are drawn as backgrounds, which
     browsers leave out of printouts unless asked to keep them. */
  :is(#letters, .legend-box), :is(#letters, .legend-box) * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Room between a phrase's underlines and the dashed line under it, and the next phrase. */
  #letters .tab-line.phrase { padding-bottom: 16px; margin-bottom: 10px; }
  /* Printing the letter tab while the sheet music shows ("Letter tab as shown"). */
  body[data-printing="tab"] #result-card .sheet-part { display: none !important; }
  body[data-printing="tab"] #result-card :is(#letters, .legend-box, #tab-credits:not(.hidden)) { display: block !important; }
  .card { border: 0; padding: 0; margin: 0; box-shadow: none; }
  #song-title { font-size: 16pt; }
  .legend-box { border: 1px solid #999; margin: 6px 0 12px; }
  .legend-list { color: #000; }
  .bar { break-inside: avoid; }
  .item .chip { border: 1px solid #999; min-height: 42px; }
  .item.rest .chip { border-style: dashed; }
  .item .chip.playing, .item .chip.start-here, .note.start-here, .rest-dot.start-here { outline: none; box-shadow: none; }
  .item .chip.start-here::after, .note.start-here::after { display: none; }
  .score { background: #fff; overflow: visible; }
  #score svg { max-width: 100% !important; height: auto !important; }
  #score img { display: none !important; } /* the playback cursor */
  /* The sheet music has its own title, so skip the page's heading for it. */
  body[data-printing="sheet"] .result-head, body[data-printing="sheet"] .score-head { display: none !important; }
}

/* ---------- metronome: link to song speed ---------- */
.link-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin: 2px 0 6px; }
.link-row.hidden { display: none; }
.link-row #match-song { margin: 0 0 0 auto; width: auto; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; font-size: 0.85rem; cursor: pointer; min-height: 32px; }
/* (The real checkbox, invisible, over the drawn switch: it's what's tapped and focused.) */
.switch input { position: absolute; left: 0; top: 50%; z-index: 1; width: 34px; height: 20px; margin: 0; transform: translateY(-50%); opacity: 0; cursor: pointer; }
.switch-track {
  position: relative; flex: 0 0 auto; width: 34px; height: 20px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border); transition: background 120ms;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--muted); transition: transform 120ms, background 120ms;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(14px); background: var(--accent-text); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }
/* Phones: buttons that work a setting, drawn as the same switch. */
.ps-switch { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 4px; border: 0; background: none; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.ps-switch[aria-checked="true"] .switch-track { background: var(--accent); border-color: var(--accent); }
.ps-switch[aria-checked="true"] .switch-track::after { transform: translateX(14px); background: var(--accent-text); }
.ps-switch:focus-visible { outline: none; }
.ps-switch:focus-visible .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }
.info-text { margin: 0 0 8px; padding: 8px 10px; font-size: 0.82rem; line-height: 1.45; }
.info-text p { margin: 0; }
.info-text p + p { margin-top: 6px; }

/* ---------- letter tab (ocarina style) ---------- */
.tab-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; }
.tab-line .note { min-width: 44px; }
/* Hold = a dash after the note (a short dash: half a beat); rest = a dot. The same marks as the
   ocarina tab, the text tab ("-" and "·"), the printouts and the images. */
.hold {
  display: inline-block; width: 22px; height: 6px; border-radius: 1.5px;
  background: var(--ok-text); margin: 0 3px;
}
.hold.folded { background: var(--folded-text); }
.hold.out { background: var(--out-text); }
.hold.playing { opacity: 1; box-shadow: 0 0 0 3px var(--playing-ring); }
.tab-bar { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; }
.rest-dot { display: inline-flex; width: 26px; height: 40px; align-items: center; justify-content: center; }
/* Rests are buttons (so they can be reached with the keyboard), drawn as plain dots. */
button.rest-dot { padding: 0; min-height: 0; border: 0; border-radius: 8px; background: none; cursor: pointer; position: relative; }
button.rest-dot:hover::before { background: var(--accent); }
#result-card[data-editing="true"] button.rest-dot { cursor: cell; }
.rest-dot::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--text); }
.barline { display: inline-block; width: 2px; height: 34px; background: var(--muted); margin: 0 6px; border-radius: 1px; }
.tab-line .breath { margin: 0 2px; align-self: center; }
@media print {
  .hold { background: #000 !important; }
  .rest-dot::before { background: #000; }
  .tab-line .note { border: 1px solid #999; }
}

/* ---------- numbered-tab underlines ---------- */
.tab-line, .tab-bar { row-gap: 14px; }
.tab-line .note .under {
  position: absolute; left: 7px; right: 7px; bottom: -6px; height: 2px;
  background: currentColor; border-radius: 1px; pointer-events: none;
}
.tab-line .note .under.u2 { box-shadow: 0 4px 0 currentColor; }
.hold.half { width: 12px; }
.rest-dot { position: relative; }
.rest-dot.u1::after {
  content: ""; position: absolute; left: 6px; right: 6px; bottom: 6px; height: 2px;
  background: var(--text); border-radius: 1px;
}
@media print {
  .tab-line .note .under { background: #000; }
  .rest-dot.u1::after { background: #000; }
}

/* A rest lights up while it goes by during playback. */
.item.rest .chip.playing { outline: 3px solid var(--playing-ring); outline-offset: 1px; }
.rest-dot.playing::before { background: var(--playing-ring); box-shadow: 0 0 0 3px var(--playing-ring); }

/* ---------- conversion progress ---------- */
/* Along the bottom, clear of the header's buttons: above the bar on phones, over the music on
   wide screens. */
.progress {
  position: fixed; bottom: calc(84px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  z-index: 30; width: min(420px, calc(100vw - 32px));
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 14px;
  transition: opacity 300ms;
}
.progress.finished { opacity: 0; pointer-events: none; }
@media (min-width: 1000px) {
  .progress { bottom: 24px; left: calc(50% - 180px); }
}
.progress-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 600; margin-bottom: 8px; }
.progress-cancel { min-height: 30px; padding: 2px 10px; margin: -4px -6px -4px 0; font-size: 0.85rem; font-weight: 600; }
.progress-track { height: 8px; border-radius: 4px; background: var(--bg); border: 1px solid var(--border); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width 150ms linear; }
.progress-hint { margin: 8px 0 0; font-size: 0.8rem; color: var(--muted); }
.progress-hint:empty { display: none; }

/* Long song titles (often made from file names with no spaces) wrap instead of overflowing. */
.result-head > * { min-width: 0; max-width: 100%; }
#song-title { overflow-wrap: anywhere; }

/* Part picker with its Preview button */
.part-row { display: flex; gap: 8px; }
.part-row select { flex: 1; min-width: 0; }
.part-row button { flex: 0 0 auto; white-space: nowrap; }
#part-use, #key-use { margin-top: 8px; }

/* A tempo change in the letter tab */
.tempo-mark { font-size: 0.75rem; font-weight: 700; color: var(--accent); white-space: nowrap; font-style: normal; }
.tab-line .tempo-mark { align-self: center; margin-right: 4px; }
.bar-num .meter-mark { margin-left: 4px; font-size: 0.7rem; } /* (a time signature change, by its bar's number) */

/* ---------- fingering diagrams ---------- */
svg.fingering { display: block; width: 100%; height: auto; color: var(--text); }
svg.fingering .body { fill: none; stroke: var(--text); stroke-width: 3; stroke-linejoin: round; }
svg.fingering .hole { fill: none; stroke: var(--text); stroke-width: 2.4; }
svg.fingering .hole.covered { fill: var(--text); }
svg.fingering .half { fill: var(--text); }

/* ---------- fingerings: the 🖐 toggle and the tap-a-note card ---------- */
.fingering-open { font-weight: 600; }
.fingering-open[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.fingering-peek {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 8px 10px 10px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
}
.peek-head { display: flex; align-items: center; gap: 8px; }
.peek-note { margin-right: auto; font-size: 1.05rem; white-space: nowrap; }
.peek-head button { min-height: 32px; padding: 4px 10px; font-size: 0.8rem; }
.peek-close { width: 32px; padding: 0 !important; justify-content: center; }
.peek-diagrams { display: flex; align-items: center; gap: 8px; height: 84px; margin-top: 4px; }
.peek-diagrams .main, .peek-diagrams .alt { height: 100%; }
.peek-diagrams svg.fingering { height: 100%; width: auto; }
.peek-diagrams .alt { height: 70%; opacity: 0.85; }
.peek-diagrams .alt-label { margin: 0; font-size: 0.75rem; color: var(--muted); }
.peek-diagrams .hint { margin: 0; }
.mini-fingerings { flex: 0 0 44px; justify-content: center; padding: 0; font-size: 1.1rem; }
.mini-fingerings[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
@media (max-width: 999px) {
  /* Phones use the 🖐 in the bar; the card floats just above the bar. */
  .fingering-open { display: none; }
  /* A fixed width (wide enough for the longest name and a note with an alternate), so the card
     doesn't change size from note to note. */
  .fingering-peek { position: absolute; right: 12px; bottom: calc(100% + 8px); z-index: 11; width: min(264px, calc(100% - 24px)); }
  .dock[data-fingerings="on"] .follow-button { bottom: calc(100% + 180px); }
  .dock[data-fingerings="on"] .toast { bottom: calc(100% + 226px); }
  .dock[data-fingerings="on"][data-quiet="true"] .follow-button { bottom: calc(100% + 96px); }
  .dock[data-fingerings="on"][data-quiet="true"] .toast { bottom: calc(100% + 142px); }
}
@media (min-width: 1000px) {
  /* (Without a song: a small button at the sidebar's foot, like the one in the Player's heading.) */
  .fingering-open { width: auto; align-self: flex-end; min-height: 36px; padding: 6px 14px; font-size: 0.9rem; }
  /* Floating over the bottom corner of the music (see peek-float.js), solid so it reads clearly. */
  .fingering-peek.peek-floating { position: fixed; bottom: 16px; z-index: 30; width: 264px; }
}

/* While the song plays (unless following it) the card shrinks to its top rows, empty. */
.dock[data-quiet="true"] .peek-diagrams { display: none; }
.peek-follow { min-height: 28px; margin-top: 4px; font-size: 0.8rem; color: var(--muted); }

/* ---------- the full chart: a slide-out on wide screens, a pop-up sheet on phones ---------- */
/* Wide screens: no backdrop, so the music stays tappable and highlights its fingering. */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40;
  width: min(480px, 92vw); display: flex; flex-direction: column;
  background: var(--card); border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px rgb(0 0 0 / 0.3);
  transform: translateX(105%); transition: transform 220ms ease;
  padding-top: env(safe-area-inset-top);
}
.drawer[aria-hidden="false"] { transform: none; }
.drawer-backdrop { display: none; }
@media (max-width: 999px) {
  .drawer {
    top: calc(env(safe-area-inset-top) + 24px); left: 0; width: auto;
    border-left: 0; border-top: 1px solid var(--border); border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 30px rgb(0 0 0 / 0.3); transform: translateY(105%); padding-top: 0;
  }
  .drawer[aria-hidden="false"] { transform: none; }
  .drawer-head { padding-top: 10px; }
  .drawer-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 39; background: rgb(0 0 0 / 0.12); }
}
/* Wide screens: the open chart takes over the sidebar; the tuner and metronome shrink to the
   compact bar above it (the "More" button brings them back). */
@media (min-width: 1000px) {
  .dock[data-chart="open"] .dock-bar { display: flex; gap: 6px; }
  .dock[data-chart="open"] :is(.mini-icon, .toggle-word, .mini-fingerings) { display: none; }
  .dock[data-chart="open"] .mini { padding: 6px 8px; }
  .dock[data-chart="open"] .dock-toggle { flex: 0 0 40px; justify-content: center; }
  /* (The tap-a-note card floats over the music, so it stays up beside the open chart.) */
  .dock[data-chart="open"] :is(.dock-body, .fingering-open) { display: none; }
  .dock[data-chart="open"] .drawer {
    position: static; width: auto; transform: none; transition: none; box-shadow: none;
    border: 1px solid var(--border); border-radius: 14px; padding-top: 0;
  }
  .dock[data-chart="open"] .drawer-head { padding: 10px 12px 6px; }
  .dock[data-chart="open"] .drawer-head .hint { display: none; }
  .dock[data-chart="open"] .drawer-body { overflow: visible; padding: 6px 12px 12px; }
  .dock[data-chart="open"] .fingering-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* Very wide screens: room for the full tuner and metronome and the chart side by side. */
@media (min-width: 1600px) {
  .layout[data-chart="open"] { max-width: 1640px; grid-template-columns: minmax(0, 1fr) 700px; }
  .dock[data-chart="open"] { display: grid; grid-template-columns: 340px minmax(0, 1fr); column-gap: 20px; align-items: start; }
  .dock[data-chart="open"] .dock-bar { display: none; }
  .dock[data-chart="open"] .dock-body { display: flex; flex-direction: column; gap: 10px; grid-column: 1; grid-row: 1; }
  .dock[data-chart="open"] .drawer { grid-column: 2; grid-row: 1; margin-top: 0; }
}
.chart-options { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px 8px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; }
.drawer-head .hint { margin: 2px 0 0; }
.drawer-body { overflow-y: auto; padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.drawer-body h3 { margin: 8px 0 6px; font-size: 0.9rem; }
.drawer-legend { font-size: 0.8rem; line-height: 1.4; color: var(--muted); margin-top: 12px; }
.drawer-legend summary { cursor: pointer; }
.drawer-legend p { margin: 6px 0 0; }

/* Every note fits on one screen: 5 across in the slide-out, 4 across on phones. */
.fingering-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
@media (max-width: 999px) { .fingering-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
#fingering-panel[data-alternates="off"] .fingering-card :is(.alt, .alt-label) { display: none; }
/* Each card is a button: pressing it plays the note. */
.fingering-card {
  display: block; width: 100%; min-height: 0; text-align: left; color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 4px 5px 5px; background: var(--card); scroll-margin: 60px;
}
.fingering-card :is(.fingering-name, .alt-label, .alt) { display: block; }
.fingering-card .fingering-name { margin: 0 0 2px; font-size: 0.72rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fingering-card .alt-label { font-size: 0.7rem; color: var(--muted); margin: 4px 0 0; }
.fingering-card .alt { opacity: 0.85; }
.fingering-card.current { outline: 3px solid var(--playing-ring); outline-offset: 1px; }


/* The chart panel never goes on paper (printing the song prints the music). */
@media print { .drawer, .drawer-backdrop { display: none !important; } }

/* ---------- song library: its own page, shown instead of the song ---------- */
#library-view { display: none; }
body[data-page="library"] #library-view { display: block; }
body[data-page="library"] .content > :not(#library-view) { display: none !important; }
.library-button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.library-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.library-back { min-height: 32px; padding: 2px 6px; margin: 0 0 6px -6px; font-size: 0.9rem; }
.library-head h2 { margin: 0; }
.library-upload { margin: 4px 0 12px; }
/* A note, not an alarm: songs live in this browser. */
.library-warning {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 0.85rem; line-height: 1.4; padding: 8px 10px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border); color: var(--muted);
}
.library-warning.hidden { display: none; }
.library-warning .ic { margin-top: 2px; color: var(--accent); }
.library-warning b { color: var(--text); font-weight: 600; }
.library-search input { width: 100%; font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.song-list { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.song-row { display: flex; align-items: stretch; gap: 6px; }
.song-row.current .song-open { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.song-open {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  text-align: left; padding: 8px 12px;
}
.song-title { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-meta { font-size: 0.8rem; color: var(--muted); }
.song-title-input { flex: 1; min-width: 0; font: inherit; font-weight: 700; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--accent); background: var(--bg); color: var(--text); }
.song-rename, .song-delete { flex: 0 0 44px; padding: 0 !important; justify-content: center; }
.undo-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--text); color: var(--bg); margin-bottom: 12px; }
.undo-bar button { background: var(--bg); color: var(--text); }
.undo-bar .undo-actions { display: flex; gap: 6px; }
.library-backup { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.library-backup .status { margin: 0; }

/* ---------- editing notes (letter tab) ---------- */
.edit-toggle { margin-left: auto; }
.edit-bar {
  position: sticky; top: var(--pin-top, 0px); z-index: 5; margin: 0 0 12px;
  background: var(--card); border: 1px solid var(--accent); border-radius: 12px;
  padding: 8px 10px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 6px 16px rgb(0 0 0 / 0.18);
}
.edit-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.edit-label { margin-right: auto; display: flex; flex-direction: column; min-width: 0; }
.edit-note { font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edit-label .hint { margin: 0; font-size: 0.75rem; }
.edit-label .hint:empty { display: none; }
.edit-actions { gap: 8px; }
.edit-tip { margin: 0; font-size: 0.75rem; }
@media (hover: none) { .edit-tip { display: none; } }  /* the tip is about the mouse */
.edit-group { display: flex; gap: 4px; }
.edit-bar button:disabled { opacity: 0.4; cursor: default; }
.edit-delete:not(:disabled) { border-color: var(--out-text); }
/* In Edit mode a tap selects; show which note. Edited notes carry a small dot. */
#result-card[data-editing="true"] #letters { user-select: none; -webkit-user-select: none; }
#result-card[data-editing="true"] #letters :is(.note, .chip, .rest-dot) { cursor: cell; }
/* "Select to…": waiting for the last note. */
#result-card[data-ranging="true"] #letters :is(.note, .chip, .rest-dot):not(.selected) { outline: 1px dashed var(--accent); outline-offset: 1px; }
.edit-bar .toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
#letters :is(.note, .chip, .rest-dot).selected { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
#letters .rest-dot.selected::before { background: var(--accent); }
#letters :is(.note, .chip).edited { position: relative; }
#letters :is(.note, .chip).edited::after {
  content: ""; position: absolute; top: 2px; right: 2px; width: 6px; height: 6px;
  border-radius: 50%; background: var(--accent);
}
.edit-more { display: none; }
/* The note picker: letters, sharp/flat/octave and lengths, for the one note selected (or a new one). */
.edit-picker { display: grid; gap: 6px; }
.edit-picker.hidden { display: none; }
.picker-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }
.edit-bar .picker-row button { min-height: 38px; padding: 4px 0; justify-content: center; font-weight: 700; }
.picker-lengths button { display: flex; flex-direction: column; align-items: center; line-height: 1; gap: 1px; }
.picker-lengths small, .pick-rest small { font-size: 0.62rem; font-weight: 400; }
.pick-rest { flex-direction: column; align-items: center; line-height: 1; gap: 1px; }
.edit-bar .picker-row .pick-rest { display: flex; }
.edit-bar .picker-row button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.picker-adding { flex-wrap: nowrap; }
.picker-new { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-adding.hidden { display: none; }
/* With the picker: its letters, ♭ ♯ and lengths stand in for the step-by-step buttons. */
.edit-bar[data-picker] :is(#edit-pitch-down, #edit-pitch-up, #edit-octave-down, #edit-octave-up) { display: none; }
/* Adding a note: just the picker (and Cancel / Add). */
.edit-bar[data-adding] :is(.edit-actions, .edit-select-row) { display: none; }
/* Sent, waiting for the redrawn music: the change is shown already, faintly marked. */
#letters :is(.note, .chip, .rest-dot).pending { opacity: 0.6; }
.edit-picker, .picker-adding { min-width: 0; }
/* The note being added, before Add: dashed, where it will go. */
.ghost-note { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 40px; padding: 4px 6px;
  border: 2px dashed var(--focus, #2f6fdb); border-radius: 8px; color: var(--focus, #2f6fdb); font-weight: 700; opacity: 0.85; align-self: stretch; }
.ghost-note small { font-weight: 400; font-size: 0.65rem; }
.sheet-ghost { position: absolute; z-index: 3; width: 22px; pointer-events: none; border: 2px dashed var(--focus, #2f6fdb); border-radius: 6px;
  background: rgb(47 111 219 / 0.08); }
.sheet-ghost::after { content: attr(data-label); position: absolute; left: 50%; top: -18px; transform: translateX(-50%); white-space: nowrap;
  font: 700 11px/1 system-ui, sans-serif; color: var(--focus, #2f6fdb); background: var(--card); padding: 2px 4px; border-radius: 4px; }
/* Time signature from a bar: its choices in a row (wrapping on phones). */
.edit-meter-row { flex-wrap: wrap; gap: 4px; }
.edit-meter-row.hidden { display: none; }
.edit-meter-label { font-size: 0.85rem; color: var(--muted); margin-right: 4px; flex: 1 1 100%; }
.edit-meter-row button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.music-first .edit-bar .edit-meter-row button { min-height: 38px; flex: 1 0 18%; } /* (a long "New note: …" mustn't widen the bar) */
.music-first .edit-picker { grid-column: 1 / -1; }
/* Phones (music first): the edit tools take the bottom bar's place, as a panel at the foot of the
   screen with every button in a grid of four: pitch, then length and ties, then add, delete and
   select. Whole phrase, Clear and Reset all are behind More. */
.music-first.editing .dock { display: none; }
.music-first.editing .layout { padding-bottom: calc(var(--edit-bar-h, 240px) + 12px); }
.music-first.editing #letters :is(.note, .chip, .rest-dot) { scroll-margin-bottom: calc(var(--edit-bar-h, 240px) + 16px); }
.music-first .edit-bar {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 20; margin: 0;
  border-radius: 14px 14px 0 0; border-width: 1px 0 0;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px;
  box-shadow: 0 -6px 20px rgb(0 0 0 / 0.18);
}
.music-first .edit-bar.hidden { display: none; }
.music-first .edit-bar > .edit-row:has(#edit-note) { grid-column: 1 / -1; flex-wrap: nowrap; }
.music-first .edit-bar > .edit-row:has(#edit-note) .wide-word { display: none; }
.music-first .passage-strip { grid-column: 1 / -1; }
.music-first :is(.edit-select-row, .edit-actions, .edit-group) { display: contents; }
.music-first .edit-actions.hidden { display: none; }
.music-first .edit-tip { display: none; }
.music-first .edit-bar :is(.edit-actions, .edit-select-row) button {
  min-height: 42px; padding: 4px 2px; font-size: 0.85rem; white-space: nowrap; justify-content: center;
}
.short-label { display: none; }
.music-first .edit-actions .short-label { display: inline; }
.music-first .edit-actions .long-label { display: none; }
.music-first .edit-bar button { align-items: center; justify-content: center; }
.music-first #edit-pitch-down { order: 1; } .music-first #edit-pitch-up { order: 2; }
.music-first #edit-octave-down { order: 3; } .music-first #edit-octave-up { order: 4; }
.music-first #edit-tie { order: 7; } .music-first #edit-untie { order: 8; }
.music-first #edit-note-after { order: 9; } .music-first #edit-delete { order: 10; }
.music-first #edit-range { order: 11; } .music-first #edit-more { order: 12; display: flex; }
.music-first :is(#edit-select-phrase, #edit-clear, #edit-reset, #edit-meter) { order: 13; display: none; }
.music-first .edit-bar.more-open :is(#edit-select-phrase, #edit-clear, #edit-reset, #edit-meter) { display: flex; }
.music-first .edit-meter-row { order: 14; grid-column: 1 / -1; }
.music-first #edit-select-phrase { grid-column: span 2; }

/* ---------- note names: numbers / do-re-mi with octave dots ---------- */
.segmented.naming-modes { min-width: 0; margin-bottom: 0; }

.naming-modes button { padding: 6px 10px; font-size: 0.85rem; white-space: nowrap; }
.score-head .naming-modes { margin-left: auto; }
.named { position: relative; display: inline-block; line-height: 1; }
.named .oct {
  position: absolute; left: 50%; transform: translateX(-50%); font-size: 0.75em; line-height: 0.8;
  letter-spacing: 1px; pointer-events: none;
}
.named .oct.above { bottom: 100%; margin-bottom: 1px; }
/* Below the letter, under any underlines (short notes), as numbered tabs do. */
.named .oct.below { top: 100%; margin-top: 1px; }
.tab-line .note:has(.under.u1) .named .oct.below { margin-top: 7px; }
.tab-line .note:has(.under.u2) .named .oct.below { margin-top: 11px; }
.naming-hint { font-size: 0.85rem; margin: 6px 0; }
@media print {
  .naming-modes { display: none !important; }
  .naming-hint { display: block !important; }
}
/* Editing on the sheet music: boxes over the selection, a dot on edited notes. */
#result-card[data-editing="true"] #score { cursor: cell; user-select: none; -webkit-user-select: none; }
.sheet-mark { position: absolute; pointer-events: none; border-radius: 6px; z-index: 3; }
.sheet-mark.selected { outline: 3px solid var(--accent); background: rgb(242 193 78 / 0.18); }
.sheet-mark.edited::after {
  content: ""; position: absolute; top: -4px; right: -2px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--accent);
}
@media print { .sheet-mark { display: none; } }
.score-head .edit-toggle { margin-left: 0; }

/* ---------- keyboard ---------- */
/* One clear focus ring for everything you can reach with Tab. */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
#letters :is(.note, .chip, .rest-dot):focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* "Skip to the music": hidden until it's focused with Tab. */
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100; padding: 10px 14px; border-radius: 10px;
  background: var(--card); color: var(--text); border: 2px solid var(--focus); font-weight: 700;
}
.skip-link:focus { top: 12px; }

/* ---------- meaning that isn't only colour ---------- */
/* Text only screen readers hear. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* ↑ ↓ moved an octave, ! out of range: in the corner of the note, as well as its colour. */
.item .chip { position: relative; }
#letters :is(.note, .chip)[data-mark]::before {
  content: attr(data-mark); position: absolute; top: 2px; left: 4px;
  font-size: 0.7rem; font-weight: 800; line-height: 1; pointer-events: none;
}
.legend .dot { display: inline-flex; align-items: center; justify-content: center; font-size: 0.65rem; font-weight: 800; font-style: normal; line-height: 1; }
/* Over the sheet music (always white paper, so fixed ink colours that read on white). */
.sheet-status {
  position: absolute; pointer-events: none; z-index: 2; transform: translate(-50%, -100%);
  font: 800 13px/1 system-ui, sans-serif; padding: 1px 3px; border-radius: 4px;
}
.sheet-status.out { color: #a1262d; background: #fbe5e5; }
/* A run of notes moved an octave: a bracket under its line of music, open towards the notes it
   applies to (a dashed line, ticks pointing up where it starts and ends), and "↓ 8ve" under it. */
.sheet-run {
  position: absolute; pointer-events: none; z-index: 2; height: 7px;
  border-bottom: 1.5px dashed #6b665c;
}
.sheet-run.starts { border-left: 1.5px solid #6b665c; }
.sheet-run.ends { border-right: 1.5px solid #6b665c; }
.sheet-run span {
  position: absolute; left: 2px; top: 11px; white-space: nowrap;
  font: 500 11px/1 system-ui, sans-serif; color: #6b665c;
}

/* The loop on the sheet music (always on white paper, so fixed colours): a soft tint with blue bar
   lines where it starts and ends, and the bars outside it faded. */
.sheet-loop, .sheet-dim { position: absolute; pointer-events: none; }
.sheet-loop { z-index: 1; background: rgb(31 79 153 / 0.07); }
.sheet-loop.starts { border-left: 3px solid #1f4f99; }
.sheet-loop.ends { border-right: 3px solid #1f4f99; }
/* The handles on the loop's ends (drag one to another bar). Bigger to touch than they look. */
.loop-handle {
  position: absolute; top: 50%; width: 14px; height: 34px; margin-top: -17px; border-radius: 7px; z-index: 3;
  background: #1f4f99; box-shadow: 0 0 0 3px #fff; pointer-events: auto; cursor: ew-resize; touch-action: none;
}
.loop-handle::before { content: ""; position: absolute; inset: -12px -14px; } /* (the touch area) */
.loop-handle::after { content: ""; position: absolute; left: 4px; top: 10px; width: 4px; height: 14px; border-left: 1px solid #fff; border-right: 1px solid #fff; }
.loop-handle.start { left: -9px; }
.loop-handle.end { right: -9px; }
body.dragging-loop, body.dragging-loop * { cursor: ew-resize !important; user-select: none; }
/* The loop's bars: steppers and lengths. */
.loop-bars { display: grid; gap: 8px; }
.loop-bars.hidden { display: none; }
.loop-bars > .label { display: none; } /* (right under Loop, or on its line: it says Loop already) */
.loop-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.loop-word { min-width: 52px; font-size: 0.85rem; color: var(--muted); }
.loop-row .loop-word + .loop-step, .loop-step + .loop-word { min-width: 0; }
.loop-step { display: inline-flex; align-items: center; gap: 6px; }
.loop-step b { min-width: 1.8em; text-align: center; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.loop-step b.word { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.loop-step .step { width: 32px; min-width: 32px; min-height: 32px; padding: 0; justify-content: center; }
.segmented.loop-lengths { display: inline-flex; }
.loop-lengths button { flex: 0 0 auto; min-height: 32px; padding: 6px 12px; font-size: 0.85rem; }
.loop-lengths button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.loop-drag-hint { margin: 0; font-size: 0.8rem; }
.sheet-dim { z-index: 3; background: rgb(255 255 255 / 0.55); }

/* ---------- big note: what the tuner hears, huge and faint over the music ---------- */
.big-note {
  position: fixed; top: 0; height: 100vh; z-index: 20; pointer-events: none;
  display: flex; align-items: center; justify-content: center; gap: 0.08em;
  /* White, inverting what's behind it: a faint dark shape on the white score, a faint light one on
     the dark page, so it shows on both. */
  color: #fff; mix-blend-mode: difference;
  font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums;
  opacity: 0; transition: opacity 250ms ease;
}
/* Faint enough that the music on top stays easy to read. */
.big-note.showing { opacity: 0.12; }
.big-note-mark { font-size: 0.4em; visibility: hidden; }
.big-note[data-tune="flat"] .big-note-mark.flat,
.big-note[data-tune="sharp"] .big-note-mark.sharp { visibility: visible; }
/* In tune: a line under the note (a shape, not only a colour). */
.big-note[data-tune="in"] .big-note-name { text-decoration: underline; text-decoration-thickness: 0.06em; text-underline-offset: 0.08em; }
.big-note-check { margin-top: 6px; }
@media (prefers-reduced-motion: reduce) { .big-note { transition: none; } }
@media print { .big-note { display: none !important; } }

/* Screenshots to read: the pages in order, each with its size and cut-off checks. */
.sheet-pages { margin: 12px 0 0; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.sheet-pages.hidden { display: none; }
.sheet-pages h3 { margin: 0; font-size: 1rem; }
.sheet-pages > .hint { margin: 2px 0 8px; }
.sheet-page-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.sheet-page {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: start; padding: 8px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
}
.sheet-page img { width: 64px; height: 84px; object-fit: cover; object-position: top; background: #fff; border: 1px solid var(--border); border-radius: 4px; }
.sheet-page-info { min-width: 0; font-size: 0.9rem; }
.sheet-page-name { color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; }
.sheet-page-check { display: grid; gap: 2px; margin-top: 4px; font-size: 0.8rem; }
.page-ok { color: var(--ok-text); }
.page-warn { color: var(--out-text); font-weight: 600; }
.sheet-page-moves { display: flex; gap: 4px; }
.sheet-page-moves button { min-width: 36px; min-height: 36px; padding: 4px; }
.sheet-pages-note { margin: 8px 0 0; }
.sheet-pages-note:empty { display: none; }
.sheet-pages-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.sheet-pages-actions .add-page span { padding: 6px 12px; font-size: 0.9rem; background: var(--card); color: var(--text); border: 1px solid var(--border); font-weight: 500; }
.sheet-pages-actions .add-page.hidden { display: none; }
@media (max-width: 520px) {
  .sheet-page { grid-template-columns: 48px 1fr; }
  .sheet-page img { width: 48px; height: 64px; }
  .sheet-page-moves { grid-column: 1 / -1; justify-content: flex-end; }
}
.sheet-page-moves button:disabled { opacity: 0.35; cursor: default; }

/* A page to read, close up. */
.sheet-page-look { position: relative; padding: 0; border: 0; background: none; min-height: 0; cursor: zoom-in; }
.sheet-page-look .look-mark {
  position: absolute; right: 2px; bottom: 2px; padding: 1px 3px; font-size: 0.75rem;
  background: var(--card); border: 1px solid var(--border); border-radius: 6px;
}
/* Send feedback: a link at the foot of the page, and its form. */
.app-footer { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 12px; padding: 8px 0 16px; }
.app-footer a.link-button { display: inline-flex; align-items: center; }
/* The first-time tour: a ring around what it points at (the rest dimmed) and a bubble beside it. */
.tour-ring {
  position: fixed; z-index: 9998; pointer-events: none; border: 3px solid var(--accent); border-radius: 14px;
  box-shadow: 0 0 0 9999px rgb(0 0 0 / 0.28);
}
.tour-tip {
  position: fixed; z-index: 9999; box-sizing: border-box; padding: 12px 14px; border-radius: 12px; font-size: 0.9rem;
  background: var(--accent); color: var(--accent-text); box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
}
.tour-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tour-head b { font-size: 1rem; }
.tour-count { font-size: 0.8rem; }
.tour-tip p { margin: 6px 0 10px; }
.tour-actions { display: flex; justify-content: space-between; align-items: center; }
.tour-skip { min-height: 0; padding: 4px 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }
.tour-next { background: var(--accent-text); color: var(--accent); border: 0; }
.tour-arrow {
  position: absolute; top: -8px; border-style: solid; border-width: 0 8px 8px; border-color: transparent transparent var(--accent);
}
.tour-tip.above .tour-arrow { top: auto; bottom: -8px; border-width: 8px 8px 0; border-color: var(--accent) transparent transparent; }
/* Where saved songs live: said once, the first time one is saved. */
.saved-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
}
.saved-note p { flex: 1 1 260px; margin: 0; }
.saved-note-actions { display: flex; gap: 8px; }
.app-footer .link-button, .feedback-dialog .link-button {
  min-height: 0; padding: 4px 8px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 0.9rem;
  text-decoration: underline; cursor: pointer;
}
.feedback-dialog {
  width: min(480px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 16px;
  color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 14px;
}
.feedback-dialog::backdrop { background: rgb(0 0 0 / 0.55); }
.feedback-dialog h2 { margin: 0 0 6px; font-size: 1.1rem; }
.feedback-dialog form { display: flex; flex-direction: column; gap: 10px; }
.feedback-dialog textarea {
  width: 100%; box-sizing: border-box; padding: 8px; font: inherit; font-size: 16px; /* (16px: iPhones don't zoom in) */
  color: var(--text); background: var(--bg, var(--card)); border: 1px solid var(--border); border-radius: 8px; resize: vertical;
}
.feedback-dialog .hint { margin: 0; }
.feedback-dialog #feedback-status:empty { display: none; }
.feedback-actions { display: flex; justify-content: flex-end; gap: 8px; }
/* Image downloads, before they're saved, copied or shared (images.js). */
.images-dialog {
  width: min(980px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; overflow: hidden;
  color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 16px;
}
.images-dialog[open] { display: flex; flex-direction: column; }
.images-dialog::backdrop { background: rgb(0 0 0 / 0.55); }
.images-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; }
.images-head h2 { margin: 0; font-size: 1.1rem; }
.images-head p { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }
.images-head button { min-height: 36px; padding: 0 12px; }
.images-pages { display: grid; grid-template-columns: 1fr; align-items: start; gap: 14px; padding: 4px 16px 16px; overflow: auto; }
.images-frame { max-height: min(62vh, 760px); overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.images-page { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.images-page img { display: block; width: 100%; height: auto; }
.images-page-foot { display: flex; align-items: center; gap: 6px; }
.images-page-foot span { margin-right: auto; color: var(--muted); font-size: 0.85rem; }
.images-page-foot button { min-height: 34px; padding: 0 12px; font-size: 0.9rem; }
.images-page-foot button.done { border-color: var(--accent); color: var(--accent); }
.images-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.images-hint { margin-right: auto; color: var(--muted); font-size: 0.85rem; }
@media (max-width: 600px) {
  .images-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .images-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .images-foot button { flex: 1; }
  .images-hint:empty { display: none; }
}
.page-view {
  width: min(900px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 12px;
  display: none; flex-direction: column; gap: 8px;
  color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 14px;
}
.page-view[open] { display: flex; }
.page-view::backdrop { background: rgb(0 0 0 / 0.55); }
.page-view-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.page-view-head h2 { margin: 0; font-size: 1.05rem; }
.page-view-body { flex: 1 1 auto; min-height: 0; overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.page-view-body img { display: block; width: 100%; height: auto; }
.page-view-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.page-view-moves { display: flex; gap: 6px; margin-left: auto; }
.page-view button:disabled { opacity: 0.35; cursor: default; }
.sheet-page-check .link-button {
  display: inline; min-height: 0; margin: 0 0 0 4px; padding: 0; border: 0; background: none;
  color: var(--accent); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer;
}
.misread-note { margin: 10px 0 0; padding: 8px 12px; font-size: 0.9rem; color: var(--out-text); background: var(--out-bg); border-radius: 10px; }
.misread-note.hidden { display: none; }
.misread-note.all-checked { color: #2c6a2a; background: #e4f1e1; }
/* The checklist: a row per passage (Go to, Looks right; Undo once marked). */
/* The one-line summary above the music, and how to fix them (behind ⓘ). */
#misread-note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
#misread-note.hidden { display: none; }
.misread-line { flex: 1 1 12em; min-width: 0; } /* (narrow: Start checking wraps under it) */
.misread-line b { white-space: nowrap; }
.passage-start { min-height: 0; border: 0; border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 0.85rem; font-weight: 700;
  background: var(--accent); color: var(--accent-text); cursor: pointer; }
.misread-help { min-height: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 700; cursor: pointer; padding: 2px 4px; }
.misread-howto { flex: 1 1 100%; font-size: 0.82rem; }
.misread-howto.hidden { display: none; }
/* The passage strip, at the top of the edit tools. */
.passage-strip { position: relative; display: grid; gap: 4px; background: #fff7e6; border: 1px solid #f1d9a6; border-radius: 10px; padding: 6px 8px; color: var(--text); }
.passage-strip.hidden { display: none; }
.strip-top { display: flex; align-items: center; gap: 6px; }
.strip-which { flex: 1; min-width: 0; min-height: 0; text-align: left; border: 0; background: none; padding: 2px 0; font: inherit; font-weight: 700; cursor: pointer; color: inherit; }
.strip-which small { font-weight: 400; color: var(--muted); }
.edit-bar .strip-nav { width: 34px; min-height: 32px; padding: 0; justify-content: center; border: 1px solid var(--border); background: var(--card); border-radius: 8px; }
.passage-strip .passage-ok:disabled { opacity: 0.7; }
.strip-fix { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; }
.strip-fix span { flex: 1; }
.passage-pop { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; display: grid; gap: 2px; padding: 6px;
  max-height: 50vh; overflow: auto; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.18); }
.passage-pop.hidden { display: none; }
.music-first .passage-pop { top: auto; bottom: calc(100% + 4px); } /* (phones: the tools are at the foot of the screen) */
.passage-pop button { display: flex; gap: 8px; align-items: center; min-height: 0; text-align: left; border: 0; background: none; padding: 8px; border-radius: 8px; font: inherit; color: inherit; cursor: pointer; }
.passage-pop button.on { background: #fff4d6; font-weight: 700; }
.passage-pop .tick { width: 1.2em; color: #2c6a2a; }
.music-first .edit-bar .passage-pop button { justify-content: flex-start; min-height: 40px; }
.pop-undo { margin-left: auto; font-size: 0.8rem; text-decoration: underline; color: var(--muted); }
/* The passage you're on, marked more strongly in the music while you check. */
.sheet-suspect.current { outline: 3px solid #e0a000; outline-offset: -2px; }
#letters .suspect.current-passage { outline: 3px solid #e0a000; }
/* What the other staves suggest is wrong, with Apply: on its own line under the passage. */
.passage-fix-apply { min-height: 0; border: 1px solid var(--accent); border-radius: 999px; padding: 2px 10px; margin-left: 4px;
  font: inherit; font-size: 0.78rem; font-weight: 700; background: var(--card); color: var(--accent); cursor: pointer; }
.passage-ok { min-height: 0; border: 0; border-radius: 999px; padding: 4px 11px; font: inherit; font-size: 0.8rem; font-weight: 700;
  background: var(--accent); color: var(--accent-text); cursor: pointer; }
.misread-note .link-button { display: inline; min-height: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* Library: a reminder to back up (it lives only in this browser). */
.backup-due { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--folded-bg); color: var(--folded-text); font-size: 0.9rem; }
.backup-due.hidden { display: none; }
.backup-due p { margin: 0 0 8px; }
.backup-due-actions { display: flex; gap: 8px; }
.last-backup { margin: 4px 0 0; }
.last-backup:empty { display: none; }
.library-button { position: relative; }
.library-button.backup-due-dot::after {
  content: ""; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--out-text);
}

/* Song setup: with a song open, its settings first; then opening another song. */
#panel-setup:not([hidden]) { display: flex; flex-direction: column; }
.has-song #options-card { order: -1; }
.setup-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: -4px 0 14px; }
.setup-summary p { margin: 0; font-weight: 600; color: var(--muted); font-size: 0.9rem; flex: 1 1 auto; }
.setup-summary .hidden { display: none; }
.setup-undo { font-size: 0.85rem; color: var(--muted); }
.setup-undo .link-button, .whats-this-toggle {
  display: inline; min-height: 0; padding: 0; border: 0; background: none; color: var(--accent); font: inherit;
  font-weight: 700; text-decoration: underline; cursor: pointer;
}
.setup-group { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }
.setup-group h3 { margin: 0 0 10px; font-size: 1rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.group-purpose { font-size: 0.8rem; font-weight: 400; color: var(--muted); }
.setup-group .field:last-of-type { margin-bottom: 8px; }
.changed-tag {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; vertical-align: 1px;
  font-size: 0.7rem; font-weight: 600; background: var(--folded-bg); color: var(--folded-text);
}
.changed-tag.hidden { display: none; }
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 0 10px; }
.group-head h3 { margin: 0; }
.whats-this-toggle { font-size: 0.8rem; white-space: nowrap; }
.whats-this { margin: -4px 0 12px; padding: 8px 10px; border-radius: 8px; background: var(--bg); font-size: 0.85rem; color: var(--muted); }
.whats-this.hidden { display: none; }
.whats-this p { margin: 0; }
.whats-this p + p { margin-top: 6px; }
.setup-summary p { font-size: 0.85rem; }
.setup-group .field { margin-bottom: 10px; }
#whole-time:empty { display: none; }
#key-hint:empty { display: none; }
@media (max-width: 520px) { .group-purpose { display: none; } }
.backing-options .hint { flex-basis: 100%; margin: 0; font-size: 0.8rem; }
.backing-volume { width: 140px; }
@media (min-width: 561px) and (max-width: 760px) { .practice-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* While the song plays: the fill under a long note or rest (see showPlayFill in playback.js). */
#letters .rest-dot { position: relative; }
/* Below the playing outline (3px, 1px out) with a 3px gap, so the two don't run together; on a pale
   track the note's whole length. (The ocarina tab's outline sits tight: 1px higher.) */
#letters .play-fill { bottom: -10px; }
#letters .play-track {
  position: absolute; left: 0; right: 0; bottom: -10px; height: 3px; border-radius: 2px; pointer-events: none;
  background: color-mix(in srgb, var(--playing-ring) 25%, transparent);
}
#letters.ocarina-tab :is(.play-fill, .play-track) { bottom: -9px; }
/* Room for it above the dashed line under a phrase. (Printouts have their own: see @media print.) */
@media screen { #letters .tab-line.phrase { padding-bottom: 14px; } }

/* Song setup: the key the song is written in, beside "Key". */
.key-original { font-weight: 400; color: var(--muted); }


/* What the app is, under its name. (It stays once a song is open: hiding it then moved the whole
   page as the song arrived.) */
.app-intro { margin: 10px 0 0; max-width: 60ch; font-size: 1rem; line-height: 1.45; color: var(--text); }

/* ---------- phones: Speed, Metronome and the tuner's settings in the panel ---------- */
/* (Wide screens: the tempo under Play, and the Tuner and Metronome cards beside the music.) */
.phone-speed { margin: 14px 0 0; }
body:not(.music-first) #phone-speed { display: none; }
.dock-speed-card .phone-speed { margin: 0; }
.music-first .player .tempo { display: none; }
.music-first #tuner-card, .music-first #metronome-card { display: none; }
.ps-head { margin: 14px 0 6px; font-size: 1rem; }
.ps-head:first-child { margin-top: 0; }
.ps-row { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.ps-row .step { width: 44px; min-width: 44px; padding: 0; justify-content: center; }
.ps-bpm { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.2ch; text-align: right; }
.ps-bpm small { font-size: 0.8rem; font-weight: 500; color: var(--muted); margin-left: 4px; }
.ps-link { margin-left: auto; font-size: 0.9rem; }
#ps-slider { width: 100%; margin: 10px 0 2px; }
.ps-metro-toggle, .ps-silent { min-height: 44px; padding: 0 14px; font-weight: 600; }
.ps-silent.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.ps-beats { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.ps-beats select { min-height: 40px; width: auto; }
.ps-lights { flex: 1 0 100%; justify-content: flex-start; } /* (phones: a row of their own, under the controls) */
.ps-tuner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 14px 0 0; font-size: 0.9rem; color: var(--muted); }
.ps-tuner-label { font-weight: 700; color: var(--text); }
/* The phone menu's tabs (with a song open): Practice, Speed (and the metronome), Tuner. Each shows
   only its own part; the sound row above them is always there. */
.panel-tabs { margin: 2px 0 4px; }
.ps-tuner-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ps-tuner-head .ps-head { margin: 6px 0; }
.ps-tuner-part .tuner-display { margin: 4px 0 6px; }
.ps-tuner-part .trace { width: 100%; }
.panel-tabs button { min-height: 40px; font-weight: 600; }
.panel-tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
body:not(.music-first) .panel-tabs { display: none; }
#dock-play-panel[data-tab="practice"] #phone-speed,
#dock-play-panel:not([data-tab="practice"]) :is(#practice, #play-from),
#dock-play-panel[data-tab="speed"] .ps-tuner-part,
#dock-play-panel[data-tab="tuner"] .ps-speed-part { display: none; }
#dock-play-panel .practice-heading { display: none; } /* (the tab says it) */
#dock-play-panel #phone-speed { margin-top: 4px; }
#dock-play-panel .ps-part > .ps-head:first-child { margin-top: 6px; }
/* (Backing, when this song has no other parts: left out rather than shown unusable.) */
#dock-play-panel #backing-toggle:disabled { display: none; }
@media (max-width: 560px) {
  /* Each option on one line: its name, what it does (cut short if need be), its switch. */
  #dock-play-panel .practice .tile, #dock-play-panel .practice .tile[aria-pressed="true"] {
    grid-template-columns: auto minmax(0, 1fr) auto; min-height: 48px; padding: 6px 0; column-gap: 10px;
  }
  #dock-play-panel .practice .tile-name { grid-column: 1; grid-row: 1; white-space: nowrap; }
  #dock-play-panel .practice .tile-what { grid-column: 2; grid-row: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.8rem; }
  #dock-play-panel .practice .tile::after { grid-column: 3; grid-row: 1; }
}
.ps-tuner button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.ps-ref { display: inline-flex; align-items: center; gap: 6px; }

/* The bar's metronome: the tempo, "BPM" (or "MUTED") under it, and its beat light. Slide on it to
   change the tempo (so the page doesn't scroll from it). */
.music-first .mini-metro .mini-top { flex-direction: column; align-items: center; gap: 0; }
.music-first .mini-metro small { display: block; font-size: 9px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; line-height: 1.1; }
.mini-metro { touch-action: none; }
.tempo-bubble {
  position: fixed; z-index: 60; transform: translate(-50%, -100%); pointer-events: none;
  padding: 6px 12px; border-radius: 10px; background: var(--accent); color: var(--accent-text);
  font: 700 1.1rem/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; box-shadow: 0 4px 14px rgb(0 0 0 / 0.25);
}

/* The metronome on silent: a small pill pinned over the music (below its controls, then at the top
   as the page scrolls) with a dot per beat and a marker hopping between them (metronome.js). It
   takes no room of its own. */
.beat-pill {
  position: sticky; top: calc(var(--pin-top, 0px) + (100vh - var(--pin-top, 0px)) / 3); z-index: 5; width: max-content; margin: 6px 12px -44px auto; /* (pinned a third of the way down the screen; room on the right) */
  display: flex; align-items: center; padding: 8px 12px; border-radius: 999px; overflow: hidden; /* (markers slide out and in) */
  background: rgb(255 255 255 / 0.94); border: 1.5px solid #a89f8f; box-shadow: 0 2px 12px rgb(0 0 0 / 0.2); /* (stands out on the white page) */
}
.beat-pill.hidden { display: none; }
.bp-track { position: relative; display: flex; align-items: center; gap: 10px; height: 22px; }
.bp-dot { width: 10px; height: 10px; flex: 0 0 auto; overflow: visible; }
/* The eighths between beats (metronome eighths on): small ticks, the one sounding lit in brown. */
.bp-eighth { width: 3px; height: 9px; flex: 0 0 auto; overflow: visible; transform-origin: center; }
.bp-eighth rect { fill: #d9d2c5; }
.bp-eighth.hit { position: relative; z-index: 2; } /* (over the marker as it passes) */
.bp-eighth.hit rect { fill: #5c3a1a; }
.bp-dot circle { fill: #fff; stroke: #b8b0a1; stroke-width: 2.4; transition: stroke 0.35s ease; } /* (filled: nothing behind shows inside) */
.bp-dot.hit circle { stroke: #8b5a2b; }
.bp-marker {
  position: absolute; left: 0; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; will-change: transform;
}
.bp-marker circle { fill: #8b5a2b; }
.bp-next { opacity: 0; }
/* Beat 1: dot 1's ring in brown (the others grey), and a faint ring drifting out from it as the marker lands. */
.bp-dot:first-child circle { stroke: #8b5a2b; }
.bp-ripple { position: absolute; left: 0; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; opacity: 0; pointer-events: none; overflow: visible; }
.bp-ripple circle { stroke: #6e4520; stroke-width: 1; vector-effect: non-scaling-stroke; }

/* Sheet music read from a page: bars whose notes don't add up (likely misread), outlined in amber
   in the music itself ("check?" over the first), and their notes in the letter tab. */
/* A tint over the music (like the playback cursor's): the notes show through, nothing drawn over them. */
.sheet-suspect { position: absolute; z-index: 2; pointer-events: none; border-radius: 6px; background: rgb(240 176 77 / 0.22); }
/* Under each tint: "check?", with Looks right on the passage you're on (the only part that takes taps). */
.suspect-tag { position: absolute; left: 0; top: calc(100% + 2px); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font: 700 11px/1 system-ui, sans-serif; color: #8a5a00; background: #fff4d6; padding: 3px 6px; border-radius: 6px; }
#letters .suspect { outline: 2px dashed #c98a00; outline-offset: 2px; }

/* ---------- the ocarina tab (letter-tab.js): a fingering picture for each note, its name below ---------- */
#letters.ocarina-tab .tab-line { gap: 14px 2px; padding-bottom: 14px; align-items: flex-start; } /* (top-aligned: a bar of only rests lines up too) */
#letters.ocarina-tab .tab-bar { gap: 14px 2px; }
#letters.ocarina-tab .note.ofing {
  display: inline-flex; flex-direction: column; align-items: center; gap: 1px;
  width: 74px; min-width: 0; min-height: 0; padding: 2px 2px 12px; border: 0; border-radius: 10px;
  background: none; color: var(--ok-text);
}
#letters.ocarina-tab .note.ofing:hover { background: var(--bg); }
#letters.ocarina-tab .note.ofing.folded { background: none; color: var(--folded-text); }
#letters.ocarina-tab .note.ofing.out { background: none; color: var(--out-text); }
#letters.ocarina-tab .note.ofing.playing { background: none; outline: 3px solid var(--playing-ring); outline-offset: 0; } /* (an outline only: the picture stays clear) */
#letters.ocarina-tab .ofing-pic { display: block; width: 100%; color: var(--text); }
#letters.ocarina-tab .ofing-pic svg { display: block; width: 100%; height: auto; }
#letters.ocarina-tab .ofing-name { position: relative; font-weight: 700; font-size: 0.9rem; line-height: 1.2; }
#letters.ocarina-tab .note .under { left: 50%; right: auto; width: 34px; margin-left: -17px; bottom: 4px; color: var(--text); }
#letters.ocarina-tab .no-fingering { display: grid; place-items: center; aspect-ratio: 170 / 152; font-weight: 700; font-size: 1.4rem; border: 2px dashed currentColor; border-radius: 10px; }
/* Holds and rests at the height of the pictures' middle (not the names'). */
#letters.ocarina-tab :is(.hold, .rest-dot, .barline, .breath, .tempo-mark) { align-self: flex-start; }
#letters.ocarina-tab .hold { margin-top: 33px; }
#letters.ocarina-tab .hold.ok { background: var(--text); }
#letters.ocarina-tab .rest-dot { margin-top: 16px; }
#letters.ocarina-tab .barline { height: 62px; margin-top: 4px; }
#letters.ocarina-tab .breath { margin-top: 2px; }
#letters.ocarina-tab .tempo-mark { margin-top: 26px; }
#letters.ocarina-tab .tab-bar { align-items: flex-start; }
@media (max-width: 600px) {
  #letters.ocarina-tab .note.ofing { width: 58px; }
  #letters.ocarina-tab .hold { margin-top: 26px; }
  #letters.ocarina-tab .rest-dot { margin-top: 9px; }
  #letters.ocarina-tab .barline { height: 50px; }
  #letters.ocarina-tab .tempo-mark { margin-top: 19px; }
}
@media print {
  #letters.ocarina-tab .note.ofing { border: 0; }
}

/* Fingerings, in the ocarina tab (which has one for every note): disabled (controls.js). */
:is(#fingering-open, #mini-fingerings):disabled { opacity: 0.4; cursor: default; }

/* ---------- which part the tune comes from (tune-from.js) ---------- */
.tune-from { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 2px 0 10px; font-size: 0.9rem; color: var(--muted); }
.tune-from.hidden, .which-part.hidden { display: none; }
.tune-from b { color: var(--text); font-weight: 600; }
.tune-from .ic { width: 16px; height: 16px; }
.tune-from button { min-height: 32px; padding: 2px 10px; font-size: 0.85rem; font-weight: 600; }
.which-part { margin: 4px 0 14px; padding: 14px 14px 10px; border: 1px solid var(--accent); border-radius: 12px; background: var(--card); }
.which-part h3 { margin: 0 0 4px; font-size: 1.02rem; }
.which-part > p { margin: 0 0 10px; font-size: 0.88rem; color: var(--muted); line-height: 1.4; }
.which-part ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.which-part li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; }
.which-part li.chosen { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.which-part-play { flex: none; width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.which-part-what { flex: 1; min-width: 0; }
.which-part-what b { display: block; font-size: 0.95rem; overflow-wrap: anywhere; }
.which-part-what > span { font-size: 0.8rem; color: var(--muted); }
.which-part-badge { font-size: 0.7rem; font-weight: 700; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 1px 7px; margin-left: 6px; vertical-align: 1px; white-space: nowrap; }
.which-part li button.small { flex: none; min-height: 36px; padding: 2px 12px; font-size: 0.85rem; font-weight: 600; }
.which-part-foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; font-size: 0.82rem; }
.which-part-foot .link-button { min-height: 0; padding: 4px 0; border: 0; background: none; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; }
