/* ==========================================================================
   Loops call UI: the lobby, the call and the thank-you screen. Tokens and
   fonts come from the design system (/loops/tokens.css, copied from
   packages/design by `pnpm sync:lobby`): paper canvas, ink, 1px hairlines,
   square corners (4px at most, on tags and icon tiles), no shadows, gradients
   or blur. Geist 400/500, Geist Mono 400. Light first; dark is the same tokens.
   ========================================================================== */

:root {
  /* Secondary text on an ink fill (the caption's speaker label): between the two, in either theme. */
  --lobby-on-ink-2: color-mix(in srgb, var(--loops-on-ink) 68%, var(--loops-ink));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--loops-canvas); }
body {
  font-family: var(--loops-font-sans); font-size: 14px; line-height: 1.5; letter-spacing: -0.14px;
  color: var(--loops-ink); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
h1, h2, h3 { font-weight: 400; margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
:focus-visible { outline: 2px solid var(--loops-accent); outline-offset: 3px; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--loops-ink); text-decoration: none; }
a.brand { min-height: var(--loops-btn-h-md); }
.brand .mark { width: 26px; height: 26px; flex: none; }
.brand .dot, .dot { fill: var(--loops-accent); }
.brand .wordmark { font-weight: 500; font-size: 17px; letter-spacing: -0.027em; line-height: 1; }
.brand-sm { gap: 7px; }
.brand-sm .mark { width: 20px; height: 20px; }
.brand-sm .wordmark { font-size: 15px; }

/* ---------- Shared pieces ---------- */
.nav {
  height: var(--loops-nav-h); flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--loops-gutter); border-bottom: 1px solid var(--loops-rule); background: var(--loops-canvas);
}
.nav-note { font-family: var(--loops-font-mono); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--loops-ink-3); }
.tag {
  display: inline-flex; align-self: flex-start; border: 1px solid var(--loops-rule-2); border-radius: var(--loops-r-tag);
  padding: var(--loops-space-8) var(--loops-space-12); font-family: var(--loops-font-mono); font-size: 10px; line-height: 1.2;
  letter-spacing: 2px; text-transform: uppercase; color: var(--loops-ink-2);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--loops-space-8);
  min-height: var(--loops-btn-h-md); padding: 0 var(--loops-space-24); border: 1px solid transparent; border-radius: 0;
  font-size: 14px; line-height: 1.25; letter-spacing: -0.14px; cursor: pointer; text-decoration: none;
  transition: background-color var(--loops-dur-fast), border-color var(--loops-dur-fast), color var(--loops-dur-fast);
}
.btn-lg { min-height: var(--loops-btn-h-lg); padding: 0 var(--loops-space-32); font-size: 15px; }
.btn-ink { background: var(--loops-ink); color: var(--loops-on-ink); font-weight: 500; }
.btn-ink:hover { background: var(--loops-ink-hover); }
.btn-ink:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: var(--loops-rule-2); color: var(--loops-ink-2); font-weight: 400; }
.btn-ghost:hover { border-color: var(--loops-ink-3); color: var(--loops-ink); }
.card-bar {
  display: flex; justify-content: space-between; align-items: center; gap: var(--loops-space-12);
  min-height: 40px; padding: 0 var(--loops-space-20); border-bottom: 1px solid var(--loops-rule); background: var(--loops-inset);
  font-family: var(--loops-font-mono); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--loops-ink-3);
}
.live-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--loops-accent); flex: none;
  animation: breathe var(--loops-dur-breathe) ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: .35; } }

/* Avatars: a marker larger than 8px takes the 4px icon radius, never a circle. */
.avatar {
  width: 88px; height: 88px; border-radius: var(--loops-r-icon); display: grid; place-items: center; position: relative;
  font-weight: 500; font-size: 32px; letter-spacing: -0.64px; background: var(--loops-ink); color: var(--loops-on-ink);
}

