/* Brateng Music v3 — base styles.
 *
 * Lifted from the approved kid mockup (design/build_v3_kid_mockups.py, its CSS
 * string) — tokens, radii, sizes and icon metrics carried verbatim where the
 * spec does not override. What the mockup hard-codes as one frame is here split
 * into: the stage scaffold, the shared chrome, the boot screens, and the shared
 * player component (SPEC v3 §5), which is defined ONCE and reskinned per shell.
 *
 * Browser floor (SPEC v3 §8.1): Chrome 96 (Fire kiosk) intersect Safari 15
 * (iPad Air 2). Nothing below uses :has(), container queries, @layer, CSS
 * nesting, text-wrap, overscroll-behavior, :focus-visible or the dvh units.
 * -webkit- prefixes are carried on mask-image, appearance and user-select.
 * :focus-visible's substitute is plain :focus plus a script-set .kbfocus class
 * (§8.1); scroll containment is by layout, since overscroll-behavior is Safari 16.
 */

/* ---------------------------------------------------------------- reset */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%;
  background: #000;
  overflow: hidden;
  color: var(--text);
  font: 19px/1.3 -apple-system, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
}
#app { position: absolute; inset: 0; }
img { max-width: 100%; }

/* ------------------------------------------------------------- the stage
 * The kid shell is a fixed 1024x768 canvas scaled to the viewport by
 * js/shells/kid.js (the mockup's own fit()). The kiosk scales by WIDTH only
 * (§8.1) and the phone is fluid CSS px (§6.3) — both land in later stages and
 * override .stage's sizing; everything inside it is shared.
 */
.stage {
  position: absolute; left: 0; top: 0;
  width: 1024px; height: 768px;
  transform-origin: 0 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
.stage button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; text-align: left; }
.stage button:active { transform: scale(.97); }
.stage button[disabled], .stage button.off { opacity: .45; pointer-events: none; }
.ico { width: 1em; height: 1em; fill: currentColor; display: block; }

/* Keyboard focus ring — :focus-visible is above the Safari 15 floor (§8.1), so
   the class is set by script on Tab and cleared on pointerdown. */
.stage :focus { outline: none; }
.kbfocus .stage :focus { outline: 2px solid var(--accent2); outline-offset: 2px; }

.scr { position: absolute; inset: 0; display: none; }
.scr.on { display: flex; }

/* Art wash — STRONG on every shell (§5). --tint/--tint2 are rewritten from the
   cover's dominant colour; subtle was refused on the glass and is not an option. */
.wash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s;
  background: radial-gradient(900px 760px at 22% 52%, var(--tint) 0%, var(--tint2) 45%, transparent 75%);
}
.stage.playing .wash { opacity: 1; }

/* ------------------------------------------------------- shared chrome
 * EVERY SHARED-CHROME RULE HERE IS SCOPED `.stage X`, NOT BARE `X`. The
 * button reset above is `.stage button` — specificity (0,1,1) — so a bare
 * `.homebtn` / `.pill` / `.add` / `.listbtn` / `.nowbar` at (0,1,0) LOSES to it
 * on every one of these controls, which are all <button>s. The approved mockup
 * carries the same two selectors and therefore the same defect: its declared
 * CSS and its rendered output disagree, and what rendered was Search and
 * Bedtime as two identical flat labels, a now-playing bar with no pill and
 * three of the four Home buttons as bare glyphs (§6.2's "Search is a solid
 * pill", D33/§5b item 3's "Home is a plain round button"). §1 makes the mockup
 * the authority on pixels, and the prose is the tiebreak where the mockup's own
 * CSS contradicts what it draws — so the rules are raised here AND in
 * design/build_v3_kid_mockups.py, in the same pass (B2 review, 2026-09-11).
 * Modifier rules (`.pill.quiet`, `.add.done`, `.listbtn.on`) are (0,2,0) and
 * sit AFTER their base rule, so they still win.
 */
