/* Bookshelf — app styles
   Palette: cool paper, blue-black ink, library-binding green, gold ribbon. */

@font-face { font-family: "Atkinson Hyperlegible"; src: url("fonts/AtkinsonHyperlegible-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("fonts/AtkinsonHyperlegible-Bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("fonts/AtkinsonHyperlegible-Italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("fonts/AtkinsonHyperlegible-BoldItalic.woff2") format("woff2"); font-weight: 700; font-style: italic; font-display: swap; }

:root {
  --paper: #F3F4EF;
  --surface: #FBFBF8;
  --ink: #1D2430;
  --ink-soft: #586172;
  --rule: #D6D9CF;
  --cloth: #2D5A4C;
  --cloth-hover: #244B3F;
  --on-cloth: #FFFFFF;
  --ribbon: #C2972F;
  --danger: #A3372A;
  --focus: #1F6FEB;
  --scrim: rgb(20 24 30 / .45);
  --cover-shadow: 0 1px 1px rgb(29 36 48 / .18), 0 8px 18px -6px rgb(29 36 48 / .35);

  --font-ui: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-title: ui-serif, "New York", "Iowan Old Style", Georgia, "Noto Serif", serif;
  --tap: 48px;
  --gutter: 16px;

  color-scheme: light;
  font-size: 17px;
}

:root[data-theme="dark"] {
  --paper: #151A18;
  --surface: #1D2421;
  --ink: #E5E8E2;
  --ink-soft: #A6AEA8;
  --rule: #2E3834;
  --cloth: #86C1AC;
  --cloth-hover: #9BD0BC;
  --on-cloth: #0F1714;
  --ribbon: #DDB54E;
  --danger: #F08A7C;
  --focus: #7DB3FF;
  --scrim: rgb(0 0 0 / .6);
  --cover-shadow: 0 1px 1px rgb(0 0 0 / .4), 0 8px 18px -6px rgb(0 0 0 / .7);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #151A18;
    --surface: #1D2421;
    --ink: #E5E8E2;
    --ink-soft: #A6AEA8;
    --rule: #2E3834;
    --cloth: #86C1AC;
    --cloth-hover: #9BD0BC;
    --on-cloth: #0F1714;
    --ribbon: #DDB54E;
    --danger: #F08A7C;
    --focus: #7DB3FF;
    --scrim: rgb(0 0 0 / .6);
    --cover-shadow: 0 1px 1px rgb(0 0 0 / .4), 0 8px 18px -6px rgb(0 0 0 / .7);
    color-scheme: dark;
  }
}

/* Older Readers mode: bigger type, bigger targets, stronger contrast */
:root[data-older] {
  font-size: 21px;
  --tap: 60px;
  --ink-soft: #343B47;
  --rule: #9AA196;
}
:root[data-older][data-theme="dark"] { --ink-soft: #D2D7D2; --rule: #5D6863; }
@media (prefers-color-scheme: dark) {
  :root[data-older]:not([data-theme="light"]) { --ink-soft: #D2D7D2; --rule: #5D6863; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.icon { width: 1.3em; height: 1.3em; flex: none; }
.quiet { color: var(--ink-soft); }
.noscript { padding: 24px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: var(--tap); padding: 0 1.05em;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--ink);
  font-weight: 700; font-size: 1rem; line-height: 1.1;
  text-decoration: none; white-space: nowrap;
  touch-action: manipulation;
}
.btn, .tool, .book-open, .seg button, .stepper button, .theme-swatches button, .list-btn, .colors button, .switch {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.btn-primary { background: var(--cloth); color: var(--on-cloth); }
.btn-primary:hover { background: var(--cloth-hover); }
.btn-quiet:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.btn-outline { box-shadow: inset 0 0 0 2px var(--rule); }
.btn-danger { color: var(--danger); box-shadow: inset 0 0 0 2px currentColor; }
.btn-big { min-height: calc(var(--tap) + 8px); padding: 0 1.6em; font-size: 1.1rem; }
.icon-btn { padding: 0 .8em; }
.icon-btn .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:root[data-older] .icon-btn .btn-label { position: static; width: auto; height: auto; clip: auto; }

/* ---------- Library ---------- */
.screen { min-height: 100dvh; }
#library {
  padding: calc(env(safe-area-inset-top) + 12px) max(var(--gutter), env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 40px) max(var(--gutter), env(safe-area-inset-left));
  max-width: 1080px; margin: 0 auto;
}
.lib-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 0 20px;
}
.lib-title {
  margin: 0;
  font-family: var(--font-title); font-weight: 600;
  font-size: 2rem; letter-spacing: -.01em; line-height: 1.05;
}
.lib-actions { display: flex; align-items: center; gap: 4px; }
:root[data-older] .lib-header { flex-wrap: wrap; }
:root[data-older] .lib-actions { width: 100%; gap: 10px; }
:root[data-older] .lib-actions #add-books { flex: 1; }

/* "Add to Home Screen" / "Install" tip */
.install-tip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  margin: 0 0 22px; padding: 14px 16px; border-radius: 16px;
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--rule);
}
.install-tip p { flex: 1 1 260px; margin: 0; }
.install-tip strong { display: block; margin-bottom: 2px; }
.install-tip .row { flex: 0 0 auto; gap: 6px; }

/* Continue reading: the one big moment */
.continue {
  display: grid; grid-template-columns: minmax(104px, 34%) 1fr; gap: 20px;
  align-items: end;
  padding: 4px 0 28px; margin-bottom: 20px;
  border-bottom: 1px solid var(--rule);
}
.continue .cover { width: 100%; max-width: 190px; }
.continue-kicker { margin: 0 0 6px; color: var(--ink-soft); font-size: .9rem; }
.continue-title {
  margin: 0 0 4px;
  font-family: var(--font-title); font-weight: 600;
  font-size: 1.45rem; line-height: 1.15;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.continue-author { margin: 0 0 14px; color: var(--ink-soft); }
.continue-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-size: .9rem; color: var(--ink-soft); }
.meter { flex: 1; height: 6px; border-radius: 3px; background: var(--rule); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--cloth); border-radius: inherit; }
:root[data-older] .continue { grid-template-columns: 1fr; }
:root[data-older] .continue .cover { max-width: 150px; }
:root[data-older] .continue .btn { width: 100%; }

