/* ═══════════════════════════════════════════════════
   AniStream — Netflix-style design system
   ═══════════════════════════════════════════════════ */

:root {
  --bg: #141414;
  --bg-raised: #181818;
  --bg-card: #2f2f2f;
  --red: #e50914;
  --red-hover: #f6121d;
  --text: #fff;
  --text-dim: #b3b3b3;
  --text-faint: #808080;
  --nav-h: 68px;
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  overflow-x: hidden;
}
body.no-scroll { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img { display: block; }
.view[hidden] { display: none; }

::-webkit-scrollbar { width: 10px; height: 0; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #444; }

/* ═══ Nav ═══ */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4%;
  background: linear-gradient(180deg, rgba(0,0,0,0.75) 10%, transparent);
  transition: background-color 0.4s var(--ease);
}
.nav.scrolled { background: var(--bg); }

.nav-left { display: flex; align-items: center; gap: 34px; }
.brand {
  color: var(--red);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  white-space: nowrap;
  text-shadow: 0 2px 8px rgba(0,0,0,0.45);
}
.nav-links { display: flex; gap: 20px; }
.nav-link {
  font-size: 0.87rem;
  color: var(--text-dim);
  transition: color 0.25s;
  white-space: nowrap;
}
.nav-link:hover { color: #e5e5e5; }
.nav-link.active { color: #fff; font-weight: 600; }

.nav-right { display: flex; align-items: center; gap: 18px; }
.icon-btn {
  display: grid;
  place-items: center;
  color: #fff;
  padding: 4px;
  transition: opacity 0.2s;
}
.icon-btn:hover { opacity: 0.75; }

.search-box {
  display: flex;
  align-items: center;
  border: 1px solid transparent;
  background: transparent;
  transition: background-color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.search-box.open {
  background: rgba(0,0,0,0.78);
  border-color: rgba(255,255,255,0.55);
}
#search-input {
  width: 0;
  padding: 0;
  border: none;
  outline: none;
  background: transparent;
  color: #fff;
  font-size: 0.87rem;
  transition: width 0.35s var(--ease), padding 0.35s var(--ease);
}
.search-box.open #search-input { width: 220px; padding: 8px 12px 8px 6px; }
#search-input::placeholder { color: #8c8c8c; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--red), #7b0810);
  cursor: pointer;
  flex-shrink: 0;
}

/* ═══ Hero billboard ═══ */
.hero {
  position: relative;
  height: 88vh;
  min-height: 560px;
  display: flex;
  align-items: center;
  margin-bottom: -80px;
}
.hero-bg {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center 18%;
  filter: blur(18px) brightness(0.62) saturate(1.1);
  transform: scale(1.12);
  transition: background-image 0.6s var(--ease);
}
.hero-scrim {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0.65) 38%, rgba(0,0,0,0.15) 68%, transparent 100%),
    linear-gradient(0deg, var(--bg) 2%, rgba(20,20,20,0.55) 18%, transparent 55%);
}
.hero-content {
  position: relative;
  z-index: 2;
  padding: 0 4%;
  max-width: 42rem;
  animation: heroIn 0.7s var(--ease) both;
}
.hero-content.swap { animation: heroIn 0.55s var(--ease) both; }
@keyframes heroIn {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: none; }
}
.hero-tagline {
  color: var(--red);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.hero-title {
  font-size: clamp(2.4rem, 5.2vw, 4.2rem);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -2px;
  margin-bottom: 16px;
  text-shadow: 0 4px 24px rgba(0,0,0,0.65);
}
.hero-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.tag-hd {
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 1px;
}
.hero-blurb {
  font-size: 1.06rem;
  line-height: 1.5;
  color: #ddd;
  text-shadow: 0 2px 10px rgba(0,0,0,0.7);
  margin-bottom: 26px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hero-actions { display: flex; gap: 12px; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 26px;
  border-radius: 4px;
  font-size: 1.02rem;
  font-weight: 700;
  transition: background-color 0.2s, transform 0.15s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn-play { background: #fff; color: #000; }
.btn-play:hover { background: rgba(255,255,255,0.78); }
.btn-info { background: rgba(109,109,110,0.7); color: #fff; }
.btn-info:hover { background: rgba(109,109,110,0.45); }
.btn-ghost {
  background: rgba(42,42,42,0.85);
  border: 1px solid rgba(255,255,255,0.28);
  padding: 9px 20px;
  font-size: 0.9rem;
}
.btn-ghost:hover:not(:disabled) { background: rgba(80,80,80,0.9); border-color: #fff; }
.btn-ghost:disabled { opacity: 0.35; cursor: not-allowed; }

.hero-dots { display: flex; gap: 8px; margin-top: 30px; }
.hero-dot {
  width: 26px; height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.32);
  transition: background-color 0.3s;
}
.hero-dot.active { background: var(--red); }

/* ═══ Rows ═══ */
.rows { position: relative; z-index: 3; padding-bottom: 60px; }
.row { margin-bottom: 8px; }
.row-title {
  font-size: 1.32rem;
  font-weight: 700;
  padding: 0 4%;
  margin-bottom: 6px;
  color: #e5e5e5;
  letter-spacing: -0.3px;
}
.row-viewport { position: relative; }
.row-scroller {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;
  /* generous vertical padding so hover-scaled cards are not clipped */
  padding: 46px 4%;
  margin: -46px 0;
}
.row-scroller::-webkit-scrollbar { display: none; }

.row-arrow {
  position: absolute;
  top: 46px; bottom: 46px;
  width: 4%;
  z-index: 12;
  display: grid;
  place-items: center;
  background: rgba(10,10,10,0.55);
  color: #fff;
  opacity: 0;
  transition: opacity 0.25s, background-color 0.25s;
}
.row-viewport:hover .row-arrow { opacity: 1; }
.row-arrow:hover { background: rgba(10,10,10,0.82); }
.row-arrow svg { transition: transform 0.2s; }
.row-arrow:hover svg { transform: scale(1.35); }
.row-arrow.left { left: 0; }
.row-arrow.right { right: 0; }
.row-arrow[hidden] { display: none; }

/* ═══ Cards ═══ */
.card {
  position: relative;
  flex: 0 0 auto;
  width: 172px;
  border-radius: 6px;
  background: var(--bg-card);
  cursor: pointer;
  transition: transform 0.32s var(--ease), box-shadow 0.32s var(--ease);
  transform-origin: center center;
}
.card:hover {
  transform: scale(1.22);
  z-index: 20;
  box-shadow: 0 14px 34px rgba(0,0,0,0.75);
}
.row-scroller .card:first-child:hover { transform: scale(1.22) translateX(6%); }
.row-scroller .card:last-child:hover { transform: scale(1.22) translateX(-6%); }

.card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 6px;
  overflow: hidden;
  background: linear-gradient(135deg, #2a2a2a, #1c1c1c);
}
.card-img { width: 100%; height: 100%; object-fit: cover; }
.card-img.broken { opacity: 0; }
.card-fallback {
  position: absolute; inset: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  text-align: center;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-dim);
  line-height: 1.3;
}

.card-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 26px 10px 9px;
  background: linear-gradient(0deg, rgba(0,0,0,0.94) 25%, transparent);
  opacity: 0;
  transition: opacity 0.28s var(--ease);
}
.card:hover .card-overlay { opacity: 1; }
.card-overlay-title {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-overlay-row { display: flex; align-items: center; gap: 6px; }
.play-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  color: #000;
  display: grid;
  place-items: center;
  transition: transform 0.18s;
}
.play-dot:hover { transform: scale(1.14); }
.card-overlay-meta { font-size: 0.62rem; color: var(--text-dim); font-weight: 600; letter-spacing: 0.4px; }

/* Continue-watching extras */
.card-progress {
  position: absolute;
  left: 8px; right: 8px; bottom: 8px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.32);
  overflow: hidden;
}
.card-progress-fill { height: 100%; background: var(--red); }
.card:hover .card-progress { bottom: 46px; }
.card-remove {
  position: absolute;
  top: 6px; right: 6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.75);
  color: #fff;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.2s, background-color 0.2s;
  z-index: 3;
}
.card:hover .card-remove { opacity: 1; }
.card-remove:hover { background: var(--red); }
.card-ep-label {
  position: absolute;
  left: 8px; bottom: 16px;
  font-size: 0.66rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}
.card:hover .card-ep-label { opacity: 0; }

/* ═══ Results grid ═══ */
.results-wrap { padding: calc(var(--nav-h) + 40px) 4% 80px; min-height: 100vh; }
.results-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 26px; }
.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 34px 12px;
}
.poster-grid .card { width: 100%; }
.poster-grid .card:hover { transform: scale(1.14); }
.empty-state { color: var(--text-faint); text-align: center; padding: 60px 0; font-size: 0.95rem; }

