:root {
  --bg: #161616; --side: #111111; --panel: #1f1f1f; --panel2: #262626; --line: #2c2c2c; --line2: #3a3a3a;
  --text: #ededed; --muted: #9a9a9a; --dim: #6f6f6f; --accent: #e0245e; --accent2: #ff4d82;
  --ok: #2fbf71; --warn: #f0b429; --bad: #ef4444; --live: #e5402e; --blue: #4f7cff;
  --r: 12px; --r-sm: 8px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 270px 1fr; min-height: 100vh; }
.shell > div { min-width: 0; }
.side { background: var(--side); border-right: 1px solid var(--line); padding: 18px 14px; display: flex;
  flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.main { padding: 36px clamp(16px, 4vw, 64px) 60px; min-width: 0; }
.wsbtn { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-sm); cursor: pointer;
  background: none; border: 0; width: 100%; text-align: left; }
.wsbtn:hover { background: var(--panel); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center;
  font-weight: 700; flex: none; border: 1px solid var(--line2); }
.wsname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wsplan { color: var(--muted); font-size: 12px; text-transform: capitalize; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.nav a, .navbtn { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--r-sm);
  text-decoration: none; color: #d8d8d8; font-weight: 500; background: none; border: 0; cursor: pointer; width: 100%; text-align: left; }
.nav a:hover, .navbtn:hover { background: var(--panel); }
.nav a.on { background: #262626; color: #fff; }
.nav svg, .navbtn svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.sep { height: 1px; background: var(--line); margin: 10px 4px; }
.sidehead { display: flex; justify-content: space-between; align-items: center; color: var(--muted); padding: 12px 10px 4px; font-weight: 500; }
.side .foot { margin-top: auto; color: var(--dim); font-size: 12px; padding: 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 2px 10px 10px; letter-spacing: .2px; }
.brand i { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.iconbtn.menubtn, .menubtn-wrap { display: none; }

/* headings & tabs */
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
h1 { font-size: 26px; font-weight: 500; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 26px 0 12px; display: flex; gap: 8px; align-items: baseline; }
h2 small { color: var(--muted); font-weight: 400; }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tab { text-decoration: none; padding: 7px 14px; border-radius: 999px; border: 0; background: none; color: #cfcfcf; cursor: pointer; font-weight: 500; }
.tab.on { background: #2d2d2d; color: #fff; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 999px;
  border: 1px solid var(--line2); background: #2a2a2a; color: #fff; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { background: #333; }
.btn.white { background: #fff; color: #111; border-color: #fff; }
.btn.white:hover { background: #e9e9e9; }
.btn.accent { background: var(--accent); border-color: var(--accent); }
.btn.accent:hover { background: var(--accent2); }
.btn.danger { background: #3a1616; border-color: #5c2121; color: #ffb4b4; }
.btn.ghost { background: none; border-color: transparent; color: #cfcfcf; }
.btn.ghost:hover { background: var(--panel2); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: none; color: #ccc; cursor: pointer;
  display: inline-grid; place-items: center; }
.iconbtn:hover { background: var(--panel2); }
label.f { display: block; margin: 0 0 14px; }
label.f > span { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 6px; font-weight: 500; }
input.in, select.in, textarea.in { width: 100%; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--line2);
  background: #141414; outline: none; }
input.in:focus, select.in:focus, textarea.in:focus { border-color: #5b5b5b; }
textarea.in { min-height: 90px; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btnrow > * { flex: 0 0 auto; }
.hint { color: var(--muted); font-size: 12.5px; }
.err { color: #ff8f8f; font-size: 13px; min-height: 18px; }
.copy { display: flex; gap: 8px; align-items: center; }
.copy input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* switch */
.sw { position: relative; width: 40px; height: 22px; flex: none; display: inline-block; }
.sw input { opacity: 0; width: 0; height: 0; }
.sw i { position: absolute; inset: 0; border-radius: 999px; background: #3b3b3b; transition: .15s; cursor: pointer; }
.sw i::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .15s; }
.sw input:checked + i { background: var(--ok); }
.sw input:checked + i::after { transform: translateX(18px); }
.sw input:focus-visible + i { outline: 2px solid #fff; outline-offset: 2px; }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: var(--muted); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #1c1c1c; }
.thumb { width: 150px; aspect-ratio: 16/9; border-radius: 6px; background: #0c0c0c center/cover no-repeat; position: relative;
  display: grid; place-items: center; color: #555; flex: none; overflow: hidden; }
.thumb .badge { position: absolute; top: 6px; left: 6px; }
.tcell { display: flex; gap: 14px; align-items: center; min-width: 0; }
.ttl { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sub { color: var(--muted); font-size: 12.5px; }
.tablewrap { overflow-x: auto; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600;
  background: #2d2d2d; color: #ddd; white-space: nowrap; }
.badge.live { background: var(--live); color: #fff; }
.badge.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.badge.ok { background: #143d27; color: #7ee2a8; }
.badge.warn { background: #3d3214; color: #f5cf6b; }
.badge.bad { background: #3d1616; color: #ff9b9b; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #666; flex: none; }
.dot.live { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.connecting { background: var(--warn); }
.dot.error { background: var(--bad); }
.plat { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 12px;
  color: #fff; flex: none; letter-spacing: .3px; border: 2px solid #2b2b2b; }
.plat.sm { width: 26px; height: 26px; font-size: 9.5px; border-width: 1px; }
.p-youtube { background: #d3202a; } .p-facebook { background: #1b6ff2; } .p-twitch { background: #7a3cf0; }
.p-kick { background: #1f9e3a; } .p-instagram { background: #c2307f; } .p-x { background: #000; border-color: #444; }
.p-linkedin { background: #0a63bc; } .p-custom { background: #555; } .p-nozara { background: var(--accent); }
.plats { display: flex; } .plats .plat { margin-left: -6px; } .plats .plat:first-child { margin-left: 0; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.empty { border: 1px solid var(--line); border-radius: var(--r); padding: 50px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: #fff; font-size: 16px; margin: 10px 0 6px; }
.empty .ico { width: 54px; height: 54px; margin: 0 auto; border-radius: 12px; border: 1px solid var(--line2); display: grid; place-items: center; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.stat b { display: block; font-size: 24px; font-weight: 600; }
.stat span { color: var(--muted); font-size: 12.5px; }

/* ingest card */
.ingest { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 26px; }
.ingest .card h3 { margin: 0 0 10px; font-size: 14px; }

/* stream studio page */
.studio { display: grid; grid-template-columns: minmax(0, 1fr) 380px 74px; gap: 16px; align-items: start; }
.stagebox { background: #000; border-radius: var(--r); overflow: hidden; position: relative; aspect-ratio: 16/9; }
.stagebox video { width: 100%; height: 100%; display: block; background: #000; object-fit: contain; }
.stagebox .ov { position: absolute; top: 14px; left: 14px; display: flex; gap: 10px; align-items: center; font-family: ui-monospace, monospace; font-size: 13px; }
.stagebox .off { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 20px; }
.stats { display: flex; gap: 10px 30px; flex-wrap: wrap; align-items: center; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px 18px; margin-top: 14px; }
.stats div b { display: block; font-weight: 600; }
.stats div span { color: var(--muted); font-size: 12.5px; }
.issues { margin-top: 10px; color: #f5cf6b; font-size: 13px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); min-height: 560px; display: flex; flex-direction: column; }
.panel .ph { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); font-weight: 600; }
.panel .pb { padding: 14px 18px; overflow-y: auto; flex: 1; }
.chrow { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.chrow:last-child { border-bottom: 0; }
.chrow .meta { flex: 1; min-width: 0; }
.chrow .nm { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.chrow .nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chrow .tt { color: #dcdcdc; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chrow .st { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.chrow .st.e { color: #ff9b9b; }
.rail { display: flex; flex-direction: column; gap: 8px; }
.rail button { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); color: #ccc; padding: 12px 4px;
  font-size: 11.5px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rail button.on { background: #2a2a2a; color: #fff; }
.rail svg { width: 20px; height: 20px; }
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg .who { font-weight: 600; margin-right: 6px; }
.msg p { margin: 0; font-size: 13.5px; word-wrap: break-word; min-width: 0; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .62); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #1b1b1b; border: 1px solid var(--line2); border-radius: 16px; width: min(560px, 100%); max-height: calc(100vh - 32px);
  overflow-y: auto; padding: 24px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.modal.wide { width: min(780px, 100%); }
.modal h3 { margin: 0 0 18px; font-size: 18px; font-weight: 600; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.pgrid button { background: var(--panel); border: 1px solid var(--line2); border-radius: var(--r); padding: 14px 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px; color: #ddd; font-weight: 500; }
.pgrid button:hover { border-color: #666; }
.menu { position: fixed; z-index: 60; background: #202020; border: 1px solid var(--line2); border-radius: 10px; padding: 6px; min-width: 190px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .5); }
.menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: #2c2c2c; }
.menu button.danger { color: #ff9b9b; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: #fff; color: #111;
  padding: 10px 18px; border-radius: 999px; font-weight: 600; opacity: 0; transition: .2s; pointer-events: none; z-index: 70; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
.progress { height: 8px; border-radius: 99px; background: #2a2a2a; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(900px 500px at 70% -10%, #3a0f22 0%, transparent 60%), var(--bg); }
.auth .card { width: min(400px, 100%); padding: 28px; }
.auth h1 { font-size: 22px; margin-bottom: 6px; }

@media (max-width: 1180px) {
  .studio { grid-template-columns: 1fr; }
  .rail { flex-direction: row; }
  .rail button { flex: 1; }
  .panel { min-height: 0; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 40; width: 280px; transform: translateX(-100%); transition: .2s; }
  .side.open { transform: none; }
  .iconbtn.menubtn { display: inline-grid; }
  .menubtn-wrap { display: block; }
  .main { padding: 20px 16px 60px; }
  .ingest { grid-template-columns: 1fr; }
  .thumb { width: 96px; }
  .pagehead h1 { font-size: 22px; }
  a.card { flex-wrap: wrap; }
  .hide-sm { display: none; }
}

/* signed-in channels */
.av { position: relative; width: 40px; height: 40px; flex: none; }
.av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid #2b2b2b; background: #222; }
.av .plat { position: absolute; right: -4px; bottom: -4px; }
.av.sm { width: 26px; height: 26px; } .av.sm .plat { width: 14px; height: 14px; font-size: 6px; }
.pgrid button.connect { border-color: #4a4a4a; }
.pgrid button:disabled { opacity: .4; cursor: not-allowed; }
.badge.pill { border: 0; cursor: pointer; text-transform: capitalize; }
.badge.pill:hover { background: #3a3a3a; }
.chrow .st a { color: #9ec1ff; }
/* stream page */
h1.editable { cursor: text; border-radius: 6px; }
h1.editable:hover { background: #1f1f1f; box-shadow: 0 0 0 6px #1f1f1f; }
input.titlein { font-size: 22px; font-weight: 500; padding: 6px 10px; }
.vbar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); opacity: 0; transition: opacity .15s; }
.stagebox:hover .vbar, .vbar:focus-within { opacity: 1; }
.vbar .iconbtn { color: #fff; background: rgba(0,0,0,.35); }
.vbar .iconbtn.on { background: var(--accent); }
.vbar input[type=range] { width: 110px; accent-color: #fff; }
.meter { display: flex; flex-direction: column; gap: 3px; width: 140px; }
.meter i { display: block; height: 5px; border-radius: 3px; background: var(--ok); width: 0; transition: width .06s linear; }
.meter i.warm { background: var(--warn); } .meter i.hot { background: var(--bad); }
.stagebox:fullscreen { border-radius: 0; }
.table tr.click, .chrow, .btn, .tab, .nav a { transition: background .12s, border-color .12s, transform .12s; }
.btn:active { transform: scale(.97); }
@media (hover: none) { .vbar { opacity: 1; } }

/* ---- Clips ---- */
.clipgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.clip { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--panel); }
.clipthumb { aspect-ratio: 16/9; background: #0c0c0c center/cover no-repeat; display: grid; place-items: center;
  color: rgba(255,255,255,.55); cursor: pointer; position: relative; }
.clipthumb:hover { color: #fff; }
.clen { position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,.72); color: #fff; font-size: 11.5px;
  padding: 2px 6px; border-radius: 5px; font-variant-numeric: tabular-nums; }
.clipmeta { padding: 10px 12px 12px; }
.clipmeta .ttl { font-weight: 600; font-size: 14px; margin-bottom: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cactions { display: flex; align-items: center; gap: 8px; }
.cactions .btn.sm { gap: 5px; }
.cactions .iconbtn { margin-left: auto; }
.working { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.spin { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--line2); border-top-color: var(--accent);
  animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
