:root {
  --bg: #0a0d14;
  --bg2: #0f1420;
  --card: rgba(24, 30, 44, 0.78);
  --line: rgba(148, 163, 184, 0.16);
  --text: #e8edf6;
  --muted: #8794ab;
  --accent: #38bdf8;
  --out: #34d399;
  --in: #60a5fa;
  --warn: #fbbf24;
  --red: #f87171;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, #14213d 0%, transparent 60%),
              radial-gradient(900px 500px at 100% 0%, #0f2f2a 0%, transparent 55%),
              var(--bg);
  background-attachment: fixed;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, Menlo, monospace; }
h1, h2, h3 { margin: 0; }
h2 { font-size: 0.95rem; letter-spacing: 0.08em; text-transform: uppercase; color: #cbd5e1; }
h3 { font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; }

input, select, button { font: inherit; color: var(--text); }
input, select {
  background: rgba(8, 11, 18, 0.7);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15); }

.btn {
  border: 1px solid var(--line);
  background: rgba(30, 38, 56, 0.9);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: rgba(148, 163, 184, 0.45); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, #0ea5e9, #2563eb); border-color: transparent; }
.btn-danger { background: rgba(248, 113, 113, 0.16); border-color: rgba(248, 113, 113, 0.5); color: #fecaca; }
.btn-ghost { background: transparent; }
.btn-rec { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.5); color: #fecaca; }
.btn-rec.active { background: var(--red); color: #1a0505; }

.btn-big {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 22px 16px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  background: rgba(51, 65, 85, 0.8);
  box-shadow: inset 0 0 0 1px var(--line);
  margin-bottom: 8px;
  transition: all 0.12s ease;
}
.btn-big.live { background: linear-gradient(135deg, #059669, #10b981); color: #03140d; }
.btn-big.muted { background: linear-gradient(135deg, #b91c1c, #ef4444); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
.btn-big.talk { background: linear-gradient(135deg, #d97706, #fbbf24); color: #1c1203; box-shadow: 0 0 28px rgba(251, 191, 36, 0.45); }

@keyframes pulse { 50% { filter: brightness(1.25); } }

.rec-banner {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(90deg, #991b1b, #ef4444, #991b1b);
  text-align: center; font-weight: 800; letter-spacing: 0.12em; padding: 10px;
}
.rec-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #fff; margin-right: 8px; animation: pulse 1s infinite; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 420px;
  background: var(--card); backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 22px; padding: 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.login-card label { display: block; margin: 14px 0 0; font-size: 0.85rem; color: var(--muted); }
.login-card input, .login-card select { width: 100%; margin-top: 6px; color: var(--text); }
.login-card .btn { width: 100%; margin-top: 20px; padding: 12px; }
.error-text { color: var(--red); min-height: 1.3em; margin: 10px 0 0; }
.brand { font-weight: 800; letter-spacing: 0.03em; display: inline-flex; align-items: center; gap: 8px; }
.brand.big { font-size: 1.35rem; margin-bottom: 6px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }

.topbar {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 20px; position: sticky; top: 0; z-index: 50;
  background: rgba(10, 13, 20, 0.8); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top-left, .top-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; background: rgba(148, 163, 184, 0.14); }
.chip-room { background: rgba(56, 189, 248, 0.14); color: #bae6fd; }
.status-pill { padding: 3px 10px; border-radius: 999px; background: rgba(52, 211, 153, 0.15); color: var(--out); font-size: 0.78rem; font-weight: 700; }

.settings { position: relative; }
.settings summary { list-style: none; display: inline-block; }
.settings summary::-webkit-details-marker { display: none; }
.settings-body {
  position: absolute; right: 0; top: 46px; z-index: 60; width: 300px;
  display: grid; gap: 10px; padding: 16px;
  background: #121826; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.settings-body label { display: grid; gap: 4px; font-size: 0.8rem; color: var(--muted); }

.grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; padding: 16px 20px 40px; max-width: 1500px; margin: 0 auto; }
.card { background: var(--card); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.flow-card, .mixer-card { grid-column: 1 / -1; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 0.85rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.checkbox { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.video-stage { background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; }
#pgmVideo { width: 100%; height: 100%; object-fit: contain; }
.downloads a { display: block; margin-top: 6px; color: var(--accent); text-decoration: none; font-size: 0.85rem; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.78rem; color: var(--muted); }
.lg { display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }
.lg-out { background: var(--out); }
.lg-in { background: var(--in); }
.lg-idle { background: #475569; }
.lg-mute { background: var(--red); }

#flowSvg { width: 100%; height: auto; max-height: 440px; display: block; }
.edge { fill: none; stroke-width: 2.5; stroke-linecap: round; transition: opacity 0.2s, stroke 0.2s; }
.edge.other { stroke: #64748b; opacity: 0.22; stroke-width: 2; }
.edge.out { stroke: var(--out); stroke-width: 3.5; }
.edge.in { stroke: var(--in); stroke-width: 3.5; }
.edge.live.out, .edge.live.in, .edge.live.other { stroke-dasharray: 9 6; animation: flow 0.7s linear infinite; }
.edge.gated, .edge.off { stroke: #475569; stroke-dasharray: 3 6; opacity: 0.35; }
.edge.muted { stroke: var(--red); stroke-dasharray: 3 5; opacity: 0.9; }
@keyframes flow { to { stroke-dashoffset: -15; } }
.edge-label { font-size: 10.5px; fill: #94a3b8; text-anchor: middle; letter-spacing: 0.04em; }
.edge-label.dim { opacity: 0.35; }

.node rect.box { fill: #131a2a; stroke: rgba(148, 163, 184, 0.25); stroke-width: 1.5; }
.node.present rect.box { stroke: rgba(148, 163, 184, 0.55); }
.node.me rect.box { stroke: var(--accent); stroke-width: 2.5; fill: #10243a; }
.node.talk rect.box { filter: drop-shadow(0 0 10px rgba(52, 211, 153, 0.7)); }
.node .role-t { font-size: 10.5px; fill: #94a3b8; letter-spacing: 0.12em; font-weight: 700; }
.node .name-t { font-size: 16px; font-weight: 700; fill: #f1f5f9; }
.node.absent .name-t { fill: #64748b; font-weight: 500; font-style: italic; }
.node .dot { fill: #475569; }
.node.present .dot { fill: var(--out); }
.node .m-bg { fill: #0a0e17; }
.node .m-fill { fill: var(--out); }
.node .me-badge { fill: var(--accent); }
.node .me-t { font-size: 9px; font-weight: 800; fill: #04121c; text-anchor: middle; }

.flow-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
.flow-col { background: rgba(8, 11, 18, 0.5); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.flow-col h4 { margin: 0 0 8px; font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase; }
.flow-col.out h4 { color: var(--out); }
.flow-col.in h4 { color: var(--in); }
.flow-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.flow-col li { display: flex; justify-content: space-between; gap: 8px; font-size: 0.9rem; }
.flow-col li .st { font-size: 0.74rem; padding: 1px 8px; border-radius: 999px; background: rgba(148, 163, 184, 0.14); color: var(--muted); white-space: nowrap; }
.flow-col li.live .st { background: rgba(52, 211, 153, 0.16); color: var(--out); }
.flow-col li.muted .st { background: rgba(248, 113, 113, 0.16); color: var(--red); }
.flow-col li.off { opacity: 0.5; }

.mixer-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.strip { background: rgba(8, 11, 18, 0.55); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.strip.local { border-color: rgba(56, 189, 248, 0.45); }
.strip-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.strip-name { font-weight: 700; font-size: 1rem; margin-bottom: 4px; word-break: break-word; }
.strip .chip { background: rgba(148, 163, 184, 0.14); }
.strip.role-host .chip { background: rgba(251, 191, 36, 0.16); color: #fde68a; }
.strip.role-actor .chip { background: rgba(52, 211, 153, 0.16); color: #a7f3d0; }
.strip.role-director1 .chip, .strip.role-director2 .chip { background: rgba(96, 165, 250, 0.16); color: #bfdbfe; }
.mute-btn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: rgba(30, 38, 56, 0.9); font-weight: 800; cursor: pointer; }
.mute-btn.on { background: var(--red); color: #1a0505; border-color: transparent; }
.meter {
  position: relative; height: 14px; border-radius: 7px; overflow: hidden; margin-bottom: 10px;
  background: #05070c; box-shadow: inset 0 0 0 1px var(--line);
}
.meter::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0, transparent calc(10% - 1px), rgba(255,255,255,0.08) calc(10% - 1px), rgba(255,255,255,0.08) 10%);
}
.meter-fill { height: 100%; width: 100%; clip-path: inset(0 100% 0 0); background: linear-gradient(90deg, #10b981 0%, #84cc16 60%, #fbbf24 82%, #ef4444 100%); }
.meter-hold { position: absolute; top: 0; bottom: 0; width: 3px; left: 0; background: #f8fafc; opacity: 0.85; }
.meter.clip { box-shadow: inset 0 0 0 1px var(--red), 0 0 10px rgba(248, 113, 113, 0.6); }
.fader-row { display: flex; align-items: center; gap: 10px; }
.fader-row .db { min-width: 72px; text-align: right; font-size: 0.82rem; font-variant-numeric: tabular-nums; color: #cbd5e1; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; background: transparent; padding: 0; border: 0; box-shadow: none; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: #1f2a3f; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; background: #e2e8f0; border: 3px solid #0ea5e9; cursor: pointer; }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: #1f2a3f; }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #e2e8f0; border: 3px solid #0ea5e9; }
.strip-status { margin-top: 10px; font-size: 0.78rem; color: var(--muted); }
.strip-status.live { color: var(--out); }
.strip-status.gated { color: #94a3b8; }
.strip-status.muted { color: var(--red); }

@media (max-width: 1000px) {
  .grid { grid-template-columns: 1fr; }
  .flow-lists { grid-template-columns: 1fr; }
}
