* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: #0d1117; color: #e6edf3; font: 14px/1.4 system-ui, sans-serif; }
[hidden] { display: none !important; }

.app { display: flex; flex-direction: column; height: 100%; padding: 12px; gap: 10px; }

.bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.title { font-weight: 600; }
.pill { background: #1f6feb33; color: #58a6ff; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.spacer { flex: 1; }
button { background: #21262d; color: #e6edf3; border: 1px solid #30363d; border-radius: 6px; padding: 4px 10px; cursor: pointer; font: inherit; font-size: 13px; }
button.on { background: #1f6feb; border-color: #1f6feb; }
button:focus-visible { outline: 2px solid #58a6ff; outline-offset: 1px; }

/* Stage: 1 column on narrow screens, 2 from 900px. Tiles keep 16:9. */
.stage { flex: 1; min-height: 0; overflow-y: auto; display: grid; gap: 8px; grid-template-columns: 1fr; align-content: start; }
@media (min-width: 900px) { .stage { grid-template-columns: repeat(2, 1fr); } }

/* Focus ("A"): big tile on the left, the rest stacked on the right. */
.stage.focus { grid-template-columns: 1fr; align-content: stretch; }
@media (min-width: 900px) {
  .stage.focus { grid-template-columns: 3fr 1fr; grid-template-rows: repeat(var(--side-count, 1), minmax(0, 1fr)); overflow: hidden; }
  .stage.focus .tile { aspect-ratio: auto; min-height: 0; }
  .stage.focus .tile.max { grid-column: 1; grid-row: 1 / span var(--side-count, 1); }
  .stage.focus .tile:not(.max) { grid-column: 2; }
}

.tile { position: relative; border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; background: #161b22; border: 1px solid #30363d; }
.tile.hidden { display: none; }
.video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile.offline .video, .tile.connecting .video { visibility: hidden; }

.placeholder, .paused { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; text-align: center; padding: 16px; font-size: 14px; }
.placeholder { color: #6e7681; background: repeating-linear-gradient(45deg, #161b22 0 12px, #1c2128 12px 24px); }
.tile.offline .placeholder, .tile.connecting .placeholder { display: flex; }
.paused { color: #e6edf3; background: #0d1117b3; }
.tile.stalled .paused { display: flex; }

.label { position: absolute; left: 8px; top: 8px; display: flex; gap: 6px; align-items: center; font-size: 13px; background: #0008; padding: 3px 8px; border-radius: 6px; max-width: calc(100% - 90px); }
.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #6e7681; }
.tile.live:not(.stalled) .dot, .chip.live .dot { background: #f85149; box-shadow: 0 0 6px #f85149; }

.ctrl { position: absolute; right: 8px; top: 8px; display: flex; gap: 4px; }
.ctrl button { background: #000a; color: #fff; border: 1px solid #fff3; border-radius: 5px; width: 28px; height: 26px; padding: 0; font-size: 14px; }
.ctrl button:hover { background: #1f6feb; }

.meta { position: absolute; left: 8px; bottom: 8px; font-size: 11px; color: #c9d1d9; background: #0008; padding: 2px 6px; border-radius: 4px; }
.meta:empty { display: none; }

.empty { grid-column: 1 / -1; padding: 40px 0; text-align: center; color: #8b949e; }

.tray { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-height: 30px; font-size: 13px; color: #8b949e; }
.chip { display: flex; gap: 6px; align-items: center; border-radius: 999px; padding: 3px 10px; }
.chip:hover { border-color: #58a6ff; }

.message { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; font-size: 20px; background: #0d1117; }

/* Join, pilot and admin pages. */
.page { max-width: 560px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.page.wide { max-width: 860px; }
.page h1 { font-size: 20px; margin: 0; }
.page h2 { font-size: 15px; margin: 0 0 10px; }
.page p { margin: 0; }
.muted { color: #8b949e; }

.card { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { margin-bottom: 0; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: #8b949e; }
input[type="text"], input[type="password"] { background: #0d1117; color: #e6edf3; border: 1px solid #30363d; border-radius: 6px; padding: 6px 10px; font: inherit; min-width: 0; }
input:focus-visible { outline: 2px solid #58a6ff; outline-offset: 1px; }
input[readonly] { font-family: ui-monospace, monospace; font-size: 13px; }
.copy-row { display: flex; gap: 6px; }
.copy-row input { flex: 1; }
.copy-row button { min-width: 84px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row input { flex: 1; min-width: 160px; }
.row.end { justify-content: flex-end; }

button.primary { background: #1f6feb; border-color: #1f6feb; }
button.danger { color: #ff7b72; }
button.danger:hover { border-color: #f85149; }
button:disabled { opacity: 0.5; cursor: default; }

.status { font-size: 16px; color: #8b949e; }
.status.good { color: #3fb950; }
.status.warn { color: #d29922; }
.tip { color: #8b949e; }
.tip.strong { background: #d2992226; border: 1px solid #d29922; color: #e6edf3; border-radius: 8px; padding: 12px 14px; font-size: 16px; font-weight: 600; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }

.error { color: #ff7b72; }
.login form { display: flex; flex-direction: column; gap: 10px; }

.pilots { width: 100%; border-collapse: collapse; }
.pilots th { text-align: left; font-size: 12px; font-weight: 400; color: #8b949e; padding: 4px 8px; }
.pilots td { padding: 6px 8px; border-top: 1px solid #30363d; vertical-align: middle; }
.pilots .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pilots .dot { display: inline-block; vertical-align: middle; }
.pilots tr.live .dot { background: #f85149; box-shadow: 0 0 6px #f85149; }
.pilots tr.revoked { opacity: 0.5; }
.pilots tr.revoked .pilot-name { text-decoration: line-through; }

dialog { background: #161b22; color: #e6edf3; border: 1px solid #30363d; border-radius: 8px; padding: 16px; max-width: 420px; width: calc(100% - 32px); }
dialog::backdrop { background: #000a; }
dialog[open] { display: flex; flex-direction: column; gap: 12px; }
dialog p { margin: 0; }
#panels { display: flex; flex-direction: column; gap: 14px; }
