:root {
  --bg: #070a12; --panel: #0e1320; --panel2: #141a2b; --line: #222a40; --text: #e7ebf5; --muted: #8b93a8;
  --accent: #6c7bff; --accent2: #8b9cff; --green: #22c55e; --red: #ef4444; --amber: #f59e0b;
  --radius: 14px; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent2); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: #0a0e18; border: 1px solid var(--line); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
h2, h3, h4 { margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.row { display: flex; align-items: center; } .gap { gap: 8px; } .grow { flex: 1; min-width: 0; } .wrap { flex-wrap: wrap; }
.hidden, [hidden] { display: none !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: .15s; }
.btn:hover { border-color: #39425f; background: #1a2135; } .btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:hover { background: #5866f0; }
.btn.danger { background: #3a1015; border-color: #5c1a22; color: #ffb4b4; } .btn.danger:hover { background: #4a141b; }
.btn.live { background: var(--red); border-color: var(--red); color: #fff; }
.btn.go { background: var(--green); border-color: var(--green); color: #04130a; }
.btn.xs { padding: 3px 8px; font-size: 12px; border-radius: 7px; } .btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; } .btn.ghost { background: transparent; }
.btn.sel { border-color: var(--accent); background: #1b2050; }

input, select, textarea { font: inherit; color: var(--text); background: #0a0e18; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #3b46a8; border-color: transparent; }
input[type=checkbox], input[type=range] { width: auto; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: #1a2033; color: var(--muted); letter-spacing: .02em; }
.pill.red { background: var(--red); color: #fff; } .pill.green { background: #0f2f1c; color: #6ee7a0; } .pill.amber { background: #3a2a08; color: #fcd34d; }
.pill.red::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.dotst { width: 8px; height: 8px; border-radius: 50%; background: #475069; display: inline-block; flex: none; }
.dotst.on { background: var(--green); box-shadow: 0 0 0 3px #22c55e33; } .dotst.err { background: var(--red); } .dotst.wait { background: var(--amber); }
.alert { background: #2a1015; border: 1px solid #5c1a22; color: #ffc2c2; padding: 10px 12px; border-radius: 10px; margin: 10px 0; }
.note { background: #101a33; border: 1px solid #22305c; color: #c2cdfa; padding: 10px 12px; border-radius: 10px; font-size: 13px; }

.brand { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; letter-spacing: -.01em; }
.brand b { color: var(--accent2); } .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 12px var(--red); }
.brand.big { font-size: 26px; justify-content: center; margin-bottom: 8px; }

/* login */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; text-align: center; display: flex; flex-direction: column; gap: 14px; }

/* app layout */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: #070a12e6; backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top .who { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.top .who img { width: 28px; height: 28px; border-radius: 50%; }
.wrapper { max-width: 1500px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 1000px) { .grid-main { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 15px; }
.stat { font-size: 12px; color: var(--muted); }

/* program */
.program { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 700px) { .program { grid-template-columns: 1fr; } }
.monitor { position: relative; background: #000; border-radius: 12px; overflow: hidden; border: 2px solid #1d2438; display: grid; place-items: center; }
.monitor.vertical { width: min(300px, 100%); aspect-ratio: 9/16; } .monitor.landscape { width: min(520px, 100%); aspect-ratio: 16/9; }
.monitor.onair { border-color: var(--red); }
.monitor video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.monitor .over { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 20px; pointer-events: none; }
.monitor .tag { position: absolute; top: 8px; left: 8px; }
.monitor .snd { position: absolute; bottom: 8px; right: 8px; pointer-events: auto; }
.ctrl { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.fmt-tabs { display: inline-flex; background: #0a0e18; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.fmt-tabs button { border: 0; background: transparent; color: var(--muted); padding: 5px 10px; border-radius: 7px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.fmt-tabs button.on { background: var(--panel2); color: var(--text); }
.kv { display: flex; align-items: center; gap: 8px; margin: 6px 0; } .kv > span { width: 90px; flex: none; font-size: 12px; color: var(--muted); } .kv code { flex: 1; }
.blur { filter: blur(5px); cursor: pointer; }

/* sources */
.sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 12px; }
.tile { background: var(--panel2); border: 2px solid transparent; border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.tile.program { border-color: var(--red); } .tile.inscene { border-color: var(--accent); }
.tile .pv { position: relative; aspect-ratio: 16/9; background: #000; display: grid; place-items: center; }
.tile .pv video { width: 100%; height: 100%; object-fit: contain; }
.tile .pv .off { position: absolute; color: var(--muted); font-size: 12px; text-align: center; padding: 8px; }
.tile .pv .num { position: absolute; top: 6px; left: 6px; background: #000a; border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 700; }
.tile .pv .badge { position: absolute; top: 6px; right: 6px; }
.tile .info { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.tile .name { font-weight: 700; display: flex; align-items: center; gap: 6px; min-width: 0; }
.tile .name span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .meta { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .acts { display: flex; gap: 6px; }
.tile .acts .btn.take { flex: 1; }
.add-tile { border: 2px dashed var(--line); background: transparent; border-radius: 12px; min-height: 200px; display: grid; place-items: center; color: var(--muted); cursor: pointer; font-weight: 700; font: inherit; }
.add-tile:hover { border-color: var(--accent); color: var(--text); }

/* scene builder */
.layouts { display: flex; gap: 8px; flex-wrap: wrap; }
.layout-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 10px; font-size: 12px; }
.layout-btn svg { width: 34px; height: 22px; }
.slots { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.slot { display: flex; align-items: center; gap: 8px; background: var(--panel2); border-radius: 9px; padding: 6px 8px; flex-wrap: wrap; }
.slot .n { width: 20px; height: 20px; border-radius: 6px; background: #1b2050; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; }
.slot input[type=range] { width: 110px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.preset { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.preset button { border: 0; background: var(--panel2); color: var(--text); padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.preset button:hover { background: #1f2740; } .preset button.x { color: var(--muted); padding: 6px 8px; border-left: 1px solid var(--line); }

/* destinations */
.dests { display: flex; flex-direction: column; gap: 8px; }
.dest { display: flex; align-items: center; gap: 10px; background: var(--panel2); border-radius: 10px; padding: 10px; min-width: 0; }
.dest .ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.ic.tiktok { background: #111; color: #25f4ee; box-shadow: inset -2px -2px 0 #fe2c55; } .ic.youtube { background: #ff0033; color: #fff; }
.ic.twitch { background: #9146ff; color: #fff; } .ic.kick { background: #53fc18; color: #000; } .ic.facebook { background: #1877f2; color: #fff; } .ic.custom { background: #2a3250; color: #fff; }
.dest .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dest .st { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #2a3250; border-radius: 99px; cursor: pointer; transition: .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--red); } .switch input:checked + span::after { transform: translateX(18px); }

/* lists */
.users { display: flex; flex-direction: column; gap: 6px; }
.user { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.user img, .user .av { width: 26px; height: 26px; border-radius: 50%; background: #2a3250; flex: none; }
.log { font-size: 12px; color: var(--muted); max-height: 220px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.log b { color: var(--text); font-weight: 600; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 10px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: #000b; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: #1a2135; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 60; max-width: calc(100% - 32px); }
.toast.err { background: #3a1015; border-color: #5c1a22; }

/* go page */
.go-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.go-main { max-width: 640px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.go-video { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16/9; margin: 12px 0; display: grid; place-items: center; }
.go-video video { width: 100%; height: 100%; object-fit: contain; }
.go-empty { position: absolute; color: var(--muted); }
.onair { position: absolute; top: 10px; left: 10px; background: var(--red); color: #fff; font-weight: 800; padding: 3px 10px; border-radius: 6px; animation: blink 1.4s infinite; }
.go-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 10px; margin-bottom: 12px; }
