/* Self-hosted Noto Sans and Noto Sans Mono (SIL Open Font License 1.1), Latin, Latin Extended and Cyrillic.
   Each file is a variable font covering weights 400-700. Japanese falls back to system fonts. */
@font-face {
  font-family: 'Noto Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(./fonts/noto-sans-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Noto Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(./fonts/noto-sans-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Noto Sans Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(./fonts/noto-sans-mono-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Noto Sans Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(./fonts/noto-sans-mono-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Noto Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(./fonts/noto-sans-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Noto Sans Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(./fonts/noto-sans-mono-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@property --bg {
  syntax: "<color>";
  inherits: true;
  initial-value: #0e0e0e;
}
@property --fg {
  syntax: "<color>";
  inherits: true;
  initial-value: #e8e8e8;
}
@property --accent {
  syntax: "<color>";
  inherits: true;
  initial-value: #e8e8e8;
}

:root {
  --toolbar-icon-size: 22px;
  color-scheme: light dark;
  --bg: #0e0e0e;
  --fg: #e8e8e8;
  --accent: #e8e8e8;
  --highlight: #0e0e0e;
  --glass: color-mix(in srgb, var(--bg) 46%, transparent);
  --glass-border: color-mix(in srgb, var(--fg) 16%, transparent);
  --glass-strong: color-mix(in srgb, var(--bg) 72%, transparent);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --gutter: 2rem;
  /* Distance from the screen edge to the content. The top adds the full safe area (status
     bar, notch). The bottom does not: the home indicator's inset (34px) would stack on the
     gutter and leave far more room below than above, so the gutter counts toward it. */
  --inset-t: calc(var(--gutter) + var(--safe-t));
  --inset-b: max(var(--gutter), calc(var(--safe-b) - var(--gutter)));
  /* The 5x5 grid the chrome and the complications share: one cell. */
  --col: calc((100vw - 2 * var(--gutter) - var(--safe-l) - var(--safe-r)) / 5);
  --row: calc((100dvh - var(--inset-t) - var(--inset-b)) / 5);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Everything sized in rem scales from here: a little larger overall, more on phones. */
html { font-size: 106.25%; }
@media (max-width: 640px) { html { font-size: 112.5%; } }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: "Noto Sans Mono", "Hiragino Sans", "Yu Gothic", "Meiryo", "Noto Sans CJK JP", monospace;
  -webkit-font-smoothing: antialiased;
}

.ui-face { font-family: "Noto Sans", "Hiragino Sans", "Yu Gothic", "Meiryo", "Noto Sans CJK JP", sans-serif; }

/* --- feed --- */

#feed {
  position: absolute;
  inset: 0;
  /* Native TikTok-style paging: swipe or wheel moves exactly one message. */
  overflow-x: hidden;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
  scroll-behavior: smooth;
}
#feed::-webkit-scrollbar { display: none; }
#feed > .page {
  scroll-snap-align: start;
  scroll-snap-stop: always; /* a hard flick still stops at the next message */
}

.page {
  position: relative;
  /* Without an explicit z-index, position:relative alone does not establish
     a stacking context, so .bg-dither's negative z-index would escape to a
     much larger ancestor context and paint underneath the page's own solid
     background instead of just behind this page's own text/chrome. */
  z-index: 0;
  height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1.1rem;
  /* The hero text is capped at 26ch, so it indents with the viewport instead
     of hugging the edge on wide windows; the chrome keeps the plain gutter.
     Left and right are the same, so wrapping uses the same room on both sides. */
  padding-left: calc(var(--gutter) + var(--safe-l));
  padding-right: calc(var(--gutter) + var(--safe-r));
}

/* --- ASCII background texture (per-page, painted by app.js) --- */

.bg-dither {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.22;
}

/* The warm look, for a theme that configures it: the page deepens away from its
   color, the field burns at full strength in its own colors and sinks to a glow
   behind the message and the top and bottom controls, and the icon takes the
   ember color. */
