:root {
  --bg: #0b0b10; --surface: #14141c; --surface-2: #1c1c27; --line: #26262f;
  --fg: #f4f4f7; --muted: #8e8e9f; --accent: #f5b942; --accent-fg: #14110a;
  --good: #5ad19a; --danger: #ff6b7a;
  --radius: 14px; --poster-ratio: 2 / 3;
  --display: 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
:root[data-theme="light"] { --bg: #f7f6f3; --surface: #fff; --surface-2: #f0eee9; --line: #e4e1da; --fg: #17171c; --muted: #6b6b78; --accent: #c98a0b; --accent-fg: #fff; }
@media (prefers-color-scheme: light) { :root[data-theme="auto"] { --bg: #f7f6f3; --surface: #fff; --surface-2: #f0eee9; --line: #e4e1da; --fg: #17171c; --muted: #6b6b78; --accent: #c98a0b; --accent-fg: #fff; } }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; background: radial-gradient(1200px 500px at 50% -200px, color-mix(in srgb, var(--accent) 14%, transparent), transparent), var(--bg);
  color: var(--fg); font: 15px/1.5 var(--body); padding-bottom: 84px; min-height: 100vh; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; letter-spacing: .01em; }
h2 { font-size: clamp(26px, 5vw, 36px); line-height: 1.15; }
.muted { color: var(--muted); font-size: 13px; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 12px; }

/* ---- shell ---- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; padding: 12px 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.logo { font-family: var(--display); font-size: 22px; display: flex; align-items: center; gap: 8px; }
.logo svg { color: var(--accent); }
nav { display: flex; gap: 4px; }
nav button { display: flex; align-items: center; gap: 8px; background: none; border: 0; color: var(--muted); padding: 8px 14px; border-radius: 999px; font: 500 14px var(--body); cursor: pointer; }
nav button:hover { color: var(--fg); }
nav button.active { color: var(--accent-fg); background: var(--accent); }
nav svg { width: 18px; height: 18px; flex: none; }
main { max-width: 1040px; margin: 0 auto; padding: 24px 20px 16px; }
@media (max-width: 720px) {
  .topbar { padding: 12px 16px; backdrop-filter: none; background: var(--bg); } /* a blurred ancestor would trap the fixed tab bar */
  nav { position: fixed; inset: auto 0 0 0; z-index: 30; justify-content: space-around; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
  nav button { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 10px; border-radius: 12px; }
  nav button.active { background: none; color: var(--accent); }
  main { padding: 18px 16px 8px; }
}

/* ---- controls ---- */
button { font: inherit; cursor: pointer; color: var(--fg); }
.btn, button.primary, button.secondary { border-radius: 999px; padding: 10px 18px; font-weight: 600; border: 1px solid var(--line); background: var(--surface-2); }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
button.primary:hover { filter: brightness(1.08); }
button.secondary:hover { border-color: var(--accent); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.ghost { background: none; border: 0; color: var(--muted); padding: 8px 10px; }
button.ghost:hover { color: var(--fg); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; }
input[type=text], input[type=password], input:not([type]), input[type=search] { font: inherit; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--fg); max-width: 100%; }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.banner { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); padding: 10px 14px; border-radius: 12px; margin: 14px 0; font-size: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 14px 0; }
.panel > b:first-child { font-family: var(--display); font-weight: 400; font-size: 20px; display: block; margin-bottom: 4px; }
.drop { display: block; margin-top: 10px; padding: 22px; border: 1.5px dashed var(--line); border-radius: 12px; text-align: center; color: var(--muted); cursor: pointer; }
.drop:hover { border-color: var(--accent); color: var(--fg); }
.drop input { display: none; }

/* ---- hero + moods ---- */
.hero { padding: 8px 0 4px; }
.hero p { margin: 6px 0 0; color: var(--muted); max-width: 52ch; }
.moods { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; margin: 14px -16px 0; padding-inline: 16px; scrollbar-width: none; }
.moods::-webkit-scrollbar { display: none; }
.mood { flex: none; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 14px; white-space: nowrap; }
.mood:hover { border-color: var(--accent); }
.mood.active { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 600; }
.toggle { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }

/* ---- posters ---- */
.poster { position: relative; aspect-ratio: var(--poster-ratio); border-radius: 10px; overflow: hidden; background: var(--surface-2); box-shadow: 0 6px 24px rgba(0,0,0,.35); }
.poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.poster .ptitle { position: absolute; inset: auto 0 0 0; padding: 10px; font-family: var(--display); font-size: 15px; line-height: 1.15; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.5); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 22px 16px; margin-top: 10px; }
.tile .poster { transition: transform .18s ease; }
.tile:hover .poster { transform: translateY(-4px); }
.tile h3 { font-size: 17px; margin: 10px 0 0; line-height: 1.2; }
.tile .meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.why { color: var(--accent); font-size: 12.5px; margin-top: 6px; line-height: 1.35; }
.stream { font-size: 12px; color: var(--good); margin-top: 4px; }
.tile .actions { display: flex; gap: 6px; margin-top: 10px; }
.chip-btn { flex: 1; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 4px; font-size: 12.5px; font-weight: 600; }
.chip-btn:hover { border-color: var(--accent); }
.chip-btn.quiet { flex: none; color: var(--muted); padding-inline: 10px; }
.skeleton .poster { animation: pulse 1.2s ease-in-out infinite; box-shadow: none; }
@keyframes pulse { 50% { opacity: .5; } }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .big { font-size: 40px; }

/* ---- rank ---- */
.stats { display: flex; gap: 12px; margin: 18px 0; }
.stat { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-family: var(--display); font-weight: 400; font-size: 32px; line-height: 1; color: var(--accent); }
.duel-wrap { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: start; max-width: 620px; margin: 22px auto; }
.duel-card { background: none; border: 0; padding: 0; text-align: center; border-radius: 12px; transition: transform .15s ease; }
.duel-card:hover, .duel-card:focus-visible { transform: translateY(-6px) scale(1.02); }
.duel-card:hover .poster { outline: 3px solid var(--accent); }
.duel-card .t { display: block; font-family: var(--display); font-size: 18px; margin-top: 10px; line-height: 1.2; }
.duel-card .y { color: var(--muted); font-size: 13px; }
.vs { align-self: center; margin-top: -40px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); font-weight: 700; font-size: 13px; color: var(--muted); }
.center { text-align: center; }
@media (max-width: 480px) { .duel-wrap { gap: 8px; } .vs { width: 34px; height: 34px; font-size: 11px; } .duel-card .t { font-size: 15px; } }

