:root {
  --bg: #0b1220; --card: #111a2e; --line: #23304d; --text: #e7ecf5; --muted: #93a1bd;
  --accent: #3b82f6; --accent-2: #2563eb; --ok: #22c55e; --bad: #ef4444; --talk: #f59e0b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 2;
}
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 18px; margin: 0; }
h3 { margin: 0 0 8px; }
main { max-width: 960px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-top: 12px; }
#login-form { max-width: 380px; margin: 40px auto; display: grid; gap: 12px; }
label { display: grid; gap: 4px; color: var(--muted); font-size: 14px; }
input {
  font: inherit; color: var(--text); background: #0d1527; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
button {
  font: inherit; color: #fff; background: var(--accent); border: 0; border-radius: 8px; padding: 10px 14px; cursor: pointer;
  min-height: 44px; touch-action: manipulation;
}
button:hover { background: var(--accent-2); }
button:disabled { opacity: .45; cursor: default; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.err { color: var(--bad); margin: 0; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
#devices { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
#devices li {
  display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
}
#devices .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); flex: none; }
#devices .dot.on { background: var(--ok); }
#devices .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#devices .id { color: var(--muted); font-size: 12px; }
#devices .acts { display: flex; gap: 6px; }
#devices .acts button { padding: 8px 10px; min-height: 40px; }
.code { font: 700 40px/1.2 ui-monospace, Consolas, monospace; letter-spacing: 6px; margin: 4px 0; }
ol { padding-left: 20px; color: var(--muted); }
.stage { position: relative; margin-top: 12px; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 704 / 576; }
video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.status {
  position: absolute; left: 12px; top: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(0,0,0,.6); font-size: 13px;
}
.status.live { color: var(--ok); }
.controls { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.talk { background: #334155; user-select: none; -webkit-user-select: none; }
.talk.active { background: var(--talk); color: #111; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-left: auto; }
.seg button { background: transparent; border-radius: 0; color: var(--muted); min-width: 56px; }
.seg button.on { background: var(--accent); color: #fff; }
@media (max-width: 520px) {
  main { padding: 12px; }
  .controls button { flex: 1; }
  .seg { margin-left: 0; width: 100%; }
  .seg button { flex: 1; }
}