:root[data-warm] .page { background: linear-gradient(160deg, var(--bg), var(--deep)); }
:root[data-warm] .page > .bg-dither {
  --quiet-message: radial-gradient(ellipse 72% 46% at 30% 50%, rgba(0, 0, 0, var(--quiet, 0.25)) 65%, #000 100%);
  --quiet-edges: linear-gradient(to bottom, rgba(0, 0, 0, 0.2) 5rem, #000 9rem, #000 calc(100% - 9rem), rgba(0, 0, 0, 0.2) calc(100% - 5rem));
  --quiet-toolbar: linear-gradient(to left, rgba(0, 0, 0, 0.2) 4rem, #000 7rem);
  opacity: 1;
  -webkit-mask-image: var(--quiet-message), var(--quiet-edges), var(--quiet-toolbar);
  mask-image: var(--quiet-message), var(--quiet-edges), var(--quiet-toolbar);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}
/* On paper the densest characters are the text's own color, so they sink further. */
:root[data-warm][data-theme="light"] .page > .bg-dither { --quiet: 0.12; }
:root[data-warm] .page > .icon { background: var(--ember); }

/* --- icon: a Material Symbol above each message --- */

.icon {
    --size: min(calc(2 * clamp(1.7rem, 3.8vw + 1.7vh, 4.8rem)), 19vw);
  width: var(--size);
  height: var(--size);
  background: var(--accent);
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
  filter: drop-shadow(0 2px 24px rgba(0, 0, 0, 0.18));
}
.icon[hidden] { display: none; }
/* The icon, message and song are one block, centred in the page together. */
/* Typed from `#` characters (typedIcon() in shared.js): larger than a plain
   symbol so its characters read, and sharp-edged, so no soft shadow. */
.page > .icon { --size: min(var(--col) * 1.35, var(--row) * 1.35, 6.5rem); flex: none; filter: none; }

/* --- message place: the city a global digest message comes from, above it --- */

.msg-place {
  font-size: 0.9rem;
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent);
  max-width: 100%;
  overflow-wrap: anywhere;
}
.msg-place[hidden] { display: none; }

/* --- now playing: current background-music track, small, under the message --- */

.now-playing {
  font-size: 0.8rem;
  line-height: 1.3;
  letter-spacing: 0.01em;
  opacity: 0.7;
  max-width: 100%;
  overflow-wrap: anywhere;
  /* The label always holds the room of two lines (a long title wraps), so the
     centred block (icon, message, song) never shifts when a title appears,
     changes or goes. It only fades; anything beyond two lines is cut off. */
  min-height: 2.6em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  transition: opacity 0.4s ease;
}
.now-playing[hidden] { display: -webkit-box; opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .now-playing { transition: none; }
}

/* --- hero message --- */

.display {
  font-size: clamp(1.7rem, 3.8vw + 1.7vh, 4.8rem);
  line-height: 1.28;
  letter-spacing: -0.015em;
  font-weight: 500;
  text-align: left;
  max-width: min(26ch, 100%);
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.18);
}

/* Tall, narrow phones (about 21:9 and beyond): width is the limit, so scale from it. */
@media (max-aspect-ratio: 9/18) {
  .display { font-size: clamp(1.7rem, 8.4vw, 3.6rem); }
}

/* The whole message is the link when it has one; .link-mark at its end says so. */
.msg-link { color: inherit; text-decoration: none; }
.msg-link[href] { cursor: pointer; }
.msg-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 0.15em; border-radius: 0.14em; }
.link-mark {
  width: 0.62em;
  height: 0.62em;
  margin-left: 0.22em;
  vertical-align: baseline;
  fill: currentColor;
  opacity: 0.75;
}
.link-mark[hidden] { display: none; }

.word {
  display: inline-block;
  /* A word never contains a space, so this only matters for a word wider than
     the line (e.g. a long German compound): it breaks with a hyphen (using the
     page's lang) and, where no hyphenation is known, at any letter instead of
     running off. The cap counts the padding the negative margins hide (2 × 0.06em):
     the line box sizes to the words' margin boxes, so a plain 100% squeezes a
     word that sets the line's width, and its last character ("." in "Hello.")
     breaks onto a line of its own. */
  max-width: calc(100% + 0.12em);
  hyphens: auto;
  overflow-wrap: anywhere;
  padding: 0 0.06em;
  margin: 0 -0.06em;
  border-radius: 0.14em;
}

.word.active {
  background-color: var(--accent);
  color: var(--highlight); /* configured per theme with the palette */
}

/* --- brand logo (top-left, duplicated per page) --- */