/* ═══ Watch view ═══ */
.watch-view { padding: calc(var(--nav-h) + 24px) 4% 70px; min-height: 100vh; }
.watch-topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.back-arrow:hover { transform: translateX(-3px); transition: transform 0.2s; }
.watch-heading { display: flex; flex-direction: column; gap: 2px; }
.watch-show { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.4px; }
.watch-ep { font-size: 0.86rem; color: var(--text-dim); }

.player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,0.6);
}
#player { width: 100%; height: 100%; display: block; }
.player-loading {
  position: absolute; inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.65);
  pointer-events: none;
}
.player-loading[hidden] { display: none; }
.spinner {
  width: 44px; height: 44px;
  border: 3px solid rgba(255,255,255,0.22);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.watch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 20px;
}
.lang-group { display: flex; align-items: center; gap: 12px; }
.lang-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.lang-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.lang-pill {
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(42,42,42,0.9);
  border: 1px solid rgba(255,255,255,0.16);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 700;
  transition: all 0.2s;
}
.lang-pill:hover { color: #fff; border-color: rgba(255,255,255,0.6); }
.lang-pill.active { background: #fff; color: #000; border-color: #fff; }
.watch-nav { display: flex; gap: 10px; }

.watch-episodes { margin-top: 46px; }
.watch-episodes h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 14px; }
.ep-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; }
.ep-chip {
  flex: 0 0 auto;
  min-width: 54px;
  padding: 11px 14px;
  border-radius: 5px;
  background: var(--bg-card);
  border: 1px solid transparent;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-dim);
  transition: all 0.18s;
}
.ep-chip:hover { background: #3d3d3d; color: #fff; }
.ep-chip.active { background: #fff; color: #000; }

/* ═══ Detail modal ═══ */
.modal-backdrop {
  position: fixed; inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.72);
  overflow-y: auto;
  padding: 46px 0;
  animation: fadeIn 0.25s var(--ease);
}
.modal-backdrop[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  position: relative;
  width: min(880px, 92vw);
  margin: 0 auto;
  background: var(--bg-raised);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 22px 70px rgba(0,0,0,0.85);
  animation: modalIn 0.32s var(--ease);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(28px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  z-index: 5;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #181818;
  color: #fff;
  display: grid;
  place-items: center;
  transition: background-color 0.2s;
}
.modal-close:hover { background: #333; }

.modal-hero { position: relative; height: 340px; }
.modal-hero-bg {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center 20%;
  filter: blur(12px) brightness(0.7);
  transform: scale(1.1);
}
.modal-hero-scrim {
  position: absolute; inset: 0;
  background:
    linear-gradient(0deg, var(--bg-raised) 1%, transparent 55%),
    linear-gradient(90deg, rgba(0,0,0,0.8), transparent 70%);
}
.modal-hero-content {
  position: absolute;
  left: 40px; bottom: 26px; right: 40px;
  z-index: 2;
}
.modal-hero-content h2 {
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 18px;
  text-shadow: 0 3px 16px rgba(0,0,0,0.7);
}
.modal-actions { display: flex; align-items: center; gap: 10px; }
.circle-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.55);
  background: rgba(42,42,42,0.7);
  color: #fff;
  display: grid;
  place-items: center;
  transition: all 0.2s;
}
.circle-btn:hover { border-color: #fff; background: rgba(255,255,255,0.15); }
.circle-btn.active { background: #fff; color: #000; border-color: #fff; }

.modal-body { padding: 26px 40px 40px; }
.modal-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.88rem;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.tag-match { color: #46d369; font-weight: 700; }
.tag-outline {
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 3px;
  padding: 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.5px;
}
.modal-alt { font-size: 0.85rem; color: var(--text-faint); margin-bottom: 12px; font-style: italic; }
.modal-alt:empty { display: none; }
.modal-desc { font-size: 0.96rem; line-height: 1.6; color: #d2d2d2; margin-bottom: 18px; }
.genre-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 30px; }
.genre-chips:empty { display: none; }
.genre-chip {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-dim);
  background: #2b2b2b;
  border: 1px solid #3d3d3d;
  border-radius: 999px;
  padding: 4px 12px;
}
.modal-section-title { font-size: 1.18rem; font-weight: 700; margin-bottom: 14px; }

.modal-episodes { display: flex; flex-direction: column; }
.ep-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 10px;
  border-top: 1px solid #333;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.18s;
}
.ep-row:hover { background: #333; }
.ep-row-num { font-size: 1.15rem; color: var(--text-faint); font-weight: 600; width: 26px; text-align: center; flex-shrink: 0; }
.ep-row-play {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.ep-row:hover .ep-row-play { border-color: #fff; background: rgba(255,255,255,0.16); }
.ep-row-body { flex: 1; min-width: 0; }
.ep-row-title { font-size: 0.94rem; font-weight: 600; margin-bottom: 5px; }
.ep-row-sub { font-size: 0.78rem; color: var(--text-faint); }
.ep-row-bar {
  margin-top: 7px;
  height: 3px;
  border-radius: 2px;
  background: #4d4d4d;
  overflow: hidden;
  max-width: 190px;
}
.ep-row-bar span { display: block; height: 100%; background: var(--red); }
.ep-badge {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-faint);
  border: 1px solid #4d4d4d;
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 8px;
}

/* ═══ Toast ═══ */
.toast {
  position: fixed;
  bottom: 30px; left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  background: #232323;
  border: 1px solid #3d3d3d;
  border-left: 3px solid var(--red);
  padding: 13px 22px;
  border-radius: 5px;
  font-size: 0.88rem;
  box-shadow: 0 10px 34px rgba(0,0,0,0.65);
  animation: toastIn 0.3s var(--ease);
}
.toast[hidden] { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ═══ Skeleton ═══ */
.skeleton {
  background: linear-gradient(100deg, #232323 30%, #2e2e2e 50%, #232323 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s infinite linear;
  border-radius: 6px;
}
@keyframes shimmer { to { background-position: -220% 0; } }
.skel-card { flex: 0 0 auto; width: 172px; aspect-ratio: 2/3; }

/* ═══ Responsive ═══ */
@media (max-width: 900px) {
  .nav-links { display: none; }
  .hero { height: 74vh; min-height: 460px; }
  .card { width: 138px; }
  .skel-card { width: 138px; }
  .modal-hero { height: 250px; }
  .modal-hero-content, .modal-body { left: 22px; right: 22px; padding-left: 22px; padding-right: 22px; }
  .modal-hero-content { left: 22px; right: 22px; }
  .modal-body { padding: 22px; }
}
@media (max-width: 560px) {
  .brand { font-size: 1.2rem; }
  .card { width: 116px; }
  .skel-card { width: 116px; }
  .hero-blurb { font-size: 0.94rem; -webkit-line-clamp: 4; }
  .search-box.open #search-input { width: 140px; }
  .watch-bar { flex-direction: column; align-items: flex-start; }
}

/* ═══════════════════════════════════════════════════
   Mobile, touch & PWA
   ═══════════════════════════════════════════════════ */

/* ─── Viewport height ───
   Phones report `vh` against the LARGEST viewport (browser chrome hidden), so a
   100vh block stays taller than what is actually visible and the page scrolls
   past its content into dead space at the bottom. `dvh` tracks the visible area
   instead. Browsers without dvh ignore these rules and keep the vh values above,
   so this is a safe progressive upgrade. */
.hero { height: 88dvh; }
.results-wrap { min-height: 100dvh; }
.watch-view { min-height: 100dvh; }

/* Stop rubber-band scrolling from revealing a band of page background. */
html, body { overscroll-behavior-y: none; }
body { -webkit-tap-highlight-color: transparent; }

/* ─── Safe areas (notch + home indicator) ───
   index.html sets viewport-fit=cover so the art reaches the screen edges; these
   keep actual controls out from under the notch and home indicator. Each inset
   is 0 on hardware without them, so desktop is untouched. */
.nav {
  height: calc(var(--nav-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  padding-left: max(4%, env(safe-area-inset-left));
  padding-right: max(4%, env(safe-area-inset-right));
}
.results-wrap { padding-top: calc(var(--nav-h) + env(safe-area-inset-top) + 40px); }
.watch-view { padding-top: calc(var(--nav-h) + env(safe-area-inset-top) + 24px); }
.rows { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
.results-wrap { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
.watch-view { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
.toast { bottom: calc(30px + env(safe-area-inset-bottom)); }

/* ─── Touch devices ───
   Tapping an element on iOS applies :hover and leaves it stuck, so a tapped card
   would stay blown up at 1.22x. Neutralise hover-driven motion where there is no
   real pointer, and surface the controls that were hover-gated. */
@media (hover: none) {
  .card:hover,
  .row-scroller .card:first-child:hover,
  .row-scroller .card:last-child:hover {
    transform: none;
    box-shadow: none;
    z-index: auto;
  }
  .card:active { transform: scale(0.97); transition: transform 0.12s var(--ease); }
  .card:hover .card-overlay { opacity: 0; }
  .card:hover .card-progress { bottom: 8px; }
  .card:hover .card-ep-label { opacity: 1; }
  .card-remove { opacity: 1; }          /* otherwise unreachable without hover */
  .row-arrow { display: none; }          /* swipe instead */
  .row-scroller { padding-top: 12px; padding-bottom: 12px; margin: 0; }
  .row { margin-bottom: 4px; }
  .btn:hover, .lang-pill:hover, .ep-chip:hover, .icon-btn:hover { background: inherit; }
}

/* ─── Phones ─── */
@media (max-width: 560px) {
  .hero { height: 76dvh; min-height: 420px; margin-bottom: -50px; }
  .hero-content { max-width: none; }
  .hero-title { font-size: clamp(2rem, 9vw, 2.8rem); letter-spacing: -1.2px; }
  .hero-actions { flex-wrap: wrap; gap: 10px; }
  .hero-actions .btn { flex: 1 1 auto; justify-content: center; padding: 12px 18px; font-size: 0.95rem; }
  .hero-dots { margin-top: 22px; }

  .row-title { font-size: 1.05rem; }
  .results-wrap { padding-top: calc(var(--nav-h) + env(safe-area-inset-top) + 22px); }
  .results-title { font-size: 1.2rem; margin-bottom: 18px; }
  .poster-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 16px 10px; }

  /* Full-bleed sheet reads better than a floating dialog on a phone. */
  .modal-backdrop { padding: 0; background: var(--bg-raised); }
  .modal { width: 100%; min-height: 100dvh; border-radius: 0; box-shadow: none; }
  .modal-hero { height: 210px; }
  .modal-hero-content { left: 18px; right: 18px; bottom: 18px; }
  .modal-hero-content h2 { font-size: 1.5rem; margin-bottom: 14px; }
  .modal-body { padding: 20px 18px calc(40px + env(safe-area-inset-bottom)); }
  .modal-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
  .ep-row { gap: 12px; padding: 12px 6px; }
  .ep-row-play { width: 34px; height: 34px; }

  .watch-topbar { gap: 10px; }
  .watch-show { font-size: 1.05rem; }
  .watch-view { padding-left: max(4%, env(safe-area-inset-left)); padding-right: max(4%, env(safe-area-inset-right)); }
  .player-wrap { border-radius: 6px; }
  .watch-bar { gap: 12px; margin-top: 16px; }
  .lang-pill { padding: 10px 16px; }     /* larger touch target */
  .watch-nav { width: 100%; }
  .watch-nav .btn { flex: 1; justify-content: center; }
  .watch-episodes { margin-top: 30px; }
  .ep-chip { min-width: 50px; padding: 12px 14px; }
}

/* Landscape phone: the hero would otherwise eat the whole screen. */
@media (max-height: 480px) and (orientation: landscape) {
  .hero { height: auto; min-height: 0; padding: calc(var(--nav-h) + 20px) 0 24px; margin-bottom: 0; }
  .modal-hero { height: 180px; }
}

/* ─── Installed as an app ───
   No browser chrome to scroll away, so the hero can safely use the full height. */
@media all and (display-mode: standalone) {
  .hero { height: 82dvh; }
}
