:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #16181d;
  --muted: #666d78;
  --accent: #2f6df6;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --stage: #0b0c0e;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1114;
    --surface: #171a1f;
    --border: #2a2f37;
    --text: #e9ecf1;
    --muted: #98a0ac;
    --accent: #5b8cff;
    --accent-text: #0b0d10;
    --danger: #ff6b5e;
    --stage: #000000;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font:
    15px/1.5 system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
}

.screen[hidden],
[hidden] {
  display: none !important;
}

/* ---- sign-in ------------------------------------------------------------ */

#login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.card {
  width: 100%;
  max-width: 380px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

#login-form {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

input[type='password'] {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-family: ui-monospace, monospace;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- buttons ------------------------------------------------------------ */

button {
  padding: 9px 16px;
  font: inherit;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: progress;
}

.primary {
  color: var(--accent-text);
  background: var(--accent);
}

.danger {
  color: #fff;
  background: var(--danger);
}

.ghost {
  color: var(--muted);
  background: transparent;
  border-color: var(--border);
}

/* ---- room --------------------------------------------------------------- */

#room {
  display: flex;
  flex-direction: column;
  /* Height comes from html/body being 100%, not from vh units: mixing vh on a
     child with vh on body leaves a dead strip when the two disagree. */
  height: 100%;
  overflow: hidden;
}

.bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

footer.bar {
  border-top: 1px solid var(--border);
  border-bottom: none;
}

.brand {
  font-weight: 600;
}

.spacer {
  flex: 1;
}

.pill {
  padding: 2px 10px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.pill[data-state='live'] {
  color: var(--accent-text);
  background: var(--accent);
  border-color: transparent;
}

.pill[data-state='error'] {
  color: #fff;
  background: var(--danger);
  border-color: transparent;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--stage);
}

#video {
  width: 100%;
  height: 100%;
  /* contain, not cover: cropping a shared desktop hides the part someone is
     pointing at. Letterboxing is the lesser evil. */
  object-fit: contain;
  background: var(--stage);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background: color-mix(in srgb, var(--stage) 92%, transparent);
  color: #e9ecf1;
}

.overlay-inner {
  display: grid;
  gap: 12px;
  justify-items: center;
  max-width: 460px;
}

.overlay h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.overlay .muted {
  color: #98a0ac;
}

.hint {
  margin: 0;
  font-size: 13px;
  color: #98a0ac;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.error {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--danger);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: min(90vw, 520px);
  margin: 0;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.18);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

@media (max-width: 560px) {
  .card {
    padding: 24px;
  }
  #whoami {
    display: none;
  }
}

/* ---- player ------------------------------------------------------------- */

.body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.player {
  position: relative;
  flex: 1 1 auto;
  /* Both min-* are load-bearing: without them the video's intrinsic size
     stretches the flex row past the viewport and leaves a dead strip. */
  min-width: 0;
  min-height: 0;
  background: var(--stage);
}

#video {
  display: block;
  width: 100%;
  height: 100%;
  /* contain, not cover: cropping a shared desktop hides the part someone is
     pointing at. Letterboxing is the lesser evil. */
  object-fit: contain;
  background: var(--stage);
}

.player:fullscreen #video {
  width: 100vw;
  height: 100vh;
}

/* ---- control bar -------------------------------------------------------- */

.controls {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  color: #f2f4f8;
  background: linear-gradient(to top, rgb(0 0 0 / 0.78), rgb(0 0 0 / 0));
  transition: opacity 0.25s ease;
}

.player.idle .controls {
  opacity: 0;
  pointer-events: none;
}

.player.idle {
  cursor: none;
}

.controls .icon {
  padding: 4px 8px;
  font-size: 16px;
  line-height: 1;
  color: inherit;
  background: transparent;
  border: none;
}

.controls .icon:hover {
  background: rgb(255 255 255 / 0.14);
}

.volume {
  width: 96px;
  accent-color: var(--accent);
}

.now-playing,
.stats {
  font-size: 12px;
  color: #cfd5de;
}

.stats {
  font-family: ui-monospace, monospace;
  padding: 2px 8px;
  background: rgb(0 0 0 / 0.45);
  border-radius: 6px;
}

.live-badge {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fff;
  background: var(--danger);
  border-radius: 4px;
}

.live-badge i {
  width: 7px;
  height: 7px;
  background: #fff;
  border-radius: 50%;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

.unmute {
  position: absolute;
  left: 50%;
  bottom: 70px;
  transform: translateX(-50%);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.4);
}

/* ---- people ------------------------------------------------------------- */

.people {
  width: 230px;
  flex: none;
  padding: 14px 16px;
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.people h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.people ul {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.people li {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
}

.people em {
  margin-left: auto;
  font-size: 11px;
  font-style: normal;
  color: var(--accent);
}

.dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--border);
}

.dot.live {
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent);
}

@media (max-width: 760px) {
  .body {
    flex-direction: column;
  }
  .people {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .volume {
    width: 64px;
  }
}

/* Idle: the bar stays reachable but recedes. */
.controls.dim {
  background: linear-gradient(to top, rgb(0 0 0 / 0.55), rgb(0 0 0 / 0));
}

.controls.dim .volume,
.controls.dim .now-playing {
  opacity: 0.45;
}

/* ---- icons -------------------------------------------------------------- */

.controls .icon svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.controls .icon svg path[d^='M4 9v6'] {
  fill: currentColor;
  stroke: none;
}

/* Muted: hide the waves, show the cross. */
.icon .cross {
  display: none;
}

.icon.muted .wave {
  display: none;
}

.icon.muted .cross {
  display: inline;
}

/* ---- missing-audio banner ---------------------------------------------- */

.no-audio {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  align-items: center;
  max-width: min(92%, 760px);
  padding: 10px 16px;
  font-size: 13px;
  color: #fff;
  background: color-mix(in srgb, var(--danger) 92%, black);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.35);
}

.no-audio strong {
  flex: none;
}

.no-audio button {
  flex: none;
  padding: 6px 12px;
  font-size: 13px;
}

@media (max-width: 760px) {
  .no-audio {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }
}

/* ---- audio source picker ------------------------------------------------ */

#audio-source {
  width: 100%;
  margin-bottom: 8px;
  padding: 7px 8px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.people .hint {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.people button {
  width: 100%;
  font-size: 13px;
}
