/* Tune page, player and setlist pages. Muster tokens only, no new colours. */

.m-page__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
/* The PDF buttons: in the page head from 600px up, right after the sheet on phones (PdfButtons renders both copies). */
.m-tune__downloads { display: none; }
.m-tune__notes { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.m-tune__none { margin: 0; color: var(--ink-muted); font-size: 14px; }
.m-btn--round { border-radius: var(--radius-pill); }

/* Sheet viewer */
.m-sheetviewer__bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.m-sheetviewer__note { margin: 0 0 var(--space-3); padding: var(--space-3); border-radius: var(--radius-md); background: var(--surface-tint); color: var(--ink); font-size: 14px; }
.m-sheetviewer__note[hidden], .m-sheet__col[hidden] { display: none; }
.m-sheet__col { display: flex; flex-direction: column; gap: var(--space-5); flex: 1 1 0; min-width: 0; max-width: 820px; }
.m-sheet__col > .m-sheet__caption { display: none; margin: 0; }
.m-sheet__col .m-sheet__page { max-width: none; flex: none; }
.m-sheet__page > svg { display: block; width: 100%; height: auto; }
/* Generated music (B3): the desktop and phone engravings are both in the page, the screen size picks one. */
.m-sheet__page > svg.kt-music--phone { display: none; }
@media (max-width: 600px) {
  .m-sheet__page > svg.kt-music--desktop { display: none; }
  .m-sheet__page > svg.kt-music--phone { display: block; }
}
/* "No letters" reuses the lettered SVG and hides its letters. */
.m-sheet--plain svg g.verse { display: none; }
.m-sheet--dim svg.kt-music { filter: brightness(0.85); }
.m-sheet__heading { margin: 0 0 var(--space-2); font-size: 18px; font-weight: 700; color: var(--on-paper-muted); }
.m-sheet { align-items: flex-start; }
@media (max-width: 600px) {
  .m-sheetviewer__bar { padding: 0 var(--space-4); }
  /* The switch and Dim paper (dark mode only) share one row, so the sheet starts higher. */
  .m-sheetviewer__bar { flex-wrap: nowrap; }
  .m-sheetviewer__bar .m-seg { flex: 1 1 0; min-width: 0; flex-wrap: nowrap; }
  .m-sheetviewer__bar .m-seg__btn { flex: 1 1 0; min-width: 0; padding: 0 var(--space-2); text-align: center; white-space: nowrap; }
  .m-sheetviewer__bar .m-dim-toggle { flex: none; gap: var(--space-2); white-space: nowrap; }
  .m-sheetviewer__note { margin-left: var(--space-4); margin-right: var(--space-4); }
}

/* Dim paper is only offered in dark mode; a saved dim=1 does nothing in the light theme */
:root[data-theme="light"] .m-sheet--dim { background: var(--paper); }
:root[data-theme="light"] .m-sheet--dim img, :root[data-theme="light"] .m-sheet--dim svg.kt-music { filter: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .m-sheet--dim { background: var(--paper); }
  :root:not([data-theme="dark"]) .m-sheet--dim img, :root:not([data-theme="dark"]) .m-sheet--dim svg.kt-music { filter: none; }
}
.m-dim-toggle { display: none; }
:root[data-theme="dark"] .m-dim-toggle { display: flex; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .m-dim-toggle { display: flex; } }

/* Setlist navigation on the tune page */
.m-setlist-nav { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.m-setlist-nav__name { flex: 1; min-width: 0; text-align: center; font-weight: 700; color: var(--link); }
.m-setlist-nav__next svg { transform: rotate(180deg); }
.m-btn svg.m-icon { width: 18px; height: 18px; }

/* Player: A and B loop handles on the progress bar */
.m-player__pick { max-width: 60%; min-height: var(--touch-min); padding: 0 var(--space-2); border-radius: var(--radius-sm); border: 1px solid rgba(255,255,255,0.35); background: var(--brand-raised); color: var(--on-brand); font: 14px var(--font-sans); }
[data-player-seek] { cursor: pointer; touch-action: none; margin: var(--space-2) 0; }
[data-player-seek]:focus-visible { outline: 2px solid var(--on-brand); outline-offset: 6px; }
.m-progress__loop { position: absolute; top: 0; height: 100%; background: rgba(255,255,255,0.35); border-radius: 3px; pointer-events: none; }
.m-progress__handle { position: absolute; top: 50%; width: 28px; height: 28px; margin: -14px 0 0 -14px; padding: 0; border-radius: var(--radius-pill); border: 2px solid var(--brass); background: var(--brand); color: var(--on-brand); font: 700 12px/1 var(--font-sans); cursor: ew-resize; touch-action: none; }
.m-progress__handle:focus-visible { outline: 2px solid var(--on-brand); outline-offset: 2px; }
.m-btn[aria-pressed="true"].m-btn--on-brand { background: rgba(255,255,255,0.18); }

/* Loop sheet: used by the recording player and the tune player's More panel */
.m-loop-sheet { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--border); }
.m-loop-sheet[hidden] { display: none; }
.m-loop-sheet__hint { margin: 0 0 var(--space-2); font-size: 14px; color: var(--ink-muted); }
.m-loop-sheet__actions { display: flex; gap: var(--space-2); justify-content: flex-end; margin-top: var(--space-3); }
@media (max-width: 599.98px) {
  .m-tune { padding-left: 0; padding-right: 0; }
  .m-tune > .m-page__head, .m-tune > .m-setlist-nav, .m-tune .m-split__side { padding-left: var(--space-4); padding-right: var(--space-4); }
  .m-tune .m-split { gap: var(--space-4); }
}

/* Setlists */
.m-setlist-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-4); }
.m-setlist-card { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--ink); text-decoration: none; }
.m-setlist-card:hover { border-color: var(--border-control); }
.m-setlist-card__top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.m-setlist-card__name { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: var(--heading); }
.m-setlist-card__badge { padding: 2px 10px; border-radius: var(--radius-pill); background: var(--tag); color: var(--on-tag); font-size: 13px; font-weight: 700; }
.m-setlist { list-style: none; margin: var(--space-4) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); max-width: 720px; }
.m-setlist__item { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.m-setlist__pos { flex: none; width: 28px; font-family: var(--font-display); font-weight: 800; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.m-setlist__body { display: flex; flex-direction: column; min-width: 0; }
.m-setlist__title { font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--heading); }
.m-setlist__note { margin-top: var(--space-1); font-size: 14px; color: var(--ink); }


/* Tune player: a slim bar pinned to the bottom of the window (the Muster mini player pieces). On phones it floats just
   above the bottom edge (--dock-offset); the page gets room for the bar so nothing hides behind it. */
:root { --tunedock-h: 72px; --dock-offset: 0px; }
.m-tunedock { position: fixed; left: 0; right: 0; bottom: var(--dock-offset); z-index: 35; padding: 10px max(var(--space-4), env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(var(--space-4), env(safe-area-inset-left)); box-shadow: var(--shadow-float); }
/* A focused element is scrolled clear of the dock. */
html:has(.m-tunedock) { scroll-padding-bottom: calc(var(--tunedock-h) + var(--dock-offset) + 16px); }
.m-tunedock .m-mini__row, .m-tunedock__panel { max-width: var(--content-max); margin-left: auto; margin-right: auto; }
.m-tunedock .m-mini__row { gap: var(--space-3); }
.m-tunedock .m-mini__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-tunedock__follow { flex: none; padding: 0 var(--space-3); font-size: 14px; }
.m-tunedock__panel { position: absolute; left: 0; right: 0; bottom: 100%; margin-top: 0; padding: var(--space-4); background: var(--surface); border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-float);
  /* Never taller than the room above the dock, so its top stays inside the window; it scrolls instead. */
  max-height: calc(100vh - var(--tunedock-h) - var(--dock-offset) - 8px); max-height: calc(100dvh - var(--tunedock-h) - var(--dock-offset) - 8px); overflow-y: auto; overscroll-behavior: contain; }
.m-tunedock__tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-4); margin-bottom: var(--space-3); }
.m-tunedock__tools[hidden] { display: none; }
.m-tunedock__field { display: flex; flex-direction: column; gap: var(--space-1); font-size: 14px; color: var(--ink-muted); }
.m-tunedock__field input[type="number"] { width: 5em; font-variant-numeric: tabular-nums; }
.m-tunedock input[type="range"] { width: 200px; max-width: 100%; min-height: var(--touch-min); accent-color: var(--primary); }
.m-tunedock input[type="number"], .m-tunedock select { height: var(--touch-min); padding: 0 var(--space-2); border-radius: var(--radius-sm); border: 1px solid var(--border-control); background: var(--surface); color: var(--ink); font: 16px var(--font-sans); }
.m-tunedock__check { display: flex; align-items: center; gap: var(--space-2); min-height: var(--touch-min); font-size: 15px; color: var(--ink); cursor: pointer; }
.m-tunedock__check input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }
.m-tunedock__panel .m-loop-sheet__hint { margin: 0; }
.m-tunedock noscript .m-loop-sheet__hint { margin: var(--space-2) 0 0; }
.m-tune.m-tune--dock { padding-bottom: calc(var(--space-6) + var(--tunedock-h)); }
@media (max-width: 899.98px) {
  .m-tunedock__panel:not([data-open="true"]) { display: none; }
}
@media (min-width: 900px) {
  .m-tunedock__more { display: none; }
  .m-tunedock .m-mini__text { flex: 0 0 auto; min-width: 96px; }
  .m-tunedock__panel { position: static; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); flex: 1 1 auto; margin: 0; padding: 0; background: transparent; border: 0; border-radius: 0; box-shadow: none; max-height: none; overflow: visible; }
  .m-tunedock__panel .m-tunedock__tools { margin-bottom: 0; gap: var(--space-3); align-items: center; }
  .m-tunedock__panel .m-tunedock__field { flex-direction: row; align-items: center; gap: var(--space-2); }
  .m-tunedock__panel input[type="range"] { width: 130px; min-height: 36px; }
  .m-tunedock__panel select, .m-tunedock__panel .m-tunedock__check { min-height: 36px; }
  .m-tunedock__panel .m-loop-sheet__hint { display: none; }
}
@media (max-width: 599.98px) {
  /* The player floats 8px above the bottom (or the home indicator's safe area less 8px), 10px in from the sides. */
  :root { --dock-offset: max(var(--space-2), calc(env(safe-area-inset-bottom) - var(--space-2))); }
  .m-tunedock { left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); padding: 10px var(--space-3) 12px; border: 1px solid var(--border); border-radius: 16px; }
  .m-tunedock__follow { padding: 0 var(--space-2); }
  /* With "Follow the music" showing there's no room for the title; the status still says "Playing". */
  .m-tunedock:has([data-tune-follow]:not([hidden])) .m-mini__title { display: none; }
}

