:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5d6573;
  --line: #dfe3ea;
  --accent: #0b6bcb;
  --accent-text: #ffffff;
  --danger: #c4321c;
  --ok: #1d7f4e;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --text: #e8eaee;
    --muted: #9aa3b2;
    --line: #2a2f38;
    --accent: #4c9eff;
    --accent-text: #08111d;
    --danger: #ff7a66;
    --ok: #4fd18b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { font-weight: 700; letter-spacing: -0.01em; text-decoration: none; color: var(--text); }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.who form { margin: 0; }
main { max-width: 720px; margin: 0 auto; padding: 24px 16px 48px; }
main.narrow { max-width: 480px; }
h1 { font-size: 24px; margin: 8px 0 16px; }
h2 { font-size: 18px; margin: 0 0 8px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px;
}
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
input.code {
  flex: 1 1 240px; min-width: 0; font: 600 22px/1.2 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.08em; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
input.code:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; background: var(--accent); color: var(--accent-text); text-decoration: none;
}
button.secondary, .button.secondary { background: transparent; color: var(--text); border-color: var(--line); }
button.danger { background: var(--danger); color: #fff; }
button:disabled { opacity: 0.55; cursor: default; }
button.link { background: none; border: none; color: var(--accent); padding: 0; font-weight: 500; }
.error { color: var(--danger); min-height: 1.5em; margin: 8px 0 0; }
ul.sessions { list-style: none; padding: 0; margin: 0; }
ul.sessions li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
ul.sessions li:first-child { border-top: none; }
code.cmd { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; }

/* ------------------------------------------------------------------ viewer */
body.viewer { background: #000; color: #e8eaee; overflow: hidden; height: 100vh; }
.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 2; display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: rgba(18, 20, 26, 0.92); border-bottom: 1px solid #2a2f38; font-size: 14px;
}
.bar .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar button { padding: 5px 10px; font-size: 13px; }
.bar button.secondary { color: #e8eaee; border-color: #3a404b; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa3b2; flex: none; }
.dot.live { background: #4fd18b; }
.dot.bad { background: #ff7a66; }
#stage {
  position: fixed; top: 41px; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center;
  outline: none; cursor: default;
}
#stage.fullscreen { top: 0; }
#screen { width: 100%; height: 100%; object-fit: contain; background: #000; }
#stage.controlling #screen { cursor: none; }
#overlay {
  position: fixed; inset: 41px 0 0 0; display: flex; align-items: center; justify-content: center; z-index: 1;
  pointer-events: none; text-align: center; padding: 16px;
}
#overlay .msg { background: rgba(18, 20, 26, 0.92); border: 1px solid #2a2f38; border-radius: 10px; padding: 16px 20px; max-width: 420px; pointer-events: auto; }
#overlay[hidden] { display: none; }
#stats { font: 12px/1.4 ui-monospace, Menlo, monospace; color: #9aa3b2; white-space: nowrap; }
.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 3;
  background: rgba(18, 20, 26, 0.95); border: 1px solid #2a2f38; border-radius: 8px; padding: 8px 14px; font-size: 14px;
}
@media (max-width: 560px) {
  #stats { display: none; }
}
