:root {
  --bg: #0c0d11;
  --panel: #15171e;
  --line: #262a35;
  --text: #eceef3;
  --muted: #8b91a1;
  --accent: #ff5a3c;
  --accent-2: #ffb03c;
  --on-accent: #ffffff;
  --radius: 14px;
  --player-radius: 18px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --card-min: 260px;
  --gap: 20px;
  --logo-h: 36px;
  --name-display: inline;
  --blur: 7px;
  --dim: 0.4;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body.theater-open { overflow: hidden; }

/* ---------- page that goes out of focus behind the player ---------- */
#app {
  transition: filter .55s var(--ease-out), transform .55s var(--ease-out), opacity .55s;
  transform-origin: 50% 30vh;
}
#app.defocus {
  filter: blur(var(--blur)) brightness(var(--dim)) saturate(.8);
  transform: scale(.965);
  pointer-events: none;
}

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 24px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: linear-gradient(var(--bg) 70%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; flex-shrink: 0; }
.logo { height: var(--logo-h); width: auto; display: block; }
.brand-name { display: var(--name-display); font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.search {
  flex: 1; max-width: 560px; margin-left: auto;
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 0 16px; height: 44px;
  transition: border-color .2s, box-shadow .2s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex-shrink: 0; }
.search input {
  flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: 0;
  color: var(--text); font: inherit; font-size: 16px;
}

main { padding: 6px clamp(16px, 4vw, 48px) 64px; }
.section-title { font-size: 15px; font-weight: 600; color: var(--muted); margin: 8px 0 18px; letter-spacing: .02em; }
.section-title b { color: var(--text); }

.grid {
  display: grid; gap: calc(var(--gap) * 1.4) var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(min(var(--card-min), 100%), 1fr));
}
.card { cursor: pointer; outline: none; }
.card .thumb {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(135deg, color-mix(in srgb, var(--panel) 80%, var(--text) 8%), var(--panel));
  transition: transform .35s var(--ease-out), box-shadow .35s var(--ease-out);
}
.card:hover .thumb, .card:focus-visible .thumb { transform: translateY(-3px); box-shadow: 0 14px 30px -12px color-mix(in srgb, #000 70%, transparent); }
.card:focus-visible .thumb { outline: 2px solid var(--accent); outline-offset: 3px; }
.card .thumb img, .card .thumb video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
}
.card .thumb video { opacity: 0; transition: opacity .3s; }
.card .thumb video.on { opacity: 1; }
.card .thumb .ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 48px; font-weight: 800; color: color-mix(in srgb, var(--muted) 45%, var(--panel));
}
.card .dur {
  position: absolute; right: 8px; bottom: 8px; z-index: 2;
  background: rgb(0 0 0 / .78); color: #fff; font-size: 12px; font-weight: 600;
  padding: 2px 6px; border-radius: 6px; font-variant-numeric: tabular-nums;
}
.card .pbar { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--accent); z-index: 3; }
.card h3 {
  margin: 10px 2px 2px; font-size: 15px; font-weight: 650; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card h3:empty::before { content: "Untitled"; color: var(--muted); font-weight: 500; }
.card .meta { margin: 0 2px; color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 60px 0; }

.loading { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 50; overflow: hidden; }
.loading span { position: absolute; inset: 0; width: 40%; background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: load 1s infinite linear; }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.loading.done { display: none; }

/* ---------- theater: player grows out of the thumbnail ---------- */
.theater { position: fixed; inset: 0; z-index: 20; }
.theater .backdrop { position: absolute; inset: 0; background: color-mix(in srgb, var(--bg) 35%, transparent); opacity: 0; transition: opacity .5s; }
.theater.in .backdrop { opacity: 1; }

.stage {
  position: fixed; z-index: 3; overflow: hidden; background: #000;
  border-radius: var(--player-radius); transform-origin: 0 0;
  box-shadow: 0 30px 80px -20px rgb(0 0 0 / .9), 0 0 0 1px rgb(255 255 255 / .06);
}
.stage:focus { outline: none; }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.stage .cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity .35s; z-index: 1; pointer-events: none; }
.stage .cover.gone { opacity: 0; }

.side-ad {
  position: fixed; z-index: 2; border: 0; border-radius: var(--radius); overflow: hidden;
  background: transparent; color-scheme: normal;
  opacity: 0;
}
.side-ad iframe { width: 100%; height: 100%; border: 0; display: block; background: transparent; color-scheme: normal; }

