/* ── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0b0b0f;
  --bg2:       #13131a;
  --bg3:       #1c1c28;
  --accent:    #7c3aed;
  --accent2:   #a855f7;
  --text:      #e2e2f0;
  --muted:     #8585a4;
  --card-w:    180px;
  --radius:    10px;
  --shadow:    0 4px 24px rgba(0,0,0,.6);
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
img { display: block; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }

/* ── Header ────────────────────────────────────────────────── */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 32px;
  height: 64px;
  background: linear-gradient(to bottom, rgba(11,11,15,.95), transparent);
  backdrop-filter: blur(8px);
  transition: background .3s;
}
#header.scrolled {
  background: rgba(11,11,15,.97);
  box-shadow: 0 1px 0 rgba(255,255,255,.06);
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.5px;
  white-space: nowrap;
}
.logo span { color: var(--accent2); }

.tabs { display: flex; gap: 4px; }
.tab {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--muted);
  transition: all .2s;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--accent);
  color: #fff;
}

.search-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  background: var(--bg3);
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,.08);
  overflow: hidden;
  transition: border-color .2s;
}
.search-wrap:focus-within { border-color: var(--accent); }

#searchInput {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  padding: 8px 16px;
  width: 260px;
  font-size: .9rem;
}
#searchInput::placeholder { color: var(--muted); }

#searchBtn {
  padding: 8px 14px;
  color: var(--muted);
  transition: color .2s;
}
#searchBtn:hover { color: var(--accent2); }
#searchBtn svg { width: 18px; height: 18px; }

/* ── Hero ──────────────────────────────────────────────────── */
#hero {
  position: relative;
  height: 520px;
  margin-bottom: 48px;
  overflow: hidden;
}

#heroBg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center top;
  filter: brightness(.4);
  transition: background-image .5s;
}
#heroBg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right, rgba(11,11,15,.9) 35%, transparent 80%
  ), linear-gradient(
    to top, var(--bg) 0%, transparent 40%
  );
}

#heroContent {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  padding: 0 48px 56px;
  max-width: 640px;
}

#heroBadge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 12px;
  width: fit-content;
}

#heroTitle {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 12px;
  text-shadow: 0 2px 12px rgba(0,0,0,.6);
}

#heroOverview {
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 16px;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  font-size: .85rem;
  color: var(--muted);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  width: fit-content;
  transition: background .2s, transform .15s;
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-2px); }
.btn-primary svg { width: 20px; height: 20px; }

/* ── Content sections ──────────────────────────────────────── */
#main { padding: 0 32px 80px; }

.content-section { margin-bottom: 48px; }

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

/* ── Card grid ─────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr));
  gap: 16px;
}

.card {
  background: var(--bg2);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  position: relative;
}
.card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow);
  z-index: 2;
}

.card-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: var(--bg3);
}

.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.85) 0%, transparent 55%);
  opacity: 0;
  transition: opacity .2s;
  display: flex;
  align-items: flex-end;
  padding: 12px;
}
.card:hover .card-overlay { opacity: 1; }

.card-play {
  width: 44px; height: 44px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
  box-shadow: 0 0 20px rgba(124,58,237,.5);
}
.card-play svg { width: 20px; height: 20px; fill: #fff; margin-left: 3px; }

.card-body {
  padding: 10px 12px 12px;
}
.card-title {
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.card-meta {
  font-size: .75rem;
  color: var(--muted);
  display: flex;
  gap: 8px;
}

.rating-badge {
  background: rgba(124,58,237,.25);
  color: var(--accent2);
  border: 1px solid rgba(168,85,247,.3);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: .75rem;
  font-weight: 700;
}

/* ── No-poster placeholder ─────────────────────────────────── */
.no-poster {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 2rem;
}

/* ── Detail page (full-screen view) ────────────────────────── */
.detail-page {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  overflow-y: auto;
  overflow-x: hidden;
}
.detail-page.hidden { display: none !important; }

