:root {
  --bg: #0b0e14;
  --bg-elev: #131722;
  --bg-card: #1a1f2e;
  --border: #262d40;
  --text: #eef1f7;
  --text-dim: #9aa4b8;
  --accent: #7c5cff;
  --accent-strong: #9d86ff;
  --accent-soft: rgba(124, 92, 255, 0.16);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --header-h: 64px;
}

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

html { scroll-behavior: smooth; overflow-x: hidden; overscroll-behavior-x: none; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

img { display: block; max-width: 100%; }

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 14, 20, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(38, 45, 64, 0.6);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  white-space: nowrap;
  min-height: 44px;
}
.logo-dot { color: var(--accent-strong); }

.main-nav { display: flex; gap: 6px; flex: 1; min-width: 0; }

.nav-link {
  background: none;
  border: none;
  color: var(--text-dim);
  font: inherit;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.nav-link.active { color: var(--text); background: var(--accent-soft); }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 220px;
}
.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-dim);
  pointer-events: none;
}
#search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  -webkit-text-fill-color: var(--text);
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}
#search-input::placeholder { color: var(--text-dim); }
#search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Fix autocomplete autofill bug on Android Chrome */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-elev) inset;
  transition: background-color 5000s ease-in-out 0s;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 520px;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--bg) 100%);
  overflow: hidden;
}
.hero-backdrop {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 20%;
  filter: brightness(0.55);
  transform: scale(1.02);
}
.hero-backdrop-blur {
  filter: blur(26px) brightness(0.5) saturate(1.2);
  transform: scale(1.05);
}
.hero-shade {
  position: absolute;
  inset: 0;
  /* Atenuado: degradado transparente → negro (0.8) para destacar el título.
     Mantiene una viñeta horizontal para legibilidad en pantallas anchas. */
  background:
    radial-gradient(ellipse 90% 60% at 50% 100%, transparent 0%, rgba(0, 0, 0, 0.55) 100%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.35) 50%, transparent 78%);
}
.hero-body {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 120px 20px 48px;
  width: 100%;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(124, 92, 255, 0.4);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.hero-title {
  font-size: clamp(1.9rem, 5vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.05;
  max-width: 640px;
  margin-bottom: 12px;
}
.hero-sub {
  color: var(--text-dim);
  font-size: clamp(0.95rem, 2.4vw, 1.15rem);
  max-width: 620px;
  margin-bottom: 20px;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.hero-body-flex { display: flex; align-items: flex-end; gap: 32px; justify-content: space-between; }
.hero-copy { flex: 1; min-width: 0; }
.hero-poster {
  flex-shrink: 0;
  width: 200px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.hero-poster img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 11px 20px;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  min-height: 44px;
  transition: transform 0.12s, background 0.15s, box-shadow 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); box-shadow: 0 6px 20px rgba(124, 92, 255, 0.35); }
.btn-ghost { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.18); }

/* ---------- Filas y grids ---------- */
.rows { display: flex; flex-direction: column; gap: 34px; max-width: 1280px; margin: 0 auto; padding: 30px 20px 20px; }
.personal-rows { padding-top: 18px; padding-bottom: 0; }
.card-media-actions { position: absolute; inset: 8px 8px auto auto; display: flex; gap: 5px; opacity: 0; transition: opacity .18s; }
.card:hover .card-media-actions, .card:focus-within .card-media-actions { opacity: 1; }
.card-media-action { width: 34px; height: 34px; padding: 0; border: 1px solid rgba(221,214,254,.35); border-radius: 50%; background: rgba(16,5,31,.82); color: #fff; cursor: pointer; font-size: 1rem; }
.card-media-action.is-active { background: #7c3aed; border-color: #c4b5fd; }
.media-flag.is-active { border-color: #c4b5fd; background: rgba(124,58,237,.4); color: #fff; }
.card-poster { position: relative; }
.card-poster-fallback { display: grid; place-items: center; width: 58%; aspect-ratio: 1; border: 1px solid rgba(167,139,250,.28); border-radius: 24%; background: #1b1725; color: #a78bfa; font-size: 1rem; font-weight: 800; letter-spacing: -.05em; }
.card-progress { position: absolute; right: 0; bottom: 0; left: 0; height: 4px; background: rgba(255,255,255,.18); }
.card-progress span { display: block; height: 100%; border-radius: 0 999px 999px 0; background: linear-gradient(90deg, #a78bfa, #7c3aed); }
@media (max-width: 700px) { .card-media-actions { opacity: 1; } }
.player-surface { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 9px; background: #000; }
.player-surface video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }

.row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.row-title { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.3px; }
.row-more {
  background: none;
  border: none;
  color: var(--accent-strong);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.row-more:hover { text-decoration: underline; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 12px;
}

.row > .grid {
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: clamp(124px, 13vw, 164px);
  justify-content: start;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 2px 2px 10px;
  scroll-snap-type: x mandatory;
  scrollbar-color: rgba(157, 134, 255, 0.45) transparent;
}
.row > .grid .card { scroll-snap-align: start; }
.continue-row { padding-top: 0; }

.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: var(--shadow); }
.card-poster {
  aspect-ratio: 2 / 3;
  background: linear-gradient(135deg, #232a3d, #161b28);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 2.2rem;
}
.card-poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-info { padding: 10px 12px 12px; }
.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.3em;
}
.card-sub {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rating { color: #ffd166; font-weight: 700; }

/* ---------- Vistas ---------- */
.view-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 18px; }
.search-view, .list-view, .library-view, .settings-view { max-width: 1280px; margin: 0 auto; padding: 28px 20px; }

.view-header { max-width: 680px; margin-bottom: 20px; }
.view-header .view-title { margin-bottom: 4px; }
.view-eyebrow { margin-bottom: 5px; color: var(--accent-strong); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.view-description { color: var(--text-dim); font-size: .92rem; }
.search-error { color: #ff8fa3; }
.library-tabs { display: flex; gap: 8px; margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.library-tabs::-webkit-scrollbar { display: none; }
.library-tabs button { min-height: 40px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--text-dim); cursor: pointer; font: inherit; font-size: .84rem; font-weight: 700; white-space: nowrap; }
.library-tabs button:hover, .library-tabs button.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 158px)); gap: 14px; }
.library-empty, .library-loading { grid-column: 1 / -1; margin: 8px 0; color: var(--text-dim); font-size: .9rem; }
.library-clear-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: -8px 0 20px; }
.text-button { border: 0; background: none; color: var(--accent-strong); cursor: pointer; font: inherit; font-weight: 700; }

.settings-view { max-width: 920px; }
.settings-account-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.settings-section { min-width: 0; }
.settings-card { display: grid; align-content: start; gap: 10px; padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-card); }
.settings-section-title { margin: 0 0 8px; color: var(--text-dim); font-size: .74rem; letter-spacing: .09em; text-transform: uppercase; }
.settings-account-name { font-size: 1.08rem; }
.settings-account-email, .settings-card small { display: block; color: var(--text-dim); font-size: .78rem; overflow-wrap: anywhere; }
.settings-card p { display: grid; gap: 4px; margin: 0; }
.settings-rename { display: grid; gap: 7px; margin-top: 6px; color: var(--text-dim); font-size: .78rem; font-weight: 700; }
.settings-rename > div { display: flex; gap: 8px; }
.settings-rename input { width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: var(--text); font: inherit; font-size: 16px; }
.settings-list { border-top: 1px solid var(--border); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 0; cursor: pointer; }
.setting-row span { display: grid; gap: 5px; }
.setting-row strong { font-size: .98rem; }
.setting-row small, .setting-warning { color: var(--text-dim); font-size: .82rem; line-height: 1.5; }
.setting-row input { width: 22px; height: 22px; flex: 0 0 auto; accent-color: var(--accent); }
.setting-row button { flex: 0 0 auto; }
.setting-warning { margin: 0; padding: 14px 16px; border-left: 2px solid var(--accent); background: rgba(124, 92, 255, .07); }

.mobile-nav { display: none; }

.empty-state { color: var(--text-dim); text-align: center; padding: 48px 0; }
.confirm-dialog-card { position: relative; z-index: 1; width: min(430px, 100%); padding: 24px; border: 1px solid var(--border); border-radius: 18px; background: var(--bg-elev); box-shadow: 0 24px 70px rgba(0, 0, 0, .55); }
.confirm-dialog-card h2 { margin-bottom: 9px; font-size: 1.25rem; }
.confirm-dialog-card p { color: var(--text-dim); line-height: 1.55; }
.confirm-dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }

/* ---------- Loader / error ---------- */
.loader-wrap { display: flex; justify-content: center; padding: 60px 0; }
.loader {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  max-width: 1280px;
  margin: 30px auto;
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  background: rgba(255, 77, 109, 0.1);
  border: 1px solid rgba(255, 77, 109, 0.4);
  color: #ff8fa3;
  text-align: center;
}

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); overscroll-behavior: contain; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 7, 12, 0.8); backdrop-filter: blur(4px); }
.modal-content {
  position: relative;
  width: 100%;
  max-width: 760px;
  max-height: min(88vh, 88dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(11, 14, 20, 0.7);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  transition: background 0.15s;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.15); }
.modal-backdrop-poster {
  height: 240px;
  background-size: cover;
  background-position: center 20%;
  position: relative;
}
.modal-backdrop-poster::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, var(--bg-elev) 0%, transparent 60%);
}
.modal-body { padding: 8px 28px 28px; }
.modal-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chip {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(124, 92, 255, 0.35);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}
.chip-plain { background: rgba(255, 255, 255, 0.07); color: var(--text-dim); border-color: transparent; }
.modal-title { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 12px; }
.modal-overview { color: var(--text-dim); margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.modal-trailer { margin-top: 18px; }
.modal-trailer iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: var(--radius-sm);
  background: #000;
}
.modal-cast-title { font-size: 0.95rem; font-weight: 700; margin: 18px 0 10px; }
.cast-list { display: flex; flex-wrap: wrap; gap: 8px; }