.app-logo {
  position: absolute;
  left: calc(var(--gutter) + var(--safe-l));
  top: calc(1.4rem + var(--safe-t));
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

/* On the message pages the logo is cell 21 (bottom-left) of the page's frame. */
/* The text itself ends on the bottom edge: no box height around it. */
.frame > .app-logo.has-logo { height: 32px; }
.frame > .app-logo { height: auto; line-height: 1; position: static; grid-area: 5 / 1; justify-self: start; align-self: end; }

.brand-mark {
  display: block;
  line-height: 0;
  color: var(--fg);
}

/* The hourglass, outlined in the text color, so the mark follows every palette. */
.brand-mark .mark { display: block; height: var(--toolbar-icon-size); width: auto; }
.brand-mark .mark path { stroke: var(--fg); }

.brand-logo-img {
  height: 100%;
  width: auto;
  max-width: 96px;
  object-fit: contain;
  display: block;
}

/* --- action bar (bottom-right, vertical; duplicated per page):
   theme, mute, thumbs up/down, share --- */

.icon-toolbar-vertical {
  /* Cells 20 and 25 merged: a column ending bottom-right. */
  grid-area: 4 / 5 / 6 / 6;
  justify-self: end;
  align-self: end;
  margin: 0 -11px -11px 0; /* glyphs, not buttons, on the content edge */
  display: flex;
  flex-direction: column;
  align-items: center;
}
/* Spaced like TikTok's rail: each action is a block (an icon, or a thumb with its
   count tucked right under it), and the same ~20px of clear space separates one
   block from the next. A glyph's ink fills 18 of its 44px button, leaving 13px
   above and below, so neighbouring buttons overlap by 4px. */
.icon-toolbar-vertical > * + * { margin-top: -4px; }
.icon-toolbar-vertical > .vote + * { margin-top: 0; }

/* Thumbs up/down in the rail, between mute and share, each count in small mono
   type under its thumb. The chosen thumb is filled in the text color, not the accent: several
   palettes (Barcelona, Madrid, Paris, Amsterdam...) have an accent that is nearly
   invisible against their dark background, and the text color always reads. */
.vote {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.vote[hidden] { display: none; }
.vote-count {
  font: 500 0.7rem "Noto Sans Mono", monospace;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
  /* line-height 1 leaves the digits' ink about 0.18em below the box's top and
     0.14em above its bottom: these margins put the digits ~4px under their
     thumb and the next block ~20px below them. */
  line-height: 1;
  margin: calc(-6px - 0.18em) 0 calc(7.5px - 0.14em);
  pointer-events: none;
}
/* The thumb-down glyph's ink ends 1px higher in its box than the thumb-up's. */
.vote-count-down { margin-top: calc(-5px - 0.18em); }
.btn-vote[aria-pressed="true"] { opacity: 1; color: var(--fg); }
.icon-btn.btn-vote:focus-visible { outline-color: var(--fg); }
.icon-btn.btn-vote[aria-pressed="true"] svg.line path:last-child { fill: currentColor; }
.btn-vote[aria-pressed="true"] + .vote-count { opacity: 1; color: var(--fg); font-weight: 700; }

/* The sound switch blinks in its usual color while waiting for sound to be
   enabled, or while the station break or the co-host's lines are spoken. */
.btn-sound.voice-over svg,
.btn-sound.sound-blocked svg {
  animation: voice-over-blink 1s ease-in-out infinite;
}
@keyframes voice-over-blink { 50% { opacity: 0.25; } }

/* --- complications: readouts in the outer ring of a 5x5 grid, cells numbered 1-25 row
   by row. The inner 3x3 (7-9, 12-14, 17-19) belongs to the message. --- */

/* Every page carries its own frame, so the readouts and controls scroll with it. */
.frame {
  position: absolute;
  inset: 0;
  padding: var(--inset-t) calc(var(--gutter) + var(--safe-r)) var(--inset-b) calc(var(--gutter) + var(--safe-l));
  display: grid;
  grid-template: repeat(5, minmax(0, 1fr)) / repeat(5, minmax(0, 1fr));
  pointer-events: none;
  z-index: 5;
}
.frame > :not(.cx):not(.cx-grid) { pointer-events: auto; }
.cx {
  font: 600 0.7rem "Noto Sans Mono", monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  align-self: center; justify-self: center; white-space: nowrap; font-variant-numeric: tabular-nums; opacity: 0.85; }
.cx[data-row="1"] { align-self: start; }
.cx[data-row="5"] { align-self: end; }
.cx[data-col="1"] { justify-self: start; }
.cx[data-col="5"] { justify-self: end; text-align: right; }
.cx-grid { display: grid; place-items: center; border: 1px dashed color-mix(in srgb, var(--fg) 35%, transparent); font-style: normal; opacity: 0.5; }
@media (max-width: 640px) { .cx[data-col="3"] { display: none; } }

/* Debug mode (?debug=<code>): the panel over the top-left corner, see renderDebug() in app.js. */
.debug-panel {
  position: fixed;
  top: calc(8px + var(--safe-t));
  left: calc(8px + var(--safe-l));
  z-index: 100;
  max-width: min(560px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow: auto;
  font: 0.7rem/1.4 "Noto Sans Mono", monospace;
  color: var(--fg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border: 1px dashed color-mix(in srgb, var(--fg) 50%, transparent);
  padding: 4px 8px;
}
.debug-panel summary { cursor: pointer; white-space: nowrap; }
.debug-panel details { margin-top: 4px; }
.debug-panel pre { margin: 2px 0 0; white-space: pre-wrap; word-break: break-all; user-select: text; }
.debug-copy { font: inherit; color: inherit; background: none; border: 1px solid currentColor; padding: 0 6px; margin-top: 4px; cursor: pointer; }

/* Cells 4 and 5 merged: the refresh and menu buttons in one right-aligned row.
   A 44px button's 22px glyph is inset 11px, so the row is pulled out by that much
   to put the glyph on the same edge as the text readouts. */
.icon-toolbar-top {
  grid-area: 1 / 4 / 2 / 6;
  justify-self: end;
  align-self: start;
  margin: -11px -11px 0 0;
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

/* The refresh button appears left of the menu icon when a newer version is out. */
.icon-btn.btn-update { display: none; }
.has-update .icon-btn.btn-update { display: flex; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--fg);
  opacity: 0.88;
  cursor: pointer;
  padding: 0;
  transition: opacity 150ms ease, transform 120ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icon-btn:hover,
.icon-btn:focus-visible { opacity: 1; background: color-mix(in srgb, var(--fg) 10%, transparent); }
.icon-btn:active { transform: scale(0.88); }
.icon-btn[hidden] { display: none; }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn svg { width: var(--toolbar-icon-size); height: var(--toolbar-icon-size); }

.btn-language {
  width: auto;
  /* The globe glyph is inset 11px, like every icon, so it lands on the content edge. */
  padding: 0 0.75rem 0 11px;
  gap: 6px;
  justify-content: flex-start;
  border-radius: 22px;
  font: 500 0.8rem "Noto Sans Mono", monospace;
  /* It shows the place name, which can be long ("Vereinigtes Königreich"): stay clear of
     the logo (up to ~96px) and the other buttons, and end in an ellipsis. */
  line-height: 44px;
  white-space: nowrap;
  max-width: calc(2 * var(--col) - 44px);
}
.btn-language svg { flex-shrink: 0; }
.btn-language .place-label { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (max-width: 640px) { .btn-language { max-width: calc(3 * var(--col) - 44px); } }
.icon-btn svg path { fill: currentColor; }
.icon-btn svg.line path { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* --- story indicator: a horizontal row of fine vertical ticks --- */

.segments {
  /* Shared across pages, aligned with cells 22–24 of the frame at rest. */
  position: fixed;
  z-index: 6;
  left: calc(var(--gutter) + var(--safe-l) + var(--col));
  right: calc(var(--gutter) + var(--safe-r) + var(--col));
  bottom: var(--inset-b);
  height: 4px; /* the ticks' own height: they end on the bottom edge */
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 600ms;
}
.segments[hidden] { display: none; }
.seg-track {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--gap, 5px);
}
.seg {
  position: relative;
  flex: none;
  padding: 0;
  border: 0;
  cursor: pointer;
  pointer-events: auto;
  width: var(--dot, 2px);
  height: 4px;
  border-radius: 0;
  background: var(--fg);
  opacity: var(--tick-opacity, 0.2);
  transition: width var(--dur) var(--ease), height var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
/* The 2px tick is a thin target: its hit area reaches into the gaps and above and below. */
.seg::before { content: ""; position: absolute; inset: -12px calc(var(--gap, 5px) / -2); }
/* The end ticks' hit areas stop at the bar's ends, so they never cover the menu
   icon or the theme button at the top of the action rail. */
.seg:first-child::before { left: 0; }
.seg:last-child::before { right: 0; }
.seg.is-active { opacity: 1; height: 10px; }
.segments { touch-action: none; }
.seg { touch-action: none; }
@media (prefers-reduced-motion: reduce) {
  .seg { transition: none; }
}

/* Route overlay: sits over the storybar, which stays mounted underneath. */
#view {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  padding: calc(var(--safe-t) + 1.25rem) calc(var(--safe-r) + var(--gutter)) calc(var(--safe-b) + 1.25rem) calc(var(--safe-l) + var(--gutter));
  background: var(--bg);
  color: var(--fg);
}
#view[hidden] { display: none; }
/* The same ASCII field as the message pages, pinned so it doesn't scroll with the
   text, and fainter so paragraphs stay readable. */
#view > .bg-dither { position: fixed; opacity: 0.22; pointer-events: none; }
/* The warm look: the view deepens like the pages, and the field burns at full
   strength beside the content and sinks to a glow behind it. The location list is
   a centered column, the menu's links hug the right edge; a phone is mostly glow. */
:root[data-warm] #view { background: linear-gradient(160deg, var(--bg), var(--deep)); }
:root[data-warm] #view > .bg-dither {
  --quiet: 0.1;
  --quiet-column: linear-gradient(to right, #000 calc(50% - 26rem), rgba(0, 0, 0, var(--quiet)) calc(50% - 19rem), rgba(0, 0, 0, var(--quiet)) calc(50% + 19rem), #000 calc(50% + 26rem));
  opacity: 1;
  -webkit-mask-image: var(--quiet-column);
  mask-image: var(--quiet-column);
}
/* On paper the densest characters are the text's own color, so they sink further. */
:root[data-warm][data-theme="light"] #view > .bg-dither { --quiet: 0.06; }
/* The menu's big links over sparse stars can take more. */
:root[data-warm] #view:has(> .picker-menu) > .bg-dither {
  --quiet: 0.25;
  --quiet-column: linear-gradient(to left, rgba(0, 0, 0, var(--quiet)) 20rem, #000 30rem);
}
#view a { color: var(--fg); min-height: 44px; display: inline-flex; align-items: center; }

/* Phones: pull the content toward the edges. --gutter drives the grid (--col, --row),
   the feed, the bottom bar and the picker, so this one value moves all of them. */
@media (max-width: 640px) {
  :root { --gutter: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  #feed { scroll-behavior: auto; }
  .icon-btn, .icon-btn:active {
    transition-duration: 0.15s;
  }
  .icon-btn:hover, .icon-btn:focus-visible { transform: none; }
  .btn-sound.voice-over svg,
  .btn-sound.sound-blocked svg { animation: none; }
}

/* Language and location pickers: full-page views, content column centered on wide screens. */

#view:has(> .picker):not([hidden]) {
  display: flex;
  justify-content: center;
  padding: 0;
}

.picker {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  --pad: max(1rem, calc((100% - 36rem) / 2));
  min-height: 100dvh;
  padding: calc(var(--safe-t, 0px) + 0.75rem) 0 calc(var(--safe-b, 0px) + 1rem) 0;
  color: var(--fg);
}

.picker-header { padding: 0 var(--pad); display: flex; align-items: center; gap: 0.5rem; min-height: 44px; flex: none; }
/* The title names the dialog for screen readers; sighted users don't need it. */
.picker-title {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* Search bar: same row height and gutters as the place rows, icon + borderless field. */
.picker-searchbar {
  display: flex; align-items: center; gap: 0.75rem;
  box-sizing: border-box; flex: none; min-height: 4.25rem; padding: 0 var(--pad);
  position: sticky; top: calc(var(--safe-t, 0px) + 0.5rem); z-index: 1;
  border-block: 1px solid var(--glass-border);
  background: color-mix(in srgb, var(--fg) 8%, var(--bg));
  box-shadow: 0 -0.5rem 0 var(--bg);
}
.picker-search-icon { flex: none; width: 1.25rem; height: 1.25rem; opacity: 0.75; }
.picker-searchbar:focus-within .picker-search-icon { opacity: 1; }
.picker-search {
  flex: 1; min-width: 0; align-self: stretch; padding: 0; border: 0; border-radius: 0;
  background: transparent; color: inherit; font: inherit; font-size: 1rem; outline: 0;
}
.picker-search::placeholder { color: inherit; opacity: 0.6; }
.picker-search::-webkit-search-cancel-button { display: none; }

.picker-list { list-style: none; margin: 0; padding: 0; }
.picker-item { border-bottom: 1px solid var(--glass-border); }
.picker-item:last-child { border-bottom: 0; }
/* The menu's page links sit on their own rows, no rules between them. */
.picker-menu .picker-item { border-bottom: 0; }
/* The links start below the toolbar (place and Close), which is the same frame, in the
   same cells, as on the message pages. */
.picker-menu {
  --pad: calc(var(--gutter) + var(--safe-l));
  position: relative;
  padding-top: calc(var(--safe-t, 0px) + var(--gutter) + 44px + 1rem);
}
.picker-menu > .frame { bottom: auto; height: 100dvh; }
.picker-menu .picker-header { min-height: 0; }

.picker-option, .picker-choice, .picker-cancel {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.1rem 0.6rem;
  box-sizing: border-box; width: 100%; min-height: 44px; padding: 0.6rem var(--pad);
  border: 0; background: transparent; color: inherit;
  font: inherit; font-size: 1rem; text-align: left; cursor: pointer;
}
.picker-option:focus-visible, .picker-choice:focus-visible, .picker-cancel:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Right-aligned at every width, under the menu button. */
.picker-menu .picker-option { justify-content: flex-end; text-align: right; min-height: 4.5rem; align-items: center; font-size: clamp(1.75rem, 7vw, 2.5rem); font-weight: 500; text-decoration: none; }
/* Hover and keyboard focus underline the link in the accent colour (#view a would otherwise pin the text colour). */
.picker-menu a.picker-option:hover, .picker-menu a.picker-option:focus-visible {
  text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 3px; text-underline-offset: 0.3em;
}
.picker-option:hover { color: var(--accent); }
/* A place name is only a label in the location list (the menu's page links are real links). */
div.picker-option { cursor: default; }
div.picker-option:hover { color: inherit; }
/* Two distinct row states, both built from the palette so they read in any theme. The
   keyboard-highlighted row inverts the scheme (page background as text on a foreground-colored
   row); the current place is a soft tint of the foreground with a solid edge. */
.picker-item:has(> .picker-option[aria-current="true"]) { background: color-mix(in srgb, var(--fg) 10%, var(--bg)); color: var(--fg); box-shadow: inset 4px 0 0 var(--fg); }
.picker-item:has(> .picker-option[aria-current="true"]) :is(.picker-option, .picker-lang):is(:hover, :focus-visible, .is-selected) { color: var(--fg); }
.picker-item:has(> .picker-option[aria-current="true"]) .picker-option:focus-visible { outline-color: var(--fg); }
.picker-list .picker-item.is-active { background: var(--fg); color: var(--bg); }
.picker-list .picker-item.is-active :is(.picker-option, .picker-lang):is(:hover, :focus-visible, .is-selected) { color: var(--bg); }
.picker-list .picker-item.is-active .picker-option:focus-visible { outline-color: var(--bg); }
.picker-item:is(.is-active, :has(> .picker-option[aria-current="true"])) .picker-lang:is([aria-current="true"], .is-selected) { font-weight: 700; }
.picker-sub { opacity: 0.6; font-size: 0.875rem; }
.picker-alt::before { content: "|\00a0"; }
.picker-hint { flex-basis: 100%; font-size: 0.8125rem; }
/* Languages sit under the place name as a plain comma-separated line. */
.picker-langs { display: flex; flex-wrap: wrap; padding: 0 var(--pad) 0.5rem; margin-top: -0.4rem; font-size: 0.8125rem; }
.picker-lang {
  padding: 0.25rem 0; border: 0; background: transparent;
  color: inherit; font: inherit; cursor: pointer; opacity: 0.75;
}
.picker-lang:not(:last-child)::after { content: ",\00a0"; }
.picker-lang:hover, .picker-lang:focus-visible, .picker-lang.is-selected { color: var(--accent); opacity: 1; }
.picker-lang:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.picker-lang[aria-current="true"] { font-weight: 700; }

.picker-confirm { padding: 0 var(--pad) 0.75rem; }
.picker-confirm-text { margin: 0 0 0.25rem; font-size: 0.9375rem; }
.picker-choice { border: 1px solid var(--glass-border); border-radius: 0; margin: 0.25rem 0; padding: 0.6rem 0.9rem; }
.picker-cancel { opacity: 0.7; }
.picker-empty { opacity: 0.6; padding: 1rem var(--pad); }


/* Settings view (rendered into #view). Mobile first. */
#view .settings-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
#view .settings-title { font-size: 1.5rem; font-weight: 600; margin: 0; }
#view .settings-section { max-width: 40rem; margin: 0 auto 1.75rem; }
#view .settings-header { max-width: 40rem; margin-inline: auto; }
#view .settings-subtitle { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; margin: 0; opacity: 0.7; }

#view .settings-row {
  display: flex; width: 100%; box-sizing: border-box; gap: 0.75rem;
  min-height: 48px; padding: 0.5rem 0; text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--fg) 16%, transparent);
}
#view .settings-row-label { flex: 1; }
#view .settings-row-value { opacity: 0.7; text-align: right; }
#view .settings-chevron { opacity: 0.5; }

#view .settings-cat-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 44px; }
#view .settings-bulk { display: flex; gap: 0.25rem; }
#view .settings-link-btn {
  min-height: 44px; min-width: 44px; padding: 0 0.6rem; background: none; border: 0;
  color: var(--accent); font: inherit; font-size: 0.9rem; cursor: pointer;
}
#view .settings-hint { margin: 0.25rem 0 0.5rem; padding: 0.6rem 0.8rem; border: 1px solid var(--accent); border-radius: 8px; font-size: 0.9rem; }
#view .settings-hint[hidden] { display: none; }
#view .settings-list { list-style: none; margin: 0; padding: 0; }

#view .settings-switch {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 48px; cursor: pointer;
  border-bottom: 1px solid color-mix(in srgb, var(--fg) 16%, transparent);
}
#view .settings-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
#view .settings-track {
  flex: none; position: relative; width: 48px; height: 28px; border-radius: 14px;
  background: color-mix(in srgb, var(--fg) 25%, transparent);
}
#view .settings-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--fg); transition: transform 0.2s;
}
#view .settings-switch input:checked ~ .settings-track { background: var(--accent); }
#view .settings-switch input:checked ~ .settings-track::after { transform: translateX(20px); background: var(--bg); }
#view .settings-switch input:focus-visible ~ .settings-track { outline: 2px solid var(--accent); outline-offset: 3px; }

