/* styles.css — studio surfaces in the "Ember Studio" design language.
   Semantic redesign tokens live in tokens.css (loaded before this file); the
   Gipity brand + Water base come from gipity-theme.css. Dark stage is committed.
   Every functional id / data-testid / body[data-screen] display selector is
   preserved — this is a restyle of containers + a re-composition of the control
   bar, not a rebuild. User text still enters via textContent elsewhere. */

/* ── Global stage ground ──────────────────────────────────────────────────── */
/* Water.css caps `body { max-width: 800px }`. Every app surface manages its own
   width (.studio-main, .landing, .tile-grid, .summary, the editor), so on desktop
   that cap squeezes the WHOLE studio into 800px — tiny lobby tiles + a cramped
   dock. Lift the cap; the component max-widths + margin:auto still center content. */
body { max-width: none; background: var(--stage-0); color: var(--ink); }
body.studio, body[data-screen="landing"] { background: var(--stage-0); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Shared button tiers ──────────────────────────────────────────────────── */
/* PRIMARY — ember gradient, one hero action per view. */
.primary-btn {
  background: var(--grad-ember);
  color: #fff;
  border: none;
  border-radius: var(--r-btn);
  box-shadow: var(--shadow-accent);
  font-weight: 700;
  transition: filter var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.primary-btn:hover { background: var(--grad-ember); filter: brightness(1.06); }
.primary-btn:active { transform: scale(.98); }
.primary-btn:focus-visible { outline: none; box-shadow: var(--focus-ring), var(--shadow-accent); }

/* SECONDARY — solid elevated fill. */
.secondary-btn { background: var(--stage-3); color: var(--ink); border: 1px solid var(--line); }
.secondary-btn:hover { background: var(--stage-4); }
.secondary-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* GHOST — transparent utility. */
button.ghost { background: transparent; color: var(--ink-dim); border: 1px solid var(--line); }
button.ghost:hover { background: var(--stage-2); color: var(--ink); }
button.ghost:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Shared disabled state — one app-wide rule so a busy/blocked CTA reads as
   inert (dimmed, no interactive shadow, not-allowed cursor) instead of looking
   clickable. Applies to both button tiers. */
.primary-btn:disabled, .secondary-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
}

/* Scoped inputs on the stage. */
.arm-fields select, .arm-fields input, #title-input, #join-input {
  background: var(--stage-2);
  border: 1px solid var(--line);
  border-radius: var(--r-input);
  color: var(--form-text);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; box-shadow: var(--focus-ring); border-color: var(--accent-line);
}

/* ── Landing ──────────────────────────────────────────────────────────────── */
.landing { max-width: 980px; margin-inline: auto; padding-top: var(--s-8); }

/* Loading placeholder — shown while requireUser() resolves so the landing isn't
   blank during the initial auth check. */
.landing-loading {
  display: flex; align-items: center; justify-content: center; gap: var(--s-3);
  color: var(--ink-dim); font-size: var(--text-sm); padding: var(--s-6) 0;
}
.landing-spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  animation: landing-spin .7s linear infinite;
}
@keyframes landing-spin { to { transform: rotate(360deg); } }

.landing-nav { position: absolute; top: var(--s-4); right: var(--s-4); margin: 0; z-index: 5; }
.nav-editor-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
  min-height: 44px; /* phone-friendly touch target */
  color: var(--ink-dim); background: var(--stage-2); border: 1px solid var(--line);
  border-radius: var(--r-chip); padding: 8px 16px; font-weight: 600; font-size: var(--text-sm);
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.nav-editor-btn:hover { color: var(--ink); border-color: var(--accent-line); }

.hero { text-align: center; margin-bottom: var(--s-7); }
.kicker {
  display: inline-block; font-size: var(--text-xs); font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: var(--r-chip); padding: 3px 12px; margin-bottom: var(--s-4);
}
.wordmark {
  background: var(--grad-ember);
  -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
  margin: 0 0 var(--s-3);
}
.tagline {
  color: var(--ink-dim); font-size: var(--text-lg);
  max-width: 54ch; margin: 0 auto;
}

