/* Live session page */
body { background: #050714; overflow: hidden; height: 100vh; height: 100dvh; }
[data-theme="light"] body { background: #E8ECFB; }

.session-app {
  display: grid;
  grid-template-columns: 1fr 360px;
  grid-template-rows: 64px 1fr;
  height: 100vh;
  height: 100dvh; /* mobile browsers: exclude the collapsing address bar */
  gap: 0;
}

/* Session topbar */
.s-top {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-deep);
  z-index: 10;
}
.s-top .l, .s-top .r { display: flex; align-items: center; gap: 16px; }
.s-top .brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.s-top .brand img { width: 22px; height: 22px; }
.s-top .divider { width: 1px; height: 24px; background: var(--border-strong); }
.s-top .scenario-tag { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.s-top .scenario-tag svg { width: 16px; height: 16px; }
.s-top .timer { font-family: var(--font-mono); font-size: 18px; font-weight: 500; color: var(--text); letter-spacing: 0.04em; }
.s-top .rec-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(255,107,107,0.16); border: 1px solid rgba(255,107,107,0.36);
  color: #FF8E8E; font-size: 12px; font-family: var(--font-mono); letter-spacing: 0.06em;
}
.s-top .rec-badge .dot { width: 8px; height: 8px; border-radius: 999px; background: #FF6B6B; animation: pulse 1.6s infinite; }

/* ===== Main stage area ===== */
.s-stage {
  position: relative;
  padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
  overflow: hidden;
  min-width: 0;
}

/* Camera view */
.cam {
  flex: 1;
  position: relative;
  border-radius: var(--r-lg);
  background: var(--bg-deep);
  border: 1px solid var(--border-strong);
  overflow: hidden;
  min-height: 360px;
}

/* Real user camera feed */
.cam > #cam-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror like a selfie */
  background: #0B1020;
  z-index: 1;
  display: none;
  transition: opacity .25s;
}
.cam.cam-live > #cam-video { display: block; }
.cam.cam-live .audience { display: none; }
.cam.cam-vid-off > #cam-video { opacity: 0; }

/* Camera off / paused indicator (center) */
.cam-paused {
  position: absolute; inset: 0; z-index: 7;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: rgba(255,255,255,0.7);
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  background: rgba(11,16,32,0.55);
}
.cam-paused[hidden] { display: none; }

/* Camera permission / enable prompt */
.cam-off {
  position: absolute; inset: 0; z-index: 8;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,11,18,0.82);
}
.cam.cam-live .cam-off { display: none; }
.cam-off-inner {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center; max-width: 330px; padding: 24px;
}
.cam-off-icon {
  width: 58px; height: 58px; display: grid; place-items: center;
  border-radius: 999px; background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.16); color: #fff;
}
.cam-off-title { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 17px; color: #fff; letter-spacing: -0.01em; }
.cam-off-desc { margin: 0; font-size: 13px; line-height: 1.55; color: rgba(255,255,255,0.72); }
.cam-off.is-error .cam-off-desc { color: #F0808F; }
.cam-off-btn {
  appearance: none; border: 0; cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  padding: 11px 24px; border-radius: var(--r-pill);
  background: var(--grad-primary); color: #fff;
  transition: opacity .15s; letter-spacing: -0.01em;
}
.cam-off-btn:hover { opacity: .88; }
.cam-off-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Control button on/off (muted) state */
.cc-btn.is-off {
  background: rgba(240,85,107,0.18);
  border-color: rgba(240,85,107,0.45);
  color: #F0808F;
}

/* Audience simulation backdrop */
.audience {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 6px;
  padding: 56% 24px 18px;
  opacity: .35;
}
.audience .seat { aspect-ratio: 1; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border-strong); }
.audience .seat:nth-child(3n+1) { background: var(--blue-dim); border-color: var(--blue-line); }
.audience .seat:nth-child(5n) { background: var(--surface-2); }

/* Pose silhouette overlay */
.pose-overlay {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -45%);
  width: 320px; aspect-ratio: 1;
  pointer-events: none;
}

/* Camera HUD top */
.cam-hud-top {
  position: absolute; top: 16px; left: 16px; right: 16px;
  display: flex; justify-content: space-between; align-items: start;
  z-index: 5;
}
.live-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.14);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; color: #fff;
}
.live-pill .dot-live { width: 8px; height: 8px; border-radius: 999px; background: #FF6B6B; animation: pulse 1.6s infinite; }

.cam-info { display: flex; gap: 8px; }
.cam-chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,0.55);

  border: 1px solid rgba(255,255,255,0.14);
  font-size: 12px;
  color: rgba(255,255,255,0.85);
}