.stage .homebtn {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--dim); flex: 0 0 auto;
}
.homebtn .ico { width: 26px; height: 26px; }
.stage .pill {
  height: 56px; padding: 0 22px 0 18px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 700; color: var(--text);
}
.pill .ico { width: 22px; height: 22px; color: var(--accent2); }
.pill.quiet { color: var(--dim); border-color: transparent; background: transparent; }
.pill.quiet .ico { color: var(--dim); }

/* Track / result rows — one shape, used by the playlist page, the search hits
   and the player's list pane. */
.tr {
  display: flex; align-items: center; gap: 14px; height: 62px; padding: 0 12px;
  border-radius: 14px; color: var(--text); width: 100%;
}
.tr:nth-child(even) { background: rgba(255, 255, 255, .03); }
/* The player's list pane keeps its rows in a `.rows` wrapper (so a keyed
   repaint can hold the pane's scrollTop), which shifts nth-child by one against
   the approved mockup — there the rows are direct children of `.pq`, after
   `.cap`, so the stripe lands on rows 1, 3, 5. Re-phase it rather than move the
   wrapper: §1 makes the mockup the authority on pixels. `:not(.now)` on both
   halves keeps the marker's gradient winning — the pane rules outrank `.tr.now`
   on specificity otherwise, and the marked row would lose its highlight. */
.pq .rows .tr:nth-child(even):not(.now) { background: none; }
.pq .rows .tr:nth-child(odd):not(.now) { background: rgba(255, 255, 255, .03); }
.tr.now { background: linear-gradient(90deg, rgba(79, 140, 255, .22), rgba(79, 140, 255, .04)); color: var(--accent2); }
.tr .i { width: 30px; color: var(--dim); font-size: 17px; text-align: right; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.tr.now .i { color: var(--accent2); }
.tr .i .ico { width: 20px; height: 20px; margin-left: auto; }
.tr .th { width: 46px; height: 46px; border-radius: 9px; flex: 0 0 auto; background: var(--panel2); }
.tr .th.round { border-radius: 50%; }
.tr .t { flex: 1; min-width: 0; font-size: 19px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr .t small { display: block; color: var(--dim); font-weight: 500; font-size: 14px; }
.tr.now .t small { color: var(--accent2); opacity: .75; }
.tr .d { color: var(--dim); font-size: 16px; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.tr .go { width: 46px; height: 46px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); display: grid; place-items: center; flex: 0 0 auto; color: var(--text); }
.tr .go .ico { width: 20px; height: 20px; }
.sh { color: var(--dim); font-size: 14px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; margin: 10px 0 6px 14px; }

/* Loading: skeletons in the tile or row shape, never spinners (§5). */
.sk { background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.09), rgba(255,255,255,.04)); border-radius: 14px; animation: skp 1.4s ease-in-out infinite; }
@keyframes skp { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.sk.row { height: 62px; margin-bottom: 6px; }
.sk.tile { width: 100%; aspect-ratio: 1; border-radius: var(--r); }

/* Toast — §8.3's failure surface. Never a modal, never a retry button. The
   per-shell position is set by each shell; this is the shared look.
   The toast renders on <body> (§8.3, overlays never inside a repainting
   subtree), so it is in UNSCALED device px while the bar it has to clear is
   inside the scaled stage. `--stage-scale` is published by shells/stage.js on
   the root element for exactly this: at the iPad's real scale (~0.974 in a
   standalone app's 1024x748 content area) an unscaled 120 px sat ~2.6% wrong
   against the bar (B2 review, 2026-09-11). */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(88px * var(--stage-scale, 1)); max-width: 70%;
  padding: 14px 22px; border-radius: 999px;
  background: rgba(20, 24, 33, .96); border: 1px solid var(--line);
  color: var(--text); font-size: 18px; font-weight: 600;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .55); z-index: 40;
  pointer-events: none;
}

/* Screen-level failure lines: flat, non-actionable, no link flow (§3.6, §8.3). */
.flatline { color: var(--dim); font-size: 19px; font-weight: 600; }

