/* LibrePad Library — the 2026-09-27 redesign (Design canvas "LibrePad Library redesign"). */

:root {
  --bg: #f6f7f2;
  --card: #ffffff;
  --ink: #1d2a21;
  --soft-ink: #3c4a40;
  --muted: #56645a;
  --faint: #8a968d;
  --line: #d9dfd4;
  --line-soft: #eceee8;
  --field: #cfd7ca;
  --track: #e6eae1;
  --accent: #2f6b45;
  --accent-ink: #ffffff;
  --accent-soft: #e1efe4;
  --accent-text: #24593a;
  --hero-ink: #f3f7ef;
  --good: #2f6b45;
  --warn: #9a5b00;
  --tone-low: #2f6b45;
  --tone-some: #b8770b;
  --tone-high: #b3392f;
  --bad: #a3312b;
  --pill-none-bg: #eef1ea; --pill-none: #4b5a50;
  --pill-mild-bg: #e1efe4; --pill-mild: #24593a;
  --pill-mod-bg: #f7e6c4; --pill-mod: #6e4300;
  --pill-strong-bg: #f6d8d4; --pill-strong: #842a22;
  --scrim: rgba(20, 28, 22, .45);
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 6px 18px rgba(31, 58, 36, .06);
  --cover-shadow: inset 4px 0 0 rgba(0, 0, 0, .12), 0 2px 8px rgba(0, 0, 0, .16);
  --serif: 'Young Serif', Georgia, serif;
  --sans: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --tabbar: 72px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121814;
    --card: #1b231e;
    --ink: #e6ece7;
    --soft-ink: #c6d0c8;
    --muted: #9aa89e;
    --faint: #748078;
    --line: #2c3830;
    --line-soft: #243029;
    --field: #3a4840;
    --track: #2c3830;
    --accent: #6fbf8b;
    --accent-ink: #0d1a12;
    --accent-soft: #21372a;
    --accent-text: #9fd8b1;
    --hero-ink: #0d1a12;
    --good: #6fbf8b;
    --warn: #e0a64a;
    --tone-low: #6fbf8b;
    --tone-some: #e0a64a;
    --tone-high: #ef7d74;
    --bad: #ef7d74;
    --pill-none-bg: #26302a; --pill-none: #b4c0b7;
    --pill-mild-bg: #21372a; --pill-mild: #9fd8b1;
    --pill-mod-bg: #3b2f14; --pill-mod: #f0c77a;
    --pill-strong-bg: #3d1f1c; --pill-strong: #f4a59d;
    --scrim: rgba(0, 0, 0, .6);
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
}
body.signed-out { padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--accent); }
h1, h2, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.good { color: var(--good); }
.warn { color: var(--warn); }

/* ---- header and tabs ---- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 34rem; margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px 6px;
}
body.on-book .topbar { display: none; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand img { border-radius: 8px; }
.brand span { font-family: var(--serif); font-size: 21px; letter-spacing: .01em; }
.who { font-size: 13px; color: var(--muted); text-decoration: none; padding: 10px 0; }
.who:hover { text-decoration: underline; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding: 6px max(8px, calc((100% - 34rem) / 2)) calc(10px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px;
}
.tabbar[hidden] { display: none; }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 14px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 700;
}
.tabbar a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---- screens ---- */

main { max-width: 34rem; margin: 0 auto; padding: 0 16px; outline: none; }
.screen { display: flex; flex-direction: column; gap: 18px; padding: 8px 0 28px; }
.title { font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.15; }
h2 { font-size: 17px; }
.section { display: flex; flex-direction: column; gap: 10px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px;
}
.kicker { font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); }
.kicker.warn { color: var(--warn); }
.caption { font-size: 13px; color: var(--muted); text-align: center; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--field); background: var(--card); color: var(--ink);
  font-weight: 700; cursor: pointer; text-align: center;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-size: 16px; }
.btn.outline { border-color: var(--accent); color: var(--accent); }
.btn.wide { width: 100%; }
.btn.small { min-height: 44px; padding: 0 16px; flex: none; }
.btn:disabled { opacity: .5; cursor: default; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid var(--accent-soft); border-top-color: var(--accent);
  animation: lp-spin .8s linear infinite;
}
@keyframes lp-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.bar.thin { height: 6px; }

.back {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px; padding-right: 6px; color: var(--accent); font-weight: 700; text-decoration: none;
}

.notice { border-left: 4px solid var(--warn); padding: 8px 12px; border-radius: 6px;
  background: color-mix(in srgb, var(--warn) 10%, transparent); }
.notice.error { border-left-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }

/* ---- covers: the book's first page, or its title on a colour ---- */