/* Floating metric cards in camera */
.cam-metric {
  position: absolute;
  background: rgba(11, 16, 32, 0.78);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: var(--r-md);
  padding: 12px 14px;

  z-index: 6;
  min-width: 140px;
  color: #fff;
}
.cam-metric .lbl { font-family: var(--font-mono); font-size: 10px; color: rgba(255,255,255,0.6); letter-spacing: 0.14em; text-transform: uppercase; }
.cam-metric .val { font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin-top: 3px; line-height: 1; }
.cam-metric .val .u { font-size: 12px; color: rgba(255,255,255,0.6); margin-left: 3px; font-weight: 500; }
.cam-metric .sub { font-size: 11px; color: rgba(255,255,255,0.66); margin-top: 6px; }
.cam-metric .bar { height: 4px; background: rgba(255,255,255,0.1); border-radius: 999px; margin-top: 8px; overflow: hidden; }
.cam-metric .bar i { display: block; height: 100%; background: var(--grad-primary); border-radius: 999px; }

.m-wpm { left: 20px; top: 64px; }
.m-eye { right: 20px; top: 64px; }
.m-fill {
  left: 20px; bottom: 116px;
  border-color: rgba(245,181,68,0.34);
}
.m-fill .val { color: #FFD27A; }
.m-confidence { right: 20px; bottom: 116px; }
.m-confidence .ring-mini {
  width: 56px; height: 56px;
  border-radius: 999px;
  background: conic-gradient(var(--blue) 78%, var(--surface-3) 0);
  position: relative;
  margin-top: 6px;
}
.m-confidence .ring-mini::after {
  content: ""; position: absolute; inset: 5px; border-radius: 999px;
  background: rgba(11,16,32,0.95);
}
.m-confidence .ring-mini span {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 16px; font-weight: 600;
  z-index: 1;
}

/* Live coach tip */
.coach-tip {
  position: absolute;
  left: 50%; bottom: 80px;
  transform: translateX(-50%);
  max-width: 460px;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(46,107,255,0.18);
  border: 1px solid rgba(46,107,255,0.4);

  display: flex; gap: 12px; align-items: center;
  z-index: 6;
  animation: tipFadeIn .5s ease-out;
}
@keyframes tipFadeIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.coach-tip .body { flex: 1; min-width: 0; }
.coach-tip .body .head { font-family: var(--font-mono); font-size: 10px; color: var(--cyan-soft); letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 4px; }
.coach-tip .body .msg { font-size: 14px; color: #fff; line-height: 1.45; }

/* Push-to-talk mic button (center live coach) */
.coach-talk {
  position: relative; flex-shrink: 0;
  width: 40px; height: 40px; border-radius: 999px; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--blue); color: #fff; border: 0;
  transition: background .15s, transform .1s;
}
.coach-talk:hover { background: #1F5BFF; }
.coach-talk:active { transform: scale(0.94); }
.coach-talk.listening { background: var(--red); animation: coachPulse 1.3s infinite; }
.coach-talk.speaking { background: var(--green); }
.coach-talk[disabled] { opacity: .45; cursor: default; }
@keyframes coachPulse {
  0% { box-shadow: 0 0 0 0 rgba(240,85,107,0.55); }
  70% { box-shadow: 0 0 0 10px rgba(240,85,107,0); }
  100% { box-shadow: 0 0 0 0 rgba(240,85,107,0); }
}
/* Coach voice-reply toggle */
.coach-voice-toggle {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 999px; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: rgba(255,255,255,0.08); color: var(--text-dim);
  border: 1px solid var(--border); transition: color .15s, background .15s;
}
.coach-voice-toggle:hover { color: #fff; }
.coach-voice-toggle[aria-pressed="true"] { color: var(--blue-bright); border-color: var(--blue-line); background: var(--blue-dim); }

/* Transcript caption ribbon */
.caption {
  position: absolute;
  left: 50%; bottom: 18px;
  transform: translateX(-50%);
  max-width: 620px;
  padding: 12px 18px;
  background: rgba(0,0,0,0.6);

  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 16px;
  color: #fff;
  line-height: 1.5;
  z-index: 5;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
}
/* CC language switch */
.cc-lang {
  position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 3px; padding: 3px 3px 3px 10px;
  border-radius: 999px; background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.12);
}
.cc-lang-tag { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.14em; color: rgba(255,255,255,0.5); margin-right: 4px; }
.cc-lang button {
  border: 0; background: transparent; color: rgba(255,255,255,0.6);
  font-family: var(--font-display); font-size: 11px; font-weight: 600;
  padding: 4px 12px; border-radius: 999px; cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur);
}
.cc-lang button.active { background: rgba(255,255,255,0.16); color: #fff; }
.caption .filler {
  background: rgba(245,181,68,0.26);
  color: #FFD27A;
  padding: 2px 8px; border-radius: 4px;
}
.caption .keyword {
  color: #8FB2FF;
  font-weight: 500;
}

/* Camera controls bar */
.cam-controls {
  display: flex; justify-content: center; align-items: center; gap: 12px;
  padding: 8px;
}
.cc-btn {
  width: 52px; height: 52px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background .2s, transform .15s;
}
.cc-btn:hover { background: var(--surface-3); }
.cc-btn:active { transform: scale(.96); }
.cc-btn:disabled { opacity: .4; cursor: not-allowed; }
.cc-btn:disabled:hover { background: var(--surface-2); }
.cc-btn:disabled:active { transform: none; }
.cc-btn svg { width: 22px; height: 22px; }
.cc-btn.danger {
  background: #FF6B6B;
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px -6px rgba(255,107,107,0.6);
  width: 64px; height: 64px;
}
.cc-btn.danger svg { width: 24px; height: 24px; }
.cc-btn .live-rec-dot { width: 18px; height: 18px; background: #fff; border-radius: 4px; }

/* ===== Right rail ===== */
.s-rail {
  background: var(--bg-deep);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.rail-tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 14px 14px 0;
}
.rail-tabs button {
  background: transparent; border: 0; color: var(--text-dim);
  font-family: var(--font-body); font-weight: 500; font-size: 12.5px;
  padding: 10px 11px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.rail-tabs button.active { color: var(--text); border-bottom-color: var(--violet); }

.rail-content {
  flex: 1; overflow-y: auto;
  padding: 18px;
  display: flex; flex-direction: column; gap: 18px;
}

/* AI Coach chat */
.coach-panel { overflow: hidden; gap: 10px; }
.coach-chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; }
.coach-msg {
  max-width: 88%; padding: 10px 13px; border-radius: 14px;
  font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word;
}
.coach-msg.bot {
  align-self: flex-start; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-bottom-left-radius: 4px;
}
.coach-msg.user {
  align-self: flex-end; background: var(--grad-primary); color: #fff;
  font-weight: 500; border-bottom-right-radius: 4px;
}
.coach-msg.typing { color: var(--text-faint); font-style: italic; }
.coach-input-row { display: flex; gap: 8px; align-items: center; flex: none; }
.coach-input {
  flex: 1; appearance: none; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-pill); color: var(--text); font-family: var(--font-body);
  font-size: 13px; padding: 10px 16px; outline: none; transition: border-color .15s;
}
.coach-input:focus { border-color: var(--violet); }
.coach-send {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--grad-primary); color: #fff;
  transition: filter .15s, opacity .15s;
}
.coach-send:hover { filter: brightness(1.08); }
.coach-send:disabled { opacity: .5; cursor: default; }
/* Voice input mic */
.coach-mic {
  flex: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
  transition: background var(--dur) var(--ease), border-color var(--dur), color var(--dur), box-shadow var(--dur);
}
.coach-mic:hover { background: var(--surface-3); border-color: var(--border-strong); }
.coach-mic:disabled { opacity: .4; cursor: default; }
.coach-mic.listening {
  background: rgba(255,107,107,0.16); border-color: var(--red); color: #FF8E8E;
  animation: coach-mic-pulse 1.4s infinite;
}
@keyframes coach-mic-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,107,107,0.5); }
  70% { box-shadow: 0 0 0 9px rgba(255,107,107,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,107,107,0); }
}
/* Speak-replies toggle */
.coach-tts {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: transparent; border: 1px solid transparent; color: var(--text-faint); cursor: pointer;
  transition: color var(--dur), background var(--dur), border-color var(--dur);
}
.coach-tts:hover { color: var(--text-dim); }
.coach-tts[aria-pressed="true"] { color: var(--violet-soft); background: rgba(46,107,255,0.14); border-color: rgba(46,107,255,0.32); }
.coach-tts[aria-pressed="false"] .tts-wave { opacity: .25; }
.coach-tts.speaking { color: var(--violet-soft); animation: coach-tts-blink 1s infinite; }
@keyframes coach-tts-blink { 50% { opacity: .5; } }

