:root {
  --bg: #0b0b0d;
  --s1: #141417;
  --s2: #1c1c21;
  --s3: #26262c;
  --line: rgba(255, 255, 255, .08);
  --line2: rgba(255, 255, 255, .15);
  --ink: #ece8df;
  --ink2: #c4c0b8;
  --mute: #93908a;
  --dim: #66645f;
  --acc: #ece8df;
  --red: #e5484d;
  --sans: "Inter Tight", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --gut: clamp(14px, 2.6vw, 32px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 4px; }
svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* header */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; height: 60px; padding: 0 var(--gut); background: rgba(11, 11, 13, .88); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15.5px; letter-spacing: -.01em; white-space: nowrap; }
.brand .mark { width: 22px; height: 26px; flex: none; stroke: none; }
.search { flex: 1; min-width: 0; max-width: 520px; margin: 0 auto; display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 12px; border-radius: 10px; background: var(--s1); border: 1px solid var(--line); }
.search:focus-within { border-color: var(--line2); }
.search svg { width: 16px; height: 16px; color: var(--mute); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 14.5px; }
.search input::placeholder { color: var(--dim); }
.links { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--ink2); white-space: nowrap; }
.links a:hover { color: var(--ink); }
.links select { height: 34px; padding: 0 8px; border-radius: 8px; background: var(--s1); border: 1px solid var(--line); color: var(--ink2); cursor: pointer; }
body.watching .links select { display: none; }