.cover {
  position: relative; display: block; width: 100%; aspect-ratio: 800 / 480; overflow: hidden;
  border-radius: 8px; background: var(--cover-bg); color: var(--cover-ink); box-shadow: var(--cover-shadow);
}
.cover-title {
  position: absolute; inset: 0; display: flex; align-items: center; padding: 8px 10px 8px 14px;
  font-family: var(--serif); font-size: 15px; line-height: 1.15; text-wrap: balance; overflow: hidden;
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #fff; }
/* Hidden but still laid out: the cover loader watches this image scroll into
   view, and an image with display:none never does. */
.cover img:not([src]) { visibility: hidden; }
.cover-sm { width: 110px; flex: none; }
.cover-sm .cover-title { font-size: 11px; padding: 6px 8px 6px 10px; }
.cover-md { width: 150px; flex: none; }
.cover-md .cover-title { font-size: 13px; }
.cover-xs { width: 72px; flex: none; border-radius: 5px; }
.cover-xs .cover-title { font-size: 8px; padding: 4px 5px 4px 7px; }

/* ---- the reader (home) ---- */

.reader-card { display: flex; flex-direction: column; gap: 14px; border-radius: 20px; box-shadow: var(--shadow); }
.reader-book { display: flex; gap: 14px; align-items: flex-start; color: inherit; text-decoration: none; }
.reader-book-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.reader-title { font-family: var(--serif); font-size: 19px; line-height: 1.2; }
.reader-book-text .muted { font-size: 14px; }
.read-progress { display: flex; flex-direction: column; gap: 6px; }
.read-line { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.check { display: flex; flex-direction: column; gap: 6px; }

.list { padding: 0; overflow: hidden; border-radius: 16px; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 11px 14px; font-size: 15px; }
.row + .row { border-top: 1px solid var(--line-soft); }
.row b { white-space: nowrap; }

.lib-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.lib-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px;
}
.lib-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.lib-text { display: flex; flex-direction: column; min-width: 0; }
.lib-title { font-weight: 700; font-size: 15px; line-height: 1.25; }
.lib-sub { font-size: 13px; color: var(--muted); }
.lib-sub.paused { color: var(--warn); }

/* ---- books ---- */

.search {
  display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 14px;
  background: var(--card); border: 1px solid var(--field); border-radius: 14px; color: var(--muted);
}
.search:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.search input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: 16px; color: var(--ink); }
.aisles {
  display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px;
  scrollbar-width: none;
}
.aisles::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 99px; white-space: nowrap;
  border: 1px solid var(--field); background: var(--card); font-size: 14px; font-weight: 700; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.books-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sort { display: flex; align-items: center; gap: 6px; }
.sort select {
  min-height: 40px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--field);
  background: var(--card); color: var(--ink); font-size: 14px;
}
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 12px; }
.book-card { display: flex; flex-direction: column; gap: 3px; color: inherit; text-decoration: none; }
.cover-wrap { position: relative; display: block; margin-bottom: 5px; }
.badge {
  position: absolute; top: 6px; right: 6px; font-size: 11px; font-weight: 700; padding: 3px 8px;
  border-radius: 99px; background: var(--accent); color: var(--accent-ink);
}
.badge.light { background: rgba(255, 255, 255, .92); color: #1d2a21; }
.bc-title { font-weight: 700; font-size: 15px; line-height: 1.25; }
.bc-author { font-size: 13px; color: var(--muted); }
.bc-meta, .bc-content { font-size: 13px; color: var(--soft-ink); }
.bc-content { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--line); }
.dot.low { background: var(--tone-low); }
.dot.some { background: var(--tone-some); }
.dot.high { background: var(--tone-high); }
.saved-mark { margin-left: auto; display: inline-flex; color: var(--accent); }
.saved-mark .icon { width: 15px; height: 15px; stroke-width: 2.4; }
.no-results { padding: 28px 8px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* ---- a book ---- */

.book-head { display: flex; gap: 16px; align-items: flex-start; }
.book-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.book-title { font-family: var(--serif); font-weight: 400; font-size: 24px; line-height: 1.15; text-wrap: balance; }
.book-head-text .muted { font-size: 15px; }
.facts { font-size: 14px; line-height: 1.5; color: var(--soft-ink); }
.on-reader { font-size: 14px; font-weight: 700; color: var(--accent-text); }
.paused { font-size: 14px; font-weight: 700; color: var(--warn); }

.volumes { display: flex; flex-direction: column; gap: 8px; }
.vol-picker {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 6px;
  padding: 4px; border-radius: 14px; background: var(--track);
}
.vol {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 52px; border-radius: 11px; color: var(--soft-ink); text-decoration: none;
}
.vol[aria-current="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }

.send-card { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px 16px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; font-size: 15px; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.send-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.send-buttons .btn { min-height: 50px; padding: 0 10px; white-space: nowrap; }
.send-buttons .btn.outline { border-color: var(--field); color: var(--ink); }
.send-buttons .btn.outline[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }

.ratings { padding: 0; overflow: hidden; }
.ratings-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border: none; background: none; text-align: left; cursor: pointer;
}
.ratings-label { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ratings-label b { font-size: 17px; }
.ratings-head .icon { color: var(--muted); transition: transform .15s; }
.ratings-head .icon.up { transform: rotate(180deg); }
.rating-list { list-style: none; margin: 0; padding: 0 16px; }
.rating { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.rating-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 700; }
.pill { font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.pill.none { background: var(--pill-none-bg); color: var(--pill-none); }
.pill.mild { background: var(--pill-mild-bg); color: var(--pill-mild); }
.pill.moderate { background: var(--pill-mod-bg); color: var(--pill-mod); }
.pill.strong { background: var(--pill-strong-bg); color: var(--pill-strong); }
.segs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.segs i { height: 6px; border-radius: 99px; background: var(--track); }
.segs.low i.on { background: var(--tone-low); }
.segs.some i.on { background: var(--tone-some); }
.segs.high i.on { background: var(--tone-high); }
.ratings-more {
  width: 100%; min-height: 48px; border: none; border-top: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--track) 35%, var(--card)); color: var(--accent); font-weight: 700; cursor: pointer;
}

.chapters { padding: 0; overflow: hidden; }
.chapters-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 14px 16px 6px; }
.chapters ul { list-style: none; margin: 0; padding: 0; }
.chapter { border-top: 1px solid var(--line-soft); }
.chapter-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 16px; font-size: 15px; }
.chapter-row > :last-child { white-space: nowrap; font-size: 14px; }
.chapter summary { cursor: pointer; list-style: none; }
.chapter summary::-webkit-details-marker { display: none; }
.chapter details[open] summary { background: color-mix(in srgb, var(--track) 35%, var(--card)); }
.chapter details > :not(summary) { margin: 8px 16px; }
.q { font-size: 15px; }
.q ol { margin: 4px 0 0; padding-left: 1.6rem; list-style: upper-alpha; }
.q li.correct { font-weight: 700; }
.q li.chosen-wrong { text-decoration: line-through; color: var(--bad); }

