:root {
  --bg: #0b0c0f; --bg2: #14161b; --bg3: #1c1f26; --line: #272b34; --text: #eef0f4; --muted: #8b92a1;
  --accent: #ff5a1f; --accent2: #ffb020; --good: #3ddc84; --bad: #ff4d6d;
  --twitch: #9146ff; --youtube: #ff0033; --kick: #53fc18; --discord: #5865f2; --site: #ff5a1f; --tiktok: #fe2c55;
  --safe-top: env(safe-area-inset-top); --safe-bottom: env(safe-area-inset-bottom);
  --font: -apple-system, ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.4 var(--font); overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus, textarea:focus { outline: 2px solid rgba(255,90,31,.5); border-color: transparent; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); margin-top: 8px; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 18px 4px 8px; }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; } .row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.btn { border: 1px solid var(--line); background: var(--bg3); border-radius: 10px; padding: 9px 14px; font-weight: 600; white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.good { background: var(--good); border-color: var(--good); color: #052; }
.btn.bad { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.wide { width: 100%; margin-top: 12px; }
.btn:active { transform: scale(.97); }

/* Gate */
.gate { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; }
.gate-box { text-align: center; max-width: 340px; }
.logo-big { width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 22px; background: var(--accent); display: grid; place-items: center; font: 900 50px var(--font); }
.gate h1 { margin: 0 0 6px; }
.hint { color: var(--muted); font-size: 13px; }

/* Top bar */
.bar { position: fixed; top: 0; left: 0; right: 0; z-index: 10; padding: calc(var(--safe-top) + 10px) 16px 10px; display: flex; justify-content: space-between; align-items: center;
  background: rgba(11,12,15,.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.status { display: flex; gap: 8px; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--bad); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.bar-right { display: flex; gap: 8px; align-items: center; }
.chip { background: var(--bg3); border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.conn { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.conn.ok { background: var(--good); }

main { padding: calc(var(--safe-top) + 58px) 12px calc(var(--safe-bottom) + 76px); }
.view { display: none; } .view.active { display: block; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }

/* Scenes */
.scenes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.scenes button { background: var(--bg2); border: 2px solid var(--line); border-radius: 14px; padding: 14px 4px; font-weight: 700; font-size: 13px; display: grid; gap: 4px; }
.scenes button i { font-style: normal; font-size: 22px; }
.scenes button.on { border-color: var(--accent); background: rgba(255,90,31,.14); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: var(--bg3); border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 13px; }
.chips button.on { border-color: var(--accent); color: var(--accent); }
.chips button.off { opacity: .35; }

/* Switches */
.toggles { display: grid; gap: 2px; padding: 4px 12px; }
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.toggle:last-child { border-bottom: 0; }
.toggle small { display: block; color: var(--muted); font-size: 12px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; margin: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--bg3); border: 1px solid var(--line); border-radius: 999px; transition: .2s; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--good); border-color: var(--good); }
.switch input:checked + span::after { transform: translateX(20px); }

/* Chat feed */
.filters { position: sticky; top: calc(var(--safe-top) + 50px); z-index: 5; background: var(--bg); padding: 8px 0; display: grid; gap: 8px; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.feed li { padding: 7px 8px; border-radius: 8px; line-height: 1.35; word-wrap: break-word; }
.feed li:active { background: var(--bg3); }
.feed li.hl { background: rgba(255,176,32,.12); }
.feed .p { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.feed .n { font-weight: 700; margin-right: 6px; }
.feed .t { color: var(--muted); font-size: 11px; margin-left: 4px; }
.send { position: fixed; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 60px); display: flex; gap: 8px; padding: 8px 12px; background: var(--bg); border-top: 1px solid var(--line); }
#v-chat.active ~ .send { display: flex; }

/* Queue */
.seg { display: flex; gap: 4px; overflow-x: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 10px; scrollbar-width: none; }
.seg button { flex: 1 0 auto; background: none; border: 0; padding: 8px 10px; border-radius: 9px; font-weight: 600; color: var(--muted); font-size: 13px; }
.seg button.on { background: var(--bg3); color: var(--text); }
.qlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.q { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.q-head { display: flex; justify-content: space-between; gap: 8px; }
.q-kind { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent2); }
.q-msg { margin: 6px 0; }
.q a { color: var(--accent2); word-break: break-all; }
.q-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* Stats */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.kpi { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.kpi b { display: block; font-size: 22px; } .kpi span { color: var(--muted); font-size: 12px; }
.spark { width: 100%; height: 60px; display: block; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; } th { color: var(--muted); font-weight: 600; }
td.r, th.r { text-align: right; }

/* Staff */
.perm { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.perm input { width: auto; margin-top: 3px; }
.staff { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.staff small { color: var(--muted); display: block; }

/* Tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(20,22,27,.96); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom); }
.tabbar button { background: none; border: 0; padding: 8px 0 10px; color: var(--muted); font-size: 11px; font-weight: 600; display: grid; justify-items: center; gap: 2px; position: relative; }
.tabbar button i { font-style: normal; font-size: 21px; }
.tabbar button.on { color: var(--text); }
.badge { position: absolute; top: 4px; left: 54%; background: var(--bad); color: #fff; font-size: 10px; border-radius: 999px; padding: 1px 6px; }

dialog { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 18px; width: min(440px, 94vw); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 14px 0 0; }
.toasts { position: fixed; top: calc(var(--safe-top) + 60px); left: 12px; right: 12px; display: grid; gap: 6px; z-index: 50; pointer-events: none; }
.toast { background: var(--bg3); border: 1px solid var(--line); border-left: 4px solid var(--good); border-radius: 10px; padding: 10px 12px; animation: drop .25s ease-out; }
.toast.err { border-left-color: var(--bad); }
@keyframes drop { from { transform: translateY(-8px); opacity: 0; } }
