/* The interface around the poster. Colours come from theme.yaml `ui` and sizes from layout.yaml `site`; app.js sets
   them as the --ui-* and --sz-* variables below at startup, so the values here are only fallbacks. */
:root {
  --ui-panel: rgba(10, 10, 30, .94); --ui-pane: rgba(7, 8, 22, .72); --ui-line: rgba(232, 236, 255, .18);
  --ui-ink: #e8ecff; --ui-dim: #a7afd3; --ui-accent: #c9b8ff; --ui-accent_strong: #6b3cff; --ui-spoiler: #ffd9a0;
  --sz-btn: 36px; --sz-bar: 56px; --sz-rail: 64px; --sz-rail-face: 40px; --sz-dock: 96px; --sz-chip-w: 260px;
  --sz-pill: 28px; --sz-legend: 320px; --sz-popup: 340px;
  --pix: 'PS2P', monospace; --txt: 'Rubik', system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px); --sz-col: 56px; --sz-side: 340px;
  color-scheme: dark; accent-color: var(--ui-accent);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #05061a; color: var(--ui-ink);
  font: 15px/1.45 var(--txt); -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
[hidden] { display: none !important; }
body.phone .u-desk, body:not(.phone) .u-phone { display: none !important; }

/* ---------------------------------------------------------------- stage: sky, endless starfield, poster */
#stage { position: fixed; inset: 0; overflow: hidden; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
  background: #0b0a26; }
#stage:active { cursor: grabbing; }
#sky { position: absolute; left: 0; top: 0; width: 100%; transform-origin: 0 0; will-change: transform; pointer-events: none; }
#starfield { position: absolute; pointer-events: none; will-change: transform; background-repeat: repeat; transform-origin: 0 0; image-rendering: pixelated; }
#poster { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
/* the poster's nebulae and background stars, under it: paintNebulae and paintStars in app.js */
#nebula, #nebula2 { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; will-change: transform; max-width: none; }
/* a background preset's nebulae fade in over the old ones (app.js showNebula); .u-in is the start of the fade */
#nebula, #nebula2 { transition: opacity .35s ease; }
#nebula.u-in, #nebula2.u-in { opacity: 0; transition: none; }
#pstars { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
#poster svg { display: block; }
#stage.u-pointer { cursor: pointer; }

/* ---------------------------------------------------------------- buttons */
button { font: inherit; color: var(--ui-ink); background: var(--ui-pane); border: 1px solid var(--ui-line); border-radius: 8px;
  padding: 0 12px; height: var(--sz-btn); cursor: pointer; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  -webkit-tap-highlight-color: transparent; }
button:hover { border-color: var(--ui-accent); }
button:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
/* a mark's number inside a button (dock chips, search results) must not inherit the icon stroke above: it outlined the digits in the
   button's text colour, which read as blur */
button svg text { stroke: none; }
.u-icon { width: var(--sz-btn); padding: 0; display: inline-grid; place-items: center; font: 17px var(--pix); }
.u-btn { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 8px; font-size: 14px;
  border: 1px solid var(--ui-line); background: rgba(255, 255, 255, .04); cursor: pointer; }
.u-btn:hover { border-color: var(--ui-accent); }
.u-small { height: 30px; padding: 0 10px; font-size: 13px; }
.u-primary { background: var(--ui-accent_strong); border-color: var(--ui-accent_strong); font-weight: 600; position: relative; overflow: hidden;
  width: 100%; justify-content: center; height: 46px; margin-top: 14px; }
.u-primary:disabled { cursor: progress; }
#ex-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(255, 255, 255, .18); transition: width .15s; }
#ex-label { position: relative; }
.u-link { background: none; border: none; color: var(--ui-accent); padding: 0; height: auto; backdrop-filter: none; }
.u-pillbtn { border-radius: 999px; white-space: nowrap; font-size: 14px; }
.u-pillbtn.on { color: var(--ui-spoiler); border-color: color-mix(in srgb, var(--ui-spoiler) 50%, transparent); }

/* ---------------------------------------------------------------- toolbar */
#bar { position: fixed; top: calc(10px + var(--safe-t)); left: 10px; right: 10px; display: flex; gap: 8px; align-items: center;
  pointer-events: none; z-index: 5; }
#bar > * { pointer-events: auto; }
#bar .u-grow { flex: 1; pointer-events: none; }
body:not(.phone) #bar { left: calc(10px + var(--rail-shift, 0px)); transition: left .15s; }
.u-seg { display: inline-flex; align-items: center; height: var(--sz-btn); border: 1px solid var(--ui-line); border-radius: 8px;
  background: var(--ui-pane); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); overflow: hidden; }
.u-seg button { border: none; border-radius: 0; background: none; backdrop-filter: none; width: var(--sz-btn); padding: 0; height: 100%; }
.u-seg button + button, .u-seg span + button, .u-seg button + span { border-left: 1px solid var(--ui-line); }
.u-seg button:hover { background: rgba(255, 255, 255, .06); }
.u-seg #zoom-pct { width: auto; min-width: 58px; padding: 0 6px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ui-dim); }
.u-seg #zoom-pct:hover { color: var(--ui-ink); }
#zoom-input { width: 58px; height: 100%; border: none; border-left: 1px solid var(--ui-line); background: rgba(255, 255, 255, .08); color: var(--ui-ink);
  font: 13px var(--txt); text-align: center; outline: none; }
/* the search field (desktop), a Search pill (portrait and desktop under 900 px), a column button (landscape) */
body:not(.land) .u-land-ic, .u-ctl .u-cl.u-sshort, body:not(.land) #b-more .u-cl, body:not(.land) #b-fit2 .u-cl { display: none; }
#b-search { display: inline-flex; align-items: center; gap: 6px; width: 196px; padding: 0 10px 0 9px; color: var(--ui-dim); text-align: left; }
#b-search svg { flex: none; width: 18px; height: 18px; }
#b-search .u-sfull { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#b-search:hover { color: var(--ui-ink); }
body.phone #b-search .u-sfull { display: none; }
body.phone #b-search { width: auto; padding: 0 14px 0 12px; border-radius: 999px; color: var(--ui-ink); font-size: 15px; }
body.phone #b-search .u-sshort { display: inline; }
@media (max-width: 900px) {
  body:not(.phone) #b-search .u-sfull { display: none; }
  body:not(.phone) #b-search { width: auto; padding: 0 14px 0 12px; border-radius: 999px; color: var(--ui-ink); }
  body:not(.phone) #b-search .u-sshort { display: inline; }
}
/* the Watched chip: the visitor's progress; gold while spoiler mode is on */
#b-watch { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
body.phone #b-watch { font-size: 15px; padding: 0 14px; }
#b-watch.on { color: var(--c-event); border: 1.5px solid var(--c-event); }
#b-watch .u-slash { display: none; }
#b-watch.on .u-slash { display: inline; }
.u-fab { position: fixed; z-index: 5; }
/* the Key and Arcs buttons, side by side at the bottom left */
#fabl { position: fixed; z-index: 5; display: flex; gap: 8px; left: calc(10px + var(--rail-shift, 0px)); bottom: calc(var(--fab-bottom, 10px) + var(--safe-b));
  transition: left .15s; }
