:root {
  --bg: #0a0a0b;
  --surface: #131315;
  --surface-2: #1a1a1d;
  --line: rgba(255,255,255,.07);
  --line-2: rgba(255,255,255,.12);
  --text: #ececee;
  --muted: #8b8b92;
  --dim: #5c5c63;
  --accent: #a594ff;
  --accent-2: #7f6cff;
  --danger: #ff6b6b;
  --ok: #5fd39a;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
::selection { background: var(--accent-2); color: #fff; }

/* ------------------------------------------------ header */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(10,10,11,.78);
  backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.02em; flex-shrink: 0; }
.grab {
  flex: 1; max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 5px 5px 5px 16px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.grab:focus-within { border-color: rgba(165,148,255,.55); box-shadow: 0 0 0 4px rgba(165,148,255,.12); background: var(--surface-2); }
.grab-ico { width: 17px; height: 17px; color: var(--dim); flex-shrink: 0; }
.grab input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; padding: 8px 4px; font-size: 14.5px; }
.grab input::placeholder { color: var(--dim); }
.grab select {
  background: transparent; border: 0; outline: 0; color: var(--muted); padding: 8px 6px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.grab select:hover { color: var(--text); }
.grab select option { background: var(--surface-2); }
.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--text); color: #0a0a0b; border: 0;
  border-radius: 999px; padding: 9px 16px; font-weight: 600; font-size: 13.5px;
  transition: transform .15s, background .15s;
}
.btn-primary svg { width: 16px; height: 16px; stroke-width: 2.4; }
.btn-primary:hover { background: #fff; }
.btn-primary:active { transform: scale(.96); }

.lock {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  background: none; border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px;
  color: var(--muted); font-size: 12.5px; white-space: nowrap; transition: color .2s, border-color .2s, background .2s;
}
.lock svg { width: 14px; height: 14px; }
.lock:hover { color: var(--text); border-color: var(--line-2); background: var(--surface); }
.lock.on { color: var(--ok); }
.lock.out { color: var(--danger); }

.dlg {
  background: var(--surface); color: var(--text); border: 1px solid var(--line-2); border-radius: 18px;
  padding: 28px; width: min(360px, calc(100vw - 32px)); text-align: center;
  box-shadow: 0 30px 90px rgba(0,0,0,.7);
}
.dlg[open] { animation: rise .25s cubic-bezier(.2,.8,.2,1); }
.dlg::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.dlg-ico { width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; }
.dlg-ico svg { width: 22px; height: 22px; color: var(--accent); }
.dlg h2 { margin: 0 0 6px; font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
.dlg p { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; }
.dlg input {
  width: 100%; background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px; padding: 11px 14px; outline: 0; font-size: 14.5px;
}
.dlg input:focus { border-color: rgba(165,148,255,.55); box-shadow: 0 0 0 4px rgba(165,148,255,.12); }
.dlg-wide { width: min(460px, calc(100vw - 32px)); }
.dlg-ico .dot { fill: currentColor; stroke: none; }
.steps { text-align: left; margin: 0 0 18px; padding-left: 20px; color: #c9c9ce; font-size: 13.5px; display: grid; gap: 6px; }
.steps b { color: var(--text); font-weight: 600; }
.file {
  display: block; border: 1px dashed var(--line-2); border-radius: 10px; padding: 12px; margin-bottom: 10px;
  color: var(--muted); font-size: 13.5px; cursor: pointer; transition: border-color .2s, color .2s;
}
.file:hover { border-color: var(--accent); color: var(--text); }
.file.has { border-style: solid; color: var(--text); }
.file input { display: none; }
.job-meta .fix { color: var(--accent); background: none; border: 0; padding: 0; font-size: inherit; white-space: nowrap; text-decoration: underline; text-underline-offset: 2px; }
.dlg-err { color: var(--danger); font-size: 13px; min-height: 20px; margin-top: 8px; }
.dlg-row { display: flex; gap: 8px; justify-content: center; margin-top: 6px; }
.dlg-row .btn-primary { padding: 9px 20px; }

/* ------------------------------------------------ jobs */
.jobs { padding: 0 clamp(16px, 4vw, 40px); display: grid; gap: 8px; max-width: 900px; margin: 0 auto; }
.jobs:not(:empty) { padding-top: 18px; }
.job {
  display: grid; grid-template-columns: 96px 1fr auto; gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px;
  animation: rise .35s cubic-bezier(.2,.8,.2,1);
  transition: opacity .4s, transform .4s;
}
.job.leaving { opacity: 0; transform: translateY(-6px); }
.job-thumb { width: 96px; aspect-ratio: 16/9; border-radius: 7px; background: var(--surface-2) center/cover; }
.job-body { min-width: 0; }
.job-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; font-variant-numeric: tabular-nums; display: flex; gap: 10px; }
.job-meta .err { color: var(--danger); white-space: normal; }
.job-meta .ok { color: var(--ok); }
.job-bar { height: 3px; background: var(--line-2); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.job-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 3px; transition: width .25s linear; }
.job-bar.indet i { width: 30%; animation: indet 1.1s ease-in-out infinite; }
.job-x { background: none; border: 0; color: var(--dim); padding: 8px; border-radius: 8px; display: grid; }
.job-x:hover { color: var(--text); background: var(--surface-2); }
.job-x svg { width: 16px; height: 16px; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ------------------------------------------------ library */
.wrap { padding: 28px clamp(16px, 4vw, 40px) 60px; max-width: 1600px; margin: 0 auto; }
.lib-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.lib-head h1 { font-size: 22px; letter-spacing: -.02em; margin: 0; font-weight: 650; }
.lib-head .count { color: var(--dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.search {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; width: min(280px, 45vw);
}
.search:focus-within { border-color: var(--line-2); }
.search svg { width: 15px; height: 15px; color: var(--dim); flex-shrink: 0; }
.search input { background: none; border: 0; outline: 0; padding: 8px 0; width: 100%; font-size: 13.5px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 28px 20px; }
.card { display: block; position: relative; outline: none; }
.card-thumb {
  position: relative; aspect-ratio: 16/9; border-radius: 12px; overflow: hidden;
  background: var(--surface-2);
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .45s cubic-bezier(.2,.8,.2,1), filter .3s; }
.card:hover .card-thumb img, .card:focus-visible .card-thumb img { transform: scale(1.04); filter: brightness(.82); }
.card:focus-visible .card-thumb { box-shadow: 0 0 0 2px var(--accent); }
.card-play {
  position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity .25s;
}
.card-play span { width: 52px; height: 52px; border-radius: 50%; background: rgba(0,0,0,.5); backdrop-filter: blur(8px); display: grid; place-items: center; transform: scale(.85); transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.card-play svg { width: 22px; height: 22px; fill: #fff; stroke: none; margin-left: 3px; }
.card:hover .card-play { opacity: 1; }
.card:hover .card-play span { transform: scale(1); }
.badge {
  position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.78); color: #fff;
  font-size: 11.5px; font-weight: 600; padding: 2px 6px; border-radius: 5px; font-variant-numeric: tabular-nums;
}
.badge.q { left: 8px; right: auto; background: rgba(0,0,0,.6); color: #ddd; font-weight: 500; }
.resume { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); }
.card-info { padding: 10px 2px 0; display: flex; gap: 8px; }
.card-text { min-width: 0; flex: 1; }
.card-title { font-weight: 550; font-size: 14.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: none; border: 0; color: var(--dim); width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; flex-shrink: 0; opacity: 0; transition: opacity .2s, background .2s, color .2s;
}
.icon-btn svg { width: 16px; height: 16px; }
.card:hover .icon-btn, .icon-btn:focus-visible { opacity: 1; }
.icon-btn:hover { background: var(--surface-2); color: var(--danger); }
@media (hover: none) { .icon-btn { opacity: 1; } }

.empty { text-align: center; padding: 14vh 20px; color: var(--muted); }
.empty-art { width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; }
.empty-art svg { width: 26px; height: 26px; color: var(--accent); }
.empty h2 { color: var(--text); font-size: 18px; margin: 0 0 6px; font-weight: 600; letter-spacing: -.01em; }
.empty p { margin: 0; }
kbd { font: 12px/1 Inter, sans-serif; background: var(--surface-2); border: 1px solid var(--line-2); border-bottom-width: 2px; padding: 2px 6px; border-radius: 5px; color: var(--text); }

/* ------------------------------------------------ watch */
.watch { max-width: 1280px; margin: 0 auto; padding: 24px clamp(0px, 3vw, 40px) 60px; }
.watch-info { padding: 18px clamp(16px, 0vw, 0px) 0; }
.watch h1 { font-size: 21px; line-height: 1.3; letter-spacing: -.015em; margin: 0; font-weight: 650; }
.watch-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.watch-row .chan { color: var(--text); font-weight: 550; font-size: 14px; }
.watch-actions { margin-left: auto; display: flex; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; color: var(--text); transition: background .2s, border-color .2s;
}
.pill svg { width: 15px; height: 15px; }
.pill:hover { background: var(--surface-2); border-color: var(--line-2); }
.pill.danger:hover { color: var(--danger); }
.desc {
  margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  white-space: pre-wrap; word-break: break-word; color: #c9c9ce; font-size: 13.5px; position: relative;
  max-height: 110px; overflow: hidden; cursor: pointer;
}
.desc.open { max-height: none; cursor: auto; }
.desc:not(.open)::after { content: ""; position: absolute; inset: auto 0 0 0; height: 50px; background: linear-gradient(transparent, var(--surface)); }
.desc a { color: var(--accent); }
.more-head { font-size: 15px; font-weight: 600; margin: 36px 0 16px; }
.watch .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* ------------------------------------------------ player */
.player {
  position: relative; background: #000; aspect-ratio: 16/9; width: 100%;
  border-radius: var(--radius); overflow: hidden; outline: none; user-select: none;
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.9), 0 0 0 1px var(--line);
}
@media (max-width: 700px) { .player { border-radius: 0; } }
.player video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #000; }
.player:fullscreen { border-radius: 0; aspect-ratio: auto; }
.player.idle { cursor: none; }
.p-shade {
  position: absolute; left: 0; right: 0; bottom: 0; height: 140px; pointer-events: none;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); transition: opacity .3s;
}
.p-controls { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 14px 8px; transition: opacity .3s, transform .3s; }
.player.idle .p-controls, .player.idle .p-shade { opacity: 0; pointer-events: none; }
.player.idle .p-controls { transform: translateY(6px); }

.p-bar { position: relative; height: 18px; display: flex; align-items: center; cursor: pointer; touch-action: none; }
.p-track { position: relative; width: 100%; height: 4px; background: rgba(255,255,255,.2); border-radius: 4px; transition: height .15s; }
.p-bar:hover .p-track, .player.scrubbing .p-track { height: 6px; }
.p-buffered, .p-played { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.p-buffered { background: rgba(255,255,255,.3); }
.p-played { background: var(--accent); }
.p-knob {
  position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 4px rgba(165,148,255,.35); transform: scale(0); transition: transform .15s;
}
.p-bar:hover .p-knob, .player.scrubbing .p-knob { transform: scale(1); }
.p-tip {
  position: absolute; bottom: 24px; transform: translateX(-50%); background: rgba(20,20,22,.92); border: 1px solid var(--line-2);
  padding: 4px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  opacity: 0; pointer-events: none; transition: opacity .15s; white-space: nowrap;
}
.p-bar:hover .p-tip, .player.scrubbing .p-tip { opacity: 1; }

.p-row { display: flex; align-items: center; gap: 2px; height: 44px; }
.p-btn {
  background: none; border: 0; color: #fff; width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; opacity: .9; transition: opacity .15s, background .15s;
}
.p-btn:hover { opacity: 1; background: rgba(255,255,255,.1); }
.p-btn svg { width: 22px; height: 22px; }
.p-btn svg .fill, .p-btn svg.solid { fill: currentColor; }
.p-speed { width: auto; padding: 0 10px; font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
.p-vol { display: flex; align-items: center; }
.p-volume { width: 0; opacity: 0; transition: width .25s, opacity .25s, margin .25s; margin: 0; accent-color: #fff; cursor: pointer; height: 4px; }
.p-vol:hover .p-volume, .p-volume:focus-visible { width: 80px; opacity: 1; margin: 0 8px 0 2px; }
.p-time { font-size: 13px; font-variant-numeric: tabular-nums; color: #eee; margin-left: 8px; white-space: nowrap; }
.p-sep { margin: 0 5px; color: rgba(255,255,255,.5); }
.p-spacer { flex: 1; }
.p-menu-wrap { position: relative; }
.p-menu {
  position: absolute; bottom: 48px; right: 0; background: rgba(20,20,22,.94); backdrop-filter: blur(14px);
  border: 1px solid var(--line-2); border-radius: 12px; padding: 6px; min-width: 120px;
  animation: rise .18s ease-out;
}
.p-menu button {
  display: flex; justify-content: space-between; width: 100%; background: none; border: 0; padding: 7px 12px; border-radius: 7px;
  font-size: 13px; text-align: left; font-variant-numeric: tabular-nums;
}
.p-menu button:hover { background: rgba(255,255,255,.08); }
.p-menu button.on { color: var(--accent); font-weight: 600; }

.p-cc { position: relative; }
.p-cc.on::after { content: ""; position: absolute; left: 11px; right: 11px; bottom: 6px; height: 2px; border-radius: 2px; background: var(--accent); }
.p-ccmenu { min-width: 170px; }

.player { container-type: inline-size; }
.p-caps {
  position: absolute; left: 5%; right: 5%; bottom: 96px; text-align: center; pointer-events: none;
  transition: bottom .3s cubic-bezier(.2,.8,.2,1);
  font-size: clamp(14px, 2.4cqw, 42px); line-height: 1.35; font-weight: 500;
}
.player.idle .p-caps { bottom: 5%; }
.p-caps span {
  display: inline; background: rgba(8,8,10,.78); color: #fff; padding: .08em .45em; border-radius: .2em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone; text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
.player video::cue { color: transparent; background: transparent; }

.p-flash {
  position: absolute; top: 50%; left: 50%; width: 72px; height: 72px; margin: -36px 0 0 -36px; border-radius: 50%;
  background: rgba(0,0,0,.5); display: grid; place-items: center; opacity: 0; pointer-events: none;
}
.p-flash svg { width: 30px; height: 30px; fill: #fff; stroke: none; }
.p-flash.go { animation: flash .55s ease-out; }
@keyframes flash { 0% { opacity: 1; transform: scale(.8); } 100% { opacity: 0; transform: scale(1.35); } }
.p-seekhint {
  position: absolute; top: 50%; transform: translateY(-50%); padding: 10px 16px; border-radius: 999px;
  background: rgba(0,0,0,.55); font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .3s;
}
.p-seekhint.show { opacity: 1; transition: none; }
.p-seekhint.l { left: 12%; } .p-seekhint.r { right: 12%; }
.p-toast {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); background: rgba(20,20,22,.88);
  border: 1px solid var(--line-2); padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .35s; white-space: nowrap;
}
.p-toast.show { opacity: 1; transition: none; }
.p-spinner {
  position: absolute; top: 50%; left: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.15); border-top-color: #fff; animation: spin .8s linear infinite;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.player.waiting .p-spinner { opacity: 1; transition-delay: .25s; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 560px) {
  .p-btn[data-act=back], .p-btn[data-act=fwd], .p-btn[data-act=pip] { display: none; }
  .p-btn { width: 36px; height: 36px; }
}

/* ------------------------------------------------ misc */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 50;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 16px;
  font-size: 13.5px; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 640px) {
  .top { gap: 10px; }
  .brand span { display: none; }
  .grab { min-width: 0; padding-left: 12px; }
  .grab-ico { display: none; }
  .grab select { padding: 8px 2px; }
  .grab .btn-primary span { display: none; }
  .lock span { display: none; }
  .lock { padding: 8px; }
  .grab .btn-primary { padding: 9px 11px; }
  .lib-head { flex-wrap: wrap; }
  .search { width: 100%; margin-left: 0; }
  .grid { grid-template-columns: 1fr; }
  .job { grid-template-columns: 72px 1fr auto; }
  .job-thumb { width: 72px; }
}
