/* Signs of Jesus trial — "an illuminated manuscript, broadcast live".
   Vellum and indigo, a single gold leaf accent, serif for the Word and sans
   for the controls. Two themes: day (host console default) and night
   (listener default: a phone screen must not light up a dim hall).
   Colour carries meaning: gold = the Word / active choice, ember = live,
   green / amber / red = health only. Motion is transform/opacity only. */

/* ---------- tokens ---------- */

:root {
  --font-serif: "Noto Serif TC", "Songti TC", "Source Han Serif TC", "PMingLiU", serif;
  --font-display: "Cormorant Garamond", "Noto Serif TC", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;

  --paper: #f6f0e3;
  --paper-raised: #fffbf3;
  --paper-sunk: #efe6d3;
  --ink: #1a1b30;
  --ink-soft: #5d596d;
  --ink-faint: #6b6679;
  --line: rgb(26 27 48 / 0.11);
  --line-strong: rgb(26 27 48 / 0.2);
  --indigo: #1d2561;
  --indigo-deep: #10153a;
  --gold: #a87a2c;
  --gold-ink: #87601d;
  --gold-soft: rgb(168 122 44 / 0.14);
  --leaf: linear-gradient(135deg, #f6e3a8 0%, #d8ab55 42%, #a8792c 70%, #e9c97c 100%);
  --ember: #b3382c;
  --ok: #2d7d59;
  --warn: #b7761a;
  --bad: #b3382c;
  --wait: #4d5ba8;
  --glow-a: rgb(216 171 85 / 0.28);
  --glow-b: rgb(214 160 120 / 0.14);
  --shadow: 0 1px 0 rgb(255 255 255 / 0.7) inset, 0 18px 40px -24px rgb(26 27 48 / 0.35), 0 2px 6px -2px rgb(26 27 48 / 0.08);
  --caption-scale: 1;

  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 9px;
  --space-1: 0.375rem;
  --space-2: 0.75rem;
  --space-3: 1.125rem;
  --space-4: 1.75rem;
  --space-5: 2.75rem;
  --space-6: clamp(3rem, 2rem + 4vw, 5.5rem);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --fast: 160ms;
  --slow: 600ms;
}

[data-theme="night"] {
  --paper: #0a0d22;
  --paper-raised: #12163a;
  --paper-sunk: #080a1b;
  --ink: #f2eadb;
  --ink-soft: #b2abc4;
  --ink-faint: #a29cbb;
  --line: rgb(242 234 219 / 0.1);
  --line-strong: rgb(242 234 219 / 0.2);
  --gold: #e2bd72;
  --gold-ink: #e8c785;
  --gold-soft: rgb(226 189 114 / 0.13);
  --ok: #4fbf8b;
  --warn: #e8a643;
  --bad: #ee6a5a;
  --wait: #8d9bf0;
  --ember: #ee6a5a;
  --glow-a: rgb(226 189 114 / 0.16);
  --glow-b: rgb(98 112 220 / 0.22);
  --shadow: 0 1px 0 rgb(255 255 255 / 0.04) inset, 0 24px 48px -28px rgb(0 0 0 / 0.8);
  color-scheme: dark;
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--slow) var(--ease), color var(--slow) var(--ease);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 6px; }

/* Vellum grain + two soft light sources. Fixed, behind everything. */
.atmosphere { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.atmosphere::after {
  content: ""; position: absolute; inset: 0; opacity: 0.35; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .38 0 0 0 0 .26 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="night"] .atmosphere::after { mix-blend-mode: screen; opacity: 0.18; }
.glow { position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%; filter: blur(10px); }
.glow-a { top: -38vmax; right: -22vmax; background: radial-gradient(circle, var(--glow-a), transparent 62%); }
.glow-b { bottom: -40vmax; left: -28vmax; background: radial-gradient(circle, var(--glow-b), transparent 60%); }

/* ---------- masthead ---------- */

.masthead {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  padding: calc(env(safe-area-inset-top) + 0.7rem) clamp(1rem, 4vw, 2.5rem) 0.7rem;
  background: color-mix(in srgb, var(--paper) 78%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.wordmark { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--ink); text-decoration: none; }
.wordmark-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--leaf); color: var(--indigo-deep);
  box-shadow: 0 0 0 1px rgb(168 122 44 / 0.4), 0 6px 14px -6px rgb(168 122 44 / 0.7);
}
.wordmark-mark svg { width: 16px; height: 16px; stroke-width: 2.4; }
.wordmark-text { font: italic 600 1.32rem/1 var(--font-display); letter-spacing: 0.01em; }
.masthead-tools { display: flex; align-items: center; gap: 0.5rem; }

