:root {
  --bg: #f6f2ea;
  --surface: #fffdf8;
  --text: #221f1a;
  --muted: #6e675c;
  --faint: #9d9588;
  --line: #e8e1d4;
  --accent: #8a3324;
  --accent-ink: #ffffff;
  --accent-soft: #f4e3dc;
  --star: #d39a1c;
  --ok: #2e7d4f;
  --ok-bg: #e5f2e8;
  --warn: #9a5b00;
  --warn-bg: #fbefd8;
  --bad: #b8352a;
  --bad-bg: #fbe5e2;
  --info: #2f5f8a;
  --info-bg: #e3edf6;
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --shadow: 0 1px 2px rgb(40 30 20 / .12), 0 4px 14px rgb(40 30 20 / .10);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151311;
    --surface: #1f1c19;
    --text: #efeae2;
    --muted: #a8a093;
    --faint: #7a7368;
    --line: #322e29;
    --accent: #e39a83;
    --accent-ink: #20120d;
    --accent-soft: #3a2420;
    --star: #f0bd45;
    --ok: #74c995;
    --ok-bg: #16291e;
    --warn: #eaa94a;
    --warn-bg: #2e2310;
    --bad: #f0806f;
    --bad-bg: #351b17;
    --info: #8dbbe6;
    --info-bg: #19293a;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 4px 14px rgb(0 0 0 / .35);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
body.bare { padding-bottom: 0; }
a { color: inherit; }
h1 { font-family: var(--serif); font-size: 1.75rem; line-height: 1.15; margin: 0; letter-spacing: -0.01em; overflow-wrap: anywhere; font-weight: 650; }
h2 { font-size: 1rem; margin: 0 0 .7rem; display: flex; align-items: center; gap: 8px; }
h2 .ic { color: var(--accent); }
p { margin: .4rem 0; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .85em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .875rem; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.bad-text { color: var(--bad); }

/* ---- chrome ---- */
.wrap { max-width: 900px; margin: 0 auto; padding: 16px 16px 40px; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--serif); font-size: 1.1rem; font-weight: 700; text-decoration: none; }
.logo { width: 28px; height: 28px; }
.logo path { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.logo path:first-child { fill: var(--accent-soft); }
.topnav { display: none; gap: 4px; margin-right: auto; }
.topnav a { padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); }
.topnav a:hover { color: var(--text); }
.topnav a[aria-current] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.add-top { display: none; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; font-size: 11px; font-weight: 550; color: var(--muted); text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.tabbar a[aria-current] { color: var(--accent); }
.tabbar .ic { width: 24px; height: 24px; }
.tab-add { align-self: center; }
.tab-add-btn {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 15px;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow);
}
.tab-add-btn .ic { stroke-width: 2.4; }
@media (min-width: 720px) {
  .topnav { display: flex; }
  .add-top { display: inline-flex; }
  .tabbar { display: none; }
  body { padding-bottom: 0; }
  .wrap { padding: 28px 24px 56px; }
}

.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px;
  border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 580; text-decoration: none; white-space: nowrap;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: border-color .15s, transform .05s;
}
.btn:hover { border-color: color-mix(in srgb, var(--text) 25%, var(--line)); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: .875rem; }
.btn.sm .ic { width: 17px; height: 17px; }
.btn.icon { width: 44px; padding: 0; flex: none; }
.btn.sm.icon { width: 36px; }
.btn.block { width: 100%; }
.link { color: var(--accent); text-decoration: none; font-weight: 580; font-size: .9rem; }