/* --------------------------------------------------- boot-screen cards
 * The unassigned card (§3.2 item 3), the admin link card (§3.2 item 4), the
 * enrollment screen (§3.2 item 2) and the rotate card (§8.2). All four are
 * shell-less: they render before a role is known, or instead of one.
 */
.boot { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 40px; }
.card {
  width: 100%; max-width: 560px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 24px;
  padding: 38px 40px; text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}
.card h1 { font-size: 30px; font-weight: 800; letter-spacing: -.01em; }
.card h2 { font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.card p { margin-top: 14px; color: var(--dim); font-size: 19px; line-height: 1.45; }
.card .kv { margin-top: 22px; color: var(--dim); font-size: 16px; line-height: 1.7; }
.card .kv b { color: var(--text); font-weight: 700; }
.card .kv code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 15px; color: var(--text); }
.card .wordmark { color: var(--dim); font-size: 14px; letter-spacing: .18em; text-transform: uppercase; font-weight: 700; margin-bottom: 16px; }
.card .lnk {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 26px;
  height: 58px; padding: 0 28px; border-radius: 999px;
  background: var(--text); color: #0b0d12; font-size: 19px; font-weight: 800; text-decoration: none;
}
.card input {
  display: block; width: 100%; margin-top: 16px; height: 66px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 16px;
  color: var(--text); font: inherit; font-size: 22px; padding: 0 20px; text-align: center;
}
.card input.code { letter-spacing: .38em; font-size: 30px; font-weight: 700; }
.card .btn {
  width: 100%; margin-top: 18px; height: 66px; border-radius: 999px;
  background: var(--text); color: #0b0d12; font-size: 21px; font-weight: 800;
  text-align: center;
}
.card .err { margin-top: 14px; color: var(--red); font-size: 17px; font-weight: 600; min-height: 21px; }

/* Short viewports. The one that matters is the kitchen panel with its keyboard
   up — 962x321 (§8.1) — which is where the enrollment screen is actually used
   at B3, and where the card at full size puts Join off the bottom of the glass.
   Scroll containment is by layout, since overscroll-behavior is Safari 16. */
@media (max-height: 430px) {
  .boot { align-items: flex-start; padding: 12px; overflow-y: auto; }
  .card { padding: 14px 24px; border-radius: 18px; }
  .card h1 { font-size: 23px; }
  .card h2 { font-size: 21px; }
  .card p { margin-top: 6px; font-size: 16px; line-height: 1.35; }
  .card .kv { margin-top: 10px; }
  .card input { height: 44px; margin-top: 8px; font-size: 18px; }
  .card input.code { font-size: 23px; }
  /* Trimmed at the B2 review: at 962x321 — the kitchen panel with its keyboard
     up, which is where this screen is actually used (§9's B3 setup: "the enroll
     screen must be usable at 962x321") — Join's bottom edge measured 322 px
     against a 321 px viewport, i.e. reachable only by scrolling. The block now
     lands it clear of the fold with room to spare. */
  .card .btn { height: 46px; margin-top: 8px; font-size: 18px; }
  .card .lnk { height: 46px; margin-top: 12px; }
  .card .err { margin-top: 6px; }
}

/* A list pane whose read failed: §5 keeps skeletons "for a first paint only",
   so a failed load gets a quiet line rather than three rows that read as
   loading forever. Never a retry button (§8.3). */
.pq .rows .empty { color: var(--dim); font-size: 18px; font-weight: 600; padding: 18px 12px; }

/* ============================================================ THE PLAYER
 * SPEC v3 §5 — one component, three shells. The metrics below are the kid
 * mockup's (player(), 1024x768); the kiosk and phone override the sizes in
 * their own stylesheets and reuse every rule here.
 */
.player { padding: 26px 36px 28px; flex-direction: column; }
.player .top { display: flex; align-items: center; height: 56px; flex: 0 0 auto; }
.player .top .sp { flex: 1; }

/* Pane control, form A: the kid shell's three-way segmented toggle, upper left,
   even radii, Album Art selected and bold (§6.2, D33). */
