/* Binge Log. Design notes: DESIGN.md */
:root, [data-theme=dark] {
  --bg: #131313; --surface: #1b1b1b; --raise: #242424; --fg: #ececec; --muted: #a8a8a8;
  --line: #2b2b2b; --line2: #3b3b3b; --ctl: #6b6b6b; --accent: #f2a33a; --on-accent: #1d1204; --mark: #41c86f;
  --bad: #ff8f80; --good: #7ad69a; --dim: rgba(0, 0, 0, .62);
  color-scheme: dark;
}
[data-theme=light] {
  --bg: #faf9f7; --surface: #fff; --raise: #f0eee9; --fg: #1a1a1a; --muted: #595959;
  --line: #e5e2dc; --line2: #d4d0c8; --ctl: #8a857d; --accent: #9c5700; --on-accent: #fff; --mark: #17803b;
  --bad: #b3261e; --good: #17803b; --dim: rgba(25, 22, 18, .45);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 12px; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--accent); color: var(--on-accent); padding: 10px 14px; border-radius: 6px; z-index: 50; text-decoration: none; font-weight: 600; }
.skip:focus { top: 8px; }
.wrap { max-width: 920px; margin: 0 auto; padding: 18px 16px 0; }

/* header */
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { font-size: 23px; font-weight: 750; letter-spacing: -.015em; color: var(--fg); text-decoration: none; margin-right: auto; padding: 4px 0; }
.tools { display: flex; align-items: center; gap: 8px; }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 11px; width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.search input { width: 270px; height: 44px; padding: 0 34px 0 36px; border: 1px solid var(--ctl); background: var(--surface); border-radius: 8px; }
.search input::placeholder { color: var(--muted); opacity: 1; }
.search kbd { position: absolute; right: 9px; font: 12px/1 inherit; color: var(--muted); border: 1px solid var(--line2); border-radius: 4px; padding: 3px 6px; pointer-events: none; }
.search input:focus + kbd, .search input:not(:placeholder-shown) + kbd { display: none; }
@media (hover: none) { .search kbd { display: none; } }
.viewsw { display: flex; border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; background: var(--surface); }
.viewsw button { display: flex; align-items: center; gap: 6px; height: 42px; padding: 0 12px; border: 0; background: none; color: var(--muted); cursor: pointer; font-weight: 600; font-size: 14px; }
.viewsw button + button { border-left: 1px solid var(--line2); }
.viewsw button[aria-pressed=true] { color: var(--fg); background: var(--raise); }
.viewsw button:hover { color: var(--fg); }
.viewsw svg, .iconbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line2); background: var(--surface); border-radius: 8px; cursor: pointer; }
.iconbtn:hover { background: var(--raise); }
.iconbtn .fill { fill: currentColor; stroke: none; }
.lede { color: var(--muted); margin: 8px 0 18px; max-width: 64ch; }

/* watching now */
.now { margin: 0 0 18px; padding: 14px 0 6px; border-top: 1px solid var(--line); }
.now h2 { font-size: 15px; margin: 0 0 10px; }
.now-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 14px; overflow-x: auto; }
.now-list a { display: grid; grid-template-columns: 48px auto; gap: 12px; align-items: center; color: inherit; text-decoration: none; padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: 8px; min-width: 220px; }
.now-list a:hover { background: var(--raise); }
.now-list small { display: block; color: var(--muted); }