#landing-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--s-4);
}
.card {
  position: relative;
  background: var(--stage-2);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: var(--s-5);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--grad-ember); }
.card-glyph {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--stage-3); color: var(--accent); border: 1px solid var(--line);
  margin-bottom: var(--s-2);
}
.card h2 { margin-top: 0; }
.card-sub { color: var(--ink-dim); font-size: var(--text-sm); margin-top: 0; }
.card form { display: flex; flex-direction: column; gap: var(--s-2); }
.card input { width: 100%; }
.card button { align-self: flex-start; }

.landing-error, .studio-error {
  margin-top: var(--s-4);
  color: var(--ink);
  background: var(--stage-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-card);
  padding: var(--s-3) var(--s-4);
}
.studio-error { margin: var(--s-5); }

/* ── Auth gate ────────────────────────────────────────────────────────────── */
#auth-gate { margin: var(--s-5) auto; max-width: 420px; }
.auth-card {
  position: relative;
  background: var(--stage-2);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: var(--s-5);
  max-width: 420px;
  margin-inline: auto;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.auth-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--grad-ember); }
.auth-card h2 { margin-top: 0; }
.auth-blurb { color: var(--ink-dim); font-size: var(--text-sm); }
.auth-error { color: var(--danger); font-size: var(--text-sm); }

/* ── Studio header ────────────────────────────────────────────────────────── */
.studio-header {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-4);
  background: var(--stage-1);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.s-title { font-weight: 600; color: var(--ink); font-size: var(--text-lg); }
.header-spacer { flex: 1 1 auto; }
.rec-timer {
  font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink);
  background: var(--stage-2); border: 1px solid var(--rec-ring);
  padding: var(--s-1) var(--s-3); border-radius: var(--r-chip); font-size: var(--text-sm);
  display: inline-flex; align-items: center; gap: 6px;
}
.rec-timer::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--rec); box-shadow: 0 0 0 3px var(--rec-ring);
  animation: chip-pulse 1s ease-in-out infinite;
}
.conn-badge {
  font-size: var(--text-xs); padding: var(--s-1) var(--s-3); border-radius: var(--r-chip);
  border: 1px solid var(--line); color: var(--ink-dim); background: var(--stage-2);
}
.conn-connected { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.conn-reconnecting { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 55%, transparent); }
/* A dropped connection is a PROBLEM — flag it in caution amber so it's visually
   distinct from the harmless "Local only" offline state (which stays faint). */
.conn-lost {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 55%, transparent);
  background: color-mix(in srgb, var(--warn) 12%, var(--stage-2));
}
.conn-offline { color: var(--ink-faint); }
.folder-badge {
  font-size: var(--text-xs); color: var(--ink-dim);
  background: var(--stage-2); border: 1px solid var(--line);
  border-radius: var(--r-chip); padding: var(--s-1) var(--s-3);
  max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Screens + layout shell ───────────────────────────────────────────────── */
.screen { display: none; }
body[data-screen="arm"] #arm-screen { display: block; }
body[data-screen="lobby"] #stage,
body[data-screen="recording"] #stage {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-4); min-height: calc(100vh - 160px); padding-bottom: 120px;
}
body[data-screen="summary"] #summary-screen { display: block; }
.studio-main { padding: var(--s-5); max-width: 1200px; margin: 0 auto; background: var(--stage-0); }
.studio-columns { display: flex; gap: var(--s-5); align-items: flex-start; }
.studio-screens { flex: 1 1 auto; min-width: 0; }

/* ── Arm screen — Riverside "green room" split ────────────────────────────── */
.arm { max-width: 960px; margin-inline: auto; }
.arm-lobby {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  gap: var(--s-5); align-items: start;
}
/* Live camera preview: <video> fills the frame; the empty/placeholder state sits
   on top and is hidden once a stream is attached (.is-live on the container). */
