:root {
  --bg: #0b0b0f;
  --bg-2: #15151c;
  --bg-3: #1f1f29;
  --text: #f4f4f6;
  --muted: #a3a3b2;
  --accent: #e5383b;
  --accent-2: #ff5a5f;
  --ok: #3ddc84;
  --pending: #f5b942;
  --radius: 6px;
  --gutter: clamp(16px, 4vw, 56px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.locked { overflow: hidden; }
button { font: inherit; color: inherit; }
img { display: block; }
[hidden] { display: none !important; }

/* ---------- Barra superior ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  display: flex; align-items: center; gap: 28px;
  height: 64px; padding: 0 var(--gutter);
  background: linear-gradient(180deg, rgba(0,0,0,.8), transparent);
  transition: background .3s;
}
.nav.solid { background: rgba(11,11,15,.97); }
.logo {
  font-weight: 900; font-size: 24px; letter-spacing: -1px;
  color: var(--accent); text-decoration: none; flex-shrink: 0;
}
.logo span { color: var(--text); }
.tabs { display: flex; gap: 18px; }
.tab {
  background: none; border: 0; padding: 4px 0; cursor: pointer;
  color: var(--muted); font-size: 15px; transition: color .2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); font-weight: 600; }

.search {
  margin-left: auto; display: flex; align-items: center;
  border: 1px solid transparent; border-radius: var(--radius);
  transition: border-color .2s, background .2s;
}
.search.open { border-color: rgba(255,255,255,.6); background: rgba(0,0,0,.75); }
.icon-btn { background: none; border: 0; padding: 6px 8px; cursor: pointer; display: flex; }
.search input {
  width: 0; padding: 0; border: 0; outline: 0; background: transparent;
  color: var(--text); font-size: 14px; transition: width .25s, padding .25s;
}
.search.open input { width: min(240px, 46vw); padding: 8px 8px 8px 0; }

/* ---------- Portada ---------- */
.hero {
  position: relative; min-height: min(82vh, 780px);
  display: flex; align-items: flex-end;
  padding: 0 var(--gutter) clamp(90px, 14vh, 160px);
  background: var(--bg-2) center 20% / cover no-repeat;
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(11,11,15,.92) 0%, rgba(11,11,15,.5) 45%, transparent 75%),
    linear-gradient(0deg, var(--bg) 0%, transparent 35%);
}
.hero-content { position: relative; max-width: 560px; }
.hero-logo { max-width: min(420px, 80%); max-height: 150px; object-fit: contain; object-position: left; margin-bottom: 18px; }
.hero h1 { font-size: clamp(32px, 5vw, 60px); margin: 0 0 14px; line-height: 1.02; letter-spacing: -1px; }
.hero p {
  font-size: clamp(14px, 1.3vw, 18px); line-height: 1.45; color: #ddd; margin: 0 0 22px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.hero-tags { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 24px; border: 0; border-radius: var(--radius);
  font-size: 16px; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: transform .15s, opacity .2s, background .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn.primary { background: var(--text); color: #000; }
.btn.primary:hover:not(:disabled) { background: #d8d8d8; }
.btn.ghost { background: rgba(110,110,125,.55); color: var(--text); }
.btn.ghost:hover { background: rgba(110,110,125,.4); }

/* ---------- Filas ---------- */
#rows { position: relative; z-index: 2; margin-top: -80px; padding-bottom: 60px; }
.home-empty #rows { margin-top: 90px; }
.row { margin: 0 0 34px; }
.row-head { display: flex; align-items: baseline; gap: 12px; padding: 0 var(--gutter); margin-bottom: 10px; }
.row-head h2 { font-size: clamp(16px, 1.5vw, 21px); margin: 0; font-weight: 700; }
.row-head button {
  background: none; border: 0; color: var(--accent-2); cursor: pointer;
  font-size: 13px; font-weight: 600; opacity: 0; transition: opacity .2s;
}
.row:hover .row-head button, .row-head button:focus-visible { opacity: 1; }
@media (hover: none) { .row-head button { opacity: 1; } }

.row-wrap { position: relative; }
.track {
  display: flex; gap: 8px; overflow-x: auto; scroll-behavior: smooth;
  padding: 6px var(--gutter) 14px; scroll-padding: 0 var(--gutter);
  scrollbar-width: none; scroll-snap-type: x proximity;
}
.track::-webkit-scrollbar { display: none; }
.arrow {
  position: absolute; top: 6px; bottom: 14px; z-index: 3; width: calc(var(--gutter) - 6px);
  border: 0; background: rgba(11,11,15,.6); color: #fff; font-size: 34px; cursor: pointer;
  opacity: 0; transition: opacity .2s, background .2s;
}
.arrow:hover { background: rgba(11,11,15,.85); }
.arrow.left { left: 0; border-radius: 0 var(--radius) var(--radius) 0; }
.arrow.right { right: 0; border-radius: var(--radius) 0 0 var(--radius); }
.row-wrap:hover .arrow { opacity: 1; }
@media (hover: none) { .arrow { display: none; } }

.card {
  position: relative; flex: 0 0 auto; width: clamp(112px, 13vw, 190px); aspect-ratio: 2 / 3;
  border: 0; padding: 0; border-radius: var(--radius); overflow: hidden; cursor: pointer;
  background: var(--bg-3); scroll-snap-align: start;
  transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s;
}
.card img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .4s; }
.card img.loaded { opacity: 1; }
.card .card-title {
  position: absolute; z-index: 2; inset: auto 0 0 0; padding: 30px 8px 8px; font-size: 13px; font-weight: 600; text-align: left;
  background: linear-gradient(0deg, rgba(0,0,0,.9), transparent);
  opacity: 0; transition: opacity .2s;
}
.card .fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 10px; text-align: center; font-size: 14px; color: var(--muted); }
.card:hover, .card:focus-visible { transform: scale(1.07); z-index: 4; box-shadow: 0 10px 30px rgba(0,0,0,.6); outline: none; }
.card:hover .card-title, .card:focus-visible .card-title { opacity: 1; }
.card:focus-visible { box-shadow: 0 0 0 3px var(--text); }

.skeleton { background: linear-gradient(90deg, var(--bg-3) 0%, #2a2a36 50%, var(--bg-3) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Rejilla (búsqueda / ver todo) ---------- */
.grid-view { padding: 96px var(--gutter) 60px; }
.grid-view h2 { margin: 0 0 18px; font-size: clamp(18px, 2vw, 26px); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(108px, 12vw, 170px), 1fr)); gap: 14px 10px; }
.grid .card { width: 100%; }
.grid-more { display: flex; justify-content: center; margin-top: 28px; }
.status-msg { padding: 120px var(--gutter); text-align: center; color: var(--muted); }

/* ---------- Ficha ---------- */
.modal { position: fixed; inset: 0; z-index: 50; overflow-y: auto; padding: 32px 12px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.72); animation: fade .2s; }
.modal-card {
  position: relative; max-width: 880px; margin: 0 auto; background: var(--bg-2);
  border-radius: 10px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.7);
  animation: pop .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(24px) scale(.97); } }
