:root {
  --bg: #0f1117; --panel: #171a23; --panel-2: #1e2230; --border: #2a2f3d;
  --text: #e8eaf0; --muted: #9aa0b4; --accent: #ff4d4d; --accent-2: #ff8a5c;
  --ok: #3ddc97; --warn: #ffc857; --danger: #ff5a6a; --info: #5cc8ff;
  --radius: 12px; --shadow: 0 10px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
a { color: var(--info); text-decoration: none; }
button, .btn { font: inherit; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); padding: 9px 14px; border-radius: 9px; cursor: pointer; transition: .15s; }
button:hover, .btn:hover { border-color: #3b4256; background: #252a3a; }
button.primary, .btn.primary { text-decoration: none; display: inline-block; background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 0; color: #fff; font-weight: 600; }
button.primary:hover, .btn.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; }
button.danger { border-color: rgba(255,90,106,.4); color: var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; width: 100%; background: #0c0e14; color: var(--text); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
h1, h2, h3 { margin: 0 0 8px; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 26px; } h2 { font-size: 20px; } h3 { font-size: 16px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.pill.ok { color: var(--ok); border-color: rgba(61,220,151,.35); }
.pill.warn { color: var(--warn); border-color: rgba(255,200,87,.35); }
.pill.danger { color: var(--danger); border-color: rgba(255,90,106,.35); }
.pill.info { color: var(--info); border-color: rgba(92,200,255,.35); }
.pill.accent { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 0; }
.progress { height: 8px; background: #0c0e14; border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; box-shadow: var(--shadow); max-width: 380px; }
.toast.err { border-color: var(--danger); }
.toast.ok { border-color: var(--ok); }

/* auth page */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, rgba(255,77,77,.18), transparent), radial-gradient(900px 500px at 100% 100%, rgba(92,200,255,.12), transparent); }
.auth .card { width: 100%; max-width: 420px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.logo .dot { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; color: #fff; font-size: 14px; }

/* app layout */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--border); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side nav a { white-space: nowrap; }
.side nav { margin-top: 24px; display: flex; flex-direction: column; gap: 4px; }
.side nav a { color: var(--muted); padding: 10px 12px; border-radius: 9px; font-weight: 500; display: flex; gap: 10px; align-items: center; }
.side nav a.active, .side nav a:hover { color: var(--text); background: var(--panel-2); }
.side .foot { margin-top: auto; font-size: 13px; color: var(--muted); }
.main { padding: 28px 32px; max-width: 1180px; width: 100%; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.stat { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.stat b { display: block; font-size: 24px; }
.video-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: .15s; }
.video-card:hover { border-color: #3b4256; transform: translateY(-2px); }
.video-card .thumb { aspect-ratio: 16/9; background: #0c0e14 center/cover no-repeat; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.video-card .body { padding: 14px; }
.scene { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: var(--panel-2); }
.scene h4 { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.steps { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 18px; }
.steps span { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.steps span.done { color: var(--ok); border-color: rgba(61,220,151,.35); }
.steps span.now { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 0; }
.preview video { width: 100%; max-height: 70vh; background: #000; border-radius: 10px; }
.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
.conn { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.conn:first-of-type { border-top: 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; }
pre.log { background: #0c0e14; border: 1px solid var(--border); border-radius: 9px; padding: 12px; max-height: 260px; overflow: auto; font-size: 12px; white-space: pre-wrap; }
.help { background: rgba(92,200,255,.07); border: 1px solid rgba(92,200,255,.25); border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.help ol { margin: 6px 0 0 18px; padding: 0; }
.hidden { display: none !important; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; gap: 12px; overflow-x: auto; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .side .logo { flex-shrink: 0; }
  .side nav { flex-direction: row; margin: 0; gap: 2px; }
  .side nav a { padding: 8px 10px; font-size: 13px; }
  .side .foot { display: none; }
  .main { padding: 18px 16px; }
  .two { grid-template-columns: 1fr; }
}

/* studio */
.studio { margin-bottom: 8px; }
.studio-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.tiles { display: grid; gap: 10px; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: 96px; grid-auto-flow: dense; }
.tile { position: relative; border-radius: 12px; overflow: hidden; background: #0c0e14; border: 1px solid var(--border); cursor: default; }
.t-hero { grid-column: span 2; grid-row: span 4; }
.t-wide { grid-column: span 2; grid-row: span 2; }
.t-tall { grid-column: span 1; grid-row: span 2; }
.t-tall .tile-meta span { display: none; }
.tile[onclick] { cursor: pointer; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .35s; transform: scale(1.02); }
.tile.on video { opacity: 1; }
.tile-meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 10px 10px; background: linear-gradient(transparent, rgba(0,0,0,.85)); font-size: 12px; line-height: 1.3; }
.tile-meta b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-meta span { color: #c9cdd8; font-size: 11px; }
.tile-live { position: absolute; top: 8px; left: 8px; font-size: 10px; letter-spacing: .04em; text-transform: uppercase; background: rgba(0,0,0,.55); padding: 3px 7px; border-radius: 999px; color: #ff8a5c; }
.channels { margin-top: 16px; }
.chan-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.chan { display: flex; align-items: center; gap: 10px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; min-width: 240px; flex-shrink: 0; }
.chan.real { border-color: rgba(255,77,77,.5); }
.chan .avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0; }
.chan > div:nth-child(2) { flex: 1; min-width: 0; }
.chan b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 84px; } .t-hero { grid-row: span 3; } }
@media (max-width: 560px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 80px; } .t-hero, .t-wide { grid-column: span 2; grid-row: span 2; } .t-tall { grid-column: span 1; grid-row: span 2; } }