@media print { .m-tunedock { display: none; } .m-tune.m-tune--dock { padding-bottom: 0; } }

/* The note being played. The sheet is always on paper, so --note-playing (3:1 or better on white and both dim papers)
   fills the note and its stem but not the letter above it (g.verse), which keeps its blue or red. */
.m-sheet svg .kt-note-playing :not(.verse):not(.verse *), .m-sheet svg .kt-note-playing:not(.verse) { fill: var(--note-playing); stroke: var(--note-playing); }

/* Phone: the sheet comes first, then the side-panel items in DOM order (Letter key first, Reference audio last). */
@media (max-width: 599.98px) {
  .m-tune .m-split { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
  .m-tune .m-split__main { flex: none; order: 1; }
  .m-tune .m-split__side { display: contents; }
  .m-tune .m-split__side > * { order: 2; margin-left: var(--space-4); margin-right: var(--space-4); }
  /* Setlist nav: the buttons wrap a long neighbour title, and the setlist name takes its own row on top */
  .m-setlist-nav .m-btn { white-space: normal; min-width: 0; max-width: 100%; text-align: left; line-height: 1.25; padding-block: var(--space-2); }
  .m-setlist-nav__name { flex-basis: 100%; order: -1; }
}

/* Reference audio: collapsed disclosure so members intentionally open it as a separate feature. */
.m-audio { padding: 0; overflow: hidden; }
.m-audio__summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: var(--touch-min); padding: 14px 18px; cursor: pointer; list-style: none; }
.m-audio__summary::-webkit-details-marker { display: none; }
.m-audio__summary .m-panel__title { margin: 0; }
.m-audio__summary:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: var(--radius-lg); }
.m-audio__state { display: inline-flex; align-items: center; gap: var(--space-2); }
.m-audio__meta { font-size: 13px; color: var(--ink-muted); }
.m-audio__state .m-icon { width: 18px; height: 18px; color: var(--ink-muted); transform: rotate(-90deg); transition: transform 140ms; }
.m-audio__details[open] .m-audio__state .m-icon { transform: rotate(90deg); }
.m-audio__details:not([open]) > .m-audio__body { display: none; }
.m-audio__body { padding: 0 18px 18px; }
@media (max-width: 599.98px) {
  .m-audio__summary { padding: 12px var(--space-4); }
  .m-audio__body { padding: 0 var(--space-4) var(--space-4); }
}
@media (prefers-reduced-motion: reduce) {
  .m-audio__state .m-icon { transition: none; }
}

/* Phone (J3): the head holds only the title, so the sheet starts right under it; the two PDF buttons share one row
   after the sheet. */
@media (max-width: 599.98px) {
  .m-tune .m-page__head > div { min-width: 0; }
  .m-tune .m-page__actions { display: none; }
  .m-tune__downloads { display: flex; gap: var(--space-2); margin-top: var(--space-3); padding: 0 var(--space-4); }
  .m-tune__downloads .m-btn { flex: 1 1 0; min-width: 0; white-space: normal; text-align: left; line-height: 1.2; padding: var(--space-2) var(--space-3); font-size: 14px; }
  .m-sheetviewer__bar { gap: var(--space-2); margin-bottom: var(--space-2); }
}

.m-tune__draft { margin: var(--space-3) 0 0; }
@media (max-width: 599.98px) {
  .m-tune__draft { padding: 0 var(--space-4); }
}
.m-tune__versions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
