:root {
  --bg: #0f1115; --bg2: #171a21; --bg3: #222632; --line: #2c3140;
  --fg: #e8eaf0; --muted: #9aa1b2; --accent: #e5484d; --accent2: #ff6b6f;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent2); }
button, select, input { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 10; display: flex; gap: 12px; align-items: center; padding: 10px 16px; background: rgba(15,17,21,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; white-space: nowrap; }
.brand img { width: 28px; height: 28px; }
.search { flex: 1; }
.search input, #provFilter { width: 100%; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg2); outline: none; }
.search input:focus, #provFilter:focus { border-color: var(--accent); }

.langs { display: flex; gap: 4px; flex-shrink: 0; }
.flag { background: none; border: 2px solid transparent; border-radius: 6px; padding: 2px; cursor: pointer; line-height: 0; opacity: .5; transition: opacity .15s; }
.flag img { width: 26px; height: 18px; border-radius: 3px; object-fit: cover; display: block; }
.flag:hover { opacity: .85; }
.flag.active { opacity: 1; border-color: var(--accent); }
.icon-btn { background: var(--bg2); border: 1px solid var(--line); border-radius: 50%; width: 38px; height: 38px; cursor: pointer; font-size: 17px; flex-shrink: 0; }
.icon-btn:hover { border-color: var(--accent); }

.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px 4px; }
.tabs { display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tab { border: 0; background: none; padding: 6px 16px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--accent); color: #fff; }
.bar select { background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; }

.chips { display: flex; gap: 8px; padding: 8px 16px; overflow-x: auto; scrollbar-width: none; }
.chip { display: flex; align-items: center; gap: 6px; padding: 4px 12px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg2); cursor: pointer; white-space: nowrap; color: var(--muted); }
.chip img { width: 24px; height: 24px; border-radius: 50%; }
.chip.all { padding-left: 12px; }
.chip.active { border-color: var(--accent); color: var(--fg); background: var(--bg3); }

main { padding: 8px 16px 24px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 10px; } .brand span, .brand { font-size: 0; gap: 0; } .brand img { width: 30px; height: 30px; } }

.card { cursor: pointer; border-radius: var(--radius); overflow: hidden; background: var(--bg2); position: relative; transition: transform .15s; }
.card:hover { transform: translateY(-3px); }
.card .poster { aspect-ratio: 2/3; width: 100%; object-fit: cover; display: block; background: var(--bg3); }
.card .noposter { aspect-ratio: 2/3; display: grid; place-items: center; padding: 10px; text-align: center; color: var(--muted); background: var(--bg3); }
.card .meta { padding: 8px 10px 10px; }
.card .t { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .s { color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; }
.card .logos { position: absolute; top: 6px; left: 6px; display: flex; gap: 3px; }
.card .logos img { width: 22px; height: 22px; border-radius: 6px; box-shadow: 0 1px 4px #000a; }
.card.unavailable { opacity: .45; }
.card.unavailable::after { content: attr(data-na); position: absolute; top: 6px; right: 6px; font-size: 11px; background: #000c; padding: 2px 6px; border-radius: 6px; }

.btn { border: 1px solid var(--line); background: var(--bg2); padding: 9px 18px; border-radius: 999px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: none; }
.more-wrap { text-align: center; padding: 20px; }
.notice { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.loader { width: 32px; height: 32px; margin: 20px auto; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

footer { color: var(--muted); font-size: 12px; text-align: center; padding: 20px 16px 30px; }

/* Modales */
.modal { border: 1px solid var(--line); border-radius: 16px; background: var(--bg2); color: var(--fg); padding: 0; width: min(760px, 94vw); max-height: 90vh; }
.modal::backdrop { background: #000b; backdrop-filter: blur(3px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 0; }
.modal-head h2 { margin: 0; font-size: 20px; }
.settings .hint { color: var(--muted); padding: 0 18px; margin: 8px 0 12px; font-size: 14px; }
.settings #provFilter { margin: 0 18px 12px; width: calc(100% - 36px); }
.prov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 0 18px; max-height: 40vh; overflow-y: auto; }
.prov { display: flex; align-items: center; gap: 8px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 13px; user-select: none; }
.prov img { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; }
.prov input { display: none; }
.prov.on { border-color: var(--accent); background: var(--bg3); }
.via-list { padding: 12px 18px 0; display: grid; gap: 6px; }
.via-list h3 { margin: 6px 0; font-size: 15px; }
.via-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.via-row img { width: 24px; height: 24px; border-radius: 6px; }
.via-row span { flex: 1; }
.via-row select { background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 18px; position: sticky; bottom: 0; background: var(--bg2); }

.detail .hero { position: relative; min-height: 180px; background: var(--bg3) center/cover no-repeat; }
.detail .hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 30%, var(--bg2)); }
.detail .hero .close { position: absolute; top: 12px; right: 12px; z-index: 2; background: #000a; }
.detail .body { display: flex; gap: 18px; padding: 0 20px 20px; margin-top: -80px; position: relative; z-index: 1; }
.detail .body > img { width: 140px; border-radius: 10px; box-shadow: 0 6px 20px #000a; align-self: flex-start; }
.detail h2 { margin: 60px 0 2px; font-size: 24px; }
.detail .sub { color: var(--muted); font-size: 14px; }
.detail .overview { margin: 12px 0; }
.detail .watch { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.watch-btn { display: inline-flex; align-items: center; gap: 8px; padding: 6px 16px 6px 6px; border-radius: 999px; background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; }
.watch-btn:hover { background: var(--accent2); }
.watch-btn img { width: 30px; height: 30px; border-radius: 50%; background: #fff; }
.watch-btn small { font-weight: 400; opacity: .85; }
.detail .others { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.detail .others img { width: 22px; height: 22px; border-radius: 5px; }
.detail .links { display: flex; gap: 14px; font-size: 14px; margin-top: 10px; }
@media (max-width: 560px) {
  .detail .body { flex-direction: column; margin-top: -60px; }
  .detail .body > img { width: 110px; }
  .detail h2 { margin-top: 4px; }
}