/* Transcript */
.transcript-block { padding: 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.transcript-block .ts { font-family: var(--font-mono); font-size: 10px; color: var(--text-faint); letter-spacing: 0.08em; margin-bottom: 6px; }
.transcript-block .text { font-size: 13px; line-height: 1.55; color: var(--text); }
.transcript-block .text .filler { background: rgba(245,181,68,0.22); color: #FFD27A; padding: 1px 6px; border-radius: 4px; }
.transcript-block .text .slow { background: rgba(46,107,255,0.18); border-bottom: 1px dashed rgba(46,107,255,0.5); }
.transcript-block.active { border-color: rgba(46,107,255,0.45); background: rgba(46,107,255,0.08); }
.transcript-block.active .ts { color: var(--violet-soft); }

/* Notes section */
.section-label { font-family: var(--font-mono); font-size: 10px; color: var(--text-faint); letter-spacing: 0.18em; text-transform: uppercase; }

/* Live alerts */
.alert-row {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
}
.alert-row.warn { border-color: rgba(245,181,68,0.32); background: rgba(245,181,68,0.08); color: #FFD27A; }
.alert-row.ok { border-color: rgba(52,211,153,0.32); background: rgba(52,211,153,0.06); color: #6EE7B7; }
.alert-row.info { border-color: rgba(46,107,255,0.32); background: rgba(46,107,255,0.06); color: #8FB2FF; }
.alert-row .ts { font-family: var(--font-mono); font-size: 10px; opacity: .7; margin-left: auto; }
.alert-row .ic { width: 24px; height: 24px; border-radius: 6px; display:grid;place-items:center; flex-shrink: 0; }
.alert-row.warn .ic { background: rgba(245,181,68,0.2); }
.alert-row.ok .ic { background: rgba(52,211,153,0.2); }
.alert-row.info .ic { background: rgba(46,107,255,0.2); }

/* Live meters list */
.live-meter { padding: 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.live-meter .row { display: flex; justify-content: space-between; align-items: baseline; }
.live-meter .lbl { font-size: 12px; color: var(--text-dim); }
.live-meter .val { font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.live-meter .val .u { font-size: 11px; color: var(--text-dim); margin-left: 3px; font-weight: 500; }
.live-meter .target { font-family: var(--font-mono); font-size: 10px; color: var(--text-faint); }
.live-meter .bar { height: 6px; background: var(--surface-3); border-radius: 999px; margin-top: 8px; position: relative; overflow: hidden; }
.live-meter .bar i { display: block; height: 100%; border-radius: 999px; background: var(--grad-primary); }
.live-meter .bar .target-mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--cyan-soft); border-radius: 2px; }

@media (max-width: 1100px) {
  .session-app { grid-template-columns: 1fr 300px; }
  .audience { display: none; }
}


/* ---- merged from inline <style> in session.html ---- */
  /* Theme + language switcher (replaces design-tool tweaks panel) */
  .nav-tools { display: flex; align-items: center; gap: 8px; }
  .lang-seg {
    display: inline-flex; padding: 3px; gap: 2px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-pill);
  }
  .lang-seg button {
    appearance: none; border: 0; background: transparent; cursor: pointer;
    font-family: var(--font-display); font-weight: 600; font-size: 12px;
    color: var(--text-dim); padding: 5px 11px; border-radius: var(--r-pill);
    transition: color .15s, background .2s;
  }
  .lang-seg button:hover { color: var(--text); }
  .lang-seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }
  .theme-toggle {
    appearance: none; cursor: pointer; width: 36px; height: 36px;
    display: grid; place-items: center; border-radius: var(--r-pill);
    background: var(--surface); border: 1px solid var(--border-strong);
    color: var(--text); transition: background .2s;
  }
  .theme-toggle:hover { background: var(--surface-2); }
  .theme-toggle svg { width: 17px; height: 17px; }
  .theme-toggle .ico-sun { display: none; }
  [data-theme="light"] .theme-toggle .ico-sun { display: block; }
  [data-theme="light"] .theme-toggle .ico-moon { display: none; }

  /* Tab panels */
  .rail-panel[hidden] { display: none; }

  /* Empty states inside the rail */
  .rail-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; text-align: center; padding: 28px 18px;
    border: 1px dashed var(--border-strong); border-radius: var(--r-md);
    color: var(--text-faint);
  }
  .rail-empty svg { opacity: .7; }
  .rail-empty p { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--text-dim); max-width: 220px; }

  /* Hand tracking canvas overlay */
  #hand-canvas {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    z-index: 3; pointer-events: none;
    /* isolate its repaints from the rest of the page (skeleton redraws every frame) */
    contain: layout paint;
  }
  /* Coach tip transition */
  .coach-tip { transition: opacity .3s; }
  .coach-tip.tip-flash { opacity: 0; animation: tipFadeIn .5s ease-out forwards; }

  /* Notes textarea */
  .notes-area {
    width: 100%; min-height: 320px; resize: vertical;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--r-md); padding: 14px;
    color: var(--text); font-family: var(--font-body); font-size: 13.5px; line-height: 1.6;
    outline: none; transition: border-color .15s;
  }
  .notes-area::placeholder { color: var(--text-faint); }
  .notes-area:focus { border-color: var(--border-strong); }