.shelf-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.shelf-title { margin: 0; font-size: 1.15rem; font-weight: 700; }
.sort select {
  min-height: 40px; padding: 0 2.1em 0 .9em; border-radius: 999px;
  border: 0; box-shadow: inset 0 0 0 1.5px var(--rule);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23778' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right .8em center / .7em;
  -webkit-appearance: none; appearance: none; font-size: 1rem;
}
:root[data-older] .sort select { min-height: var(--tap); font-size: 1rem; }
.filter {
  display: flex; align-items: center; gap: 8px;
  min-height: var(--tap); margin: 0 0 18px; padding: 0 14px;
  border-radius: 12px; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--rule);
  color: var(--ink-soft);
}
.filter input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--ink); font-size: 1rem; }
.filter-empty { color: var(--ink-soft); }

.book-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 26px 18px;
}
.book { position: relative; container-type: inline-size; }
.book-open {
  display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left;
  color: inherit; border-radius: 6px;
}
.book-title {
  margin: 10px 0 2px;
  font-family: var(--font-title); font-weight: 600; font-size: 1rem; line-height: 1.2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.book-meta { margin: 0; font-size: .85rem; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.book-more {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: 50%;
  background: rgb(255 255 255 / .88); color: #1D2430; box-shadow: 0 1px 3px rgb(0 0 0 / .25);
}
/* sit in the cover's bottom corner (the cover is 1.5 times as tall as it is wide) */
@supports (top: 1cqi) { .book-more { top: calc(150cqi - 42px); } }
:root[data-older] .book-grid { grid-template-columns: 1fr; gap: 0; }
:root[data-older] .book { border-bottom: 1px solid var(--rule); }
:root[data-older] .book-open { display: grid; grid-template-columns: 92px 1fr; gap: 18px; align-items: center; padding: 16px 64px 16px 0; }
:root[data-older] .book-title { margin-top: 0; font-size: 1.1rem; }
:root[data-older] .book-meta { -webkit-line-clamp: 2; font-size: .95rem; }
:root[data-older] .book-more { top: 50%; right: 0; transform: translateY(-50%); width: 56px; height: 56px; background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 2px var(--rule); }

/* Covers look like objects: small radius on the spine side, a spine highlight, a real shadow */
.cover {
  position: relative; display: block; width: 100%; aspect-ratio: 2 / 3;
  border-radius: 2px 5px 5px 2px; overflow: hidden;
  background: var(--rule); box-shadow: var(--cover-shadow);
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgb(0 0 0 / .22) 0, rgb(255 255 255 / .18) 2.5%, rgb(0 0 0 / 0) 6%, rgb(0 0 0 / 0) 100%);
}
.cover-made {
  display: flex; flex-direction: column; justify-content: space-between;
  height: 100%; padding: 12% 28% 10% 14%; color: #fff;
}
.cover-made .cm-title { font-family: var(--font-title); font-weight: 600; font-size: clamp(.8rem, 4.2cqi, 1.3rem); line-height: 1.15; overflow-wrap: anywhere; }
.cover-made .cm-author { font-size: .72rem; opacity: .85; }
.cover-made .cm-rule { height: 1px; background: rgb(255 255 255 / .45); margin: 10px 0; }
.cover { container-type: inline-size; }
.cover-made .cm-title { font-size: clamp(.75rem, 11cqi, 1.6rem); }
.cover-made .cm-author { font-size: clamp(.6rem, 7cqi, .95rem); }
.cover-format {
  position: absolute; left: 8px; bottom: 8px; z-index: 1; pointer-events: none;
  padding: 2px 7px; border-radius: 6px; font-size: .68rem; font-weight: 700;
  background: rgb(0 0 0 / .62); color: #fff;
}
/* gold ribbon marker: its length shows how far you've read */
.ribbon {
  position: absolute; top: 0; right: 12%; z-index: 1; pointer-events: none; max-height: 78%;
  width: 12%; min-width: 11px; max-width: 18px;
  background: var(--ribbon);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 7px), 0 100%);
  box-shadow: 0 1px 2px rgb(0 0 0 / .3);
}