.close {
  position: absolute; top: 14px; right: 14px; z-index: 5; width: 38px; height: 38px;
  border-radius: 50%; border: 0; background: rgba(11,11,15,.85); cursor: pointer; font-size: 16px;
}
.m-hero { position: relative; aspect-ratio: 16 / 8; background: var(--bg-3) center / cover no-repeat; }
.m-hero-fade { position: absolute; inset: 0; background: linear-gradient(0deg, var(--bg-2) 2%, transparent 60%); }
.m-hero-info { position: absolute; left: 36px; right: 36px; bottom: 26px; }
.m-logo { max-width: 320px; max-height: 110px; object-fit: contain; object-position: left; margin-bottom: 14px; }
.m-hero-info h2 { margin: 0 0 16px; font-size: clamp(24px, 4vw, 40px); }
.m-logo:not([hidden]) + h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.m-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.m-hint { color: var(--muted); font-size: 13px; }
.m-body > * { min-width: 0; }
.m-body { display: grid; grid-template-columns: 2fr 1fr; gap: 28px; padding: 6px 36px 36px; }
.m-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: var(--muted); font-size: 15px; margin-bottom: 14px; }
.m-meta .rating { color: var(--ok); font-weight: 700; }
.m-meta .pill { border: 1px solid rgba(255,255,255,.4); padding: 0 6px; border-radius: 3px; font-size: 12px; }
.m-overview { line-height: 1.55; margin: 0 0 22px; }
.m-side { font-size: 14px; color: var(--muted); line-height: 1.6; }
.m-side b { color: #777788; font-weight: 500; }
.m-side div { margin-bottom: 10px; }
h3 { font-size: 18px; margin: 0 0 12px; }

.season-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.season-bar h3 { margin: 0; }
.season-bar select { background: var(--bg-3); color: var(--text); border: 1px solid #444; border-radius: var(--radius); padding: 8px 12px; font-size: 15px; }
.episodes { list-style: none; padding: 0; margin: 0 0 26px; max-height: 420px; overflow-y: auto; }
.episode {
  display: grid; grid-template-columns: 26px 130px 1fr; gap: 14px; align-items: center; width: 100%;
  padding: 12px 10px; border: 0; border-bottom: 1px solid #2a2a35; background: none; cursor: pointer; text-align: left;
  border-radius: var(--radius);
}
.episode:hover, .episode:focus-visible, .episode.active { background: var(--bg-3); outline: none; }
.episode .num { font-size: 20px; color: var(--muted); text-align: center; }
.thumb-wrap { position: relative; display: block; }
.thumb-play {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px;
  background: rgba(0,0,0,.45); border-radius: 4px; opacity: 0; transition: opacity .2s;
}
.episode:hover .thumb-play, .episode:focus-visible .thumb-play { opacity: 1; }
.episode .thumb { display: block; width: 130px; aspect-ratio: 16/9; border-radius: 4px; object-fit: cover; background: var(--bg-3); }
.episode .ep-title { font-weight: 600; margin-bottom: 4px; }
.episode .ep-overview { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 100; transform: translateX(-50%);
  background: var(--text); color: #000; padding: 10px 18px; border-radius: var(--radius); font-weight: 600;
  animation: pop .2s;
}

/* ---------- Móvil ---------- */
@media (max-width: 720px) {
  .nav { gap: 14px; height: 56px; }
  .logo { font-size: 20px; }
  .tabs { gap: 12px; }
  .tab { font-size: 13px; }
  .search.open { position: absolute; left: 12px; right: 12px; }
  .search.open input { width: 100%; }
  .hero { min-height: 68vh; padding-bottom: 96px; }
  .hero p { -webkit-line-clamp: 2; }
  .btn { padding: 9px 18px; font-size: 15px; }
  .modal { padding: 0; }
  .modal-card { border-radius: 0; min-height: 100%; }
  .m-hero { aspect-ratio: 16 / 11; }
  .m-hero-info { left: 16px; right: 16px; }
  .m-body { grid-template-columns: minmax(0, 1fr); padding: 6px 16px 32px; gap: 8px; }
  .season-bar select { min-width: 0; max-width: 55%; }
  .episode { grid-template-columns: 22px 104px 1fr; gap: 10px; }
  .episode .thumb { width: 104px; }
}
@media (max-width: 420px) {
  .tabs .tab[data-view="home"] { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
