:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --bg3: #1a1a24;
  --card: #16161e;
  --card-h: #1e1e2a;
  --border: rgba(255,255,255,.07);
  --accent: #F97316;
  --accent2: #F87171;
  --text: #f0f0f5;
  --text2: #8888a0;
  --text3: #555568;
  --green: #22c55e;
  --blue: #3b82f6;
  --radius: 10px;
  --radius-sm: 6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }
html { scroll-behavior: smooth }
body { background: var(--bg); color: var(--text); font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif; font-size: 15px; overflow-x: hidden; min-height: 100vh }
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit }
img { display: block; max-width: 100% }
a { color: inherit; text-decoration: none }
.hidden { display: none !important }

/* ── NAV ── */
#nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; gap: 24px;
  padding: 0 28px; height: 60px;
  background: linear-gradient(to bottom, rgba(10,10,15,.98) 0%, rgba(10,10,15,.8) 100%);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0 }
.nav-logo span { font-size: 1.25rem; font-weight: 700; letter-spacing: -.3px; background: linear-gradient(135deg,#F87171,#F97316); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text }
.nav-logo svg { flex-shrink: 0 }

.nav-links { display: flex; gap: 4px }
.nav-links button { padding: 6px 14px; border-radius: 20px; font-size: .875rem; color: var(--text2); transition: color .2s, background .2s }
.nav-links button:hover { color: var(--text) }
.nav-links button.active { color: var(--text); background: var(--bg3) }

.nav-right { margin-left: auto }
.search-box { display: flex; align-items: center; gap: 8px; background: var(--bg3); border: 1px solid var(--border); border-radius: 24px; padding: 7px 14px; transition: border-color .2s }
.search-box:focus-within { border-color: var(--accent) }
.search-box svg { color: var(--text2); flex-shrink: 0 }
.search-box input { background: none; border: none; outline: none; color: var(--text); font-size: .875rem; width: 180px }
.search-box input::placeholder { color: var(--text3) }

/* ── MAIN ── */
#main { padding-top: 60px }

/* ── HERO ── */
#hero {
  position: relative; height: 80vh; min-height: 480px; overflow: hidden; cursor: pointer;
}
#hero-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transition: transform 6s ease; transform-origin: center;
}
#hero:hover #hero-img { transform: scale(1.03) }
#hero-grad {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(10,10,15,0) 20%, rgba(10,10,15,.6) 60%, rgba(10,10,15,1) 100%),
              linear-gradient(to right, rgba(10,10,15,.8) 0%, transparent 60%);
}
#hero-info {
  position: absolute; bottom: 60px; left: 60px; max-width: 520px; z-index: 2;
}
#hero-badge {
  display: inline-block; padding: 3px 10px; background: var(--accent); color: white;
  font-size: .7rem; font-weight: 700; letter-spacing: 1.5px; border-radius: 3px; margin-bottom: 12px;
}
#hero-title { font-size: 2.6rem; font-weight: 800; line-height: 1.1; margin-bottom: 12px; text-shadow: 0 2px 8px rgba(0,0,0,.5) }
#hero-desc { font-size: .95rem; line-height: 1.6; color: rgba(240,240,245,.8); max-width: 440px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 20px; text-shadow: 0 1px 4px rgba(0,0,0,.6) }
#hero-actions { display: flex; gap: 12px }

/* ── BUTTONS ── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 26px;
  background: var(--accent); color: white; border-radius: 8px;
  font-size: .95rem; font-weight: 600; transition: background .15s, transform .1s;
}
.btn-primary:hover { background: #fb923c; transform: translateY(-1px) }
.btn-primary:active { transform: translateY(0) }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 22px;
  background: rgba(255,255,255,.12); color: white; border-radius: 8px;
  font-size: .95rem; font-weight: 500; backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.15); transition: background .15s;
}
.btn-ghost:hover { background: rgba(255,255,255,.2) }

.btn-cancel {
  display: block; width: 100%; padding: 10px; border-radius: var(--radius-sm);
  background: var(--bg3); color: var(--text2); font-size: .9rem; margin-top: 10px;
  border: 1px solid var(--border); transition: background .15s, color .15s;
}
.btn-cancel:hover { background: var(--card-h); color: var(--text) }

/* ── ROWS ── */
#rows { padding: 20px 0 60px }

