:root {
  --bg: #f4f4f7;
  --card: #ffffff;
  --text: #15161a;
  --muted: #6b6f7b;
  --line: #e3e4ea;
  --chip: #e9eaf0;
  --accent: #5b5bd6;
  --accent-text: #ffffff;
  --ok: #1f8a4c;
  --ok-bg: #e2f5e9;
  --warn: #9a6200;
  --warn-bg: #fff1d6;
  --bad: #c62828;
  --bad-bg: #fde4e4;
  --shadow: 0 1px 2px rgba(0,0,0,.06);
  --tabh: 58px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #1a1d23;
    --text: #eceef3;
    --muted: #9399a6;
    --line: #2a2e36;
    --chip: #262a32;
    --accent: #8b8bff;
    --accent-text: #0f1115;
    --ok: #5fd08f;
    --ok-bg: #173323;
    --warn: #f3b74d;
    --warn-bg: #3a2c10;
    --bad: #ff7a7a;
    --bad-bg: #3d1717;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  padding-bottom: calc(var(--tabh) + env(safe-area-inset-bottom));
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; } /* stops iOS zoom */
h1 { font-size: 28px; margin: 0; letter-spacing: -.02em; }

.view { display: none; min-height: 100vh; }
.view.active { display: block; }

.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 8px;
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.top select { border: 0; background: var(--chip); border-radius: 10px; padding: 6px 10px; }

input[type=search], input[type=text], input[type=number], input[type=password], textarea, .field select {
  width: 100%; border: 1px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 10px 12px; outline: none; -webkit-appearance: none; appearance: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 70px; resize: vertical; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 0; background: var(--chip); border-radius: 999px; padding: 7px 12px;
  font-size: 14px; white-space: nowrap; font-weight: 500;
}
.chips.small .chip { padding: 5px 10px; font-size: 13px; }
.chip.on { background: var(--accent); color: var(--accent-text); }
.chip .n { opacity: .65; margin-left: 4px; font-variant-numeric: tabular-nums; }
.chip.flag { background: var(--warn-bg); color: var(--warn); }
.chip.flag.on { background: var(--warn); color: var(--card); }

.list { padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 8px; }
.card {
  display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 14px;
  padding: 10px; box-shadow: var(--shadow); min-height: 84px; cursor: pointer;
}
.cover {
  width: 48px; height: 68px; border-radius: 8px; object-fit: cover; flex: none; background: var(--chip);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); font-size: 20px;
}
.info { flex: 1; min-width: 0; }
.title { font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { color: var(--muted); font-size: 13px; margin-top: 3px; }
.sub { color: var(--muted); font-size: 13px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-style: italic; }
.plus {
  flex: none; border: 0; background: var(--chip); color: var(--accent); font-weight: 700;
  border-radius: 12px; min-width: 52px; height: 44px; font-size: 16px;
}
.plus:active { transform: scale(.94); }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 6px; vertical-align: 1px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.block { background: var(--bad-bg); color: var(--bad); }
.badge.unknown { background: var(--chip); color: var(--muted); }
.badge.have { background: var(--chip); color: var(--accent); }

.card.blocked { opacity: .55; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.section-h { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 10px 2px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 11px 14px; background: var(--accent); color: var(--accent-text);
  font-weight: 600; font-size: 15px; text-align: center; cursor: pointer;
}
.btn.ghost { background: var(--chip); color: var(--text); }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 600; }
.shot-row { display: flex; gap: 8px; margin-top: 8px; }
.shot-row .btn { flex: 1; font-size: 13px; padding: 9px 8px; }
.link-note { background: var(--chip); border-radius: 10px; padding: 8px 10px; font-size: 14px; margin-bottom: 8px; }

#banner:empty { display: none; }
.banner { margin: 10px 16px 0; padding: 10px 12px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); font-size: 14px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner .btn { margin-top: 8px; padding: 8px 12px; font-size: 14px; }
.bar { height: 6px; border-radius: 3px; background: var(--chip); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); }

