:root {
  --bg: #0d1117; --panel: #161b22; --line: #30363d; --fg: #e6edf3; --dim: #8b949e;
  --ok: #3fb950; --warn: #d29922; --err: #f85149; --live: #f85149; --accent: #58a6ff;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); min-height: 100vh; }

header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; padding: 0.9rem 1.25rem; border-bottom: 1px solid var(--line);
}
h1 { font-size: 1.05rem; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.tag {
  font-size: 0.7rem; font-weight: 500; color: var(--dim); border: 1px solid var(--line);
  padding: 0.15rem 0.45rem; border-radius: 999px; margin-left: 0.4rem; vertical-align: middle;
}

.pipeline { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.hop {
  font-size: 0.7rem; padding: 0.25rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--dim); transition: all 0.25s;
}
.hop.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.hop.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.hop.err { color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, transparent); }

main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; padding: 1.25rem; align-items: start; }
main.single { grid-template-columns: minmax(0, 1fr) 320px; }
@media (max-width: 900px) { main, main.single { grid-template-columns: 1fr; } }

.stage { display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }
.video {
  width: 100%; aspect-ratio: 16 / 9; background: #000; border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.placeholder { color: var(--dim); font-size: 0.85rem; }

.controls { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
button {
  font: inherit; font-size: 0.85rem; font-weight: 500; padding: 0.55rem 1rem;
  border-radius: 7px; border: 1px solid var(--line); background: var(--panel);
  color: var(--fg); cursor: pointer; transition: all 0.15s;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #06131f; }
button.live { background: var(--live); border-color: var(--live); color: #fff; }
button.danger { border-color: color-mix(in srgb, var(--err) 50%, transparent); color: var(--err); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
.row { display: flex; justify-content: space-between; gap: 0.75rem; padding: 0.45rem 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); font-size: 0.8rem; }
.row:last-of-type { border-bottom: none; }
.row span { color: var(--dim); flex-shrink: 0; }
.row.full { flex-direction: column; gap: 0.3rem; }
.row code, .row a { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.75rem; text-align: right; }
.row.full code, .row.full a { text-align: left; }
.wrap { word-break: break-all; color: var(--dim); }
a { color: var(--accent); }

.status { color: var(--dim); }
.s-live { color: var(--ok); } .s-degraded { color: var(--warn); }
.s-failed { color: var(--err); } .s-ended { color: var(--dim); }

h2 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); margin: 1.1rem 0 0.5rem; }
.log {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.7rem; line-height: 1.6;
  max-height: 260px; overflow-y: auto; margin: 0; white-space: pre-wrap; color: var(--dim);
}
.log .ok { color: var(--ok); } .log .err { color: var(--err); } .log .warn { color: var(--warn); }
.latency code { font-family: ui-monospace, monospace; color: var(--accent); font-size: 0.85rem; }

/* ---- multi-guest + scene switching ---- */
.text {
  font: inherit; font-size: 0.85rem; padding: 0.55rem 0.8rem; border-radius: 7px;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg); min-width: 11rem;
}
.text:focus { outline: none; border-color: var(--accent); }

.scenes { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; }
.scene {
  display: flex; flex-direction: column; gap: 0.15rem; align-items: flex-start;
  padding: 0.55rem 0.7rem; text-align: left;
}
.scene b { font-size: 0.82rem; font-weight: 600; }
.scene small { font-size: 0.65rem; color: var(--dim); }
.scene.active {
  border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.scene.active b { color: var(--accent); }

.hint { font-size: 0.65rem; color: var(--dim); text-transform: none; letter-spacing: 0; margin-left: 0.4rem; }

.people { list-style: none; margin: 0 0 0.6rem; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.people .empty { font-size: 0.75rem; color: var(--dim); padding: 0.4rem 0; }
.person {
  display: flex; align-items: center; gap: 0.55rem; cursor: pointer; user-select: none;
  padding: 0.4rem 0.55rem; border-radius: 7px; border: 1px solid var(--line);
  background: var(--bg); transition: all 0.15s;
}
.person:hover { border-color: var(--accent); }
.person.picked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.person .slot {
  width: 1.35rem; height: 1.35rem; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.7rem; font-weight: 600;
  border: 1px solid var(--line); color: var(--dim);
}
.person.picked .slot { background: var(--accent); border-color: var(--accent); color: #06131f; }
.person .who { display: flex; flex-direction: column; font-size: 0.78rem; line-height: 1.3; min-width: 0; }
.person .who small { font-size: 0.63rem; color: var(--dim); }
.person .tally {
  margin-left: auto; font-size: 0.58rem; font-weight: 700; letter-spacing: 0.05em;
  color: var(--live); border: 1px solid color-mix(in srgb, var(--live) 50%, transparent);
  padding: 0.1rem 0.35rem; border-radius: 3px; flex-shrink: 0;
}
.person.onair { border-color: color-mix(in srgb, var(--live) 45%, transparent); }

/* ---- multiview: program preview + source grid ---- */
.program-wrap { position: relative; }
.video.program { position: relative; background: #000; overflow: hidden; }
.onair-badge {
  position: absolute; top: 0.6rem; left: 0.6rem; z-index: 50;
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.08em;
  padding: 0.2rem 0.5rem; border-radius: 4px;
  background: rgba(0,0,0,0.65); color: var(--dim); border: 1px solid var(--line);
}
.onair-badge.live {
  background: var(--live); color: #fff; border-color: var(--live);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.65; } }

/* Regions are positioned in percentages of the canvas, so the preview matches the
   composite at any size. */
.region { position: absolute; overflow: hidden; background: #05070a; }
.region video { width: 100%; height: 100%; object-fit: cover; display: block; }
.region .rlabel {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 0.2rem 0.4rem;
  font-size: 0.6rem; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,0.75));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.region.missing { display: grid; place-items: center; border: 1px dashed var(--warn); }
.region.missing::after {
  content: 'no video'; font-size: 0.65rem; color: var(--warn);
}

.sources-title { margin: 0.2rem 0 0.5rem; }
.sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.5rem; }
.sources .empty {
  grid-column: 1 / -1; font-size: 0.75rem; color: var(--dim);
  border: 1px dashed var(--line); border-radius: 8px; padding: 1rem; text-align: center;
}
.source {
  position: relative; padding: 0; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: 8px; border: 2px solid var(--line); background: #000; cursor: pointer;
}
.source video { width: 100%; height: 100%; object-fit: cover; display: block; }
.source:hover { border-color: var(--accent); }
.source.picked { border-color: var(--accent); }
.source.onair { border-color: var(--live); }
.source.is-screen { border-style: dashed; }
.source .slot {
  position: absolute; top: 0.3rem; left: 0.3rem; width: 1.2rem; height: 1.2rem;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--accent); color: #06131f; font-size: 0.65rem; font-weight: 700;
}
.source .tally {
  position: absolute; top: 0.3rem; right: 0.3rem;
  font-size: 0.52rem; font-weight: 700; letter-spacing: 0.05em;
  background: var(--live); color: #fff; padding: 0.1rem 0.3rem; border-radius: 3px;
}
.source .label {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 0.2rem 0.35rem;
  font-size: 0.6rem; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,0.8));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left;
}
.wide-scene { grid-column: 1 / -1; }

/* ---- guest stage: what everyone else in the room is sending ---- */
.main-label {
  position: absolute; bottom: 0.6rem; left: 0.6rem; z-index: 50;
  font-size: 0.65rem; color: #fff; background: rgba(0,0,0,0.65);
  border: 1px solid var(--line); border-radius: 4px; padding: 0.2rem 0.5rem;
}
.video.main { position: relative; }
.video.main video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }

.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.5rem; }
.strip .empty {
  grid-column: 1 / -1; font-size: 0.75rem; color: var(--dim);
  border: 1px dashed var(--line); border-radius: 8px; padding: 0.9rem; text-align: center;
}
.tile {
  position: relative; padding: 0; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: 8px; border: 2px solid var(--line); background: #000; cursor: pointer;
}
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile:hover { border-color: var(--accent); }
/* Your own camera is not something you can pin — it is here for reassurance only. */
.tile.self { border-style: dotted; cursor: default; }
.tile.is-screen { border-style: dashed; }
.tile.pinned { border-color: var(--accent); }
.tile .label {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 0.2rem 0.35rem;
  font-size: 0.6rem; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,0.8));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left;
}
.tile .audio-only {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 0.65rem; color: var(--dim);
}