/* ---------- Lobby ---------- */
.lobby { min-height: 100%; display: flex; flex-direction: column; background: var(--loops-canvas); }
.lobby-grid { flex: 1; display: grid; grid-template-columns: 42fr 58fr; min-height: 0; }
.lobby-copy {
  display: flex; flex-direction: column; justify-content: center; gap: var(--loops-space-20);
  padding: var(--loops-hero-y) var(--loops-gutter); border-right: 1px solid var(--loops-rule);
}
.lobby-copy h1 { font-size: 42px; line-height: 1; letter-spacing: -1.13px; color: var(--loops-ink); max-width: 14ch; }
.lobby-copy .sub { font-size: 16px; line-height: 1.33; letter-spacing: -0.18px; color: var(--loops-ink-2); max-width: 54ch; }
.presence { display: inline-flex; align-items: center; align-self: flex-start; gap: var(--loops-space-10); font-size: 14px; color: var(--loops-ink-2); margin-top: var(--loops-space-4); }
.presence #agent { color: var(--loops-ink); font-weight: 500; }
.presence .avatar { width: 28px; height: 28px; font-size: 13px; letter-spacing: 0; }
.perks {
  list-style: none; margin: var(--loops-space-12) 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, auto);
  justify-content: start; border-top: 1px solid var(--loops-rule); padding-top: var(--loops-space-16);
}
.perks li { display: flex; align-items: center; gap: var(--loops-space-8); font-size: 12px; letter-spacing: 0.12px; color: var(--loops-ink-2); padding: 0 var(--loops-space-16); border-left: 1px solid var(--loops-rule); }
.perks li:first-child { padding-left: 0; border-left: 0; }
.perks svg { width: 16px; height: 16px; color: var(--loops-ink-3); flex: none; }

/* The Accent Panel: the one tinted field in the lobby, holding the join form. */
.lobby-panel, .stage {
  background-color: var(--loops-accent-wash);
  background-image: radial-gradient(var(--loops-accent-edge) 0.6px, transparent 0.8px);
  background-size: 4px 4px;
}
.lobby-panel { display: grid; place-items: center; padding: var(--loops-hero-y) var(--loops-gutter); }
.lobby-card { width: min(440px, 100%); background: var(--loops-surface); border: 1px solid var(--loops-ink-2); }
.card-body { padding: var(--loops-space-24); display: flex; flex-direction: column; }
.lobby-card label { font-size: 14px; font-weight: 500; color: var(--loops-ink); margin: 0 0 var(--loops-space-8); }
.lobby-card input ~ label { margin-top: var(--loops-space-20); }
.lobby-card input, .lobby-card select {
  width: 100%; min-height: var(--loops-btn-h-md); padding: 0 var(--loops-space-12); border: 1px solid var(--loops-rule-2); border-radius: 0;
  background: var(--loops-surface); color: var(--loops-ink); outline: none; font-size: 14px;
  transition: border-color var(--loops-dur-fast);
}
.lobby-card select { appearance: none; -webkit-appearance: none; padding-right: var(--loops-space-40); cursor: pointer; }
.select { position: relative; display: block; }
.select::after {
  content: ""; position: absolute; right: 18px; top: 50%; width: 6px; height: 6px; pointer-events: none;
  border-right: 1px solid var(--loops-ink-3); border-bottom: 1px solid var(--loops-ink-3); transform: translateY(-70%) rotate(45deg);
}
.lobby-card input::placeholder { color: var(--loops-ink-3); }
.lobby-card input:hover, .lobby-card select:hover { border-color: var(--loops-ink-3); }
.lobby-card input:focus-visible, .lobby-card select:focus-visible { border-color: var(--loops-ink); outline: 2px solid var(--loops-accent); outline-offset: 2px; }
.lobby-card .btn { width: 100%; margin-top: var(--loops-space-24); }
.card-title { font-size: 20px; line-height: 1.2; letter-spacing: -0.22px; font-weight: 500; color: var(--loops-ink); }
.card-text { margin-top: var(--loops-space-8); font-size: 14px; line-height: 1.5; letter-spacing: -0.14px; color: var(--loops-ink-2); }
.fine { font-size: 12px; line-height: 1.4; letter-spacing: 0.12px; color: var(--loops-ink-3); margin-top: var(--loops-space-16); }
.fine a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.turnstile { margin-top: var(--loops-space-16); min-height: 65px; }
.join-error { margin-top: var(--loops-space-12); font-size: 13px; color: var(--loops-ink); }