/* tabs and toolbar */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 10px 11px; font-weight: 650; color: var(--muted); cursor: pointer; white-space: nowrap; min-height: 46px; }
.tabs button:hover { color: var(--fg); }
.tabs button[aria-selected=true] { color: var(--fg); border-bottom-color: var(--accent); }
.tabs .n { font-weight: 500; margin-left: 5px; font-variant-numeric: tabular-nums; }
.tabs.searching button { opacity: .55; }
.bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 0 4px; }
.bar-gap { flex: 1; }
.sel { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.sel select { height: 40px; border: 1px solid var(--ctl); background: var(--surface); border-radius: 6px; padding: 0 30px 0 10px; color: var(--fg); max-width: 210px; cursor: pointer; }
.btn { min-height: 40px; padding: 0 14px; border: 1px solid var(--line2); background: var(--surface); border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--fg); }
.btn:hover { background: var(--raise); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-main { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-main:hover { background: var(--accent); filter: brightness(1.08); }
.linklike { background: none; border: 0; padding: 10px 0; color: var(--accent); text-decoration: underline; cursor: pointer; }

/* panel states */
#panel { outline: none; min-height: 50vh; }
.state { color: var(--muted); padding: 28px 0; margin: 0; }
.state .btn { margin-top: 10px; }
.results-h { font-size: 15px; font-weight: 600; margin: 16px 0 4px; color: var(--muted); }
.results-h b { color: var(--fg); }

/* year and group sections */
.sec { border-bottom: 1px solid var(--line); }
.sec > summary { display: flex; align-items: baseline; gap: 10px; padding: 14px 0 12px; cursor: pointer; list-style: none; min-height: 48px; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary h2 { margin: 0; font-size: 21px; font-weight: 750; color: var(--accent); font-variant-numeric: tabular-nums; }
.sec > summary h2.small { font-size: 17px; }
.sec > summary .c { color: var(--muted); }
.sec > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); align-self: center; margin-right: 6px; }
.sec[open] > summary::after { transform: rotate(-135deg); }
.sec > summary:hover::after { border-color: var(--fg); }
.key { color: var(--muted); font-size: 13.5px; margin: -4px 0 8px; }

/* rows */
.list { list-style: none; margin: 0 0 10px; padding: 0; }
.row { display: grid; grid-template-columns: 48px 46px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 9px 8px; margin: 0 -8px; border-radius: 6px; color: inherit; text-decoration: none; border-top: 1px solid var(--line); }
.list li:first-child .row { border-top-color: transparent; }
.row.nodate { grid-template-columns: 48px minmax(0, 1fr) auto; }
.row:hover { background: var(--raise); border-top-color: transparent; }
.row:hover + .row, .list li:hover + li .row { border-top-color: transparent; }
.thumb { width: 48px; height: 72px; border-radius: 6px; object-fit: cover; background: var(--raise); display: block; }
.ph { display: grid; place-items: center; color: var(--muted); font-weight: 700; font-size: 18px; background: var(--raise); }
.stub { text-align: center; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stub b { display: block; font-size: 19px; }
.stub span { font-size: 13px; color: var(--muted); }
.t { font-weight: 650; display: block; }
.sub { display: block; color: var(--muted); font-size: 13.5px; }
.sub .note { color: var(--fg); }
.mark { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--mark); margin-right: 8px; vertical-align: 2px; }
.when { color: var(--muted); font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.when small { display: block; font-size: 13px; }
.when .live { color: var(--accent); font-weight: 600; }
mark { background: none; color: var(--accent); font-weight: 700; }

/* poster grid */
.grid { list-style: none; margin: 0; padding: 6px 0 18px; display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 20px 14px; }
.card { display: block; color: inherit; text-decoration: none; border-radius: 8px; }
.card .poster { width: 100%; height: auto; aspect-ratio: 2 / 3; border-radius: 8px; object-fit: cover; background: var(--raise); display: block; }
.card .ph { font-size: 34px; }
.card .ct { display: block; font-weight: 650; font-size: 14px; margin-top: 8px; line-height: 1.3; }
.card .cw { display: block; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.card:hover .ct { color: var(--accent); }

/* images fade in once loaded */
img.thumb, img.poster, img.d-poster { opacity: 0; }
img.ok { opacity: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: -1px; }

/* detail dialog */
dialog { border: 1px solid var(--line2); background: var(--surface); color: var(--fg); border-radius: 10px; padding: 0; width: calc(100% - 32px); max-width: 760px; max-height: calc(100% - 32px); }
dialog::backdrop { background: var(--dim); }
.detail { display: none; }
.detail[open] { display: flex; flex-direction: column; }
.d-body { overflow: auto; padding: 20px; display: grid; grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "poster titles" "poster info"; gap: 0 22px; }
.d-head { display: contents; }
.d-poster, .d-body .ph { grid-area: poster; width: 220px; height: 330px; border-radius: 8px; object-fit: cover; background: var(--raise); }
.d-body .ph { font-size: 64px; }
.d-titles { grid-area: titles; }
.d-info { grid-area: info; }
.d-body h2 { font-size: 23px; line-height: 1.25; margin: 2px 0 4px; }
.d-body h2:focus { outline: none; }
.d-kind { color: var(--muted); margin: 0 0 14px; }
.d-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0 0 14px; }
.d-facts dt { color: var(--muted); }
.d-facts dd { margin: 0; }
.d-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.d-links a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border: 1px solid var(--line2); border-radius: 6px; text-decoration: none; font-weight: 600; font-size: 14px; }
.d-links a:hover { background: var(--raise); }
.d-src { color: var(--muted); font-size: 13px; margin: 0; }
.d-src a { color: inherit; }
.d-foot { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--line); }

/* pick one */
.pick { max-width: 380px; padding: 20px; text-align: center; }
.pick h2 { font-size: 18px; margin: 0 0 14px; }
.p-stage { width: 200px; height: 300px; margin: 0 auto; border-radius: 8px; background: var(--raise); overflow: hidden; display: grid; place-items: center; }
.p-poster { width: 200px; height: 300px; object-fit: cover; display: block; }
.p-ph { font-size: 64px; font-weight: 700; color: var(--muted); }
.p-title { font-size: 19px; font-weight: 700; margin: 14px 0 2px; min-height: 1.5em; }
.p-meta { color: var(--muted); margin: 0 0 16px; min-height: 1.5em; }
.p-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.shuffling .p-title, .shuffling .p-meta { color: var(--muted); }