/* Providers (dÃ³nde ver) */
.modal-providers { display: flex; gap: 10px; flex-wrap: wrap; }
.provider {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}
.provider img { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; }
.provider:hover { border-color: var(--accent); text-decoration: none; }

/* Episodios / temporadas (modo demo) */
.episode-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.episode {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  transition: border-color 0.15s, background 0.15s;
}
.episode:hover { border-color: var(--accent); background: rgba(124, 92, 255, 0.08); }
.episode-num {
  flex-shrink: 0;
  font-weight: 800;
  color: var(--accent-strong);
  font-size: 0.9rem;
  width: 26px;
  text-align: center;
  padding-top: 2px;
}
.episode-name { font-weight: 600; font-size: 0.92rem; }
.episode-overview { color: var(--text-dim); font-size: 0.84rem; margin-top: 2px; }

/* Banner modo demo */
.demo-banner {
  max-width: 1280px;
  margin: 20px auto 0;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: rgba(124, 92, 255, 0.1);
  border: 1px dashed rgba(124, 92, 255, 0.5);
  color: var(--text-dim);
  font-size: 0.88rem;
  text-align: center;
}
.demo-banner code { color: var(--accent-strong); }

/* Reproductor de trÃ¡iler en modal demo */
.trailer-box { margin-bottom: 8px; }
.trailer-box iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: var(--radius-sm);
  background: #000;
}
.trailer-play { width: 100%; justify-content: center; padding: 14px; font-size: 1rem; }
.modal-divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  text-align: center;
  font-size: 0.85rem;
  padding: 26px 20px;
  margin-top: 40px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .header-inner { gap: 14px; padding: 0 14px; }
  .main-nav { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .main-nav::-webkit-scrollbar { display: none; }
  .search-box { flex: 1; min-width: 0; }
  .header-inner { flex-wrap: wrap; height: auto; padding: 10px 14px 12px; }
  .logo { font-size: 1.4rem; }
  #genre-filter { max-width: 140px; }
}