/* ---------- Call ---------- */
.call { height: 100%; display: grid; grid-template-rows: minmax(0, 1fr) auto; background: var(--loops-canvas); }
/* Screen on the left; on the right a column with the people on top and the chat under them
   (chat closed: just the people, as a narrow strip). Nothing ever covers the shared screen. */
.call-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: 0; position: relative; }
.side { display: flex; flex-direction: column; min-height: 0; background: var(--loops-canvas); border-left: 1px solid var(--loops-rule); }
.call.chat-open .side { width: 360px; }
/* The stage is the call's Accent Panel; the screen sits on it in a square 1px frame. */
.stage { position: relative; padding: var(--loops-space-24); min-width: 0; min-height: 0; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.screen {
  position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); min-height: 0; min-width: 0;
  background: var(--loops-surface); border: 1px solid var(--loops-ink-2); overflow: hidden;
}
.screen-bar {
  display: flex; align-items: center; gap: var(--loops-space-12); min-height: 40px; padding: 0 var(--loops-space-16);
  border-bottom: 1px solid var(--loops-rule); background: var(--loops-inset);
  font-family: var(--loops-font-mono); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--loops-ink-3);
}
.screen-label { display: flex; align-items: center; gap: var(--loops-space-8); min-width: 0; color: var(--loops-ink-2); white-space: nowrap; }
.screen-label span { overflow: hidden; text-overflow: ellipsis; }
.screen-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--loops-accent); animation: breathe var(--loops-dur-breathe) ease-in-out infinite; }
.screen-label:not([hidden]) ~ .screen-idle { display: none; }
.status-chip {
  margin-left: auto; min-width: 0; max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border: 1px solid var(--loops-rule-2); border-radius: var(--loops-r-tag); padding: var(--loops-space-4) var(--loops-space-8);
  letter-spacing: 0.14em; color: var(--loops-ink-2); background: var(--loops-surface);
  opacity: 0; transition: opacity var(--loops-dur-base) var(--loops-ease-standard);
}
.status-chip.on { opacity: 1; }
.screen-view { position: relative; min-height: 0; display: grid; place-items: center; background: var(--loops-surface); }
.screen-pan { position: absolute; inset: 0; display: grid; place-items: center; }
.screen img { width: 100%; height: 100%; object-fit: contain; display: block; min-height: 0; }
/* The demo in this page fills the screen 1:1 and lays itself out for that space (its desktop
   layout on a laptop, its phone layout on a phone): nothing is shrunk. */
.demo-fit { position: absolute; inset: 0; overflow: hidden; }
.demo-fit[hidden] { display: none; }
.demo-fit iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--loops-surface); }
.demo-shield { position: absolute; inset: 0; }
.screen.control .demo-shield { display: none; }
/* Zoom (phones, upright): the screen at full height, slid sideways with a finger. */
.screen-zoom {
  display: none; place-items: center; flex: none; width: var(--loops-btn-h-md); height: var(--loops-btn-h-md); margin: 0;
  background: none; border: 0; border-left: 1px solid var(--loops-rule); border-radius: 0; color: var(--loops-ink-2); cursor: pointer;
}
.screen-zoom svg { width: 18px; height: 18px; }
.screen-zoom .i-out, .call.zoom .screen-zoom .i-in { display: none; }
.call.zoom .screen-zoom .i-out { display: block; }
.screen.control { border-color: var(--loops-accent); outline: 1px solid var(--loops-accent); cursor: crosshair; }
.connecting { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: var(--loops-space-16); text-align: center; color: var(--loops-ink-2); font-size: 14px; padding: var(--loops-space-24); }
.connecting .avatar { width: 72px; height: 72px; font-size: 28px; }
.connecting .avatar::after {
  content: ""; position: absolute; inset: -7px; border: 1px solid var(--loops-accent); border-radius: 6px;
  animation: ring 1.6s var(--loops-ease-standard) infinite;
}