.arm-preview {
  position: relative; aspect-ratio: 16 / 9; background: #000;
  border: 1px solid var(--line); border-radius: var(--r-tile);
  box-shadow: var(--shadow-tile); overflow: hidden;
}
.arm-preview-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000;
  transform: scaleX(-1);            /* mirror the self-view, like a real green room */
  display: none;
}
.arm-preview.is-live .arm-preview-video { display: block; }
.arm-preview.is-live .arm-preview-empty { display: none; }
.arm-preview-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-3); color: var(--ink-faint); text-align: center; padding: var(--s-4);
}
.arm-preview-cap { font-size: var(--text-sm); max-width: 26ch; }
.arm-panel { display: flex; flex-direction: column; gap: var(--s-3); }
.arm-panel h2 { margin: 0; }
.hint { color: var(--ink-dim); font-size: var(--text-sm); }
.headphones-hint {
  background: var(--accent-soft);
  border: none; border-left: 3px solid var(--accent-line);
  border-radius: var(--r-sm); padding: var(--s-3); margin: 0;
}
.arm-fields {
  display: grid; grid-template-columns: max-content 1fr;
  gap: var(--s-2) var(--s-4); align-items: center; margin: 0;
}
.arm-fields label, .arm-meter-label { color: var(--ink-dim); font-size: var(--text-sm); }
.arm-fields select, .arm-fields input { width: 100%; margin: 0; }
.arm-fields input { padding: var(--s-2) var(--s-3); }
/* Display-name is OPTIONAL — de-emphasize by ordering its label + input LAST in
   the arm fields (below recording quality). Both share order:1 so they stay a
   paired row; every other field keeps the default order:0 in source order. */
.arm-fields label[for="session-name"], .arm-fields #session-name { order: 1; }

/* Live mic level meter (green-room). Ember accent fill + a peak-hold marker. */
.mic-meter {
  position: relative; height: 10px; width: 100%;
  background: color-mix(in srgb, #fff 6%, transparent);
  border: 1px solid var(--line); border-radius: var(--r-chip); overflow: hidden;
}
.mic-meter-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: var(--grad-ember); border-radius: var(--r-chip);
  transition: width 80ms linear;
}
.mic-meter-peak {
  position: absolute; top: 0; bottom: 0; left: 0; width: 2px;
  background: var(--ink); opacity: .8; transition: left 120ms linear;
}
.arm-meter-label { align-self: center; }

.arm-disk {
  margin: 0; font-size: var(--text-xs); color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.arm-save {
  border-top: 1px solid var(--line); padding-top: var(--s-3);
  display: flex; flex-direction: column; gap: var(--s-2);
}
.arm-save-head { color: var(--ink); font-weight: 600; font-size: var(--text-sm); margin: 0; }
.save-file-lbl { color: var(--ink-faint); font-size: var(--text-xs); margin: 0; }
#folder-label-lbl { color: var(--ink-dim); font-size: var(--text-sm); margin: 0; }
.save-row { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.save-loc-label { color: var(--ink-faint); font-size: var(--text-sm); }
.arm-enter { width: 100%; font-size: var(--text-lg); margin-top: var(--s-2); }
/* Green-room split balances side-by-side at ≥900px; stacks below. */
@media (max-width: 900px) {
  .arm-lobby { grid-template-columns: 1fr; }
  .arm-preview { max-width: 640px; margin-inline: auto; width: 100%; }
}
@media (max-width: 560px) {
  .arm-fields { grid-template-columns: 1fr; }
  .arm-fields label, .arm-meter-label { margin-bottom: calc(var(--s-1) * -1); }
}

/* ── REC liveness pill (top-center of the stage, recording only) ──────────── */
.rec-live {
  display: none; align-items: center; gap: var(--s-2);
  background: var(--stage-2); border: 1px solid var(--line);
  border-radius: var(--r-chip); padding: 6px 14px; box-shadow: var(--shadow-card);
}
body[data-screen="recording"] .rec-live { display: inline-flex; }
.rec-live-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--rec);
  box-shadow: 0 0 0 4px var(--rec-ring); animation: chip-pulse 1s ease-in-out infinite;
}
.rec-live-label { font-weight: 800; letter-spacing: .06em; color: var(--rec); font-size: var(--text-xs); }
.rec-live-time { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 700; font-size: var(--text-sm); }