/* Empty shelf */
.empty { text-align: center; padding: 6vh 8px 0; max-width: 560px; margin: 0 auto; }
.empty-art { width: min(260px, 70vw); height: auto; margin-bottom: 10px; }
.empty h2 { font-family: var(--font-title); font-size: 1.6rem; margin: 0 0 10px; }
.empty p { margin: 0 0 12px; }
.empty .btn { margin-top: 12px; }

/* ---------- Reader ---------- */
.reader {
  --big-nav-h: 86px;
  position: fixed; inset: 0; overflow: hidden; overflow: clip; touch-action: manipulation;
  background: var(--r-bg); color: var(--r-fg);
  --r-bg: #FBFBF7; --r-fg: #1E2228; --r-soft: #646B75; --r-bar: #F2F2EC; --r-rule: #DADBD3;
  --r-accent: #2D5A4C; --r-on-accent: #fff;
}
.reader[data-reading-theme="sepia"] { --r-bg: #F4EAD5; --r-fg: #4B3B2A; --r-soft: #7A6650; --r-bar: #EADFC6; --r-rule: #D6C7A6; --r-accent: #6F4E22; }
.reader[data-reading-theme="night"] { --r-bg: #181C1B; --r-fg: #D8D5CB; --r-soft: #9A9C95; --r-bar: #212725; --r-rule: #353D3A; --r-accent: #86C1AC; --r-on-accent: #0F1714; }
.reader[data-reading-theme="contrast"] { --r-bg: #FFFFFF; --r-fg: #000000; --r-soft: #1A1A1A; --r-bar: #FFFFFF; --r-rule: #000000; --r-accent: #000000; --r-on-accent: #fff; }
.reader[data-reading-theme="contrast-dark"] { --r-bg: #000000; --r-fg: #FFFFFF; --r-soft: #E6E6E6; --r-bar: #000000; --r-rule: #FFFFFF; --r-accent: #FFFFFF; --r-on-accent: #000; }

.book-host {
  position: absolute;
  top: env(safe-area-inset-top); right: env(safe-area-inset-right);
  bottom: env(safe-area-inset-bottom); left: env(safe-area-inset-left);
}
.reader.with-big-nav .book-host { bottom: calc(env(safe-area-inset-bottom) + var(--big-nav-h)); }
foliate-view { display: block; width: 100%; height: 100%; }
foliate-view::part(head), foliate-view::part(foot) { color: var(--r-soft); opacity: 1; font-family: var(--font-ui); }
:root[data-older] foliate-view::part(foot), :root[data-older] foliate-view::part(head) { font-size: 1rem; }
.reader[data-reading-theme="night"] foliate-view, .reader[data-reading-theme="contrast-dark"] foliate-view {
  --overlayer-highlight-opacity: .45; --overlayer-highlight-blend-mode: screen;
}
foliate-view { --overlayer-highlight-opacity: .4; --overlayer-highlight-blend-mode: multiply; }
.reader.invert-pages foliate-view::part(filter) { filter: invert(.9) hue-rotate(180deg); }

.reader-bar {
  position: absolute; left: 0; right: 0; z-index: 10;
  background: var(--r-bar); color: var(--r-fg);
  visibility: hidden;
  transition: transform .22s ease, visibility 0s linear .22s;
}
.reader.chrome-on .reader-bar { visibility: visible; transition: transform .22s ease, visibility 0s; }
.reader-top {
  top: 0; display: flex; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top) + 4px) max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--r-rule);
  transform: translateY(-105%);
}
.reader-top .btn { color: var(--r-fg); }
.reader-title {
  flex: 1; min-width: 0; margin: 0; text-align: center;
  font-family: var(--font-title); font-weight: 600; font-size: .95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reader-bottom {
  bottom: 0;
  padding: 10px max(14px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 4px) max(14px, env(safe-area-inset-left));
  border-top: 1px solid var(--r-rule);
  transform: translateY(105%);
}
.reader.chrome-on .reader-top, .reader.chrome-on .reader-bottom { transform: none; }
.progress-row { display: flex; justify-content: space-between; gap: 12px; font-size: .85rem; color: var(--r-soft); }
.chapter-label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.percent-label { flex: none; font-variant-numeric: tabular-nums; }
.progress-slider { width: 100%; margin: 6px 0 4px; accent-color: var(--r-accent); height: 32px; }
.tool-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.tool {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 58px; min-width: 60px; padding: 4px 6px;
  border: 0; border-radius: 14px; background: none; color: inherit;
  font-size: .78rem; font-weight: 700; touch-action: manipulation;
}
.tool:hover { background: color-mix(in srgb, currentColor 9%, transparent); }
.tool:disabled { opacity: .35; cursor: default; }
.tool .icon { width: 1.55em; height: 1.55em; }
:root[data-older] .tool { min-height: 72px; font-size: .85rem; }

.reader.with-big-nav .reader-bottom {
  bottom: calc(env(safe-area-inset-bottom) + var(--big-nav-h));
  padding-bottom: 6px;
}
.big-nav {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 11;
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px;
  padding: 10px max(12px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 10px) max(12px, env(safe-area-inset-left));
  background: var(--r-bar); border-top: 2px solid var(--r-rule);
}
.big-nav-btn { min-width: 0; min-height: 64px; padding: 0 .5em; gap: .2em; border-radius: 18px; font-size: .95rem; background: var(--r-accent); color: var(--r-on-accent); }
.big-nav-menu { background: transparent; color: var(--r-fg); box-shadow: inset 0 0 0 2px var(--r-rule); padding: 0 .9em; }
@media (max-width: 420px) { .big-nav-btn .icon { display: none; } }

.selection-bar, .listen-bar {
  position: absolute; z-index: 12; left: 0; right: 0; margin-inline: auto;
  width: max-content; max-width: calc(100vw - 20px);
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  display: flex; gap: 2px; padding: 6px;
  border-radius: 20px; background: var(--r-bar); color: var(--r-fg);
  box-shadow: 0 0 0 1px var(--r-rule), 0 10px 30px -8px rgb(0 0 0 / .4);
}
.selection-bar .tool, .listen-bar .tool { min-width: 0; flex: 1 1 0; }
.reader.with-big-nav .selection-bar, .reader.with-big-nav .listen-bar { bottom: calc(env(safe-area-inset-bottom) + var(--big-nav-h) + 12px); }
.listen-bar .tool-main { background: var(--r-accent); color: var(--r-on-accent); }
.swatch { width: 1.4em; height: 1.4em; border-radius: 50%; background: #F2C94C; box-shadow: inset 0 0 0 2px rgb(0 0 0 / .15); }

.link-back {
  position: absolute; z-index: 11; left: 0; right: 0; margin-inline: auto; width: max-content; max-width: calc(100vw - 32px);
  top: calc(env(safe-area-inset-top) + 12px);
  background: var(--r-accent); color: var(--r-on-accent); box-shadow: 0 6px 20px -6px rgb(0 0 0 / .5);
}
.reader-loading {
  position: absolute; inset: 0; z-index: 8;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--r-bg); color: var(--r-soft);
}
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--r-rule); border-top-color: var(--r-accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

/* ---------- Sheets ---------- */
.sheet-scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); }
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0;
  max-height: min(88dvh, 900px); display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 40px -12px rgb(0 0 0 / .35);
  padding-bottom: env(safe-area-inset-bottom);
  animation: sheet-in .24s ease-out;
}
@media (min-width: 700px) { .sheet { left: 50%; right: auto; width: 640px; transform: translateX(-50%); } }
@keyframes sheet-in { from { translate: 0 30px; opacity: 0; } }
.sheet:focus { outline: none; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 10px 8px 20px; border-bottom: 1px solid var(--rule);
}
.sheet-title { margin: 0; font-size: 1.15rem; font-weight: 700; }
.sheet-body { overflow: auto; padding: 12px 20px 24px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-body h3 { margin: 22px 0 10px; font-size: .95rem; font-weight: 700; color: var(--ink-soft); }
.sheet-body h3:first-child { margin-top: 6px; }
.sheet-body p { margin: 0 0 12px; }

/* segmented choices */
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button {
  min-height: var(--tap); padding: 0 1em; border: 0; border-radius: 12px;
  background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--rule);
  font-weight: 700;
}
.seg button[aria-pressed="true"] { background: var(--cloth); color: var(--on-cloth); box-shadow: none; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: calc(var(--tap) + 12px); height: var(--tap); border: 0; border-radius: 12px;
  background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--rule); font-weight: 700;
}
.stepper output { flex: 1; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.theme-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.theme-swatches button {
  min-height: calc(var(--tap) + 8px); border-radius: 12px; border: 0;
  box-shadow: inset 0 0 0 1.5px rgb(0 0 0 / .18); font-weight: 700; padding: 6px;
}
.theme-swatches button[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--cloth), inset 0 0 0 5px var(--surface); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; }
.switch-row .switch-text { min-width: 0; }
.switch-row .switch-text strong { display: block; }
.switch-row .switch-text span { display: block; color: var(--ink-soft); font-size: .9rem; }
.switch {
  position: relative; flex: none; width: 58px; height: 34px; border: 0; border-radius: 999px;
  background: var(--rule); padding: 0;
}
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .18s ease; }
.switch[aria-checked="true"] { background: var(--cloth); }
.switch[aria-checked="true"]::after { transform: translateX(24px); }
:root[data-older] .switch { width: 72px; height: 42px; }
:root[data-older] .switch::after { width: 36px; height: 36px; }
:root[data-older] .switch[aria-checked="true"]::after { transform: translateX(30px); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--rule); }
.list-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: var(--tap); padding: 10px 4px; border: 0; background: none; text-align: left; color: inherit;
}
.list-btn:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.list-btn[aria-current="true"] { font-weight: 700; color: var(--cloth); }
.list-btn .sub { display: block; color: var(--ink-soft); font-size: .85rem; font-weight: 400; }
.toc-depth-1 { padding-left: 18px !important; }
.toc-depth-2 { padding-left: 34px !important; }
.toc-depth-3 { padding-left: 50px !important; }

