/* =============================================================================
   1891 Teleprompter — /run/ prompter surface
   =============================================================================
   Full-bleed viewport. Owns the page — no site chrome.
   ============================================================================= */

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

/* ── Universal hidden-attribute respect ────────────────────────────────── */
/* The browser's UA stylesheet provides `[hidden] { display: none }` at
   attribute specificity (0,0,1,0). Anywhere this file sets an explicit
   `display:` on an ID selector (specificity 0,1,0,0) — like #gesture-menu,
   #ily-progress, #rest-progress, #mode-picker, #perm-help, #end-screen —
   the ID rule beats the UA's `[hidden]` rule and the element renders even
   while `hidden` is on. That's how the Phase 8 menu landed Anthony in the
   menu the moment he opened the page in a private window (2026-05-26).
   This rule wins everywhere with `!important` so any future toggleable
   surface "just works" with `el.hidden = true/false`. */
[hidden] { display: none !important; }

/* ── Brand accent ──────────────────────────────────────────────────────────
   Default accent is the workspace bloom; Studio org owners can override via
   `--brand-accent` set on :root by prompter.js (see _applyStudioBrand). The
   accent is decoration only — per workspace a11y rule, every state change
   carries shape + text in addition to color. */
:root {
  --brand-accent: var(--telep-bloom);
  --brand-accent-soft: rgba(216,58,111,0.18);
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--telep-font-body);
  background: #000;
  color: #fff;
}

body { line-height: 1.4; }

/* ── Theme variants ────────────────────────────────────────────────────── */
body[data-theme="light"]   { background: #f7f7f5; color: #111; }
body[data-theme="dark"]    { background: #000;    color: #fff; }
body[data-theme="hicon"]   { background: #000;    color: #ffe600; }
body[data-theme="sepia"]   { background: #f3e8d2; color: #2a1d0d; }

/* Mirror */
body[data-mirror="h"]  #prompter-track { transform: scaleX(-1); }
body[data-mirror="v"]  #prompter-track { transform: scaleY(-1); }
body[data-mirror="hv"] #prompter-track { transform: scale(-1, -1); }

/* ── Stage ─────────────────────────────────────────────────────────────── */
#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  cursor: none;
}
#stage.show-cursor,
#stage:focus-within { cursor: default; }

#prompter-viewport {
  height: 100%;
  width: 100%;
  overflow: hidden;
  position: relative;
  padding-inline: clamp(1.5rem, 6vw, 6rem);
}

#prompter-track {
  position: absolute;
  left: 0;
  right: 0;
  padding-inline: clamp(1.5rem, 6vw, 6rem);
  /* Top padding starts the script below the eyeline (third), then scrolls up. */
  padding-top: 33vh;
  padding-bottom: 100vh;
  font-family: var(--telep-font-body);
  font-size: 48px;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  letter-spacing: -0.005em;
  white-space: pre-wrap;
  transform-origin: center center;
  transition: transform 0s; /* no transition while scrolling */
  will-change: transform;
}

/* ── Hands-free menu (Phase 8) ─────────────────────────────────────────── */
/*
 * Appears over the prompter when the signer pauses via ILY-HOLD. The signer
 * is typically 6 feet from the camera, so everything here is big — large
 * text, generous spacing, high-contrast highlight. The numbered prefix on
 * each item teaches the gesture vocabulary visually (sign "3" to jump to
 * "Back 10 seconds"). The active row scales slightly for unmistakable
 * focus, and a colored accent bar runs down the left edge.
 */
#gesture-menu {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4vh 6vw;
  background: rgba(8, 10, 14, 0.84);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #f5f5f7;
  font-family: var(--telep-font-body);
}
body[data-theme="light"] #gesture-menu {
  background: rgba(248, 249, 252, 0.92);
  color: #1a1d22;
}
#gesture-menu h2 {
  font-size: clamp(28px, 4vw, 56px);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 max(2.5vh, 1.5rem) 0;
  text-align: center;
}
#gesture-menu-items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6em;
  width: min(720px, 92%);
}
#gesture-menu-items li {
  display: flex;
  align-items: center;
  gap: 0.9em;
  padding: 0.5em 0.9em;
  font-size: clamp(28px, 3.4vw, 44px);
  font-weight: 500;
  line-height: 1.15;
  border-radius: 14px;
  border: 2px solid transparent;
  background: rgba(255,255,255,0.04);
  transition: background 0.12s, transform 0.12s, border-color 0.12s;
}
body[data-theme="light"] #gesture-menu-items li {
  background: rgba(0,0,0,0.04);
}
#gesture-menu-items li .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6em;
  height: 1.6em;
  flex: 0 0 auto;
  border-radius: 50%;
  background: rgba(255,255,255,0.10);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