/* ── Detail hero ─────────────────────────────────────────── */
.detail-hero {
  position: relative;
  height: 65vh;
  min-height: 440px;
  overflow: hidden;
  background: #000;
}
.detail-hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 20%;
  filter: brightness(.48);
  transition: background-image .4s;
}
.detail-hero-overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, rgba(11,11,15,.96) 30%, rgba(11,11,15,.35) 70%, transparent),
    linear-gradient(to top, var(--bg) 0%, rgba(11,11,15,.8) 25%, transparent 60%);
}
.detail-hero-nav {
  position: absolute;
  top: 14px;
  left: 48px;
  z-index: 5;
}
.detail-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 24px;
  font-size: .88rem;
  font-weight: 600;
  color: #fff;
  backdrop-filter: blur(14px);
  transition: background .2s, border-color .2s;
}
.detail-back-btn:hover { background: rgba(0,0,0,.65); border-color: rgba(255,255,255,.4); }

.detail-hero-content {
  position: absolute;
  bottom: 130px;
  left: 48px;
  right: 46%;
  z-index: 5;
}
.detail-hero-content h1 {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 14px;
  text-shadow: 0 2px 16px rgba(0,0,0,.7);
}
.detail-hero-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: .9rem;
  color: #ccc;
  flex-wrap: wrap;
}
.detail-hero-meta .rating-badge {
  background: rgba(124,58,237,.3);
  border: 1px solid rgba(168,85,247,.4);
  color: var(--accent2);
  padding: 2px 9px;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 700;
}
.hero-genres {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.detail-hero-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Detail body ─────────────────────────────────────────── */
.detail-body {
  background: var(--bg);
  padding: 0 48px 100px;
}

/* ── Info layout: poster + details ──────────────────────── */
.detail-info-layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 44px;
  padding: 0 0 44px;
  align-items: start;
}
.detail-poster-col {
  margin-top: -50px;
  position: relative;
  z-index: 10;
}
.detail-poster-col img {
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: 0 16px 56px rgba(0,0,0,.85);
  display: block;
}
.detail-info-col {
  padding-top: 28px;
}
#modalOverview {
  color: #b8b8d0;
  font-size: .95rem;
  line-height: 1.75;
  margin-bottom: 20px;
}

/* Trailer button in info col — hidden (hero has it already) */
#trailerArea { display: none !important; }

/* video/trailer inside detail body */
.detail-body .video-wrap {
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 32px;
  box-shadow: 0 8px 40px rgba(0,0,0,.7);
}

.cast-list {
  font-size: .79rem;
  color: var(--muted);
  margin-bottom: 18px;
  line-height: 1.5;
}
.cast-list strong { color: #c0c0d8; }

/* Quality selection */
.quality-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.q-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 10px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  font-size: .82rem;
  font-weight: 600;
  transition: all .18s;
  color: var(--text);
}
.q-btn:hover {
  background: rgba(124,58,237,.18);
  border-color: rgba(124,58,237,.5);
  color: var(--accent2);
  transform: translateY(-1px);
}
.q-btn.loading { opacity: .5; pointer-events: none; }
.q-btn.active {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 20px rgba(124,58,237,.4);
}

/* Player status */
.player-status {
  font-size: .84rem;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.55;
  background: rgba(124,58,237,.08);
  border: 1px solid rgba(124,58,237,.2);
  border-radius: 10px;
  padding: 11px 14px;
}
.player-status small { font-size: .74rem; color: var(--muted); }
.player-status strong { color: #e0e0f0; }
.player-status .dot {
  width: 8px; height: 8px;
  flex-shrink: 0;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--accent2);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(168,85,247,.4); }
  50%      { opacity: .6; box-shadow: 0 0 0 5px rgba(168,85,247,0); }
}

/* ── Video player ──────────────────────────────────────────── */
.video-wrap {
  padding: 0;
  background: #000;
}
.video-wrap.hidden { display: none; }

#video {
  width: 100%;
  aspect-ratio: 16/9;
  max-height: 62vh;
  display: block;
  background: #000;
  outline: none;
}

