:root {
  --bg: #0e1116; --surface: #171b22; --hi: #242b38; --accent: #4f8cff; --dim: #9aa4b2; --text: #fff; --err: #ff8a80;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text); overflow: hidden;
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.hidden { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; flex: none; }
header h2 { margin: 0; font-size: 20px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tabs { display: flex; gap: 2px; }
#tabs button { padding: 9px 16px; border-radius: 8px; color: var(--dim); font-size: 17px; }
#tabs button.on { background: var(--hi); color: var(--text); font-weight: 600; }
#search { flex: 1; min-width: 60px; max-width: 420px; margin-left: auto; padding: 9px 14px; border-radius: 22px; border: 1px solid var(--hi); background: var(--surface); outline: none; }
#search:focus { border-color: var(--accent); }
.icon { width: 42px; height: 42px; border-radius: 50%; font-size: 20px; flex: none; }
.icon:hover { background: var(--hi); }

#banner { background: var(--hi); padding: 7px 16px; font-size: 13px; display: flex; gap: 10px; align-items: center; flex: none; }
#banner.err { color: var(--err); }
.spin { width: 14px; height: 14px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

#body { flex: 1; display: flex; min-height: 0; }
#cats { width: 240px; flex: none; overflow-y: auto; background: var(--surface); padding: 6px; }
#cats button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cats button:hover { background: var(--hi); }
#cats button.on { background: var(--hi); color: var(--text); }
#list { flex: 1; min-width: 0; position: relative; overflow-y: auto; contain: strict; }
.vl-spacer { width: 1px; }
.vl-item { position: absolute; contain: layout paint; }
.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--dim); }

.ch { display: flex; align-items: center; gap: 12px; padding: 0 12px; border-radius: 8px; cursor: pointer; height: 100%; }
.ch:hover, .ch.on { background: var(--hi); }
.ch .num { min-width: 44px; text-align: center; color: var(--dim); font-size: 13px; }
.ch img { width: 56px; height: 40px; object-fit: contain; flex: none; }
.ch .logo-ph { width: 56px; flex: none; }
.ch .txt { flex: 1; min-width: 0; }
.ch .name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch .now { color: var(--dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 3px; background: var(--hi); width: 60%; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.ch .act { color: var(--dim); padding: 6px 8px; border-radius: 6px; font-size: 16px; }
.ch .act:hover { background: var(--surface); color: var(--text); }
.ch .act.fav { color: #ffc83d; }

.poster { padding: 6px; cursor: pointer; height: 100%; display: flex; flex-direction: column; }
.poster .pic { flex: 1; min-height: 0; border-radius: 6px; background: var(--hi) center/cover no-repeat; position: relative; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--dim); font-size: 13px; padding: 8px; overflow: hidden; }
.poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.poster:hover .pic { outline: 2px solid var(--accent); }
.poster .cap { height: 40px; margin-top: 4px; font-size: 13px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.poster .star { position: absolute; top: 4px; right: 6px; color: #ffc83d; z-index: 1; text-shadow: 0 0 4px #000; }

.btn { padding: 10px 18px; border-radius: 22px; background: var(--hi); white-space: nowrap; }
.btn:hover { filter: brightness(1.2); }
.btn.primary { background: var(--accent); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

#pageBody { flex: 1; overflow-y: auto; padding: 8px 16px 32px; }
.card { background: var(--surface); border-radius: 12px; padding: 16px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 8px; }
.card h3 { margin: 0; font-size: 18px; }
.muted { color: var(--dim); font-size: 13px; }
.form { max-width: 560px; display: flex; flex-direction: column; gap: 12px; }
.form input[type=text], .form input[type=password], #loginPass { padding: 12px 14px; border-radius: 8px; border: 1px solid #3a4250; background: transparent; width: 100%; outline: none; }
.form input:focus, #loginPass:focus { border-color: var(--accent); }
.err { color: var(--err); font-size: 14px; min-height: 1em; }
#login { align-items: center; justify-content: center; }
#login .card { width: min(360px, 90vw); gap: 14px; }
#login h1 { margin: 0; font-size: 24px; }

.detail { display: flex; gap: 20px; max-width: 900px; }
.detail .cover { width: 160px; aspect-ratio: 2/3; border-radius: 8px; background: var(--hi) center/cover; flex: none; object-fit: cover; }
.detail h1 { margin: 0 0 6px; font-size: 24px; }
.detail .plot { color: #d5dae2; white-space: pre-line; margin-top: 12px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0; }
.chips button { padding: 8px 14px; border-radius: 20px; background: var(--hi); white-space: nowrap; flex: none; }
.chips button.on { background: var(--accent); }
.ep { padding: 10px 12px; border-radius: 8px; cursor: pointer; max-width: 900px; }
.ep:hover { background: var(--hi); }
.ep .plot { color: var(--dim); font-size: 13px; }
.prog { display: flex; gap: 14px; padding: 9px 12px; border-radius: 8px; max-width: 900px; }
.prog.cur { background: var(--hi); }
.prog.play { cursor: pointer; }
.prog.play:hover { background: var(--hi); }
.prog.past { color: var(--dim); }
.prog time { color: var(--dim); width: 44px; flex: none; }
.prog.cur time { color: var(--accent); }
.prog small { display: block; color: var(--dim); }
.prog .tag { margin-left: auto; color: var(--dim); font-size: 12px; white-space: nowrap; }

#player { position: fixed; inset: 0; background: #000; z-index: 10; }
#video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.pbar { position: absolute; left: 0; right: 0; padding: 18px 22px; transition: opacity .25s; }
#player.idle .pbar { opacity: 0; pointer-events: none; }
#player.idle { cursor: none; }
#pTop { top: 0; background: linear-gradient(#000c, transparent); display: flex; gap: 10px; flex-wrap: wrap; padding-bottom: 40px; }
#pInfo { bottom: 0; background: linear-gradient(transparent, #000d); padding-top: 50px; display: flex; gap: 16px; align-items: center; pointer-events: none; }
#pInfo img { width: 84px; height: 60px; object-fit: contain; }
#pInfo h2 { margin: 0; font-size: 22px; }
#pInfo .bar { width: 100%; height: 4px; margin: 6px 0; }
#player.vod #pInfo { display: none; }
#pMsg { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #000d; padding: 16px 26px; border-radius: 10px; text-align: center; white-space: pre-line; max-width: min(560px, 88vw); z-index: 2; }
#pMsg .row { justify-content: center; margin-top: 14px; }
#pNum { position: absolute; top: 24px; right: 28px; background: #000c; padding: 6px 18px; border-radius: 8px; font-size: 34px; font-weight: 700; }
#pList { position: absolute; top: 0; bottom: 0; left: 0; width: min(400px, 90vw); background: #0e1116ee; overflow-y: auto; contain: strict; }

@media (max-width: 720px) {
  #body { flex-direction: column; }
  #cats { width: auto; display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; background: none; padding: 4px 8px; }
  #cats button { width: auto; flex: none; background: var(--hi); border-radius: 20px; padding: 8px 14px; color: var(--text); }
  #cats button.on { background: var(--accent); }
  #tabs button { padding: 8px 10px; font-size: 16px; }
  .detail { flex-direction: column; }
  .detail .cover { width: 120px; }
}

#av { position: absolute; inset: 0; background: #000; }
#av canvas, #av video { width: 100%; height: 100%; object-fit: contain; }
#pCtl { bottom: 0; background: linear-gradient(transparent, #000d); padding-top: 40px; display: flex; gap: 14px; align-items: center; }
#pCtl input { flex: 1; accent-color: var(--accent); }
#avTime { font-variant-numeric: tabular-nums; white-space: nowrap; }