body[data-theme="light"] #gesture-menu-items li .num {
  background: rgba(0,0,0,0.08);
}
#gesture-menu-items li.active {
  background: var(--telep-bloom);
  border-color: var(--brand-accent);
  color: #fff;
  transform: scale(1.02);
}
#gesture-menu-items li.active .num {
  background: rgba(255,255,255,0.22);
  color: #fff;
}
#gesture-menu-items li.flash {
  animation: gesture-flash 0.5s ease-out;
}
@keyframes gesture-flash {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,0.85); }
  100% { box-shadow: 0 0 0 28px rgba(255,255,255,0); }
}
#gesture-menu .gesture-hint {
  margin: max(2.5vh, 1.5rem) 0 0 0;
  font-size: clamp(14px, 1.4vw, 18px);
  text-align: center;
  opacity: 0.7;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

/* Live diagnostic strip — see exactly what the recognizer is locking in
   menu mode. Helps debug "I signed 5 but nothing happened" — the user
   can see whether their gesture was classified as something else
   (e.g. "B" instead of "5") or didn't lock at all. */
#gesture-menu .gesture-diag {
  margin: 0.8rem 0 0 0;
  font-size: clamp(13px, 1.3vw, 17px);
  text-align: center;
  opacity: 0.55;
  letter-spacing: 0.02em;
  font-family: var(--telep-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
}
#gesture-menu .gesture-diag .diag-label { opacity: 0.6; margin-right: 0.4em; }
#gesture-menu .gesture-diag .diag-tokens {
  font-variant-numeric: tabular-nums;
}

/* Paragraphs as structural units — hands-down rest snaps between these. */
#prompter-track .para {
  margin: 0 0 0.9em 0;
}
#prompter-track .para:last-child {
  margin-bottom: 0;
}

/* Letter-spacing tighter for serif */
body[data-font="serif"] #prompter-track,
body[data-font="garamond"] #prompter-track {
  font-family: var(--telep-font-serif);
  letter-spacing: 0;
}
body[data-font="mono"] #prompter-track {
  font-family: var(--telep-font-mono);
  letter-spacing: 0;
}

/* Alignment */
body[data-align="center"] #prompter-track { text-align: center; }
body[data-align="right"]  #prompter-track { text-align: right; }

/* ── Eyeline marker (1/3 from top) ─────────────────────────────────────── */
#eyeline {
  position: fixed;
  left: 0; right: 0;
  top: 33vh;
  height: 0;
  /* Accent (Studio org brand or workspace default). The dash shape stays —
     color is never the SOLE signal for this marker; its position + dashed
     pattern remain the primary visual cue. */
  border-top: 2px dashed var(--brand-accent);
  opacity: 0.7;
  pointer-events: none;
  z-index: 5;
}
body[data-eyeline="off"] #eyeline { display: none; }

/* ── Controls bar ──────────────────────────────────────────────────────── */
#controls {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(20, 20, 24, 0.85);
  color: #fff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.6rem 0.7rem;
  border-radius: 14px;
  display: flex;
  gap: 0.35rem;
  align-items: center;
  font-family: var(--telep-font-body);
  font-size: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
  z-index: 20;
  max-width: calc(100vw - 2rem);
  flex-wrap: wrap;
  justify-content: center;
  transition: opacity .25s ease, transform .25s ease;
}
body[data-controls="hidden"] #controls {
  opacity: 0;
  transform: translate(-50%, 0.6rem);
  pointer-events: none;
}

