:root {
  --purple: #2D145F;
  --purple-dark: #1C0A3E;
  --purple-light: #3F2280;
  --purple-line: rgba(255, 255, 255, 0.08);
  --orange: #F0A01E;
  --gold: #D4A014;
  --gold-soft: #FFD27A;
  --text: #F4EEFF;
  --muted: rgba(244, 238, 255, 0.6);
  --danger: #FF6B6B;
  --radius: 12px;
  --top-h: 64px;
  --cats-w: 260px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 800px at 20% -10%, var(--purple-light), transparent 60%), var(--purple-dark);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: var(--gold-soft); }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
.muted { color: var(--muted); }
.noscript { padding: 2rem; text-align: center; }

/* ---------- Botões ---------- */
.btn {
  border: 0; border-radius: 10px; padding: 0.8rem 1.2rem; font-weight: 600;
  transition: transform .1s, filter .15s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--orange); color: #2a1300; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { filter: grayscale(.6) brightness(.8); cursor: progress; }
.btn-ghost { background: rgba(255,255,255,.06); border: 1px solid var(--purple-line); }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-sm { padding: .45rem .9rem; font-size: .9rem; }
.icon-btn {
  background: transparent; border: 0; width: 42px; height: 42px; border-radius: 50%;
  display: inline-grid; place-items: center; flex: none;
}
.icon-btn:hover { background: rgba(255,255,255,.1); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; color: var(--gold); letter-spacing: .02em; }
.brand img { border-radius: 22%; }
.brand span { font-size: 1.35rem; }
.brand-lg h1 { margin: 0; font-size: 2.4rem; color: var(--gold); line-height: 1; }
.brand-lg .tagline { margin: .3rem 0 0; color: var(--gold-soft); font-weight: 500; }

/* ---------- Login ---------- */
.login {
  min-height: 100%; display: grid; place-items: center;
  padding: max(1.5rem, env(safe-area-inset-top)) 1rem max(1.5rem, env(safe-area-inset-bottom));
}
.login-card {
  width: 100%; max-width: 440px; padding: 2rem;
  background: rgba(45, 20, 95, .85); border: 1px solid var(--purple-line);
  border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.45);
  backdrop-filter: blur(8px);
}
.tabs { display: grid; grid-template-columns: 1fr 1fr; margin: 1.8rem 0 1.2rem; background: rgba(0,0,0,.25); border-radius: 12px; padding: 4px; }
.tab { background: transparent; border: 0; padding: .65rem; border-radius: 9px; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--purple-light); color: var(--gold-soft); }
.login-form { display: grid; gap: .9rem; }
.login-form label { display: grid; gap: .35rem; font-size: .9rem; color: var(--muted); }
.login-form input[type=url], .login-form input[type=text], .login-form input[type=password] {
  width: 100%; padding: .8rem .9rem; border-radius: 10px; color: var(--text);
  background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.12);
}
.login-form input:focus { border-color: var(--orange); outline: none; }
.login-form .check { display: flex; align-items: center; gap: .5rem; grid-template-columns: none; }
.login-form .check input { accent-color: var(--orange); width: 18px; height: 18px; }
.login-form .btn { margin-top: .4rem; font-size: 1.05rem; }
.error { color: var(--danger); background: rgba(255,107,107,.1); padding: .7rem .9rem; border-radius: 10px; margin: 1rem 0 0; font-size: .92rem; }
.disclaimer { font-size: .78rem; color: var(--muted); margin: 1.4rem 0 .4rem; line-height: 1.45; }
.support { font-size: .82rem; color: var(--muted); margin: 0; }