/* ── Tile grid — the stage floor ──────────────────────────────────────────── */
.tile-grid {
  display: grid; gap: var(--s-4);
  grid-template-columns: 1fr; width: 100%;
  max-width: 1100px; margin-inline: auto; justify-content: center;
}
.tile-grid[data-count="1"] { max-width: 720px; }
.tile-grid[data-count="2"] { grid-template-columns: repeat(2, 1fr); max-width: 1000px; }
.tile-grid[data-count="3"] { grid-template-columns: repeat(3, 1fr); }
.tile-grid[data-count="4"] { grid-template-columns: repeat(2, 1fr); max-width: 900px; }
/* 5 → three across the top, two centered below (6-col base, each tile spans 2). */
.tile-grid[data-count="5"] { grid-template-columns: repeat(6, 1fr); }
.tile-grid[data-count="5"] > * { grid-column: span 2; }
.tile-grid[data-count="5"] > *:nth-child(4) { grid-column: 2 / span 2; }
.tile-grid[data-count="5"] > *:nth-child(5) { grid-column: 4 / span 2; }
@media (max-width: 760px) {
  .tile-grid[data-count] { grid-template-columns: 1fr; }
  .tile-grid[data-count="5"] > * { grid-column: auto; }
}

.tile {
  position: relative; aspect-ratio: 16 / 9;
  background: var(--stage-2); border: 1px solid var(--line);
  border-radius: var(--r-tile); overflow: hidden; box-shadow: var(--shadow-tile);
  transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.tile-self:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
.tile video {
  width: 100%; height: 100%; object-fit: cover;
  background: #000; display: block; /* letterbox, not a themed surface */
}
.tile-recording {
  border-color: var(--rec);
  box-shadow: inset 0 0 0 2px var(--rec), 0 0 0 3px var(--rec-ring), var(--shadow-tile);
}

/* Name chip bottom-left (low glass pill); badges bottom-right. */
.tile-overlay {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s-2); padding: var(--s-2); background: none; pointer-events: none;
}
.tile-name {
  color: #fff; font-size: var(--text-sm); font-weight: 600;
  background: rgba(0, 0, 0, .5); backdrop-filter: blur(6px);
  border-radius: var(--r-chip); padding: 3px 10px; max-width: 68%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile-chip {
  font-size: var(--text-xs); font-weight: 700; padding: 2px 8px;
  border-radius: var(--r-chip); white-space: nowrap;
  background: var(--stage-3); color: var(--ink-dim); border: 1px solid var(--line);
}
/* Semantic rec-state chips — shared by tiles and the participants panel. Defined
   AFTER the base .tile-chip/.pp-chip so they win on equal specificity. */
.chip-idle { background: var(--stage-3); color: var(--ink-dim); border: 1px solid var(--line); }
.chip-countdown { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); animation: chip-pulse 1s ease-in-out infinite; }
.chip-recording { background: var(--rec); color: #fff; border: 1px solid var(--rec); }
.chip-stopped { background: var(--stage-3); color: var(--ink-faint); border: 1px solid var(--line); }
@keyframes chip-pulse { 50% { opacity: 0.45; } }

.tile-meter { position: absolute; left: 0; right: 0; top: 0; height: 4px; background: transparent; }
.tile-meter-fill { display: block; height: 100%; width: 0; background: var(--primary); transition: width 0.08s linear; }

.tile-conn {
  position: absolute; top: var(--s-2); right: var(--s-2);
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--ink-faint); box-shadow: 0 0 0 2px var(--stage-2);
}
.tile-conn.peer-connected { background: var(--ok); }
.tile-conn.peer-connecting { background: var(--primary); animation: chip-pulse 1s ease-in-out infinite; }
.tile-conn.peer-failed { background: var(--rec); }
.tile-conn.peer-closed { background: var(--ink-faint); }

