:root {
  --bg: #0f0f0f; --surface: #1c1c1c; --surface-2: #272727; --line: #303030;
  --text: #f1f1f1; --muted: #aaa; --accent: #ff2d3b; --ok: #3ccf7a; --warn: #f0b03c; --err: #ff6b6b;
  --side: 232px; --top: 56px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
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: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(340px, 100%); display: grid; gap: 12px; }
.login input { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.login button { background: var(--accent); border: 0; border-radius: 10px; padding: 12px; font-weight: 600; color: #fff; }
.field { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.err { color: var(--err); min-height: 1.4em; font-size: 13px; }

/* ---------- shell ---------- */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; letter-spacing: -.2px; white-space: nowrap; }
.brand.big { font-size: 22px; justify-content: center; margin-bottom: 8px; }
.logo { width: 28px; height: 20px; border-radius: 6px; background: var(--accent); position: relative; flex: none; }
.logo::after { content: ""; position: absolute; left: 11px; top: 5px; border-left: 8px solid #fff; border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.top { position: fixed; inset: 0 0 auto 0; height: var(--top); display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--bg); z-index: 20; }
.top input[type=search] { flex: 1; max-width: 560px; margin: 0 auto; background: #121212; border: 1px solid var(--line); border-radius: 20px; padding: 8px 16px; }
.icon { background: none; border: 0; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; display: grid; place-items: center; }
.icon:hover { background: var(--surface-2); }
.menu-toggle { display: none; }
.queue-pill { font-size: 12px; background: var(--surface-2); border-radius: 14px; padding: 5px 12px; white-space: nowrap; }
.queue-pill .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); margin-right: 6px; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.side { position: fixed; top: var(--top); bottom: 0; left: 0; width: var(--side); overflow-y: auto; padding: 8px 12px 24px; }
.side h4 { margin: 18px 12px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.side a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; color: var(--text); overflow: hidden; }
.side a span.n { margin-left: auto; color: var(--muted); font-size: 12px; }
.side a:hover { background: var(--surface); }
.side a.on { background: var(--surface-2); font-weight: 600; }
.side a.sub { padding-left: 28px; font-size: 13px; }
.side a .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { margin: var(--top) 0 0 var(--side); padding: 16px 24px 48px; min-height: calc(100vh - var(--top)); }

/* ---------- headings & rows ---------- */
.h { display: flex; align-items: center; gap: 12px; margin: 8px 0 14px; flex-wrap: wrap; }
.h h2 { font-size: 20px; margin: 0; }
.h .crumbs { color: var(--muted); font-size: 13px; }
.h .crumbs a:hover { color: var(--text); }
.h .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.btn { background: var(--surface-2); border: 0; border-radius: 18px; padding: 8px 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: #3a3a3a; }
.btn.primary { background: var(--text); color: #0f0f0f; }
.btn.primary:hover { background: #d9d9d9; }
.btn.danger:hover { background: #4a1f22; color: var(--err); }
.btn.small { padding: 5px 10px; font-size: 12px; }
section { margin-bottom: 32px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { background: var(--surface-2); border-radius: 8px; padding: 6px 12px; font-size: 13px; }
.chip:hover { background: #3a3a3a; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }
.empty .big { font-size: 18px; color: var(--text); margin-bottom: 6px; }

/* ---------- video grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px 16px; }
.row-scroll { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 300px); gap: 16px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.card { display: block; min-width: 0; }
.card .thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: var(--surface) center / cover no-repeat; }
.card:hover .thumb { border-radius: 6px; transition: border-radius .15s; }
.card .dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.8); font-size: 12px; font-weight: 500; padding: 1px 5px; border-radius: 4px; }
.card .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.3); }
.card .bar > i { display: block; height: 100%; background: var(--accent); }
.card .state { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.6); font-size: 13px; text-align: center; padding: 8px; }
.card .state .pbar { width: 70%; height: 4px; background: rgba(255,255,255,.2); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.card .state .pbar i { display: block; height: 100%; background: var(--warn); }
.card .live { position: absolute; left: 6px; bottom: 6px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 4px; }
.card .title { margin-top: 10px; font-weight: 600; font-size: 15px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card.disabled { pointer-events: none; }

/* ---------- watch page ---------- */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; max-width: 1700px; }
.watch media-player { --video-brand: var(--accent); border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; background: #000; }
.watch h1 { font-size: 20px; margin: 12px 0 6px; line-height: 1.3; }
.watch .info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.watch .info .meta { color: var(--muted); font-size: 13px; margin-right: auto; }
.versions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.versions .lbl { color: var(--muted); font-size: 13px; margin-right: 4px; }
.chip.on { background: var(--text); color: #0f0f0f; font-weight: 600; }
.chip.off { opacity: .55; cursor: default; }
.upnext h3 { font-size: 16px; margin: 0 0 12px; }
.upnext .item { display: grid; grid-template-columns: 168px 1fr; gap: 8px; margin-bottom: 8px; padding: 4px; border-radius: 10px; }
.upnext .item:hover { background: var(--surface); }
.upnext .item.on { background: var(--surface-2); }
.upnext .item .thumb { border-radius: 8px; }
.upnext .item .title { margin-top: 0; font-size: 14px; }
.next-overlay { position: absolute; right: 16px; bottom: 72px; background: rgba(0,0,0,.85); border-radius: 12px; padding: 12px 14px; z-index: 5; width: min(320px, calc(100% - 32px)); }
.next-overlay .t { font-weight: 600; margin: 2px 0 10px; }
.next-overlay .row { display: flex; gap: 8px; }
.player-wrap { position: relative; }

/* ---------- menus, dialogs, tables ---------- */
.pop { position: absolute; background: var(--surface-2); border-radius: 12px; padding: 8px 0; min-width: 240px; box-shadow: 0 8px 30px rgba(0,0,0,.5); z-index: 30; }
.pop .it { display: flex; align-items: center; gap: 10px; padding: 8px 16px; cursor: pointer; }
.pop .it:hover { background: #3a3a3a; }
.pop .sep { height: 1px; background: var(--line); margin: 6px 0; }
.pop input { margin: 4px 12px; width: calc(100% - 24px); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.panel { background: var(--surface); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); word-break: break-all; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 6px; padding: 2px 7px; text-transform: uppercase; letter-spacing: .3px; }
.badge.ready { background: rgba(60,207,122,.15); color: var(--ok); }
.badge.processing { background: rgba(240,176,60,.15); color: var(--warn); }
.badge.queued { background: var(--surface-2); color: var(--muted); }
.badge.error { background: rgba(255,107,107,.15); color: var(--err); }
.steps { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.steps li { display: grid; grid-template-columns: 20px 1fr auto; gap: 6px; align-items: center; color: var(--muted); }
.steps li.done { color: var(--text); }
.steps li.done .i { color: var(--ok); }
.steps li.run { color: var(--text); font-weight: 500; }
.steps li .t { font-size: 12px; color: var(--muted); font-weight: 400; white-space: nowrap; }
.steps li .prog { grid-column: 2 / -1; margin-top: 2px; }
.ctlrow { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.badge.stopped { background: var(--surface-2); color: var(--warn); }
.badge.duplicate { background: var(--surface-2); color: var(--muted); }
.prog { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; min-width: 120px; }
.prog i { display: block; height: 100%; background: var(--warn); transition: width .5s; }
.browser { border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; max-height: 320px; overflow: auto; }
.browser .path { padding: 8px 12px; background: var(--surface-2); font-family: ui-monospace, Consolas, monospace; font-size: 12px; position: sticky; top: 0; }
.browser .d { padding: 8px 12px; cursor: pointer; border-top: 1px solid var(--line); }
.browser .d:hover { background: var(--surface-2); }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.form-row input[type=text] { flex: 1; min-width: 200px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--surface-2); border-radius: 10px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #888; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: rgba(60,207,122,.35); }
.switch input:checked + span::after { transform: translateX(16px); background: var(--ok); }
.pl-item { display: grid; grid-template-columns: 28px 168px 1fr auto; gap: 12px; align-items: center; padding: 6px; border-radius: 10px; }
.pl-item:hover { background: var(--surface); }
.pl-item .n { color: var(--muted); text-align: center; }
.pl-item .ctl { display: flex; gap: 4px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #f1f1f1; color: #0f0f0f; padding: 10px 16px;
         border-radius: 8px; font-weight: 500; opacity: 0; transition: .25s; pointer-events: none; z-index: 50; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .watch { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .menu-toggle { display: grid; }
  .side { background: var(--bg); transform: translateX(-100%); transition: transform .2s; z-index: 25; box-shadow: 4px 0 20px rgba(0,0,0,.5); }
  body.nav-open .side { transform: none; }
  main { margin-left: 0; padding: 12px 16px 40px; }
  .top { gap: 8px; padding: 0 8px; }
  .top .brand { font-size: 0; gap: 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .watch media-player { border-radius: 0; margin: -12px -16px 0; }
  .upnext .item, .pl-item { grid-template-columns: 140px 1fr; }
  .pl-item .n { display: none; }
  .pl-item .ctl { grid-column: 1 / -1; justify-content: flex-end; }
  .table .hide-sm { display: none; }
}