/* the Key, Arcs and Events buttons share one look: an icon and a word. The Key's icon is a white ⓘ (gold is for events);
   the Events button's icon is the event marks. */
#b-legend, #b-arcs, #dock-btn { display: inline-flex; align-items: center; gap: 8px; padding: 0 14px 0 12px; font-size: 14px; font-weight: 500; }
#b-arcs, #b-legend { gap: 6px; }
#b-arcs svg.u-arcic { width: 18px; height: 18px; stroke: var(--ui-accent); stroke-width: 2.4; stroke-linecap: square; }
#b-legend svg.u-keyic { width: 18px; height: 18px; stroke-width: 2.2; }
body.phone #fabl { left: 10px; }   /* over the rail's foot: shifted, it would run into the Events pill */
body.phone #b-legend, body.phone #b-arcs, body.phone #dock-btn { padding: 0 14px 0 12px; font-size: 15px; }
body.phone #dock-btn { gap: 7px; }
.u-keygl { display: inline-flex; align-items: center; gap: 3px; }
.u-keygl svg { width: 14px; height: 14px; display: block; }
/* major events' edge tags (app.js updateMajorTags): fixed size, at the top of the poster area */
#mjtags { position: fixed; left: 0; top: 0; z-index: 4; pointer-events: none; }
.u-mjtag { position: absolute; left: 0; top: 0; height: 22px; padding: 0 8px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font: 9px/1 var(--pix); letter-spacing: .5px; color: var(--c-event); background: var(--c-label_knockout); border: 1px solid var(--c-event); border-radius: 999px;
  backdrop-filter: none; -webkit-backdrop-filter: none; pointer-events: auto; will-change: transform; }
.u-mjtag::before { content: ''; position: absolute; inset: -8px -4px; }   /* a bigger target for a finger */
.u-mjtag:hover { border-color: var(--c-bright); color: var(--c-bright); }
.u-mjtag svg { width: 10px; height: 10px; }
.u-mjtag .u-up { font-size: 7px; }
.u-mjtag.u-dim { opacity: var(--focus-dim, .25); }   /* a focus that leaves its major event out */
#b-fit2 { right: 10px; bottom: calc(var(--fab-bottom, 10px) + var(--safe-b)); }
#focus-chip { position: fixed; z-index: 5; top: calc(10px + var(--safe-t) + var(--sz-btn) + 8px); left: 50%; transform: translateX(-50%); }
body:not(.phone) #focus-chip { top: calc(10px + var(--safe-t)); }

/* ---------------------------------------------------------------- frozen panes */
.u-pane { background: var(--ui-pane); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#rail { position: fixed; left: 0; top: 0; bottom: var(--rail-bottom, 0px); width: var(--sz-rail); border-right: 1px solid var(--ui-line); z-index: 3;
  opacity: 0; pointer-events: none; transition: opacity .15s; }
#rail.on { opacity: 1; pointer-events: auto; }
.u-face { position: absolute; left: 0; width: var(--sz-rail); top: 0; display: flex; flex-direction: column; align-items: center; cursor: pointer;
  will-change: transform; }
.u-face img { width: var(--sz-rail-face); height: var(--sz-rail-face); image-rendering: pixelated; border: 2px solid var(--ui-ink);
  box-shadow: 0 0 10px rgba(160, 180, 255, .5); background: #070816; display: block; }
.u-face span { font: 7px/1 var(--pix); margin-top: 4px; letter-spacing: .3px; color: var(--ui-ink); white-space: nowrap; }
/* a big face glows while hovered, to show it opens the protagonist card */
.u-face img { transition: box-shadow .12s, border-color .12s; }
.u-face:not(.chip):hover img { border-color: #fff; box-shadow: 0 0 0 2px var(--ui-accent), 0 0 18px 4px rgba(201, 184, 255, .75); }
.u-face.chip img { width: 22px; height: 22px; border-width: 1px; }
.u-face.chip span { display: none; }
.u-face.chip::after { font: 9px var(--pix); color: var(--ui-dim); margin-top: 2px; }
.u-face.chip.up::after { content: '▲'; order: -1; margin: 0 0 2px; }
.u-face.chip.down::after { content: '▼'; }
body.phone .u-face span { display: none; }

#dock { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--sz-dock) + var(--safe-b)); border-top: 1px solid var(--ui-line); z-index: 2; display: flex; }
#dock-row { display: flex; gap: 10px; height: calc(var(--sz-dock) - 1px); flex: 1; min-width: 0; padding: 12px 10px; margin-right: 160px;   /* clear of the Events button */ overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
  overscroll-behavior-x: contain; }
/* the dock stepper ‹ | ›: previous / next event in story order, one button split in the middle, as wide as the Events
   button (app.js syncDock) and right below it, in the dock's band, while the desktop dock is open */
#dock-steps { position: fixed; z-index: 8; display: flex; right: 16px; height: var(--sz-btn); bottom: calc((var(--sz-dock) - 2 * var(--sz-btn) - 8px) / 2 + var(--safe-b));
  border: 1px solid var(--ui-line); border-radius: 999px; background: var(--ui-pane); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); overflow: hidden; }
#dock-steps:hover { border-color: var(--ui-accent); }
.u-dstep { flex: 1; height: 100%; padding: 0; border: none; border-radius: 0; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; display: grid; place-items: center; }
.u-dstep + .u-dstep { box-shadow: inset 1px 0 0 var(--ui-line); }   /* the split, without making one half wider */
.u-dstep:hover { background: rgba(255, 255, 255, .08); }
.u-dstep svg { width: 18px; height: 18px; stroke-width: 2.4; }
.u-dstep:disabled { opacity: .35; cursor: default; }
.u-dstep:disabled:hover { background: none; }
.u-chip { flex: none; width: var(--sz-chip-w); height: calc(var(--sz-dock) - 24px); display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--ui-line); background: rgba(10, 10, 30, .55); cursor: pointer;
  font-size: 13px; line-height: 1.35; color: rgba(215, 220, 245, .9); text-align: left; backdrop-filter: none; }
