/* findMyNextBook — light/dark tokens, then components. No build step. */
:root {
  color-scheme: light dark;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f1eee7;
  --sunken: #ebe7de;
  --line: #e4dfd5;
  --line-2: #d4cdbf;
  --ink: #1c1a16;
  --ink-2: #4f4a42;
  --muted: #8a8377;
  --accent: #1f6b57;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe9;
  --star: #e0a01c;
  --good: #2e7d4f;
  --good-soft: #e3f2e8;
  --bad: #b4473a;
  --warn: #9a6512;
  --warn-soft: #f8eedb;
  --buy: #ffd814;
  --buy-line: #f2c200;
  --buy-ink: #0f1111;
  --shadow: 0 1px 2px rgba(28, 26, 22, .05), 0 6px 18px -8px rgba(28, 26, 22, .14);
  --shadow-lg: 0 30px 80px -24px rgba(28, 26, 22, .40);
  --r: 14px;
  --r-sm: 9px;
  --serif: "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, ui-serif, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12110f;
    --surface: #1b1a17;
    --surface-2: #23211d;
    --sunken: #0e0d0b;
    --line: #2d2a25;
    --line-2: #3c3831;
    --ink: #f2ede3;
    --ink-2: #c4bcae;
    --muted: #8c8478;
    --accent: #6fcfae;
    --accent-ink: #0a1f18;
    --accent-soft: #17302a;
    --star: #f2b544;
    --good: #7cc791;
    --good-soft: #193022;
    --bad: #ea8b7d;
    --warn: #e5b764;
    --warn-soft: #2e2615;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px -10px rgba(0, 0, 0, .6);
    --shadow-lg: 0 30px 90px -20px rgba(0, 0, 0, .85);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 14.5px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; white-space: nowrap;
  font-weight: 500; transition: background .12s, border-color .12s, transform .06s; text-decoration: none !important; color: var(--ink); }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.buy { background: var(--buy); border-color: var(--buy-line); color: var(--buy-ink); font-weight: 600; }
