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

:root {
  --bg: #0f0f13;
  --bg2: #16161d;
  --bg3: #1e1e28;
  --bg4: #252530;
  --acc: #7c3aed;
  --acc2: #9d5cf0;
  --glow: rgba(124, 58, 237, .28);
  --text: #e8e8f0;
  --text2: #9090a8;
  --text3: #5a5a72;
  --ok: #4ade80;
  --danger: #ef4444;
  --border: rgba(255, 255, 255, .07);
  --radius: 12px;
}

* { scrollbar-width: thin; scrollbar-color: var(--bg4) transparent; }
::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

html, body { min-height: 100%; background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }
body { line-height: 1.4; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; }
.muted { color: var(--text2); }
.small { font-size: 12px; }
.error { color: #fca5a5; font-size: 13px; }

/* Botões */
.btn { border: 1px solid var(--border); background: var(--bg3); padding: 9px 16px; border-radius: 10px; font-weight: 600; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--bg4); }
.btn.primary { background: var(--acc); border-color: transparent; color: #fff; }
.btn.primary:hover { background: var(--acc2); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.on { border-color: var(--acc); background: rgba(124, 58, 237, .18); color: #d8c4ff; }
.btn:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--acc2); outline-offset: 2px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(900px 500px at 50% -10%, var(--glow), transparent 70%), var(--bg); }
.login-card { width: min(380px, 100%); background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 28px 24px; display: flex; flex-direction: column; gap: 8px; text-align: center; }
.login-card h1 { font-size: 26px; }
.login-logo { margin: 0 auto 4px; border-radius: 20px; }
.login-card label { text-align: left; font-size: 12px; color: var(--text2); margin-top: 8px; }
.login-card input { width: 100%; padding: 11px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }
.login-card input:focus { border-color: var(--acc); outline: none; }
.login-card .btn { margin-top: 14px; padding: 12px; }

/* Topo */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 10px 20px; background: rgba(15, 15, 19, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand img { border-radius: 7px; }
.nav { display: flex; gap: 4px; }
.nav button { background: none; border: 0; padding: 8px 12px; border-radius: 8px; color: var(--text2); font-weight: 600; white-space: nowrap; }
.nav button:hover { color: var(--text); background: var(--bg3); }
.nav button.on { color: #fff; background: rgba(124, 58, 237, .25); }
.search { margin-left: auto; width: min(280px, 100%); padding: 9px 12px; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; }
.search:focus { border-color: var(--acc); outline: none; }
.who { display: flex; align-items: center; gap: 10px; }
.badge-server { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(124, 58, 237, .18); color: #c4b5fd; border: 1px solid rgba(124, 58, 237, .35); }

.content { padding: 18px 20px 60px; max-width: 1500px; margin: 0 auto; }

/* Navegação por categorias */
.browse { display: grid; grid-template-columns: 230px 1fr; gap: 18px; align-items: start; }
.cats { position: sticky; top: 74px; max-height: calc(100vh - 92px); overflow: auto; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; }
.cats button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; color: var(--text2); font-size: 13px; }
.cats button:hover { background: var(--bg3); color: var(--text); }
.cats button.on { background: rgba(124, 58, 237, .22); color: #fff; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; min-height: 34px; }
.toolbar h2 { font-size: 18px; }
.seg { display: flex; gap: 6px; }

/* Grade de cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.grid.live { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.card { position: relative; cursor: pointer; }
.thumb { position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden; background: var(--bg3) center / 38% no-repeat; border: 1px solid var(--border); transition: transform .15s, border-color .15s; }
.live .thumb, .card.live .thumb, .card.episode .thumb { aspect-ratio: 16 / 9; }
.card:hover .thumb { transform: translateY(-2px); border-color: rgba(124, 58, 237, .6); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.card.live .thumb img { object-fit: contain; padding: 14px; }
.thumb .bar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--acc2); }
.thumb::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .12); z-index: 0; }
.thumb .bar { z-index: 1; }
.badge { position: absolute; left: 8px; top: 8px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: rgba(34, 197, 94, .88); color: #04210f; }
.fav { position: absolute; right: 6px; top: 6px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); color: #fff; font-size: 17px; line-height: 1; }
.fav.on { color: #facc15; }
.fav:hover { background: rgba(0, 0, 0, .8); }
.card .name { margin-top: 8px; font-size: 13px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .sub { font-size: 12px; color: var(--text2); }

/* Fileiras da home */
.row { margin-bottom: 28px; }
.row h2 { font-size: 17px; margin-bottom: 12px; }
.row .scroller { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x proximity; }
.row .card { flex: 0 0 150px; scroll-snap-align: start; }
.row .card.live, .row .card.episode { flex-basis: 210px; }

.empty { text-align: center; color: var(--text2); padding: 70px 10px; }
.empty b { display: block; font-size: 18px; color: var(--text); margin-bottom: 6px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--bg4); border-top-color: var(--acc2); animation: spin .8s linear infinite; margin: 60px auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.sentinel { height: 1px; }

/* Modal */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .72); display: grid; place-items: center; padding: 16px; }
.modal { position: relative; width: min(860px, 100%); max-height: 92vh; overflow: auto; background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 22px; }
.close { position: absolute; right: 12px; top: 12px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--bg3); z-index: 2; }
.close:hover { background: var(--bg4); }
.detail { display: flex; gap: 20px; }
.detail .poster { flex: 0 0 170px; aspect-ratio: 2 / 3; border-radius: var(--radius); background: var(--bg3) center / 38% no-repeat; overflow: hidden; border: 1px solid var(--border); }
.detail .poster.wide { aspect-ratio: 16 / 9; flex-basis: 220px; }
.detail .poster img { width: 100%; height: 100%; object-fit: cover; }
.detail .info { min-width: 0; flex: 1; }
.detail h2 { font-size: 22px; padding-right: 36px; }
.detail .plot { color: var(--text2); font-size: 14px; margin: 10px 0; max-height: 120px; overflow: auto; }
.hero { position: relative; height: 190px; margin: -22px -22px 0; border-radius: 16px 16px 0 0; background: var(--bg3) center / cover no-repeat; }
.hero::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(to top, var(--bg2) 5%, rgba(22, 22, 29, .25)); }
.hero + .detail { position: relative; z-index: 1; margin-top: -70px; }
.extra { margin-top: 12px; font-size: 13px; color: var(--text2); line-height: 1.7; }
.extra b { color: var(--text); font-weight: 600; }
.credit { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--text3); margin-top: 10px; }
.credit img { height: 22px; width: auto; flex: 0 0 auto; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 8px; }
.note { font-size: 12px; color: var(--text3); margin-top: 12px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg3); border: 1px solid var(--border); margin-right: 6px; }
.pill.ok { color: var(--ok); border-color: rgba(34, 197, 94, .35); background: rgba(34, 197, 94, .1); }
.eps-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 20px 0 10px; flex-wrap: wrap; }
.eps-head select { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; }
.eps { display: flex; flex-direction: column; gap: 6px; }
.ep { position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; background: var(--bg3); border: 1px solid transparent; overflow: hidden; }
.ep.flash { border-color: var(--acc2); }
.ep .num { flex: 0 0 34px; color: var(--text2); font-weight: 700; }
.ep .t { flex: 1; min-width: 0; font-size: 14px; }
.ep .t small { display: block; color: var(--text2); font-size: 12px; }
.ep .check { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: transparent; color: var(--text3); }
.ep .check.on { background: rgba(34, 197, 94, .18); color: var(--ok); border-color: rgba(34, 197, 94, .4); }
.ep .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--acc2); }
.ep.done .t { color: var(--text2); }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--bg4); border: 1px solid var(--border); padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 60; }

/* Telas pequenas */
@media (max-width: 860px) {
  .top { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .search { order: 2; margin-left: 0; flex: 1; }
  .who { margin-left: auto; }
  .content { padding: 14px 12px 50px; }
  .browse { grid-template-columns: 1fr; }
  .cats { position: static; max-height: none; display: flex; gap: 6px; overflow-x: auto; padding: 6px; }
  .cats button { width: auto; white-space: nowrap; flex: 0 0 auto; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px; }
  .grid.live { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .row .card { flex-basis: 118px; }
  .row .card.live, .row .card.episode { flex-basis: 170px; }
  .detail { flex-direction: column; }
  .detail .poster { flex-basis: auto; width: 150px; }
  .detail .poster.wide { width: 100%; }
  #sync-status { display: none; }
}
