@property --voice {
  syntax: '<number>';
  inherits: true;
  initial-value: 0;
}

@font-face {
  font-family: 'Avantt';
  src: url('fonts/AvanttVF-TRIAL.woff2') format('woff2-variations');
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

/* One token set, two themes: rose accent on near-black, flipped by data-theme on <html>. */
:root,
:root[data-theme='dark'] {
  color-scheme: dark;
  --stage: #030303;
  --glow-1: rgba(158, 40, 190, 0.38);
  --glow-2: rgba(190, 54, 157, 0.22);
  --panel: #0e0e0f;
  --card: #151516;
  --card-2: #222225;
  --accent-tab: rgba(250, 37, 196, 0.30);
  --field: #232326;
  --raised: #1e1e20;
  --hover: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.14);
  --ink: #ffffff;
  --ink-2: rgba(255, 255, 255, 0.64);
  --ink-3: rgba(255, 255, 255, 0.46);
  --accent: #be369d;
  --accent-ink: #ff6fdc;
  --accent-soft: rgba(190, 54, 157, 0.16);
  --accent-edge: rgba(190, 54, 157, 0.55);
  --accent-rgb: 190, 54, 157;
  --bubble: #6c1c59;
  --bubble-ink: #ffffff;
  --good: #2fd27a;
  --bad: #ff6b6b;
  --info: #a9b8e8;
  --tag-pink: #d7a6c4;
  --tag-sky: #9fcbe0;
  --invert-bg: #ffffff;
  --invert-ink: #17121a;
  --frame-ring: 255, 255, 255;
  --scrim: rgba(8, 8, 10, 0.78);
  --inner-light: inset -1px -1px 0.5px rgba(255, 255, 255, 0.08), inset 1px 1px 0.5px rgba(255, 255, 255, 0.08);
  --shadow-pop: 0 24px 64px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.5);
  --ui: 'Avantt', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --speech: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --radius-frame: 22px;
  --director-w: 340px;
}

:root[data-theme='light'] {
  color-scheme: light;
  --stage: #faf8fb;
  --glow-1: rgba(190, 54, 157, 0.12);
  --glow-2: rgba(140, 90, 230, 0.10);
  --panel: #ffffff;
  --card: #ffffff;
  --card-2: #faf8fb;
  --accent-tab: rgba(190, 54, 157, 0.14);
  --field: #f7f5f8;
  --raised: #f8f6f9;
  --hover: rgba(40, 10, 40, 0.035);
  --line: rgba(40, 10, 40, 0.065);
  --line-2: rgba(40, 10, 40, 0.12);
  --ink: #17121a;
  --ink-2: rgba(23, 18, 26, 0.64);
  --ink-3: rgba(23, 18, 26, 0.48);
  --accent: #be369d;
  --accent-ink: #a01f80;
  --accent-soft: rgba(190, 54, 157, 0.10);
  --accent-edge: rgba(190, 54, 157, 0.45);
  --bubble: #be369d;
  --good: #12904d;
  --bad: #d03a3a;
  --info: #4a62b8;
  --tag-pink: #a9548a;
  --tag-sky: #3a7ca8;
  --invert-bg: #17121a;
  --invert-ink: #ffffff;
  --frame-ring: 90, 30, 90;
  --scrim: rgba(250, 248, 251, 0.84);
  --inner-light: 0 1px 2px rgba(40, 10, 40, 0.05);
  --shadow-pop: 0 24px 64px rgba(60, 20, 60, 0.18), 0 2px 8px rgba(60, 20, 60, 0.08);
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background:
    radial-gradient(50% 45% at 10% 0%, var(--glow-1), transparent 70%),
    radial-gradient(45% 50% at 100% 100%, var(--glow-2), transparent 70%),
    var(--stage);
  background-attachment: fixed;
  color: var(--ink);
  font: 500 15px/1.5 var(--ui);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; letter-spacing: inherit; }
button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 3px; border-radius: 10px; }
[hidden] { display: none !important; }

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--director-w);
  min-height: 100vh;
  min-height: 100dvh;
}
.app[data-director="closed"][data-chat="closed"] { grid-template-columns: minmax(0, 1fr) 0; }
.app[data-director="closed"] .director { display: none; }
.app[data-chat="closed"] .chat { display: none; }

/* stage */

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 36px 18px;
  min-width: 0;
}

