:root {
  /* Surfaces */
  --stage: #080808;
  --surface: #131313;
  --chrome: #1f1f1f;
  --hairline: rgba(255,255,255,0.08);
  --hairline-strong: rgba(255,255,255,0.16);

  /* Text */
  --text-1: #ffffff;
  --text-2: rgba(255,255,255,0.65);
  --text-3: rgba(255,255,255,0.40);

  /* Accent */
  --accent: #e04848;
  --accent-hover: #ff6060;
  --accent-pressed: #b73838;

  /* Type */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;

  /* Radii */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 9999px;

  /* Spacing — 4px base */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 48px; --s-9: 64px;

  /* Motion */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-entry:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-cinema:   cubic-bezier(0.65, 0, 0.35, 1);
  --t-fast: 200ms;
  --t-pop: 320ms;
  --t-cinema: 600ms;

  /* Layout */
  --max-width: 1440px;
  --gutter: 48px;
}

@media (max-width: 768px) {
  :root { --gutter: 16px; }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--stage);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

main { flex: 1; }

a { color: inherit; text-decoration: none; }

button {
  font-family: inherit;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
}

img { display: block; max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---------- Type scale ---------- */
.t-display {
  font-size: clamp(44px, 5vw, 64px);
  line-height: 1.0;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0;
}
.t-h1 { font-size: 28px; line-height: 1.15; font-weight: 500; letter-spacing: -0.01em; margin: 0; }
.t-h2 { font-size: 18px; line-height: 1.3;  font-weight: 500; margin: 0; }
.t-body { font-size: 14px; line-height: 1.6; font-weight: 400; margin: 0; }
.t-caption { font-size: 12px; line-height: 1.4; font-weight: 400; margin: 0; }
.t-eyebrow {
  font-size: 11px;
  line-height: 1.3;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 0;
}

/* ---------- Site bar ---------- */
.site-bar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
  background: var(--stage);
  border-bottom: 0.5px solid var(--hairline);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 500;
  font-size: 16px;
  color: var(--text-1);
}
.logo-mark { display: block; }

.status {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text-2);
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease-standard);
}
.status[data-mode="playing"] .status-dot { opacity: 1; animation: pulse 1.6s var(--ease-standard) infinite; }
.status[data-mode="playing"] .status-text { color: var(--text-1); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (max-width: 480px) {
  .status-text { display: none; }
}

/* ---------- Hero ---------- */
.hero {
  padding: var(--s-6) var(--gutter) var(--s-7);
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
}
.hero-frame {
  position: relative;
  aspect-ratio: 21 / 9;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
}
@media (max-width: 768px) {
  .hero-frame { aspect-ratio: 16 / 10; border-radius: var(--r-md); }
}
.hero-video, .hero-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.hero-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.92) 100%);
  pointer-events: none;
}
.hero-content {
  position: absolute;
  left: var(--s-7);
  right: var(--s-7);
  bottom: var(--s-7);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  pointer-events: none;
  max-width: 720px;
}
@media (max-width: 768px) {
  .hero-content { left: var(--s-4); right: var(--s-4); bottom: var(--s-5); }
}
.hero-eyebrow { color: var(--accent); }
.hero-title { color: var(--text-1); }
@media (max-width: 768px) {
  .hero-title { font-size: clamp(28px, 6vw, 44px); }
}
.hero-meta { color: var(--text-2); }
.hero-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: rgba(255,255,255,0.06);
}
.hero-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 250ms linear;
}
.hero-click {
  position: absolute;
  inset: 0;
  background: transparent;
  cursor: pointer;
  border: 0;
  z-index: 2;
}
.hero-click:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
}

/* ---------- Rails ---------- */
.rail {
  padding: 0 var(--gutter);
  margin: 0 auto var(--s-8);
  max-width: var(--max-width);
  width: 100%;
  position: relative;
}
.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-left: 2px solid var(--accent);
  padding: 0 var(--s-4);
  margin-bottom: var(--s-4);
}
.rail-eyebrow { color: var(--text-1); }
.rail-meta { color: var(--text-3); }

.rail-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - var(--s-3) * 2) / 3);
  gap: var(--s-3);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding-bottom: var(--s-2);
}
.rail-track::-webkit-scrollbar { display: none; }
.rail-track > * { scroll-snap-align: start; }

@media (min-width: 1920px) {
  .rail-track { grid-auto-columns: calc((100% - var(--s-3) * 3) / 4); }
}
@media (max-width: 1024px) {
  .rail-track { grid-auto-columns: calc((100% - var(--s-3)) / 2); }
}
@media (max-width: 480px) {
  .rail-track { grid-auto-columns: 83.3%; } /* ~1.2 visible */
}

.rail-edge {
  position: absolute;
  top: 32px;
  bottom: var(--s-2);
  right: 0;
  width: var(--gutter);
  background: linear-gradient(270deg, var(--stage), transparent);
  pointer-events: none;
}