#controls button {
  background: transparent;
  color: inherit;
  border: 1px solid rgba(255,255,255,0.18);
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 36px;
}
#controls button:hover { background: rgba(255,255,255,0.08); }
#controls button.primary {
  background: var(--telep-bloom);
  border-color: var(--telep-bloom);
}
/* Studio brand accent rides on the hover border so it's a tasteful visual
   nudge, not a wholesale replacement of the primary action color. Icon +
   text remain the load-bearing signals for play/pause. */
#controls button.primary:hover {
  background: var(--telep-bloom-deep);
  border-color: var(--brand-accent);
}
#controls .group { display: inline-flex; gap: 0.25rem; align-items: center; padding-inline: 0.25rem; }

/* Record button (Phase 7) — picks up a red leading dot only while inactive.
   When active (data-rec="on") it flips to a stop-square label + a pressed
   look. Icon + text always carry the signal — color is additive. */
#controls button.rec { color: #ff7a7a; }
#controls button.rec:hover { color: #ff5a5a; }
body[data-rec="on"] #controls button.rec {
  background: #c41e1e;
  color: #fff;
  border-color: #c41e1e;
}
#controls .divider { width: 1px; height: 22px; background: rgba(255,255,255,0.18); margin-inline: 0.25rem; }
#controls .readout {
  font-variant-numeric: tabular-nums;
  min-width: 3.5em;
  text-align: center;
  opacity: 0.85;
  padding-inline: 0.25rem;
}

/* ── Top utility row ───────────────────────────────────────────────────── */
#topbar {
  position: fixed;
  top: max(0.75rem, env(safe-area-inset-top));
  left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-inline: 1rem;
  transition: opacity .25s ease;
  font-size: 0.9rem;
}
/* The back link anchors left; the fullscreen button anchors right; the
   kind badge + Studio org brand mark sit between them. The auto-margin on
   the back link pushes everything else (kind badge, org mark, fullscreen)
   to the far right of the row. */
#topbar > a:first-child { margin-right: auto; }
body[data-controls="hidden"] #topbar { opacity: 0; pointer-events: none; }
#topbar a, #topbar button {
  color: inherit;
  background: rgba(20,20,24,0.7);
  border: 1px solid rgba(255,255,255,0.18);
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}
#topbar a:hover, #topbar button:hover { background: rgba(255,255,255,0.08); }

/* Script-kind badge (English / Gloss). Surfaces script.kind to the signer so
   they can spot it at a glance — same chrome as topbar buttons, slightly
   muted to read as a label, not an action. Per [feedback-surface-device-
   agnostic]: just the kind, no device language. */
.kind-badge {
  /* Background tint layers a workspace-neutral overlay over the Studio
     brand accent (or workspace default when no brand is set). Text + dot
     in the ::before pseudo-element remain the primary signal — color is
     additive only. */
  background-color: var(--brand-accent-soft);
  background-image: linear-gradient(rgba(20,20,24,0.55), rgba(20,20,24,0.55));
  border: 1px solid rgba(255,255,255,0.18);
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  user-select: none;
}

/* ── Studio org brand mark in the topbar ────────────────────────────────
   ~24px tall, top-right of the prompter header. Subtle "delivered for"
   note — the page is still 1891-branded. Lazy-loaded; graceful on error
   (prompter.js hides on `error` event). */
#org-brand-mark {
  height: 24px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
  opacity: 0.85;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  padding: 2px 4px;
}
#org-brand-mark[hidden] { display: none; }
body[data-theme="light"] #org-brand-mark,
body[data-theme="sepia"] #org-brand-mark {
  background: rgba(0,0,0,0.04);
}
.kind-badge[data-kind="gloss"]::before {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #6fb1ff;
}
.kind-badge[data-kind="english"]::before {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #b6b6c2;
}
body[data-theme="light"] .kind-badge,
body[data-theme="sepia"] .kind-badge {
  background: rgba(255,255,255,0.85);
  color: #111;
  border-color: rgba(0,0,0,0.15);
}