.bar {
  width: 100%;
  max-width: var(--frame-w);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.who { display: flex; align-items: center; gap: 14px; min-width: 0; }
h1 {
  margin: 0;
  font: 650 1.5rem/1 var(--ui);
  letter-spacing: -0.03em;
}
.bar-end { display: flex; align-items: center; gap: 10px; }
.pickers { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.picker { position: relative; display: flex; }
.picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line-2);
  color: var(--ink);
  height: 32px;
  box-sizing: border-box;
  padding: 0 12px 0 2px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--inner-light);
  transition: border-color 0.15s;
}
.picker-btn:hover { border-color: var(--accent-edge); }
.picker-btn:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 1px; }
.picker-btn:disabled { opacity: 0.5; cursor: default; }
.picker-btn .role { color: var(--ink-3); font-weight: 500; }
.picker-btn .role:empty { display: none; }
.picker-btn[data-active="false"] { padding-left: 14px; color: var(--ink-2); }
.who .pill { height: 32px; box-sizing: border-box; }
.picker-btn[data-active="false"] .face { display: none; }
.picker-btn .chev { color: var(--ink-3); margin-left: 2px; }
.face { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex: none; background: var(--raised); }
.picker-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  width: min(300px, calc(100vw - 32px));
  max-height: min(70vh, 540px);
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  box-shadow: var(--shadow-pop);
}
.picker-menu[hidden] { display: none; }
.picker-head {
  padding: 10px 10px 4px;
  color: var(--ink-3);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.picker-menu [role="option"] {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 6px 6px;
  border-radius: 12px;
  cursor: pointer;
  outline: none;
}
.picker-menu [role="option"]:hover, .picker-menu [role="option"]:focus { background: var(--hover); }
.picker-menu [role="option"]:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-ink); }
.picker-menu .face { width: 40px; height: 40px; border: 2px solid transparent; }
.picker-menu [aria-selected="true"] .face { border-color: var(--accent); }
.picker-menu [aria-selected="true"] .opt-name::after { content: " ✓"; color: var(--accent-ink); }
.opt-text { display: flex; flex-direction: column; min-width: 0; }
.opt-name { font-weight: 650; font-size: 0.92rem; }
.opt-role { color: var(--ink-3); font-size: 0.78rem; }
.face.plus { display: grid; place-items: center; font-size: 1.3rem; color: var(--accent-ink); border: 1px dashed var(--accent-edge); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.timer { color: var(--ink-2); font-variant-numeric: tabular-nums; font-size: 0.9rem; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--inner-light);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.pill[data-tone="connecting"] .dot,
.pill[data-tone="preparing"] .dot,
.pill[data-tone="reconnecting"] .dot { background: var(--accent-ink); animation: breathe 1.4s ease-in-out infinite; }
.pill[data-tone="listening"] { color: var(--ink); }
.pill[data-tone="listening"] .dot { background: var(--good); }
.pill[data-tone="speaking"] { color: var(--ink); border-color: var(--accent-edge); }
.pill[data-tone="speaking"] .dot { background: var(--accent-ink); box-shadow: 0 0 0 4px var(--accent-soft); }
.pill[data-tone="error"] { color: var(--ink); border-color: var(--bad); }
.pill[data-tone="error"] .dot { background: var(--bad); }

@keyframes breathe { 50% { opacity: 0.35; } }

.ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-2);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.ghost:hover { color: var(--ink); background: var(--hover); }
.ghost[aria-expanded="true"] { color: var(--ink); background: var(--card-2); border-color: var(--line); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), var(--inner-light); }
:root[data-theme='light'] .ghost[aria-expanded="true"] { box-shadow: 0 1px 3px rgba(60, 20, 60, 0.12), var(--inner-light); }

.theme { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; }
.theme svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.theme .t-moon { display: none; }
:root[data-theme='light'] .theme .t-moon { display: block; }
:root[data-theme='light'] .theme .t-sun { display: none; }

/* the video */

.stage { --frame-w: min(100%, calc((100vh - 290px) * 1.5), 1120px); }
@supports (height: 100dvh) {
  .stage { --frame-w: min(100%, calc((100dvh - 290px) * 1.5), 1120px); }
}

.screen { width: var(--frame-w); min-width: min(100%, 420px); }

.frame {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: var(--radius-frame);
  overflow: hidden;
  background: #0f0d11;
  isolation: isolate;
  box-shadow:
    0 0 0 1px rgba(var(--frame-ring), calc(0.08 + var(--voice) * 0.22)),
    0 28px 70px -30px rgba(0, 0, 0, 0.7),
    0 0 calc(30px + var(--voice) * 60px) calc(var(--voice) * 6px) rgba(var(--accent-rgb), calc(0.1 + var(--voice) * 0.32));
  transition: --voice 180ms linear;
}

