:root {
  --bg: #0f0f11; --bg-2: #16171a; --surface: #1c1d21; --surface-2: #24262b; --hover: #2c2e34; --line: #2e3036;
  --text: #f1f1f3; --text-2: #aaadb5; --dim: #767a84; --accent: #f0532a; --accent-2: #ff6a3d; --good: #4fc98a; --warn: #f0b84a;
  --r: 12px; --top: 56px; --side: 232px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; font-size: 14px; line-height: 1.45;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
img { display: block; }
.dim { color: var(--dim); } .t2 { color: var(--text-2); }
.hidden { display: none !important; }

/* ---------- top bar */
.top { position: fixed; inset: 0 0 auto 0; height: var(--top); display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--bg); z-index: 20; }
.menu-btn { display: none; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; letter-spacing: -.02em; white-space: nowrap; }
.logo img { width: 30px; height: 30px; }
.search { flex: 1; max-width: 620px; margin: 0 auto; display: flex; }
.search input { flex: 1; height: 40px; padding: 0 16px; border: 1px solid var(--line); border-right: none; border-radius: 20px 0 0 20px; background: var(--bg-2); outline: none; min-width: 0; }
.search input:focus { border-color: #3d6fd8; }
.search button svg { width: 20px; height: 20px; }
.search button { width: 60px; height: 40px; border: 1px solid var(--line); border-radius: 0 20px 20px 0; background: var(--surface); cursor: pointer; display: grid; place-items: center; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: none; background: none; display: grid; place-items: center; cursor: pointer; color: var(--text); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg, .btn svg, .nav svg { width: 22px; height: 22px; }
.avatar { border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none; }
.me-btn { border: none; background: none; padding: 0; cursor: pointer; border-radius: 50%; }
.dropdown { position: absolute; right: 16px; top: 52px; width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 0; box-shadow: 0 12px 30px rgba(0, 0, 0, .5); }
.dropdown .who { display: flex; gap: 10px; align-items: center; padding: 8px 16px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.dropdown a, .dropdown button { display: flex; gap: 12px; align-items: center; width: 100%; padding: 9px 16px; background: none; border: none; text-align: left; cursor: pointer; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); }

/* ---------- layout */
.side { position: fixed; top: var(--top); bottom: 0; left: 0; width: var(--side); padding: 8px 12px; overflow-y: auto; background: var(--bg); z-index: 15; }
.nav { display: flex; align-items: center; gap: 20px; padding: 0 12px; height: 40px; border-radius: 10px; color: var(--text); }
.nav:hover { background: var(--surface); }
.nav.on { background: var(--surface-2); font-weight: 600; }
.side h4 { margin: 14px 12px 6px; font-size: 14px; font-weight: 600; }
.side hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
.side .sub-ch { display: flex; align-items: center; gap: 14px; padding: 0 12px; height: 38px; border-radius: 10px; }
.side .sub-ch:hover { background: var(--surface); }
.side .sub-ch span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { padding: calc(var(--top) + 12px) 24px 48px calc(var(--side) + 24px); min-height: 100vh; }
.main.narrow { max-width: calc(var(--side) + 1000px); }
.scrim { display: none; }

/* ---------- buttons, fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px; border-radius: 18px; border: none; background: var(--surface-2); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--text); color: #0f0f11; }
.btn.primary:hover { background: #d9d9dc; }
.btn.red { background: var(--accent); color: #fff; }
.btn.red:hover { background: var(--accent-2); }
.btn.ghost { background: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: #ff8a80; }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 20px; height: 20px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.input { width: 100%; height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-2); outline: none; }
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: #3d6fd8; }
select.input { padding-right: 8px; }
.err { color: #ff8a80; margin: 0 0 12px; }
.err:empty { display: none; }

/* ---------- video grid */
.chips { display: flex; gap: 10px; margin-bottom: 20px; }
.chip { height: 32px; padding: 0 12px; border-radius: 8px; background: var(--surface-2); border: none; cursor: pointer; font-weight: 600; }
.chip.on { background: var(--text); color: #0f0f11; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 36px 16px; }
.card .thumb { display: block; position: relative; aspect-ratio: 16 / 9; border-radius: var(--r); overflow: hidden; background: var(--surface); }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.card:hover .thumb img { transform: scale(1.02); }
.dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0, 0, 0, .8); font-size: 12px; font-weight: 600; padding: 1px 5px; border-radius: 4px; }
.resume-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .3); }
.resume-bar i { display: block; height: 100%; background: var(--accent); }
.card .meta { display: flex; gap: 12px; margin-top: 12px; }
.card .meta .avatar { width: 36px; height: 36px; }
.card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .sub { color: var(--text-2); font-size: 13px; }
.card .sub a:hover { color: var(--text); }
.row-title { font-size: 20px; margin: 0 0 16px; }
.section { margin-bottom: 40px; }
.empty { text-align: center; color: var(--text-2); padding: 80px 20px; }
.empty .big { font-size: 20px; color: var(--text); margin-bottom: 8px; font-weight: 600; }
.more { display: flex; justify-content: center; margin-top: 32px; }