/* Tiles */
.tiles { display: flex; flex-direction: column; gap: var(--loops-space-12); padding: var(--loops-space-24) var(--loops-space-16); position: relative; }
.call.chat-open .tiles { padding: var(--loops-space-16); flex-direction: row; border-bottom: 1px solid var(--loops-rule); }
.call.chat-open .tiles .tile { flex: 1; width: auto; height: 100px; }
/* Chat open with a video face: her video fills the column, the prospect is a picture-in-picture. */
.call.chat-open .tiles .tile.video { height: auto; aspect-ratio: 16 / 9; }
.call.chat-open .tiles:has(.tile.video) .tile.you { position: absolute; right: var(--loops-space-24); bottom: var(--loops-space-24); width: 104px; height: 59px; flex: none; z-index: 2; border-color: var(--loops-ink-2); }
.call.chat-open .tiles:has(.tile.video) .tile.you .name { display: none; }
.call.chat-open .tiles:has(.tile.video) .tile.you .avatar { width: 28px; height: 28px; font-size: 13px; }
.call.chat-open .tiles:has(.tile.video) .tile-mic { right: 4px; bottom: 4px; width: 20px; height: 20px; }
.tile {
  width: 168px; height: 100px; background: var(--loops-inset); border: 1px solid var(--loops-rule);
  display: grid; place-items: center; position: relative;
  transition: border-color var(--loops-dur-fast);
}
.tile .avatar { width: 44px; height: 44px; font-size: 18px; letter-spacing: -0.22px; }
.tile.you .avatar { background: var(--loops-surface); color: var(--loops-ink); border: 1px solid var(--loops-rule-2); }
.tile .name {
  position: absolute; left: var(--loops-space-8); bottom: var(--loops-space-8); max-width: calc(100% - 48px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--loops-font-mono); font-size: 10px; line-height: 1.2; letter-spacing: 1px; text-transform: uppercase;
  color: var(--loops-ink-2); background: var(--loops-surface); border: 1px solid var(--loops-rule); border-radius: var(--loops-r-tag); padding: var(--loops-space-2) var(--loops-space-6);
}
.tile.speaking { border-color: var(--loops-accent); }
.tile.speaking .avatar::after {
  content: ""; position: absolute; inset: -6px; border: 1px solid var(--loops-accent); border-radius: 6px;
  animation: ring 1.2s var(--loops-ease-standard) infinite;
}
.tile.thinking .avatar::after {
  content: ""; position: absolute; inset: -5px; border: 1px dashed var(--loops-ink-3); border-radius: 6px;
  animation: breathe 1.2s ease-in-out infinite;
}
/* Mic state on the tile: off = ink square with a slashed mic; on = neutral; live = accent. */
.tile-mic {
  position: absolute; right: var(--loops-space-8); bottom: var(--loops-space-8); width: 22px; height: 22px; border-radius: var(--loops-r-icon);
  display: grid; place-items: center; background: var(--loops-surface); color: var(--loops-ink-2); border: 1px solid var(--loops-rule);
}
.tile-mic svg { width: 13px; height: 13px; }
.tile-mic.off { background: var(--loops-ink); color: var(--loops-on-ink); border-color: var(--loops-ink); }
.tile-mic.live { color: var(--loops-accent); border-color: var(--loops-accent); }
.i-off { display: none; }
.off .i-on { display: none; }
.off .i-off { display: block; }
@keyframes ring { from { transform: scale(0.96); opacity: 1; } to { transform: scale(1.18); opacity: 0; } }

/* The prospect's live level: an accent outline that opens with their voice. No shadow. */
.tile.you { --lvl: 0; }
.tile.you.talking { border-color: var(--loops-accent); outline: 1px solid var(--loops-accent-edge); outline-offset: calc(var(--lvl) * 8px); }