/* Stats bar below video */
.torrent-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: rgba(0,0,0,.6);
  font-size: .76rem;
}
.torrent-stats span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  background: rgba(255,255,255,.06);
  border-radius: 20px;
  color: #9090b0;
  white-space: nowrap;
}
.torrent-stats span strong { color: #d0d0f0; font-weight: 700; }

/* Progress bar */
.progress-bar-wrap {
  height: 4px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #a855f7);
  width: 0%;
  transition: width .8s ease;
  box-shadow: 0 0 8px rgba(168,85,247,.6);
}

/* ── Custom HTML5 Player ───────────────────────────────────── */
.player-box {
  position: relative;
  background: #000;
  border-radius: 12px 12px 0 0;
  overflow: hidden;
  aspect-ratio: 16/9;
  max-height: 68vh;
  cursor: pointer;
  user-select: none;
}
.player-box video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Center play/pause flash */
.player-center-flash {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  width: 72px; height: 72px;
  background: rgba(0,0,0,.55);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s, transform .18s;
  z-index: 5;
}
.player-center-flash.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.player-center-flash svg { width: 32px; height: 32px; color: #fff; }

/* Buffering spinner */
.player-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 4;
}
.player-spinner-ring {
  width: 56px; height: 56px;
  border: 3px solid rgba(255,255,255,.12);
  border-top-color: #a855f7;
  border-radius: 50%;
  animation: spin .85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Controls overlay — tall gradient, Netflix-style */
.player-ctrl-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(
    to top,
    rgba(0,0,0,.95) 0%,
    rgba(0,0,0,.8) 30%,
    rgba(0,0,0,.5) 60%,
    rgba(0,0,0,.15) 85%,
    transparent 100%
  );
  padding: 80px 24px 18px;
  opacity: 0;
  transition: opacity .3s ease;
  z-index: 3;
}
.player-box:hover .player-ctrl-overlay,
.player-box.paused .player-ctrl-overlay,
.player-box.ctrl-visible .player-ctrl-overlay { opacity: 1; }

.pctrl-row { display: flex; align-items: center; gap: 12px; }
.pctrl-seek-row { margin-bottom: 10px; }
.pctrl-main-row { justify-content: space-between; }
.pctrl-group { display: flex; align-items: center; gap: 2px; }

/* Seek bar */
.seek-bar {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,.22);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: height .15s ease;
}
.seek-bar:hover { height: 6px; }
.seek-buf {
  position: absolute;
  height: 100%;
  background: rgba(255,255,255,.28);
  border-radius: 999px;
  pointer-events: none;
}
.seek-prog {
  position: absolute;
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #a855f7);
  border-radius: 999px;
  pointer-events: none;
}
.seek-thumb {
  position: absolute;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  top: 50%; transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity .15s, transform .15s;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(168,85,247,.9), 0 1px 4px rgba(0,0,0,.5);
}
.seek-bar:hover .seek-thumb { opacity: 1; }
.seek-bar:active .seek-thumb { transform: translate(-50%, -50%) scale(1.25); }

/* Time labels */
.pctrl-time {
  font-size: .75rem;
  font-variant-numeric: tabular-nums;
  font-family: 'SF Mono', 'Consolas', monospace;
  color: rgba(255,255,255,.85);
  min-width: 42px;
  text-align: center;
  letter-spacing: .02em;
  flex-shrink: 0;
}

/* Control buttons */
.pctrl-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: rgba(255,255,255,.9);
  transition: color .15s, background .15s, transform .12s;
  flex-shrink: 0;
}
.pctrl-btn:hover {
  color: #fff;
  background: rgba(255,255,255,.14);
  transform: scale(1.08);
}
.pctrl-btn:active { transform: scale(0.96); }

