:root {
  --bg: #0e0f13; --panel: #171920; --line: #262933; --text: #e8e9ee;
  --muted: #8b8f9c; --accent: #7c9cff; --ok: #4ade80; --bad: #f87171;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; height: 100dvh; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input { font: inherit; color: inherit; }
button { background: var(--accent); color: #0b0d14; border: 0; border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-weight: 600; }
button.link { background: none; color: var(--muted); padding: 0; font-weight: 400; }
input { background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; width: 100%; }
.muted { color: var(--muted); }

.login { display: grid; place-items: center; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px; width: min(340px, 92vw); display: grid; gap: 14px; }
.card h1 { margin: 0 0 4px; font-size: 20px; }
.card label { display: grid; gap: 6px; color: var(--muted); }
.err { color: var(--bad); margin: 0; }

body:not(.login) { display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
header #now-title { overflow: hidden; text-overflow: ellipsis; }
header form { margin: 0; }
.spacer { flex: 1; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--line); }
.pill.ok { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.pill.bad { background: color-mix(in srgb, var(--bad) 20%, transparent); color: var(--bad); }

main { flex: 1; display: grid; grid-template-columns: 1fr 320px; min-height: 0; }
.stage { position: relative; display: grid; place-items: center; background: #000; min-height: 0; }
.player { position: relative; width: 100%; height: 100%; }
video { width: 100%; height: 100%; background: #000; display: block; }
.overlay { position: absolute; inset: 0; margin: auto; height: fit-content; width: fit-content;
  color: var(--muted); }
.overlay.big { font-size: 18px; padding: 14px 22px; color: #0b0d14; }
.toast { position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(20,22,28,.9); border: 1px solid var(--line); padding: 6px 12px;
  border-radius: 8px; pointer-events: none; }

aside { display: grid; grid-template-rows: 1fr 40%; border-left: 1px solid var(--line); min-height: 0; }
.panel { display: flex; flex-direction: column; min-height: 0; padding: 10px; gap: 8px; }
.panel + .panel { border-top: 1px solid var(--line); }
.row { display: flex; gap: 6px; }
.row button { padding: 6px 12px; }
ul { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#library li { padding: 7px 8px; border-radius: 6px; cursor: pointer; word-break: break-word; }
#library li:hover { background: var(--line); }
#library li.active { background: color-mix(in srgb, var(--accent) 22%, transparent); }
#library li small { display: block; color: var(--muted); }
#messages li { padding: 3px 0; word-break: break-word; }
#messages li b { color: var(--accent); }
#messages li.sys { color: var(--muted); font-style: italic; }

/* Phones, and tablets held upright: video full width on top, library below. */
@media (max-width: 800px), (orientation: portrait) {
  main { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .stage { aspect-ratio: 16 / 9; }
  aside { border-left: 0; grid-template-rows: 1fr 1fr; }
  header #users { display: none; }
}
