:root {
  --bg: #0e0f11;
  --panel: #17191c;
  --line: #2a2d31;
  --text: #f1f2f4;
  --muted: #9aa0a6;
  --accent: #3e6ae1;
  --danger: #e15b5b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 18px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: #8fb0ff; }
[hidden] { display: none !important; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; gap: 14px; align-items: center;
  padding: 14px 20px; background: rgba(14,15,17,.95); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 22px; letter-spacing: .02em; white-space: nowrap; }
.search { flex: 1; display: flex; gap: 10px; }
.search input { flex: 1; min-width: 0; height: 56px; padding: 0 18px; font-size: 20px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.quality { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.quality select { height: 56px; font-size: 18px; padding: 0 10px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 56px; padding: 0 22px;
  font: inherit; font-weight: 600; color: var(--text); text-decoration: none; cursor: pointer; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.round { width: 72px; height: 72px; padding: 0; border-radius: 50%; background: rgba(255,255,255,.08); }
.btn.round.big { width: 88px; height: 88px; font-size: 26px; background: rgba(255,255,255,.16); }
.btn:active { transform: scale(.97); }

.banner { margin: 14px 20px 0; padding: 14px 18px; border-radius: 12px; background: #3a1f1f; border: 1px solid var(--danger); }

main { padding: 6px 20px 40px; }
h2 { font-size: 20px; color: var(--muted); font-weight: 600; margin: 22px 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.row { display: grid; grid-auto-flow: column; grid-auto-columns: 300px; gap: 18px; overflow-x: auto; padding-bottom: 6px; }
.card { display: block; width: 100%; padding: 0; text-align: left; color: inherit; font: inherit; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.card:active { transform: scale(.98); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #000; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .dur { position: absolute; right: 8px; bottom: 8px; padding: 2px 8px; font-size: 15px;
  background: rgba(0,0,0,.8); border-radius: 6px; }
.thumb .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(255,255,255,.25); }
.thumb .bar i { display: block; height: 100%; background: var(--danger); }
.meta { padding: 10px 14px 14px; }
.meta .t { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta .c { color: var(--muted); font-size: 16px; margin-top: 4px; }
.notice { margin-top: 36px; color: var(--muted); font-size: 15px; text-align: center; }

.player { position: fixed; inset: 0; z-index: 10; background: #000; }
.player canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.controls { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(rgba(0,0,0,.65), transparent 22%, transparent 70%, rgba(0,0,0,.75));
  transition: opacity .25s; }
.controls.hidden { opacity: 0; pointer-events: none; }
.ctl-top { display: flex; align-items: center; gap: 14px; padding: 16px 20px; }
.title { font-size: 20px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctl-bottom { display: flex; align-items: center; gap: 16px; padding: 18px 24px 26px; }
.time { min-width: 72px; text-align: center; font-variant-numeric: tabular-nums; }
#seek { flex: 1; height: 56px; accent-color: var(--danger); }

.spinner { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center;
  justify-content: center; pointer-events: none; }
.spinner div { width: 64px; height: 64px; border-radius: 50%; border: 6px solid rgba(255,255,255,.2);
  border-top-color: #fff; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 20; max-width: 80vw;
  padding: 14px 22px; border-radius: 12px; background: #2b2e33; border: 1px solid var(--line); }

.title { flex: 1; }
.modal { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.7); }
.modal-card { width: min(760px, 92vw); padding: 28px 32px; border-radius: 18px; background: var(--panel);
  border: 1px solid var(--line); }
.modal-card.center { text-align: center; }
.modal-card h2 { margin-top: 0; color: var(--text); font-size: 26px; }
.pair-row { display: flex; gap: 28px; align-items: center; margin-bottom: 20px; }
.qr { width: 260px; height: 260px; background: #fff; border-radius: 12px; padding: 8px; flex: none; }
.pair-code { font: 700 44px/1.2 ui-monospace, Consolas, monospace; letter-spacing: .18em; margin: 8px 0 12px; }
.muted { color: var(--muted); font-size: 15px; }

/* phone remote */
body.remote { font-size: 17px; padding-bottom: 40px; }
.r-top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: rgba(14,15,17,.95); border-bottom: 1px solid var(--line); }
.pill { padding: 6px 12px; border-radius: 999px; font-size: 14px; background: #2b2e33; color: var(--muted); }
.pill.on { background: #173d24; color: #6fdc8c; }
.r-card { margin: 14px 12px; padding: 16px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.r-card h2 { margin: 0 0 8px; color: var(--text); }
.r-form { display: flex; gap: 8px; }
.r-form input { flex: 1; min-width: 0; height: 52px; padding: 0 14px; font-size: 18px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
#codeInput { font: 700 24px ui-monospace, Consolas, monospace; letter-spacing: .15em; text-transform: uppercase; }
.now-head { display: flex; gap: 12px; align-items: center; }
.now-head img { width: 120px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: #000; flex: none; }
.now-title { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#nowSeek { width: 100%; height: 40px; margin: 10px 0 6px; accent-color: var(--danger); }
.now-btns { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.now-btns .btn { padding: 0; }
.r-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.r-row { display: flex; gap: 12px; align-items: center; width: 100%; padding: 6px; text-align: left; font: inherit;
  color: inherit; background: transparent; border: 0; border-radius: 10px; cursor: pointer; }
.r-row:active { background: #22252a; }
.r-row img { width: 128px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: #000; flex: none; }
.r-row .t { font-weight: 600; font-size: 16px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.r-row .muted { font-size: 14px; margin-top: 2px; }

/* login + check pages */
.page { max-width: 820px; margin: 40px auto; padding: 0 20px; }
.page input[type=password], .page input[type=text] { width: 100%; height: 60px; padding: 0 18px; font-size: 22px;
  color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin: 12px 0; }
table.checks { width: 100%; border-collapse: collapse; margin: 16px 0; }
table.checks td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ok { color: #6fdc8c; font-weight: 700; }
.bad { color: var(--danger); font-weight: 700; }
#driveCanvas { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; border: 1px solid var(--line); }
