:root {
  --bg: #0b0d10; --panel: #14181d; --line: #232a32; --text: #e8edf2; --muted: #8b97a4;
  --accent: #3ddc97; --live: #ff4d5e; --bar-h: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; }
button:hover { border-color: #3a4552; }
button:focus-visible, .tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button[aria-pressed="true"] { background: #17302a; border-color: var(--accent); color: var(--accent); }

.bar { height: var(--bar-h); display: flex; align-items: center; gap: 14px; padding: 0 14px;
  border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--live);
  box-shadow: 0 0 0 0 rgba(255,77,94,.6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(255,77,94,0); } 100% { box-shadow: 0 0 0 0 rgba(255,77,94,0); } }
.tabs { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs button { white-space: nowrap; }
.actions { display: flex; gap: 6px; }

.stage { height: calc(100dvh - var(--bar-h)); padding: 6px; }
.stage.single { display: grid; }
.stage.multi { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 6px; }

.tile { position: relative; background: #000; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); min-height: 0; }
.tile.audio { border-color: var(--accent); }
.tile video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.stage.single .tile video { }

.hud { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column;
  justify-content: space-between; padding: 8px; }
.hud > * { pointer-events: auto; }
.hud-top { display: flex; align-items: center; gap: 8px; }
.name { font-weight: 600; text-shadow: 0 1px 3px #000; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px 7px; border-radius: 5px;
  background: rgba(0,0,0,.6); color: var(--muted); }
.badge.live { background: var(--live); color: #fff; }
.badge.warn { background: #b7791f; color: #fff; }
.spacer { flex: 1; }
.hud-bottom { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #cfd8e1;
  text-shadow: 0 1px 3px #000; }
.hud button { padding: 4px 9px; font-size: 12px; background: rgba(20,24,29,.8); }
.tile .hud-top .tools, .tile .hud-bottom { opacity: 0; transition: opacity .15s; }
.tile:hover .hud-top .tools, .tile:hover .hud-bottom,
.tile:focus-within .hud-top .tools, .tile:focus-within .hud-bottom,
.tile.touch .hud-top .tools, .tile.touch .hud-bottom { opacity: 1; }
.tools { display: flex; gap: 6px; }

.unmute { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 10px 16px; background: rgba(20,24,29,.9); border-color: var(--accent); }
.empty { margin: auto; color: var(--muted); text-align: center; max-width: 40ch; }

#toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--panel);
  border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; opacity: 0; transition: opacity .2s;
  pointer-events: none; }
#toast.show { opacity: 1; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 22px; }
dialog::backdrop { background: rgba(0,0,0,.7); }
dialog h2 { margin: 0 0 12px; font-size: 16px; }
dialog input { width: 100%; padding: 9px 10px; margin-bottom: 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.err { color: var(--live); margin: 0 0 10px; }

@media (max-width: 720px) {
  .stage.multi { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-rows: auto; overflow-y: auto; }
  .stage.multi .tile { aspect-ratio: 16 / 9; }
  .brand { display: none; }
}