/* Volume group */
.pctrl-vol {
  display: flex;
  align-items: center;
  gap: 4px;
}
.vol-slider {
  -webkit-appearance: none;
  width: 76px; height: 4px;
  background: rgba(255,255,255,.28);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  transition: width .2s;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
  transition: transform .12s;
}
.vol-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.vol-slider::-moz-range-thumb {
  width: 13px; height: 13px;
  border: none;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

/* Select dropdowns (audio / subtitles) */
.pctrl-select-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 20px;
  padding: 4px 10px 4px 8px;
  transition: background .15s, border-color .15s;
  color: rgba(255,255,255,.85);
}
.pctrl-select-wrap:hover {
  background: rgba(255,255,255,.18);
  border-color: rgba(255,255,255,.28);
}
.pctrl-select-wrap svg { flex-shrink: 0; opacity: .75; }
.pctrl-select {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.9);
  font-size: .73rem;
  font-weight: 500;
  max-width: 140px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.pctrl-select option { background: #1a1a2e; color: #e2e2f0; }

/* ── Player quality badge ──────────────────────────────────── */
.player-quality-badge {
  position: absolute;
  top: 12px; right: 12px;
  background: rgba(0,0,0,.62);
  border: 1px solid rgba(255,255,255,.18);
  backdrop-filter: blur(10px);
  color: rgba(255,255,255,.92);
  font-size: .7rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 5px;
  letter-spacing: .6px;
  z-index: 4;
  pointer-events: none;
  text-transform: uppercase;
  transition: opacity .3s;
}

/* ── Loader ────────────────────────────────────────────────── */
.loader {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(11,11,15,.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.loader.hidden { display: none; }

.spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--bg3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 32px; right: 32px;
  z-index: 400;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,.1);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: .9rem;
  box-shadow: var(--shadow);
  max-width: 360px;
  transition: opacity .3s, transform .3s;
}
.toast.hidden { opacity: 0; transform: translateY(12px); pointer-events: none; }

/* ── External ratings (KP / IMDB / Meta) ──────────────────── */
.ext-ratings {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.ext-rating-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 700;
  text-decoration: none;
  transition: transform .15s;
  cursor: pointer;
}
.ext-rating-badge:hover { transform: translateY(-2px); }
.ext-rating-logo {
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .5px;
  opacity: .8;
}
.kp-badge {
  background: rgba(255,102,0,.15);
  border: 1px solid rgba(255,102,0,.4);
  color: #ff9040;
}
.kp-badge .ext-rating-logo { color: #ff6600; }
.imdb-badge {
  background: rgba(245,197,24,.15);
  border: 1px solid rgba(245,197,24,.4);
  color: #f5c518;
}
.imdb-badge .ext-rating-logo { color: #f5c518; }
.meta-badge {
  background: rgba(92,184,92,.15);
  border: 1px solid rgba(92,184,92,.4);
  color: #6fcf6f;
}

/* ── Language badges on quality buttons ───────────────────── */
.lang-rus {
  background: rgba(220,38,38,.25);
  color: #fc8181;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: .70rem;
  font-weight: 800;
  letter-spacing: .4px;
}
.lang-eng {
  background: rgba(37,99,235,.25);
  color: #93c5fd;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: .70rem;
  font-weight: 800;
}
.lang-demo {
  background: rgba(234,179,8,.25);
  color: #fbbf24;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: .70rem;
  font-weight: 800;
}
.demo-btn { border-color: rgba(234,179,8,.25) !important; }
.demo-btn:hover { border-color: #fbbf24 !important; color: #fbbf24 !important; }

/* ── Magnet button in header ───────────────────────────────── */
.magnet-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: .82rem;
  font-weight: 600;
  background: rgba(124,58,237,.18);
  border: 1px solid rgba(124,58,237,.4);
  color: var(--accent2);
  white-space: nowrap;
  transition: background .2s, border-color .2s, transform .15s;
  flex-shrink: 0;
}
.magnet-btn:hover {
  background: rgba(124,58,237,.32);
  border-color: var(--accent2);
  transform: translateY(-1px);
}

/* ── Magnet modal overlay ──────────────────────────────────── */
.magnet-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.magnet-dialog {
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 18px;
  padding: 28px 32px 24px;
  width: 100%;
  max-width: 540px;
  box-shadow: 0 24px 80px rgba(0,0,0,.7);
}

.magnet-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.magnet-dialog-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}
.magnet-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: .9rem;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.magnet-close:hover { background: rgba(255,255,255,.1); color: var(--text); }

.magnet-hint {
  font-size: .84rem;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.4;
}

.magnet-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: .9rem;
  font-family: 'SF Mono', 'Consolas', monospace;
  color: var(--text);
  outline: none;
  transition: border-color .2s;
  margin-bottom: 8px;
}
.magnet-input:focus { border-color: var(--accent); }
.magnet-input::placeholder { color: var(--muted); font-family: inherit; }

.magnet-error {
  font-size: .8rem;
  color: #f87171;
  min-height: 18px;
  margin-bottom: 14px;
}

.magnet-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ── Utilities ─────────────────────────────────────────────── */
.hidden { display: none !important; }

/* Разделитель между info и плеером */
.video-wrap:not(.hidden) {
  border-top: 1px solid rgba(255,255,255,.06);
}
#trailerWrap:not(.hidden) {
  border-top: 1px solid rgba(255,255,255,.06);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 860px) {
  .detail-hero { height: 58vh; min-height: 360px; }
  .detail-hero-content { left: 24px; right: 22px; bottom: 110px; }
  .detail-hero-content h1 { font-size: 2.2rem; }
  .detail-hero-nav { left: 24px; top: 12px; }
  .detail-body { padding: 0 24px 80px; }
  .detail-info-layout { grid-template-columns: 160px 1fr; gap: 24px; }
  .detail-poster-col { margin-top: -40px; }
}