/* pause advertising layer: transparent HTML laid over the paused video */
.pause-layer {
  position: absolute; left: 0; right: 0; top: 0; bottom: 56px; z-index: 4;
  opacity: 0; visibility: hidden; transition: opacity .3s, visibility 0s .3s;
}
.pause-layer.on { opacity: 1; visibility: visible; transition: opacity .3s; }
.pause-layer .pause-box { position: absolute; inset: 0; }
.pause-layer iframe { width: 100%; height: 100%; border: 0; background: transparent; color-scheme: normal; display: block; }
/* a pause ad with a set size: exactly that size, centred over the paused video */
.pause-layer.sized { display: grid; place-items: center; cursor: pointer; }
.pause-layer.sized .pause-box { position: relative; inset: auto; flex: none; cursor: auto; }
.pause-layer.sized .ad-x { top: auto; bottom: calc(100% + 6px); right: 0; }
.pause-layer .ad-x {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  border: 0; border-radius: 999px; padding: 5px 10px; font: 600 12px system-ui, sans-serif;
  background: rgb(0 0 0 / .6); color: #fff; cursor: pointer;
}

.controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 14px;
  background: linear-gradient(transparent, rgb(0 0 0 / .75));
  opacity: 0; transition: opacity .3s;
}
.stage.ready .controls { opacity: 1; }
.stage.ready.idle .controls { opacity: 0; }
.stage.ready.idle { cursor: none; }
.controls button.pp {
  width: 40px; height: 40px; border: 0; border-radius: 50%; padding: 0; cursor: pointer;
  background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex-shrink: 0;
  transition: transform .15s;
}
.controls button.pp:hover { transform: scale(1.08); }
.controls button.pp svg { width: 18px; height: 18px; fill: currentColor; }
.time { font-size: 12.5px; color: #e6e8ee; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 84px; }

.seek { position: relative; flex: 1; height: 24px; cursor: pointer; touch-action: none; outline: none; }
.seek .track, .seek .buf, .seek .fill { position: absolute; left: 0; top: 50%; height: 4px; margin-top: -2px; border-radius: 4px; transition: height .15s, margin .15s; }
.seek .track { right: 0; background: rgb(255 255 255 / .22); }
.seek .buf { background: rgb(255 255 255 / .38); width: 0; }
.seek .fill { background: var(--accent); width: 0; }
.seek .knob {
  position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  background: #fff; left: 0; transform: scale(0); transition: transform .15s;
  box-shadow: 0 1px 4px rgb(0 0 0 / .5);
}
.seek:hover .knob, .seek:focus-visible .knob, .seek.drag .knob { transform: scale(1); }
.seek:hover .track, .seek:hover .buf, .seek:hover .fill, .seek.drag .track, .seek.drag .buf, .seek.drag .fill { height: 6px; margin-top: -3px; }
.seek .tip {
  position: absolute; bottom: 22px; transform: translateX(-50%); padding: 2px 6px; border-radius: 5px;
  background: rgb(0 0 0 / .8); font-size: 11px; color: #fff; pointer-events: none; opacity: 0; transition: opacity .15s;
  font-variant-numeric: tabular-nums;
}
.seek:hover .tip, .seek.drag .tip { opacity: 1; }

.theater .info {
  position: fixed; z-index: 3; overflow: auto;
  opacity: 0; transform: translateY(12px); transition: opacity .4s .25s, transform .4s .25s var(--ease-out);
}
.theater.in .info { opacity: 1; transform: none; }
.theater .info h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.01em; }
.theater .info .meta { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.theater .info p { margin: 0; color: color-mix(in srgb, var(--text) 82%, var(--muted)); white-space: pre-line; font-size: 14px; }

.theater .close {
  position: fixed; top: 14px; right: 16px; z-index: 6; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 75%, transparent); color: var(--text); cursor: pointer;
  display: grid; place-items: center; opacity: 0; transition: opacity .3s .2s, background .2s;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.theater.in .close { opacity: 1; }
.theater .close:hover { background: var(--accent); color: var(--on-accent); }
.theater .close svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: 10px; }
  .search { flex: 1 1 100%; max-width: 100%; min-width: 0; margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #app, .card .thumb, .theater .info { transition: none !important; }
}

/* muted autoplay (a tab nobody clicked in): one tap turns the sound on */
.unmute { position: absolute; left: 14px; top: 14px; z-index: 4; display: flex; align-items: center; gap: 7px;
  padding: 9px 14px; border: 0; border-radius: 99px; background: rgb(0 0 0 / .65); color: #fff;
  font: 600 14px var(--font, system-ui, sans-serif); cursor: pointer; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.unmute:hover { background: rgb(0 0 0 / .8); }