/* Light themes need different chrome contrast */
body[data-theme="light"] #controls,
body[data-theme="sepia"] #controls,
body[data-theme="light"] #topbar a,
body[data-theme="light"] #topbar button,
body[data-theme="sepia"] #topbar a,
body[data-theme="sepia"] #topbar button {
  background: rgba(255,255,255,0.92);
  color: #111;
  border-color: rgba(0,0,0,0.15);
}
body[data-theme="light"] #controls button,
body[data-theme="sepia"] #controls button {
  border-color: rgba(0,0,0,0.18);
}

/* ── Countdown ─────────────────────────────────────────────────────────── */
#countdown {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(7rem, 22vw, 16rem);
  font-weight: 800;
  font-family: var(--telep-font-display);
  letter-spacing: -0.04em;
  color: var(--telep-bloom);
  background: rgba(0,0,0,0.7);
  z-index: 30;
  pointer-events: none;
}
#countdown[hidden] { display: none; }

/* ── No-script state ──────────────────────────────────────────────────── */
#empty {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  z-index: 10;
}
#empty h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  letter-spacing: -0.02em;
}
#empty p { color: rgba(255,255,255,0.7); max-width: 32rem; }
body[data-theme="light"] #empty p,
body[data-theme="sepia"] #empty p { color: rgba(0,0,0,0.65); }
#empty .btn-row { margin-top: 1rem; display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; }
#empty a {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  border: 1px solid currentColor;
  color: inherit;
}
#empty a.primary {
  background: var(--telep-bloom);
  color: #fff;
  border-color: var(--telep-bloom);
}

/* Reduced motion: still scrolls (the product is a scroll loop) but skip
   chrome transitions. */
@media (prefers-reduced-motion: reduce) {
  #controls, #topbar { transition: none; }
}

/* ============================================================================
   Phase 3 — sign + voice mode UI
   ========================================================================== */

/* ── Self-preview camera backdrop (Phase 7) ────────────────────────────── */
/*
 * The signer's own camera view, full-stage behind the script. Eyeline stays
 * on the camera + the text simultaneously — same idea as a broadcast
 * teleprompter glass, but software-only. The recognizer continues to read
 * frames in sign mode; this is a visibility-only change.
 *
 * Defaults to off-screen (1×1 hidden pixel) so the existing recognizer
 * pipeline keeps working when preview is disabled. `data-preview="on"` on
 * <body> swaps the layout to full-stage with a darkening overlay so the
 * script stays readable over arbitrary lighting.
 *
 * Always horizontally mirrored (selfie convention — Zoom/FaceTime do the
 * same). The `data-mirror` body attribute applies to the SCRIPT, not the
 * camera, because mirror is for users with a real teleprompter glass rig
 * that flips text. The camera image doesn't go through the glass, so it
 * stays selfie-natural regardless.
 */
#cam-feed {
  position: fixed;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
  /* Selfie mirror — overridden in preview-on state. */
}

body[data-preview="on"] #cam-feed {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: var(--telep-preview-opacity, 0.45);
  z-index: 0;
  pointer-events: none;
  /* Default = selfie mirror (Zoom/FaceTime convention — looking at yourself
     naturally). Mirror button toggles this off in broadcast-glass rig mode,
     where a physical 45° glass already flips the camera image for the
     talent. Mirror "h" → text flipped, camera natural (glass undoes both).
     Mirror "none" → text upright, camera selfie-flipped (our default). */
  transform: scaleX(-1);
  background: #000;
}
body[data-preview="on"][data-mirror="h"] #cam-feed,
body[data-preview="on"][data-mirror="hv"] #cam-feed {
  /* When the script is horizontally flipped (broadcast rig), the camera
     should NOT also be flipped — the rig's glass takes care of that. */
  transform: none;
}
body[data-preview="on"][data-mirror="v"] #cam-feed {
  /* Vertical-only flip: keep the selfie horizontal flip + add vertical. */
  transform: scale(-1, -1);
}

