/* Layout: fixed left rail of navigation + a single scrolling content column of soft cards on a lilac-grey ground. */
:root {
  --bg: #f4f3f8;
  --surface: #ffffff;
  --surface-2: #f8f7fc;
  --ink: #22202d;
  --muted: #6b6780;
  --faint: #8f8aa3;
  --line: #e7e4ef;
  --accent: #5b4bb0;
  --accent-ink: #ffffff;
  --accent-soft: #eeebfa;
  --ebook: #6577d6;
  --ebook-soft: #e9ecfb;
  --audio: #e0854a;
  --audio-soft: #fcefe5;
  --dnf: #5f6274;
  --c3: #17a08c;
  --c4: #8e5cc4;
  --c5: #c99a1e;
  --c6: #d4668f;
  --spice: #df5a4a;
  --star: #d39e2c;
  --good: #2f8f5b;
  --danger: #c4443b;
  --shadow: 0 1px 2px rgba(34, 32, 45, .04), 0 6px 20px rgba(34, 32, 45, .05);
  --font-display: "Gloock", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Figtree", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --radius: 14px;
  --rail: 236px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15141b; --surface: #1e1c26; --surface-2: #24222e; --ink: #ece9f4; --muted: #aaa5bb; --faint: #7f7a92;
    --line: #2f2c3b; --accent: #a99bf0; --accent-ink: #15141b; --accent-soft: #2b2740;
    --ebook: #7d8de6; --ebook-soft: #252a45; --audio: #d27a42; --audio-soft: #3a2a1f; --dnf: #6c6f82;
    --c3: #1aa58f; --c4: #a07ad6; --c5: #b98c14; --c6: #d46d95; --spice: #ee6a5b; --star: #e2b04c;
    --good: #4fb47c; --danger: #e46a60; --shadow: 0 1px 2px rgba(0,0,0,.25), 0 6px 20px rgba(0,0,0,.2);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15141b; --surface: #1e1c26; --surface-2: #24222e; --ink: #ece9f4; --muted: #aaa5bb; --faint: #7f7a92;
  --line: #2f2c3b; --accent: #a99bf0; --accent-ink: #15141b; --accent-soft: #2b2740;
  --ebook: #7d8de6; --ebook-soft: #252a45; --audio: #d27a42; --audio-soft: #3a2a1f; --dnf: #6c6f82;
  --c3: #1aa58f; --c4: #a07ad6; --c5: #b98c14; --c6: #d46d95; --spice: #ee6a5b; --star: #e2b04c;
  --good: #4fb47c; --danger: #e46a60; --shadow: 0 1px 2px rgba(0,0,0,.25), 0 6px 20px rgba(0,0,0,.2);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* App frame */
.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: env(safe-area-inset-top, 0px); height: 100vh; overflow-y: auto; padding: 22px 14px 22px max(14px, env(safe-area-inset-left, 0px)); border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-family: var(--font-display); font-size: 21px; letter-spacing: .01em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); padding: 14px 10px 6px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: 14.5px; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav a .count { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.rail .btn-primary { width: 100%; justify-content: center; }
.rail-foot { margin-top: auto; font-size: 12px; color: var(--faint); padding: 0 10px; }
.theme-switch { display: flex; width: 100%; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); cursor: pointer; }
.ts-opt { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 5px 8px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.ts-opt svg { width: 15px; height: 15px; }
.ts-opt.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.1); }

.topbar { display: none; }
.scrim { display: none; }
.main { min-width: 0; padding-block: 28px 64px; padding-left: max(32px, env(safe-area-inset-left, 0px)); padding-right: max(32px, env(safe-area-inset-right, 0px)); }
.page { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }

/* Page header */
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ph h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(28px, 3.4vw, 38px); line-height: 1.1; letter-spacing: -.005em; }
.ph p { margin: 6px 0 0; color: var(--muted); max-width: 62ch; }
.ph-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 500; font-size: 14px; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.06); border-color: var(--accent); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-danger { color: var(--danger); }
.btn-danger.armed { background: var(--danger); color: #fff; border-color: var(--danger); }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-h h2, .card-h h3 { font-size: 15px; font-weight: 600; letter-spacing: .005em; }
.card-h .sub { font-size: 12.5px; color: var(--faint); font-weight: 400; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.span2 { grid-column: span 2; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.eyebrow { font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); font-weight: 600; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.kpi .v { font-family: var(--font-display); font-size: 32px; line-height: 1.1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .v small { font-family: var(--font-body); font-size: 13px; color: var(--muted); margin-left: 4px; }
.kpi .d { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.kpi.feature { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.kpi.feature .eyebrow, .kpi.feature .d { color: inherit; opacity: .8; }

/* Format badges */
.fmt { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px 3px 7px; border-radius: 999px; letter-spacing: .01em; white-space: nowrap; }
.fmt svg { width: 14px; height: 14px; }
.fmt-ebook { background: var(--ebook-soft); color: var(--ebook); }
.fmt-audiobook { background: var(--audio-soft); color: var(--audio); }
.fmt-dnf { background: var(--surface-2); color: var(--dnf); border: 1px solid var(--line); }

/* Chips & tags */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.link { cursor: pointer; }
.chip.link:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip .x { cursor: pointer; opacity: .6; border: 0; background: none; padding: 0; line-height: 1; }
.chip .x:hover { opacity: 1; }

/* Covers */
.cover { position: relative; aspect-ratio: 2 / 3; width: 100%; max-width: 100%; border-radius: 6px; overflow: hidden; background: var(--surface-2); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 4px 12px rgba(34,32,45,.08); flex: none; }
.cover img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .ph-cover { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 10% 10%; color: #fff; }
.cover .ph-cover b { font-family: var(--font-display); font-weight: 400; font-size: clamp(11px, 1.1vw, 15px); line-height: 1.15; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; }
.cover .ph-cover span { font-size: 10px; opacity: .85; text-transform: uppercase; letter-spacing: .06em; }
.cover.sm .ph-cover b { font-size: 9px; -webkit-line-clamp: 4; }
.cover.sm .ph-cover span { display: none; }

/* Ratings */
.rate { display: inline-flex; gap: 1px; vertical-align: middle; }
.rate .u { position: relative; width: 15px; height: 15px; }
.rate .u svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.rate .u .bg { color: var(--line); }
.rate .u .fg { clip-path: inset(0 calc(100% - var(--f) * 100%) 0 0); }
.rate.stars .fg { color: var(--star); }
.rate.peppers .fg { color: var(--spice); }
.rate.lg .u { width: 26px; height: 26px; }
.rate-input { display: inline-flex; align-items: center; gap: 10px; }
.rate-input .rate { cursor: pointer; }
.rate-input .u .hit { position: absolute; top: 0; bottom: 0; width: 50%; z-index: 1; }
.rate-input .u .hit.l { left: 0; } .rate-input .u .hit.r { right: 0; }

/* Progress */
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.bar.ebook > i { background: var(--ebook); }
.bar.audiobook > i { background: var(--audio); }

/* Book lists */
.book-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 10px 6px; border-radius: 10px; cursor: pointer; }
.book-row:hover { background: var(--surface-2); }
.book-row + .book-row { border-top: 1px solid var(--line); border-radius: 0; }
.book-row .t { font-weight: 600; line-height: 1.3; }
.book-row .a { color: var(--muted); font-size: 13.5px; }
.book-row .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }

.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 22px 18px; }
.shelf-item { cursor: pointer; display: flex; flex-direction: column; gap: 8px; min-width: 0; text-align: left; background: none; border: 0; padding: 0; }
.shelf-item:hover .cover { transform: translateY(-2px); }
.shelf-item .cover { transition: transform .18s ease; }
.shelf-item .t { font-weight: 600; font-size: 13.5px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.shelf-item .a { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shelf-item .m { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ebook { background: var(--ebook); } .dot.audiobook { background: var(--audio); } .dot.dnf { background: var(--dnf); }

/* Reading now */
.reading { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.rd { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 16px; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); position: relative; }
.rd.ebook { border-left: 3px solid var(--ebook); }
.rd.audiobook { border-left: 3px solid var(--audio); }
.rd .t { font-weight: 600; line-height: 1.25; cursor: pointer; }
.rd .a { color: var(--muted); font-size: 13.5px; }
.rd .prog { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.rd .prog .bar { flex: 1; }
.rd .pct { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; min-width: 40px; text-align: right; }
.rd form { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.rd form input { width: 84px; }

/* Forms */
.input, .select, textarea.input { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 7px 10px; font-size: 14px; min-width: 0; }
.input:focus, .select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { width: 100%; min-height: 76px; resize: vertical; line-height: 1.45; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .lbl { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--faint); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--surface-2); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; cursor: pointer; font-size: 13.5px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 600; }
.tag-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 6px; background: var(--surface); }
.tag-input input { border: 0; outline: none; background: transparent; flex: 1; min-width: 120px; padding: 2px 4px; font-size: 14px; }
.tag-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; cursor: pointer; background: var(--surface); }
.checks input { accent-color: var(--accent); margin: 0; }
.checks label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 18, 30, .42); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: max(28px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(28px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); overflow-y: auto; }
.modal { background: var(--surface); border-radius: 18px; width: min(760px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.25); border: 1px solid var(--line); }
.modal.wide { width: min(980px, 100%); }
.modal.narrow { width: min(480px, 100%); }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); gap: 12px; }
.modal-h h2 { font-family: var(--font-display); font-weight: 400; font-size: 24px; }
.modal-b { padding: 22px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-f .left { margin-right: auto; display: flex; gap: 8px; }

/* Book detail */
.detail { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 26px; }
.detail h2.title { font-family: var(--font-display); font-weight: 400; font-size: 30px; line-height: 1.12; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px 18px; margin-top: 18px; }
.facts .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 600; }
.facts .v { margin-top: 3px; }
.journal { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.journal td, .journal th { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.journal th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 600; }

/* Tables */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: default; }
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--ink); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.tbl td.n, .tbl th.n { text-align: right; font-variant-numeric: tabular-nums; }

/* Library toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search { position: relative; flex: 1 1 280px; min-width: 0; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { width: 100%; padding: 10px 12px 10px 38px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); font-size: 14.5px; }
.search input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.lib { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; align-items: start; }
.filters { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 16px); max-height: calc(100vh - 32px); overflow-y: auto; padding: 16px; }
.fgroup { border-top: 1px solid var(--line); padding: 12px 0; }
.fgroup:first-of-type { border-top: 0; padding-top: 0; }
.fgroup summary { cursor: pointer; font-weight: 600; font-size: 13.5px; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.fgroup summary::-webkit-details-marker { display: none; }
.fgroup summary .n { font-size: 12px; color: var(--accent); font-weight: 600; }
.fopts { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; max-height: 240px; overflow-y: auto; }
.fopts label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 3px 4px; border-radius: 6px; cursor: pointer; }
.fopts label:hover { background: var(--surface-2); }
.fopts label .c { margin-left: auto; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.fopts input[type=checkbox] { accent-color: var(--accent); margin: 0; }
.fsearch { width: 100%; margin-top: 8px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.results-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); }

/* Period selector */
.period { display: flex; flex-direction: column; gap: 8px; }
.period .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 13px; font-size: 13px; cursor: pointer; color: var(--muted); font-variant-numeric: tabular-nums; }
.pbtn:hover:not(:disabled) { border-color: var(--faint); color: var(--ink); }
.pbtn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pbtn:disabled { opacity: .35; cursor: default; }
.pbtn.m { padding: 4px 10px; font-size: 12.5px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--accent); }