/* ---- progress ---- */

.hero {
  display: flex; flex-direction: column; gap: 6px; padding: 18px; border-radius: 20px;
  background: var(--accent); color: var(--hero-ink);
}
.hero .kicker { color: inherit; opacity: .85; }
.hero-number { font-family: var(--serif); font-size: 44px; line-height: 1; }
.prog-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.prog-book { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 16px; color: inherit; text-decoration: none; }
.prog-line { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; font-size: 15px; }

/* ---- forms ---- */

.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 6px; font-weight: 700; }
input[type="text"], input[type="password"] {
  font-size: 1.1rem; font-weight: 400;
  min-height: 48px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--field); background: var(--card); color: var(--ink);
}
input:focus-visible, select:focus-visible, .btn:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- sheets: sending, and "not finished yet" ---- */

#sheet { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; justify-content: flex-end; }
#sheet[hidden] { display: none; }
.scrim { position: absolute; inset: 0; background: var(--scrim); }
.sheet-panel {
  position: relative; width: 100%; max-width: 34rem; margin: 0 auto;
  display: flex; flex-direction: column; gap: 14px;
  padding: 22px 20px calc(26px + env(safe-area-inset-bottom));
  background: var(--bg); border-radius: 24px 24px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .18);
  max-height: 92vh; overflow-y: auto;
}
.sheet-title { font-family: var(--serif); font-weight: 400; font-size: 22px; line-height: 1.2; margin-top: -10px; }
#warn-body { display: flex; flex-direction: column; gap: 10px; font-size: 15px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.step { display: flex; flex-direction: column; gap: 6px; color: var(--faint); }
.step.active, .step.done, .step.failed { color: var(--ink); }
.step.active { font-weight: 700; }
.step-line { display: flex; align-items: center; gap: 12px; }
.step-mark {
  width: 24px; height: 24px; flex: none; border-radius: 50%; border: 2px solid var(--field);
  display: inline-flex; align-items: center; justify-content: center;
}
.step-mark.done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.step-mark.failed { background: var(--bad); border-color: var(--bad); color: #fff; }
.step-mark .icon { width: 14px; height: 14px; stroke-width: 3; }
.step-spin { width: 20px; height: 20px; margin: 2px; border-width: 2.5px; }
.step-bar { margin-left: 36px; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom));
  max-width: 32rem; margin: 0 auto; z-index: 30;
  padding: 12px 16px; border-radius: 14px; background: var(--ink); color: var(--bg);
  font-size: 15px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
#toast[hidden] { display: none; }
body.signed-out #toast { bottom: calc(20px + env(safe-area-inset-bottom)); }
.noscript { padding: 16px; }