/* ---- my top ---- */
.list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: 44px 52px 1fr auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px 8px 8px; }
.item .n { font-family: var(--display); font-size: 24px; text-align: center; color: var(--muted); }
.item:nth-child(-n+3) .n { color: var(--accent); font-size: 30px; }
.item .poster { border-radius: 6px; box-shadow: none; }
.item .poster .ptitle { font-size: 8px; padding: 4px; }
.item .t { font-weight: 600; line-height: 1.25; }
.item .score { font-family: var(--display); font-size: 22px; color: var(--accent); }
@media (max-width: 480px) { .item { grid-template-columns: 34px 46px 1fr auto; gap: 10px; } }

/* ---- re-rank ---- */
.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 4px 0 8px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s ease; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; cursor: pointer; border-top: 1px solid var(--line); }
.choice:first-of-type { border-top: 0; margin-top: 8px; }
.choice input { margin-top: 4px; accent-color: var(--accent); }

/* ---- next watch ---- */
.filters { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end; margin: 8px 0 10px; }
.filters > div, .filters .select { display: flex; flex-direction: column; gap: 4px; }
select { font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--fg); }
select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { background: none; border: 0; border-radius: 999px; padding: 6px 12px; font-size: 13.5px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.seg button.on { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.shuffle { margin-left: auto; }
.picks { display: grid; gap: 14px; margin-top: 14px; }
.pick { display: grid; grid-template-columns: 150px 1fr; gap: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.pick.first { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent); }
.pick h3 { font-size: 24px; line-height: 1.15; }
.pick .meta { color: var(--muted); font-size: 13px; margin-top: 3px; }
.synopsis { margin: 10px 0 0; color: color-mix(in srgb, var(--fg) 85%, var(--muted)); font-size: 14px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.pick .actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.pick .chip-btn { flex: none; padding: 8px 14px; }
.pick.skeleton { min-height: 220px; } .pick.skeleton .poster { animation: pulse 1.2s ease-in-out infinite; }
@media (max-width: 720px) {
  .pick { grid-template-columns: 112px 1fr; gap: 14px; padding: 12px; }
  .pick h3 { font-size: 19px; } .synopsis { font-size: 13.5px; -webkit-line-clamp: 5; }
  .filters { gap: 10px 14px; } .shuffle { margin-left: auto; }
  nav button { padding: 6px 4px; font-size: 10.5px; min-width: 0; } nav { gap: 0; }
}

/* ---- log / search ---- */
input.wide { width: 100%; font-size: 16px; }
.result { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.result .thumb { width: 44px; flex: none; }
.result .thumb .poster { border-radius: 5px; box-shadow: none; } .result .thumb .ptitle { font-size: 7px; padding: 3px; }
.result .info { flex: 1; min-width: 0; } .result .t { font-weight: 600; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result .chip-btn { flex: none; padding: 8px 14px; }
.sub { font-size: 20px; margin: 22px 0 6px; }
.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.fixbox { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
input[type=date] { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--fg); color-scheme: dark; }
:root[data-theme="light"] input[type=date] { color-scheme: light; }
