:root {
  --bg: #F4EFE6;
  --surface: #FFFDF9;
  --surface-2: #EAE3D6;
  --ink: #1D1915;
  --muted: #6D6458;
  --line: #DDD3C3;
  --accent: #B8551F;
  --accent-ink: #FFFFFF;
  --gold: #B07A14;
  --badge-bg: rgba(22, 19, 15, .82);
  --badge-ink: #F6D58C;
  --shadow: 0 1px 2px rgba(40, 30, 15, .08), 0 6px 18px rgba(40, 30, 15, .08);
  --radius: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16130F;
    --surface: #211D18;
    --surface-2: #2C2721;
    --ink: #F1EBE1;
    --muted: #A89D8E;
    --line: #3A332B;
    --accent: #E2A33B;
    --accent-ink: #16130F;
    --gold: #E2A33B;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16130F; --surface: #211D18; --surface-2: #2C2721; --ink: #F1EBE1; --muted: #A89D8E;
  --line: #3A332B; --accent: #E2A33B; --accent-ink: #16130F; --gold: #E2A33B;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--font); min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; z-index: 50; background: var(--surface); padding: 6px 10px; border-radius: 6px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- botones y campos --- */
button { cursor: pointer; border: 0; border-radius: 8px; padding: 8px 14px; background: var(--surface-2); }
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.ghost { background: transparent; border: 1px solid var(--line); }
.ghost[aria-expanded="true"] { background: var(--surface-2); }
.small { padding: 5px 10px; font-size: 13px; }
select, input[type="search"], input[type="email"] {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 40px;
}
input[type="search"] { width: 100%; }

/* --- login --- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-box { max-width: 380px; text-align: center; }
.login h1 { font: 700 40px/1.1 var(--display); margin: 4px 0 12px; letter-spacing: -.01em; }
.login p { color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 12px; color: var(--accent) !important; font-weight: 600; margin: 0; }
.gbtn { display: flex; justify-content: center; margin: 24px 0 8px; min-height: 44px; }
.login-msg { color: var(--accent) !important; min-height: 1.5em; }

/* --- cabecera --- */
.top {
  position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 10px 16px 0;
}
.top-row { display: flex; align-items: center; gap: 10px; max-width: 1200px; margin: 0 auto; }
.brand { font: 700 21px/1 var(--display); text-decoration: none; margin-right: auto; white-space: nowrap; }
.profile select { max-width: 160px; min-height: 34px; padding: 4px 8px; font-size: 14px; }
.views {
  display: flex; gap: 4px; overflow-x: auto; max-width: 1200px; margin: 8px auto 0; scrollbar-width: none;
}
.views::-webkit-scrollbar { display: none; }
.views a {
  text-decoration: none; padding: 8px 12px 10px; color: var(--muted); font-weight: 500; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.views a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

.banner {
  max-width: 1200px; margin: 12px auto 0; padding: 10px 14px; border-radius: var(--radius);
  background: var(--surface-2); font-size: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.banner + main { margin-top: 0; }

main { max-width: 1200px; margin: 0 auto; padding: 16px; outline: none; }

/* --- barra de herramientas --- */
.toolbar { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; }
.search { min-width: 0; }
.sort select { max-width: 170px; }
@media (max-width: 520px) {
  .toolbar { grid-template-columns: 1fr auto; }
  .search { grid-column: 1 / -1; }
  .sort select { max-width: none; width: 100%; }
  .sort { min-width: 0; }
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 14px;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .n { color: var(--muted); margin-left: 4px; font-size: 12px; }
.chip[aria-pressed="true"] .n { color: inherit; opacity: .7; }
.filters {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 12px;
  padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); align-items: end;
}
.filters label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.filters label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; min-height: 40px; }
.count { color: var(--muted); font-size: 13px; margin: 14px 0 8px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* --- cuadrícula --- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px 12px; }
@media (max-width: 420px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 12px 8px; } }
.card { all: unset; cursor: pointer; display: block; min-width: 0; }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
.poster {
  position: relative; aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden;
  background: var(--surface-2); box-shadow: var(--shadow);
}
.poster img { width: 100%; height: 100%; object-fit: cover; }
.poster .noimg { position: absolute; inset: 0; display: grid; place-items: center; padding: 8px; text-align: center; font: 600 13px/1.3 var(--display); color: var(--muted); }
.badge {
  position: absolute; left: 6px; bottom: 6px; background: var(--badge-bg); color: var(--badge-ink);
  font-weight: 600; font-size: 13px; padding: 2px 7px; border-radius: 6px; font-variant-numeric: tabular-nums;
}
.badge.top { left: auto; right: 6px; top: 6px; bottom: auto; color: #fff; font-weight: 500; font-size: 11px; }
.badge.seen { background: rgba(32, 110, 70, .9); }
.card h3 { font-size: 13px; font-weight: 600; line-height: 1.3; margin: 8px 0 2px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card p { margin: 0; font-size: 12px; color: var(--muted); }

/* --- ficha --- */
.detail {
  width: min(760px, 100vw); max-height: 92vh; padding: 0; border: 0; border-radius: 14px;
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
}
.detail::backdrop { background: rgba(10, 8, 6, .6); }
@media (max-width: 600px) {
  .detail { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100%; margin: 0; border-radius: 0; }
}
.d-hero { position: relative; aspect-ratio: 16 / 7; background: var(--surface-2) center / cover no-repeat; }
.d-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 30%, var(--surface)); }
.d-close {
  position: absolute; top: 10px; right: 10px; z-index: 2; width: 38px; height: 38px; padding: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 20px; line-height: 38px;
}
.d-head { display: grid; grid-template-columns: 110px 1fr; gap: 16px; padding: 0 20px; margin-top: -60px; position: relative; z-index: 1; }
.d-head .poster { width: 110px; }
.d-head h2 { font: 700 26px/1.15 var(--display); margin: 52px 0 4px; }
.d-sub { color: var(--muted); font-size: 14px; margin: 0; }
.d-body { padding: 16px 20px 24px; }
.d-body h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 20px 0 8px; }
.d-body p { margin: 0 0 8px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { background: var(--surface-2); border-radius: 999px; padding: 3px 10px; font-size: 13px; }
.scores { display: flex; flex-wrap: wrap; gap: 10px; }
.score { background: var(--surface-2); border-radius: var(--radius); padding: 8px 12px; min-width: 92px; }
.score b { font: 700 22px/1 var(--display); display: block; color: var(--gold); }
.score span { font-size: 12px; color: var(--muted); }
.prov { display: grid; gap: 8px; }
.prov div { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.prov strong { font-size: 13px; color: var(--muted); font-weight: 500; min-width: 82px; }
.trailer { aspect-ratio: 16 / 9; width: 100%; border: 0; border-radius: var(--radius); background: #000; }
.links { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; }

/* --- estadísticas y compartir --- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel h3 { font: 700 18px/1.2 var(--display); margin: 0 0 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.kpi b { font: 700 28px/1 var(--display); display: block; }
.kpi span { color: var(--muted); font-size: 13px; }
.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.bar i { display: block; height: 10px; border-radius: 5px; background: var(--accent); min-width: 2px; }
.bar em { font-style: normal; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 36px; }
.share-form { display: flex; gap: 8px; flex-wrap: wrap; }
.share-form input { flex: 1 1 220px; }
.share-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.share-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; word-break: break-all; }
.muted { color: var(--muted); }
.note { font-size: 13px; color: var(--muted); }

.foot { max-width: 1200px; margin: 24px auto 0; padding: 20px 16px 40px; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 12px; }
.foot p { margin: 0; }
.foot img { flex: none; }