@media (max-width: 700px) {
  .header-inner { gap: 10px; }
  .logo { font-size: 1.25rem; }
  .search-box { order: 4; width: 100%; min-width: 0; }
  #search-input { padding: 10px 14px 10px 38px; }
  #genre-filter { order: 5; width: 100%; max-width: none; text-align: left; }
  .hero { min-height: 400px; }
  .hero-body { padding: 80px 16px 20px; }
  .hero-title { font-size: 1.5rem; }
  .hero-sub { font-size: 0.9rem; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px)); }
  .main-nav { display: none; }
  .rows { padding: 20px 12px 12px; gap: 24px; }
  .personal-rows { padding-top: 14px; padding-bottom: 0; }
  .row > .grid { grid-auto-columns: clamp(104px, 29vw, 126px); gap: 9px; margin-right: -12px; padding-right: 12px; }
  .row-title { font-size: 1.1rem; }
  .card-info { padding: 7px 8px 9px; }
  .card-title { font-size: .8rem; min-height: 2.2em; }
  .card-sub { font-size: .68rem; gap: 4px; }
  .search-view, .library-view, .settings-view { padding: 22px 14px; }
  .library-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
  .setting-row { align-items: flex-start; gap: 14px; }
  .settings-account-panel { grid-template-columns: 1fr; }
  .settings-rename > div { flex-direction: column; }
  .mobile-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 80; display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); border-top: 1px solid rgba(38, 45, 64, .9); background: rgba(11, 14, 20, .96); backdrop-filter: blur(14px); }
  .mobile-nav button { display: grid; justify-items: center; gap: 1px; min-height: 48px; padding: 3px 2px; border: 0; background: none; color: var(--text-dim); cursor: pointer; font: inherit; font-size: .67rem; font-weight: 700; }
  .mobile-nav button span { font-size: 1.15rem; line-height: 1; }
  .mobile-nav button.is-active { color: var(--accent-strong); }
  .site-footer { padding: 20px 14px; }
}