/* Captions and "we heard you", over the bottom of the shared screen */
.caption-stack {
  position: absolute; left: 50%; bottom: var(--loops-space-24); transform: translateX(-50%); width: min(820px, calc(100% - 48px));
  display: flex; flex-direction: column; align-items: center; gap: var(--loops-space-8); pointer-events: none;
}
.heard {
  display: flex; align-items: center; gap: var(--loops-space-10); max-width: 100%; padding: var(--loops-space-8) var(--loops-space-12);
  background: var(--loops-surface); border: 1px solid var(--loops-rule-2); font-size: 14px; color: var(--loops-ink);
  opacity: 0; transform: translateY(6px); transition: opacity var(--loops-dur-base) var(--loops-ease-standard), transform var(--loops-dur-base) var(--loops-ease-standard);
}
.heard.on { opacity: 1; transform: none; }
.heard.done { opacity: 0.6; }
.heard-icon { flex: none; display: grid; place-items: center; width: 14px; font-size: 12px; color: var(--loops-ink-3); }
.heard.listening .heard-icon::before, .heard.hearing .heard-icon::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--loops-accent); animation: breathe 1s ease-in-out infinite;
}
.heard-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; }
.heard-text bdi { direction: ltr; }
.heard-state { color: var(--loops-ink-3); font-size: 12px; letter-spacing: 0.12px; white-space: nowrap; flex: none; }
.heard-text { min-width: 0; }
.heard.thinking .heard-state::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.captions {
  width: 100%; background: var(--loops-ink); color: var(--loops-on-ink); padding: var(--loops-space-12) var(--loops-space-16);
  font-size: 16px; line-height: 1.45; letter-spacing: -0.18px; text-align: center; text-wrap: balance;
  opacity: 0; transition: opacity var(--loops-dur-base) var(--loops-ease-standard);
}
.captions.on { opacity: 1; }
.captions b {
  font-family: var(--loops-font-mono); font-weight: 400; font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--lobby-on-ink-2); margin-right: var(--loops-space-10); vertical-align: 2px;
}