@media (max-width: 700px) {
  #header { padding: 0 16px; gap: 12px; }
  #searchInput { width: 140px; }
  #heroContent { padding: 0 20px 40px; }
  #heroTitle { font-size: 1.8rem; }
  #main { padding: 0 16px 60px; }
  #video { max-height: 50vw; }
  :root { --card-w: 140px; }
  .detail-hero { height: 52vh; min-height: 300px; }
  .detail-hero-content { left: 16px; right: 16px; bottom: 90px; }
  .detail-hero-content h1 { font-size: 1.6rem; }
  .detail-hero-nav { left: 16px; top: 10px; }
  .detail-body { padding: 0 16px 60px; }
  .detail-info-layout { grid-template-columns: 1fr; gap: 16px; }
  .detail-poster-col { margin-top: -36px; max-width: 150px; }
  .detail-info-col { padding-top: 12px; }
}

/* ── Trailer button ────────────────────────────────────────── */
.trailer-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 22px;
  font-size: .81rem;
  font-weight: 600;
  color: var(--text);
  transition: background .2s, border-color .2s;
}
.trailer-btn:hover {
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.25);
}

/* ── Trailer iframe ────────────────────────────────────────── */
#trailerWrap iframe { border-radius: var(--radius); min-height: 360px; }

/* ── Season tabs ───────────────────────────────────────────── */
#seasonEpisodeWrap { margin-bottom: 12px; }