@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 9px; }
  .hero { min-height: 440px; }
  .hero-body { padding-top: 90px; }
  .hero-poster { display: none; }
  .modal-content { max-height: 94vh; }
  .modal-body { padding: 6px 18px 22px; }
  .modal-backdrop-poster { height: 180px; }
  .player-header { flex-wrap: wrap; gap: 10px; padding: 12px; }
  .player-title { width: 100%; order: 3; font-size: 0.95rem; }
  .player-server { width: 100%; max-width: none; margin-left: 0; order: 4; }
  .cast-content { width: 100%; max-width: 340px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .player-surface { height: 100%; aspect-ratio: auto; border-radius: 0; }
}

/* ---------- Skeleton Screens ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--border) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-hero { width: 100%; height: 320px; }
.skeleton-poster { width: 100%; aspect-ratio: 2/3; }
.skeleton-row { width: 100%; height: 180px; }
.skeleton-card { width: 100%; aspect-ratio: 2/3; }
.skeleton-text { width: 100%; height: 1em; }
.skeleton-text-sm { width: 70%; height: 1em; }

/* ---------- Vista del Reproductor ---------- */
.player-view { position:fixed; inset:0; z-index:200; background:var(--bg); display:flex; flex-direction:column; padding-bottom: env(safe-area-inset-bottom, 0px); }
.player-header { padding:calc(16px + env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) 16px max(24px, env(safe-area-inset-left, 0px)); display:flex; align-items:center; gap:16px; background:var(--bg-elev); border-bottom:1px solid var(--border); }
.player-title { flex:1; min-width:0; font-size:1.1rem; font-weight:600; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.player-container { flex:1; display:flex; flex-direction:column; justify-content:center; align-items:center; background:#000; position:relative; }
.player-container video, .player-container iframe { width:100%; height:100%; max-height:100vh; outline:none; }
.player-container .modal-cast-title { margin: 10px 0 6px; flex-shrink: 0; }
.player-container .trailer-box { flex: 1; width: 100%; min-height: 0; margin-bottom: 8px; display: flex; flex-direction: column; }
.player-container .trailer-box video { flex: 1; height: auto; min-height: 0; object-fit: contain; }

/* Selector de servidores (página de detalle + cabecera del player) */
.server-select {
  background: rgba(255,255,255,0.07);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font: inherit;
  font-size: 0.88rem;
  outline: none;
  cursor: pointer;
  min-height: 44px;
}
.server-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.server-select:disabled { opacity: 0.55; cursor: default; }
.player-server { max-width: 240px; min-width: 0; margin-left: auto; flex-shrink: 1; }

/* ---------- Página de detalle (#/titulo/...) ---------- */
.detail-view { max-width: 1280px; margin: 0 auto; padding: 24px 20px 48px; }

.detail-hero {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  background-color: var(--bg-elev);
  background-size: cover;
  background-position: center 20%;
  box-shadow: var(--shadow);
}
.detail-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(11,14,20,0.96) 0%, rgba(11,14,20,0.82) 45%, rgba(11,14,20,0.4) 100%),
    linear-gradient(0deg, var(--bg) 0%, transparent 55%);
}
.detail-hero-inner {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 28px;
  padding: 130px 28px 26px;
}
.detail-poster {
  flex-shrink: 0;
  width: 210px;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-sm);
  background-size: cover;
  background-position: center;
  background-color: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 2.4rem;
}
.detail-info { flex: 1; min-width: 0; }
.detail-title { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; letter-spacing: -0.6px; margin-bottom: 10px; }
.detail-overview { color: var(--text-dim); margin-bottom: 16px; max-width: 760px; }
.detail-actions { margin-bottom: 8px; }