.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 2px; }
.seg button { height: 46px; padding: 0 20px; border-radius: 999px; font-size: 17px; font-weight: 600; color: var(--dim); }
.seg button.on { background: var(--panel2); color: var(--text); font-weight: 800; box-shadow: inset 0 0 0 1px var(--line); }

/* Pane control, form B: the kiosk/phone list button at the right end of the
   title row (§5, "Title row"). Built here, first used in stage 3. */
.stage .listbtn { width: 56px; height: 56px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); display: grid; place-items: center; color: var(--dim); flex: 0 0 auto; }
.listbtn.on { color: var(--text); background: var(--panel2); }
.listbtn .ico { width: 26px; height: 26px; }

.player .body { flex: 1; min-height: 0; display: flex; align-items: center; margin-top: 14px; }
.player .lft { width: 410px; height: 100%; flex: 0 0 auto; display: flex; flex-direction: column; justify-content: center; min-height: 0; position: relative; }

/* Album art is the DEFAULT FACE — after any pick, after any flip back, and
   every time the player opens, however it was reached (§5). */
.art { width: 410px; height: 410px; border-radius: var(--r); box-shadow: 0 30px 70px rgba(0, 0, 0, .6); display: none; background: var(--panel2) center/cover no-repeat; }
.stage.pane-art .art { display: block; }
/* A track with no artwork renders the flat card, no placeholder glyph (§5). */
.art.blank { background: var(--panel2); }