/* ---------- App ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  height: var(--top-h); flex: none; display: flex; align-items: center; gap: .8rem;
  padding: 0 max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
  background: rgba(45, 20, 95, .95); border-bottom: 1px solid var(--purple-line);
  position: sticky; top: 0; z-index: 20;
}
.sections { display: flex; gap: .3rem; margin-left: 1rem; }
.section {
  background: transparent; border: 0; padding: .5rem .95rem; border-radius: 999px;
  color: var(--muted); font-weight: 600; white-space: nowrap;
}
.section:hover { color: var(--text); }
.section.active { background: var(--orange); color: #2a1300; }
.search { flex: 1; display: flex; justify-content: flex-end; min-width: 0; }
.search input {
  width: 100%; max-width: 320px; padding: .55rem .9rem; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12); background: rgba(0,0,0,.25); color: var(--text);
}
.search input:focus { outline: none; border-color: var(--orange); }

.layout { flex: 1; display: flex; min-height: 0; }
.cats {
  width: var(--cats-w); flex: none; overflow-y: auto; border-right: 1px solid var(--purple-line);
  background: rgba(28, 10, 62, .6); padding: .6rem;
}
.cats ul { list-style: none; margin: 0; padding: 0; }
.cats li button {
  width: 100%; text-align: left; background: transparent; border: 0; padding: .6rem .8rem;
  border-radius: 8px; color: var(--muted); font-size: .92rem; line-height: 1.25;
}
.cats li button:hover { background: rgba(255,255,255,.06); color: var(--text); }
.cats li button.active { background: rgba(240,160,30,.16); color: var(--gold-soft); font-weight: 600; }
.cats-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 29; }

.content { flex: 1; overflow-y: auto; padding: 1.2rem 1.4rem 3rem; min-width: 0; }
.content-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.content-head h2 { margin: 0; color: var(--gold); font-size: 1.3rem; }

.grid { display: grid; gap: 1rem; }
.grid.live { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid.poster { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.card {
  background: rgba(63, 34, 128, .45); border: 1px solid var(--purple-line); border-radius: var(--radius);
  padding: 0; overflow: hidden; text-align: left; display: flex; flex-direction: column;
  transition: transform .12s, border-color .12s, background .12s;
}
.card:hover, .card:focus-visible { transform: translateY(-2px); border-color: var(--orange); background: rgba(63, 34, 128, .75); }
.card .thumb { position: relative; background: rgba(0,0,0,.25); display: grid; place-items: center; overflow: hidden; }
.grid.live .card .thumb { aspect-ratio: 16 / 10; padding: .8rem; }
.grid.poster .card .thumb { aspect-ratio: 2 / 3; }
.card img { width: 100%; height: 100%; object-fit: contain; }
.grid.poster .card img { object-fit: cover; }
.card .ph { color: var(--orange); font-size: 2rem; font-weight: 800; opacity: .8; }
.card .name { padding: .55rem .7rem .7rem; font-size: .86rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.grid-status { text-align: center; color: var(--muted); padding: 2rem 1rem; }
#btn-more { display: block; margin: 1.2rem auto 0; }

.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--orange); animation: spin .8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modal série ---------- */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(10, 4, 25, .75); display: grid; place-items: center; padding: 1rem; }
.modal-card {
  position: relative; width: 100%; max-width: 760px; max-height: 92vh; overflow-y: auto;
  background: var(--purple); border: 1px solid var(--purple-line); border-radius: 18px; padding: 1.4rem;
}
.modal-close { position: absolute; top: .6rem; right: .6rem; }
.series-head { display: flex; gap: 1rem; padding-right: 2.5rem; }
.series-head img { width: 110px; aspect-ratio: 2/3; object-fit: cover; border-radius: 10px; background: rgba(0,0,0,.3); flex: none; }
.series-head h2 { margin: 0 0 .4rem; color: var(--gold); }
.series-head p { margin: 0; font-size: .9rem; line-height: 1.45; max-height: 9em; overflow: auto; }
.season-tabs { display: flex; gap: .4rem; overflow-x: auto; margin: 1.2rem 0 .8rem; padding-bottom: .3rem; }
.season-tabs button { background: rgba(255,255,255,.06); border: 0; padding: .45rem .9rem; border-radius: 999px; white-space: nowrap; color: var(--muted); }
.season-tabs button.active { background: var(--orange); color: #2a1300; font-weight: 600; }
.episode-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.episode-list button {
  width: 100%; text-align: left; background: rgba(0,0,0,.2); border: 1px solid transparent; border-radius: 10px;
  padding: .75rem .9rem; display: flex; gap: .7rem; align-items: center;
}
.episode-list button::before { content: "▶"; color: var(--orange); font-size: .8rem; }
.episode-list button:hover { border-color: var(--orange); }

/* ---------- Player ---------- */
.player { position: fixed; inset: 0; z-index: 50; background: #000; }
.player video { width: 100%; height: 100%; background: #000; }
.player-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: .6rem;
  padding: max(.6rem, env(safe-area-inset-top)) max(.8rem, env(safe-area-inset-right)) 1.6rem max(.8rem, env(safe-area-inset-left));
  background: linear-gradient(rgba(0,0,0,.75), transparent); transition: opacity .3s;
}
.player.idle .player-top { opacity: 0; pointer-events: none; }
.player-top .icon-btn { background: rgba(0,0,0,.35); }
#player-title { font-weight: 600; color: var(--gold-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.player-status {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center;
  color: var(--text); max-width: 80%; pointer-events: none; font-size: 1rem; line-height: 1.4;
  text-shadow: 0 1px 3px #000;
}
.player-status:empty { display: none; }

/* ---------- Toast / instalar ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(1.2rem, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--purple-light); border: 1px solid var(--orange); padding: .7rem 1.1rem; border-radius: 10px;
  z-index: 60; max-width: 90vw; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.install {
  position: fixed; right: 1rem; bottom: max(1rem, env(safe-area-inset-bottom)); z-index: 35;
  display: flex; align-items: center; gap: .6rem; padding: .5rem .5rem .5rem 1rem;
  background: var(--purple); border: 1px solid var(--purple-line); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}

/* ---------- Responsivo ---------- */
.only-narrow { display: none; }

@media (max-width: 900px) {
  :root { --cats-w: 280px; }
  .only-narrow { display: inline-grid; }
  .cats {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 30; transform: translateX(-100%);
    transition: transform .2s; background: var(--purple-dark); padding-top: calc(env(safe-area-inset-top) + .6rem);
  }
  .cats.open { transform: none; }
  .sections { margin-left: 0; }
}

@media (max-width: 680px) {
  .topbar { flex-wrap: wrap; height: auto; padding-top: max(.5rem, env(safe-area-inset-top)); padding-bottom: .5rem; row-gap: .5rem; }
  .brand span { display: none; }
  .sections { order: 3; width: 100%; justify-content: center; }
  .search { order: 2; }
  .content { padding: 1rem .8rem 3rem; }
  .grid.live { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .7rem; }
  .grid.poster { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .7rem; }
  .login-card { padding: 1.4rem; }
  .series-head img { width: 80px; }
}

@media (hover: none) {
  .card:hover { transform: none; }
}