.detail-sections { max-width: 900px; margin: 26px auto 0; }
.detail-trailer { margin-top: 18px; }
.detail-trailer iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: var(--radius-sm);
  background: #000;
}

/* ---------- Player inline (reproduce dentro de la página de detalle) ---------- */
.detail-player {
  position: relative;
  margin-top: 18px;
  padding: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.detail-player video,
.detail-player iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  background: #000;
  display: block;
}
/* El h4 que renderFuente agrega como encabezado del reproductor */
.detail-player .modal-cast-title { margin-bottom: 10px; }
.detail-player-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  padding: 2px 12px;
  font-size: 0.9rem;
  line-height: 1.5;
}

@media (max-width: 700px) {
  .detail-view { padding: 16px 14px 40px; }
  .detail-hero-inner { flex-direction: column; align-items: center; gap: 14px; padding: 90px 18px 22px; }
  .detail-poster { width: 150px; margin-top: -60px; }
  .detail-info { width: 100%; }
}

/* Filtro de género (header) */
#genre-filter {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#genre-filter:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }



/* ---------- Clasificación de edad sobre el reproductor ---------- */
.clasificacion-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  max-width: 100%;
}
.clasificacion-banner[hidden] { display: none; }
.clasif-badge {
  flex: none;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  letter-spacing: 0.03em;
}
.clasif-verde { background: rgba(46, 160, 67, 0.18); color: #3fb950; border: 1px solid rgba(46, 160, 67, 0.45); }
.clasif-amarillo { background: rgba(210, 153, 34, 0.16); color: #d29922; border: 1px solid rgba(210, 153, 34, 0.45); }
.clasif-rojo { background: rgba(248, 81, 73, 0.15); color: #f85149; border: 1px solid rgba(248, 81, 73, 0.5); }
.clasif-desc {
  color: var(--text-dim);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
/* Clasificación como chip dentro de la fila de metadatos del detalle. */
.modal-meta .clasif-badge,
#detail-meta .clasif-badge { border-radius: 14px; }

/* ---------- Barra de acciones del reproductor (PiP + Cast) ---------- */
.player-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}
.player-container .player-actions { justify-content: center; }
.koabtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.koabtn:hover { background: rgba(124, 92, 255, 0.16); border-color: var(--accent); color: var(--accent-strong); }
.koabtn.is-active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 16px rgba(124, 92, 255, 0.4); }
/* ---------- Descarga (job en backend -> MP4 listo) ---------- */
.koabtn-descargar:disabled { opacity: 0.6; cursor: wait; }
.descarga-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.85rem;
  color: var(--text);
}
.descarga-msg { flex: 1 1 100%; color: var(--text-dim); }
.descarga-msg.descarga-ok { color: #7ee2a8; font-weight: 600; }
.descarga-msg.descarga-error { color: #ff8fa3; }
.descarga-bar {
  flex: 1 1 160px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.descarga-fill {
  height: 100%;
  width: 2%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.4s;
}
.descarga-cancelar { padding: 4px 10px; font-size: 0.78rem; }
.descarga-guardar {
  background: var(--accent);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
}

/* ---------- Panel de Cast ---------- */
.cast-panel {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
   padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
}
.cast-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 12, 0.8);
  backdrop-filter: blur(4px);
}
.cast-content {
  position: relative;
  width: 100%;
  max-width: 340px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 24px;
}
.cast-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(11, 14, 20, 0.7);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
}
.cast-close:hover { background: rgba(255, 255, 255, 0.15); }
.cast-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 8px;
}
.cast-desc { color: var(--text-dim); font-size: 0.86rem; margin-bottom: 16px; }
.cast-code-input {
  width: 100%;
  padding: 14px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cast-code-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cast-error { color: #ff8fa3; font-size: 0.82rem; margin-top: 8px; }
.cast-actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.cast-titulo { font-weight: 700; font-size: 0.98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cast-estado {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 999px;
}
.cast-code-label { color: var(--text-dim); font-size: 0.82rem; }
.cast-code-label strong { color: var(--text); letter-spacing: 1px; }

/* ---------- Footer/header de settings en MAYÚSCULAS ---------- */
.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  margin: 26px 0 10px;
}

/* ---------- Polish "pro streaming" (púrpura; aditivo, no rompe JS) ---------- */
.hero-title {
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.6);
}
.hero-rating {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ffd166;
  font-weight: 800;
}
/* Dots indicadores del hero (activo accent, inactivo blanco 30%) */
.hero-dots {
  display: inline-flex;
  gap: 6px;
  margin-left: 4px;
  vertical-align: middle;
}
.hero-dots .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transition: background 0.2s, transform 0.2s;
}
.hero-dots .dot.active { background: var(--accent); transform: scale(1.25); }