/* ---- layout bits ---- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 4px 0 18px; }
.back { display: inline-flex; align-items: center; gap: 2px; margin: 0 0 8px -4px; color: var(--muted); text-decoration: none; font-size: .9rem; }
.back .ic { width: 18px; height: 18px; }
.section { margin: 26px 0; }
.section.first { margin-top: 4px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-head h2 { margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.section { margin: 14px 0; }
.card.inset { background: var(--bg); padding: 12px 14px; margin: 14px 0 4px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.actions.center { justify-content: center; flex-wrap: wrap; }
.wrap-actions { justify-content: flex-start; flex-wrap: wrap; }
.danger-zone { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 28px; }
.notes { white-space: pre-wrap; margin: 0; overflow-wrap: anywhere; }
.review { font-family: var(--serif); font-size: 1.05rem; line-height: 1.6; }

.flash {
  margin: 0 0 16px; padding: 10px 14px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  animation: fadein .25s ease-out;
}
@keyframes fadein { from { opacity: 0; transform: translateY(-4px); } }

.banner { padding: 12px 14px; border-radius: 12px; margin: 10px 0; background: var(--surface); border: 1px solid var(--line); }
.banner.bad { background: var(--bad-bg); border-color: transparent; color: var(--bad); }

/* ---- stat tiles ---- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  display: flex; flex-direction: column; justify-content: space-between; gap: 2px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; min-width: 0;
}
.stat b { font-size: 1.65rem; line-height: 1.15; font-weight: 680; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat b.stat-sm { font-size: 1.1rem; letter-spacing: 0; padding-top: 6px; }
.stat span { color: var(--muted); font-size: .85rem; }
a.stat:hover { border-color: color-mix(in srgb, var(--text) 20%, var(--line)); }
.star-mini { font-style: normal; color: var(--star); font-size: .8em; margin-left: 2px; }

/* ---- goal ---- */
.goal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.goal-head h2 { margin: 0; }
.goal-num { margin: 8px 0 2px; color: var(--muted); }
.goal-num b { font-size: 1.5rem; color: var(--text); }
.goal-set { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.goal-set > span { display: flex; align-items: center; gap: 8px; font-weight: 580; flex: 1 1 100%; }
.goal-set > span .ic { color: var(--accent); }
.goal-set input { flex: 1 1 100px; width: auto; }

/* ---- progress ---- */
.usage { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.usage small { color: var(--muted); font-size: .78rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.usage.big { margin: 8px 0 4px; }
progress { flex: 1; width: 100%; min-width: 0; height: 6px; border: 0; border-radius: 99px; background: var(--line); overflow: hidden; -webkit-appearance: none; appearance: none; }
.usage.big progress { height: 9px; }
progress::-webkit-progress-bar { background: var(--line); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 99px; }

/* ---- covers ---- */
.cover {
  display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover;
  border-radius: 3px 7px 7px 3px; background: var(--line);
  box-shadow: var(--shadow);
}
.cover.ph {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; gap: 6px;
  padding: 12% 10% 12% 16%; color: #f7f1e6; text-align: left;
  font-family: var(--serif); container-type: inline-size;
}
.cover.ph::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 7%; background: rgb(0 0 0 / .18); }
.cover.ph b { font-size: clamp(9px, 11cqi, 22px); line-height: 1.15; font-weight: 700; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.cover.ph small { font-size: clamp(7px, 7.5cqi, 14px); opacity: .8; font-family: system-ui, sans-serif; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.t0 { background: #6b4f3a; } .t1 { background: #2f4f5f; } .t2 { background: #5a3e5d; } .t3 { background: #3f5a3a; }
.t4 { background: #8a3324; } .t5 { background: #44466a; } .t6 { background: #8a6a2a; } .t7 { background: #355c56; }
.thumb { flex: none; width: 46px; }
.thumb .cover { box-shadow: 0 1px 3px rgb(40 30 20 / .25); }
.thumb .cover.ph { padding: 4px 4px 4px 7px; }
.thumb .cover.ph b { font-size: 6px; -webkit-line-clamp: 4; }
.thumb .cover.ph small { display: none; }

/* ---- lists ---- */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--line); }
.list.plain { background: none; border: 0; border-radius: 0; margin: 8px 0 12px; overflow: visible; }
.list.plain > li { padding: 10px 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; min-height: 60px; -webkit-tap-highlight-color: transparent; }
.row:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
.row > .ic { color: var(--faint); }
.row-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.row-title { font-family: var(--serif); font-size: 1.05rem; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; text-decoration: none; }
.row-sub { color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.row-sub.faint { color: var(--faint); font-size: .8rem; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; color: var(--muted); font-size: .8rem; }
.row-meta .dur { display: inline-flex; align-items: center; gap: 3px; }
.row-meta .dur .ic { width: 13px; height: 13px; }
.group-head { font-family: var(--serif); font-size: 1.2rem; margin: 22px 0 8px; }
.group-head small { font-family: system-ui, sans-serif; font-size: .8rem; color: var(--faint); font-weight: 500; }

.badge { display: inline-flex; align-items: center; height: 21px; padding: 0 8px; border-radius: 999px; font-size: .72rem; font-weight: 650; letter-spacing: .01em; white-space: nowrap; }
.s-to_read { background: var(--line); color: var(--muted); }
.s-reading { background: var(--info-bg); color: var(--info); }
.s-read { background: var(--ok-bg); color: var(--ok); }
.s-dropped { background: var(--bad-bg); color: var(--bad); }

.stars { display: inline-flex; gap: 1px; font-size: .85rem; line-height: 1; letter-spacing: 0; }
.stars i { font-style: normal; color: var(--line); }
.stars i.on { color: var(--star); }

/* ---- shelf (grid view) ---- */
.shelf { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 20px 14px; }
@media (min-width: 720px) { .shelf { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 26px 20px; } }
.shelf-item { display: flex; flex-direction: column; gap: 3px; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.shelf-item .cover { margin-bottom: 6px; transition: transform .15s; }
.shelf-item:hover .cover { transform: translateY(-2px); }
.shelf-title { font-family: var(--serif); font-weight: 650; font-size: .9rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.shelf-author { color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shelf-item .stars { font-size: .72rem; }

/* ---- home: reading now ---- */
.reading { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 720px) { .reading { grid-template-columns: 1fr 1fr; } }
.reading-card { display: flex; gap: 14px; padding: 14px; }
.reading-cover { flex: none; width: 76px; }
.reading-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.reading-title { font-family: var(--serif); font-size: 1.12rem; font-weight: 650; line-height: 1.2; text-decoration: none; overflow-wrap: anywhere; }
.reading-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.page-form { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-form input { width: 84px; min-height: 36px; padding: 6px 10px; }
.page-form label { font-weight: 550; }
.next-pick { display: flex; align-items: center; gap: 14px; text-decoration: none; margin: 18px 0; }
.next-pick > .ic:first-child { color: var(--accent); width: 26px; height: 26px; }
.next-pick span { display: flex; flex-direction: column; flex: 1; }
.next-pick > .ic:last-child { color: var(--faint); }

/* ---- book page ---- */
.book { display: grid; gap: 18px; }
.book-cover { width: 150px; justify-self: center; }
@media (min-width: 640px) {
  .book { grid-template-columns: 190px 1fr; gap: 28px; align-items: start; }
  .book-cover { width: 100%; }
}
.book-main { min-width: 0; }
.book-title { font-size: 1.9rem; }
.book-author { margin: 4px 0 10px; font-size: 1.05rem; }
.book-author a { color: var(--muted); text-decoration: none; }
.book-author a:hover { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.chip-tag {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 11px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: .82rem; font-weight: 600; text-decoration: none;
}
.chips.pick { margin: 0 0 8px; }
.chips.pick .chip-tag { min-height: 38px; padding: 0 14px; background: var(--surface); color: var(--text); border: 1px solid var(--line); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.chips.pick .chip-tag input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.chips.pick .chip-tag:has(input:checked) { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.chips.pick .chip-tag:has(input:focus-visible) { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.rate { display: flex; align-items: center; gap: 10px; margin: 12px 0 4px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 16px 0 8px; }
.facts div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; }
.facts div.hl { background: var(--accent-soft); border-color: transparent; }
.facts dt { font-size: .75rem; color: var(--muted); font-weight: 550; }
.facts dd { margin: 0; font-weight: 650; }
.facts .hl dd { color: var(--accent); }

/* ---- star input ---- */
.star-input { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; }
.star-input input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.star-input label { font-size: 1.9rem; line-height: 1; padding: 2px 3px; color: var(--line); cursor: pointer; transition: color .1s, transform .1s; -webkit-tap-highlight-color: transparent; }
.star-input input:checked ~ label { color: var(--star); }
@media (hover: hover) {
  .star-input:hover label { color: var(--line); }
  .star-input label:hover, .star-input label:hover ~ label { color: var(--star) !important; }
}
.star-input label:active { transform: scale(1.15); }
.star-input input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 6px; }
.rating-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.chip-radio { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; font-weight: 500; font-size: .85rem; color: var(--muted); cursor: pointer; }
.chip-radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-radio:has(input:checked) { background: var(--line); color: var(--text); }

/* ---- forms ---- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; margin: 0; border: 0; padding: 0; }
label, legend { font-size: .875rem; font-weight: 580; padding: 0; }
legend { margin-bottom: 5px; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  font: inherit; font-size: 16px; /* no iOS zoom */
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[type="date"] { -webkit-appearance: none; appearance: none; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; min-height: 0; padding: 0; margin: 0; accent-color: var(--accent); flex: none; }
input[type="file"] { padding: 8px; font-size: .9rem; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.grid2.cards { gap: 14px; margin: 14px 0; }
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.date-mode { border: 0; background: none; padding: 0 0 0 6px; color: var(--accent); font: inherit; font-size: .75rem; font-weight: 550; cursor: pointer; }
.sticky-actions { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); margin: 0 -16px -16px; padding: 12px 16px; background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
@media (min-width: 720px) { .sticky-actions { bottom: 0; } }

.segmented { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
@media (min-width: 560px) { .segmented { grid-template-columns: repeat(4, 1fr); } }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span {
  display: flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-weight: 550; cursor: pointer; text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.segmented input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.segmented input:focus-visible + span { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

.cover-field { display: flex; gap: 16px; align-items: center; }
.cover-preview { width: 92px; flex: none; }
.cover-preview .cover.ph b { font-size: .8rem; }
.cover-controls { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }

.lookup { padding: 14px; margin: -2px 0 2px; border-radius: 12px; background: var(--bg); border: 1px dashed var(--line); }
.lookup label { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lookup label .ic { color: var(--accent); width: 18px; height: 18px; }
.lookup label small { font-weight: 400; }
.lookup-results { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.lookup-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; color: var(--text); font: inherit; cursor: pointer;
}
.lookup-item:hover { border-color: var(--accent); }
.lookup-item .thumb { width: 38px; min-height: 57px; border-radius: 3px; background: var(--line); }
.lookup-item .row-title { font-size: .95rem; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.inline-form input { flex: 1 1 200px; width: auto; }
.inline-form.tight { margin: 0; flex-wrap: nowrap; flex: 1; min-width: 0; }
.inline-form.tight input { flex: 1 1 auto; min-width: 0; min-height: 36px; padding: 6px 10px; }
.genres li { display: flex; align-items: center; gap: 10px; }
.genres .count { white-space: nowrap; text-decoration: none; }

/* ---- toolbar & tabs ---- */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 12px; padding: 2px 16px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-weight: 580; text-decoration: none; font-size: .9rem; }
.tabs a small { font-size: .75rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.tabs a[aria-current] { background: var(--text); border-color: var(--text); color: var(--bg); }
.tabs a[aria-current] small { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.toolbar-row { display: flex; gap: 8px; align-items: center; overflow-x: auto; margin: 0 -16px; padding: 2px 16px; scrollbar-width: none; }
.toolbar-row::-webkit-scrollbar { display: none; }
.toolbar-row select { width: auto; flex: none; background-color: var(--surface); min-height: 40px; padding: 6px 10px; font-size: 15px; }
.toolbar-row .btn.icon { margin-left: auto; min-height: 40px; height: 40px; width: 40px; }
.search { position: relative; display: block; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search input { padding-left: 40px; background: var(--surface); }
@media (min-width: 720px) {
  .tabs, .toolbar-row { margin: 0 0 12px; padding: 2px 0; }
  .toolbar-row { margin: 0; }
}

.kv { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.kv > span { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }

/* ---- empty states ---- */
.empty { text-align: center; padding: 32px 16px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty h1 { color: var(--text); margin-bottom: 8px; }
.empty .btn { margin-top: 8px; }
.empty.compact { padding: 20px 16px; }
.welcome { padding: 40px 20px; }
.welcome .logo { width: 64px; height: 64px; margin-bottom: 8px; }

/* ---- stats ---- */
.chart { display: block; width: 100%; max-height: 260px; overflow: visible; }
.chart .bar { fill: var(--accent); }
.chart .bar-bg { fill: var(--bg); }
.chart .bar-val { fill: var(--text); font-size: 10px; font-weight: 700; text-anchor: middle; }
.chart .bar-lab { fill: var(--muted); font-size: 10px; text-anchor: middle; }
.chart a:hover .bar { fill: color-mix(in srgb, var(--accent) 75%, var(--text)); }
.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hbars li { display: grid; grid-template-columns: minmax(0, 8.5rem) 1fr 2rem; align-items: center; gap: 10px; font-size: .875rem; }
.hbars li > a, .hbars li > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.hbars li > a:hover { color: var(--accent); }
.hbars b { text-align: right; font-variant-numeric: tabular-nums; }
.hbars progress { height: 8px; }
.records { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.records > * { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 12px; background: var(--bg); text-decoration: none; min-width: 0; }
.records small { color: var(--muted); font-size: .75rem; }
.records b { font-family: var(--serif); line-height: 1.25; overflow-wrap: anywhere; }
.records span { color: var(--accent); font-weight: 600; font-size: .85rem; }
.times { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.times a { display: flex; justify-content: space-between; gap: 10px; text-decoration: none; font-size: .875rem; margin-bottom: 3px; }
.times-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.times-val { color: var(--muted); white-space: nowrap; }
.times progress { display: block; height: 5px; }
.longest { margin-top: 12px; }
.longest a { color: var(--accent); }

/* ---- auth ---- */
.auth { max-width: 380px; margin: 0 auto; padding-top: max(6vh, env(safe-area-inset-top)); }
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-brand .logo { width: 58px; height: 58px; }
.auth-brand h1 { margin-top: 8px; }
.auth .card { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: .8rem; margin: 4px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---- page header extras ---- */
.head-actions { display: flex; gap: 8px; }
.sublinks { display: flex; gap: 16px; margin: -8px 0 14px; }
.sublinks a { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); font-weight: 580; font-size: .9rem; text-decoration: none; }
.sublinks .ic { width: 17px; height: 17px; }
.tag { font-size: .66rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 5px; background: var(--line); color: var(--muted); margin-left: 6px; }
.steps { padding-left: 18px; margin: 4px 0 8px; }
.steps li { margin: 4px 0; }

/* ---- series ---- */
.series-link { display: inline-flex; align-items: center; gap: 6px; margin: -4px 0 10px; color: var(--accent); font-weight: 580; font-size: .9rem; text-decoration: none; }
.series-link .ic { width: 16px; height: 16px; }
.series-books { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.series-books li + li { border-top: 1px solid var(--line); }
.series-books a { display: flex; align-items: center; gap: 12px; padding: 10px 14px; text-decoration: none; }
.series-books li.current { background: var(--accent-soft); }
.series-no { width: 26px; flex: none; text-align: center; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.series-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.series-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.series-strip { list-style: none; margin: 12px 0 8px; padding: 0 0 4px; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: thin; }
.series-strip li { flex: none; width: 54px; }
.series-strip a { display: flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; font-size: .75rem; font-weight: 650; color: var(--muted); }
.series-strip .cover.ph { padding: 4px 4px 4px 7px; }
.series-strip .cover.ph b { font-size: 6px; }
.series-strip .cover.ph small { display: none; }
.series-strip li.s-to_read .cover { opacity: .45; }
.series-strip li.s-reading span { color: var(--info); }
.series-strip li.s-read span { color: var(--ok); }
.series-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.series-foot .ok-text { display: inline-flex; align-items: center; gap: 4px; }
.series-foot .ic { width: 16px; height: 16px; }

/* ---- quotes ---- */
.quote { margin: 0; padding: 10px 0 10px 14px; border-left: 3px solid var(--accent-soft); }
.quote blockquote { margin: 0; font-family: var(--serif); font-size: 1.02rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.quote-note { margin: 6px 0 0; color: var(--muted); font-size: .88rem; font-style: italic; white-space: pre-wrap; }
.quote-note::before { content: "Nota: "; font-style: normal; font-weight: 600; }
.quote figcaption { color: var(--faint); font-size: .75rem; margin-top: 4px; }
.quote figcaption:empty { display: none; }
.quote-row { display: flex; gap: 6px; align-items: flex-start; }
.quote-row + .quote-row { margin-top: 6px; }
.quote-row > .quote { flex: 1; min-width: 0; }
.quote-edit { flex: none; }
.quote-edit > summary { list-style: none; cursor: pointer; padding: 8px; color: var(--faint); border-radius: 8px; }
.quote-edit > summary::-webkit-details-marker { display: none; }
.quote-row:has(.quote-edit[open]) { flex-wrap: wrap; }
.quote-edit[open] { flex: 1 1 100%; }
.quote-edit[open] > summary { color: var(--accent); }
.quote-edit form { margin: 6px 0; }
.quote-author { margin: -6px 0 8px; }
.inline-form .w-page { flex: 0 0 90px; }
.quote-card { display: block; margin: 18px 0; text-decoration: none; border-left: 4px solid var(--accent); }
.quote-card blockquote { margin: 0 0 8px; font-family: var(--serif); font-size: 1.1rem; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
#quotes details.add > summary { padding: 10px 0; border: 0; }
#quotes details.add > form { padding: 0; }

/* ---- scanner ---- */
.scanner { position: relative; margin-top: 10px; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; max-height: 50vh; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-line { position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; background: #ff5a3c; box-shadow: 0 0 10px #ff5a3c; animation: scanpulse 1.4s ease-in-out infinite; }
@keyframes scanpulse { 50% { opacity: .35; } }
.scanner .btn { position: absolute; right: 10px; bottom: 10px; }

/* ---- links to wrapped / share ---- */
.wrapped-link { display: flex; align-items: center; gap: 14px; text-decoration: none; margin: 0 0 14px; background: linear-gradient(120deg, var(--accent-soft), var(--surface)); }
.wrapped-link > .ic:first-child { color: var(--accent); width: 26px; height: 26px; }
.wrapped-link span { display: flex; flex-direction: column; flex: 1; }
.share-box { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 8px 0 12px; background: var(--bg); border-radius: 10px; }
.share-box a { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--accent); }

/* ---- public page ---- */
.public { max-width: 760px; margin: 0 auto; }
.public-head { text-align: center; margin: 12px 0 24px; }
.public-head .logo { width: 44px; height: 44px; }
.public-head .usage { max-width: 320px; margin: 10px auto 0; }
.public-foot { text-align: center; margin-top: 40px; }

/* ---- wrapped ---- */
.wrapped { max-width: 520px; margin: 0 auto; }
.w-card { border-radius: 22px; padding: 30px 24px; margin: 0 0 14px; text-align: center; color: #fff8f0; box-shadow: var(--shadow); }
.w-card p { margin: 2px 0; }
.w-card h1 { font-size: 2.1rem; color: inherit; }
.w-hero { background: linear-gradient(150deg, #8a3324, #4a1d16); padding: 40px 24px; }
.w-hero small { text-transform: uppercase; letter-spacing: .14em; font-size: .75rem; opacity: .8; }
.w-t1 { background: linear-gradient(150deg, #2f4f5f, #1b2e38); }
.w-t2 { background: linear-gradient(150deg, #5a3e5d, #33223a); }
.w-t3 { background: linear-gradient(150deg, #8a6a2a, #4e3b14); }
.w-t4 { background: linear-gradient(150deg, #3f5a3a, #22331f); }
.w-t5 { background: linear-gradient(150deg, #44466a, #262840); }
.w-quote { background: linear-gradient(150deg, #355c56, #1d3531); }
.w-quote blockquote { margin: 0 0 10px; font-family: var(--serif); font-size: 1.2rem; line-height: 1.5; }
.w-shelf { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.w-card .w-big { font-family: var(--serif); font-size: 4.2rem; line-height: 1; font-weight: 700; margin: 14px 0 4px; letter-spacing: -0.02em; }
.w-mid { font-family: var(--serif); font-size: 1.6rem; line-height: 1.2; font-weight: 650; overflow-wrap: anywhere; }
.w-card .w-label { text-transform: uppercase; letter-spacing: .1em; font-size: .72rem; opacity: .75; margin-top: 18px; }
.w-card .w-label:first-child { margin-top: 0; }
.w-sub { opacity: .8; font-size: .9rem; }
.w-covers { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 14px; }
.w-covers span { display: block; font-size: .75rem; margin-top: 6px; line-height: 1.2; }
.w-mosaic { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.w-mosaic .cover.ph, .w-covers .cover.ph { padding: 5px 4px 5px 8px; }
.w-mosaic .cover.ph b { font-size: 6px; }
.w-mosaic .cover.ph small { display: none; }
.w-actions { margin: 20px 0; }
details.add > summary { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; color: var(--accent); list-style: none; -webkit-tap-highlight-color: transparent; }
details.add > summary::-webkit-details-marker { display: none; }
details.add > summary .ic { width: 18px; height: 18px; }
details.add[open] > summary { margin-bottom: 6px; }
.w-covers { grid-template-columns: repeat(auto-fit, 92px); justify-content: center; }
.w-mosaic { grid-template-columns: repeat(auto-fit, 54px); justify-content: center; }
