/* Muster components. Every colour, space and radius comes from tokens.css.
   Class names are BEM-style with the m- prefix; each block maps to one Razor component. */

.m-root { background: var(--bg); color: var(--ink); font-family: var(--font-sans); font-size: 16px; line-height: 24px; }
.m-root *, .m-root *::before, .m-root *::after { box-sizing: border-box; }
.m-root :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.m-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.m-icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.m-icon--solid { fill: currentColor; stroke: none; }

/* Layout */
.m-page { max-width: var(--content-max); margin: 0 auto; padding: var(--space-6) var(--space-5) var(--space-7); }
.m-page__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); }
.m-page__title { margin: 0 0 6px; font-family: var(--font-display); font-size: 36px; line-height: 40px; font-weight: 800; letter-spacing: -0.01em; color: var(--heading); text-wrap: balance; }
.m-page__lede { margin: 0; color: var(--ink-muted); }
.m-split { display: flex; flex-wrap: wrap; gap: var(--space-5); align-items: flex-start; }
.m-split__main { flex: 999 1 560px; min-width: 0; }
.m-split__side { flex: 1 1 300px; max-width: 100%; display: flex; flex-direction: column; gap: var(--space-4); }
@media (max-width: 600px) {
  .m-page { padding: var(--space-5) var(--space-4) var(--space-7); }
  .m-page__title { font-size: 28px; line-height: 32px; }
}

/* AppHeader */
.m-header { background: var(--brand); color: var(--on-brand); }
.m-header :focus-visible { outline-color: var(--on-brand); }
.m-header__inner { max-width: var(--content-max); margin: 0 auto; padding: 14px var(--space-5); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4) 28px; }
.m-brand { display: flex; align-items: center; min-height: var(--touch-min); gap: var(--space-3); color: var(--on-brand); text-decoration: none; }
.m-brand__mark { width: 34px; height: 38px; flex: none; object-fit: contain; }
.m-brand__mark .shield { fill: none; stroke: var(--brass); stroke-width: 2.5; }
.m-brand__mark .lines { stroke: var(--on-brand); stroke-width: 2; }
.m-brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.m-brand__name { font-family: var(--font-display); font-weight: 800; font-size: 17px; }
.m-brand__sub { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--on-brand-muted); }
.m-nav { display: flex; flex-wrap: wrap; gap: var(--space-1); flex: 1 1 auto; }
.m-nav__link { display: inline-flex; align-items: center; min-height: var(--touch-min); padding: 0 14px; border-radius: var(--radius-sm); color: var(--on-brand-muted); text-decoration: none; font-weight: 700; font-size: 15px; }
.m-nav__link:hover { color: var(--on-brand); }
.m-nav__link[aria-current="page"] { color: var(--on-brand); background: rgba(255,255,255,0.12); }
.m-avatar { width: var(--touch-min); height: var(--touch-min); border-radius: var(--radius-pill); border: 2px solid var(--brass); background: var(--brand-raised); color: var(--on-brand); font: 700 15px var(--font-sans); cursor: pointer; }