/* Cards: radius 8-12 y hover sutil con sombra */
.card { border-radius: 10px; }
.card-poster { overflow: hidden; }

/* Transiciones de redondez en chips (radius 12-20) */
.chip, .chip-plain { border-radius: 14px; }

/* Footer uppercase */
.site-footer small { text-transform: uppercase; letter-spacing: 0.8px; }

/* ---------- Responsive móvil (Tarea 3) ---------- */
@media (max-width: 480px) {
  .hero-title { font-size: 1.6rem; }
  .hero-sub { font-size: 0.9rem; }
  .hero { min-height: 400px; }
  .card-title { font-size: 0.82rem; }
  .grid { gap: 10px; }
  .player-header { flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
  .player-server { max-width: 100%; width: 100%; margin-left: 0; }
  .detail-hero-inner { padding: 100px 14px 20px; }
  .site-header { padding-top: env(safe-area-inset-top, 0px); }
  .header-inner { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
  .nav-link, .row-more, .modal-close, .cast-close { min-width: 44px; min-height: 44px; }
  .modal { align-items: flex-end; }
  .modal-content { max-height: min(94vh, 94dvh); border-radius: 18px 18px 0 0; }
  .modal-body { padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px)); }
  .btn, .koabtn, .server-select { min-height: 44px; }
  .modal-content, .cast-content { max-width: 100%; width: 100%; }
  .cast-content { max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); overflow-y: auto; }
  input, select { font-size: 16px; }
}
/* Public links are catalog-free and playback-disabled until the stream backend
   accepts the share credential. */
.koa-public-mode .site-header,
.koa-public-mode .mobile-nav,
.koa-public-mode .site-footer,
.koa-public-mode #hero,
.koa-public-mode #rows,
.koa-public-mode #personal-rows,
.koa-public-mode #search-view,
.koa-public-mode #list-view,
.koa-public-mode #library-view,
.koa-public-mode #settings-view,
.koa-public-mode #cast-panel,
.koa-public-mode .detail-back { display: none !important; }