/* Lyrics pane (kid shell only — no lyrics on the wall or the phone, §1). */
.lyr {
  display: none; position: absolute; left: 0; right: 0; top: 0; bottom: 34px; overflow: hidden;
  -webkit-mask-image: linear-gradient(transparent, #000 10%, #000 84%, transparent);
  mask-image: linear-gradient(transparent, #000 10%, #000 84%, transparent);
}
.stage.pane-lyrics .lyr { display: block; }
.lyr .roll { position: absolute; left: 0; right: 0; top: 46%; }
.lyr ol { list-style: none; }
.lyr li { font-size: 23px; font-weight: 700; line-height: 1.25; padding: 9px 0; color: rgba(242, 245, 250, .32); letter-spacing: -.005em; }
.lyr li.now { color: var(--text); font-size: 27px; }
.lyr li.done { color: rgba(242, 245, 250, .55); }
/* plain: the text static and unhighlighted, scrolled by hand, with no
   current-line emphasis to fake (§6.2). none: one quiet line. */
.lyr.plain .roll { position: static; }
.lyr.plain { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.lyr.plain li { color: rgba(242, 245, 250, .72); font-size: 22px; }
.lyr .quiet { color: var(--dim); font-size: 20px; font-weight: 600; padding-top: 12px; }

/* List pane — the queue, or the search results the song was picked from (§5). */
.pq {
  display: none; height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; position: relative;
  -webkit-mask-image: linear-gradient(#000 88%, transparent);
  mask-image: linear-gradient(#000 88%, transparent);
}
.stage.pane-list .pq { display: block; }
.pq .cap { display: flex; align-items: baseline; gap: 10px; color: var(--dim); font-size: 14px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; margin: 0 0 6px 12px; }
.pq .cap b { color: var(--text); font-size: 18px; letter-spacing: 0; text-transform: none; }
.pq .tr { height: 58px; }

.player .col { flex: 1; margin-left: 44px; display: flex; flex-direction: column; justify-content: center; min-width: 0; height: 100%; }

/* Origin line — the list the song came from. A LIST name, never a room name
   (§5b item 5). While a clip is in flight the announcement badge takes this
   slot and nothing else changes (§5, §10 item 26a). */
.from { color: var(--dim); font-size: 17px; font-weight: 600; letter-spacing: .02em; display: flex; gap: 8px; align-items: center; }
.from .ico { width: 18px; height: 18px; color: var(--green); }
.from.ann {
  height: 38px; padding: 0 16px; border-radius: 999px;
  background: rgba(217, 164, 65, .14); border: 1px solid rgba(217, 164, 65, .45);
  color: var(--amber); font-weight: 700; align-self: flex-start; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.from.ann .ico { color: var(--amber); }
.from.ann.duck { background: rgba(154, 164, 184, .12); border-color: var(--line); color: var(--dim); }
.from.ann.duck .ico { color: var(--dim); }
/* "Loading the rest of the list…" while the group's `queue_loading` is up
   (§7.9, D41 follow-up): the same slot and size as the list name, the glyph
   dimmed so it reads as a wait and not as the origin. */
.from.loading .ico { color: var(--dim); opacity: .7; }

.ttl { margin-top: 6px; font-size: 42px; font-weight: 800; line-height: 1.1; letter-spacing: -.015em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.artist { margin-top: 6px; font-size: 23px; color: var(--dim); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Progress — hidden when idle (§5). Seek is per shell: on for the kiosk and
   phone, off on the kid shell, where the knob is not drawn at all (§10 item 25). */
.prog { margin-top: 28px; }
.prog .bar { height: 7px; border-radius: 4px; background: #2a3347; position: relative; }
.prog .bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 4px; background: var(--accent2); }
.prog .bar b { display: none; position: absolute; top: 50%; left: 0; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .6); }
/* `touch-action: none` where seek is on: the drag is a pointer sequence the
   shell owns, and the WebView would otherwise take a sideways finger for a
   scroll and cancel the pointer mid-drag. */
.prog.seekable { padding: 12px 0; margin-top: 16px; touch-action: none; cursor: pointer; }
.prog.seekable .bar b { display: block; }
.prog .t { display: flex; justify-content: space-between; color: var(--dim); font-size: 16px; font-variant-numeric: tabular-nums; margin-top: 10px; }
.player.idle .prog { visibility: hidden; }
/* §7.21: a live station — no seek, no skip; the bar and prev/next step aside. */
.player.live .prog { visibility: hidden; }
.player.live .tx [data-act="prev"], .player.live .tx [data-act="next"] { visibility: hidden; }
/* The bar is inert while the group is announcing (§5). */
.prog.frozen { opacity: .5; pointer-events: none; }

.tx { display: flex; align-items: center; justify-content: center; gap: 34px; margin-top: 24px; }
.tx button { width: 80px; height: 80px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); display: grid; place-items: center; color: var(--text); }
.tx button .ico { width: 36px; height: 36px; }
.tx button.play { width: 104px; height: 104px; background: var(--text); color: #0b0d12; border: 0; }
.tx button.play .ico { width: 50px; height: 50px; }

.vol { display: flex; align-items: center; gap: 16px; margin-top: 26px; }
.vol .ico { width: 30px; height: 30px; color: var(--dim); flex: 0 0 auto; }
.vol .n { width: 48px; text-align: right; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
/* A ducked group shows the LIVE ducked level, dimmed and inert — the restore
   writes member volumes back from its own pre-clip snapshot, so a drag made
   during a clip is discarded seconds later (§5). */
.vol.ducked { opacity: .5; }
.vol.ducked input { pointer-events: none; }
.stage input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; height: 56px; background: transparent; margin: 0; }
.stage input[type=range]::-webkit-slider-runnable-track { height: 12px; border-radius: 6px; background: #2a3347; }
.stage input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 36px; height: 36px; border-radius: 50%; background: #fff; margin-top: -12px; box-shadow: 0 3px 10px rgba(0, 0, 0, .6); }

/* Add to My List — add-only since D40: "Add to My List" -> "In My List", and
   it does not un-tap. Kid shell only. */
.addrow { margin-top: 26px; display: flex; justify-content: flex-end; }
/* §7.14: `my_list_playlist_id` unset -> Add hidden. Not drawn and inert — gone. */
.addrow.gone { display: none; }
.stage .add { height: 58px; padding: 0 24px 0 18px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); display: flex; align-items: center; gap: 12px; font-size: 19px; font-weight: 700; color: var(--text); }
.add .ico { width: 26px; height: 26px; color: var(--accent2); }
.add.done { background: #16301f; border-color: #2b6b45; color: var(--green); }
.add.done .ico { color: var(--green); }