/* PhoneHeader */
.m-phone-header { background: var(--brand); color: var(--on-brand); padding: var(--space-2) var(--space-2) var(--space-3); }
.m-phone-header :focus-visible { outline-color: var(--on-brand); }
.m-phone-header__row { display: flex; align-items: center; gap: var(--space-1); }
.m-phone-header__titles { flex: 1; min-width: 0; }
.m-phone-header__title { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 18px; line-height: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-phone-header__meta { margin: 2px 0 0; font-size: 13px; color: var(--on-brand-muted); }
.m-phone-header .m-seg { margin: var(--space-2) var(--space-2) 0; display: flex; }

/* Button */
.m-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--touch-min); padding: 0 var(--space-4); border-radius: var(--radius-md); border: 1px solid transparent; font: 700 15px/1 var(--font-sans); text-decoration: none; cursor: pointer; white-space: nowrap; }
.m-btn--primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.m-btn--secondary { background: var(--surface); color: var(--link); border-color: var(--border-control); }
.m-btn--secondary:hover { background: var(--surface-tint); }
.m-btn--on-brand { background: transparent; color: var(--on-brand); border-color: rgba(255,255,255,0.35); }
.m-btn--icon { width: var(--touch-min); padding: 0; }
.m-btn--ghost { background: transparent; color: inherit; border-color: transparent; }
.m-btn--float { width: var(--touch-min); padding: 0; border-radius: var(--radius-pill); background: var(--surface); color: var(--link); border-color: var(--border-control); box-shadow: var(--shadow-float); font-size: 22px; }
.m-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* PlayButton */
.m-play { display: inline-flex; align-items: center; justify-content: center; flex: none; border: 0; border-radius: var(--radius-pill); cursor: pointer; }
.m-play--lg { width: var(--play-lg); height: var(--play-lg); background: var(--brass); color: var(--on-brass); }
.m-play--md { width: var(--play-md); height: var(--play-md); background: var(--primary); color: var(--on-primary); }
.m-play--pill { gap: var(--space-2); height: var(--touch-min); padding: 0 14px 0 8px; background: var(--surface); color: var(--link); border: 1px solid var(--border-control); font: 700 14px var(--font-sans); font-variant-numeric: tabular-nums; }
.m-play--pill .m-play__dot { width: 24px; height: 24px; border-radius: var(--radius-pill); background: var(--primary); color: var(--on-primary); display: inline-flex; align-items: center; justify-content: center; }
.m-play svg { width: 40%; height: 40%; }
.m-play--pill svg { width: 12px; height: 12px; }

/* SegmentedControl */
.m-seg { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); padding: var(--space-1); background: var(--surface-sunken); border-radius: 12px; }
.m-seg__btn { flex: 1 0 auto; min-height: var(--touch-min); padding: 0 var(--space-4); border: 0; border-radius: 9px; background: transparent; color: var(--ink); font: 700 15px var(--font-sans); cursor: pointer; }
a.m-seg__btn, a.m-chip { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.m-seg__btn[aria-pressed="true"], .m-seg__btn[aria-current="page"] { background: var(--surface); color: var(--heading); box-shadow: var(--shadow-selected); }
.m-seg--on-brand { background: rgba(255,255,255,0.12); }
.m-seg--on-brand .m-seg__btn { color: var(--on-brand); }
.m-seg--on-brand .m-seg__btn[aria-pressed="true"], .m-seg--on-brand .m-seg__btn[aria-current="page"] { background: var(--on-brand); color: var(--brand); box-shadow: none; }
/* Dark mode: --surface on --surface-sunken is nearly the same navy, so the chosen segment takes --primary with
   --on-primary text (like a pressed chip) and the track gets a --border edge. Not on navy (m-seg--on-brand). */
[data-theme="dark"] .m-seg:not(.m-seg--on-brand), [data-theme="dark"] .m-theme { box-shadow: inset 0 0 0 1px var(--border); }
[data-theme="dark"] .m-seg:not(.m-seg--on-brand) .m-seg__btn:is([aria-pressed="true"], [aria-current="page"]), [data-theme="dark"] .m-theme .m-seg__btn[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .m-seg:not(.m-seg--on-brand), :root:not([data-theme="light"]) .m-theme { box-shadow: inset 0 0 0 1px var(--border); }
  :root:not([data-theme="light"]) .m-seg:not(.m-seg--on-brand) .m-seg__btn:is([aria-pressed="true"], [aria-current="page"]), :root:not([data-theme="light"]) .m-theme .m-seg__btn[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
}

/* SearchField */
.m-search { position: relative; display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 14px; background: var(--surface); border: 1px solid var(--border-control); border-radius: var(--radius-md); color: var(--ink-muted); min-width: 0; }
.m-search:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.m-search__input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--ink); font: 16px var(--font-sans); }
.m-search__input::placeholder { color: var(--ink-muted); }