/* Charts */
.chart-card { position: relative; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 320px; }
.chart-box.xtall { height: 420px; }
.chart-card .hide-btn { display: none; }
.customizing .chart-card .hide-btn { display: inline-grid; }
.customizing .chart-card { outline: 2px dashed var(--line); outline-offset: 3px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.hidden-tray { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 12px; font-size: 13px; color: var(--muted); }

/* Heatmap */
.heat { display: grid; gap: 3px; font-size: 12.5px; }
.heat .hc { border-radius: 5px; min-height: 28px; display: grid; place-items: center; font-variant-numeric: tabular-nums; font-size: 12px; }
.heat .hh { color: var(--muted); font-weight: 600; font-size: 12px; text-align: center; align-self: end; padding-bottom: 4px; }
.heat .hr { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px; align-self: center; cursor: pointer; }
.heat .hr:hover { color: var(--accent); }

/* Rankings */
.rank { display: flex; flex-direction: column; }
.rank-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.rank-row:first-child { border-top: 0; }
.rank-row .pos { font-family: var(--font-display); color: var(--faint); font-size: 18px; text-align: center; }
.rank-row .nm { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .sb { font-size: 12.5px; color: var(--muted); }
.rank-row .val { text-align: right; font-variant-numeric: tabular-nums; font-size: 13.5px; }

/* Quote */
.quote { position: relative; padding: 26px 28px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--line); }
.quote blockquote { margin: 0; font-family: var(--font-display); font-size: clamp(19px, 2vw, 24px); line-height: 1.35; color: var(--ink); max-width: 60ch; }
.quote blockquote::before { content: "\201C"; display: block; font-size: 54px; line-height: .6; color: var(--accent); margin-bottom: 8px; }
.quote .src { margin-top: 14px; color: var(--muted); font-size: 13.5px; }
.quote .q-actions { position: absolute; top: 12px; right: 12px; display: flex; gap: 4px; }

/* Characters */
.chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.char { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; min-width: 0; cursor: pointer; }
.char:hover { border-color: var(--faint); }
.char .pic { aspect-ratio: 4 / 5; max-width: 100%; background: var(--surface-2); position: relative; overflow: hidden; }
.char .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.char .pic .mono { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-size: 54px; color: #fff; }
.char .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 4px; }
.char .nm { font-family: var(--font-display); font-size: 19px; line-height: 1.2; }
.char .bk { font-size: 12.5px; color: var(--muted); }
.char .ds { font-size: 13px; color: var(--muted); margin-top: 6px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.role { font-size: 11px; font-weight: 700; letter-spacing: .08em; padding: 2px 8px; border-radius: 99px; align-self: flex-start; }
.role.MMC { background: var(--ebook-soft); color: var(--ebook); }
.role.FMC { background: color-mix(in oklab, var(--c6) 16%, var(--surface)); color: var(--c6); }
.role.Other { background: var(--surface-2); color: var(--muted); }

/* Series */
.series-row { display: grid; grid-template-columns: minmax(0, 1fr) 180px auto; gap: 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.series-row:first-child { border-top: 0; }
.series-row .nm { font-weight: 600; }
.series-row .au { font-size: 13px; color: var(--muted); }
.mini-covers { display: flex; gap: 0; }
.mini-covers .cover { width: 30px; margin-right: -8px; border: 2px solid var(--surface); }

/* TBR */
.tbr-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.tbr-item { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.tbr-item:first-child { border-top: 0; }
.tbr-item .t { font-weight: 600; font-size: 14px; line-height: 1.3; }
.tbr-item .a { font-size: 12.5px; color: var(--muted); }
.tbr-item .acts { display: flex; gap: 2px; opacity: .55; }
.tbr-item:hover .acts { opacity: 1; }
.date-pill { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: color-mix(in oklab, var(--c3) 15%, var(--surface)); color: var(--c3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.upcoming { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 16px; }
.up-item { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.up-item .t { font-weight: 600; font-size: 13.5px; line-height: 1.3; }
.up-item .a { font-size: 12.5px; color: var(--muted); }

/* Empty, toast, misc */
.empty { text-align: center; padding: 36px 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty h3 { font-family: var(--font-display); font-weight: 400; font-size: 21px; color: var(--ink); }
.empty p { margin: 0; max-width: 46ch; }
.toast { position: fixed; bottom: max(20px, env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 80; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.notice { padding: 12px 16px; border-radius: 12px; background: var(--accent-soft); color: var(--ink); font-size: 14px; border: 1px solid var(--line); }
.loading { padding: 80px 0; text-align: center; color: var(--muted); }
.goal-ring { width: 96px; height: 96px; flex: none; }
.split { display: flex; gap: 18px; align-items: center; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 500; font-size: 13.5px; }
.link-btn:hover { text-decoration: underline; }
.sep { height: 1px; background: var(--line); margin: 6px 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Responsive */
.mobile-only { display: none; }
@media (max-width: 1100px) { .mobile-only { display: inline; } }
@media (max-width: 1100px) {
  .lib { grid-template-columns: minmax(0, 1fr); }
  .filters { position: static; max-height: none; }
  .filters.collapsed .fgroups { display: none; }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); z-index: 60; transform: translateX(-102%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.2); height: 100%; padding-top: max(22px, env(safe-area-inset-top, 0px)); }
  .app.nav-open .rail { transform: none; }
  .scrim { display: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(20,18,30,.35); z-index: 55; }
  .topbar { display: flex; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; align-items: center; justify-content: space-between; gap: 10px; padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); background: var(--bg); border-bottom: 1px solid var(--line); }
  .topbar .brand-name { font-size: 19px; }
  .main { padding-block: 20px 56px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .g2, .g3, .tbr-cols { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .detail { grid-template-columns: minmax(0, 1fr); }
  .detail .cover { max-width: 160px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .series-row { grid-template-columns: minmax(0, 1fr) auto; }
  .series-row .bar-cell { grid-column: 1 / -1; }
  .reading { grid-template-columns: minmax(0, 1fr); }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 18px 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Standalone site additions ---------- */
:root { color-scheme: light; }
body { margin: 0; }
img { max-width: 100%; }

/* Account area under the theme switch */
.account-box { display: flex; gap: 8px; }
.account-box .btn { flex: 1; justify-content: center; }
.account-chip { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; text-align: left; color: var(--ink); }
.account-chip:hover { border-color: var(--faint); }
.account-chip .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; }
.account-chip .who { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.account-chip .who b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-chip .who span { font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Log in / sign up screen */
.auth-wrap { max-width: 1040px; margin: 4vh auto 0; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.auth-intro h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(30px, 4vw, 46px); line-height: 1.08; margin: 10px 0 14px; }
.auth-intro p { color: var(--muted); max-width: 46ch; margin: 0; font-size: 16px; }
.auth-points { list-style: none; padding: 0; margin: 26px 0 0; display: flex; flex-direction: column; gap: 12px; color: var(--muted); }
.auth-points li { display: flex; gap: 10px; align-items: center; }
.auth-points svg { color: var(--accent); }
.auth-card { padding: 28px; }
.auth-card h2 { font-family: var(--font-display); font-weight: 400; font-size: 26px; margin-bottom: 16px; }
.auth-tabs { margin-bottom: 18px; width: 100%; }
.auth-tabs button { flex: 1; justify-content: center; }
.auth-card .auth-submit { justify-content: center; padding: 10px 14px; }
.auth-card .input { padding: 10px 12px; }
.auth-error { background: color-mix(in oklab, var(--danger) 12%, var(--surface)); color: var(--danger); border: 1px solid color-mix(in oklab, var(--danger) 35%, var(--surface)); padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }

/* Online book search */
.lookup { margin-bottom: 20px; padding: 14px; border: 1px dashed var(--line); border-radius: 12px; background: var(--surface-2); }
.lookup-bar { display: flex; gap: 8px; align-items: center; }
.lookup-bar svg { color: var(--faint); flex: none; }
.lookup-bar .input { flex: 1; }
.lookup-results { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; max-height: 320px; overflow-y: auto; }
.lk-item { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: center; padding: 8px; border-radius: 10px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--ink); }
.lk-item:hover { background: var(--surface); border-color: var(--line); }
.lk-item .t { font-weight: 600; font-size: 14px; line-height: 1.3; }
.lk-item .a { font-size: 12.5px; color: var(--muted); }
.cover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 14px; }
.cover-pick { display: flex; flex-direction: column; gap: 6px; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.cover-pick:hover .cover { outline: 3px solid var(--accent); outline-offset: 2px; }

@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: minmax(0, 1fr); gap: 24px; margin-top: 8px; }
  .auth-points { display: none; }
}

/* Read-only shared profile */
.viewing-pill { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13.5px; }
.viewing-banner { max-width: 1240px; margin: 0 auto 18px; display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); border: 1px solid var(--line); font-size: 14px; }
.viewing-banner svg { color: var(--accent); }

/* Friends and activity */
.badge { display: inline-block; min-width: 18px; padding: 1px 7px; border-radius: 99px; background: var(--accent); color: var(--accent-ink) !important; font-size: 11px; font-weight: 700; text-align: center; line-height: 1.5; vertical-align: middle; }
.feed-row { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: center; padding: 9px 6px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.feed-row + .feed-row { border-top: 1px solid var(--line); border-radius: 0; }
.feed-row:hover { background: var(--surface-2); }
.feed-row.new { background: color-mix(in oklab, var(--accent) 7%, var(--surface)); }
.feed-text { line-height: 1.4; font-size: 14px; }
.feed-name { font-weight: 700; color: var(--accent); }
.friend-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.friend-row:first-of-type { border-top: 0; }
.friend-row .avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; }
.add-tbr { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding: 10px 12px; border: 1px dashed var(--accent); border-radius: 12px; background: var(--accent-soft); }
.viewing-banner { flex-wrap: wrap; }
@media (max-width: 860px) { .friend-row { grid-template-columns: 36px minmax(0, 1fr); } .friend-row > .row-gap { grid-column: 1 / -1; } }

/* Language switch */
.lang-switch .ts-opt { border: 0; background: transparent; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 600; letter-spacing: .04em; }
.lang-switch .ts-opt.on { background: var(--surface); }
.lang-top { font-size: 12px; font-weight: 700; letter-spacing: .04em; width: auto; padding: 0 8px; }

/* BETA label next to the name */
.beta { display: inline-block; margin-left: 6px; padding: 2px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font: 700 10px/1.3 var(--font-body); letter-spacing: .08em; vertical-align: middle; }
.brand .beta { align-self: center; }
.brand { gap: 8px; }
.brand-name { white-space: nowrap; }
.rail .brand-name { font-size: 19px; }
.rail .beta { margin-left: 2px; padding: 2px 5px; font-size: 9.5px; }

/* Stars and peppers: partial fill via a clipped wrapper (works in every browser) */
.rate { --u: 15px; }
.rate.lg { --u: 26px; }
.rate .u { width: var(--u); height: var(--u); flex: none; }
.rate .u .fg { clip-path: none; }
.rate .u .fgw { position: absolute; top: 0; left: 0; bottom: 0; overflow: hidden; pointer-events: none; }
.rate .u .fgw svg { position: absolute; top: 0; left: 0; width: var(--u); height: var(--u); }
.rate .u svg.bg { display: block; }

/* Stars and peppers: partial fill via a clipped wrapper (works in every browser) */
.rate { --u: 15px; }
.rate.lg { --u: 26px; }
.rate .u { width: var(--u); height: var(--u); flex: none; }
.rate .u .fg { clip-path: none; }
.rate .u .fgw { position: absolute; top: 0; left: 0; bottom: 0; overflow: hidden; pointer-events: none; }
.rate .u .fgw svg { position: absolute; top: 0; left: 0; width: var(--u); height: var(--u); }
.rate .u svg.bg { display: block; }