.u-chip:hover, .u-chip.u-hl { border-color: var(--ui-accent); background: rgba(30, 24, 70, .7); }
.u-chip.u-sel { border-color: var(--ui-accent); box-shadow: 0 0 0 2px var(--ui-accent) inset; background: rgba(40, 30, 90, .8); }
.u-chip svg { flex: none; width: 34px; height: 34px; }
.u-chip .u-gl { flex: none; width: 34px; height: 34px; display: grid; place-items: center; }
.u-chip .u-gl svg { width: 30px; height: 30px; }
.u-chip svg.u-dg { width: 30px; height: 30px; margin: 2px; }
.u-chip.major .u-txt { color: var(--c-event); font-weight: 500; }
.u-dia { fill: var(--c-event); stroke: var(--c-bg); stroke-width: 1.4; }
.u-badge-dia { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; margin-top: -1px; }
.u-badge-dia svg { filter: drop-shadow(0 0 4px rgba(255, 176, 46, .6)); }
.u-chip .u-txt { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.u-chip.key .u-txt { color: #ffe2a2; }
.u-chip.minor .u-txt { color: rgba(167, 175, 211, .8); }
.u-chip.veiled .u-txt { color: var(--ui-dim); font-style: italic; }
/* the events toggle: level with Key and Arcs; while the desktop dock is open, a button higher, the stepper below it
   (app.js fabBottom). Open, its border is lit. */
#dock-btn { position: fixed; right: 16px; bottom: calc((var(--sz-dock) - 2 * var(--sz-btn) - 8px) / 2 + var(--safe-b)); z-index: 8; }
body.u-evdock:not(.phone) #dock-btn { bottom: calc((var(--sz-dock) - 2 * var(--sz-btn) - 8px) / 2 + var(--sz-btn) + 8px + var(--safe-b)); }
#dock-btn[aria-expanded="true"] { border-color: var(--ui-accent); }
/* portrait: at the right, beside Fit, leaving the left to the Key and Arcs */
body.phone #dock-btn { bottom: calc(8px + var(--safe-b)); right: calc(18px + var(--sz-btn)); }
body.phone.u-popopen #dock-btn { display: none; }
/* narrow phones: Key, Arcs, Events and Fit still fit one row */
@media (max-width: 380px) {
  body.phone:not(.land) #b-legend, body.phone:not(.land) #b-arcs, body.phone:not(.land) #dock-btn { padding: 0 10px; font-size: 14px; gap: 5px; }
  body.phone:not(.land) #fabl { gap: 6px; }
  body.phone:not(.land) #dock-btn { right: calc(16px + var(--sz-btn)); }
}
@media (max-width: 340px) { body.phone:not(.land) .u-keygl { display: none; } }
body.phone #events-list { padding-bottom: calc(var(--sz-pill) + 16px); }

.u-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; background: var(--ui-panel); border-top: 1px solid var(--ui-line);
  border-radius: 14px 14px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .5); padding: 6px 14px calc(14px + var(--safe-b)); touch-action: pan-y; }
#events-sheet { height: var(--sheet-h, 45dvh); display: flex; flex-direction: column; }
#events-list { overflow-y: auto; flex: 1; overscroll-behavior: contain; }
#events-list .u-chip { width: 100%; height: auto; margin: 6px 0; }
.u-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--ui-line); margin: 4px auto 8px; }
.u-sheet-head .u-h { margin: 2px 0 8px; }
/* ---------------------------------------------------------------- dialogs */
.u-dlg { position: fixed; top: calc(10px + var(--safe-t) + var(--sz-btn) + 8px); right: 10px; width: min(360px, calc(100vw - 20px));
  max-height: calc(100dvh - 90px); overflow: auto; z-index: 9; background: var(--ui-panel); border: 1px solid var(--ui-line); border-radius: 12px;
  padding: 14px 18px 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); overscroll-behavior: contain; }
/* headings of panels and dialogs: the interface font (GLOSSARY.md, Typography) */
.u-h { font: 600 16px/1.3 var(--txt); color: var(--ui-ink); margin: 16px 0 12px; }
.u-dlg > .u-h:first-of-type { margin-top: 6px; }
.u-close { position: absolute; right: 8px; top: 8px; width: 34px; height: 34px; padding: 0; font-size: 18px; backdrop-filter: none; z-index: 1; }
.u-row { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.u-row input[type=range] { flex: 1; }
.u-label { font-size: 13px; color: var(--ui-dim); margin: 14px 0 8px; }
.u-hint { color: var(--ui-dim); font-size: 13px; min-height: 1.2em; }
.u-foot { margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--ui-line); font-size: 13px; }
.u-dlg a { color: var(--ui-accent); }
.u-dlg p { margin: 8px 0; }
details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '▸'; color: var(--ui-dim); font: 10px var(--pix); }
details[open] > summary::before { content: '▾'; }
/* Appearance: the background presets as swatches, three per row */
.u-swatches { display: grid; grid-template-columns: repeat(3, 96px); gap: 12px 14px; justify-content: start; }
.u-swatch { display: flex; flex-direction: column; align-items: center; gap: 5px; height: auto; padding: 0; border: none; background: none; backdrop-filter: none;
  -webkit-backdrop-filter: none; font-size: 13px; color: var(--ui-dim); }
.u-swatch img { display: block; width: 96px; height: 56px; border-radius: 6px; border: 1px solid var(--ui-line); }
.u-swatch:hover img { border-color: var(--ui-accent); }
.u-swatch[aria-checked=true] { color: var(--ui-ink); }
.u-swatch[aria-checked=true] img { box-shadow: 0 0 0 2px var(--ui-accent); border-color: transparent; }