.note-item { padding: 14px 0; }
.note-item + .note-item { border-top: 1px solid var(--rule); }
.note-quote { margin: 0 0 6px; padding-left: 12px; border-left: 4px solid var(--hl, #F2C94C); font-family: var(--font-title); }
.note-text { margin: 6px 0; white-space: pre-wrap; }
.note-where { font-size: .85rem; color: var(--ink-soft); }
.note-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.note-actions .btn { min-height: 40px; padding: 0 .9em; font-size: .9rem; }
:root[data-older] .note-actions .btn { min-height: var(--tap); font-size: 1rem; }
.colors { display: flex; gap: 12px; flex-wrap: wrap; }
.colors button { width: var(--tap); height: var(--tap); border-radius: 50%; border: 0; box-shadow: inset 0 0 0 2px rgb(0 0 0 / .15); }
.colors button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--ink); }
textarea.note-input {
  width: 100%; min-height: 140px; padding: 12px; border-radius: 12px; border: 0;
  background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--rule); resize: vertical; font-size: 1rem;
}
.field { display: block; margin: 8px 0 14px; }
.field input[type="text"], .field input[type="search"], .field input[type="number"], .field input[type="password"], .field select {
  width: 100%; min-height: var(--tap); padding: 0 12px; border-radius: 12px; border: 0;
  background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--rule); font-size: 1rem;
}
.field-label { display: block; margin-bottom: 6px; font-weight: 700; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.result-btn { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 12px 2px; color: inherit; }
.result-btn mark { background: color-mix(in srgb, var(--ribbon) 45%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.results-head { margin: 14px 0 4px; font-size: .9rem; font-weight: 700; color: var(--ink-soft); }
.callout { padding: 12px 14px; border-radius: 12px; background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--rule); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 16px; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.issue-list li { padding: 10px 0; }
.issue-list strong { display: block; overflow-wrap: anywhere; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 60; left: 0; right: 0; margin-inline: auto;
  width: max-content; max-width: min(calc(100vw - 32px), 520px);
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 4px;
  padding: 14px 18px; border-radius: 14px;
  background: var(--ink); color: var(--paper); font-weight: 700;
  box-shadow: 0 10px 30px -10px rgb(0 0 0 / .5);
}
.toast { pointer-events: none; }  /* taps pass through to whatever is underneath… */
.toast .btn { pointer-events: auto; min-height: 36px; margin-left: 10px; color: var(--paper); box-shadow: inset 0 0 0 1.5px currentColor; }  /* …except its own button */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 720px) {
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .continue { grid-template-columns: 190px 1fr; }
}