/* ===== Mobile: stack camera over the metrics/coach rail (phones ≤640px) ===== */
@media (max-width: 640px) {
  body { overflow: auto; }
  .session-app { display: flex; flex-direction: column; height: auto; min-height: 100vh; min-height: 100dvh; }
  .s-top { padding: 0 12px; height: 56px; flex-wrap: nowrap; gap: 8px; }
  /* On a phone the state is already told by the REC button + timer — drop the
     duplicating badge/scenario/theme chrome so nothing overlaps at 360–430px. */
  .s-top .scenario-tag, .s-top .divider, .s-top .chip,
  .s-top .rec-badge, .s-top .nav-tools { display: none; }
  .s-top .brand span { display: none; }
  .s-top .l, .s-top .r { gap: 8px; }
  .s-top .timer { font-size: 14px; white-space: nowrap; }
  .s-stage { min-height: 56vh; min-height: 56dvh; }
  .s-rail { width: auto; max-height: none; border-left: 0; border-top: 1px solid var(--border);
    padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .caption { max-width: 88vw; font-size: 14px; bottom: 14px; }
  .cc-lang { bottom: 60px; }
  .cam-controls { gap: 8px; }
  /* Touch targets: keep every session control comfortably tappable (≥44px) */
  .cam-controls button, .icon-btn, .theme-toggle { min-width: 44px; min-height: 44px; }
  /* Floating metric cards: compact so they don't blanket a phone-sized stage */
  .cam-metric { padding: 8px 10px; min-width: 96px; border-radius: 10px; }
  .cam-metric .val { font-size: 17px; }
  .cam-metric .sub { display: none; }
  .m-wpm { left: 10px; top: 54px; }
  .m-eye { right: 10px; top: 54px; }
  .m-fill { left: 10px; bottom: 92px; }
  .m-confidence { right: 10px; bottom: 92px; }
  .m-confidence .ring-mini { width: 44px; height: 44px; margin-top: 4px; }
  .m-confidence .ring-mini span { font-size: 13px; }
  .coach-tip { max-width: 92vw; bottom: 64px; padding: 10px 14px; }
  .cam-hud-top { padding: 10px 10px 0; }
  /* Pre-practice brief: 9 cards can outgrow a phone screen — let the card scroll */
  .brief-card { max-height: 86dvh; overflow-y: auto; padding: 20px 18px; }
}

/* ===== Co-op live scoreboard overlay ===== */
#coop-panel {
  position: fixed; top: 74px; right: 16px; z-index: 120;
  width: 210px; padding: 12px 13px; border-radius: var(--r-md);
  background: rgba(8,11,18,0.9); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-pop);
}
[data-theme="light"] #coop-panel { background: rgba(255,255,255,0.94); }
/* Drag handle grab bar + head. The user can pull the scoreboard off the controls. */
#coop-panel .coop-grab { width: 34px; height: 4px; border-radius: 999px; background: var(--border-strong);
  margin: 1px auto 9px; }