.u-switch { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-size: 15px; }
.u-switch input { position: absolute; opacity: 0; pointer-events: none; }
.u-track { flex: none; width: 46px; height: 28px; border-radius: 14px; background: rgba(255, 255, 255, .12); border: 1px solid var(--ui-line); position: relative; transition: background .15s; }
.u-track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ui-ink); transition: transform .15s; }
.u-switch input:checked + .u-track { background: var(--ui-accent_strong); }
.u-switch input:checked + .u-track::after { transform: translateX(18px); }
.u-switch input:focus-visible + .u-track { outline: 2px solid var(--ui-accent); }
.u-segctl { display: flex; border: 1px solid var(--ui-line); border-radius: 8px; overflow: hidden; margin-top: 12px; }
.u-segctl button { flex: 1; border: none; border-radius: 0; height: 40px; background: none; backdrop-filter: none; }
.u-segctl button + button { border-left: 1px solid var(--ui-line); }
.u-segctl button[aria-checked=true] { background: color-mix(in srgb, var(--ui-accent) 22%, transparent); color: #fff; }
/* the spoiler slider: preview row with steppers, the range (a 28 px knob, the track after it dimmed), season bands */
#spoilers { width: min(360px, calc(100vw - 20px)); }
.u-dlg > .u-h { padding-right: 34px; }
#spoilers .u-h { margin-bottom: 2px; }
.u-spdesc { margin: 0 0 4px; }
#sp-count { margin: 4px 0 0; }
#sp-count b { font-weight: 700; color: var(--c-event); }
.u-sprow { display: flex; align-items: center; gap: 8px; min-height: 58px; }
.u-step { flex: none; width: 44px; height: 44px; padding: 0; font-size: 24px; line-height: 1; backdrop-filter: none; -webkit-backdrop-filter: none; }
.u-step:disabled { opacity: .3; cursor: default; }
#sp-preview { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; font-size: 13px; line-height: 1.3; }
#sp-preview img { flex: none; width: 96px; height: 54px; object-fit: cover; border-radius: 4px; background: #1a1d3a; }
#sp-preview div { min-width: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
#sp-preview span { display: block; color: var(--ui-dim); font-size: 12px; }
#sp-preview .u-all { text-align: center; flex: 1; font-size: 14px; }
#sp-range { --knob: 28px; -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 44px; margin: 6px 0 0; background: none; cursor: pointer; touch-action: pan-y; }
#sp-range::-webkit-slider-runnable-track { height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--c-event) 0 calc(var(--knob) / 2 + var(--pct, 1) * (100% - var(--knob))), rgba(232, 236, 255, .16) 0); }
#sp-range::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(232, 236, 255, .16); }
#sp-range::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--c-event); }
#sp-range::-webkit-slider-thumb { -webkit-appearance: none; width: var(--knob); height: var(--knob); margin-top: calc(3px - var(--knob) / 2); border-radius: 50%;
  background: var(--ui-ink); border: 3px solid var(--c-event); box-shadow: 0 2px 8px rgba(0, 0, 0, .5); }
#sp-range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--ui-ink); border: 3px solid var(--c-event); }
#sp-range:focus-visible { outline: none; }
#sp-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--ui-accent); }
#sp-seasons { position: relative; height: 24px; margin: 0 14px; }
.u-season { position: absolute; top: 0; height: 100%; padding: 0; border: none; border-top: 2px solid rgba(232, 236, 255, .3); border-radius: 0; background: none;
  backdrop-filter: none; -webkit-backdrop-filter: none; font: 600 12px/1 var(--txt); color: var(--ui-dim); text-align: center; }
.u-season + .u-season { border-left: 1px solid rgba(232, 236, 255, .3); }
.u-season span { display: block; padding-top: 5px; }
.u-season:hover { color: var(--ui-ink); border-top-color: var(--c-event); background: rgba(255, 255, 255, .05); }
.u-season.on { color: var(--c-event); }
.u-sprow2 { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.u-sprow2 .u-btn { height: 40px; font-size: 14px; }
.u-sprow2 .u-btn:disabled { opacity: .4; cursor: default; border-color: var(--ui-line); }
/* Blur | Hide: one pill with two options; the chosen one filled */
.u-sprow2 .u-segctl { margin: 0 0 0 auto; width: 150px; }
#sp-mode { padding: 3px; gap: 3px; border-radius: 999px; background: rgba(255, 255, 255, .05); }
#sp-mode button { height: 34px; border-radius: 999px; color: var(--ui-dim); font-size: 14px; transition: background .12s, color .12s; }
#sp-mode button + button { border-left: none; }
#sp-mode button:hover { background: rgba(255, 255, 255, .1); color: var(--ui-ink); }
#sp-mode button[aria-checked=true] { background: var(--c-event); color: #1a1205; font-weight: 600; }
#sp-mode button[aria-checked=true]:hover { background: var(--c-event); color: #1a1205; }
#sp-mode.u-off button[aria-checked=true] { background: rgba(255, 215, 106, .45); }
/* Save poster image: named sizes, each with its pixels and file size */
#ex-sizes { margin-top: 8px; }
#ex-sizes label { display: flex; align-items: center; gap: 10px; min-height: 44px; font-variant-numeric: tabular-nums; cursor: pointer; }
.u-exrow { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-size: 14px; }
.u-exrow b { font-weight: 600; min-width: 62px; }
.u-exrow small { color: var(--ui-dim); font-size: 13px; }
.u-exrow em { flex-basis: 100%; font-style: normal; font-size: 12px; color: #ffb454; }
.u-gold { color: var(--c-event); }
#export > .u-hint { margin: 4px 0; }

/* the More menu: each entry with an icon and a line saying what it does */
.u-menu { width: min(280px, calc(100vw - 20px)); padding: 6px; }
.u-menu button { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; height: auto; min-height: 52px; padding: 6px 10px; border: none;
  background: none; backdrop-filter: none; -webkit-backdrop-filter: none; border-radius: 8px; }
.u-menu button:hover { background: rgba(255, 255, 255, .06); }
.u-menu button svg { flex: none; color: var(--ui-accent); }
.u-menu button span { display: flex; flex-direction: column; min-width: 0; }
.u-menu b { font-weight: 500; font-size: 14px; }
.u-menu small { font-size: 12px; color: var(--ui-dim); overflow-wrap: anywhere; }

#legend, #arcs { left: calc(10px + var(--rail-shift, 0px)); right: auto; top: auto; bottom: calc(var(--fab-bottom, 10px) + var(--sz-btn) + 8px + var(--safe-b));
  width: min(var(--sz-legend), calc(100vw - 20px)); max-height: 70dvh; }
#lg-arcn { color: var(--ui-dim); font-weight: 400; }
.u-arcshint { margin: -6px 0 6px; }
.u-lgh { font: 600 12px/1.4 var(--txt); color: var(--ui-dim); letter-spacing: .6px; text-transform: uppercase; margin: 16px 0 4px; }
#lg-rows .u-lgh:first-child { margin-top: 4px; }
.u-lgrow { display: flex; gap: 10px; align-items: center; font-size: 13px; margin: 8px 0; color: var(--ui-dim); }
.u-lgrow svg { flex: none; width: 60px; height: auto; }
.u-lgintro { font-size: 13px; color: var(--ui-dim); margin: 6px 0; }
.u-lgrow b, .u-lgintro b { color: var(--ui-ink); font-weight: 600; }
.u-lgarc { display: flex; gap: 10px; align-items: center; width: 100%; height: 34px; padding: 0 6px; border: none; background: none; backdrop-filter: none;
  font: 9px/1.2 var(--pix); text-align: left; border-radius: 6px; }
.u-lgarc:hover { background: rgba(255, 255, 255, .06); }
.u-lgarc svg { flex: none; width: 44px; height: 12px; }

/* ---------------------------------------------------------------- popup */
#pop { position: fixed; z-index: 7; width: min(var(--sz-popup), calc(100vw - 16px)); background: var(--ui-panel); border: 1px solid var(--ui-line);
  border-radius: 10px; padding: 12px 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, .55); left: 0; top: 0; }
