:root {
  --bg: #0e1116;
  --panel: #161b23;
  --panel-2: #1c222d;
  --border: #242c3a;
  --text: #e8edf4;
  --muted: #93a0b4;
  --accent: #4f8cff;
  --accent-2: #3b6fd4;
  --ok: #34c98e;
  --warn: #f0b23c;
  --bad: #f06a5d;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

.wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 28px 22px 60px;
}

/* ---------- header ---------- */
header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, #4f8cff, #7a5cff);
  display: grid; place-items: center;
  font-weight: 800; font-size: 20px; color: #fff;
  box-shadow: 0 4px 14px rgba(79, 140, 255, .35);
}
.brand h1 { font-size: 19px; margin: 0; font-weight: 700; letter-spacing: .2px; }
.brand .sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 999px; font-size: 13px;
  color: var(--muted); white-space: nowrap;
}
.pill .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #5b6779; flex: none;
}
.pill.connected { color: var(--ok); border-color: rgba(52, 201, 142, .4); }
.pill.connected .dot { background: var(--ok); box-shadow: 0 0 8px rgba(52, 201, 142, .8); }
.pill.joining { color: var(--warn); border-color: rgba(240, 178, 60, .4); }
.pill.joining .dot { background: var(--warn); animation: pulse 1s infinite; }
.pill.disconnected { color: var(--bad); border-color: rgba(240, 106, 93, .4); }
.pill.disconnected .dot { background: var(--bad); }
@keyframes pulse { 50% { opacity: .4; } }

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.panel h2 {
  margin: 0 0 4px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .12em; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.panel h2 .hint { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 12px; }
.panel .desc { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- probe table ---------- */
.probe-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid rgba(36, 44, 58, .7);
  min-width: 0;
}
.probe-row:last-child { border-bottom: none; }
.probe-row .name { font-size: 14px; font-weight: 600; white-space: nowrap; }
.probe-row .detail {
  grid-column: 1 / -1;
  color: var(--muted); font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}
.chip {
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em;
  padding: 3px 10px; border-radius: 999px; text-transform: uppercase;
  flex: none;
}
.chip.ok { background: rgba(52, 201, 142, .14); color: var(--ok); }
.chip.warn { background: rgba(240, 178, 60, .14); color: var(--warn); }
.chip.bad { background: rgba(240, 106, 93, .14); color: var(--bad); }
.chip.idle { background: rgba(91, 103, 121, .18); color: var(--muted); }

/* ---------- controls ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--muted); margin-bottom: 6px; letter-spacing: .03em;
}
.field input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 14.5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, .18);
}
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
button.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px; font-weight: 600;
  padding: 10px 16px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s, opacity .15s;
}
button.btn:hover:not(:disabled) { background: #232b38; border-color: #31405a; }
button.btn:active:not(:disabled) { transform: translateY(1px); }
button.btn:disabled { opacity: .45; cursor: not-allowed; }
button.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
button.btn.primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
button.btn.danger:hover:not(:disabled) { background: #3a2026; border-color: var(--bad); color: var(--bad); }

/* ---------- stage ---------- */
.stage {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  min-height: 120px;
}
.tile {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #05070a;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  min-width: 0;
}
.tile video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.tile video.mirror { transform: scaleX(-1); }
.tile .tag {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .72));
  font-size: 13px; font-weight: 600;
  pointer-events: none;
}
.tile .tag .q {
  width: 8px; height: 8px; border-radius: 50%; background: #5b6779; flex: none;
}
.q.excellent { background: var(--ok); }
.q.good { background: var(--warn); }
.q.poor { background: var(--bad); }
.q.lost, .q.unavailable { background: #5b6779; }
.tile .you {
  position: absolute; top: 8px; left: 8px;
  background: rgba(79, 140, 255, .85);
  color: #fff; font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; letter-spacing: .05em;
}
.tile.noaudio { display: grid; place-items: center; }
.tile.noaudio .ph { color: #3d4657; font-size: 13px; padding: 12px; text-align: center; }
.stage-empty {
  grid-column: 1 / -1;
  display: grid; place-items: center;
  min-height: 140px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted); font-size: 14px;
}

/* ---------- log ---------- */
.logbox {
  background: #0a0d12;
  border: 1px solid var(--border);
  border-radius: 10px;
  height: 230px;
  overflow-y: auto;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.7;
}
.logbox .line { white-space: pre-wrap; overflow-wrap: anywhere; }
.logbox .t { color: #55617a; margin-right: 8px; }
.logbox .info { color: #b8c2d4; }
.logbox .ok { color: var(--ok); }
.logbox .warn { color: var(--warn); }
.logbox .bad { color: var(--bad); }

a.link { color: var(--accent); text-decoration: none; font-weight: 600; }
a.link:hover { text-decoration: underline; }

footer.foot {
  margin-top: 26px; color: #55617a; font-size: 12.5px;
  border-top: 1px solid var(--border); padding-top: 14px;
}
footer.foot code { color: var(--muted); }