/* FilterChip */
.m-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.m-chip { min-height: var(--touch-min); padding: 0 14px; border-radius: var(--radius-pill); border: 1px solid var(--border-control); background: var(--surface); color: var(--link); font: 700 14px var(--font-sans); cursor: pointer; }
.m-chip[aria-pressed="true"], .m-chip[aria-current="page"], .m-chip[aria-current="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

/* CategoryFilter */
.m-category-picker { min-width: 0; }
.m-category-picker__summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 0 14px; border: 1px solid var(--border-control); border-radius: var(--radius-md); background: var(--surface); cursor: pointer; list-style: none; }
.m-category-picker__summary::-webkit-details-marker { display: none; }
.m-category-picker__summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.m-category-picker__summary .m-label { margin: 0; }
.m-category-picker__selection { color: var(--ink-muted); font-size: 13px; }
.m-category-picker[open] .m-category-picker__summary { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.m-category-picker__panel { padding: 12px; border: 1px solid var(--border-control); border-top: 0; border-radius: 0 0 var(--radius-md) var(--radius-md); background: var(--surface); }
.m-category-picker__options { display: grid; max-height: 300px; margin-top: 10px; overflow-y: auto; }
.m-category-picker__option { min-height: 40px; }
.m-category-picker__clear { display: inline-flex; align-items: center; margin-top: 10px; }

/* Checkbox */
.m-check { display: flex; align-items: center; gap: 10px; min-height: var(--touch-min); font-size: 15px; color: var(--ink); cursor: pointer; }
.m-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }

/* Panel and group label */
.m-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.m-panel__title { margin: 0 0 10px; font-family: var(--font-display); font-size: 17px; line-height: 22px; font-weight: 700; color: var(--heading); }
.m-label { margin: 0 0 10px; font-size: 13px; line-height: 16px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); }

/* Breadcrumb */
.m-crumb { font-size: 14px; color: var(--ink-muted); }
.m-crumb a { color: var(--link); font-weight: 700; }
.m-crumb__sep { margin: 0 6px; }

/* TuneTable */
.m-table-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.m-table-scroll { overflow-x: auto; }
.m-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 15px; }
.m-table th { padding: var(--space-3); text-align: left; background: var(--bg); color: var(--ink-muted); font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.m-table td { padding: var(--space-3); border-top: 1px solid var(--border); vertical-align: middle; }
.m-table th:first-child, .m-table td:first-child { padding-left: 18px; }
.m-table th:last-child, .m-table td:last-child { padding-right: 18px; text-align: right; white-space: nowrap; }
.m-table__actions { display: inline-flex; gap: 6px; }
.m-tune-link { font-family: var(--font-display); font-weight: 700; font-size: 16px; line-height: 22px; color: var(--heading); text-decoration: none; }
.m-tune-link:hover { text-decoration: underline; }
.m-meta { font-size: 13px; color: var(--ink-muted); margin-top: 2px; }
.m-soon { font-size: 14px; color: var(--ink-muted); }

/* TuneCard */
.m-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-4); }
.m-tune-card { display: flex; gap: 14px; align-items: center; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; color: var(--ink); text-decoration: none; }
.m-tune-card:hover { border-color: var(--border-control); }
.m-tune-card__thumb { width: 56px; height: 72px; flex: none; object-fit: cover; object-position: top; background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius-xs); }
.m-tune-card__name { display: block; font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--heading); }
.m-tune-card__meta { display: block; font-size: 14px; color: var(--ink-muted); }

