:root {
  --bg: #0b0d10;
  --panel: #14181d;
  --line: #242a32;
  --text: #e9edf1;
  --muted: #8a95a3;
  --accent: #ff4d3d;
  --ok: #3ddc84;
  --warn: #ffb020;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; }
a { color: var(--text); }
.muted { color: var(--muted); }
.err { color: var(--accent); margin: 0; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 32px 24px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.logo { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto; }
.card h1 { margin: 0; font-size: 1.5rem; letter-spacing: -.01em; }
.card p { margin: 0; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: #0f1216;
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
textarea { min-height: 70px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
button, .btn { font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 12px 18px;
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; display: inline-block; text-align: center; }
button.ghost, .btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
button:disabled { opacity: .6; cursor: default; }

/* ---------- speler ---------- */
.player { height: 100vh; height: 100dvh; display: flex; flex-direction: column; max-width: 1280px; margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom)); gap: 12px; }
.player header, .player footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.title { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 1.1rem; min-width: 0; }
.title span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; transition: background .3s; }
.dot.on { background: var(--accent); box-shadow: 0 0 0 4px rgba(255,77,61,.18); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(255,77,61,.05); } }
.meta { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.screen { position: relative; width: min(100%, calc(56dvh * 16 / 9)); aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--line); margin: 0 auto; flex: none; }
.screen video { width: 100%; height: 100%; display: block; background: #000; }
.overlay { position: absolute; inset: 0; width: 100%; border-radius: 0; background: rgba(0,0,0,.55);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: #fff; padding: 16px; }
.overlay[hidden] { display: none; }
.overlay:disabled { opacity: 1; }
.overlay .play { width: 76px; height: 76px; border-radius: 50%; background: var(--accent); display: grid;
  place-items: center; font-size: 30px; padding-left: 4px; box-shadow: 0 10px 40px rgba(255,77,61,.35); }
.overlay .spin { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(255,255,255,.2);
  border-top-color: #fff; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ovtext { font-weight: 600; font-size: 1.05rem; max-width: 26ch; text-align: center; }
.player footer { font-size: .9rem; }
.player nav { display: flex; gap: 16px; }
.player nav a { color: var(--muted); text-decoration: none; }
.player nav a:hover { color: var(--text); }

/* ---------- beheer ---------- */
.admin { max-width: 760px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 48px; }
.admin h1 { font-size: 1.4rem; margin: 8px 0 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.admin h1 a { font-size: .9rem; font-weight: 500; color: var(--muted); }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.box h2 { font-size: 1rem; margin: 0 0 12px; }
.grid { display: grid; gap: 14px; }
@media (min-width: 620px) { .grid.two { grid-template-columns: 1fr 1fr; } }
label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--muted); }
label small { color: var(--muted); opacity: .8; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stat { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: .92rem; }
.stat dt { color: var(--muted); }
.stat dd { margin: 0; word-break: break-all; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .82rem; font-weight: 600; }
.pill.ok { background: rgba(61,220,132,.15); color: var(--ok); }
.pill.off { background: rgba(138,149,163,.15); color: var(--muted); }
.pill.bad { background: rgba(255,77,61,.15); color: var(--accent); }
.notice { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: .92rem; }
.notice.ok { background: rgba(61,220,132,.12); color: var(--ok); }
.notice.bad { background: rgba(255,77,61,.12); color: #ff8a7d; }
.notice.warn { background: rgba(255,176,32,.12); color: var(--warn); }
pre { background: #0f1216; border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow: auto;
  font-size: .78rem; line-height: 1.4; max-height: 320px; margin: 0; white-space: pre-wrap; word-break: break-all; }

.ver { color: var(--muted); opacity: .6; font-size: .78rem; font-variant-numeric: tabular-nums; margin: 0; }

/* ---------- chat ---------- */
.chat { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.chat-head { display: flex; align-items: baseline; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.chat-title { font-weight: 650; }
.present { color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.msgs { list-style: none; margin: 0; padding: 10px 12px 12px; flex: 1 1 0; min-height: 80px; overflow-y: auto;
  overscroll-behavior: contain; display: flex; flex-direction: column; gap: 2px; -webkit-overflow-scrolling: touch; }
.msgs li.m { display: flex; flex-direction: column; align-items: flex-start; max-width: 85%; margin-top: 8px; }
.msgs li.m.grouped { margin-top: 0; }
.msgs li.mine { align-self: flex-end; align-items: flex-end; }
.who { display: flex; gap: 8px; align-items: baseline; font-size: .78rem; margin: 0 4px 2px; }
.who b { color: hsl(var(--h) 75% 68%); font-weight: 650; }
.mine .who b { color: var(--muted); }
.who time { color: var(--muted); opacity: .8; }
.bubble { background: #1f252d; padding: 7px 11px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: .95rem; line-height: 1.35; border-top-left-radius: 5px; }
.grouped .bubble { border-top-left-radius: 14px; }
.mine .bubble { background: var(--accent); color: #fff; border-top-left-radius: 14px; border-top-right-radius: 5px; }
.mine.grouped .bubble { border-top-right-radius: 14px; }
.msgs li.sys { align-self: center; color: var(--muted); font-size: .8rem; margin: 8px 0; text-align: center; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); align-items: flex-end; }
.chat-form input, .chat-form textarea { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 20px; resize: none;
  font-family: inherit; font-size: 16px; line-height: 1.35; min-height: 42px; }
.chat-form button { border-radius: 50%; width: 42px; height: 42px; padding: 0; flex: none; font-size: 1rem; }
#nameForm button { border-radius: 20px; width: auto; padding: 0 16px; }
.chat-err { margin: 0; padding: 0 14px 10px; color: #ff8a7d; font-size: .85rem; }
.chat-err[hidden] { display: none; }
.newmsg { position: absolute; left: 50%; transform: translateX(-50%); bottom: 70px; padding: 6px 14px;
  font-size: .82rem; border-radius: 99px; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.newmsg[hidden] { display: none; }
@media (max-height: 560px) {
  .player { height: auto; min-height: 100dvh; }
  .chat { min-height: 340px; }
}
.chat-form[hidden] { display: none; }