.season-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.season-btn {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  background: var(--bg3);
  color: var(--muted);
  border: 1px solid transparent;
  transition: all .2s;
}
.season-btn:hover  { color: var(--text); border-color: var(--accent); }
.season-btn.active { background: var(--accent); color: #fff; }

/* ── Episode list ──────────────────────────────────────────── */
.episode-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
  margin-bottom: 10px;
}
.ep-loading {
  font-size: .8rem;
  color: var(--muted);
  padding: 8px 0;
}
.ep-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  background: var(--bg3);
  text-align: left;
  font-size: .8rem;
  transition: background .15s;
  border: 1px solid transparent;
}
.ep-btn:hover  { background: var(--bg2); border-color: var(--accent); }
.ep-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ep-code {
  font-family: monospace;
  font-size: .75rem;
  font-weight: 700;
  color: var(--accent2);
  min-width: 52px;
}
.ep-btn.active .ep-code { color: #fff; }
.ep-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep-date { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.ep-btn.active .ep-date { color: rgba(255,255,255,.7); }

/* ── Cast chips ────────────────────────────────────────────── */
.cast-label { color: var(--muted); font-size: .82rem; margin-right: 4px; }
.cast-chip {
  display: inline-block;
  padding: 3px 9px;
  margin: 2px 3px 2px 0;
  border-radius: 12px;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,.1);
  font-size: .78rem;
  color: var(--text);
  transition: all .15s;
}
.cast-chip:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Back button ───────────────────────────────────────────── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,.1);
  font-size: .82rem;
  color: var(--text);
  margin-bottom: 16px;
  transition: all .15s;
}
.back-btn:hover { background: var(--bg2); border-color: var(--accent); }

/* ── Person view ───────────────────────────────────────────── */
#personView { padding: 4px 0; }

.person-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}
.person-photo {
  width: 90px;
  height: 135px;
  object-fit: cover;
  border-radius: var(--radius);
  flex-shrink: 0;
}
.person-photo-placeholder {
  width: 90px;
  height: 135px;
  border-radius: var(--radius);
  background: var(--bg3);
  flex-shrink: 0;
}
.person-info { flex: 1; min-width: 0; }
.person-name { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.person-meta { font-size: .8rem; color: var(--muted); margin-bottom: 8px; }
.person-bio  { font-size: .8rem; color: var(--muted); line-height: 1.5; }

/* ── Person filmography grid ───────────────────────────────── */
.person-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
.person-card {
  background: var(--bg3);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  border: 1px solid transparent;
}
.person-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}
.person-card img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
}
.person-card-info { padding: 6px 7px; }
.person-card-title {
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.person-card-meta {
  display: flex;
  gap: 6px;
  font-size: .68rem;
  color: var(--muted);
  align-items: center;
}

/* ── Row scroll (horizontal, Netflix-style) ─────────────────── */
.row-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--bg3) transparent;
}
.row-scroll::-webkit-scrollbar { height: 4px; }
.row-scroll::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 2px; }
.row-scroll .card {
  flex-shrink: 0;
  width: var(--card-w);
  scroll-snap-align: start;
}

/* ── Section header ────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

/* ── Genre tags ────────────────────────────────────────────── */
.genre-tag {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(124,58,237,.2);
  border: 1px solid rgba(124,58,237,.35);
  border-radius: 12px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--accent2);
}

.card-genres {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.card-genres span {
  font-size: .65rem;
  color: var(--muted);
  background: rgba(255,255,255,.05);
  border-radius: 8px;
  padding: 1px 6px;
  white-space: nowrap;
}

/* ── Hero actions row ─────────────────────────────────────── */
.hero-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.12);
  color: #fff;
  padding: 11px 22px;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,.2);
  transition: background .2s, transform .15s;
}
.btn-secondary:hover { background: rgba(255,255,255,.22); transform: translateY(-2px); }