#view .settings-legal { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; max-width: 40rem; margin: 0 auto; }

@media (prefers-reduced-motion: reduce) {
  #view .settings-track, #view .settings-track::after { transition: none; }
}

/* Hide the date, weekday and time cells in the top row. */
.cx[data-row="1"] { display: none; }
/* The location button sits top-left, on the content edge (the frame is its
   positioning context). */
.icon-toolbar-top .btn-language {
  position: absolute;
  top: var(--inset-t);
  left: calc(var(--gutter) + var(--safe-l));
  margin: -11px 0 0 -11px;
}

/* The storybar ticks run vertically in the action rail's column, centred between
   the menu icon (top right) and the top of the rail, the same distance clear of
   each: the row is laid out by the same code, then turned a quarter.
   placeSegments() measures both and sets --seg-x, --seg-y and --seg-len. */
.page { padding-right: calc(var(--gutter) + var(--safe-r) + 1.75rem); }
.segments {
  top: var(--seg-y, 30%);
  bottom: auto;
  left: var(--seg-x, calc(100vw - var(--gutter) - var(--safe-r) - 11px));
  right: auto;
  width: var(--seg-len, 30vh);
  transform: translate(-50%, -50%) rotate(90deg);
}

/* Tap-to-pause (TikTok): a big play glyph in the middle of the screen while the
   feed is paused, popping in on pause and out on resume. */
.tap-icon {
  position: fixed;
  left: 50%; top: 50%;
  z-index: 7;
  width: 96px; height: 96px;
  margin: -48px 0 0 -48px;
  display: grid; place-items: center;
  color: #fff;
  filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.35));
  pointer-events: none;
  opacity: 0;
  transform: scale(1.5);
  transition: opacity 160ms ease-out, transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.tap-icon svg { width: 96px; height: 96px; fill: currentColor; }
.tap-icon.is-shown { opacity: 0.8; transform: scale(1); pointer-events: auto; cursor: pointer; } /* above the link, so a tap on it resumes */
/* Resuming: the glyph swells and fades. */
.tap-icon.is-leaving { opacity: 0; transform: scale(1.35); pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .tap-icon { transition: none; transform: none !important; } }

