:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2430;
  --line: #2a3441;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #3b82f6;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

header h1 { font-size: 17px; margin: 0; letter-spacing: .3px; }
header .spacer { flex: 1; }
header button, header .button-link { padding: 7px 14px; font-size: 14px; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 14px; }

button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
button:hover:not(:disabled) { filter: brightness(1.1); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--bad); }

select, input {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
}

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.live { background: var(--ok); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.pair { display: flex; gap: 32px; flex-wrap: wrap; align-items: flex-start; }

/* The cast code is read aloud across a room or a phone call, so it is the
   largest thing on the sender's screen. */
.code {
  font: 700 44px/1.15 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .12em;
  margin-top: 6px;
}
.muted { color: var(--muted); font-size: 13px; }

/* --- entry flow: sign in, choose a side, type a code ---------------------- */

.flow { max-width: 620px; }

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

.choice {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  padding: 20px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
}
.choice:hover:not(:disabled) { border-color: var(--accent); filter: none; }
.choice-icon { width: 30px; height: 30px; color: var(--accent); margin-bottom: 8px; }
.choice-title { font-size: 17px; font-weight: 600; }
.choice-sub { font-size: 13px; color: var(--muted); font-weight: 400; }

.code-input {
  flex: 1;
  min-width: 200px;
  font: 700 22px/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .14em;
  text-align: center;
  text-transform: uppercase;
}

/* A link that has to sit in a row of buttons and match them. */
.button-link {
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}
.button-link.accent { background: var(--accent); border-color: transparent; color: #fff; }
.button-link:hover { filter: brightness(1.1); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 3px; }

video {
  width: 100%;
  background: #000;
  border-radius: var(--radius);
  display: block;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

#preview { max-width: 420px; aspect-ratio: auto; }

.log {
  font: 12px/1.6 ui-monospace, Menlo, Consolas, monospace;
  color: var(--muted);
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
}

.viewer-shell { max-width: 1400px; }
.hidden { display: none !important; }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.notice.bad { border-color: var(--bad); color: #fecaca; }