/* RecordingPlayer (full) */
.m-player { background: var(--brand); color: var(--on-brand); border-radius: var(--radius-lg); padding: 20px; }
.m-player :focus-visible { outline-color: var(--on-brand); }
.m-player__head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; gap: var(--space-3); }
.m-player__title { margin: 0; font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.m-player__source { font-size: 13px; color: var(--on-brand-muted); }
.m-player__row { display: flex; align-items: center; gap: 14px; }
.m-player__bar { flex: 1; min-width: 0; }
.m-progress { position: relative; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.2); }
.m-progress__fill { height: 100%; border-radius: 3px; background: var(--brass); }
.m-progress__knob { position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: var(--radius-pill); background: var(--on-brand); }
.m-player__times { display: flex; justify-content: space-between; margin-top: var(--space-2); font-size: 13px; color: var(--on-brand-muted); font-variant-numeric: tabular-nums; }
.m-player__tools { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); align-items: center; }
.m-player__speed { display: flex; align-items: center; gap: var(--space-2); font-size: 14px; color: var(--on-brand-muted); }
.m-player__speed select { 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: 15px var(--font-sans); }
.m-player__hint { margin: 14px 0 0; font-size: 13px; color: var(--on-brand-muted); }
.m-player--empty .m-player__hint { margin: 0; }

/* MiniPlayer (phone) */
.m-mini { background: var(--surface); border-top: 1px solid var(--border); padding: 10px 14px 12px; }
.m-mini .m-progress { height: 4px; background: var(--surface-sunken); margin-bottom: 10px; }
.m-mini .m-progress__fill { background: var(--primary); }
.m-mini__row { display: flex; align-items: center; gap: var(--space-3); }
.m-mini__text { flex: 1; min-width: 0; }
.m-mini__title { font-weight: 700; font-size: 15px; color: var(--ink); }
.m-mini__time { font-size: 13px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.m-mini__speed { min-height: var(--touch-min); padding: 0 var(--space-3); border-radius: var(--radius-pill); border: 1px solid var(--border-control); background: var(--surface); color: var(--link); font: 700 14px var(--font-sans); }

/* SheetViewer */
.m-sheet { position: relative; display: flex; gap: 20px; justify-content: center; padding: var(--space-5); background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.m-sheet__page { margin: 0; flex: 1 1 0; min-width: 0; max-width: 820px; }
.m-sheet__page img { display: block; width: 100%; height: auto; }
.m-sheet__caption { margin-bottom: var(--space-2); font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--on-paper-muted); }
.m-sheet--dim { background: var(--paper-dim); }
.m-sheet--dim img { filter: brightness(0.85); }
.m-sheet__zoom { position: absolute; top: var(--space-3); right: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
@media (max-width: 600px) { .m-sheet { padding: 0; border-radius: 0; border: 0; } }

/* LetterKey */
.m-key { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px var(--space-3); font-size: 14px; color: var(--ink); }
.m-key__note { font-family: var(--font-display); font-weight: 800; color: var(--note); margin-right: 6px; }
.m-key__note--ornament { color: var(--note-ornament); }
.m-key__link { margin: var(--space-3) 0 0; }

/* PartsList */
.m-parts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.m-part { display: flex; justify-content: space-between; align-items: center; min-height: var(--touch-min); padding: 0 var(--space-3); border-radius: var(--radius-sm); color: var(--link); font-weight: 700; text-decoration: none; }
.m-part:hover { background: var(--bg); }
.m-part[aria-current="page"] { background: var(--surface-tint); color: var(--heading); }
.m-part__state { font-size: 13px; font-weight: 400; color: var(--ink-muted); }
.m-part--none { color: var(--ink-muted); font-weight: 400; font-size: 14px; }

/* SetlistTag */
.m-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.m-tag { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: var(--radius-pill); background: var(--tag); color: var(--on-tag); font-size: 14px; font-weight: 700; text-decoration: none; }

/* Menu button (.m-navbtn) and NavDrawer (phones, below 600px): the header's menu button opens a left-hand drawer, an HTML
   popover (open, Escape and a tap outside work without JS). The head is navy like the header; the current section is a
   tinted row in bold with a brass edge, so the brass is never the only signal. */
.m-navbtn { display: none; align-items: center; justify-content: center; flex: none; width: var(--touch-min); height: var(--touch-min); padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--on-brand); cursor: pointer; }
.m-navbtn:hover { background: rgba(255,255,255,0.12); }
.m-drawer { position: fixed; inset: 0 auto 0 0; width: min(300px, 85vw); height: 100%; max-height: none; margin: 0; padding: 0 0 env(safe-area-inset-bottom) env(safe-area-inset-left); border: 0; border-right: 1px solid var(--border); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-float); overflow-y: auto; overscroll-behavior: contain; font-family: var(--font-sans);
  transform: translateX(-100%); transition: transform 200ms ease, overlay 200ms allow-discrete, display 200ms allow-discrete; }