/* feedback dialog (same pattern as Marvel Timelines and Exam Stash) */
.fb { max-width: 560px; }
.fb-form, .fb-done { padding: 18px 20px 20px; }
.fb-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fb h2 { font-size: 19px; margin: 0; }
.fb-intro { color: var(--muted); margin: 8px 0 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; min-width: 0; }
.field label, .fb-rate legend { font-weight: 600; font-size: 14px; }
.field input, .field select, .field textarea { border: 1px solid var(--ctl); background: var(--bg); border-radius: 6px; padding: 10px 12px; min-height: 44px; width: 100%; }
.field textarea { resize: vertical; }
.field [aria-invalid=true] { border-color: var(--bad); }
.opt { color: var(--muted); font-weight: 400; }
.err { color: var(--bad); font-size: 13.5px; margin: 0; }
.help { color: var(--muted); font-size: 13.5px; margin: 0; }
.fb-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fb-rate { border: 0; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.fb-rate legend { padding: 0; margin-bottom: 6px; width: 100%; }
.stars { display: flex; }
.stars button { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; cursor: pointer; color: var(--line2); }
.stars svg { width: 28px; height: 28px; fill: currentColor; }
.stars button.on { color: var(--accent); }
.star-word { color: var(--muted); font-size: 14px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.fb-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.fb-actions .btn-main { min-height: 44px; padding: 0 22px; }
.form-status { margin: 0; color: var(--muted); }
.form-status.bad { color: var(--bad); }
.form-status.good { color: var(--good); }
.fb-done p { color: var(--muted); }

/* footer and cookie bar */
.foot { margin-top: 40px; padding: 22px 0 36px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.foot p { margin: 10px 0; max-width: 75ch; }
.foot a { color: var(--fg); }
.foot-fb { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 18px; }
.foot-fb b { display: block; color: var(--fg); font-size: 15px; }
.cookie { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--line2); padding: 14px max(16px, calc((100% - 920px) / 2)); display: flex; align-items: center; gap: 16px; }
.cookie p { margin: 0; font-size: 14px; color: var(--muted); flex: 1; }
.cookie p b { color: var(--fg); }
.cookie-btns { display: flex; gap: 8px; flex-shrink: 0; }
.cookie-btns .btn { min-height: 44px; }

/* simple pages (privacy, 404) */
.page h1 { font-size: 28px; margin: 18px 0 8px; letter-spacing: -.01em; }
.page h2 { font-size: 18px; margin: 26px 0 6px; }
.page p, .page li { max-width: 68ch; }
.page .back { display: inline-flex; align-items: center; min-height: 44px; }

@media (max-width: 720px) {
  .tools { width: 100%; }
  .search { flex: 1; }
  .search input { width: 100%; }
  .viewsw span { display: none; }
  .viewsw button { padding: 0 11px; }
  .d-body { grid-template-columns: 110px minmax(0, 1fr); grid-template-rows: auto auto; grid-template-areas: "poster titles" "info info"; gap: 14px; }
}
@media (max-width: 560px) {
  .top { gap: 10px; }
  .row { grid-template-columns: 44px 40px minmax(0, 1fr); grid-template-rows: auto auto; gap: 2px 12px; }
  .row.nodate { grid-template-columns: 44px minmax(0, 1fr); }
  .row > .thumb, .row > .stub { grid-row: 1 / span 2; }
  .thumb { width: 44px; height: 66px; }
  .when { grid-column: 3; grid-row: 2; text-align: left; white-space: normal; align-self: start; }
  .row.nodate .when { grid-column: 2; }
  .when small { display: inline; margin-left: 6px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 10px; }
  .card .ct { font-size: 13px; }
  .bar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .sel span { display: none; }
  .sel select { width: 100%; max-width: none; }
  .bar [data-pickbtn] { grid-column: 1 / -1; }
  .bar-gap { display: none; }
  .search kbd { display: none; }
  .d-poster, .d-body .ph { width: 110px; height: 165px; font-size: 40px; }
  .d-body { padding: 16px; gap: 14px; }
  .d-body h2 { font-size: 19px; }
  .d-foot { padding: 10px 16px; }
  .d-foot .btn { flex: 1; white-space: nowrap; padding: 0 8px; }
  .d-foot .bar-gap { display: none; }
  .fb-row { grid-template-columns: 1fr; }
  .foot-fb { flex-direction: column; align-items: flex-start; }
  .cookie { flex-direction: column; align-items: stretch; }
  .cookie-btns .btn { flex: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  img.thumb, img.poster, img.d-poster { transition: opacity .35s ease; }
  .row, .btn, .viewsw button, .iconbtn { transition: background-color .15s ease; }
  .card .poster { transition: transform .2s ease, opacity .35s ease; }
  .card:hover .poster { transform: translateY(-3px); }
  dialog[open] { animation: rise .2s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}
@media print { .tools, .tabs, .bar, .foot-fb, .cookie, .skip { display: none !important; } body { background: #fff; color: #000; } }