.btn.buy:hover { filter: brightness(1.04); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 13px; }
.btn.lg { height: 46px; padding: 0 22px; font-size: 15.5px; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn.danger:hover { color: var(--bad); border-color: var(--bad); }
.icon-btn { width: 36px; height: 36px; border-radius: 999px; border: 1px solid transparent; background: transparent;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg, .btn svg { width: 18px; height: 18px; }
input[type=text], input[type=search], input:not([type]), input[type=number], input[type=date], select, textarea {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 8px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { width: 100%; min-height: 90px; resize: vertical; }
label.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
label.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 28px; height: 60px; padding: 0 24px;
  background: color-mix(in oklab, var(--bg) 85%, transparent); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font: 600 18px/1 var(--serif); color: var(--ink); text-decoration: none !important; }
.brand svg { width: 24px; height: 24px; color: var(--accent); }
.tabs { display: flex; gap: 2px; height: 100%; }
.tabs button { position: relative; border: 0; background: none; padding: 0 12px; color: var(--muted); cursor: pointer; font-weight: 500; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); }
.tabs button.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.topbar-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.bg-pill { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-right: 6px; }

main { max-width: 1240px; margin: 0 auto; padding: 0 24px 80px; }
.view { padding-top: 28px; }

/* ---------- banner ---------- */
.banner { display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 16px; border-radius: var(--r);
  background: var(--warn-soft); border: 1px solid color-mix(in oklab, var(--warn) 30%, transparent); margin-bottom: 22px; }
.banner .txt { flex: 1; color: var(--ink-2); }
.banner b { color: var(--ink); }

/* ---------- discover ---------- */
.hero { text-align: center; padding: 34px 0 10px; max-width: 760px; margin: 0 auto; }
.hero h1 { font-size: clamp(30px, 4.6vw, 44px); line-height: 1.1; }
.hero .sub { color: var(--muted); margin: 10px 0 26px; }
.ask { display: flex; gap: 8px; padding: 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow); }
.ask:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.ask input { flex: 1; border: 0 !important; box-shadow: none !important; background: transparent; padding: 0 14px; font-size: 15.5px; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hero .chips { justify-content: center; margin-top: 14px; }
.chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; cursor: pointer;
  color: var(--ink-2); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: var(--muted); color: var(--ink); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.active .n { color: color-mix(in oklab, var(--bg) 70%, transparent); }

.options { margin: 18px auto 0; max-width: 760px; text-align: left; }
.options > summary { list-style: none; cursor: pointer; color: var(--muted); font-size: 13px; text-align: center; user-select: none; }
.options > summary::-webkit-details-marker { display: none; }
.options > summary::after { content: " ▾"; }
.options[open] > summary::after { content: " ▴"; }
.options-body { margin-top: 14px; padding: 18px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.opt-label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.opt-hint { font-weight: 400; letter-spacing: 0; text-transform: none; margin-left: 6px; }
.opt-foot { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
/* model picker */
.model-picked { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; min-height: 30px; align-items: center; }
.pick-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 4px 0 12px; border-radius: 999px; font-size: 13px;
  font-weight: 600; background: var(--accent-soft); border: 1px solid var(--accent); color: var(--ink); }
.pick-chip .pc-cost { font-weight: 400; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pick-chip button { width: 22px; height: 22px; border-radius: 50%; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 15px; line-height: 1; }
.pick-chip button:hover { background: var(--surface); color: var(--ink); }
.mb-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.mb-bar input[type=search] { flex: 1 1 200px; min-width: 0; }
/* .seg.wide: the text version of the Library's icon toggle (.seg, further down) */
.seg.wide { padding: 3px; background: var(--surface-2); border-color: var(--line); }
.seg.wide button { width: auto; height: 28px; padding: 0 12px; color: var(--ink-2); font-size: 13px; font-weight: 500; white-space: nowrap; }
.seg.wide button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.model-list { max-height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); padding: 4px; }
.model-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.model-row:hover { background: var(--surface-2); }
.model-row:has(input:checked) { background: var(--accent-soft); }
.model-row.off { opacity: .45; cursor: not-allowed; }
.model-row input { accent-color: var(--accent); margin: 0; }
.mr-main { min-width: 0; }
.mr-main .nm { font-weight: 600; margin-right: 6px; }
.mr-main .slug { display: block; font: 11.5px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mtag { display: inline-block; font-size: 10.5px; font-weight: 600; letter-spacing: .02em; padding: 1px 6px; margin-right: 4px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--ink-2); vertical-align: 1px; }
.mtag.open { border-color: color-mix(in oklab, var(--accent) 50%, transparent); color: var(--accent); }
.mtag.free { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.mr-cost { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mr-cost b { display: block; font-weight: 600; }
.mr-cost span { font-size: 11px; color: var(--muted); }
.mr-more { margin: 8px 10px; }
label.check-inline input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
@media (max-width: 560px) {
  .mr-cost span { display: none; }
  .seg.wide { width: 100%; }
  .seg.wide button { flex: 1; padding: 0 6px; }
}
.opt-row { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: center; margin-top: 16px; }
.opt-row label { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; }
.opt-row input[type=number] { width: 68px; }
.opt-row .grow { flex: 1; }
#rec-model { width: 100%; }

/* progress */
.progress { max-width: 760px; margin: 28px auto 0; padding: 18px 20px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.prog-row + .prog-row { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.prog-model { font-weight: 600; margin-bottom: 10px; display: flex; justify-content: space-between; gap: 10px; }
.prog-model .t { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.stages { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; list-style: none; margin: 0; padding: 0; }
.stages li { position: relative; padding-top: 12px; font-size: 12.5px; color: var(--muted); }
.stages li::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; border-radius: 4px; background: var(--sunken); }
.stages li.done { color: var(--ink-2); }
.stages li.done::before { background: var(--accent); }
.stages li.active { color: var(--ink); font-weight: 600; }
.stages li.active::before { background: linear-gradient(90deg, var(--accent) 0 40%, var(--sunken) 40%); background-size: 250% 100%; animation: bar 1.4s linear infinite; }
@keyframes bar { from { background-position: 100% 0; } to { background-position: -150% 0; } }
.prog-err { color: var(--bad); font-size: 13px; margin-top: 8px; }

/* results */
.results-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 40px 0 14px; }
.results-head h2 { font-size: 26px; }
.results-head .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.results-head select { max-width: 340px; }
.model-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.taste { margin: 0 0 22px; padding: 16px 20px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 var(--r) var(--r) 0;
  font: italic 16px/1.55 var(--serif); color: var(--ink-2); }
.taste .who { display: block; font: 600 11.5px/1 var(--sans); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-style: normal; margin-bottom: 8px; }
.recs { display: grid; grid-template-columns: repeat(auto-fill, minmax(520px, 1fr)); gap: 16px; }
.rec { display: grid; grid-template-columns: 112px 1fr; gap: 18px; padding: 18px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); transition: opacity .2s; }
.rec .cover { width: 112px; }
.rec-top { display: flex; gap: 10px; align-items: baseline; }
.rank { font: 600 13px/1 var(--sans); color: var(--muted); min-width: 16px; }
.rec h3 { font-size: 20px; line-height: 1.2; }
.byline { color: var(--ink-2); font-size: 13.5px; margin-top: 3px; }
.hook { font: italic 15px/1.45 var(--serif); color: var(--ink); margin: 10px 0 6px; }
.reason { color: var(--ink-2); font-size: 13.5px; margin: 0; }
.blurb { color: var(--muted); font-size: 13px; margin: 8px 0 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.blurb.open { -webkit-line-clamp: unset; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid transparent; white-space: nowrap; }
.tag.store { background: var(--good-soft); color: var(--good); font-weight: 600; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.agree { border-color: color-mix(in oklab, var(--accent) 45%, transparent); color: var(--accent); background: transparent; }
.tag.read { color: var(--good); }
.tag.to-read { color: var(--warn); }
.tag.currently-reading { color: var(--accent); }
.tag.abandoned { color: var(--bad); }
.tag .star { color: var(--star); }
.rec-actions { display: flex; flex-wrap: wrap; gap: 6px 4px; margin-top: 14px; align-items: center; }
.rec-actions .acts { display: inline-flex; flex-wrap: wrap; gap: 2px; }
.rec-actions .acts .btn.ghost { padding: 0 9px; }
.rec.st-dismissed { opacity: .5; }
.rec.st-bought, .rec.st-owned, .rec.st-added { border-color: color-mix(in oklab, var(--accent) 45%, var(--line)); }
.state { font-size: 12.5px; font-weight: 600; color: var(--accent); margin-left: 4px; }
.dropped { color: var(--muted); font-size: 13px; margin-top: 18px; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty h3 { color: var(--ink); font-size: 20px; margin-bottom: 6px; }

/* ---------- covers ---------- */
.cover { display: block; width: 100%; aspect-ratio: 2 / 3; border-radius: 4px 7px 7px 4px; object-fit: cover; background: var(--sunken);
  box-shadow: inset 3px 0 0 rgba(0, 0, 0, .08), 0 1px 1px rgba(0, 0, 0, .08), 0 10px 22px -10px rgba(0, 0, 0, .45); }
.cover.ph { display: flex; flex-direction: column; justify-content: space-between; padding: 12% 10%; overflow: hidden; color: #fffaf0;
  background: linear-gradient(160deg, hsl(var(--h, 30) 32% 38%), hsl(var(--h, 30) 38% 24%)); }
.cover.ph .pt { font: 600 clamp(10px, 1.1em, 15px)/1.18 var(--serif); display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.cover.ph .pa { font-size: .78em; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- library ---------- */
.lib-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.lib-head h1 { font-size: 32px; }
.lib-head .count { font: 400 15px var(--sans); color: var(--muted); margin-left: 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 22px; }
.search { position: relative; flex: 1 1 260px; max-width: 360px; }
.search svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); }
.search input { width: 100%; padding-left: 34px; border-radius: 999px; }
.toolbar .chips { flex: 1 1 auto; }
.toolbar-right { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; padding: 2px; background: var(--surface); }
.seg button { border: 0; background: none; height: 30px; width: 34px; border-radius: 999px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.seg button svg { width: 16px; height: 16px; }
.seg button.active { background: var(--surface-2); color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 26px 20px; }
.book { cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.book .cover { margin-bottom: 6px; transition: transform .18s ease; }
.book:hover .cover { transform: translateY(-4px); }
.book .t { font-weight: 600; font-size: 13.5px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book .a { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stars { color: var(--star); letter-spacing: 1px; font-size: 12px; }
.stars .off { color: var(--line-2); }
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.list .book { flex-direction: row; align-items: center; gap: 14px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.list .book:last-child { border-bottom: 0; }
.list .book:hover { background: var(--surface-2); }
.list .book .cover { width: 30px; margin: 0; font-size: 0; padding: 0; }
.list .book:hover .cover { transform: none; }
.list .t { flex: 2 1 0; -webkit-line-clamp: 1; }
.list .a { flex: 1 1 0; }
.list .meta { flex: 1.3 1 0; display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.grid .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
/* author names link to their page */
.author-link { cursor: pointer; }
.author-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.hbar .n.author-link:hover { color: var(--accent); }
/* bulk changes */
.bulk-bar { position: sticky; top: 60px; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: -8px 0 18px;
  padding: 8px 10px; border-radius: var(--r-sm); background: color-mix(in oklab, var(--surface) 92%, transparent); border: 1px solid var(--line);
  backdrop-filter: blur(8px); font-size: 13px; }
.bulk-bar .spacer { flex: 1; }
.bulk-bar .bk-count { color: var(--ink-2); padding-left: 4px; }
.bulk-bar select { height: 30px; padding: 0 8px; font-size: 13px; }
.bulk-bar select:disabled, .bulk-bar .btn:disabled { opacity: .45; }
#books.selecting .book { position: relative; }
.pick-box { position: absolute; top: 6px; left: 6px; z-index: 2; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: transparent; background: rgb(255 255 255 / .85); border: 1.5px solid var(--line-2); }
.book.sel .pick-box { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.book.sel .cover { outline: 3px solid var(--accent); outline-offset: 2px; }
.list .pick-box { position: static; flex: none; }
.list .book.sel { background: var(--accent-soft); }
.list .book.sel .cover { outline: 0; }
#toast .toast-act { margin-left: 14px; border: 0; background: none; color: inherit; font: inherit; font-weight: 700; text-decoration: underline;
  text-underline-offset: 3px; cursor: pointer; padding: 0; }
/* author page */
.author-head { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 6px 16px; margin: 4px 0 8px; }
.author-head [data-author-back] { grid-column: 1 / -1; justify-self: start; margin-left: -10px; }
.author-head h1 { font-size: 34px; }
.author-head .author-stats { grid-column: 1; color: var(--ink-2); }
.author-head > .btn { grid-column: 2; grid-row: 2 / 4; align-self: center; }
.series-block { margin-top: 24px; padding: 18px 20px 22px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.series-block.solo { background: transparent; border-style: dashed; }
.series-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 18px; }
.sh-text { flex: 1 1 220px; min-width: 0; }
.sh-text h2 { font-size: 20px; }
.sh-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.series-done { color: var(--good); font-weight: 600; }
.sh-bar { width: 140px; height: 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.sh-bar span { display: block; height: 100%; background: var(--accent); }
.series-books { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 22px 16px; }
.series-books .book { position: relative; }
.series-books .book:not(.is-read):not(.missing) .cover { filter: saturate(.35); opacity: .78; }
.snum { position: absolute; top: 6px; left: 6px; z-index: 1; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: color-mix(in oklab, var(--ink) 82%, transparent); color: var(--bg); }
.book.next .snum { background: var(--accent); color: var(--accent-ink); }
.series-books .book.next .cover { outline: 2px solid var(--accent); outline-offset: 3px; filter: none; opacity: 1; }
.book.next .t::before { content: "Up next · "; color: var(--accent); }
.book.missing { text-decoration: none !important; color: var(--ink); }
.cover.gap { display: grid; place-content: center; gap: 4px; text-align: center; background: transparent; box-shadow: none;
  border: 1.5px dashed var(--line-2); color: var(--muted); }
.cover.gap span { font: 600 22px var(--serif); color: var(--ink-2); }
.cover.gap small { font-size: 11px; padding: 0 8px; }
.book.missing:hover .cover.gap { border-color: var(--accent); }
.grid .meta .d { display: none; }
.skel { background: linear-gradient(90deg, var(--sunken), var(--surface-2), var(--sunken)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- insights ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.tile .v { font: 600 30px/1.05 var(--serif); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 14px; align-items: start; }
.panel { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; }
.panel figcaption { font-weight: 600; margin-bottom: 14px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 190px; padding: 22px 0 22px; }
.bars .bar { flex: 1; background: color-mix(in oklab, var(--accent) 75%, var(--surface)); border-radius: 4px 4px 0 0; position: relative; min-width: 8px; }
.bars .bar:hover { background: var(--accent); }
.bars .bar .x { position: absolute; top: 100%; left: -6px; right: -6px; text-align: center; font-size: 10.5px; color: var(--muted); margin-top: 5px; }
.bars .bar .y { position: absolute; bottom: 100%; left: -6px; right: -6px; text-align: center; font-size: 11px; color: var(--ink-2); margin-bottom: 3px; }
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar { display: grid; grid-template-columns: 170px 1fr 74px; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.hbar .track { height: 12px; background: var(--sunken); border-radius: 6px; overflow: hidden; }
.hbar .fill { height: 100%; background: color-mix(in oklab, var(--accent) 75%, var(--surface)); border-radius: 6px; }
.hbar .val { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.charts .panel.wide { grid-column: 1 / -1; }

/* ---------- overlays: sheet (wizard, settings, add), drawer, toast ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(12, 11, 9, .5); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 24px; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: relative; width: min(880px, 100%); max-height: min(860px, calc(100vh - 48px)); display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); animation: rise .2s ease; }
.sheet.narrow { width: min(620px, 100%); }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px 14px 26px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 20px; flex: 1; }
.sheet-body { padding: 26px; overflow-y: auto; flex: 1; }
.sheet-foot { display: flex; align-items: center; gap: 10px; padding: 14px 18px 14px 26px; border-top: 1px solid var(--line); }
.sheet-foot .spacer { flex: 1; }

.steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; flex: 1; }
.steps li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.steps li + li::before { content: ""; width: 26px; height: 1px; background: var(--line-2); margin-right: 2px; }
.steps .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 600;
  border: 1px solid var(--line-2); color: var(--muted); }
.steps li.active { color: var(--ink); font-weight: 600; }
.steps li.active .dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.steps li.done .dot { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent); }

.wz h2.title { font-size: 28px; line-height: 1.15; }
.lead { color: var(--ink-2); font-size: 15px; margin: 10px 0 0; max-width: 640px; }
.how { list-style: none; counter-reset: how; padding: 0; margin: 24px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.how li { counter-increment: how; padding: 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.how li::before { content: counter(how); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; margin-bottom: 10px; }
.how b { display: block; margin-bottom: 4px; }
.how span { color: var(--muted); font-size: 13px; }
.sync-box { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.sync-box .msg { flex: 1; }
.sync-box .msg b { display: block; }
.sync-box.err { border-color: color-mix(in oklab, var(--bad) 40%, transparent); }
.sync-box.err .msg { color: var(--bad); }
.sync-box.ok { border-color: color-mix(in oklab, var(--good) 40%, transparent); }
.big-check { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--good-soft); color: var(--good); font-weight: 700; flex: none; }
.spinner { display: inline-block; width: 16px; height: 16px; flex: none; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.lg { width: 30px; height: 30px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
details.alt { margin-top: 18px; }
details.alt > summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.alt-body { margin-top: 12px; padding: 16px 18px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); font-size: 13.5px; }
.alt-body ol { margin: 0; padding-left: 20px; display: grid; gap: 12px; }
.code { position: relative; margin-top: 8px; }
.code pre { margin: 0; padding: 10px 12px; padding-right: 74px; border-radius: var(--r-sm); background: var(--sunken); font-size: 11px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-all; max-height: 96px; overflow: auto; color: var(--ink-2); }
.code .btn { position: absolute; top: 8px; right: 8px; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 22px 0; }
.stat { padding: 14px 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.stat .v { font: 600 28px/1 var(--serif); font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.stat.hl { border-color: var(--accent); background: var(--accent-soft); }
.stat.hl .v { color: var(--accent); }
.cover-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; margin: 6px 0 4px; }
.cover-wall .cover { font-size: 7px; }
.wz-section { margin-top: 24px; }
.wz-section h3 { font: 600 12px/1 var(--sans); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.choice-list { display: grid; gap: 10px; }
.choice-list .note { color: var(--muted); font-size: 12.5px; display: block; margin-top: 2px; }
.extra-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.drop { display: block; padding: 16px; border-radius: var(--r); border: 1.5px dashed var(--line-2); background: var(--surface); cursor: pointer; transition: border-color .12s, background .12s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop b { display: block; margin-bottom: 4px; }
.drop .d { color: var(--muted); font-size: 12.5px; }
.drop .res { display: block; margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--accent); }
.drop .res.err { color: var(--bad); }

.rate-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 20px 16px; margin-top: 22px; }
.rate-card { display: flex; flex-direction: column; gap: 4px; position: relative; }
.rate-card .cover { margin-bottom: 6px; }
.rate-card .t { font-weight: 600; font-size: 13px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rate-card .a { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rate-card.rated .cover { outline: 3px solid var(--accent); outline-offset: 2px; }
.rate-stars { display: flex; gap: 1px; font-size: 20px; line-height: 1; cursor: pointer; user-select: none; margin-top: 2px; }
.rate-stars span { color: var(--line-2); transition: color .08s, transform .08s; }
.rate-stars span.on, .rate-stars span.hover { color: var(--star); }
.rate-stars span:hover { transform: scale(1.15); }
.rated-count { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; }
.done-mark { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 4px auto 18px; background: var(--good-soft); color: var(--good); font-size: 30px; }
.center { text-align: center; }

/* settings + add */
.set-row { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.set-row:first-child { padding-top: 0; }
.set-row:last-child { border-bottom: 0; padding-bottom: 0; }
.set-row .txt { flex: 1; }
.set-row .txt b { display: block; }
.set-row .txt span { color: var(--muted); font-size: 13px; }
.ok-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 6px; }
.ok-dot.no { background: var(--bad); }
.hit { display: grid; grid-template-columns: 64px 1fr; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.hit:last-child { border-bottom: 0; }
.hit h3 { font-size: 16px; }
.hit .byline { font-size: 13px; }
.hit .blurb { -webkit-line-clamp: 2; }

/* drawer */
#backdrop { position: fixed; inset: 0; background: rgba(12, 11, 9, .45); z-index: 30; animation: fade .15s; }
#drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--bg); z-index: 31; overflow-y: auto;
  padding: 26px 28px 40px; box-shadow: var(--shadow-lg); border-left: 1px solid var(--line); animation: slide .2s ease; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
#drawer .close { position: absolute; top: 12px; right: 12px; }
.dhead { display: grid; grid-template-columns: 132px 1fr; gap: 20px; }
.dhead h2 { font-size: 23px; line-height: 1.2; padding-right: 26px; }
.dhead .byline { margin: 4px 0 12px; }
.dhead .author-link { color: var(--ink-2); cursor: pointer; }
.dhead .author-link:hover { color: var(--accent); }
.big-stars { font-size: 28px; letter-spacing: 2px; cursor: pointer; user-select: none; line-height: 1; }
.big-stars span { color: var(--line-2); }
.big-stars span.on, .big-stars span.hover { color: var(--star); }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.dactions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 13.5px; margin: 22px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.desc { color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.drawer-h { font: 600 12px/1 var(--sans); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 24px 0 8px; }

#modal-pre { white-space: pre-wrap; font-size: 12px; margin: 0; color: var(--ink-2); }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px;
  border-radius: 999px; z-index: 60; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: rise .2s; }
.tip { position: fixed; z-index: 70; background: var(--ink); color: var(--bg); padding: 5px 9px; border-radius: 6px; font-size: 12px; pointer-events: none; }

@media (max-width: 760px) {
  .topbar { gap: 12px; padding: 0 14px; }
  .brand span { display: none; }
  .bg-pill { display: none; }
  main { padding: 0 16px 60px; }
  .recs { grid-template-columns: 1fr; }
  .rec { grid-template-columns: 80px 1fr; gap: 14px; padding: 14px; }
  .rec .cover { width: 80px; }
  .how, .extra-grid, .source-grid { grid-template-columns: 1fr; }
  .bulk-bar { top: 60px; }
  .author-head { grid-template-columns: 1fr; }
  .author-head > .btn { grid-column: 1; grid-row: auto; justify-self: start; }
  .series-books { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 18px 12px; }
  .charts { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 110px 1fr 60px; }
  .steps li:not(.active) .lbl { display: none; }
  .ask { flex-direction: column; border-radius: var(--r); }
  .ask input { padding: 10px 12px; }
  .dhead { grid-template-columns: 96px 1fr; }
  .sheet-body { padding: 20px; }
}

/* ---------- browser-only edition: privacy, bookmarklet, paste zones ---------- */
.priv-pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid color-mix(in oklab, var(--good) 35%, transparent); background: var(--good-soft); color: var(--good); font-size: 12.5px; font-weight: 600; }
.priv-pill svg { width: 14px; height: 14px; }
.priv-pill:hover { filter: brightness(1.04); }
.page-foot { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 70px 0 0; color: var(--muted); font-size: 12.5px; }
.page-foot svg { width: 13px; height: 13px; color: var(--good); }
.bookmarklet { display: inline-block; margin: 6px 0 2px; padding: 5px 12px; border-radius: 999px; background: var(--accent); color: var(--accent-ink) !important;
  font-weight: 600; font-size: 13px; cursor: grab; text-decoration: none !important; box-shadow: var(--shadow); }
.paste-zone { display: block; margin-top: 4px; border: 1.5px dashed var(--line-2); border-radius: var(--r); background: var(--surface); transition: border-color .12s, background .12s; }
.paste-zone.over, .paste-zone:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.paste-zone textarea { border: 0 !important; box-shadow: none !important; background: transparent; min-height: 74px; padding: 16px 18px; font-size: 14px; resize: none; }
#wz-kindle-status:not(:empty), #wz-gr-status:not(:empty) { margin-top: 12px; }
/* wizard: where are your books? */
.source-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
.source-card { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: var(--r); cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line); transition: border-color .12s, background .12s; }
.source-card:hover { border-color: var(--line-2); }
.source-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.source-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.source-card input { position: absolute; opacity: 0; pointer-events: none; }
.sc-head { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.sc-head svg { width: 22px; height: 22px; color: var(--accent); }
.sc-star { width: 22px; text-align: center; font-size: 20px; line-height: 1; color: var(--star); }
.sc-tick { margin-left: auto; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700;
  border: 1.5px solid var(--line-2); color: transparent; }
.source-card:has(input:checked) .sc-tick { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.source-card .d { color: var(--ink-2); font-size: 13.5px; }
.sc-status { font-size: 12.5px; font-weight: 600; color: var(--good); }
.sc-status:empty { display: none; }
.file-zone { display: grid; place-items: center; min-height: 96px; padding: 18px; text-align: center; cursor: pointer; color: var(--ink-2); font-size: 14px; }
.file-zone:hover { border-color: var(--accent); }
.file-zone:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.extra-grid.three { grid-template-columns: repeat(3, 1fr); }
.mini-paste { min-height: 38px !important; height: 38px; margin-top: 10px; padding: 8px 10px; font-size: 12.5px; resize: none; }
.connect-box { text-align: left; margin: 26px auto 0; max-width: 560px; padding: 18px 20px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.connect-box h3 { font-size: 17px; margin-bottom: 6px; }
.connect-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.connect-row input { flex: 1 1 220px; }
.free-box { display: flex; gap: 14px; align-items: center; margin-top: 16px; padding: 14px 16px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px dashed var(--line-2); }
.free-box .fb-text { flex: 1; min-width: 0; }
.free-box .fb-text b { display: block; margin-bottom: 3px; }
.free-box .fb-text span { font-size: 12.5px; color: var(--ink-2); }
.free-box .btn { flex: none; }
@media (max-width: 560px) { .free-box { flex-direction: column; align-items: stretch; } }
.set-row .stack { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.set-row input[type=password], .set-row input[type=text] { width: 220px; }

.proof h3 { font: 600 12px/1 var(--sans); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 28px 0 12px; }
.proof h3:first-child { margin-top: 0; }
.proof p { color: var(--ink-2); margin: 0 0 10px; }
.claims { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.claim { padding: 14px 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.claim b { display: block; margin-bottom: 4px; }
.claim span { color: var(--muted); font-size: 13px; }
.test-box { padding: 16px 18px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.test-result { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.test-result:first-of-type { margin-top: 12px; }
.test-result .verdict { margin-left: auto; font-weight: 700; }
.verdict.ok { color: var(--good); }
.verdict.bad { color: var(--bad); }
.hosts { width: 100%; border-collapse: collapse; font-size: 13px; }
.hosts th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 0 10px 8px 0; }
.hosts td { padding: 9px 10px 9px 0; border-top: 1px solid var(--line); vertical-align: top; }
.hosts td:first-child { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; white-space: nowrap; }
.hosts tr.own td { background: var(--good-soft); }
.hosts tr.own td:first-child { border-radius: 8px 0 0 8px; padding-left: 8px; }
.hosts .paths { color: var(--muted); font-size: 12px; margin-top: 3px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.csp { margin: 0; padding: 12px 14px; border-radius: var(--r-sm); background: var(--sunken); font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; color: var(--ink-2); }
.csp b { color: var(--ink); }
.data-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
@media (max-width: 760px) {
  .priv-pill span { display: none; }
  .claims, .extra-grid.three { grid-template-columns: 1fr; }
}
.stages.three { grid-template-columns: repeat(3, 1fr); }