.frame video,
.frame .poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.frame video { opacity: 0; transition: opacity 500ms ease; background: transparent; }
.frame.has-video video { opacity: 1; }
.frame .poster { transition: opacity 600ms ease, filter 600ms ease; }
.frame.has-video .poster { opacity: 0; }
.app[data-state="idle"] .poster,
.app[data-state="ended"] .poster { filter: saturate(0.85) brightness(0.62); }
.app[data-state="connecting"] .frame:not(.has-video) .poster { filter: saturate(0.8) brightness(0.55); animation: wait 2.2s ease-in-out infinite; }
@keyframes wait { 50% { filter: saturate(0.8) brightness(0.68); } }

/* overlays on the frame sit on the photo, so they stay dark in both themes */
.lobby {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 120px 24px 34px;
  background: linear-gradient(to top, rgba(10, 8, 12, 0.85), rgba(10, 8, 12, 0));
}
.app:not([data-state="idle"]):not([data-state="ended"]) .lobby { display: none; }
.hint { margin: 0; color: rgba(255, 255, 255, 0.8); font-size: 0.88rem; }
.access { display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(360px, 100%); }
.access label { font-size: 0.85rem; font-weight: 600; color: rgba(255, 255, 255, 0.88); }
.access-row { display: flex; gap: 8px; width: 100%; }
.access input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(16, 13, 18, 0.9);
  color: #fff;
  font: inherit;
}
.access input:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 1px; border-color: transparent; }
.access .primary { padding: 12px 22px; }
.access-error { margin: 0; color: #ff8b8b; font-size: 0.85rem; }

.primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 26px 13px 22px;
  border-radius: 999px;
  border: 0;
  color: #fff;
  background:
    radial-gradient(94.9% 60.48% at 9.82% 81.25%, rgba(253, 229, 213, 0.35), rgba(253, 229, 213, 0)),
    linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.25)),
    var(--accent);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: inset 0 1.45px 2.18px rgba(255, 150, 217, 0.5), inset 0 -1.45px 2.18px rgba(0, 0, 0, 0.15), 0 8px 24px rgba(190, 54, 157, 0.25);
  transition: transform 120ms ease, filter 120ms ease;
}
.primary svg { width: 18px; height: 18px; fill: currentColor; }
.primary:hover { filter: brightness(1.08); }
.primary:active { transform: scale(0.98); }