/* Segmented controls and icon buttons share one shape. */
.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px;
  background: var(--paper-sunk); border: 1px solid var(--line);
}
.seg button {
  min-width: 2.75rem; min-height: 2.75rem; padding: 0 0.8rem; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-soft); font-size: 0.86rem; font-weight: 600; white-space: nowrap;
  transition: background-color var(--fast), color var(--fast), transform var(--fast);
}
.seg button small { font-size: 0.7em; margin-left: 1px; }
.seg button:hover { color: var(--ink); }
.seg button:active { transform: scale(0.96); }
.seg button[aria-pressed="true"] { background: var(--paper-raised); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12), 0 0 0 1px var(--line); }
.icon-btn {
  display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 50%;
  border: 1px solid var(--line); background: var(--paper-sunk); color: var(--ink-soft);
  transition: color var(--fast), transform var(--fast);
}
.icon-btn:hover { color: var(--gold-ink); }
.icon-btn:active { transform: scale(0.94) rotate(-12deg); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .i-sun { display: none; }
[data-theme="night"] .icon-btn .i-sun { display: block; }
[data-theme="night"] .icon-btn .i-moon { display: none; }

/* ---------- layout ---------- */

.page { width: min(100%, 44rem); margin: 0 auto; padding: var(--space-4) clamp(1rem, 4vw, 1.5rem) var(--space-5); display: grid; gap: var(--space-5); }
.host-page { width: min(100%, 72rem); }
.colophon { text-align: center; padding: 0 1rem calc(env(safe-area-inset-bottom) + 2rem); color: var(--ink-faint); font: italic 500 0.95rem var(--font-display); letter-spacing: 0.04em; }

.eyebrow {
  display: flex; align-items: center; gap: 0.6rem;
  color: var(--gold-ink); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase;
}
.eyebrow-rule { flex: 0 0 2.2rem; height: 1px; background: currentColor; opacity: 0.55; }
.section-label { display: flex; align-items: baseline; gap: 0.6rem; font: 700 1.05rem/1.2 var(--font-serif); letter-spacing: 0.06em; }
.section-label .en { font: italic 500 0.98rem var(--font-display); color: var(--ink-faint); letter-spacing: 0.02em; }
.hint { color: var(--ink-soft); font-size: 0.86rem; line-height: 1.55; }
.hint.center { text-align: center; }

.panel {
  position: relative; padding: var(--space-3) var(--space-3) var(--space-4);
  background: var(--paper-raised); border-radius: var(--r-lg); box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
/* Gold hairline inset: the manuscript border. */
.panel::before, .scroll::before {
  content: ""; position: absolute; inset: 6px; border-radius: calc(var(--r-lg) - 6px);
  border: 1px solid var(--gold-soft); pointer-events: none;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.step { font: italic 600 1.5rem/1 var(--font-display); color: var(--gold); opacity: 0.7; }

/* ---------- buttons ---------- */

.btn {
  position: relative; display: block; width: 100%; padding: 0.95rem 1.2rem; border: 0; border-radius: var(--r-md);
  font-size: 1.08rem; font-weight: 700; letter-spacing: 0.08em; text-align: center;
  transition: transform var(--fast) var(--ease), box-shadow var(--fast), opacity var(--fast);
}
.btn .en-sub { display: block; margin-top: 0.15rem; font: italic 500 0.92rem var(--font-display); letter-spacing: 0.03em; opacity: 0.8; }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-gold {
  color: var(--indigo-deep); background: var(--leaf); background-size: 160% 160%;
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.6) inset, 0 -2px 0 rgb(0 0 0 / 0.12) inset, 0 14px 30px -14px rgb(168 122 44 / 0.9);
}
.btn-gold::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / 0.55) 50%, transparent 65%);
  transform: translateX(-110%); transition: transform 900ms var(--ease);
}
.btn-gold:hover::after { transform: translateX(110%); }
.btn-hero { padding: 1.25rem; font-size: 1.3rem; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line-strong); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-ink); }
.btn-ghost[aria-pressed="true"] { border-color: var(--ok); color: var(--ok); }
.btn-sm { padding: 0.6rem 0.8rem; font-size: 0.92rem; letter-spacing: 0.04em; }
.btn-sm .en-sub { font-size: 0.82rem; }
.btn-danger { background: transparent; color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 55%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 8%, transparent); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }

.field {
  width: 100%; padding: 0.8rem 0.95rem; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink);
  transition: border-color var(--fast), box-shadow var(--fast);
}
.field:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.field-lg { font-size: 1.25rem; letter-spacing: 0.3em; text-align: center; }
.field-label { display: block; margin: var(--space-3) 0 0.4rem; font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); letter-spacing: 0.06em; }

.error-box { padding: 0.9rem 1rem; border-radius: var(--r-md); white-space: pre-line; color: var(--bad); background: color-mix(in srgb, var(--bad) 9%, transparent); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); }

/* ---------- status pill (written by listen.js / host.js) ---------- */

.status {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.85rem; border-radius: 999px;
  font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); background: var(--paper-sunk); border: 1px solid var(--line);
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); }
.status.ok { color: var(--wait); }
.status.ok .dot { background: var(--wait); }
.status.live { color: var(--ember); border-color: color-mix(in srgb, var(--ember) 35%, transparent); }
.status.live .dot { background: var(--ember); animation: beat 1.6s var(--ease) infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.7); opacity: 0.45; } }

/* ---------- listener: the nave ---------- */

.nave { display: grid; justify-items: center; text-align: center; gap: var(--space-2); padding-top: var(--space-3); }
.nave .eyebrow { justify-content: center; }
.nave-title { max-width: 16em; font: 700 clamp(1.35rem, 1rem + 2.6vw, 2.6rem)/1.3 var(--font-serif); letter-spacing: 0.04em; text-wrap: balance; overflow-wrap: anywhere; }
.nave-sub { font: italic 500 1.08rem/1.4 var(--font-display); color: var(--ink-soft); }
.nave-state { display: grid; justify-items: center; gap: 0.6rem; min-height: 5.5rem; }
.state-line { display: grid; gap: 0.15rem; }
.state-line .zh { font: 700 1.2rem/1.4 var(--font-serif); letter-spacing: 0.05em; }
.state-line .en { font: italic 500 1rem var(--font-display); color: var(--ink-soft); }

/* The lumen: a cross of light whose halos breathe while the Word is spoken. */
.lumen { position: relative; width: min(11.5rem, 58vw); aspect-ratio: 1; margin: var(--space-3) 0 var(--space-2); display: grid; place-items: center; }
.lumen-ring { position: absolute; inset: 0; border-radius: 50%; border: 1px solid var(--gold); opacity: 0.18; }
.lumen-ring:nth-child(2) { inset: 13%; opacity: 0.28; }
.lumen-ring:nth-child(3) { inset: 26%; opacity: 0.4; }
.lumen-core {
  position: relative; width: 44%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  color: var(--indigo-deep);
  background: radial-gradient(circle at 35% 30%, #fff8e0, #ecc778 45%, #b5852f 100%);
  box-shadow: 0 0 0 1px rgb(168 122 44 / 0.4), 0 0 40px 6px rgb(226 189 114 / 0.38), 0 0 120px 20px rgb(226 189 114 / 0.18);
  transition: transform var(--slow) var(--ease), filter var(--slow);
}
.lumen-core svg { width: 58%; stroke-width: 2.6; }
.lumen[data-state="idle"] .lumen-core, .lumen[data-state="ended"] .lumen-core { filter: saturate(0.55) brightness(0.92); transform: scale(0.92); }
.lumen[data-state="waiting"] .lumen-ring { animation: breathe 3.6s var(--ease) infinite; }
.lumen[data-state="live"] .lumen-ring { animation: breathe 4.8s ease-in-out infinite; }
.lumen[data-state="speaking"] .lumen-ring { animation: ripple 2.4s cubic-bezier(0.2, 0.6, 0.3, 1) infinite; }
.lumen[data-state="speaking"] .lumen-core { transform: scale(1.04); }
.lumen-ring:nth-child(2) { animation-delay: 0.4s !important; }
.lumen-ring:nth-child(3) { animation-delay: 0.8s !important; }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 0.18; } 50% { transform: scale(1.05); opacity: 0.42; } }
@keyframes ripple { 0% { transform: scale(0.7); opacity: 0.65; } 100% { transform: scale(1.18); opacity: 0; } }