/* Chat */
.chat { display: none; flex-direction: column; min-width: 0; min-height: 0; flex: 1; overflow: hidden; background: var(--loops-surface); }
.call.chat-open .chat { display: flex; }
.chat header {
  display: flex; justify-content: space-between; align-items: center; min-height: 44px; padding: 0 var(--loops-space-8) 0 var(--loops-space-16);
  border-bottom: 1px solid var(--loops-rule); background: var(--loops-inset);
  font-family: var(--loops-font-mono); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--loops-ink-3);
}
.chat header button {
  width: var(--loops-btn-h-sm); height: var(--loops-btn-h-sm); display: grid; place-items: center; background: none;
  border: 1px solid transparent; border-radius: 0; color: var(--loops-ink-3); cursor: pointer;
  transition: border-color var(--loops-dur-fast), color var(--loops-dur-fast);
}
.chat header button:hover { border-color: var(--loops-rule-2); color: var(--loops-ink); }
.chat header button svg { width: 16px; height: 16px; }
.log { flex: 1; overflow-y: auto; padding: var(--loops-space-16); display: flex; flex-direction: column; gap: var(--loops-space-12); }
/* Each message reads like a transcript turn: a mono speaker label column, then the words. */
.msg { display: grid; grid-template-columns: 6ch minmax(0, 1fr); column-gap: var(--loops-space-10); font-size: 14px; line-height: 1.5; color: var(--loops-ink-2); }
.msg .who { font-family: var(--loops-font-mono); font-size: 12px; line-height: 21px; color: var(--loops-ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.agent .body { color: var(--loops-ink); }
.msg.you .body { color: var(--loops-ink-2); }
/* Notices (mic reconnected, voice fallback, errors): a quiet line with a mono label. */
.msg.step {
  display: block; font-size: 12px; line-height: 1.4; letter-spacing: 0.12px; color: var(--loops-ink-3);
  border: 1px solid var(--loops-rule); background: var(--loops-inset); padding: var(--loops-space-8) var(--loops-space-10);
}
.msg.step::before {
  content: "Note"; display: block; margin-bottom: var(--loops-space-2);
  font-family: var(--loops-font-mono); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--loops-ink-3);
}
.compose { display: flex; gap: var(--loops-space-8); padding: var(--loops-space-12); border-top: 1px solid var(--loops-rule); }
.compose input {
  flex: 1; min-width: 0; min-height: var(--loops-btn-h-md); background: var(--loops-surface); border: 1px solid var(--loops-rule-2); border-radius: 0;
  padding: 0 var(--loops-space-12); outline: none; font-size: 14px; color: var(--loops-ink); transition: border-color var(--loops-dur-fast);
}
.compose input::placeholder { color: var(--loops-ink-3); }
.compose input:focus-visible { border-color: var(--loops-ink); outline: 2px solid var(--loops-accent); outline-offset: 2px; }
.compose .btn { padding: 0 var(--loops-space-16); }

/* Controls */
.controls {
  display: flex; justify-content: center; align-items: center; gap: var(--loops-space-8);
  min-height: 72px; padding: var(--loops-space-12) var(--loops-space-16); position: relative;
  border-top: 1px solid var(--loops-rule); background: var(--loops-canvas);
}
.controls .left { position: absolute; left: var(--loops-gutter); display: flex; align-items: center; gap: var(--loops-space-12); color: var(--loops-ink-3); }
.left-sep { width: 1px; height: 20px; background: var(--loops-rule); }
#clock { font-family: var(--loops-font-mono); font-size: 12px; color: var(--loops-ink); }
.left-title { font-size: 12px; letter-spacing: 0.12px; color: var(--loops-ink-3); }
/* Square ghost controls. Hierarchy is fill against outline: the only ink control is Leave. */
.ctl {
  height: var(--loops-btn-h-md); min-width: var(--loops-btn-h-md); padding: 0 var(--loops-space-16); border-radius: 0;
  border: 1px solid var(--loops-rule-2); background: transparent; color: var(--loops-ink-2); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--loops-space-8); font-size: 14px; letter-spacing: -0.14px;
  transition: background-color var(--loops-dur-fast), border-color var(--loops-dur-fast), color var(--loops-dur-fast);
}
.ctl:hover { border-color: var(--loops-ink-3); color: var(--loops-ink); }
.ctl svg { width: 18px; height: 18px; flex: none; }
/* Pressed (chat open, control taken): a surface step and a stronger hairline. */
.ctl.on { background: var(--loops-inset); border-color: var(--loops-ink-3); color: var(--loops-ink); }
/* Mic or camera off: the outline goes to ink so a muted mic is never missed. */
.ctl.off { border-color: var(--loops-ink); color: var(--loops-ink); background: var(--loops-inset); }
.ctl.mic { --lvl: 0; }
.mic-glyph { position: relative; display: inline-grid; place-items: center; width: 18px; height: 18px; }
.mic-glyph svg { grid-area: 1 / 1; }
/* Accent fill rising inside the mic capsule with your voice level. */
.mic-level { position: absolute; left: 50%; bottom: 7px; width: 3px; height: calc(var(--lvl) * 8px); transform: translateX(-50%); background: var(--loops-accent); transition: height 60ms linear; }
.ctl.mic.off .mic-level { display: none; }
.ctl.mic.talking { border-color: var(--loops-accent); }
.ctl.leave { background: var(--loops-ink); border-color: var(--loops-ink); color: var(--loops-on-ink); font-weight: 500; padding: 0 var(--loops-space-24); margin-left: var(--loops-space-8); }
.ctl.leave:hover { background: var(--loops-ink-hover); border-color: var(--loops-ink-hover); }
.ctl.cam .i-on, .ctl.cam.off .i-off { display: block; }
.ctl.cam .i-off, .ctl.cam.off .i-on { display: none; }
.ctl[hidden] { display: none; }

/* ---------- Thank-you screen ---------- */
.ended { position: fixed; inset: 0; background: var(--loops-canvas); display: none; overflow-y: auto; }
.ended.on { display: flex; flex-direction: column; }
.ended-inner { width: min(980px, 100% - 2 * var(--loops-gutter)); margin: 0 auto; padding: var(--loops-hero-y) 0 var(--loops-space-64); display: flex; flex-direction: column; align-items: flex-start; gap: var(--loops-space-32); }
.ended-head { display: flex; flex-direction: column; gap: var(--loops-space-16); }
.ended h2 { font-size: 42px; line-height: 1; letter-spacing: -1.13px; color: var(--loops-ink); }
.ended p { color: var(--loops-ink-2); font-size: 16px; line-height: 1.33; letter-spacing: -0.18px; max-width: 54ch; }
.booking { width: 100%; background: var(--loops-surface); border: 1px solid var(--loops-rule); }
.booking-head { padding: var(--loops-space-24) var(--loops-space-24) var(--loops-space-8); display: flex; flex-direction: column; gap: var(--loops-space-6); }
.booking h3 { font-size: 20px; line-height: 1.2; letter-spacing: -0.22px; font-weight: 500; color: var(--loops-ink); }
.booking .booking-sub { font-size: 14px; line-height: 1.5; letter-spacing: -0.14px; color: var(--loops-ink-2); }
.booking-cal { width: 100%; min-height: 620px; overflow: auto; }
.booking-done {
  display: flex; align-items: center; gap: var(--loops-space-10); margin: 0 var(--loops-space-24) var(--loops-space-24) !important;
  padding: var(--loops-space-12) var(--loops-space-16); border: 1px solid var(--loops-rule); background: var(--loops-inset);
  color: var(--loops-ink) !important; font-size: 14px !important; font-weight: 500;
}
.booking-done::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--loops-accent); flex: none; }