.veil {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.veil-title { margin: 0; font: 650 1.45rem/1.25 var(--ui); letter-spacing: -0.03em; }
.veil-text { margin: 0 0 14px; color: var(--ink-2); max-width: 46ch; }

.sound {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(10, 8, 12, 0.72);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

/* the caller's own camera, mirrored, in a corner of her frame */

.selfview {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: clamp(76px, 20%, 200px);
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: #0f0d11;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.7);
}
.selfview video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  opacity: 1;
}
.cam-on {
  position: absolute;
  top: 6px;
  left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  background: rgba(10, 8, 12, 0.72);
  color: #fff;
  font-size: 0.7rem;
  line-height: 1.4;
  white-space: nowrap;
}
.cam-on .dot { width: 6px; height: 6px; border-radius: 50%; background: #ff6b6b; flex: none; }

/* captions */

.captions {
  width: var(--frame-w);
  min-width: min(100%, 420px);
  height: 7.4rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  transition: opacity 900ms ease;
}
.captions.quiet .said { opacity: 0; }
.said { display: flex; flex-direction: column; align-items: center; gap: 4px; transition: opacity 900ms ease; }
.said p { margin: 0; max-width: 44ch; }
.said .older {
  font: 400 0.98rem/1.4 var(--speech);
  color: var(--ink-2);
  opacity: 0.55;
}
.said .older + .older { opacity: 0.8; }
.said .latest {
  font: 400 clamp(1.2rem, 1.1rem + 0.8vw, 1.7rem)/1.35 var(--speech);
  color: var(--ink);
  text-wrap: balance;
}
.you {
  margin: 0;
  min-height: 1.3em;
  font-size: 0.86rem;
  color: var(--ink-2);
  max-width: 60ch;
  transition: opacity 600ms ease;
}
.you b { font-weight: 650; color: var(--ink); margin-right: 6px; }
.you.talking b::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  vertical-align: middle;
  border-radius: 50%;
  background: var(--good);
}
.you.faded { opacity: 0; }

/* controls */

.controls { display: flex; align-items: center; justify-content: center; gap: 12px; }

.round,
.end {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 48px;
  padding: 0 20px 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--card-2);
  cursor: pointer;
  font-weight: 600;
  box-shadow: var(--inner-light);
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease, transform 120ms ease, filter 120ms ease;
}
.round svg, .end svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.round, .end { white-space: nowrap; }
.round:active:not(:disabled), .end:active:not(:disabled) { transform: scale(0.98); }
.round:hover:not(:disabled) { filter: brightness(1.12); }
.round .icon-off { display: none; }
.round[aria-pressed="true"] { background: var(--invert-bg); color: var(--invert-ink); border-color: var(--invert-bg); }
.round[aria-pressed="true"] .icon-on { display: none; }
.round[aria-pressed="true"] .icon-off { display: block; }
.round:disabled .level { display: none; }
.round .level {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 0 calc(var(--lvl, 0) * 4px) rgba(var(--accent-rgb), 0.35);
  transition: box-shadow 90ms linear;
}
.round[aria-pressed="true"] .level { display: none; }
.end {
  color: #fff;
  border: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.25)),
    #d64545;
  box-shadow: inset 0 1.45px 2.18px rgba(255, 170, 160, 0.4), inset 0 -1.45px 2.18px rgba(0, 0, 0, 0.15), 0 8px 24px rgba(214, 69, 69, 0.25);
}
.end:hover:not(:disabled) { filter: brightness(1.08); }
.round:disabled, .end:disabled { opacity: 0.45; cursor: default; }
.cam .cam-on-icon { display: none; }
.cam[aria-pressed="true"] .cam-on-icon { display: block; }
.cam[aria-pressed="true"] .cam-off { display: none; }

/* connection stats */

.stats { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 0.8rem; }
.stats summary { cursor: pointer; width: max-content; list-style: none; padding: 2px 0; font-weight: 600; }
.stats summary::-webkit-details-marker { display: none; }
.stats summary::before { content: '▸'; display: inline-block; margin-right: 6px; transition: transform 150ms ease; }
.stats[open] summary::before { transform: rotate(90deg); }
.stats-list { display: grid; grid-template-columns: 1fr; gap: 4px; margin: 10px 0 0; }
.stats-list div { display: flex; justify-content: space-between; gap: 12px; }
.stats-list dt { color: var(--ink-3); }
.stats-list dd { margin: 0; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* director */

.director,
.chat {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 22px;
  background: var(--panel);
  border-left: 1px solid var(--line);
}
.director-head h2 { margin: 0 0 4px; font: 650 1.2rem/1.2 var(--ui); letter-spacing: -0.02em; }
.chat-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0 2px;
  list-style: none;
}
.chat-log li {
  max-width: 94%;
  font: 400 0.95rem/1.45 var(--speech);
  color: var(--ink);
  background: var(--raised);
  border-radius: 16px;
  padding: 9px 13px;
  overflow-wrap: break-word;
  box-shadow: var(--inner-light);
}
.chat-log li.user {
  align-self: flex-end;
  background: radial-gradient(94.9% 60.48% at 9.82% 81.25%, rgba(253, 229, 213, 0.08), rgba(253, 229, 213, 0)), var(--bubble);
  color: var(--bubble-ink);
  border-bottom-right-radius: 6px;
}
.chat-log li.her { align-self: flex-start; border-top-left-radius: 6px; }
.chat-log li.pending { opacity: 0.75; }
.chat-log li.note { align-self: center; background: none; box-shadow: none; color: var(--ink-3); font: 600 0.78rem/1.4 var(--ui); padding: 2px; }
.chat-form { display: flex; gap: 8px; }
.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
}
.chat-form input::placeholder { color: var(--ink-3); }
.chat-form input:focus-visible { outline: none; border-color: var(--accent-edge); box-shadow: 0 0 0 4px var(--accent-soft); }
.chat-form .primary { padding: 9px 16px; font-size: 0.9rem; }
.director-head p { margin: 0; color: var(--ink-2); font-size: 0.86rem; font-weight: 400; }