/* Darkening overlay between the camera and the text — keeps script legible
   over varied lighting / backgrounds. Tuned per theme. Gated on
   `data-preview-active` (set by JS when a stream actually attaches) so the
   page doesn't dim when preview is "on" but no camera permission landed —
   that would just be a darkening for no reason. */
body[data-preview-active="on"] #prompter-viewport::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.42) 0%,
    rgba(0, 0, 0, 0.25) 28%,
    rgba(0, 0, 0, 0.42) 100%
  );
  z-index: 1;
  pointer-events: none;
}
body[data-theme="light"][data-preview-active="on"] #prompter-viewport::before {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.55) 0%,
    rgba(255, 255, 255, 0.38) 28%,
    rgba(255, 255, 255, 0.55) 100%
  );
}

/* Boost text legibility over moving video — small, additive shadow that
   doesn't change layout or font metrics. */
body[data-preview-active="on"] #prompter-track {
  position: relative;
  z-index: 2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65), 0 0 18px rgba(0, 0, 0, 0.35);
}
body[data-theme="light"][data-preview-active="on"] #prompter-track {
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.85), 0 0 18px rgba(255, 255, 255, 0.6);
}

/* ── Capture indicator (always icon + text + color) ──────────────────── */
#capture-indicator {
  position: fixed;
  top: max(0.75rem, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: #b22222;
  color: #fff;
  border-radius: 999px;
  padding: 0.35rem 0.7rem 0.35rem 0.85rem;
  font: 600 13px var(--telep-font-body);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
}
#capture-indicator .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.45);
  animation: cap-blink 1.4s ease-in-out infinite;
}
@keyframes cap-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}
#capture-indicator .label { white-space: nowrap; }
#capture-indicator .pause {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 999px;
  font: inherit;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  margin-left: 0.5rem;
  cursor: pointer;
}
#capture-indicator .pause:hover { background: rgba(255,255,255,0.32); }
#capture-indicator[data-kind="voice"] { background: #2a5d8f; }

/* RECORDING — stronger red + faster blink. Per SPEECH_PROCESSING.md every
   shared screen shows this. The dot animation runs a beat faster than the
   live-capture badge so the user can spot recording-on at a glance. */
#capture-indicator[data-rec="on"] {
  background: #c41e1e;
  box-shadow: 0 4px 14px rgba(196, 30, 30, 0.45), 0 0 0 3px rgba(196, 30, 30, 0.18);
}
#capture-indicator[data-rec="on"] .dot { animation-duration: 0.9s; }

/* ── ILY hold-progress ring (long-press semantics) ───────────────────── */
#ily-progress {
  position: fixed;
  bottom: 6.5rem;
  right: 1.25rem;
  z-index: 24;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  --progress: 0;
}
#ily-progress .ring {
  --size: 56px;
  width: var(--size); height: var(--size);
  border-radius: 50%;
  background:
    conic-gradient(var(--telep-bloom) calc(var(--progress) * 360deg),
                   rgba(255,255,255,0.18) 0deg);
  box-shadow: inset 0 0 0 4px #000;
  position: relative;
  transition: background .12s linear;
}
#ily-progress .ring::after {
  content: "ILY";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 12px var(--telep-font-body);
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.85);
}
#ily-progress .hint {
  font: 11px var(--telep-font-body);
  color: rgba(255,255,255,0.7);
  text-align: center;
}
body[data-theme="light"] #ily-progress .ring,
body[data-theme="sepia"] #ily-progress .ring { box-shadow: inset 0 0 0 4px #f7f7f5; }
body[data-theme="light"] #ily-progress .ring::after,
body[data-theme="sepia"] #ily-progress .ring::after { color: #333; }
body[data-theme="light"] #ily-progress .hint,
body[data-theme="sepia"] #ily-progress .hint { color: #555; }

