:root {
  --bg: #0c0b0b; --card: #17151a; --line: rgba(255,255,255,.12);
  --text: #fff; --muted: rgba(255,255,255,.62); --orange: #ff7a00; --orange2: #ffa23a; --red: #e5191e;
  --safe-top: env(safe-area-inset-top); --safe-bottom: env(safe-area-inset-bottom);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
input { font: inherit; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.center { text-align: center; }
.error { color: #ff8a80; }

.primary { background: linear-gradient(180deg, var(--orange2), var(--orange)); color: #fff; font-weight: 700; padding: 14px 20px; border-radius: 14px; }
.primary:disabled { opacity: .6; }
.ghost { background: rgba(255,255,255,.1); border-radius: 999px; padding: 10px 16px; }
.small { font-size: 14px; padding: 8px 14px; }

/* Entrada */
.screen { min-height: 100vh; }
#login { display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0%, #3a1c05 0%, var(--bg) 60%); }
.login-card { width: min(420px, 100%); display: grid; gap: 14px; background: rgba(23,21,26,.9); border: 1px solid var(--line); border-radius: 22px; padding: 28px; }
.login-logo { width: 220px; justify-self: center; }
.login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.login-card input { background: #0f0e10; border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; color: #fff; font-size: 16px; }
.login-card input:focus { outline: 2px solid var(--orange); border-color: transparent; }

/* Catálogo */
.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 12px; align-items: center; padding: calc(10px + var(--safe-top)) 16px 10px; background: rgba(12,11,11,.94); backdrop-filter: blur(10px); }
.top-logo { height: 30px; }
#search { flex: 1; min-width: 0; background: #1a181c; border: 1px solid var(--line); border-radius: 999px; padding: 9px 14px; color: #fff; font-size: 16px; }
.tabs { display: flex; gap: 8px; padding: 6px 16px; position: sticky; top: calc(50px + var(--safe-top)); z-index: 4; background: rgba(12,11,11,.94); }
.tab { background: transparent; padding: 9px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--orange); color: #fff; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; background: rgba(255,255,255,.08); padding: 7px 13px; border-radius: 999px; font-size: 13px; white-space: nowrap; }
.chip.active { background: #fff; color: #000; font-weight: 600; }

.grid { display: grid; gap: 12px; padding: 4px 16px calc(24px + var(--safe-bottom)); grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.grid.live { grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 720px) { .grid.live { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; text-align: left; padding: 0; }
.card img { display: block; width: 100%; aspect-ratio: 2/3; object-fit: cover; background: #222; }
.card .name { padding: 8px 9px 10px; font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.8em; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; text-align: left; }
.row .logo { width: 72px; height: 46px; border-radius: 9px; background: #232227; object-fit: contain; flex: none; padding: 4px; }
.row .num { color: var(--orange); font-weight: 700; font-size: 13px; margin-right: 6px; }
.row.playing { border-color: var(--orange); background: #2a1a0e; }

/* Series */
.overlay { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto; }
.sheet-top { display: flex; align-items: center; gap: 12px; padding: calc(12px + var(--safe-top)) 16px 8px; position: sticky; top: 0; background: var(--bg); }
.sheet-top h2 { margin: 0; font-size: 18px; }
.episodes { display: grid; gap: 8px; padding: 0 16px calc(30px + var(--safe-bottom)); }
.episode { display: flex; gap: 12px; align-items: center; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px; }
.episode img { width: 128px; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; background: #222; flex: none; }
.episode .ep { color: var(--orange); font-weight: 700; font-size: 12px; }

/* Reproductor */
.player { background: #000; display: flex; flex-direction: column; }
.player-top { display: flex; align-items: center; gap: 12px; padding: calc(10px + var(--safe-top)) 14px 10px; }
.player-title { display: grid; min-width: 0; }
.player-title strong, .player-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#video { width: 100%; flex: 1; min-height: 0; background: #000; max-height: calc(100vh - 140px); }
.player-msg { margin: 0; padding: 12px 16px; background: #2a1414; color: #ffcdc8; }
.diag { padding: 6px 16px calc(12px + var(--safe-bottom)); color: var(--muted); font-size: 12px; }
.diag pre { white-space: pre-wrap; word-break: break-all; max-height: 30vh; overflow: auto; }