#pop .u-arrow { position: absolute; width: 14px; height: 14px; background: var(--ui-panel); border: 1px solid var(--ui-line); transform: rotate(45deg); }
#pop[data-side=right] .u-arrow { left: -8px; border-right: none; border-top: none; }
#pop[data-side=left] .u-arrow { right: -8px; border-left: none; border-bottom: none; }
#pop[data-side=below] .u-arrow { top: -8px; border-right: none; border-bottom: none; }
#pop[data-side=above] .u-arrow { bottom: -8px; border-left: none; border-top: none; }
#pop.u-sheetpop { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto; border-radius: 14px 14px 0 0; max-height: 55dvh; overflow: auto;
  padding-bottom: calc(14px + var(--safe-b)); }
#pop.u-sheetpop .u-arrow { display: none; }
.u-pophead { display: flex; gap: 10px; align-items: flex-start; padding-right: 30px; font-size: 16px; line-height: 1.3; }
.u-badge { flex: none; font: 11px var(--pix); color: #05060f; padding: 5px 6px 4px; margin-top: 1px; }
.u-badge.tier-key { background: #ffc93c; } .u-badge.tier-notable { background: #f2f4ff; } .u-badge.tier-minor { background: #a7afd3; }
.u-badge.tier-major { background: #ffd76a; }
.u-popmeta { color: var(--ui-dim); font-size: 13px; margin: 6px 0 4px; }
.u-popmeta .u-link { font-size: 13px; text-decoration: underline dotted; }
.u-tier { display: flex; align-items: center; gap: 7px; }
.u-tier .u-tg { flex: none; }
.u-tierbtn { display: inline-flex; align-items: center; gap: 5px; height: auto; padding: 1px 0; border: none; background: none; backdrop-filter: none;
  -webkit-backdrop-filter: none; font-size: 13px; color: var(--ui-dim); }
.u-tierbtn strong { color: var(--ui-ink); font-weight: 600; }
.u-tierbtn .u-info { width: 15px; height: 15px; stroke-width: 1.6; color: var(--ui-dim); }
.u-tierbtn:hover .u-info, .u-tierbtn[aria-expanded=true] .u-info { color: var(--ui-accent); }
.u-tierdef { font-size: 13px; color: var(--ui-dim); margin: 2px 0 4px 23px; }
/* a protagonist's card, from their face in the rail */
#pop.u-linepop { width: min(300px, calc(100vw - 16px)); }
.u-linehead { align-items: center; }
.u-linehead img { flex: none; width: 32px; height: 32px; image-rendering: pixelated; border: 2px solid var(--ui-ink); background: #070816; }
.u-linehead .u-pname { font: 11px/1.4 var(--pix); letter-spacing: .5px; }
.u-linehead .u-popmeta { margin: 3px 0 0; }
.u-linearcs .u-lgarc { height: 30px; }
.u-linebtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--ui-line); }
.u-linebtns button { height: 36px; font-size: 13px; padding: 0 8px; backdrop-filter: none; }
.u-linebtns button:disabled { opacity: .35; cursor: default; }
.u-linebtns .u-wide { grid-column: 1 / -1; }
body.phone .u-linebtns button { height: 44px; }
body.land .u-linebtns { grid-template-columns: 1fr 1fr 1fr; }   /* one row, so the card fits the side panel's height */
body.land .u-linebtns .u-wide { grid-column: auto; }
body.land .u-linebtns button { height: auto; min-height: 44px; line-height: 1.2; padding: 4px 6px; }
body.land .u-linearcs .u-lgarc { height: 26px; }
#pop p { margin: 8px 0; }
.u-muted { color: var(--ui-dim); font-style: italic; }
#pop a { color: var(--ui-accent); text-decoration: none; }
.u-watch { display: inline-block; margin-top: 2px; font-weight: 600; }
.u-eps { list-style: none; padding: 0; margin: 8px 0 0; }
.u-eps li { margin: 4px 0; display: flex; gap: 6px; align-items: center; }
.u-eps button { height: auto; min-height: 30px; padding: 4px 8px; font-size: 13px; text-align: left; backdrop-filter: none; }
.u-popx { position: absolute; right: 6px; top: 6px; width: 32px; height: 32px; padding: 0; font-size: 17px; backdrop-filter: none; }
.u-nav { display: flex; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--ui-line); align-items: center; }
.u-nav button { flex: 1; height: 38px; font-size: 13px; backdrop-filter: none; }
.u-nav button:disabled { opacity: .35; cursor: default; }
.u-nav span { font-size: 11px; color: var(--ui-dim); white-space: nowrap; }
body.phone .u-nav button { height: 44px; }

#hover-label { position: fixed; z-index: 6; pointer-events: none; font-size: 12px; background: var(--ui-panel); border: 1px solid var(--ui-line);
  border-radius: 6px; padding: 3px 8px; white-space: nowrap; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- loading screen */
#loading { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: linear-gradient(180deg, #05061a, #0b0a26 55%, #120a2a);
  transition: opacity .35s; }
#loading.done { opacity: 0; pointer-events: none; }
.u-load-inner { text-align: center; padding: 20px; }
.u-load-logo { font: 34px/1.3 var(--pix); color: #fff; text-shadow: 3px 3px 0 #6b3cff, 6px 6px 0 #2a1470, 0 0 30px rgba(150, 110, 255, .8);
  opacity: 0; transition: opacity .3s; letter-spacing: 1px; }
