:root {
  --bg: #0f1012;
  --panel: #17191c;
  --panel-2: #1f2226;
  --line: #2a2e33;
  --text: #ececec;
  --muted: #9aa0a6;
  --accent: #f5c518;
  --accent-ink: #111;
  --danger: #ff6b6b;
  --ok: #5fd38d;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 20px; background: rgba(15,16,18,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font: 700 20px/1 ui-monospace, "Cascadia Code", Consolas, monospace; white-space: nowrap; }
.brand .prompt { color: var(--accent); }
.tabs { display: flex; gap: 4px; }
.tabs button {
  background: none; border: 0; padding: 8px 14px; border-radius: 999px; cursor: pointer; color: var(--muted);
}
.tabs button.active, .tabs button:hover, .tabs button:focus-visible { background: var(--panel-2); color: var(--text); }
.search { flex: 1; min-width: 180px; }
.search input, .add input, select {
  width: 100%; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); outline: none;
}
select { width: auto; border-radius: 8px; padding: 6px 10px; }
.search input:focus, .add input:focus { border-color: var(--accent); }
.me { display: flex; align-items: center; gap: 10px; color: var(--muted); }

main { padding: 20px; max-width: 1500px; margin: 0 auto; }
h2 { font-size: 18px; margin: 18px 0 12px; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.btn {
  display: inline-block; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px;
  padding: 10px 18px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn.big { padding: 14px 28px; font-size: 18px; }
.ghost {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer;
}
.ghost.small { padding: 4px 12px; font-size: 14px; }
.btn:focus-visible, .ghost:focus-visible, .card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 7px; font-size: 12px; margin-left: 4px; }
.hint { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); }

.login { text-align: center; padding: 12vh 0; }
.login h1 { font: 700 48px/1.1 ui-monospace, Consolas, monospace; margin: 0 0 8px; }
.login p { color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  cursor: pointer; text-align: left; padding: 0; display: flex; flex-direction: column;
  transition: transform .12s ease, border-color .12s ease;
}
.card:hover, .card:focus-visible { transform: translateY(-2px); border-color: var(--accent); }
.thumb { aspect-ratio: 16/9; background: var(--panel-2) center/cover no-repeat; display: grid; place-items: center; font-size: 34px; color: var(--muted); }
.card .meta { padding: 10px 12px 12px; }
.card .name { font-size: 14px; font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.empty { color: var(--muted); padding: 30px 0; }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); }
.crumbs button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 2px; }
.crumbs button:hover { color: var(--text); }
.crumbs .sep { opacity: .5; }

.ready-list { display: flex; flex-direction: column; gap: 8px; }
.ready-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--ok);
  border-radius: 10px; padding: 10px 14px;
}
.ready-item .when { color: var(--muted); font-size: 13px; }

.add { display: flex; gap: 10px; }
.transfers { display: flex; flex-direction: column; gap: 10px; }
.transfer { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.transfer .line { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.transfer .tname { font-weight: 600; word-break: break-word; }
.transfer .stat { color: var(--muted); font-size: 13px; white-space: nowrap; }
.bar { height: 6px; background: var(--panel-2); border-radius: 99px; margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.transfer.done .bar > i { background: var(--ok); }
.transfer.err .bar > i { background: var(--danger); }

dialog#player {
  width: min(1100px, 96vw); padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--text);
}
dialog::backdrop { background: rgba(0,0,0,.8); }
.player-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; }
#video { width: 100%; max-height: 70vh; background: #000; display: block; }
.resume { display: flex; gap: 10px; align-items: center; padding: 8px 14px; color: var(--muted); font-size: 14px; }
.player-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px 14px; }

.card .thumb { position: relative; }
.card .prog { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.2); }
.card .prog i { display: block; height: 100%; background: var(--accent); }

dialog#pair-dlg { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); padding: 22px; width: min(420px, 92vw); }
.pair-form h2 { margin-top: 0; }
.pair-form input {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  font: 700 28px ui-monospace, Consolas, monospace; letter-spacing: 6px; text-transform: uppercase; text-align: center;
}
.pair-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 20;
  background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 999px;
}

@media (max-width: 640px) {
  .top { padding: 10px 16px; gap: 10px; }
  main { padding: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .add { flex-direction: column; }
}