.m-drawer:popover-open { display: flex; flex-direction: column; transform: none; }
@starting-style { .m-drawer:popover-open { transform: translateX(-100%); } }
.m-drawer::backdrop { background: rgba(0,0,0,0.45); transition: background-color 200ms, overlay 200ms allow-discrete, display 200ms allow-discrete; }
@starting-style { .m-drawer:popover-open::backdrop { background: rgba(0,0,0,0); } }
@media (max-width: 599.98px) { html:has(.m-drawer:popover-open) { overflow: hidden; } }
.m-drawer :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.m-drawer__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: 10px var(--space-2) 10px var(--space-4); padding-top: max(10px, env(safe-area-inset-top)); background: var(--brand); color: var(--on-brand); }
.m-drawer__head :focus-visible { outline-color: var(--on-brand); }
.m-drawer__close { display: inline-flex; align-items: center; justify-content: center; flex: none; width: var(--touch-min); height: var(--touch-min); padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--on-brand); cursor: pointer; }
.m-drawer__close:hover { background: rgba(255,255,255,0.12); }
.m-drawer__nav { display: flex; flex-direction: column; gap: 2px; padding: var(--space-3) var(--space-2); }
.m-drawer__link { display: flex; align-items: center; gap: var(--space-3); min-height: 48px; padding: 0 var(--space-3); border-radius: var(--radius-md); color: var(--ink); font-size: 16px; text-decoration: none; }
.m-drawer__link .m-icon { flex: none; width: 22px; height: 22px; color: var(--ink-muted); }
.m-drawer__link:hover { background: var(--surface-tint); }
.m-drawer__link[aria-current="page"] { background: var(--surface-tint); color: var(--heading); font-weight: 700; box-shadow: inset 4px 0 0 var(--brass); }
.m-drawer__link[aria-current="page"] .m-icon { color: var(--heading); }
.m-drawer__more { display: flex; flex-direction: column; gap: var(--space-1); margin: 0 var(--space-2); padding: var(--space-3) 0 var(--space-5); border-top: 1px solid var(--border); }
.m-drawer__label { margin: var(--space-3) var(--space-3) var(--space-1); }
.m-drawer__more form { padding: 0 var(--space-3); }
/* The theme choice fills the drawer's width in three equal, centred buttons, so it never runs past the edge. */
.m-drawer .m-theme { display: flex; }
.m-drawer .m-theme .m-seg__btn { flex: 1 1 0; min-width: 0; justify-content: center; padding: 0 var(--space-2); }
@media (prefers-reduced-motion: reduce) { .m-drawer, .m-drawer::backdrop { transition: none; } }
@media (min-width: 600px) { .m-drawer:popover-open { display: none; } }

/* ThemeToggle */
.m-theme { display: inline-flex; gap: var(--space-1); padding: var(--space-1); background: var(--surface-sunken); border-radius: 12px; }
.m-theme .m-seg__btn { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }

/* F1: free text from data (titles, notes, source links) breaks anywhere rather than widening a phone page. Here, not in tune.css, because the library and catalog don't load tune.css. */
.m-page__title, .m-tune .m-meta, .m-tune-link, .m-tune-card__name, .m-tune-card__meta, .m-setlist__title, .m-setlist__note { overflow-wrap: anywhere; }