/* ---------- listener: language choice ---------- */

.choose { display: grid; gap: var(--space-3); }
.lang-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: var(--space-2); }
.lang-grid .opt {
  position: relative; display: grid; gap: 0.1rem; justify-items: start; text-align: left;
  min-height: 6.4rem; padding: 1rem 1.1rem; border-radius: var(--r-lg);
  border: 1px solid var(--line-strong); background: var(--paper-raised); box-shadow: var(--shadow);
  transition: transform var(--fast) var(--ease), border-color var(--fast), box-shadow var(--fast);
}
.lang-grid .opt:hover { transform: translateY(-2px); border-color: var(--gold); }
.lang-grid .opt:active { transform: translateY(0) scale(0.985); }
.lang-grid .opt .zh { font: 700 1.55rem/1.2 var(--font-serif); letter-spacing: 0.06em; }
.lang-grid .opt .en { font: italic 500 1.05rem var(--font-display); color: var(--ink-soft); }
.lang-grid .opt .desc { margin-top: 0.35rem; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.12em; color: var(--gold-ink); }
.lang-grid .opt[aria-pressed="true"] {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 0 0 6px var(--gold-soft), var(--shadow);
}
.lang-grid .opt[aria-pressed="true"]::after {
  content: ""; position: absolute; top: 1.05rem; right: 1.05rem; width: 10px; height: 10px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft);
}
body[data-playing="true"] .lang-grid .opt[aria-pressed="true"]::after { background: var(--ember); animation: beat 1.6s var(--ease) infinite; }
.lang-grid .opt:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ---------- captions: the scroll ---------- */

.scroll {
  position: relative; display: grid; gap: var(--space-3);
  padding: var(--space-3); border-radius: var(--r-lg);
  background: var(--paper-raised); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.scroll-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }
.scroll-tools { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.caption-frame { position: relative; }
.caption-list {
  list-style: none; margin: 0; padding: 0.4rem 0.2rem 1.2rem; display: grid; gap: 1.25rem;
  max-height: min(62vh, 38rem); overflow-y: auto; overscroll-behavior: contain;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 2.6rem, #000 calc(100% - 1rem), transparent);
  mask-image: linear-gradient(to bottom, transparent 0, #000 2.6rem, #000 calc(100% - 1rem), transparent);
}
.caption {
  position: relative; padding-left: 1.05rem;
  animation: rise 520ms var(--ease) both;
}
.caption::before { content: ""; position: absolute; left: 0; top: 0.4em; bottom: 0.3em; width: 2px; border-radius: 2px; background: var(--line-strong); transition: background-color var(--slow); }
.caption .caption-translation { color: var(--ink-soft); transition: color var(--slow) var(--ease); }
.caption.current .caption-translation { color: var(--ink); }
.caption.current::before { background: var(--leaf); box-shadow: 0 0 12px rgb(226 189 114 / 0.6); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.caption-translation {
  font: 500 calc(1.28rem * var(--caption-scale))/1.75 var(--font-serif); letter-spacing: 0.03em;
}
.caption-source { margin-top: 0.3rem; font-size: calc(0.92rem * var(--caption-scale)); line-height: 1.65; color: var(--ink-soft); }
.caption-translation.pending {
  height: calc(1.28rem * var(--caption-scale) * 1.75); border-radius: 6px; color: transparent;
  background: linear-gradient(90deg, var(--gold-soft) 0%, color-mix(in srgb, var(--gold) 30%, transparent) 50%, var(--gold-soft) 100%);
  background-size: 200% 100%; animation: shimmer 1.6s linear infinite; max-width: 70%;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.captions[data-view="translation"] .caption-source { display: none; }
.captions[data-view="source"] .caption-translation { display: none; }
.captions[data-view="source"] .caption-source { font: 500 calc(1.22rem * var(--caption-scale))/1.75 var(--font-serif); color: var(--ink); margin: 0; }

/* A verse read from the 和合本: the illuminated block. */
.caption-verse { padding: 1.1rem 1.2rem 1.2rem 1.35rem; border-radius: var(--r-md); background: linear-gradient(160deg, var(--gold-soft), transparent 70%); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); }
.caption-verse::before { display: none; }
.verse-ref { display: flex; align-items: center; gap: 0.55rem; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.16em; color: var(--gold-ink); }
.verse-ref::before { content: ""; width: 9px; height: 9px; transform: rotate(45deg); background: var(--leaf); }
.verse-tag { margin-left: auto; padding: 0.1rem 0.5rem; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent); font-size: 0.7rem; letter-spacing: 0.1em; }
.verse-text { margin-top: 0.55rem; font: 500 calc(1.18rem * var(--caption-scale))/1.85 var(--font-serif); letter-spacing: 0.04em; }
.verse-text::first-letter { float: left; margin: 0.08em 0.12em 0 0; font-size: 2.6em; line-height: 0.9; font-weight: 700; color: var(--gold-ink); }

.caption-empty { padding: 2.2rem 1rem; text-align: center; color: var(--ink-faint); font: 500 1rem/1.7 var(--font-serif); }
.caption-latest {
  position: absolute; left: 50%; bottom: 0.6rem; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.5rem 1rem; border-radius: 999px; border: 0;
  background: var(--ink); color: var(--paper); font-size: 0.86rem; font-weight: 700; box-shadow: 0 10px 24px -10px rgb(0 0 0 / 0.6);
  animation: rise 320ms var(--ease) both;
}
.caption-latest svg { width: 16px; height: 16px; stroke-width: 2.2; }

/* ---------- notes ---------- */

.notes { display: grid; gap: var(--space-3); }
.tips { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.85rem; }
.tips li { display: grid; grid-template-columns: 2.1rem 1fr; gap: 0.75rem; align-items: start; color: var(--ink-soft); font-size: 0.92rem; line-height: 1.6; }
.tips svg { width: 2.1rem; height: 2.1rem; padding: 0.45rem; border-radius: 50%; background: var(--gold-soft); color: var(--gold-ink); }
.tips small { display: block; font: italic 500 0.92rem var(--font-display); color: var(--ink-faint); }
.compliance-note { padding: var(--space-3); border-radius: var(--r-md); border: 1px dashed var(--line-strong); color: var(--ink-soft); font-size: 0.85rem; }
.compliance-note strong { display: block; margin-bottom: 0.25rem; color: var(--ink); font-family: var(--font-serif); }

/* ---------- host: setup ---------- */

.host-hero { display: grid; gap: var(--space-3); padding-top: var(--space-2); }
.route-title { display: flex; flex-wrap: wrap; align-items: center; gap: clamp(0.6rem, 2vw, 1.6rem); }
.route-title b { display: block; font: 700 clamp(2.6rem, 1.6rem + 5vw, 5.2rem)/1 var(--font-serif); letter-spacing: 0.04em; }
.route-title small { display: block; margin-top: 0.4rem; font: italic 500 clamp(1rem, 0.9rem + 0.6vw, 1.35rem) var(--font-display); color: var(--ink-soft); }
.route-to b { background: var(--leaf); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 2px 10px rgb(168 122 44 / 0.25)); }
.route-arrow { color: var(--gold); width: clamp(3rem, 8vw, 5.5rem); }
.route-arrow svg { width: 100%; stroke-width: 1.4; }
.host-lede { max-width: 34em; font: 500 clamp(1rem, 0.95rem + 0.3vw, 1.15rem)/1.8 var(--font-serif); color: var(--ink-soft); }

.setup { display: grid; gap: var(--space-4); }
.setup-grid { display: grid; gap: var(--space-3); align-items: start; }
.setup-main { display: grid; gap: var(--space-3); }

.source-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.source {
  display: grid; gap: 0.1rem; justify-items: start; text-align: left; padding: 0.95rem; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--paper);
  transition: border-color var(--fast), box-shadow var(--fast), transform var(--fast) var(--ease);
}
.source:hover { border-color: var(--gold); }
.source:active { transform: scale(0.985); }
.source svg { width: 1.6rem; height: 1.6rem; margin-bottom: 0.35rem; color: var(--gold-ink); }
.source b { font: 700 1.08rem var(--font-serif); letter-spacing: 0.05em; }
.source small { font-size: 0.78rem; color: var(--ink-soft); }
.source .en { font: italic 500 0.92rem var(--font-display); color: var(--ink-faint); }
.source[aria-checked="true"] { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 0 5px var(--gold-soft); background: var(--paper-raised); }
.source:disabled { opacity: 0.5; cursor: not-allowed; }