/* ---------- Tile ---------- */
.tile {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  text-align: left;
  border-radius: var(--r-sm);
  background: transparent;
  transition: transform var(--t-fast) var(--ease-standard), box-shadow var(--t-fast) var(--ease-standard);
}
.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px var(--accent);
}
.tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.tile-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface);
}
.tile-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tile-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,0.92) 100%);
  pointer-events: none;
}
.tile-play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border-radius: var(--r-pill);
  background: rgba(0,0,0,0.55);
  color: var(--text-1);
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease-standard);
}
.tile:hover .tile-play, .tile:focus-visible .tile-play { opacity: 1; }

.tile-info {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding: 0 var(--s-1);
}
.tile-title {
  color: var(--text-1);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-meta {
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
}

/* ---------- Footer ---------- */
.site-foot {
  padding: var(--s-7) var(--gutter);
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.04em;
}
.site-foot .dot { color: var(--text-3); }

/* ---------- Empty state ---------- */
.empty {
  min-height: 60vh;
  display: grid;
  place-items: center;
  color: var(--text-2);
}

/* ---------- Popout dialog ---------- */
.popout {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text-1);
  max-width: 100vw;
  max-height: 100vh;
  width: 100vw;
  height: 100vh;
  margin: 0;
}
.popout::backdrop {
  background: rgba(0,0,0,0.85);
}
.popout[open] {
  display: grid;
  place-items: center;
}
.popout-inner {
  position: relative;
  width: 92vw;
  height: 92vh;
  max-width: 1600px;
  background: #0a0a0a;
  border-radius: var(--r-lg);
  overflow: hidden;
  display: grid;
  grid-template-rows: 44px 1fr 60px;
  animation: popIn var(--t-pop) var(--ease-entry);
}
@keyframes popIn {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@media (max-width: 768px) {
  .popout-inner {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    grid-template-rows: 44px 1fr auto;
  }
}

.popout-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s-5);
  border-bottom: 0.5px solid var(--hairline);
}
.popout-now { color: var(--text-3); }
.popout-close {
  width: 28px;
  height: 28px;
  border-radius: var(--r-pill);
  border: 0.5px solid var(--hairline-strong);
  color: var(--text-1);
  display: grid;
  place-items: center;
  transition: background var(--t-fast) var(--ease-standard);
}
.popout-close:hover { background: rgba(255,255,255,0.06); }

.popout-stage {
  position: relative;
  background: #000;
  overflow: hidden;
}
.popout-video, .popout-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.popout-video {
  transition: opacity var(--t-cinema) var(--ease-cinema);
}
.popout-video.fading {
  opacity: 0;
}
.popout-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: rgba(255,255,255,0.08);
  z-index: 4;
}
.popout-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 250ms linear;
}

.popout-prev, .popout-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
}
.popout-prev {
  left: var(--s-4);
  width: 40px;
  height: 40px;
  border-radius: var(--r-pill);
  border: 0.5px solid var(--hairline-strong);
  background: rgba(0,0,0,0.45);
  color: var(--text-1);
  display: grid;
  place-items: center;
  font-size: 22px;
  line-height: 1;
  backdrop-filter: blur(4px);
  transition: background var(--t-fast) var(--ease-standard);
}
.popout-prev:hover { background: rgba(0,0,0,0.7); }

.popout-next {
  right: var(--s-4);
  background: var(--accent);
  color: var(--text-1);
  font-size: 13px;
  font-weight: 500;
  padding: 14px 22px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  transition: background var(--t-fast) var(--ease-standard), transform var(--t-fast) var(--ease-standard);
  box-shadow: 0 6px 24px rgba(224,72,72,0.35);
}
.popout-next:hover { background: var(--accent-hover); transform: translateY(-50%) scale(1.02); }
.popout-next:active { background: var(--accent-pressed); }

@media (max-width: 768px) {
  .popout-prev {
    top: auto;
    transform: none;
    bottom: 84px;
    left: var(--s-4);
    width: 36px;
    height: 36px;
  }
  .popout-next {
    top: auto;
    transform: none;
    right: var(--s-4);
    bottom: var(--s-4);
    left: 64px;
    justify-content: center;
    padding: 16px 22px;
  }
}

.popout-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: 0 var(--s-6);
  border-top: 0.5px solid var(--hairline);
}
@media (max-width: 768px) {
  .popout-bottom {
    flex-direction: column;
    align-items: flex-start;
    padding: var(--s-3) var(--s-4) calc(var(--s-3) + 56px);
    gap: var(--s-1);
  }
}
.popout-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.popout-studio { color: var(--accent); }
.popout-title { color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.popout-queue { color: var(--text-2); white-space: nowrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--s-7);
  transform: translateX(-50%);
  background: var(--chrome);
  color: var(--text-1);
  font-size: 12px;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-pill);
  border: 0.5px solid var(--hairline-strong);
  z-index: 100;
  animation: toastIn var(--t-fast) var(--ease-standard);
}
@keyframes toastIn {
  from { transform: translate(-50%, 12px); opacity: 0; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .popout-video.fading { opacity: 1; }
}