#coop-panel .coop-grab, #coop-panel .coop-head { cursor: grab; touch-action: none; user-select: none; }
#coop-panel.dragging { box-shadow: 0 0 0 1px var(--blue-bright), var(--shadow-pop); }
#coop-panel.dragging .coop-grab, #coop-panel.dragging .coop-head { cursor: grabbing; }
#coop-panel .coop-head { display: flex; align-items: center; gap: 7px; font-family: var(--font-mono);
  font-size: 10.5px; letter-spacing: .08em; color: var(--text-dim); margin-bottom: 10px; }
#coop-panel .coop-head b { color: var(--blue-bright); letter-spacing: .16em; }
.coop-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; padding: 5px 0; }
.coop-row + .coop-row { border-top: 1px solid var(--border); }
.coop-row .cdot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.coop-row .cdot.on { background: var(--green); }
.coop-row .cnm { font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coop-row.me .cnm { color: var(--blue-bright); font-weight: 600; }
.coop-row .csc { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--text); }
/* Phones: keep the co-op scoreboard usable — shrink it instead of hiding it */
@media (max-width: 900px) {
  #coop-panel { top: auto; bottom: 96px; right: 8px; width: 160px; padding: 8px 10px; }
  #coop-panel .coop-head { margin-bottom: 6px; }
  .coop-row .cnm { font-size: 11.5px; }
  .coop-row .csc { font-size: 13px; }
}