.meter-row { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2); align-items: center; margin: var(--space-3) 0 var(--space-2); }
.meter-row .btn { width: auto; }
.meter { position: relative; height: 8px; border-radius: 999px; background: var(--paper-sunk); border: 1px solid var(--line); overflow: hidden; }
.meter-lg { height: 14px; }
.meter > span {
  position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0); border-radius: inherit;
  background: linear-gradient(90deg, var(--ok) 0%, var(--ok) 62%, var(--warn) 82%, var(--bad) 100%);
  transition: transform 90ms linear;
}
.meter .meter-server { background: var(--gold); opacity: 0.85; height: 3px; top: auto; bottom: 0; }
.meter .meter-queue { background: linear-gradient(90deg, var(--wait), var(--warn) 70%, var(--bad)); transition: transform 600ms var(--ease); }
.meter-ticks { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), var(--paper-raised) calc(10% - 1px) 10%); pointer-events: none; }

.qr-panel { display: grid; gap: var(--space-2); }
.qr-frame { display: grid; place-items: center; padding: 1rem; border-radius: var(--r-md); background: #fff; border: 1px solid var(--line); }
.qr-frame img { width: min(100%, 15rem); height: auto; image-rendering: pixelated; }
.share-link { font: 0.78rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-soft); word-break: break-all; text-align: center; }

/* ---------- host: live control room ---------- */

