:root {
  --bg: #0a0b0e;
  --bg-raised: #12141a;
  --surface: #171a21;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #eef0f4;
  --muted: #8d95a2;
  --accent: #b6f36a;
  --accent-ink: #0d1a03;
  --radius: 16px;
  --gutter: clamp(16px, 3vw, 40px);
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.8);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  background-image:
    radial-gradient(1100px 520px at 85% -12%, rgba(182, 243, 106, 0.09), transparent 62%),
    radial-gradient(900px 520px at -8% 6%, rgba(96, 132, 255, 0.07), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.is-locked { overflow: hidden; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 10px; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: calc(12px + env(safe-area-inset-top)) var(--gutter) 12px;
  background: rgba(10, 11, 14, 0.72);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
.brand__name { font-size: 22px; font-weight: 800; letter-spacing: -0.035em; }
.brand__tag {
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
  background: var(--accent); color: var(--accent-ink);
  padding: 3px 7px; border-radius: 7px; transform: translateY(1px);
}
.top__meta { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- sections ---------- */
#app { padding: 8px var(--gutter) 40px; }
#app[inert] { filter: none; }
.section { margin-top: 28px; }
.section__title {
  display: flex; align-items: baseline; gap: 8px;
  margin: 0 0 14px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em;
}
.section__count { font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------- cards ---------- */
.card {
  display: block; color: inherit; text-decoration: none;
  transition: transform 0.25s var(--ease);
}
.card:active { transform: scale(0.98); }
.thumb {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  transition: box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
}
.thumb img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.6s var(--ease), opacity 0.4s ease;
}
.card:hover .thumb { border-color: var(--line-strong); box-shadow: var(--shadow); }
.card:hover .thumb img { transform: scale(1.04); }
.pill {
  position: absolute; right: 8px; bottom: 8px;
  padding: 3px 7px; border-radius: 7px;
  background: rgba(8, 9, 12, 0.72); backdrop-filter: blur(8px);
  font-size: 12px; font-weight: 700; letter-spacing: 0.01em; font-variant-numeric: tabular-nums;
}

/* video grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: 26px 18px;
}
.card--video .thumb { aspect-ratio: 16 / 9; }
.card--video .card__title {
  margin-top: 11px; font-size: 15px; font-weight: 600; line-height: 1.3; letter-spacing: -0.005em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card--video .card__channel { margin-top: 4px; font-size: 13px; color: var(--muted); }

/* shorts rail */
.section--rail .rail {
  display: flex; gap: 14px;
  margin: 0 calc(-1 * var(--gutter));
  padding: 4px var(--gutter) 14px;
  overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x proximity; scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
}
.section--rail .rail::-webkit-scrollbar { display: none; }
.card--short {
  flex: 0 0 auto; width: clamp(148px, 17vw, 196px);
  scroll-snap-align: start;
}
.card--short .thumb { aspect-ratio: 9 / 16; }
.card--short .pill { right: auto; left: 8px; top: 8px; bottom: auto; }
.card--short .card__overlay {
  position: absolute; inset: auto 0 0 0; padding: 40px 12px 12px;
  background: linear-gradient(to top, rgba(6, 7, 10, 0.92), rgba(6, 7, 10, 0));
}
.card--short .card__title {
  font-size: 13px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* skeletons */
.skeleton .thumb, .skeleton .line {
  background: linear-gradient(100deg, var(--surface) 30%, #1e222b 50%, var(--surface) 70%);
  background-size: 300% 100%;
  animation: shimmer 1.6s linear infinite;
}
.skeleton .line { height: 14px; border-radius: 6px; margin-top: 12px; width: 85%; }
.skeleton .line + .line { width: 45%; margin-top: 8px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* states */
.state {
  margin: 80px auto; max-width: 420px; text-align: center; color: var(--muted); font-size: 15px; line-height: 1.5;
}
.state .btn { margin-top: 18px; }

.foot {
  padding: 0 var(--gutter) calc(28px + env(safe-area-inset-bottom));
  font-size: 12px; color: var(--muted); text-align: center;
}
.foot .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin: 0 6px 1px 0; }
.foot .dot--snapshot { background: #ffb85c; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--line-strong); border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); padding: 10px 18px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.2s ease, transform 0.15s var(--ease);
}
.btn:hover { background: rgba(255, 255, 255, 0.11); }
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--primary:hover { background: #c6f98a; }

.icon-btn, .nav {
  appearance: none; border: 1px solid rgba(255, 255, 255, 0.12); cursor: pointer;
  display: grid; place-items: center; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: background 0.2s ease, transform 0.15s var(--ease), opacity 0.2s ease;
}
.icon-btn:hover, .nav:hover { background: rgba(255, 255, 255, 0.16); }
.icon-btn:active, .nav:active { transform: scale(0.94); }
.icon-btn svg, .nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn { width: 44px; height: 44px; }

/* ---------- player ---------- */
.player {
  position: fixed; inset: 0; z-index: 50;
  display: none;
  grid-template-rows: auto 1fr;
  grid-template-columns: minmax(0, 1fr); /* don't let a long nowrap title widen the column past the viewport */
  background: #050608;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.player.is-open { display: grid; animation: player-in 0.26s var(--ease); }
@keyframes player-in { from { opacity: 0; transform: scale(1.02); } to { opacity: 1; transform: none; } }

.player__ambient {
  position: absolute; inset: -12%;
  background: var(--ambient) center / cover no-repeat;
  filter: blur(80px) saturate(1.4);
  opacity: 0.42;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.player__ambient::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(5, 6, 8, 0.2), rgba(5, 6, 8, 0.6));
}

.player__bar {
  position: relative; z-index: 2; min-width: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 12px var(--gutter);
  min-height: 68px;
}
.player__info { min-width: 0; flex: 1; }
.player__title {
  font-size: 15px; font-weight: 700; letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player__channel { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player__index { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.player__stage {
  position: relative; z-index: 1;
  display: grid; place-items: center;
  min-height: 0;
  padding: 0 calc(var(--gutter) + 56px) calc(var(--gutter) * 0.8);
  touch-action: pan-y;
}
.player__frame {
  position: relative;
  border-radius: 20px; overflow: hidden;
  background: #000;
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.06);
  width: min(100%, calc((100dvh - 150px) * 16 / 9));
  aspect-ratio: 16 / 9;
}
.player.is-portrait .player__ambient { opacity: 0.55; }
.player.is-portrait .player__frame {
  width: auto;
  height: min(calc(100dvh - 130px), calc((100dvw - 2 * var(--gutter) - 112px) * 16 / 9));
  aspect-ratio: 9 / 16;
}
.player__frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 52px; height: 52px; z-index: 3;
}
.nav:active { transform: translateY(-50%) scale(0.94); }
.nav--prev { left: max(10px, env(safe-area-inset-left)); }
.nav--next { right: max(10px, env(safe-area-inset-right)); }
.nav:disabled { opacity: 0.25; cursor: default; }

/* up-next cover */
.cover {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-items: center;
  padding: var(--gutter);
  background: rgba(5, 6, 8, 0.86);
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  cursor: pointer;
}
.cover__card {
  width: min(100%, 360px);
  padding: 18px;
  border-radius: 20px;
  background: rgba(14, 16, 21, 0.9);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow);
  animation: cover-in 0.3s var(--ease);
  cursor: pointer;
}
@keyframes cover-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.cover__kicker { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.cover__thumb { margin-top: 12px; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; background: #000; }
.cover__thumb img { width: 100%; height: 100%; object-fit: cover; }
.player.is-portrait .cover__thumb { aspect-ratio: 9 / 16; max-height: 200px; width: auto; margin-inline: auto; }
.cover__title { margin-top: 12px; font-size: 15px; font-weight: 600; line-height: 1.35; }
.cover__bar { margin-top: 14px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.cover__bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width linear; }
.cover__bar i.is-running { width: 100%; }
.cover__actions { display: flex; gap: 10px; margin-top: 14px; }
.cover__actions .btn { flex: 1; }
.cover.is-final .cover__thumb, .cover.is-final .cover__bar { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .player__stage { padding-left: var(--gutter); padding-right: var(--gutter); }
  .player.is-portrait .player__frame {
    height: min(calc(100dvh - 130px), calc((100dvw - 2 * var(--gutter)) * 16 / 9));
  }
  .nav { width: 46px; height: 46px; top: auto; bottom: calc(14px + env(safe-area-inset-bottom)); transform: none; }
  .nav:active { transform: scale(0.94); }
  .player__index { display: none; }
  .grid { gap: 22px 14px; }
}

@media (hover: none) {
  .card:hover .thumb img { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
.state .btn, .state a.btn { display: inline-block; text-decoration: none; margin-top: 18px; }