/* ── Speed control ─────────────────────────────────────────── */
.pctrl-speed-wrap {
  position: relative;
}
.pctrl-speed-btn {
  width: auto;
  padding: 0 10px;
  border-radius: 5px;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .5px;
  height: 28px;
  min-width: 34px;
}
.speed-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: rgba(12,12,20,.96);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  backdrop-filter: blur(14px);
  z-index: 20;
  min-width: 72px;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
}
.speed-menu button {
  padding: 6px 12px;
  border-radius: 5px;
  font-size: .8rem;
  font-weight: 600;
  color: rgba(255,255,255,.78);
  text-align: center;
  transition: background .12s, color .12s;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
}
.speed-menu button:hover { background: rgba(255,255,255,.1); color: #fff; }
.speed-menu button.active { background: var(--accent); color: #fff; }

/* ── Seek tooltip ──────────────────────────────────────────── */
.seek-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  background: rgba(12,12,20,.95);
  border: 1px solid rgba(255,255,255,.13);
  color: rgba(255,255,255,.95);
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
  font-family: 'SF Mono', 'Consolas', monospace;
  padding: 3px 8px;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  letter-spacing: .02em;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.seek-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(255,255,255,.13);
}

/* ── Row navigation arrows ─────────────────────────────────── */
.row-nav {
  position: relative;
}
.row-arrow {
  position: absolute;
  top: 0; bottom: 12px; /* match row-scroll padding-bottom */
  z-index: 5;
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0;
  transition: opacity .2s;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}
.row-nav:hover .row-arrow { opacity: 1; }
.row-arrow-left  {
  left: 0;
  background: linear-gradient(to right, rgba(11,11,15,.92) 60%, transparent);
}
.row-arrow-right {
  right: 0;
  background: linear-gradient(to left,  rgba(11,11,15,.92) 60%, transparent);
}
.row-arrow:hover { opacity: 1 !important; }
.row-arrow svg { filter: drop-shadow(0 1px 3px rgba(0,0,0,.8)); }

/* ── Row skeleton placeholder ─────────────────────────────── */
.row-skeleton {
  width: 100%;
  height: 220px;
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg2) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
  opacity: .5;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Class aliases for ID-styled hero elements ─────────────── */
/* index.html uses both id and class; ID rules already cover most cases.
   These class rules catch cases where only the class is applied. */
.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center top;
  filter: brightness(.4);
  transition: background-image .5s;
}
.hero-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right, rgba(11,11,15,.9) 35%, transparent 80%
  ), linear-gradient(
    to top, var(--bg) 0%, transparent 40%
  );
}
.hero-vignette {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--bg) 0%, transparent 35%);
  pointer-events: none;
}
.hero-content {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  padding: 0 48px 56px;
  max-width: 640px;
}
.hero-title {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 12px;
  text-shadow: 0 2px 12px rgba(0,0,0,.6);
}
.hero-overview {
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 16px;
}
.hero-year {
  font-size: .85rem;
  color: var(--muted);
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 12px;
  width: fit-content;
}

/* ── Header layout additions ───────────────────────────────── */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.search-icon-btn {
  padding: 8px 10px;
  color: var(--muted);
  transition: color .2s;
  flex-shrink: 0;
}
.search-icon-btn:hover { color: var(--accent2); }
/* Reset margin-left on search-wrap when inside header-right */
.header-right .search-wrap { margin-left: 0; }

/* ── Button variants ───────────────────────────────────────── */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.9);
  padding: 11px 22px;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,.18);
  transition: background .2s, border-color .2s, transform .15s;
}
.btn-ghost:hover {
  background: rgba(255,255,255,.16);
  border-color: rgba(255,255,255,.32);
  transform: translateY(-2px);
}
.btn-lg {
  padding: 13px 30px;
  font-size: 1rem;
}
.btn-lg svg { width: 18px; height: 18px; }

/* ── Runtime badge ─────────────────────────────────────────── */
.runtime-badge {
  font-size: .85rem;
  color: var(--muted);
}

/* ── Trailer close button ──────────────────────────────────── */
.trailer-close-btn {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 5;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 50%;
  color: #fff;
  transition: background .15s;
}
.trailer-close-btn:hover { background: rgba(0,0,0,.85); }

/* ── Mobile player controls ────────────────────────────────── */
@media (max-width: 600px) {
  /* Bigger touch targets */
  .pctrl-btn {
    width: 44px;
    height: 44px;
  }
  /* Hide volume slider — use hardware buttons on mobile */
  .vol-slider {
    display: none;
  }
  /* Larger time labels */
  .pctrl-time {
    font-size: .8rem;
  }
  /* Stack selects if needed */
  .pctrl-select-wrap {
    max-width: 90px;
  }
  .pctrl-select {
    max-width: 72px;
    font-size: .72rem;
  }
  /* Row arrows: always visible on touch screens (no hover) */
  .row-arrow {
    opacity: 0.7;
  }

}