/* ---------- watch page */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; max-width: 1760px; }
.player-wrap { position: relative; background: #000; border-radius: var(--r); overflow: hidden; aspect-ratio: 16 / 9; }
.player-wrap video { width: 100%; height: 100%; display: block; background: #000; }
.player-wrap.portrait video { object-fit: contain; }
.quality { position: absolute; top: 10px; right: 10px; opacity: 0; transition: opacity .2s; }
.player-wrap:hover .quality, .quality:focus-within { opacity: 1; }
.quality select { background: rgba(0, 0, 0, .7); border: 1px solid rgba(255, 255, 255, .2); border-radius: 6px; height: 28px; padding: 0 6px; }
.w-title { font-size: 20px; font-weight: 700; margin: 12px 0 8px; line-height: 1.3; word-break: break-word; }
.w-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.w-bar > .input { flex: 1; min-width: 200px; width: auto; }
.panel h3 { margin: 0 0 12px; font-size: 16px; }
.w-ch { display: flex; align-items: center; gap: 12px; margin-right: auto; min-width: 0; }
.w-ch .avatar { width: 40px; height: 40px; }
.w-ch b { display: block; font-size: 16px; }
.w-ch small { color: var(--text-2); font-size: 12px; }
.liked { background: var(--text); color: #0f0f11; }
.liked:hover { background: #d9d9dc; }
.desc { background: var(--surface); border-radius: var(--r); padding: 12px; margin-top: 12px; white-space: pre-wrap; word-break: break-word; }
.desc b { display: block; margin-bottom: 4px; }
.desc a { color: #6ea8ff; }
.desc.clamp .txt { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.desc .toggle { background: none; border: none; padding: 0; margin-top: 6px; font-weight: 600; cursor: pointer; }
.up-next .item { display: flex; gap: 8px; margin-bottom: 10px; }
.up-next .item .thumb { width: 168px; flex: none; position: relative; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--surface); }
.up-next .item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.up-next .item h4 { margin: 0 0 4px; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.up-next .item .sub { font-size: 12px; color: var(--text-2); }
.notice { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin-bottom: 12px; color: var(--text-2); }
.notice b { color: var(--text); }

/* comments */
.comments { margin-top: 24px; }
.comments h3 { font-size: 18px; margin: 0 0 16px; }
.c-new { display: flex; gap: 12px; margin-bottom: 24px; }
.c-new .avatar { width: 40px; height: 40px; }
.c-new form { flex: 1; }
.c-new textarea { width: 100%; background: none; border: none; border-bottom: 1px solid var(--line); padding: 6px 0; outline: none; resize: none; min-height: 32px; }
.c-new textarea:focus { border-bottom-color: var(--text); }
.c-new .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.comment { display: flex; gap: 12px; margin-bottom: 18px; }
.comment .avatar { width: 40px; height: 40px; }
.comment.reply .avatar { width: 28px; height: 28px; }
.comment .body { flex: 1; min-width: 0; }
.comment .head { font-size: 13px; }
.comment .head b { font-weight: 600; margin-right: 6px; }
.comment p { margin: 2px 0 4px; white-space: pre-wrap; word-break: break-word; }
.comment .c-acts { display: flex; gap: 4px; }
.replies { margin-top: 12px; }

/* ---------- channel */
.ch-head { display: flex; align-items: center; gap: 24px; margin: 8px 0 28px; }
.ch-head .avatar { width: 128px; height: 128px; }
.ch-head h1 { margin: 0 0 4px; font-size: 32px; letter-spacing: -.02em; }
.ch-head .t2 { margin-bottom: 8px; }
.ch-head p { margin: 0 0 12px; color: var(--text-2); max-width: 640px; white-space: pre-wrap; }

/* ---------- upload, studio, forms */
.panel { background: var(--surface); border-radius: var(--r); padding: 24px; }
.page-title { font-size: 24px; margin: 0 0 20px; }
.drop { border: 2px dashed #3a3d45; border-radius: var(--r); padding: 56px 20px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(240, 83, 42, .06); }
.drop .circle { width: 120px; height: 120px; border-radius: 50%; background: var(--bg-2); display: grid; place-items: center; margin: 0 auto 18px; }
.drop .circle svg { width: 56px; height: 56px; color: var(--dim); }
.drop strong { display: block; font-size: 16px; margin-bottom: 4px; }
.up-item { display: grid; grid-template-columns: 1fr 260px; gap: 24px; background: var(--surface); border-radius: var(--r); padding: 20px; margin-top: 16px; }
.up-item .status { background: var(--bg-2); border-radius: 10px; padding: 14px; align-self: start; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 10px 0 6px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.bar.good i { background: var(--good); }
.seg { display: flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 3px; }
.seg label { flex: 1; text-align: center; padding: 6px 8px; border-radius: 6px; cursor: pointer; color: var(--text-2); }
.seg input { display: none; }
.seg input:checked + span { color: var(--text); }
.seg label:has(input:checked) { background: var(--surface-2); color: var(--text); }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; color: var(--text-2); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.list td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:hover td { background: rgba(255, 255, 255, .02); }
.st-vid { display: flex; gap: 12px; align-items: center; min-width: 280px; }
.st-vid .thumb { display: block; width: 120px; flex: none; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: var(--bg-2); position: relative; }
.st-vid .thumb img { width: 100%; height: 100%; object-fit: cover; }
.st-vid b { display: block; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pill svg { width: 14px; height: 14px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill.ok { color: var(--good); } .pill.bad { color: #ff8a80; } .pill.busy { color: var(--warn); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.acts { display: flex; gap: 4px; justify-content: flex-end; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--surface); border-radius: var(--r); padding: 16px; }
.stat .k { color: var(--text-2); font-size: 12px; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.code-box { display: flex; align-items: center; gap: 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 12px 0; }
.code-box .mono { flex: 1; word-break: break-all; }

/* ---------- auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .box { width: 100%; max-width: 400px; background: var(--surface); border-radius: 16px; padding: 32px 28px; }
.auth .logo { justify-content: center; margin-bottom: 8px; font-size: 22px; }
.auth h1 { text-align: center; font-size: 18px; font-weight: 600; margin: 0 0 24px; color: var(--text-2); }
.auth .btn { width: 100%; height: 42px; border-radius: 10px; }
.auth .alt { text-align: center; margin-top: 16px; color: var(--text-2); }
.auth .alt a { color: var(--text); font-weight: 600; }

/* ---------- modal + toasts */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border-radius: 16px; padding: 24px; }
.modal h2 { margin: 0 0 18px; font-size: 20px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.thumb-pick { display: flex; gap: 14px; align-items: center; }
.thumb-pick img { width: 200px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--bg-2); }
#toasts { position: fixed; left: 24px; bottom: 24px; display: grid; gap: 8px; z-index: 60; }
.toast { background: #ececee; color: #111; padding: 12px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .4); max-width: 380px; }
.toast.bad { background: #ffdad6; }

/* ---------- smaller screens */
@media (max-width: 1300px) { .watch { grid-template-columns: minmax(0, 1fr) 340px; } .up-next .item .thumb { width: 140px; } }
@media (max-width: 1000px) {
  .watch { grid-template-columns: 1fr; }
  .side { transform: translateX(-100%); transition: transform .2s; }
  body.menu-open .side { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .6); }
  body.menu-open .scrim { display: block; position: fixed; inset: var(--top) 0 0 0; background: rgba(0, 0, 0, .5); z-index: 14; }
  .menu-btn { display: grid; }
  .main { padding-left: 24px; }
  .up-item { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .main { padding: calc(var(--top) + 8px) 16px 40px; }
  .top { gap: 6px; padding: 0 8px; }
  .logo span { display: none; }
  .search button { width: 44px; }
  .grid { grid-template-columns: 1fr; }
  .player-wrap { margin: 0 -16px; border-radius: 0; }
  .ch-head { flex-direction: column; text-align: center; }
  .ch-head .avatar { width: 96px; height: 96px; }
  .ch-head h1 { font-size: 24px; }
  .hide-sm { display: none; }
  table.list .hide-sm { display: none; }
}

/* verification badges */
.badge { display: inline-flex; vertical-align: -2px; margin-left: 4px; width: 14px; height: 14px; flex: none; }
.badge svg { width: 100%; height: 100%; }
.badge.verified { color: #aaadb5; }
.badge.ambassador { color: #f5b942; }
h1 .badge { width: 22px; height: 22px; margin-left: 8px; vertical-align: -1px; }
.w-ch b .badge, .dropdown .badge { width: 15px; height: 15px; }
.badge-pick { width: auto; height: 30px; padding: 0 8px; font-size: 13px; }
.comment .head .badge { margin: 0 8px 0 -2px; }
.acts { align-items: center; }
.nav .count { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.nav > span:last-child { display: flex; align-items: center; flex: 1; gap: 8px; }
.panel.waiting { border: 1px solid rgba(240, 83, 42, .45); }
.center { text-align: center; }