/* bottom tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  height: calc(var(--tabh) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar button { flex: 1; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.tabbar .ti { font-size: 21px; line-height: 1; }
.tabbar .plus-ti { background: var(--accent); color: var(--accent-text); border-radius: 10px; width: 34px; height: 26px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.tabbar button.active { color: var(--accent); }

/* sheet */
#sheet { position: fixed; inset: 0; z-index: 20; }
#sheet .backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); animation: fade .2s; }
#sheet .panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); border-radius: 18px 18px 0 0; padding: 6px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up .22s cubic-bezier(.2,.8,.2,1);
}
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
@keyframes up { from { transform: translateY(40%); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

.d-head { display: flex; gap: 14px; align-items: flex-start; }
.d-head .cover { width: 84px; height: 120px; border-radius: 10px; font-size: 30px; }
.d-head h2 { margin: 0 0 4px; font-size: 20px; line-height: 1.2; }
.d-head .alt { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.field { margin-top: 14px; }
.field > label, .lbl { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 2px 6px; }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 6px; }
.seg button { border: 0; background: var(--chip); border-radius: 10px; padding: 10px 6px; font-size: 14px; font-weight: 600; }
.seg button.on { background: var(--accent); color: var(--accent-text); }
.seg button.on.dropped { background: var(--bad); color: #fff; }
.stepper { display: flex; gap: 8px; align-items: center; }
.stepper button { border: 0; background: var(--chip); border-radius: 12px; width: 52px; height: 44px; font-size: 22px; font-weight: 700; color: var(--accent); flex: none; }
.stepper input { text-align: center; font-weight: 600; }
.stepper .of { color: var(--muted); font-size: 14px; white-space: nowrap; }
.stars { display: flex; gap: 4px; }
.stars button { border: 0; background: none; font-size: 30px; padding: 0 2px; color: var(--line); }
.stars button.on { color: #f5b301; }
.drop-box { background: var(--bad-bg); border-radius: 14px; padding: 12px; margin-top: 14px; }
.drop-box .lbl { color: var(--bad); }
.drop-box .chips { flex-wrap: wrap; overflow: visible; padding-top: 0; margin-bottom: 8px; }
.drop-box .chip { background: var(--card); }
.drop-box .chip.on { background: var(--bad); color: #fff; }
.qchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.qchips .chip { padding: 5px 10px; font-size: 13px; }
.desc { font-size: 14px; color: var(--muted); white-space: pre-wrap; margin-top: 6px; }
details summary { font-size: 14px; font-weight: 600; color: var(--accent); cursor: pointer; }
.verdict { border-radius: 12px; padding: 10px 12px; margin-top: 12px; font-size: 14px; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.warn { background: var(--warn-bg); color: var(--warn); }
.verdict.block { background: var(--bad-bg); color: var(--bad); }
.verdict.unknown { background: var(--chip); color: var(--muted); }
.verdict b { display: block; font-size: 15px; margin-bottom: 2px; }
.verdict ul { margin: 4px 0 0; padding-left: 18px; }
.add-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.row-btns { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.row-btns .btn { flex: 1; }
.links { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 14px; }
.links a { color: var(--accent); text-decoration: none; font-weight: 600; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabh) + env(safe-area-inset-bottom) + 10px); z-index: 30;
  background: #222; color: #fff; border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: up .2s;
}
#toast[hidden] { display: none; }
#toast button { border: 0; background: none; color: #a9a9ff; font-weight: 700; font-size: 14px; }

.pad { padding: 12px 16px 30px; }
.group { background: var(--card); border-radius: 14px; padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow); }
.group h3 { margin: 0 0 6px; font-size: 16px; }
.group p { margin: 4px 0 10px; color: var(--muted); font-size: 14px; }
.group .btn { margin: 4px 4px 0 0; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle input { width: 46px; height: 28px; accent-color: var(--accent); flex: none; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stats div { background: var(--chip); border-radius: 10px; padding: 8px 4px; font-size: 12px; color: var(--muted); }
.stats b { display: block; font-size: 20px; color: var(--text); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* cover placeholder */
.cover.ph { padding: 4px; text-align: center; color: #fff; font-size: 9px; font-weight: 700; line-height: 1.15; overflow: hidden; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.cover.ph span { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.d-head .cover.ph { font-size: 12px; }
.icon-btn { border: 0; background: var(--chip); border-radius: 10px; width: 38px; height: 34px; font-size: 18px; }

/* gallery grid */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 10px; padding: 12px 16px 24px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(5, 1fr); } }
.tile { cursor: pointer; min-width: 0; }
.tile-cover { position: relative; }
.tile .cover { width: 100%; height: auto; aspect-ratio: 2 / 3; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.tile .cover.ph { font-size: 13px; padding: 8px; }
.tile-title { font-size: 13px; font-weight: 600; margin-top: 6px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-meta { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-plus { position: absolute; right: 6px; bottom: 6px; border: 0; border-radius: 10px; padding: 6px 9px; font-weight: 800; font-size: 14px;
  background: rgba(255,255,255,.92); color: #4a4ac4; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.tile-plus:active { transform: scale(.92); }
.tile-flag { position: absolute; left: 5px; top: 5px; }
.tile.blocked { opacity: .5; }

/* movie-every-year challenge */
#view-years h1 { font-size: 22px; }
.yr-hero { display: flex; gap: 14px; align-items: center; background: var(--card); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.yr-big { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.yr-big span { font-size: 18px; color: var(--muted); font-weight: 600; }
.yr-dec { color: #fff; font-weight: 800; text-align: center; border-radius: 999px; padding: 6px 12px; margin: 18px auto 8px; width: max-content; font-size: 15px; letter-spacing: .02em; }
.yr-row { display: flex; gap: 10px; align-items: center; background: var(--card); border-radius: 12px; padding: 8px 10px; margin-bottom: 6px; box-shadow: var(--shadow); cursor: pointer; }
.yr-num { font-weight: 800; font-size: 17px; width: 50px; flex: none; }
.yr-check { display: block; font-size: 13px; color: var(--ok); }
.yr-picks { display: flex; gap: 8px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
.yr-picks::-webkit-scrollbar { display: none; }
.yr-pick { flex: none; position: relative; display: flex; align-items: center; gap: 8px; max-width: 210px; }
.yr-picks:has(.yr-pick + .yr-pick) .yr-pick { max-width: 150px; }
.yr-pick .cover { width: 38px; height: 56px; border-radius: 6px; flex: none; font-size: 6px; }
.yr-pick:not(.seen) .cover { filter: grayscale(.9); opacity: .55; }
.yr-pick:not(.seen) .yr-t { color: var(--muted); }
.yr-pick.seen::after { content: '✓'; position: absolute; top: -4px; left: 26px; background: var(--ok); color: #fff; border-radius: 50%; width: 18px; height: 18px; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.yr-t { font-size: 13px; line-height: 1.2; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.yr-empty { color: var(--accent); font-weight: 600; font-size: 14px; padding: 8px 0; }
.plus.seen-on { background: var(--ok-bg); color: var(--ok); }
.sync-dot { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--chip); border-radius: 999px; padding: 3px 8px; margin-left: 6px; white-space: nowrap; }
.sync-dot.ok { color: var(--ok); }
.sync-dot.error, .sync-dot.auth { color: var(--bad); }
