:root {
  --bg: #1a1517; --panel: #2a2124; --panel2: #382b2f; --text: #f6ede6; --muted: #bfaea6;
  --accent: #ff8a5b; --accent2: #3fc1a9; --accent3: #f2c14e; --accent4: #c17bd9;
  --danger: #ff6b7a; --ok: #3fc1a9; --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif; }
a { color: inherit; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 8px; padding: 8px 14px;
  background: var(--accent); color: #2a1208; font-weight: 600; }
button.ghost { background: var(--panel2); color: var(--text); font-weight: 500; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
input { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid #4a3a3f;
  border-radius: 8px; padding: 8px 10px; }
input[type=checkbox] { width: auto; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(26,21,23,.92); backdrop-filter: blur(10px); border-bottom: 1px solid #3a2c30; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { text-decoration: none; padding: 6px 12px; border-radius: 8px; color: var(--muted); }
nav a.on { background: var(--panel2); color: var(--text); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger);
  color: #fff; font-size: 12px; text-align: center; }

main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.searchbar { display: flex; gap: 8px; }
.searchbar input { flex: 1; font-size: 17px; padding: 12px 14px; }
.filters { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 12px 0; }
.seg { display: inline-flex; background: var(--panel2); border-radius: 8px; padding: 2px; }
.seg button { background: transparent; color: var(--muted); padding: 5px 12px; font-weight: 500; }
.seg button.on { background: var(--panel); color: var(--text); }
.status { color: var(--muted); margin: 8px 0; min-height: 1.4em; }
.section-h { margin: 28px 0 8px; font-size: 16px; color: var(--muted); font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.card { display: flex; gap: 12px; background: var(--panel); border-radius: var(--radius); padding: 10px; min-width: 0; }
.card.watched { opacity: .55; }
.poster { flex: 0 0 92px; }
.poster img { width: 92px; aspect-ratio: 2/3; object-fit: cover; border-radius: 8px; background: var(--panel2); display: block; }
.info { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.title { font-weight: 650; font-size: 16px; }
.title a { text-decoration: none; }
.title a:hover { text-decoration: underline; }
.meta { color: var(--muted); font-size: 13px; }
.offers { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 6px; font-size: 13px;
  font-weight: 650; text-decoration: none; white-space: nowrap; }
.chip small { font-weight: 500; opacity: .85; }
.none { font-size: 13px; color: var(--muted); }
.sam-detail { font-size: 12.5px; color: var(--muted); }
.other { font-size: 12.5px; color: var(--muted); }
.other a { color: var(--muted); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.actions button { padding: 5px 10px; font-size: 13px; }
.tag-new { color: var(--ok); font-size: 12px; font-weight: 700; }

.list-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.list-tabs button { background: var(--panel2); color: var(--muted); font-weight: 500; }
.list-tabs button.on { background: var(--accent); color: #2a1208; font-weight: 650; }

.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.events li { background: var(--panel); border-radius: var(--radius); padding: 10px 14px; display: flex; gap: 12px; align-items: baseline; }
.events li.unseen { border-left: 3px solid var(--accent); }
.events time { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

.settings { max-width: 640px; display: flex; flex-direction: column; gap: 10px; }
.settings label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.settings h3 { margin: 18px 0 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

dialog { background: var(--panel); color: var(--text); border: 1px solid #4a3a3f; border-radius: 14px; width: min(420px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
.add-lists { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.add-lists label { display: flex; gap: 8px; align-items: center; }
.newlist { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; margin-bottom: 12px; }

@media (max-width: 420px) {
  .grid { grid-template-columns: 1fr; }
  .poster, .poster img { flex-basis: 76px; width: 76px; }
}
select.ghost-select { font: inherit; font-size: 13px; background: var(--panel2); color: var(--text); border: 0; border-radius: 8px; padding: 5px 8px; }
[hidden] { display: none !important; }

.nf-strip { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.nf-strip .nf-link { background: var(--panel); padding: 3px 9px; border-radius: 6px; }
.nf-note { font-size: 13px; }
.nf-groups { columns: 300px; column-gap: 12px; }
.nf-group { break-inside: avoid; background: var(--panel); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; }
.nf-group h3 { margin: 0 0 6px; font-size: 15px; }
.nf-link { display: block; text-decoration: none; padding: 3px 0; font-size: 14px; }
.nf-strip .nf-link { display: inline-block; }
.nf-link:hover { color: var(--accent); }
.nf-link.top { font-weight: 650; }
.nf-code { display: inline-block; min-width: 52px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }

.rail { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 8px; min-height: 60px; }
.rail-tile { flex: 0 0 132px; scroll-snap-align: start; display: flex; flex-direction: column; gap: 5px; }
.rail-poster { position: relative; display: block; width: 132px; aspect-ratio: 2/3; border-radius: 10px; overflow: hidden;
  background: var(--panel2); text-decoration: none; font-size: 13px; }
.rail-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rail-title { font-size: 13px; font-weight: 600; line-height: 1.25; }
.rail-tile .chip { font-size: 11px; padding: 2px 6px; }
.rail-empty { margin: 4px 0; font-size: 13px; }
.rank { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.75); border-radius: 6px; padding: 0 7px; font-weight: 700; font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.tile { display: flex; align-items: flex-end; height: 96px; padding: 12px 14px; border-radius: var(--radius);
  text-decoration: none; font-weight: 700; font-size: 18px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.4); }
.tile:hover { filter: brightness(1.12); }
.genre-head { display: flex; align-items: baseline; gap: 14px; }
.genre-head h2 { margin: 0; }
.back { color: var(--muted); text-decoration: none; }
.genre-note { font-size: 13px; margin: 6px 0 0; }
#genre-items .card { position: relative; }
#genre-items .card::before { content: attr(data-rank); position: absolute; left: 4px; top: 4px; z-index: 1;
  background: rgba(0,0,0,.75); border-radius: 6px; padding: 0 7px; font-weight: 700; font-size: 13px; }

body { background: radial-gradient(1200px 600px at 10% -10%, #3a2030 0%, transparent 60%),
  radial-gradient(900px 500px at 110% 10%, #12383a 0%, transparent 55%), var(--bg); background-attachment: fixed; }
.brand { color: var(--accent); }
nav a.on { background: var(--accent); color: #2a1208; }
.h-genre { color: var(--accent3); }
.h-tv { color: var(--accent2); }
.h-film { color: var(--accent4); }
.card { border: 1px solid #3d2f33; }
.other { color: var(--accent3); }
.other a { color: var(--accent3); }
.seg button.on { background: var(--accent2); color: #08201b; }
.list-tabs button.on { background: var(--accent4); color: #1d0b24; }
.events li.unseen { border-left-color: var(--accent3); }

.login { min-height: 100vh; display: grid; place-items: center; }
.login-box { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; background: var(--panel);
  border: 1px solid #3d2f33; border-radius: 16px; padding: 24px; }
.login-box label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