.row { margin-bottom: 36px }
.row-title {
  padding: 0 28px; margin-bottom: 14px;
  font-size: 1.1rem; font-weight: 700; color: var(--text);
}
.row-cards {
  display: flex; gap: 10px; padding: 4px 28px; overflow-x: auto;
  scrollbar-width: none;
}
.row-cards::-webkit-scrollbar { display: none }

/* ── CARDS ── */
.card {
  flex: 0 0 160px; cursor: pointer;
  border-radius: var(--radius); overflow: hidden;
  background: var(--card); transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: scale(1.05); box-shadow: 0 8px 32px rgba(0,0,0,.6); z-index: 2; position: relative }
.card img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block }
.card-title {
  padding: 8px 10px; font-size: .78rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text2);
}
.card:hover .card-title { color: var(--text) }

.skel { flex: 0 0 160px; aspect-ratio: 2/3; border-radius: var(--radius); background: var(--bg3); animation: pulse 1.4s ease-in-out infinite }
@keyframes pulse { 0%,100% { opacity: .5 } 50% { opacity: 1 } }

/* ── SEARCH GRID ── */
#page-search { padding: 28px }
#search-heading { font-size: 1.3rem; font-weight: 700; margin-bottom: 20px; color: var(--text2) }
#search-heading em { color: var(--text); font-style: normal }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(150px,1fr)); gap: 14px }
.card-grid .card { flex: none }

/* ── OVERLAY ── */
.overlay {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.75); backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.overlay.open { opacity: 1; pointer-events: all }
.modal-box {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 16px;
  width: min(860px, 95vw); max-height: 90vh; overflow-y: auto; position: relative;
  transform: translateY(16px); transition: transform .25s;
  scrollbar-width: thin; scrollbar-color: var(--bg3) transparent;
}
.overlay.open .modal-box { transform: translateY(0) }

/* ── DETAIL MODAL ── */
.close-btn {
  position: absolute; top: 14px; right: 14px; z-index: 10;
  width: 34px; height: 34px; border-radius: 50%; background: rgba(0,0,0,.6);
  color: white; font-size: .9rem; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); transition: background .15s;
}
.close-btn:hover { background: rgba(255,255,255,.15) }

.detail-hero-wrap { position: relative; height: 220px; overflow: hidden; border-radius: 16px 16px 0 0 }
.detail-hero-wrap img { width: 100%; height: 100%; object-fit: cover }
.detail-hero-fade { position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 30%, var(--bg2) 100%) }

.detail-content { display: flex; gap: 24px; padding: 20px 24px }
.detail-left { flex-shrink: 0 }
.detail-left img { width: 130px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.5) }
.detail-right { flex: 1; min-width: 0 }
.detail-right h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 8px; line-height: 1.2 }

.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; font-size: .82rem; color: var(--text2) }
.meta-tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; background: var(--bg3); border-radius: 20px }
.meta-tag.rating { color: #fbbf24 }

.detail-right p { font-size: .9rem; line-height: 1.65; color: rgba(240,240,245,.75); margin-bottom: 16px }
#d-actions { display: flex; gap: 10px; flex-wrap: wrap }
#d-actions .btn-primary { font-size: .875rem; padding: 10px 22px }

/* ── SEASONS ── */
#d-seasons { padding: 0 24px 24px }
.season-select {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm); font-size: .875rem; margin-bottom: 14px;
  outline: none; cursor: pointer;
}
.season-select:focus { border-color: var(--accent) }
.ep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 8px }
.ep-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; cursor: pointer; transition: background .15s, border-color .15s;
}
.ep-card:hover { background: var(--card-h); border-color: var(--accent) }
.ep-num { font-size: .75rem; color: var(--accent); font-weight: 600; margin-bottom: 4px }
.ep-name { font-size: .85rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }

/* ── SOURCE PICKER ── */
.source-modal { max-width: 520px !important }
.source-modal h3 { padding: 20px 20px 4px; font-size: 1.05rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
#src-list { padding: 0 12px }
.src-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s; border-bottom: 1px solid var(--border);
}
.src-item:last-child { border-bottom: none }
.src-item:hover { background: var(--card-h) }
.src-badges { display: flex; gap: 5px; flex-shrink: 0 }
.badge {
  font-size: .68rem; font-weight: 700; letter-spacing: .5px; padding: 3px 7px; border-radius: 4px;
  white-space: nowrap; text-transform: uppercase;
}
.badge.vf     { background: #15803d; color: #bbf7d0 }
.badge.vostfr { background: #1d4ed8; color: #bfdbfe }
.badge.vo     { background: #374151; color: #d1d5db }
.badge.embed  { background: #7c3aed; color: #ddd6fe }
.badge.q4k    { background: #831843; color: #fbcfe8 }
.badge.q1080  { background: #1e3a5f; color: #bae6fd }
.badge.q720   { background: #1a3a2a; color: #bbf7d0 }

.src-info { flex: 1; min-width: 0 }
.src-name { font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.src-detail { font-size: .75rem; color: var(--text2); margin-top: 2px }
.src-cancel-wrap { padding: 0 12px 16px }

.src-loading { text-align: center; padding: 28px; color: var(--text2); font-size: .875rem }
.src-spinner { width: 28px; height: 28px; border: 2.5px solid var(--bg3); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto 10px }
@keyframes spin { to { transform: rotate(360deg) } }

/* ── PLAYER ── */
#player {
  position: fixed; inset: 0; z-index: 300; display: flex; flex-direction: column;
  background: #000; opacity: 0; pointer-events: none; transition: opacity .25s;
}
#player.open { opacity: 1; pointer-events: all }

#player-top {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  background: linear-gradient(to bottom, rgba(0,0,0,.7), transparent);
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
}
#player-title { flex: 1; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.player-btn {
  width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,.15); transition: background .15s;
}
.player-btn:hover { background: rgba(255,255,255,.22) }

#player-wrap { flex: 1; position: relative; overflow: hidden }
#vid, #emb {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: none; background: #000;
}

#dl-bar {
  padding: 10px 18px 14px;
  background: linear-gradient(to top, rgba(0,0,0,.7), transparent);
  position: absolute; bottom: 0; left: 0; right: 0;
}
#dl-track { height: 3px; background: rgba(255,255,255,.15); border-radius: 2px; margin-bottom: 6px; overflow: hidden }
#dl-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s }
#dl-info { display: flex; justify-content: space-between; font-size: .75rem; color: rgba(255,255,255,.6) }

/* Plyr theme */
.plyr { --plyr-color-main: #F97316; --plyr-font-family: inherit; height: 100% }
.plyr--video { height: 100% }
.plyr__video-wrapper { height: 100% }

/* ── TOAST ── */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(16px);
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  padding: 10px 22px; border-radius: 24px; font-size: .875rem; opacity: 0;
  transition: opacity .25s, transform .25s; z-index: 500; pointer-events: none; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0) }

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
  #nav { padding: 0 14px; gap: 12px }
  .nav-links { display: none }
  .search-box input { width: 130px }
  #hero-info { left: 20px; bottom: 30px; max-width: calc(100% - 40px) }
  #hero-title { font-size: 1.6rem }
  #hero-desc { display: none }
  .row-title, .row-cards { padding-left: 14px; padding-right: 14px }
  .detail-content { flex-direction: column }
  .detail-left img { width: 100px }
  #page-search { padding: 14px }
}