.cues { display: flex; flex-direction: column; gap: 16px; }
.cue-group h3, .activity h3 { margin: 0 0 8px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--card);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--inner-light);
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.chip:hover:not(:disabled) { border-color: var(--accent-edge); background: var(--accent-soft); }
.chip:disabled { opacity: 0.4; cursor: default; }
.chip.sent { background: var(--accent-tab); border-color: var(--accent-edge); color: var(--ink); }
.chip.done { border-color: var(--accent-edge); color: var(--accent-ink); }

.free { display: flex; flex-direction: column; gap: 8px; margin-top: -4px; }
.free label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.free-row { display: flex; gap: 6px; }
.free input {
  flex: 1;
  min-width: 0;
  padding: 7px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
}
.free input::placeholder { color: var(--ink-3); }
.free input:focus-visible { outline: none; border-color: var(--accent-edge); box-shadow: 0 0 0 4px var(--accent-soft); }
.free input:disabled { opacity: 0.4; }
.free-go { flex: none; }

.activity { display: flex; flex-direction: column; flex: 1; min-height: 180px; overflow: hidden; }
.log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  font-size: 0.84rem;
}
.log li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.log li.fresh { animation: arrive 1.6s ease-out; }
@keyframes arrive { from { background: var(--accent-soft); } to { background: transparent; } }
.log time { color: var(--ink-3); font-variant-numeric: tabular-nums; font-size: 0.78rem; }
.log .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log .what i { font-style: normal; color: var(--ink-2); }
.log .src {
  font-size: 0.74rem;
  font-weight: 650;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--raised);
  color: var(--ink-2);
}
.log .src[data-src="manual"] { color: var(--accent-ink); }
.log .src[data-src="tool"] { color: var(--good); }
.log .src[data-src="director"] { color: var(--info); }
.log .src[data-src="tagger"] { color: var(--tag-pink); }
.log .src[data-src="vision"] { color: var(--tag-sky); }
.log .log-empty { display: block; color: var(--ink-3); border: 0; padding: 4px 0; }

/* toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(92vw, 520px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line-2);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-pop);
  z-index: 10;
}

/* upload a photo as a character */