.tile-badges { display: inline-flex; align-items: center; gap: var(--s-1); }
.tile-muted {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  color: #fff; background: var(--accent); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.tile-muted svg { display: block; }

.tile-xfer {
  font-size: var(--text-xs); font-weight: 700; padding: 2px 8px;
  border-radius: var(--r-chip); white-space: nowrap;
  color: var(--ink); background: var(--stage-2); border: 1px solid var(--accent-line);
}
.tile-xfer.xfer-ok { border-color: var(--line); color: var(--ok); }

.tile-camoff {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--stage-2);
}
.tile-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22%; min-width: 44px; max-width: 96px; aspect-ratio: 1;
  border-radius: 50%; background: var(--grad-ember); color: #fff;
  font-weight: 700; font-size: var(--text-xl); text-transform: uppercase;
}

/* Per-peer LOCAL volume control (remote tiles only). */
.tile-vol {
  position: absolute; top: var(--s-2); left: var(--s-2);
  display: flex; align-items: center; gap: var(--s-1);
  padding: var(--s-1) var(--s-2); border-radius: var(--r-chip);
  background: rgba(0, 0, 0, 0.45); opacity: 0; transition: opacity 0.15s ease;
}
.tile:hover .tile-vol, .tile:focus-within .tile-vol { opacity: 1; }
/* Touch devices have no hover — the per-peer volume/mute control would be
   invisible and untappable. Keep it always visible there so it works on phones. */
@media (hover: none) {
  .tile-vol { opacity: 1; }
}
.vol-mute {
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
  width: 22px; height: 22px; background: transparent; border: none; color: #fff; cursor: pointer;
}
.vol-mute:hover { color: var(--accent); background: transparent; }
.vol-mute.is-muted { color: var(--accent); }
.vol-mute svg { display: block; }
.vol-slider { width: 80px; margin: 0; accent-color: var(--accent); }