/* home */
.home { padding: 26px var(--gut) 80px; min-height: calc(100vh - 60px); overflow-x: clip; touch-action: pan-y pinch-zoom; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 30px 20px; }
.empty { color: var(--mute); margin: 0; padding: 55px 0; }
.empty a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line2); text-underline-offset: 3px; }
/* papers / projects */
.shelves { display: inline-flex; gap: 4px; padding: 4px; margin: 0 0 22px; border-radius: 10px; background: var(--s1); max-width: 100%; }
.shelves a { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 16px; border-radius: 7px; color: var(--mute); font-size: 14px; font-weight: 550; white-space: nowrap; }
.shelves a:hover { color: var(--ink); }
.shelves a.on { background: var(--s3); color: var(--ink); }
.shelves .n { font: 500 12px/1 var(--mono); color: var(--dim); }
.shelves a.on .n { color: var(--mute); }
/* a touch swipe drags the shelf sideways; the neighbouring shelf is drawn beside it, one screen over, for as long as the drag lasts */
.panes { position: relative; }
.panes.drag { will-change: transform; }
.beside { position: absolute; top: 0; width: 100%; pointer-events: none; }
.beside.r { left: calc(100% + 2 * var(--gut)); }
.beside.l { right: calc(100% + 2 * var(--gut)); }
.films .shelf { margin: 14px 6px 6px; font: 600 12px/1.2 var(--sans); color: var(--mute); }
.films .shelf:first-child { margin-top: 2px; }
.card { display: block; min-width: 0; }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #000; box-shadow: 0 0 0 1px var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .sb { position: absolute; inset: 0; background-color: #000; background-repeat: no-repeat; opacity: 0; }
.thumb.scrub .sb { opacity: 1; }
.thumb .dur { position: absolute; right: 7px; bottom: 7px; padding: 2px 6px; border-radius: 5px; background: rgba(0, 0, 0, .78); font: 500 11.5px/1.4 var(--mono); }
.thumb .at { position: absolute; left: 7px; bottom: 9px; max-width: calc(100% - 14px); padding: 2px 7px; border-radius: 5px; background: rgba(0, 0, 0, .8); font: 500 11.5px/1.4 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: none; }
.thumb.scrub .at { display: block; }
.thumb.scrub .dur { display: none; }
.thumb .line { position: absolute; left: 0; bottom: 0; height: 3px; width: calc(var(--x, 0) * 100%); background: var(--acc); display: none; }
.thumb.scrub .line { display: block; }
.thumb .prog { position: absolute; left: 0; bottom: 0; height: 3px; width: calc(var(--p) * 100%); background: var(--red); }
.thumb.scrub .prog { display: none; }
.card h3 { margin: 10px 0 0; font-size: 15.5px; font-weight: 600; line-height: 1.3; letter-spacing: -.005em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card p { margin: 3px 0 0; font-size: 13px; color: var(--mute); display: flex; gap: 6px; align-items: center; }
.card p svg { width: 13px; height: 13px; stroke-width: 2.4; }
.card:hover h3 { color: #fff; }

/* watch */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) clamp(320px, 26vw, 400px); grid-template-areas: "player side" "info side"; gap: 0 24px; padding: 20px var(--gut) 60px; max-width: 1840px; margin: 0 auto; align-items: start; }
.watch.theater { grid-template-areas: "player player" "info side"; padding-top: 0; max-width: none; }
.player { grid-area: player; position: relative; background: #000; border-radius: 12px; overflow: hidden; user-select: none; -webkit-user-select: none; }
.screen { position: relative; aspect-ratio: 16 / 9; background: #000; }
.watch.theater .player { border-radius: 0; margin: 0 calc(-1 * var(--gut)); }
.watch.theater .screen { aspect-ratio: auto; height: min(56.25vw, calc(100vh - 60px - 62px)); }
.player video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; display: block; }
.player.idle .screen { cursor: none; }
.bigplay { position: absolute; left: 50%; top: 50%; width: 72px; height: 72px; margin: -36px 0 0 -36px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(6px); transition: opacity .2s, transform .2s; }
.bigplay svg { width: 30px; height: 30px; margin-left: 4px; fill: currentColor; stroke: none; }
.bigplay:hover { transform: scale(1.06); background: rgba(0, 0, 0, .7); }
.player.playing .bigplay, .player.ended .bigplay { opacity: 0; pointer-events: none; }
.spin { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .2); border-top-color: #fff; animation: spin .8s linear infinite; display: none; pointer-events: none; }
.player.waiting .spin { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.ctrl { position: relative; padding: 2px 12px 4px; background: #000; }
.player:fullscreen { border-radius: 0; }
.player:fullscreen .screen { position: absolute; inset: 0; aspect-ratio: auto; height: auto; }
.player:fullscreen .ctrl { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 16px 8px; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); transition: opacity .25s; }
.player.idle:fullscreen .ctrl { opacity: 0; pointer-events: none; }
.player.idle:fullscreen { cursor: none; }
.seek { position: relative; height: 18px; cursor: pointer; touch-action: none; }
.seg { position: absolute; top: 7px; height: 4px; padding: 0 1px; transition: top .12s, height .12s; }
.seg b { display: block; position: relative; height: 100%; background: rgba(255, 255, 255, .26); overflow: hidden; border-radius: 1px; }
.seg u { position: absolute; inset: 0 auto 0 0; width: calc(var(--b, 0) * 100%); background: rgba(255, 255, 255, .36); }
.seg i { position: absolute; inset: 0 auto 0 0; width: calc(var(--f, 0) * 100%); background: var(--red); }
.seek:hover .seg, .seek.drag .seg { top: 5.5px; height: 7px; }
.seg.hov b { background: rgba(255, 255, 255, .42); }
.knob { position: absolute; top: 2.5px; width: 13px; height: 13px; margin-left: -6.5px; border-radius: 50%; background: var(--red); transform: scale(0); transition: transform .12s; pointer-events: none; }
.seek:hover .knob, .seek.drag .knob { transform: scale(1); }
.pop { position: absolute; bottom: 26px; left: 0; width: 200px; transform: translateX(-50%); pointer-events: none; display: none; text-align: center; }
.seek.show .pop { display: block; }
.pop .im { width: 200px; height: 112.5px; border-radius: 6px; border: 2px solid rgba(255, 255, 255, .9); background-color: #000; background-repeat: no-repeat; }
.pop .tt { display: inline-block; margin-top: 6px; padding: 2px 7px; border-radius: 4px; background: rgba(0, 0, 0, .8); font: 500 12px/1.4 var(--mono); max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btns { display: flex; align-items: center; gap: 2px; height: 40px; }
.cb { height: 36px; min-width: 36px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; font-size: 13px; font-weight: 600; }
.cb:hover { background: rgba(255, 255, 255, .12); }
.cb svg { width: 20px; height: 20px; }
.cb[aria-pressed="true"] { box-shadow: inset 0 -2px 0 var(--red); border-radius: 8px 8px 2px 2px; }
.vol { display: flex; align-items: center; }
.vol input { width: 0; opacity: 0; transition: width .2s, opacity .2s; accent-color: #fff; height: 4px; cursor: pointer; }
.vol:hover input, .vol:focus-within input { width: 80px; opacity: 1; margin: 0 8px 0 2px; }
.clock { font: 500 12.5px var(--mono); color: #fff; margin-left: 6px; white-space: nowrap; }
.chap { min-width: 0; flex: 1; border: 0; background: none; padding: 0 0 0 6px; text-align: left; font-size: 13px; color: rgba(255, 255, 255, .78); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.chap:hover { color: #fff; }
.menu { position: absolute; right: 10px; bottom: 64px; min-width: 150px; padding: 6px; border-radius: 10px; background: rgba(24, 24, 28, .97); border: 1px solid var(--line2); z-index: 5; }
.menu button { display: flex; width: 100%; justify-content: space-between; gap: 16px; padding: 8px 10px; border: 0; border-radius: 6px; background: none; cursor: pointer; font-size: 13.5px; text-align: left; }
.menu button:hover { background: rgba(255, 255, 255, .08); }
.menu button.on::after { content: "✓"; }
.endcard { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .8); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.endcard > div { width: min(380px, 76%); text-align: center; }
.endcard small { color: var(--mute); font-size: 13px; }
.endcard .next { display: block; margin: 10px 0 16px; }
.endcard .next img { border-radius: 10px; width: 100%; box-shadow: 0 0 0 1px var(--line2); }
.endcard .next strong { display: block; margin-top: 10px; font-size: 17px; }
.endcard .row { display: flex; gap: 10px; justify-content: center; }

.info { grid-area: info; padding: 16px 0 0; min-width: 0; }
.info h1 { margin: 0; font-size: clamp(20px, 1.9vw, 24px); font-weight: 650; letter-spacing: -.015em; line-height: 1.2; }
.info .sub { margin: 3px 0 0; color: var(--ink2); font-size: 15px; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.bar .meta { color: var(--mute); font-size: 13.5px; margin-right: auto; white-space: nowrap; }
.pill { height: 34px; padding: 0 13px; border-radius: 999px; border: 0; background: var(--s2); display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 550; cursor: pointer; white-space: nowrap; }
.pill:hover { background: var(--s3); }
.pill svg { width: 15px; height: 15px; }
.dl { position: relative; }
.dl .menu { right: 0; bottom: auto; top: 40px; min-width: 250px; }
.dl .menu a { display: flex; justify-content: space-between; gap: 16px; padding: 9px 10px; border-radius: 6px; font-size: 13.5px; }
.dl .menu a:hover { background: rgba(255, 255, 255, .08); }
.dl .menu a small { color: var(--mute); font-family: var(--mono); font-size: 12px; }
.desc { margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; background: var(--s1); color: var(--ink2); font-size: 14px; line-height: 1.55; cursor: pointer; }
.desc:hover { background: var(--s2); }
.desc > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.desc.open > span { display: block; }
.desc .src { display: none; margin-top: 10px; }
.desc.open .src { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.desc .src a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line2); text-underline-offset: 3px; }

.side { grid-area: side; position: sticky; top: 76px; display: flex; flex-direction: column; height: calc(100vh - 92px); min-height: 360px; min-width: 0; }
.watch.theater .side { margin-top: 16px; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 10px; background: var(--s1); flex: none; }
.tabs button { flex: 1; height: 32px; border: 0; border-radius: 7px; background: none; color: var(--mute); font-size: 13.5px; font-weight: 550; cursor: pointer; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { background: var(--s3); color: var(--ink); }
.tabs button:disabled { opacity: .35; cursor: default; }
.panel { flex: 1; min-height: 0; overflow-y: auto; margin-top: 10px; position: relative; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .16) transparent; }
.item { display: grid; grid-template-columns: 152px minmax(0, 1fr); gap: 10px; padding: 6px; border-radius: 10px; align-items: start; cursor: pointer; }
.item:hover { background: var(--s1); }
.item.on { background: var(--s2); }
.item .thumb { border-radius: 7px; }
.item .thumb .dur { font-size: 10.5px; right: 4px; bottom: 4px; padding: 1px 5px; }
.item b { font-size: 14px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item small { display: block; margin-top: 3px; font-size: 12.5px; color: var(--mute); }
.item small em { font-style: normal; color: var(--red); }
.chapters .item { grid-template-columns: 104px minmax(0, 1fr); align-items: center; }
.chapters .item small { font-family: var(--mono); font-size: 11.5px; margin: 0 0 2px; }
.chapters .item b { font-weight: 550; }
.chapters .item .thumb .line { display: block; width: calc(var(--f, 0) * 100%); background: var(--red); }

.txfind { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; margin-bottom: 4px; border-radius: 9px; background: var(--s1); border: 1px solid var(--line); }
.txfind svg { width: 15px; height: 15px; color: var(--mute); }
.txfind input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 13.5px; }
.txfind small { font: 500 11px var(--mono); color: var(--mute); }
.tx { padding: 4px 8px 50%; }
.tx h4 { margin: 20px 0 6px; font-size: 13px; font-weight: 600; color: var(--ink2); display: flex; gap: 8px; cursor: pointer; }
.tx h4 time { font: 500 11px var(--mono); color: var(--dim); margin-left: auto; padding-top: 2px; }
.tx h4:hover { color: var(--ink); }
.tx p { margin: 0 0 10px; font-size: 14.5px; line-height: 1.6; color: var(--mute); }
.tx p span { cursor: pointer; border-radius: 3px; }
.tx p span:hover { color: var(--ink); background: rgba(255, 255, 255, .07); }
.tx p.now { color: var(--ink2); }
.tx p span.now { color: #fff; background: rgba(229, 72, 77, .35); }
.tx p span.hit { background: rgba(255, 214, 10, .28); color: var(--ink); }
.tx p span.hit.cur { box-shadow: 0 0 0 2px rgba(255, 214, 10, .8); }
.txnow { position: sticky; bottom: 10px; display: block; margin: -46px auto 0; height: 32px; padding: 0 14px; border-radius: 999px; border: 0; background: var(--ink); color: #111; font-size: 12.5px; font-weight: 600; cursor: pointer; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }
.note { padding: 12px 8px; color: var(--mute); font-size: 13px; }

/* toast + keys */
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 50; transform: translate(-50%, 16px); display: flex; align-items: center; gap: 12px; padding: 9px 9px 9px 16px; border-radius: 999px; background: #222227; border: 1px solid var(--line2); box-shadow: 0 16px 48px rgba(0, 0, 0, .6); font-size: 13.5px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 28px); }
.toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast:not(:has(button)) { padding-right: 16px; }
.toast button { height: 30px; padding: 0 12px; border-radius: 999px; border: 0; background: var(--ink); color: #111; font-weight: 600; font-size: 12.5px; cursor: pointer; }
.keys { background: #18181c; color: var(--ink); border: 1px solid var(--line2); border-radius: 14px; padding: 20px 22px; width: min(380px, calc(100vw - 28px)); }
.keys::backdrop { background: rgba(0, 0, 0, .55); }
.keys dl { display: grid; grid-template-columns: max-content 1fr; gap: 9px 18px; margin: 0 0 16px; align-items: center; font-size: 14px; }
.keys dd { margin: 0; color: var(--ink2); }
.keys form { display: flex; justify-content: flex-end; }
.keys button { height: 34px; padding: 0 14px; border-radius: 8px; border: 0; background: var(--s3); cursor: pointer; }
kbd { display: inline-block; min-width: 24px; padding: 2px 6px; border-radius: 5px; background: var(--s3); border: 1px solid var(--line2); font: 500 11.5px var(--mono); text-align: center; }

@media (max-width: 1000px) {
  .watch, .watch.theater { grid-template-columns: minmax(0, 1fr); grid-template-areas: "player" "info" "side"; padding-top: 0; }
  .player, .watch.theater .player { border-radius: 0; margin: 0 calc(-1 * var(--gut)); }
  .watch.theater .screen { aspect-ratio: 16 / 9; height: auto; }
  .side, .watch.theater .side { position: static; height: auto; min-height: 0; margin-top: 22px; }
  .panel { max-height: 70vh; }
  .cb.th { display: none; }
}
@media (max-width: 640px) {
  .top { gap: 10px; }
  .brand span { display: none; }
  .links select { display: none; }
  .vol input { display: none; }
  .chap { visibility: hidden; }
  .grid { gap: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
