:root {
  --bg: #0f1115; --bg2: #171a21; --bg3: #1f2430; --line: #2a303d;
  --fg: #e8eaf0; --muted: #8b93a7; --accent: #f5c518; --ok: #3ddc84; --bad: #ff5c6c; --want: #6ea8ff;
  --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(--want); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); min-height: 1.2em; margin: 6px 0 0; font-size: 13px; }

button, input, select { font: inherit; color: inherit; }
input, select { background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.btn { background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: #111; border-color: transparent; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 360px; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.auth-card h1 { margin: 0 0 4px; }
.auth-card form { display: grid; gap: 10px; margin-top: 18px; }

/* topbar */
.topbar { display: flex; align-items: center; gap: 18px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--bg2); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; }
.tabs { display: flex; gap: 4px; }
.tab { background: transparent; border: 0; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--bg3); color: var(--fg); }
.count { background: var(--line); border-radius: 999px; padding: 0 7px; font-size: 12px; margin-left: 4px; }
.user { margin-left: auto; display: flex; gap: 10px; align-items: center; }

.profile { padding: 10px 20px 0; }
.profile b { color: var(--fg); }

/* filters */
.filters { padding: 10px 20px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row #q { min-width: 200px; flex: 1; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--bg3); border-radius: 999px; padding: 4px 11px; cursor: pointer; font-size: 13px; color: var(--muted); }
.chip.inc { border-color: var(--ok); color: var(--ok); background: rgba(61,220,132,.08); }
.chip.exc { border-color: var(--bad); color: var(--bad); background: rgba(255,92,108,.08); text-decoration: line-through; }
b.inc { color: var(--ok); } b.exc { color: var(--bad); }

/* grid */
main { padding: 14px 20px 60px; }
.summary-row { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; margin-bottom: 10px; }
.syncing { color: var(--accent); }
.list-meta { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-meta .btn:disabled { opacity: .5; cursor: default; }
.syncing::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .25; } to { opacity: 1; } }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 16px; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: transform .15s, opacity .25s; }
.card:hover { transform: translateY(-2px); border-color: var(--muted); }
.card.leaving { opacity: 0; transform: scale(.95); }
.poster { aspect-ratio: 2/3; background: var(--bg3); cursor: pointer; position: relative; display: grid; place-items: center; text-align: center; padding: 12px; }
.poster img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.poster .ph { font-weight: 700; font-size: 16px; line-height: 1.2; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.badge { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.75); border-radius: 6px; padding: 2px 7px; font-size: 12px; font-weight: 600; }
.badge.match { color: var(--ok); }
.badge.rating { color: var(--accent); }
.badge.status { left: auto; right: 8px; }
.body { padding: 10px; display: grid; gap: 4px; }
.title { font-weight: 600; line-height: 1.25; cursor: pointer; }
.meta { color: var(--muted); font-size: 12px; }
.why { font-size: 12px; color: var(--muted); }
.why b { color: var(--fg); font-weight: 500; }
.actions { display: flex; gap: 6px; margin-top: 6px; }
.actions .btn { flex: 1; padding: 6px 4px; font-size: 13px; }
.actions .btn.ok { color: var(--ok); }
.actions .btn.want { color: var(--want); }
.actions .btn.x { flex: 0 0 34px; color: var(--muted); }
.actions .btn.active.ok { background: var(--ok); color: #111; border-color: transparent; }
.actions .btn.active.want { background: var(--want); color: #111; border-color: transparent; }
.actions .btn.active.x { background: var(--bad); color: #111; border-color: transparent; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.more-wrap { display: flex; justify-content: center; margin-top: 20px; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.7); }
.modal-card { position: relative; width: 100%; max-width: 820px; max-height: 92vh; overflow: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; }
.hero { position: relative; aspect-ratio: 16/7; background: var(--bg3) center/cover; }
.hero.no-img { aspect-ratio: auto; height: 56px; }
.hero .close { position: absolute; top: 10px; right: 10px; }
.detail { padding: 18px 20px 22px; display: grid; gap: 12px; }
.detail h2 { margin: 0; font-size: 24px; }
.detail .meta { font-size: 13px; }
.detail .genres { display: flex; gap: 6px; flex-wrap: wrap; }
.detail .genres span { border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; font-size: 12px; color: var(--muted); }
.detail .why { font-size: 14px; }
.trailer { aspect-ratio: 16/9; background: #000; border-radius: 10px; overflow: hidden; display: grid; place-items: center; }
.trailer iframe { width: 100%; height: 100%; border: 0; }
.detail .actions { max-width: 460px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--bg3); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 30; display: flex; align-items: center; gap: 12px; }
.toast .undo { background: transparent; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; }

@media (max-width: 640px) {
  .topbar { padding: 10px 12px; gap: 10px; }
  .user #user-email { display: none; }
  .filters, main, .profile { padding-left: 12px; padding-right: 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
}

/* Stremio: painel de conexão (S10.5) e aba "Para confirmar" (S12.6) */
.tabs { flex-wrap: wrap; }
.stremio-card { max-width: 460px; }
.stremio-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.stremio-head h2 { margin: 0; font-size: 20px; }
.stremio-body { padding: 8px 20px 20px; display: grid; gap: 10px; }
.stremio-body p { margin: 0; }
.link-code { font: 700 34px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; text-align: center; background: var(--bg3); border: 1px solid var(--line); border-radius: 10px; padding: 14px; user-select: all; }
.link-url { text-align: center; word-break: break-all; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel-actions .btn:disabled { opacity: .5; cursor: default; }
.warn { color: var(--accent); background: rgba(245,197,24,.08); border: 1px solid rgba(245,197,24,.35); border-radius: 8px; padding: 10px 12px; }
.badge.was-want { color: var(--want); top: auto; bottom: 8px; }
.watched-on { font-size: 13px; }
.again { font-size: 12px; color: var(--accent); }
.decisions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.decisions .btn { padding: 6px 4px; font-size: 13px; }
.decisions .btn:disabled { opacity: .5; cursor: default; }
.decisions .btn.ok { color: var(--ok); }
.decisions .btn.want { color: var(--want); }
.decisions .btn.x { color: var(--muted); }
.uncatalogued { text-align: center; margin-top: 18px; }

/* Áudio em português e "Abrir no Stremio" (S8.11, S13.5, S13.6) */
.badge.pt-audio { top: auto; bottom: 8px; color: var(--want); }
.stremio-box { display: grid; gap: 8px; }
.pt-line { margin: 0; font-size: 14px; }
.pt-line.yes { color: var(--ok); }
.stremio-links { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.stremio-links .btn { text-decoration: none; color: var(--fg); }

/* Atribuição ao TMDB (P-4, audit F-12) */
.tmdb-attribution { text-align: center; font-size: 12px; opacity: .7; padding: 24px 16px 32px; }
.tmdb-attribution a { color: inherit; font-weight: 600; }
