/* ============ Tokens ============ */
:root {
  --bg: #0D0D0F;
  --surface: #17171B;
  --surface-2: #202027;
  --line: rgba(255, 255, 255, 0.09);
  --text: #F5F3F0;
  --text-dim: #A7A29B;
  --brand: #F26522;
  --brand-press: #D95415;
  --on-brand: #1A0D05;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.view { min-height: 100dvh; }

/* ============ Buttons ============ */
button { font: inherit; cursor: pointer; border: 0; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 26px;
  border-radius: 999px;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 17px;
  font-weight: 700;
  transition: transform 150ms ease-out, background 150ms ease-out;
  touch-action: manipulation;
}
.btn-primary:active { transform: scale(0.97); background: var(--brand-press); }
.btn-primary svg { width: 22px; height: 22px; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(13, 13, 15, 0.55);
  color: var(--text);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 150ms ease-out;
  touch-action: manipulation;
}
.btn-icon:active { transform: scale(0.92); }
.btn-icon svg { width: 22px; height: 22px; }

/* ============ Topbar ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 20px 12px;
  max-width: 1100px;
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.2px;
}
.brand img { border-radius: 10px; }
.topbar-note {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

/* ============ Hero ============ */
.hero {
  position: relative;
  max-width: 1100px;
  margin: 4px auto 8px;
  padding: 0 20px;
}
.hero-card {
  position: relative;
  display: block;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  aspect-ratio: 9 / 12;
  max-height: 72dvh;
  margin: 0 auto;
  background: var(--surface);
}
@media (min-width: 768px) {
  .hero-card { aspect-ratio: 16 / 9; max-height: 520px; }
}
.hero-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
}
.hero-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(13, 13, 15, 0.95) 0%, rgba(13, 13, 15, 0.35) 45%, rgba(13, 13, 15, 0.05) 70%);
}
.hero-body {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 22px;
}
.hero-badge {
  display: inline-block;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.hero-title {
  margin: 0 0 6px;
  font-size: clamp(26px, 6vw, 40px);
  font-weight: 800;
  line-height: 1.15;
}
.hero-tag { margin: 0 0 16px; color: var(--text-dim); font-size: 14px; font-weight: 600; }

/* ============ Rails ============ */
.row { max-width: 1100px; margin: 22px auto; padding: 0 20px; }
.row-title { font-size: 19px; font-weight: 700; margin: 0 0 12px; }
.rail {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }

.card {
  position: relative;
  flex: 0 0 42%;
  max-width: 190px;
  scroll-snap-align: start;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  transition: transform 150ms ease-out;
}
.card:active { transform: scale(0.97); }
@media (min-width: 768px) { .card { flex-basis: 190px; } }
.card img { aspect-ratio: 9 / 16; width: 100%; object-fit: cover; }
.card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 3px 10px;
  border-radius: 999px;
}
.card-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 52px;
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
}
.card-progress > span { display: block; height: 100%; background: var(--brand); }
.card-body { padding: 10px 12px 12px; }
.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-sub { margin: 3px 0 0; font-size: 12px; color: var(--text-dim); }

/* ============ Footer ============ */
.footer {
  max-width: 1100px;
  margin: 40px auto 0;
  padding: 26px 20px calc(30px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 14px;
}
.footer img { border-radius: 8px; margin-bottom: 10px; opacity: 0.85; }
.footer p { margin: 0 0 6px; max-width: 480px; }
.footer-fine { font-size: 12px; }

/* ============ Series detail ============ */
#view-serie { position: relative; }
.detail-backdrop {
  position: absolute;
  inset: 0 0 auto;
  height: 62dvh;
  background-size: cover;
  background-position: center 15%;
}
.detail-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--bg) 8%, rgba(13, 13, 15, 0.55) 55%, rgba(13, 13, 15, 0.25) 100%);
}
.detail-content {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: calc(14px + var(--safe-top)) 20px calc(40px + var(--safe-bottom));
}
.btn-back { margin-bottom: 34dvh; }
.detail-tag {
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin: 0 0 6px;
}
.detail-title { margin: 0 0 12px; font-size: clamp(28px, 7vw, 42px); font-weight: 800; line-height: 1.12; }
.detail-desc { margin: 0 0 22px; color: var(--text-dim); font-size: 16px; max-width: 56ch; }
.detail-eps-title { font-size: 18px; font-weight: 700; margin: 30px 0 12px; }
.detail-soon { color: var(--text-dim); font-size: 14px; margin-top: 14px; }

.ep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 10px;
}
.ep-btn {
  position: relative;
  min-height: 52px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  border: 1px solid var(--line);
  transition: transform 150ms ease-out, background 150ms ease-out;
  touch-action: manipulation;
}
.ep-btn:active { transform: scale(0.94); }
.ep-btn.seen { color: var(--text-dim); }
.ep-btn.current { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

/* ============ Player ============ */
#view-player { position: fixed; inset: 0; background: #000; z-index: 50; }
.feed {
  height: 100dvh;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }
.slide {
  position: relative;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
.slide video {
  height: 100%;
  width: auto;
  max-width: 100vw;
  object-fit: contain;
}
.slide-tap {
  position: absolute;
  inset: 0;
  background: transparent;
  border: 0;
}
.slide-paused {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(13, 13, 15, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms ease-out;
}
.slide.is-paused .slide-paused { opacity: 1; }
.slide-paused svg { width: 34px; height: 34px; fill: var(--text); margin-left: 4px; }
.slide-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(0px + var(--safe-bottom));
  height: 3px;
  background: rgba(255, 255, 255, 0.18);
}
.slide-progress > span { display: block; width: 0%; height: 100%; background: var(--brand); }
.slide-end {
  position: absolute;
  right: 14px;
  bottom: calc(22px + var(--safe-bottom));
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  background: rgba(13, 13, 15, 0.55);
  padding: 6px 12px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.player-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent);
  pointer-events: none;
}
.player-top .btn-icon { pointer-events: auto; }
.player-heading { flex: 1; min-width: 0; text-align: center; }
.player-heading p { margin: 0; }
#player-series {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#player-ep { font-size: 12px; color: var(--text-dim); font-weight: 600; }

.sound-hint {
  position: fixed;
  z-index: 60;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(30px + var(--safe-bottom));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 15px;
  font-weight: 700;
  min-height: 46px;
  padding: 10px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.sound-hint svg { width: 20px; height: 20px; }

/* ============ Episode sheet ============ */
.sheet-scrim {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, 0.55);
}
.sheet {
  position: fixed;
  z-index: 71;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 66dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 10px 20px calc(26px + var(--safe-bottom));
  animation: sheet-in 220ms ease-out;
}
@keyframes sheet-in {
  from { transform: translateY(40%); opacity: 0.5; }
  to { transform: translateY(0); opacity: 1; }
}
.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  margin: 4px auto 14px;
}
.sheet h2 { font-size: 18px; margin: 0 0 14px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