/* ===== Co-op Zoom-style gallery (you + partner, direct P2P video) ===== */
/* Solo → one tile fills the stage exactly as before. Partner online → the stage
   splits into an equal 2-up gallery (stacked on phones), like a Zoom meeting. */
.stage-gallery { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr; gap: 16px; }
.stage-gallery.has-peer { grid-template-columns: 1fr 1fr; }
.stage-gallery > .cam { min-height: 0; height: 100%; }
/* Active-speaker ring on your own tile while you're presenting (like Zoom) */
.stage-gallery.has-peer > .cam.tile-active { border-color: var(--green); box-shadow: 0 0 0 2px var(--green); }
/* Narrow partner tile duplicates the right-hand metrics panel → hide the floating
   HUD cards in gallery mode so the video tiles stay clean. */
.stage-gallery.has-peer .cam-metric { display: none !important; }

/* Zoom-style name label (bottom-left), shown only in a co-op gallery */
.tile-name { position: absolute; left: 12px; bottom: 12px; z-index: 6;
  display: none; align-items: center; gap: 7px; padding: 5px 11px; border-radius: var(--r-pill);
  background: rgba(5,7,15,0.66); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font-size: 12.5px; font-weight: 600; color: #fff; max-width: 72%; }
.tile-name .tn-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-name .tn-dot { width: 7px; height: 7px; border-radius: 999px; background: #34D399; flex: none; }
.stage-gallery.has-peer .tile-name { display: flex; }

/* Partner tile — an equal gallery cell (no longer a floating PiP) */
#coop-video { position: relative; min-height: 0; height: 100%; width: auto;
  border-radius: var(--r-lg); overflow: hidden; background: #05070F; border: 1px solid var(--border-strong); }
#coop-video[hidden] { display: none; }
#coop-video video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #05070F; }
#coop-video .cv-bar {
  position: absolute; left: 12px; bottom: 12px; right: auto; display: flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: var(--r-pill); background: rgba(5,7,15,0.66);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
#coop-video .cv-dot { width: 7px; height: 7px; border-radius: 999px; background: #34D399; flex: none; }
#coop-video .cv-name { flex: none; max-width: 60%; font-size: 12.5px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#coop-video .cv-mute {
  appearance: none; border: 0; background: rgba(255,255,255,0.16); color: #fff;
  border-radius: 999px; width: 28px; height: 28px; cursor: pointer; font-size: 12px; flex: none;
}
@media (max-width: 900px) {
  .stage-gallery.has-peer { grid-template-columns: 1fr; grid-auto-rows: 1fr; }
}

/* ===== Pre-practice briefing overlay ===== */
#brief-modal {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5,7,12,0.78); padding: 20px;
}
#brief-modal[hidden] { display: none; }
.brief-card {
  width: 100%; max-width: 560px; padding: 26px 28px;
  border-radius: var(--r-lg); background: var(--surface);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop);
  position: relative; overflow: hidden;
}
.brief-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--blue); }
.brief-kicker { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .14em; color: var(--blue-bright); text-transform: uppercase; }
.brief-card h2 { font-family: var(--font-display); font-weight: 700; font-size: 22px; margin: 8px 0 16px; }
.brief-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.brief-item { display: flex; flex-direction: column; gap: 3px; padding: 11px 13px;
  border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); }
.brief-item b { font-family: var(--font-display); font-size: 15px; color: var(--blue-bright); }
.brief-item span { font-size: 12px; color: var(--text-dim); line-height: 1.45; }
.brief-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.brief-skip { display: flex; align-items: center; gap: 7px; margin-top: 12px;
  font-size: 12px; color: var(--text-faint); cursor: pointer; }
.brief-skip input { accent-color: var(--blue); }
@media (max-width: 560px) { .brief-grid { grid-template-columns: 1fr; } }