.fonts .u-load-logo { opacity: 1; }
.u-load-bar { width: min(320px, 70vw); height: 14px; margin: 34px auto 14px; border: 2px solid rgba(232, 236, 255, .7); padding: 2px; }
#load-fill { height: 100%; width: 0; background: repeating-linear-gradient(90deg, #c9b8ff 0 10px, transparent 10px 12px); transition: width .2s; }
.u-load-text { font: 14px var(--txt); color: var(--ui-dim); }
@media (max-width: 640px) { .u-load-logo { font-size: 24px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------------------------------------------------------------- phone: dialogs as bottom sheets */
body.phone #legend, body.phone #arcs, body.phone #spoilers, body.phone #appearance, body.phone #export, body.phone #about {
  left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 70dvh; border-radius: 14px 14px 0 0; padding-bottom: calc(18px + var(--safe-b)); }
body.phone #menu { top: calc(10px + var(--safe-t) + var(--sz-btn) + 8px); right: 10px; }

/* ---------------------------------------------------------------- search */
.u-search { position: fixed; inset: 0; z-index: 12; background: rgba(3, 4, 14, .45); display: flex; justify-content: center; align-items: flex-start;
  padding-top: calc(70px + var(--safe-t)); }
.u-searchbox { width: min(480px, calc(100vw - 20px)); max-height: min(70dvh, 560px); display: flex; flex-direction: column; background: var(--ui-panel);
  border: 1px solid var(--ui-line); border-radius: 12px; box-shadow: 0 16px 50px rgba(0, 0, 0, .6); overflow: hidden; }
.u-qrow { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--ui-line); }
.u-qrow svg { width: 20px; height: 20px; fill: none; stroke: var(--ui-dim); stroke-width: 2; stroke-linecap: round; flex: none; }
#q { flex: 1; height: 52px; border: none; background: none; color: var(--ui-ink); font: 16px var(--txt); outline: none; min-width: 0; }
#q::-webkit-search-cancel-button { filter: invert(.7); }
.u-results { overflow-y: auto; overscroll-behavior: contain; padding: 4px; }
.u-results .u-hint { padding: 10px 12px; margin: 0; }
.u-res { display: flex; width: 100%; height: auto; min-height: 48px; gap: 12px; align-items: center; padding: 6px 8px; border: none; border-radius: 8px;
  background: none; backdrop-filter: none; text-align: left; }