.upload {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 22px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
}
.upload::backdrop { background: rgba(8, 4, 10, 0.6); backdrop-filter: blur(4px); }
.upload form { display: flex; flex-direction: column; gap: 12px; padding: 22px; }
.upload h2 { margin: 0; font: 650 1.3rem/1.2 var(--ui); letter-spacing: -0.02em; }
.upload-pick {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 2;
  border: 1px dashed var(--accent-edge);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  color: var(--ink-2);
  background: var(--field);
  font-weight: 600;
}
.upload-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-pick img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.upload-pick:focus-within { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.upload-hint { margin: -4px 0 0; color: var(--ink-2); font-size: 0.82rem; }
.upload-row { display: flex; gap: 8px; }
.upload-row input, .upload-row select {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
}
.upload-row input:focus-visible, .upload-row select:focus-visible { outline: none; border-color: var(--accent-edge); box-shadow: 0 0 0 4px var(--accent-soft); }
.upload-consent { display: flex; gap: 10px; align-items: flex-start; font-size: 0.85rem; color: var(--ink-2); cursor: pointer; }
.upload-consent input { margin-top: 3px; accent-color: var(--accent); }
.upload-status { margin: 0; font-size: 0.85rem; color: var(--accent-ink); font-weight: 600; }
.upload-progress { display: flex; flex-direction: column; gap: 6px; }
.upload-progress[hidden] { display: none; }
.upload-bar { height: 6px; border-radius: 999px; background: var(--raised); overflow: hidden; }
.upload-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #8f2a77, var(--accent), #ff6fdc); transition: width 0.5s linear; }
.upload-step { display: flex; justify-content: space-between; gap: 12px; margin: 0; font-size: 0.85rem; color: var(--ink-2); }
.upload-time { font-variant-numeric: tabular-nums; color: var(--ink-3); }
.upload form[data-busy="on"] .upload-pick { opacity: 0.6; pointer-events: none; }
.spinner { display: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
.upload form[data-busy="on"] #upload-go .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.upload-status[data-tone="error"] { color: var(--bad); }
.upload-actions { display: flex; justify-content: flex-end; gap: 10px; }
@media (max-width: 420px) { .upload-row { flex-direction: column; } }

/* full screen: the call fills the window, captions and controls float over the bottom of the video */

.round.full .full-off { display: none; }
.round.full[aria-pressed="true"] { background: var(--panel); color: var(--ink); border: 1px solid var(--line-2); box-shadow: var(--inner-light); }
.round.full[aria-pressed="true"] .full-on { display: none; }
.round.full[aria-pressed="true"] .full-off { display: block; }

.app[data-full="on"] { display: block; }
.app[data-full="on"] .director,
.app[data-full="on"] .bar { display: none; }
.app[data-full="on"] .stage { position: fixed; inset: 0; padding: 0; gap: 0; background: #000; z-index: 50; }
.app[data-full="on"] .screen { position: absolute; inset: 0; width: 100%; min-width: 0; }
.app[data-full="on"] .frame { height: 100%; aspect-ratio: auto; border-radius: 0; box-shadow: none; }
.app[data-full="on"] .captions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(86px + env(safe-area-inset-bottom));
  width: auto;
  min-width: 0;
  height: auto;
  max-height: 6.5rem;
  padding: 0 20px;
  z-index: 3;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.app[data-full="on"] .captions .said .latest,
.app[data-full="on"] .captions .said .older { color: #fff; }
.app[data-full="on"] .controls {
  position: absolute;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 4;
  padding: 8px;
  max-width: calc(100% - 24px);
  border-radius: 999px;
  background: rgba(10, 8, 12, 0.6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.app[data-full="on"] .round { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.2); color: #fff; }
.app[data-full="on"] .round[aria-pressed="true"] { background: #fff; color: #17121a; border-color: #fff; }
.app[data-full="on"] .round.full[aria-pressed="true"] { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.2); color: #fff; }
.app[data-full="on"] .screen::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 42%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0));
  pointer-events: none;
  z-index: 2;
}
.app[data-full="on"] .captions .you { color: rgba(255, 255, 255, 0.82); }
.app[data-full="on"] .captions .you b { color: #fff; }
.app[data-full="on"] .selfview { top: calc(14px + env(safe-area-inset-top)); bottom: auto; }
.app[data-full="on"] .lobby { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.app[data-full="on"] .sound { z-index: 5; }

/* narrower screens: the director moves under the call */

@media (max-width: 1100px) {
  .app,
  .app[data-director="closed"][data-chat="closed"] { grid-template-columns: minmax(0, 1fr); }
  .director,
  .chat {
    position: static;
    height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .chat-log { max-height: 50vh; }
  .stage { --frame-w: min(100%, 980px); }
  .activity { min-height: 0; }
  .log { max-height: 360px; }
}

@media (max-width: 640px) {
  :root { --radius-frame: 14px; }
  body { font-size: 14px; }
  .stage { padding: 14px 16px 16px; gap: 14px; }
  .screen, .captions { min-width: 0; width: 100%; }
  h1 { font-size: 1.35rem; }
  .timer { display: none; }
  .lobby { padding: 60px 16px 18px; }
  .primary { padding: 11px 22px 11px 18px; }
  .captions { height: 7rem; }
  .director { padding: 20px 16px 28px; }
  .round, .end { height: 46px; }
  .selfview { right: 10px; bottom: 10px; border-radius: 9px; }
  .cam-on { top: 4px; left: 4px; padding: 1px 6px 1px 5px; font-size: 0.62rem; }
  .bar { flex-wrap: wrap; row-gap: 10px; }
  .who { flex-wrap: wrap; row-gap: 8px; gap: 10px; }
  .app[data-full="on"] .controls { gap: 8px; padding: 6px; flex-wrap: nowrap; }
  .app[data-full="on"] .end span,
  .app[data-full="on"] .controls .label,
  .round.full .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .app[data-full="on"] .round, .app[data-full="on"] .end { width: 50px; height: 50px; padding: 0; justify-content: center; }
  .app[data-full="on"] .captions { bottom: calc(76px + env(safe-area-inset-bottom)); padding: 0 14px; }
  .round.full { padding: 0 14px; }
}

@media (max-height: 500px) {
  .app[data-full="on"] .controls { gap: 8px; padding: 6px; flex-wrap: nowrap; bottom: calc(10px + env(safe-area-inset-bottom)); }
  .app[data-full="on"] .controls .label,
  .app[data-full="on"] .end span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .app[data-full="on"] .round, .app[data-full="on"] .end { width: 46px; height: 46px; padding: 0; justify-content: center; }
  .app[data-full="on"] .captions { bottom: calc(66px + env(safe-area-inset-bottom)); max-height: 4.6rem; }
}

@media (max-width: 420px) {
  .controls { flex-wrap: wrap; gap: 10px; }
  .round.cam { padding: 0 14px; }
  .round.cam .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