/* Video SDR (VOICE=tavus): the agent tile shows the PAL's face, larger than a plain avatar tile. */
#agent-video { display: none; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile.video { width: 288px; height: 162px; overflow: hidden; } /* 16:9, like the PAL's stream */
.tile.video #agent-video { display: block; }
.tile.video .avatar { display: none; }
.tile.video .name { z-index: 1; }

/* The prospect's own camera (Tavus calls): mirrored like every video app's self-view. */
#you-video { display: none; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.tile.you.video { overflow: hidden; width: 288px; height: 162px; }
.tile.you.video #you-video { display: block; }
.tile.you.video .avatar { display: none; }
.tile.you.video .name, .tile.you.video .tile-mic { z-index: 1; }
/* With a video face in the strip, both tiles share its width. */
.call:not(.chat-open) .tiles:has(.tile.video) .tile { width: 288px; }

/* ---------- Narrow screens ---------- */
@media (max-width: 1080px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .lobby-copy { border-right: 0; border-bottom: 1px solid var(--loops-rule); }
}
@media (max-width: 860px) and (orientation: portrait) {
  /* Phones, upright: the demo is the call. The shared screen takes the height, the people a
     strip under it, then the controls; the chat opens from its button and takes the lower part
     while it's open. Only the captions sit on the screen. The call fills the visible viewport
     (--app-h and --app-top, kept by call.ts), so the chat box stays above the keyboard. */
  .call { position: fixed; left: 0; right: 0; top: var(--app-top, 0px); height: var(--app-h, 100dvh); }
  .call-main { display: flex; flex-direction: column; }
  .stage { flex: 1; min-height: 0; padding: var(--loops-space-8); }
  .screen-bar { min-height: var(--loops-btn-h-md); gap: var(--loops-space-8); padding: 0 0 0 var(--loops-space-10); letter-spacing: 1px; }
  .status-chip { max-width: 50%; letter-spacing: 0.06em; }
  .screen-zoom { display: grid; }
  .side, .call.chat-open .side { display: flex; flex: none; min-height: 0; width: auto; border-left: 0; border-top: 1px solid var(--loops-rule); }
  .call.chat-open .side { flex: 0 0 45%; }
  .tiles, .call.chat-open .tiles { flex-direction: row; align-items: center; gap: var(--loops-space-8); padding: var(--loops-space-8) var(--loops-space-12); border-bottom: 1px solid var(--loops-rule); }
  .tile, .call.chat-open .tiles .tile { flex: none; width: 88px; height: 52px; border-color: var(--loops-rule-2); }
  .tile.you { display: none; }
  .tile.you.video { display: grid; }
  .tile .avatar { width: 30px; height: 30px; font-size: 14px; }
  .tile .name, .tile-mic { display: none; }
  .tile.video, .call.chat-open .tiles .tile.video, .call:not(.chat-open) .tiles:has(.tile.video) .tile, .tiles:has(.tile.video) .tile { width: 112px; height: 63px; aspect-ratio: auto; }
  .call.chat-open .tiles:has(.tile.video) .tile.you { position: static; width: 112px; height: 63px; }
  .chat { display: none; }
  .call.chat-open .chat { display: flex; flex: 1; }
  .chat header { display: none; }
  .msg { font-size: 15px; }
  .compose { padding: var(--loops-space-8); }
  .compose input { font-size: 16px; } /* under 16px, iOS zooms the page when the box takes focus */
  .caption-stack { width: calc(100% - 16px); bottom: var(--loops-space-8); gap: var(--loops-space-6); }
  .captions { font-size: 13px; line-height: 1.4; padding: var(--loops-space-6) var(--loops-space-10); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .heard { padding: var(--loops-space-6) var(--loops-space-10); font-size: 13px; }
  .controls { justify-content: space-between; gap: var(--loops-space-8); padding: var(--loops-space-8) var(--loops-space-12) max(var(--loops-space-8), env(safe-area-inset-bottom)); min-height: 0; }
  /* Just the Loops mark on the left; the clock and title need more room than a phone has. */
  .controls .left { display: flex; position: static; }
  .controls .left > :not(.brand), .controls .left .wordmark { display: none; }
  .ctl { padding: 0; width: var(--loops-btn-h-md); }
  .ctl .label { display: none; }
  .ctl.leave { width: auto; padding: 0 var(--loops-space-24); margin-left: 0; }
  /* While typing, the keyboard needs the room: the controls step aside until the box loses focus. */
  .call:has(#chat-input:focus) .controls { display: none; }
  /* Zoomed: the screen takes the whole call at full height; slide sideways to see all of it. */
  .call.zoom .side { display: none; }
  .call.zoom .stage { flex: 1; min-height: 0; }
  .call.zoom .screen-pan { display: block; place-items: normal; overflow: auto; overscroll-behavior: contain; }
  .call.zoom .screen-pan img { width: auto; max-width: none; height: 100%; }
}
@media (orientation: landscape) and (max-height: 520px) {
  /* Phones on their side: the screen takes the height, the people and the chat a column beside it. */
  .call { position: fixed; left: 0; right: 0; top: var(--app-top, 0px); height: var(--app-h, 100dvh); }
  .stage { padding: var(--loops-space-8); }
  .screen-bar { min-height: 36px; }
  .call.chat-open .side { width: min(320px, 40vw); }
  .tiles { padding: var(--loops-space-8); gap: var(--loops-space-8); }
  .tile, .call.chat-open .tiles .tile { width: 112px; height: 63px; }
  .call.chat-open .tiles .tile { flex: 1; width: auto; height: 56px; }
  .tile .avatar { width: 30px; height: 30px; font-size: 14px; }
  .tile .name { display: none; }
  .tile.video, .call:not(.chat-open) .tiles:has(.tile.video) .tile { width: 112px; height: 63px; }
  .chat header { min-height: 36px; }
  .compose input { font-size: 16px; }
  .caption-stack { width: calc(100% - 24px); bottom: var(--loops-space-8); }
  .captions { font-size: 13px; padding: var(--loops-space-6) var(--loops-space-10); }
  .controls { min-height: 0; padding: var(--loops-space-6) var(--loops-space-12) max(var(--loops-space-6), env(safe-area-inset-bottom)); }
  .controls .left { display: none; }
  .ctl .label { display: none; }
  .ctl { padding: 0; width: var(--loops-btn-h-md); }
  .ctl.leave { width: auto; padding: 0 var(--loops-space-24); }
}
@media (max-width: 600px) {
  .lobby-copy h1 { font-size: 32px; line-height: 1.15; letter-spacing: -0.64px; }
  .lobby-copy { gap: var(--loops-space-16); }
  .perks { grid-template-columns: repeat(3, auto); }
  .perks li { padding: 0 var(--loops-space-10); }
  .ended h2 { font-size: 32px; line-height: 1.15; letter-spacing: -0.64px; }
  .booking-head { padding: var(--loops-space-20) var(--loops-space-20) var(--loops-space-8); }
  .card-body { padding: var(--loops-space-20); }
  /* Phones: the join card nearer the top, and 16px fields so iOS doesn't zoom on focus. */
  .lobby-copy { padding: var(--loops-space-32) var(--loops-gutter) var(--loops-space-24); }
  .lobby-panel { padding: var(--loops-space-24) var(--loops-space-16) var(--loops-space-32); }
  .lobby-card input, .lobby-card select { font-size: 16px; }
}
.call[hidden], .lobby[hidden] { display: none; }

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