:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c232c;
  --border: #2a323d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #4a9eff;
  --ok: #3fb950;
  --no: #f85149;
  --warn: #d29922;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); }

.wrap { margin: 0 auto; padding: 0 16px 64px; }

header.top {
  display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
  padding: 16px 0; border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
header.top h1 { font-size: 17px; margin: 0; letter-spacing: -0.01em; }
header.top h1 a { color: var(--text); text-decoration: none; }
header.top .sub { color: var(--muted); font-size: 13px; }
header.top .spacer { flex: 1; }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
}
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin: 0 0 12px; font-weight: 600; }

.cols { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .cols { grid-template-columns: minmax(0,1fr); } }

button, .btn {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 7px;
  padding: 7px 12px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { border-color: #3d4854; background: #232c37; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: #1f6feb; border-color: #1f6feb; color: #fff; }
button.primary:hover { background: #2b7bf5; }
button.ok { border-color: #2c6e37; }
button.ok:hover { background: #17301d; }
button.no { border-color: #6e2b28; }
button.no:hover { background: #30171a; }
button.tiny, .btn.tiny { padding: 3px 7px; font-size: 12px; border-radius: 5px; }

input[type=text], input[type=url], input[type=password], select {
  font: inherit; color: var(--text); background: #0d1117;
  border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px; width: 100%;
}
input[type=file] { font: inherit; color: var(--muted); width: 100%; }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }

.wrap.narrow { max-width: 420px; }
.wrap.narrow .panel { margin-bottom: 16px; }
.spacer { flex: 1; }
.empty { color: var(--muted); font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; }
.err { color: var(--no); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
progress { width: 100%; height: 10px; accent-color: var(--accent); }

/* ---- room list ---- */
.roomlist { display: grid; gap: 8px; }
.roomrow {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
}
.roomrow a.room { flex: 1; min-width: 0; color: var(--text); text-decoration: none; }
.roomrow .meta { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.badge.ready { color: var(--ok); border-color: #2c6e37; }
.badge.error { color: var(--no); border-color: #6e2b28; }
.badge.busy  { color: var(--warn); border-color: #6b5320; }

/* ---- the room ---- */
/* The stage is exactly the picture: --ar is the video's own shape, set by
   room.js, and --chrome is the height everything else on the page needs. The
   canvas on top therefore covers the picture and nothing else. */
.stage {
  --ar: 1.7778; --chrome: 300px;
  position: relative; margin: 0 auto; background: #000;
  aspect-ratio: var(--ar);
  width: min(100%, max(320px, calc((100dvh - var(--chrome)) * var(--ar))));
}
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
[data-role=coach] .stage canvas { touch-action: none; cursor: crosshair; }
[data-role=viewer] .stage canvas { pointer-events: none; }

.bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.bar input[type=range] { flex: 1; min-width: 160px; accent-color: var(--accent); }
.bar select { width: auto; }
.bar button, .bar select { min-height: 38px; } /* a finger on an iPad, not a mouse */
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.conn { font-size: 12px; color: var(--warn); }
.conn.ok { color: var(--ok); }

.pens { display: flex; gap: 8px; }
.pen { width: 38px; padding: 0; border-radius: 999px; border: 2px solid var(--border); }
.pen.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }

.share { margin-top: 16px; }
.share .code { font-size: 34px; font-weight: 700; letter-spacing: 0.08em; margin-bottom: 8px; }

/* A viewer's page is the picture and one thin bar. */
.watch { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; background: #000; }
.watch .stage { --chrome: 56px; }
.watch .bar { margin: 0; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
.watch .sub { color: var(--muted); font-size: 13px; }
/* Full screen, or on an iPhone the page's own version of it: nothing but
   the picture, with the bar laid over its foot until it fades. */
.watch.fill { position: fixed; inset: 0; z-index: 10; }
.watch.fill .stage { --chrome: 0px; }
.watch.fill .bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.55); transition: opacity 0.25s;
}
.watch.fill.quiet .bar { opacity: 0; pointer-events: none; }
.join {
  position: absolute; inset: 0; width: 100%; border: 0; border-radius: 0;
  background: rgba(0,0,0,0.6); color: #fff; font-size: 22px;
}
.join[hidden] { display: none; }