.live { display: grid; gap: var(--space-4); }
.control {
  position: relative; display: grid; gap: var(--space-4); padding: var(--space-4) var(--space-3);
  border-radius: calc(var(--r-lg) + 6px); color: #f2eadb;
  background: radial-gradient(120% 140% at 15% 0%, #1f2867 0%, #10153a 55%, #0a0d22 100%);
  box-shadow: 0 30px 60px -30px rgb(10 13 34 / 0.75); overflow: hidden;
  --ink-soft: #b2abc4; --line: rgb(242 234 219 / 0.12); --paper-sunk: rgb(255 255 255 / 0.06); --gold-ink: #e8c785;
}
[data-theme="night"] .control { box-shadow: 0 0 0 1px rgb(226 189 114 / 0.22), 0 30px 70px -30px rgb(0 0 0 / 0.9), 0 0 80px -20px rgb(98 112 220 / 0.35); }
.control::before { content: ""; position: absolute; inset: 8px; border-radius: var(--r-lg); border: 1px solid rgb(226 189 114 / 0.16); pointer-events: none; }
.health { display: grid; grid-template-columns: auto 1fr; gap: var(--space-4); align-items: center; }
.health-light { --c: var(--wait); position: relative; width: clamp(5.5rem, 16vw, 8rem); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; }
.health-light span { position: absolute; inset: 0; border-radius: 50%; }
.health-light span:first-child { background: radial-gradient(circle at 38% 32%, color-mix(in srgb, var(--c) 30%, #fff) 0%, var(--c) 45%, color-mix(in srgb, var(--c) 60%, #000) 100%); box-shadow: 0 0 0 6px color-mix(in srgb, var(--c) 18%, transparent), 0 0 60px 10px color-mix(in srgb, var(--c) 45%, transparent); transition: background var(--slow), box-shadow var(--slow); }
.health-light span:last-child { border: 2px solid var(--c); animation: ripple 2.6s cubic-bezier(0.2, 0.6, 0.3, 1) infinite; }
.health[data-health="ok"] .health-light { --c: #4fbf8b; }
.health[data-health="warn"] .health-light { --c: #e8a643; }
.health[data-health="bad"] .health-light { --c: #ee6a5a; }
.health[data-health="bad"] .health-light span:last-child { animation-duration: 1.1s; }
.health[data-health="ok"] .health-light span:last-child { animation-duration: 4s; }
.health-copy { display: grid; gap: 0.35rem; justify-items: start; }
.health-headline { font: 700 clamp(1.7rem, 1.2rem + 2.4vw, 2.7rem)/1.15 var(--font-serif); letter-spacing: 0.05em; }
.health-detail { font-size: 0.98rem; color: #cfc8de; max-width: 32em; }
.control .status { margin-top: 0.4rem; background: rgb(255 255 255 / 0.06); border-color: rgb(255 255 255 / 0.1); color: #cfc8de; }
.control .status.live { color: #ff8b7c; }
.control .status.live .dot { background: #ff8b7c; }

.gauges { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.gauge { display: grid; gap: 0.5rem; padding: 0.9rem; border-radius: var(--r-md); background: rgb(255 255 255 / 0.04); border: 1px solid rgb(255 255 255 / 0.08); }
.gauge-label { display: flex; justify-content: space-between; gap: 0.4rem; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.1em; color: #cfc8de; }
.gauge-label small { font: italic 500 0.88rem var(--font-display); color: #8f89a6; letter-spacing: 0.02em; }
.gauge-value { font: 600 1.05rem var(--font-serif); letter-spacing: 0.04em; }
.control .meter { background: rgb(255 255 255 / 0.08); border-color: rgb(255 255 255 / 0.1); height: 10px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 10px; }
.bars i { flex: 1; border-radius: 2px; background: rgb(255 255 255 / 0.14); transition: background-color var(--slow); }
.bars i:nth-child(1) { height: 40%; } .bars i:nth-child(2) { height: 70%; } .bars i:nth-child(3) { height: 100%; }
.bars[data-level="3"] i { background: #4fbf8b; }
.bars[data-level="2"] i:nth-child(-n + 2) { background: #e8a643; }
.bars[data-level="1"] i:nth-child(1) { background: #ee6a5a; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; border-top: 1px solid rgb(255 255 255 / 0.1); padding-top: var(--space-3); }
.stats div { display: grid; gap: 0.2rem; text-align: center; }
.stats div + div { border-left: 1px solid rgb(255 255 255 / 0.1); }
.stats dt { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.16em; color: #8f89a6; }
.stats dd { margin: 0; font: 600 clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem)/1.1 var(--font-display); font-variant-numeric: lining-nums tabular-nums; }

.live-grid { display: grid; gap: var(--space-3); align-items: start; }

.ended { display: grid; justify-items: center; gap: var(--space-3); text-align: center; padding: var(--space-5) 0; }
.ended .btn { max-width: 24rem; }

/* ---------- wide screens ---------- */

@media (min-width: 52rem) {
  .setup-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: var(--space-4); }
  .qr-panel { position: sticky; top: 6rem; }
  .live-grid { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
  .control { padding: var(--space-5) var(--space-5) var(--space-4); }
}
@media (max-width: 30rem) {
  .gauges { grid-template-columns: 1fr; gap: var(--space-2); }
  .gauge { grid-template-columns: 6.5rem 1fr auto; align-items: center; padding: 0.7rem 0.85rem; }
  .health { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .health-copy { justify-items: center; }
  .health-copy .eyebrow { justify-content: center; }
  .wordmark-text { font-size: 1.15rem; }
  .source-grid { grid-template-columns: 1fr; }
}
@media (max-width: 22rem) {
  .masthead { padding-inline: 0.5rem; }
  .masthead-tools { gap: 0.25rem; }
  .seg { padding: 2px; }
  .seg button { min-width: 2.75rem; padding: 0 0.4rem; }
  .nave, .nave > * { min-width: 0; max-width: 100%; }
  .wordmark-text { display: none; }
  .lang-grid { grid-template-columns: 1fr; }
}

@media (max-height: 720px) and (max-width: 40rem) {
  .listener-page { padding-top: var(--space-2); gap: var(--space-4); }
  .nave { gap: var(--space-1); padding-top: 0; }
  .nave-sub { font-size: 0.95rem; }
  .lumen { width: min(6.5rem, 40vw); margin: var(--space-1) 0 0; }
  .nave-state { min-height: 0; }
  .lang-grid .opt { min-height: 5.2rem; padding: 0.8rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