/* ── Floating control bar ─────────────────────────────────────────────────── */
.controls {
  position: fixed; left: 50%; transform: translateX(-50%);
  /* Lift clear of the home indicator / notch on phones so the bar isn't cut off. */
  bottom: max(var(--s-5), env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: var(--s-3);
  background: var(--stage-1); border: 1px solid var(--line-strong);
  border-radius: var(--r-control); padding: var(--s-2) var(--s-3);
  padding-bottom: max(var(--s-2), env(safe-area-inset-bottom));
  box-shadow: var(--shadow-bar); backdrop-filter: blur(8px); z-index: 40;
}

/* Circular icon buttons. */
.io-btn {
  display: none; align-items: center; justify-content: center;
  width: 48px; height: 48px; padding: 0; border-radius: 50%;
  background: var(--stage-2); color: var(--ink-dim); border: 1px solid var(--line);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
body[data-screen="lobby"] .io-btn,
body[data-screen="recording"] .io-btn { display: inline-flex; }
.io-btn:hover { background: var(--stage-3); color: var(--ink); }
.io-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.io-btn .io-icon { display: inline-flex; align-items: center; }
.io-btn .io-off { display: none; }
.io-btn .io-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.io-btn.is-off { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.io-btn.is-off:hover { background: var(--accent-soft); }
.io-btn.is-off .io-on { display: none; }
.io-btn.is-off .io-off { display: inline-flex; }

/* Record — the hero, resting slightly larger than its siblings. */
.record-btn, .stop-btn, .guest-wait { display: none; }
body.is-host[data-screen="lobby"] .record-btn { display: inline-flex; }
body:not(.is-host)[data-screen="lobby"] .guest-wait { display: inline-flex; }
body[data-screen="recording"] .stop-btn { display: inline-flex; }
.record-btn {
  align-items: center; gap: var(--s-2);
  height: 52px; padding: 0 var(--s-5); border: none; border-radius: var(--r-btn);
  background: var(--grad-ember); color: #fff; font-size: var(--text-base); font-weight: 700;
  box-shadow: var(--shadow-accent); transform: scale(1.02);
  transition: filter var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.record-btn:hover { background: var(--grad-ember); filter: brightness(1.06); transform: scale(1.02) translateY(-1px); }
.record-btn:active { transform: scale(.99); }
.record-btn:focus-visible { outline: none; box-shadow: var(--focus-ring), var(--shadow-accent); }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; display: inline-block; }
.stop-btn {
  align-items: center; gap: var(--s-2);
  height: 52px; padding: 0 var(--s-5); border: none; border-radius: var(--r-btn);
  background: var(--rec); color: #fff; font-size: var(--text-base); font-weight: 700;
  box-shadow: 0 6px 22px color-mix(in srgb, var(--rec) 40%, transparent);
}
.stop-btn::before { content: ""; width: 12px; height: 12px; border-radius: 3px; background: #fff; display: inline-block; }
.stop-btn:hover { background: var(--rec); filter: brightness(1.06); }
.stop-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.guest-wait {
  align-items: center; color: var(--ink-dim); font-size: var(--text-sm);
  background: var(--stage-2); border: 1px solid var(--line);
  border-radius: var(--r-chip); padding: 8px 16px; margin: 0;
}

/* ── Self-guest + dev test-sink banners ───────────────────────────────────── */
.self-guest-banner {
  margin: var(--s-2) auto 0; max-width: 42rem; padding: var(--s-2) var(--s-4);
  text-align: center; font-size: var(--text-sm); color: var(--ink);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: var(--r-card);
}
.dev-testsink-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding: 4px 10px; text-align: center; font-size: var(--text-sm); font-weight: 700;
  color: #fff; background: var(--accent);
}

/* ── Countdown overlay ────────────────────────────────────────────────────── */
.countdown-overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 10, 12, .72); backdrop-filter: blur(8px); z-index: 50;
}
.countdown-num {
  display: flex; align-items: center; justify-content: center;
  width: 15rem; height: 15rem; border-radius: 50%;
  border: 2px solid var(--accent-line);
  font-size: 8rem; font-weight: 800; line-height: 1; color: var(--ink);
  text-shadow: 0 0 24px color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 60px color-mix(in srgb, var(--accent) 38%, transparent);
  animation: cd-tick 1s var(--ease-out) infinite;
}
@keyframes cd-tick { 0% { transform: scale(1.12); opacity: .5; } 30% { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .countdown-num { animation: none; } }

/* ── Summary — "recording complete" card ──────────────────────────────────── */
.summary { max-width: 640px; margin-inline: auto; }
#summary-title { display: flex; align-items: center; gap: var(--s-3); }
#summary-title::before {
  content: "✓"; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--grad-ember); color: #fff; font-size: var(--text-lg); font-weight: 800;
  box-shadow: var(--shadow-accent);
}
.summary-stats {
  display: grid; grid-template-columns: max-content 1fr; align-items: center;
  gap: 0 var(--s-5);
  background: var(--stage-2); border: 1px solid var(--line);
  border-radius: var(--r-card); padding: var(--s-2) var(--s-5); box-shadow: var(--shadow-card);
}
.summary-stats dt, .summary-stats dd { margin: 0; padding: var(--s-3) 0; border-bottom: 1px solid var(--line); }
.summary-stats dt { color: var(--ink-dim); font-size: var(--text-sm); }
.summary-stats dd { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.summary-stats dt:nth-last-of-type(1), .summary-stats dd:nth-last-of-type(1) { border-bottom: none; }
.stat-status {
  display: inline-block; font-size: var(--text-xs); font-weight: 700;
  padding: 2px 10px; border-radius: var(--r-chip);
  background: var(--stage-3); color: var(--ink-dim); border: 1px solid var(--line);
}
.stat-status.is-verified { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.stat-status.is-uploading { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.stat-status.is-failed { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.summary-warn { color: var(--accent); font-size: var(--text-sm); }

.summary-primary { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; margin: var(--s-5) 0 var(--s-3); }
.summary-editor-primary { text-decoration: none; font-size: var(--text-lg); font-weight: 700; padding: var(--s-4) var(--s-8); }
.summary-newtake { text-decoration: none; }
/* "What you get" — discoverability line under Open-in-editor: names the render
   outputs so the export flow is visible without opening the session folder. */
.summary-whatyouget {
  flex: 1 1 100%; margin: 0; color: var(--ink-dim); font-size: var(--text-sm); line-height: 1.5;
}
.summary-whatyouget strong { color: var(--ink); font-weight: 600; }
.summary-save-note { color: var(--ink-dim); font-size: var(--text-sm); margin: var(--s-2) 0; }
.summary-download { margin-bottom: var(--s-2); }
.summary-actions {
  display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap;
  margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--line);
}
.summary-home { display: inline-block; color: var(--ink-dim); }

/* Multi-take list — compact sub-card. */
.takes-list-wrap {
  max-width: 640px; margin-bottom: var(--s-5);
  background: var(--stage-2); border: 1px solid var(--line);
  border-radius: var(--r-card); padding: var(--s-3) var(--s-4);
}
.takes-list-title { color: var(--ink-dim); font-size: var(--text-sm); font-weight: 600; margin: 0 0 var(--s-2); }
.takes-list { list-style: none; margin: 0; padding: 0; }
.takes-list li { padding: var(--s-2); border-radius: var(--r-sm); color: var(--ink-dim); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.takes-list li.is-current { background: var(--stage-3); color: var(--ink); font-weight: 600; }
.takes-current-tag { color: var(--ink-faint); font-weight: 400; }

/* ── Transfer status (summary) — sub-cards ────────────────────────────────── */
.summary-transfer { max-width: 640px; margin-top: var(--s-5); }
.xfer-status {
  background: var(--stage-2); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: var(--r-card);
  padding: var(--s-4) var(--s-5);
}
.xfer-status p { margin: 0 0 var(--s-2); color: var(--ink); }
.xfer-status p:last-child { margin-bottom: 0; }
.xfer-head { color: var(--ink-dim); font-size: var(--text-sm); font-weight: 600; }
.xfer-done { color: var(--ok); font-weight: 600; }
.xfer-list { margin: 0; padding-left: var(--s-5); color: var(--ink); }
.xfer-list li { margin: var(--s-1) 0; font-variant-numeric: tabular-nums; }

/* ── Participants panel ───────────────────────────────────────────────────── */
.participants-panel { display: none; }
body[data-screen="lobby"] .participants-panel,
body[data-screen="recording"] .participants-panel,
body[data-screen="summary"] .participants-panel { display: block; }
.participants-panel.pp {
  flex: 0 0 300px; position: sticky; top: var(--s-5);
  background: var(--stage-1); border: 1px solid var(--line);
  border-radius: var(--r-card); box-shadow: var(--shadow-card); overflow: hidden;
}
.pp-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  padding: var(--s-2) var(--s-4); background: var(--stage-2); border-bottom: 1px solid var(--line);
}
.pp-heading { display: inline-flex; align-items: center; gap: var(--s-2); }
.pp-title { font-weight: 600; color: var(--ink); font-size: var(--text-sm); }
.pp-count {
  font-size: var(--text-xs); font-weight: 700; color: var(--ink-dim);
  background: var(--stage-3); border: 1px solid var(--line);
  border-radius: var(--r-chip); padding: 1px 8px; font-variant-numeric: tabular-nums;
}
.pp-toggle { padding: 0 var(--s-2); line-height: 1.6; font-size: var(--text-sm); }
.pp-body { padding: 0 var(--s-4) var(--s-2); }
.pp-collapsed .pp-body { display: none; }

.pp-nag {
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: var(--r-sm); padding: var(--s-3); margin-top: var(--s-3);
}
.pp-nag-text { margin: 0 0 var(--s-2); font-size: var(--text-sm); color: var(--ink); }
.pp-nag-btn { font-size: var(--text-sm); }

.pp-row { display: flex; gap: var(--s-2); padding: var(--s-3) 0; border-bottom: 1px solid var(--line); }
.pp-row:last-child { border-bottom: none; }
.pp-main { flex: 1 1 auto; min-width: 0; }

.pp-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-faint); flex: 0 0 auto; margin-top: 5px; }
.pp-dot.peer-connected { background: var(--ok); }
.pp-dot.peer-connecting { background: var(--primary); animation: chip-pulse 1s ease-in-out infinite; }
.pp-dot.peer-failed { background: var(--rec); }
.pp-dot.peer-closed { background: var(--ink-faint); }

.pp-l1 { display: flex; align-items: center; gap: var(--s-1); }
.pp-name { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pp-chip {
  font-size: var(--text-xs); font-weight: 700; padding: 1px 8px; border-radius: var(--r-chip);
  white-space: nowrap; background: var(--stage-3); color: var(--ink-dim); border: 1px solid var(--line);
}
.pp-role.is-host { background: var(--grad-ember); color: #fff; border: none; }

.pp-l2 { display: flex; align-items: center; gap: var(--s-2); margin-top: 3px; }
.pp-io { display: inline-flex; align-items: center; justify-content: center; color: var(--ink-dim); }
.pp-io.is-off { color: var(--accent); }
.pp-io svg { display: block; }
.pp-save { font-size: var(--text-xs); color: var(--ink-dim); margin-left: auto; }
.pp-save.is-ok { color: var(--ok); font-weight: 600; }

.pp-xfer { margin-top: var(--s-1); }
.pp-bar { height: 6px; border-radius: var(--r-chip); background: color-mix(in srgb, #fff 6%, transparent); overflow: hidden; }
.pp-bar-fill { display: block; height: 100%; width: 0; background: var(--grad-ember); transition: width 0.2s ease; }
.pp-bar.is-done .pp-bar-fill { background: var(--ok); }
.pp-bar.is-stalled .pp-bar-fill { background: var(--ink-faint); }
.pp-xlabel { display: block; font-size: var(--text-xs); color: var(--ink-dim); margin-top: 2px; font-variant-numeric: tabular-nums; }
.pp-xlabel.is-done { color: var(--ok); font-weight: 600; }
.pp-xlabel.is-warn { color: var(--accent); }

@media (max-width: 900px) {
  .studio-columns { flex-direction: column; }
  .participants-panel.pp { position: static; flex-basis: auto; width: 100%; }
}

/* ── Toasts ───────────────────────────────────────────────────────────────── */
.toasts {
  position: fixed; bottom: var(--s-5); right: var(--s-5);
  display: flex; flex-direction: column; gap: var(--s-2);
  z-index: 100; max-width: min(90vw, 360px);
}
.toast {
  background: var(--stage-2); border: 1px solid var(--line);
  border-left: 3px solid var(--primary); border-radius: var(--r-card);
  padding: var(--s-3) var(--s-4); color: var(--ink); font-size: var(--text-sm);
  box-shadow: var(--shadow-pop); opacity: 0; transform: translateY(8px);
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
}
.toast-show { opacity: 1; transform: translateY(0); }
.toast-success { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }

/* Build stamp (auto-bumped by tools/bump-build.mjs on each deploy) */
.build-stamp {
  position: fixed; right: 10px; bottom: 8px; font-size: 12px; opacity: 0.95;
  color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  pointer-events: none; user-select: none; z-index: 50;
}