/* ── Rest hold-progress ring ─────────────────────────────────────────────
   Fills while the signer pauses after a ≥10s signing streak. Mirrors the
   ILY ring on the opposite side (bottom-left) and uses an amber accent so
   the two are unambiguously distinct. */
#rest-progress {
  position: fixed;
  bottom: 9.5rem;
  left: 1.25rem;
  z-index: 24;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  --progress: 0;
}
#rest-progress .ring {
  --size: 56px;
  width: var(--size); height: var(--size);
  border-radius: 50%;
  background:
    conic-gradient(var(--telep-amber) calc(var(--progress) * 360deg),
                   rgba(255,255,255,0.18) 0deg);
  box-shadow: inset 0 0 0 4px #000;
  position: relative;
  transition: background .12s linear;
}
#rest-progress .ring::after {
  content: "REST";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 12px var(--telep-font-body);
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.85);
}
#rest-progress .hint {
  font: 11px var(--telep-font-body);
  color: rgba(255,255,255,0.7);
  text-align: center;
}
body[data-theme="light"] #rest-progress .ring,
body[data-theme="sepia"] #rest-progress .ring { box-shadow: inset 0 0 0 4px #f7f7f5; }
body[data-theme="light"] #rest-progress .ring::after,
body[data-theme="sepia"] #rest-progress .ring::after { color: #333; }
body[data-theme="light"] #rest-progress .hint,
body[data-theme="sepia"] #rest-progress .hint { color: #555; }

/* ── Handshape toast (Pattern C) ─────────────────────────────────────── */
#handshape-toast {
  position: fixed;
  bottom: 6.5rem;
  left: 1.25rem;
  z-index: 24;
  background: rgba(20,20,24,0.92);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  font: 13px var(--telep-font-body);
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
  max-width: 18rem;
}
body[data-theme="light"] #handshape-toast,
body[data-theme="sepia"] #handshape-toast {
  background: rgba(255,255,255,0.95);
  color: #111;
  border-color: rgba(0,0,0,0.15);
}

/* ── Mode picker / perm help / end screen — modal panels ─────────────── */
#mode-picker, #perm-help, #end-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#mode-picker[hidden], #perm-help[hidden], #end-screen[hidden] { display: none; }

#mode-picker h2, #perm-help h2, #end-screen h2 {
  color: #fff;
  font: 700 clamp(1.5rem, 4vw, 2.1rem) var(--telep-font-display, var(--telep-font-body));
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}
#mode-picker .sub, #perm-help p, #end-screen p {
  color: rgba(255,255,255,0.78);
  max-width: 32rem;
  margin: 0 auto 1.25rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

#mode-picker .cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.8rem;
  max-width: 44rem;
  width: 100%;
}
#mode-picker .mode-card {
  background: rgba(255,255,255,0.06);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 14px;
  padding: 1.1rem 1rem;
  font: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: background .15s ease, border-color .15s ease;
}
#mode-picker .mode-card:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.4);
}
#mode-picker .mode-card strong {
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
#mode-picker .mode-card span {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.75);
  line-height: 1.4;
}
#mode-picker .mode-card[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
#mode-picker .picker-foot {
  margin-top: 1rem;
  min-height: 1.2em;
}
#mode-picker .cap-warning {
  color: #ffb6b6;
  font-size: 0.85rem;
}

#perm-help .btn-row, #end-screen .btn-row {
  display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center;
  margin-top: 0.75rem;
}
#perm-help button, #end-screen button, #end-screen a {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 10px;
  padding: 0.6rem 1.1rem;
  font: 600 inherit;
  cursor: pointer;
  text-decoration: none;
}
#perm-help button.primary, #end-screen button.primary {
  background: var(--telep-bloom);
  border-color: var(--telep-bloom);
  color: #fff;
}
#perm-help button.primary:hover, #end-screen button.primary:hover {
  background: var(--telep-bloom-deep, var(--telep-bloom));
}