.u-res.sel { background: color-mix(in srgb, var(--ui-accent) 18%, transparent); }
.u-res .u-pic { flex: none; width: 64px; height: 36px; display: grid; place-items: center; border-radius: 4px; overflow: hidden; background: #1a1d3a; }
.u-res .u-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.u-res .u-pic img.u-face-pic { width: 32px; height: 32px; image-rendering: pixelated; }
.u-res .u-pic svg { width: 30px; height: 30px; }
.u-res .u-pic svg.u-charpic { width: 24px; height: 24px; fill: none; stroke: var(--ui-accent); stroke-width: 2; }
.u-arcpic { width: 44px; height: 12px; border: 4px solid currentColor; border-top: none; }
.u-rtxt { display: flex; flex-direction: column; min-width: 0; }
.u-rt { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-rm { font-size: 12px; color: var(--ui-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-rm em { color: var(--ui-accent); font-style: normal; }
body.phone .u-search { padding-top: calc(8px + var(--safe-t)); }
body.phone .u-searchbox { width: calc(100vw - 16px); max-height: 60dvh; }
/* desktop: the panel opens over the search field (app.js openSearch sets where) */
body:not(.phone) .u-search { justify-content: flex-start; padding: var(--sy, 70px) 0 0 var(--sx, 10px); }
body:not(.phone) .u-searchbox { width: var(--sw, 480px); }

/* ---------------------------------------------------------------- landscape phone: a touch screen held sideways, at most
   site_land_max_h tall (body.phone.land). The toolbar becomes a button column at the right edge; popups, the events list
   and dialogs open as a side panel beside it; the face rail is a strip of faces without a pane. --sz-col is the column
   with its margins; every edge also keeps clear of the safe-area insets (a notch can be on either side). */
#safe-probe { position: fixed; left: 0; top: 0; visibility: hidden; pointer-events: none; padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
body.land { --col-r: calc(var(--safe-r) + 8px); --side-r: calc(var(--safe-r) + var(--sz-col));
  --side-w: min(var(--sz-side), 46vw); --side-top: calc(var(--safe-t) + 8px); --side-bot: calc(var(--safe-b) + 8px); }
/* seven buttons in the column (three at the top, four at the bottom): smaller than site_btn_land on a short screen, so they fit */
body.land { --sz-btn: min(var(--sz-btn-land, 48px), calc((100dvh - var(--safe-t) - var(--safe-b) - 52px) / 7)); }
body.land #bar { top: var(--side-top); right: var(--col-r); left: auto; flex-direction: column; gap: 6px; }
body.land #bar .u-grow { display: none; }
body.land .u-fab, body.land #dock-btn, body.land #fabl { left: auto; right: var(--col-r); transform: none; }
body.land #b-fit2 { right: var(--col-r); bottom: var(--side-bot); }
/* the column: Search, Watched, More at the top; Events, Key, Fit at the bottom. Each an icon over a 10 px label. */
body.land .u-ctl { width: var(--sz-btn); height: var(--sz-btn); padding: 2px 0 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; border-radius: 10px; color: var(--ui-ink); font: 10px/1 var(--txt); }
body.land .u-ctl .u-cl { display: block; font: 500 10px/1 var(--txt); white-space: nowrap; letter-spacing: 0; }
body.land .u-ctl svg { width: 20px; height: 20px; }
body.land .u-land-ic { display: block; }
body.land #b-search .u-sfull { display: none; }
body.land #b-search, body.land #dock-btn, body.land #b-watch { width: var(--sz-btn); height: var(--sz-btn); padding: 2px 0 0; font-size: 10px; }
body.land #fabl { flex-direction: column-reverse; gap: 6px; bottom: calc(var(--side-bot) + var(--sz-btn) + 6px); }
body.land #b-legend, body.land #b-arcs, body.land #dock-btn { padding: 2px 0 0; gap: 4px; }
body.land #dock-btn { bottom: calc(var(--side-bot) + 3 * (var(--sz-btn) + 6px)); }
body.land #dock-btn[aria-expanded="true"] { border-color: var(--ui-accent); }
body.land.u-popopen #dock-btn { display: flex; }
body.land .u-keygl { gap: 1px; }
body.land .u-keygl svg { width: 11px; height: 11px; }
body.land #focus-chip { top: var(--side-top); left: calc((100vw - var(--side-r)) / 2); }

body.land #rail { left: var(--safe-l); background: none; border: none; backdrop-filter: none; -webkit-backdrop-filter: none; }

/* popups, the events list and the dialogs: one side panel, full height, beside the column */
body.land #pop.u-sidepop, body.land #events-sheet, body.land #legend, body.land #arcs, body.land #spoilers, body.land #appearance, body.land #export, body.land #about {
  left: auto; right: var(--side-r); top: var(--side-top); bottom: auto; width: var(--side-w); max-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 16px);
  border: 1px solid var(--ui-line); border-radius: 12px; transform: none; }
body.land #pop.u-sidepop { overflow: auto; overscroll-behavior: contain; }
body.land #pop.u-sidepop .u-arrow { display: none; }
body.land #events-sheet { bottom: var(--side-bot); height: auto; max-height: none; padding: 6px 12px 10px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
body.land #events-sheet .u-handle { display: none; }
body.land #events-list { padding-bottom: 0; }
body.land #menu { top: var(--side-top); right: var(--side-r); left: auto; bottom: auto; }
body.land .u-dlg { padding: 10px 14px 14px; }
body.land .u-search { padding: var(--side-top) var(--side-r) 0 var(--safe-l); }
body.land .u-searchbox { width: min(480px, calc(100vw - var(--side-r) - var(--safe-l) - 16px)); max-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 16px); }

/* ---------------------------------------------------------------- the characters feature (app.js, "the characters feature")
   Present only when layout.yaml site.characters is on (body.chars). The button stacks 8 px above Events (desktop,
   portrait) or sits between More and Events in the landscape column; the dock is a right panel (desktop), a bottom
   sheet (portrait) or the side panel (landscape). */
/* a face from the atlas (--atlas, set once characters.json has loaded): --s px square, the cell at (--fx, --fy) in face
   units, the atlas --aw face units wide */
.u-cf { flex: none; display: inline-block; width: var(--s); height: var(--s); background-image: var(--atlas); background-repeat: no-repeat;
  background-size: calc(var(--s) * var(--aw)) auto; background-position: calc(var(--s) * var(--fx) * -1) calc(var(--s) * var(--fy) * -1);
  image-rendering: pixelated; image-rendering: crisp-edges; image-rendering: pixelated; border-radius: 2px; }
.u-cf0 { background: #3a3f63; }
#b-chars { display: inline-flex; align-items: center; gap: 6px; padding: 0 14px 0 12px; font-size: 14px; font-weight: 500; position: fixed; z-index: 8;
  right: 16px; bottom: calc((var(--sz-dock) - 2 * var(--sz-btn) - 8px) / 2 + var(--sz-btn) + 8px + var(--safe-b)); }   /* above Events */
#b-chars svg.u-charic { width: 18px; height: 18px; stroke: var(--ui-accent); stroke-width: 2.2; }
#b-chars[aria-expanded="true"] { border-color: var(--ui-accent); }
/* desktop: above the open events dock (the steppers take its place), or in the Events button's place without it */
body.u-evdock:not(.phone) #b-chars { bottom: calc(var(--sz-dock) + 10px + var(--safe-b)); }
body.u-evdock:not(.phone) .u-chars { bottom: calc(var(--sz-dock) + 10px + var(--sz-btn) + 8px + var(--safe-b)); }
body.noevents:not(.phone) #b-chars { bottom: calc((var(--sz-dock) - 2 * var(--sz-btn) - 8px) / 2 + var(--safe-b)); }
body.noevents.phone #b-chars { bottom: calc(8px + var(--safe-b)); }
body.noevents:not(.phone) .u-chars { bottom: calc((var(--sz-dock) - 2 * var(--sz-btn) - 8px) / 2 + var(--sz-btn) + 8px + var(--safe-b)); }
/* the visitor switches: without the characters feature, none of it; without the events dock, no dock, button or steppers */
body:not(.chars) #b-chars, body:not(.chars) #chars, body:not(.chars) #char-chip,
body.noevents #dock, body.noevents #events-sheet, body.noevents #dock-btn, body.noevents #dock-steps { display: none !important; }
body.phone #b-chars { font-size: 15px; right: calc(18px + var(--sz-btn)); bottom: calc(8px + var(--sz-btn) + 8px + var(--safe-b)); }
@media (max-width: 380px) { body.phone:not(.land) #b-chars { padding: 0 10px; font-size: 14px; gap: 5px; right: calc(16px + var(--sz-btn)); } }
/* portrait: hidden while a popup, a sheet or a dialog is open */
body.phone:not(.land):is(.u-popopen, :has(#events-sheet:not([hidden]), #chars:not([hidden]), .u-dlg:not([hidden]))) #b-chars { display: none; }
/* landscape: eight buttons in the column (Search, Watched, More; Characters, Events, Arcs, Key, Fit) */
body.land.chars:not(.noevents) { --sz-btn: min(var(--sz-btn-land, 48px), calc((100dvh - var(--safe-t) - var(--safe-b) - 58px) / 8)); }
body.land.noevents:not(.chars) { --sz-btn: min(var(--sz-btn-land, 48px), calc((100dvh - var(--safe-t) - var(--safe-b) - 46px) / 6)); }
body.land #b-chars { right: var(--col-r); bottom: calc(var(--side-bot) + 4 * (var(--sz-btn) + 6px)); padding: 2px 0 0; gap: 4px; }
body.land.noevents #b-chars { bottom: calc(var(--side-bot) + 3 * (var(--sz-btn) + 6px)); }
body.land #b-chars svg.u-charic { width: 20px; height: 20px; }

.u-chars { position: fixed; z-index: 6; right: 10px; top: calc(10px + var(--safe-t) + var(--sz-btn) + 8px); width: min(var(--sz-chars, 320px), calc(100vw - 20px));
  bottom: calc((var(--sz-dock) - 2 * var(--sz-btn) - 8px) / 2 + 2 * var(--sz-btn) + 16px + var(--safe-b)); display: flex; flex-direction: column; background: var(--ui-panel); border: 1px solid var(--ui-line);
  border-radius: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); overflow: hidden; }
.u-chars > .u-handle { display: none; }
#ch-list-view, #ch-card-view { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.u-chhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 6px 14px; }
.u-chhead .u-h { margin: 0; }
.u-chx { width: 34px; height: 34px; padding: 0; font-size: 18px; backdrop-filter: none; -webkit-backdrop-filter: none; }
.u-chback { height: 34px; padding: 0; border: none; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; color: var(--ui-accent); font-size: 14px; }
.u-chback:hover { text-decoration: underline; }
#ch-q { margin: 0 14px 6px; height: 38px; border-radius: 8px; border: 1px solid var(--ui-line); background: rgba(255, 255, 255, .05); color: var(--ui-ink);
  padding: 0 12px; font: 14px var(--txt); outline: none; flex: none; }
#ch-q:focus { border-color: var(--ui-accent); }
#ch-q::-webkit-search-cancel-button { filter: invert(.7); }
.u-chbody { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 8px; }
.u-chnote { margin: 4px 14px 6px; font-size: 13px; color: var(--c-event); }
.u-chempty { margin: 8px 14px; }
.u-chgrp { display: flex; justify-content: space-between; padding: 10px 14px 4px; font: 600 12px/16px var(--txt); color: var(--ui-dim); letter-spacing: .6px; text-transform: uppercase; }
.u-chcol { font-weight: 500; font-size: 10px; letter-spacing: .4px; }   /* names the counts' column */
.u-crow { display: flex; align-items: center; gap: 10px; width: 100%; height: 40px; padding: 0 14px; border: none; border-radius: 0; background: none;
  backdrop-filter: none; -webkit-backdrop-filter: none; text-align: left; font-size: 14px; }
.u-crow:hover, .u-crow:focus-visible { background: rgba(201, 184, 255, .1); }
.u-cn { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-cc { color: var(--ui-dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.u-chfoot { flex: none; margin: 0; padding: 10px 14px calc(10px + var(--safe-b)); border-top: 1px solid var(--ui-line); font-size: 13px; color: var(--ui-dim); }
.u-chfoot b { font-weight: 700; color: var(--c-event); }
.u-chcard { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 14px calc(14px + var(--safe-b)); }
.u-chid { display: flex; align-items: center; gap: 12px; margin: 2px 0 8px; }
.u-chid .u-cf { border-radius: 4px; }
.u-chname { font: 12px/1.5 var(--pix); letter-spacing: .5px; overflow-wrap: anywhere; }
.u-chid .u-popmeta { margin: 3px 0 0; }
.u-chdesc { margin: 6px 0 10px; font-size: 14px; line-height: 1.5; }
.u-chspoil { position: relative; margin: 6px 0 10px; }
.u-chspoil .u-chdesc { margin: 0; filter: blur(6px); user-select: none; -webkit-user-select: none; pointer-events: none; }
.u-chreveal { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); height: auto; min-height: 34px; padding: 6px 12px; font-size: 13px;
  background: var(--ui-panel); border-color: var(--ui-line); white-space: nowrap; }
.u-chreveal b { color: var(--ui-accent); font-weight: 600; }
.u-chevs .u-chip { width: 100%; height: auto; margin: 6px 0; }
/* the character chip: in the focus chip's place on every layout */
#char-chip { position: fixed; z-index: 5; top: calc(10px + var(--safe-t) + var(--sz-btn) + 8px); left: 50%; transform: translateX(-50%); width: max-content;   /* until app.js chSnapChip places it between its neighbours, on whole pixels */ display: flex; align-items: center;
  height: var(--sz-btn); max-width: calc(100vw - 20px); border: 1px solid var(--ui-accent); border-radius: 999px; background: var(--ui-pane);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); overflow: hidden; }
body:not(.phone) #char-chip { top: calc(10px + var(--safe-t)); }
@media (max-width: 1200px) { body:not(.phone) #char-chip { top: calc(10px + var(--safe-t) + var(--sz-btn) + 8px); } }
#char-chip button { height: 100%; border: none; border-radius: 0; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
#char-chip button:hover { background: rgba(255, 255, 255, .08); }
.u-ccstep { width: 38px; padding: 0; font-size: 12px; color: var(--ui-ink); }
.u-ccstep:disabled { opacity: .3; cursor: default; }
.u-ccstep:disabled:hover { background: none; }
.u-ccname { display: inline-flex; align-items: center; gap: 8px; min-width: 0; padding: 0 8px; font-size: 14px; }
.u-ccn { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.u-ccm { color: var(--ui-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.u-ccx { width: 38px; padding: 0; font-size: 14px; color: var(--ui-dim); border-left: 1px solid var(--ui-line) !important; }
body.phone .u-ccstep, body.phone .u-ccx { width: 44px; }
body.land #char-chip { top: var(--side-top); }
/* the popups' "In this episode" and "Involves" rows */
.u-chrow { margin: 10px 0 2px; }
.u-chrow .u-lgh { margin: 0 0 6px; line-height: 17px; }
.u-pcs { display: flex; flex-wrap: wrap; gap: 6px; }
.u-pc, .u-pcmore { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 9px 0 4px; font-size: 13px; border-radius: 6px; backdrop-filter: none;
  -webkit-backdrop-filter: none; max-width: 100%; }
.u-pc span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-pc.u-on { border-color: var(--ui-accent); box-shadow: 0 0 0 1px var(--ui-accent) inset; }
.u-pcmore { padding: 0 10px; color: var(--ui-accent); }
body.phone .u-pc, body.phone .u-pcmore { height: 38px; }
/* portrait: a bottom sheet, 72 dvh for the list, 50 dvh for a card (the lit poster shows above it) */
body.phone:not(.land) .u-chars { left: 0; right: 0; top: auto; bottom: 0; width: auto; height: 72dvh; z-index: 8; border-radius: 14px 14px 0 0; border-width: 1px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .5); touch-action: pan-y; }
body.phone:not(.land) .u-chars.u-oncard { height: 50dvh; }
body.phone:not(.land) .u-chars > .u-handle { display: block; flex: none; }
body.phone .u-crow { height: 46px; font-size: 15px; }
body.phone .u-chx { width: 44px; height: 44px; }
body.phone .u-chback { height: 44px; font-size: 15px; }
body.phone #ch-q { height: 44px; font-size: 16px; }
/* landscape: the side panel beside the column */
body.land .u-chars { left: auto; right: var(--side-r); top: var(--side-top); bottom: var(--side-bot); width: var(--side-w); z-index: 8; }

/* the More menu's visitor switches: a row each, the switch at the right */
.u-menusw { border-top: 1px solid var(--ui-line); border-bottom: 1px solid var(--ui-line); margin: 4px 0; padding: 2px 0; }
.u-menusw:empty { display: none; }
.u-menu .u-msw { justify-content: space-between; }
.u-msw .u-track { width: 40px; height: 24px; border-radius: 12px; }
.u-msw .u-track::after { width: 16px; height: 16px; }
.u-msw[aria-checked=true] .u-track { background: var(--ui-accent_strong); }
.u-msw[aria-checked=true] .u-track::after { transform: translateX(16px); }
.u-menu .u-msw { padding-left: 42px; }   /* the text lines up with the entries that have an icon */
body.land .u-menu small { display: none; }   /* landscape: one line per entry, so the menu fits the height */
body.land .u-menu button { min-height: 40px; padding: 2px 10px; }   /* landscape: the whole menu, switches included, fits the height */
body.land .u-menu .u-msw { padding-left: 42px; }
