/* Reading Room. Design notes: app/DESIGN.md.
   The book is printed in ink; the reader's own marks are cobalt. */

/* ---------- fonts (self-hosted, OFL) ---------- */
@font-face {
  font-family: "Literata"; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url("/fonts/literata-latin-opsz-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Literata"; font-style: italic; font-weight: 200 900; font-display: swap;
  src: url("/fonts/literata-latin-opsz-italic.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Literata"; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url("/fonts/literata-latin-ext-opsz-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Literata"; font-style: italic; font-weight: 200 900; font-display: swap;
  src: url("/fonts/literata-latin-ext-opsz-italic.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("/fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next"; font-style: italic; font-weight: 200 800; font-display: swap;
  src: url("/fonts/atkinson-hyperlegible-next-latin-wght-italic.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("/fonts/atkinson-hyperlegible-next-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- tokens ---------- */
:root {
  --serif: "Literata", "Iowan Old Style", Georgia, serif;
  --ui: "Atkinson Hyperlegible Next", -apple-system, "Helvetica Neue", sans-serif;
  --reading-size: 18px;
  --gutter: clamp(20px, 5.6vw, 36px);
  --bar-h: 50px;
  --tab-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --paper: #F6F7F4;
  --paper-2: #ECEEE9;
  --ink: #1C1F2B;
  --ink-2: #545A69;
  --rule: #D8DBD3;
  --rule-strong: #A9AEB5;
  --mark: #2F4E9E;
  --mark-wash: rgba(47, 78, 158, 0.12);
  --scrim: rgba(28, 31, 43, 0.32);
  --body-weight: 400;
  color-scheme: light;
}
:root[data-theme="sepia"] {
  --paper: #F2EADB; --paper-2: #E8DECB; --ink: #33291D; --ink-2: #6B5B47;
  --rule: #D6C8AE; --rule-strong: #A8977D; --mark: #2D4B86; --mark-wash: rgba(45, 75, 134, 0.12);
  --scrim: rgba(51, 41, 29, 0.32);
}
:root[data-theme="dark"] {
  --paper: #191B21; --paper-2: #23262E; --ink: #E2DFD6; --ink-2: #A3A39F;
  --rule: #30333B; --rule-strong: #5A5E68; --mark: #9BB1EC; --mark-wash: rgba(155, 177, 236, 0.16);
  --scrim: rgba(0, 0, 0, 0.5); --body-weight: 380;
  color-scheme: dark;
}
:root[data-theme="eink"] {
  --paper: #FFFFFF; --paper-2: #FFFFFF; --ink: #000000; --ink-2: #1A1A1A;
  --rule: #000000; --rule-strong: #000000; --mark: #000000; --mark-wash: transparent;
  --scrim: transparent; --body-weight: 450;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--paper); }
body {
  margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink);
  font: 15px/1.45 var(--ui); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--mark); outline-offset: 2px; border-radius: 3px; }
[hidden] { display: none !important; }
h1, h2, h3, p, ul, ol, blockquote, figure { margin: 0; }
ul, ol { padding: 0; }

.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- page frame ---------- */
#view:focus { outline: none; }
.page {
  max-width: calc(38rem + 2 * var(--gutter));
  margin: 0 auto;
  padding: calc(var(--safe-top) + 16px) var(--gutter) calc(var(--tab-h) + var(--safe-bottom) + 48px);
}
.page__head { margin: 22px 0 18px; }
.page__title { font: 560 34px/1.08 var(--serif); letter-spacing: -0.012em; }
.page__title--long { font-size: clamp(28px, 7.4vw, 36px); text-wrap: balance; }
.page__lede { margin-top: 10px; font: italic 400 17px/1.45 var(--serif); color: var(--ink-2); max-width: 32em; }
.back-link { display: inline-flex; align-items: center; gap: 2px; margin-left: -6px; padding: 6px 6px 6px 0; color: var(--mark); font-weight: 600; text-decoration: none; }
.fine-print { margin-top: 28px; font-size: 13px; color: var(--ink-2); }

/* ---------- tab bar ---------- */
#tabs {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: flex; height: calc(var(--tab-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  -webkit-backdrop-filter: saturate(1.3) blur(16px); backdrop-filter: saturate(1.3) blur(16px);
  border-top: 1px solid var(--rule);
}
.tab {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-2); text-decoration: none; font: 600 11px/1 var(--ui); letter-spacing: 0.01em;
}
.tab .icon { width: 25px; height: 25px; stroke-width: 1.5; }
.tab.is-active { color: var(--mark); }
.tab.is-active .icon { stroke-width: 1.9; }
.tab__badge {
  position: absolute; top: 5px; left: calc(50% + 7px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px;
  background: var(--mark); color: var(--paper); font: 700 11px/17px var(--ui); text-align: center;
}

/* ---------- shared controls ---------- */
.icon-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 2px; min-width: 44px; height: 44px;
  margin: 0; padding: 0 6px; border: 0; background: none; color: var(--mark); border-radius: 10px; text-decoration: none; font-weight: 600;
}
.text-button {
  border: 0; background: none; padding: 10px 2px; color: var(--ink); font-weight: 600; font-size: 15.5px;
  text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 4px;
}
.text-button.is-primary { color: var(--mark); text-decoration-color: currentColor; }
.text-button.is-danger { color: var(--ink-2); }
.text-link { display: inline-block; margin-top: 4px; color: var(--mark); font-weight: 600; text-underline-offset: 4px; }

/* the table-of-contents line: label ........ meta */
.leader-button {
  display: flex; align-items: baseline; gap: 10px; width: 100%; margin: 26px 0 0; padding: 15px 0 14px;
  border: 0; border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); background: none;
  color: var(--mark); text-decoration: none; text-align: left; font: 650 16.5px/1.2 var(--ui);
}
.leader-button + .leader-button { margin-top: 0; border-top: 0; }
.leader-button { position: relative; }
/* doubled class: must beat .progress__fill's height: 100% */
.leader-button .leader-button__progress { position: absolute; left: 0; bottom: -1.5px; height: 3px; width: 0; background: var(--mark); }
.leader-button:disabled { color: var(--ink-2); cursor: default; }
.leader-button__dots { flex: 1; min-width: 12px; border-bottom: 2px dotted var(--rule-strong); transform: translateY(-4px); }
.leader-button__meta { color: var(--ink-2); font-weight: 500; font-size: 14.5px; white-space: nowrap; }
.leader-button--solid {
  justify-content: center; border: 0; border-radius: 12px; background: var(--ink); color: var(--paper); padding: 16px;
}
.leader-button--solid .leader-button__dots, .leader-button--solid .leader-button__meta { display: none; }

.progress { height: 3px; margin-top: 10px; background: var(--rule); border-radius: 2px; overflow: hidden; }
.progress--thin { display: block; height: 2px; margin-top: 10px; max-width: 12rem; }
.progress__fill { display: block; height: 100%; width: 0; background: var(--mark); }

.empty { padding: 18vh 0 0; }
.empty--inline { padding: 24px 0; color: var(--ink-2); }
.empty__title { font: 520 30px/1.15 var(--serif); margin-bottom: 12px; }
.empty p { font: 17px/1.5 var(--serif); color: var(--ink-2); }

.plain-list { list-style: none; }
.row-link { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 11px 0; text-decoration: none; border-bottom: 1px solid var(--rule); }
.row-link__title { font: 450 17px/1.3 var(--serif); }
.row-link__meta { flex: none; font-size: 13px; font-weight: 600; color: var(--mark); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-bottom) + 16px); z-index: 60;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  padding: 10px 16px; border-radius: 10px; background: var(--ink); color: var(--paper); font-weight: 600; font-size: 14.5px;
  transition: opacity 160ms ease, transform 160ms ease;
}
#toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
body.is-reading #toast { bottom: calc(var(--safe-bottom) + 72px); }

/* ---------- Today: the title page ---------- */
.today__bar { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.today__date { font-weight: 600; font-size: 14px; color: var(--ink-2); }
.today__bar .icon-button { margin-right: -10px; }
.title-page { padding-top: clamp(28px, 10vh, 110px); }
.title-page__reason { font: italic 400 17px/1.4 var(--serif); color: var(--ink-2); }
.title-page__title {
  margin-top: 14px;
  font: 470 clamp(40px, 11.4vw, 66px)/1.02 var(--serif); letter-spacing: -0.016em;
  text-wrap: balance; font-optical-sizing: auto; hyphens: manual;
}
.title-page__title a { text-decoration: none; }
.title-page__byline { margin-top: 16px; font: italic 420 19px/1.3 var(--serif); }
.title-page__why { margin-top: 22px; font: 400 19.5px/1.5 var(--serif); color: var(--ink); max-width: 30em; text-wrap: pretty; }
.title-page__imprint { margin-top: 28px; padding-top: 10px; font-size: 13px; color: var(--ink-2); border-top: 1px solid var(--rule); width: fit-content; min-width: 5rem; }

.aside { margin-top: 52px; }
.aside__title { font: 650 13.5px/1.3 var(--ui); color: var(--ink-2); margin-bottom: 12px; }
.aside p { font: 16px/1.5 var(--serif); color: var(--ink-2); }
.claim {
  font: italic 400 21px/1.42 var(--serif); hanging-punctuation: first; text-wrap: pretty;
}
.claim::before { content: "\201C"; }
.claim::after { content: "\201D"; }
.claim--excerpt { font-style: normal; font-size: 18.5px; }
.aside__source { margin-top: 12px; }
.aside__source a { color: var(--mark); text-underline-offset: 3px; }
.today__foot { margin-top: 56px; padding-top: 14px; border-top: 1px solid var(--rule); color: var(--ink-2); font-size: 14px; }
.today__foot p + p { margin-top: 6px; }
.today__foot a { color: var(--mark); font-weight: 600; }

/* ---------- Library ---------- */
.search {
  display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; border-radius: 11px;
  background: var(--paper-2); color: var(--ink-2);
}
.search .icon { width: 18px; height: 18px; }
.search__input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 16px; color: var(--ink); -webkit-appearance: none; appearance: none; }
.search__input::placeholder { color: var(--ink-2); opacity: 0.8; }
.search:focus-within { outline: 2px solid var(--mark); outline-offset: 1px; }

.chips, .segments {
  display: flex; gap: 22px; overflow-x: auto; margin: 16px calc(-1 * var(--gutter)) 0; padding: 0 var(--gutter);
  scrollbar-width: none; border-bottom: 1px solid var(--rule);
}
.chips::-webkit-scrollbar, .segments::-webkit-scrollbar { display: none; }
.chip, .segment {
  flex: none; padding: 10px 0 11px; border: 0; border-bottom: 2.5px solid transparent; margin-bottom: -1px;
  background: none; font-weight: 600; font-size: 15px; color: var(--ink-2); white-space: nowrap;
}
.chip.is-active, .segment.is-active { color: var(--ink); border-bottom-color: var(--mark); }

.filters { display: flex; gap: 10px; margin-top: 14px; }
.filters .select { flex: 1 1 0; min-width: 0; text-overflow: ellipsis; }
.library__summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; }
.select {
  -webkit-appearance: none; appearance: none; padding: 7px 28px 7px 11px; border: 0; border-radius: 9px;
  background: var(--paper-2) no-repeat right 9px center / 10px 6px; font-size: 14px; font-weight: 600; color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23777' stroke-width='1.5'/%3E%3C/svg%3E");
}
.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; padding: 6px 2px; }
.toggle__input { width: 18px; height: 18px; margin: 0; accent-color: var(--mark); }
.library__count { font-size: 13px; color: var(--ink-2); }

.shelf + .shelf { margin-top: 12px; }
.shelf__title { margin: 34px 0 14px; font: italic 430 27px/1.15 var(--serif); }
.shelf__count { font: normal 600 13px var(--ui); color: var(--ink-2); vertical-align: 3px; }
.library__list > .shelf:first-child .shelf__title { margin-top: 26px; }
.entries { list-style: none; }
.shelf > .entries:first-child { margin-top: 24px; }
.entry + .entry { margin-top: 20px; }
.entry__link { display: flex; gap: 12px; text-decoration: none; }
.entry__body { display: block; min-width: 0; }
.entry__title { display: block; font: 480 19px/1.27 var(--serif); text-wrap: pretty; }
.entry.is-core .entry__title { font-weight: 640; }
.entry.is-minor .entry__title { font-weight: 400; color: var(--ink-2); }
.entry__byline { display: block; margin-top: 4px; font-size: 13.5px; color: var(--ink-2); }
.entry__why {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 5px; font: 15.5px/1.42 var(--serif); color: var(--ink-2);
}
.entry__number { flex: none; width: 1.6em; font: 500 17px/1.45 var(--serif); color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
.entries--compact .entry + .entry { margin-top: 14px; }
.entries--compact .entry__title { font-size: 17px; }
.status { font-weight: 650; white-space: nowrap; }
.status .icon { width: 14px; height: 14px; vertical-align: -2px; margin-right: 2px; stroke-width: 2.2; }
.status--reading, .status--done { color: var(--mark); }

/* ---------- Paths: tables of contents ---------- */
.contents { list-style: none; margin-top: 8px; }
.contents__entry + .contents__entry { border-top: 1px solid var(--rule); }
.contents__link { display: flex; gap: 14px; padding: 16px 0; text-decoration: none; }
.contents__number { flex: none; width: 1.7em; font: 500 20px/1.25 var(--serif); color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
.contents__number .icon { width: 20px; height: 20px; color: var(--mark); stroke-width: 2.2; }
.contents__body { display: block; flex: 1; min-width: 0; }
.contents__title { font: 520 21px/1.25 var(--serif); text-wrap: pretty; }
.contents__desc { display: block; margin-top: 5px; font: italic 15.5px/1.42 var(--serif); color: var(--ink-2); }
.contents__meta { display: block; margin-top: 5px; font-size: 13.5px; color: var(--ink-2); }
.contents__entry.is-current .contents__title { text-decoration: underline 2px var(--mark); text-underline-offset: 5px; }
/* leaders sit on the title's last line, as in a printed table of contents */
.contents--items .contents__line { display: flex; align-items: flex-end; gap: 6px; }
.contents--items .contents__title { flex: 0 1 auto; }
.contents--items .contents__title { font-size: 18.5px; font-weight: 480; }
.contents__dots { flex: 1 1 0; min-width: 1.6em; margin-bottom: 7px; border-bottom: 2px dotted var(--rule-strong); }
.contents__minutes { flex: none; font-size: 13.5px; line-height: 23px; color: var(--ink-2); white-space: nowrap; }
.contents__entry.is-done .contents__title { color: var(--ink-2); }
.contents__entry.is-next .contents__number { color: var(--mark); font-weight: 700; }
.path .leader-button { margin: 4px 0 18px; }

/* ---------- Map ---------- */
.map-section { margin-top: 22px; }
.school { margin-top: 38px; }
.school__name { font: 560 25px/1.15 var(--serif); }
.school__desc { margin-top: 6px; font-size: 14px; color: var(--ink-2); }
.school__exemplars { margin: 6px 0 16px; font: italic 15.5px/1.45 var(--serif); color: var(--ink-2); }
.lenses { margin-top: 8px; }
.lenses .shelf__title { margin-top: 18px; }

.debates { list-style: none; }
.debate { margin-top: 26px; padding-left: 16px; border-left: 2px solid var(--rule-strong); }
.debate__piece { display: block; text-decoration: none; }
.debate__title { display: block; font: 520 18.5px/1.28 var(--serif); }
.debate__byline { display: block; margin-top: 3px; font-size: 13.5px; color: var(--ink-2); }
.debate__relation { margin: 8px 0; font: italic 15px var(--serif); color: var(--mark); }

.ledger { list-style: none; }
.ledger__entry { margin-top: 26px; padding-left: 16px; border-left: 3px dotted var(--rule-strong); }
.ledger__entry.is-hit, .ledger__entry.is-on-track { border-left-style: solid; border-left-color: var(--mark); }
.ledger__entry.is-missed { border-left-style: double; border-left-width: 4px; border-left-color: var(--ink); }
.ledger__entry.is-ambiguous { border-left-style: dashed; }
.ledger__claim { font: 400 18px/1.45 var(--serif); text-wrap: pretty; }
.ledger__who { margin-top: 6px; font-size: 13.5px; color: var(--ink-2); }
.ledger__who a { color: inherit; }
.ledger__status { margin-top: 4px; font-size: 13.5px; }
.ledger__verdict { font-weight: 700; }
.ledger__entry.is-missed .ledger__verdict { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.ledger__note { color: var(--ink-2); }
.ledger__status a { color: var(--mark); font-weight: 600; }

/* ---------- Inbox ---------- */
.inbox__list { margin-top: 26px; }
.inbox__entry { padding-bottom: 16px; border-bottom: 1px solid var(--rule); }
.inbox__actions { display: flex; gap: 22px; margin-top: 8px; padding-left: 0; }

/* ---------- sheets ---------- */
#sheet-root .sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: var(--scrim); opacity: 0; transition: opacity 200ms ease; }
#sheet-root .sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 86dvh; overflow-y: auto;
  max-width: 40rem; margin: 0 auto; padding: 6px var(--gutter) calc(var(--safe-bottom) + 24px);
  background: var(--paper); border-radius: 18px 18px 0 0; transform: translateY(102%); transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 -1px 0 var(--rule);
}
#sheet-root.is-open .sheet-backdrop { opacity: 1; }
#sheet-root.is-open .sheet { transform: none; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.sheet__title { font: 560 21px/1.2 var(--serif); }
.sheet__head .icon-button { margin-right: -10px; color: var(--ink-2); }
.sheet__actions { display: flex; flex-wrap: wrap; gap: 6px 24px; margin-top: 12px; }
.sheet__actions--stack { margin-top: 18px; }
.more .leader-button:first-child { margin-top: 4px; }
.more__highlights { margin-top: 22px; }
.quote-button { display: block; width: 100%; padding: 12px 0; border: 0; border-bottom: 1px solid var(--rule); background: none; text-align: left; font: italic 16px/1.45 var(--serif); }
.quote-button__note { display: block; margin-top: 4px; font: normal 600 13.5px/1.4 var(--ui); color: var(--mark); }

.choice { margin: 0 0 24px; padding: 0; border: 0; }
.choice__legend { padding: 0; margin-bottom: 8px; font-weight: 650; font-size: 13.5px; color: var(--ink-2); }
.choice__option { display: flex; align-items: center; gap: 12px; min-height: 44px; border-bottom: 1px solid var(--rule); font: 450 17px var(--serif); }
.choice__option input { width: 19px; height: 19px; margin: 0; accent-color: var(--mark); }
.stepper { display: flex; align-items: center; gap: 18px; }
.stepper__button { width: 52px; height: 44px; border: 1.5px solid var(--ink); border-radius: 10px; background: none; font: 500 16px var(--serif); }
.stepper__button--large { font-size: 24px; }
.stepper__value { min-width: 4em; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.settings .reading-controls { margin-top: 8px; }
.settings > .text-button { margin-top: 32px; }

.note__quote { margin-bottom: 14px; padding-left: 14px; border-left: 2px solid var(--mark); font: italic 17px/1.5 var(--serif); }
.note__input { width: 100%; padding: 12px; border: 1.5px solid var(--rule-strong); border-radius: 10px; background: var(--paper-2); font: 16px/1.45 var(--serif); resize: vertical; }

/* ---------- Reader ---------- */
body.is-reading { --tab-h: 0px; }
.reader__bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; height: calc(var(--bar-h) + var(--safe-top)); padding: var(--safe-top) 8px 0;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.reader__back span { font-size: 16px; }
.reader__bar-spacer { flex: 1; }
.reader__progress { position: fixed; top: calc(var(--bar-h) + var(--safe-top)); left: 0; right: 0; z-index: 30; height: 2px; background: var(--rule); }
.reader__progress-fill { display: block; height: 100%; width: 0; background: var(--mark); }

.reader__page {
  max-width: calc(34em + 2 * var(--gutter)); margin: 0 auto;
  padding: calc(var(--bar-h) + var(--safe-top) + 30px) var(--gutter) calc(var(--safe-bottom) + 120px);
  font-size: var(--reading-size);
}
.reader__title { font: 520 clamp(30px, 8.2vw, 46px)/1.07 var(--serif); letter-spacing: -0.012em; text-wrap: balance; }
.reader__byline { margin-top: 14px; font: italic 420 18px/1.35 var(--serif); }
.reader__meta { margin-top: 6px; font: 13.5px/1.4 var(--ui); color: var(--ink-2); }
.reader__meta:first-letter { text-transform: uppercase; }

.before { margin: 26px 0 30px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.before__summary {
  display: flex; justify-content: space-between; align-items: center; min-height: 48px; list-style: none;
  font: 650 15px var(--ui); color: var(--mark); cursor: pointer;
}
.before__summary::-webkit-details-marker { display: none; }
.before__summary::after { content: "Show"; font-weight: 500; color: var(--ink-2); font-size: 13.5px; }
.before[open] .before__summary::after { content: "Hide"; }
.before__body { padding: 0 0 18px; font: 16.5px/1.52 var(--serif); color: var(--ink-2); }
.before__body > * + * { margin-top: 10px; }
.before__why { color: var(--ink); font-size: 17.5px; }
.before__label { margin-top: 18px !important; font: 650 13px var(--ui); color: var(--ink-2); }
.before__claims { padding-left: 1.1em; }
.before__claims li + li { margin-top: 6px; }

.prose {
  font: var(--body-weight) 1em/1.62 var(--serif); font-optical-sizing: auto;
  hyphens: auto; -webkit-hyphens: auto; text-wrap: pretty; hanging-punctuation: first;
  overflow-wrap: break-word;
}
.prose p { margin: 0 0 0.95em; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-weight: 600; line-height: 1.25; margin: 1.7em 0 0.6em; break-after: avoid; text-wrap: balance; hyphens: manual; }
.prose h1 { font-size: 1.4em; }
.prose h2 { font-size: 1.24em; }
.prose h3 { font-size: 1.08em; }
.prose h4, .prose h5, .prose h6 { font-size: 1em; font-style: italic; }
.prose a { color: inherit; text-decoration: underline; text-decoration-color: var(--rule-strong); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
.prose blockquote { margin: 1.2em 0; padding-left: 1em; border-left: 2px solid var(--rule-strong); color: var(--ink-2); }
.prose ul, .prose ol { margin: 0 0 1em; padding-left: 1.3em; }
.prose li + li { margin-top: 0.35em; }
.prose hr { margin: 2em 0; border: 0; text-align: center; color: var(--ink-2); }
.prose hr::before { content: "\2042"; font-size: 1.1em; }
.prose code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.84em; background: var(--paper-2); padding: 0.08em 0.3em; border-radius: 4px; }
.prose pre { overflow-x: auto; padding: 0.9em 1em; background: var(--paper-2); border-radius: 8px; font-size: 0.82em; line-height: 1.5; }
.prose pre code { background: none; padding: 0; }
.prose table { display: block; overflow-x: auto; border-collapse: collapse; margin: 1.2em 0; font-size: 0.82em; font-family: var(--ui); }
.prose th, .prose td { padding: 6px 10px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.prose figcaption { font-size: 0.82em; color: var(--ink-2); font-family: var(--ui); }
.prose mark.hl {
  background: var(--mark-wash); color: inherit; border-radius: 2px; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--mark); text-decoration-thickness: 2px; text-underline-offset: 0.22em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.prose::selection, .prose *::selection { background: var(--mark-wash); }

.access { margin: 10px 0 0; }
.access__note { font: 17px/1.5 var(--serif); color: var(--ink-2); margin-bottom: 4px; }

.reader__end { margin-top: 3.2em; font-size: 15px; }
.relations { margin-top: 38px; }
.relations__title { margin-bottom: 12px; font: italic 430 21px/1.2 var(--serif); }
.reader__source { margin-top: 40px; font-size: 13px; color: var(--ink-2); }
.reader__source a { color: inherit; }
.reader__pager {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; padding: 8px 0 calc(var(--safe-bottom) + 10px);
  text-align: center; font-size: 12.5px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums;
}

.selection-bar {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 18px); z-index: 35; transform: translateX(-50%);
  display: flex; overflow: hidden; border-radius: 13px; background: var(--ink); color: var(--paper);
}
.selection-bar__button { border: 0; background: none; color: inherit; padding: 13px 18px; font-weight: 650; font-size: 15px; white-space: nowrap; }
.selection-bar__button + .selection-bar__button { border-left: 1px solid color-mix(in srgb, var(--paper) 25%, transparent); }

/* paged layout: CSS columns, one screen per column, turned by JS */
:root[data-layout="pages"] body.is-reading { height: 100dvh; overflow: hidden; }
:root[data-layout="pages"] .reader__page {
  position: fixed; left: 0; right: 0; margin: 0 auto;
  top: calc(var(--bar-h) + var(--safe-top) + 2px); bottom: calc(var(--safe-bottom) + 38px);
  width: min(100vw, calc(34em + 2 * var(--gutter))); max-width: none;
  padding: 26px var(--gutter) 0;
  column-width: calc(min(100vw, calc(34em + 2 * var(--gutter))) - 2 * var(--gutter));
  column-gap: calc(2 * var(--gutter)); column-fill: auto;
  overflow: hidden;
}
:root[data-layout="pages"] .reader__end { break-before: column; }
:root[data-layout="pages"] .reader--lens .reader__page { position: static; columns: auto; overflow: visible; width: auto; max-width: calc(34em + 2 * var(--gutter)); padding-top: calc(var(--bar-h) + var(--safe-top) + 30px); }

/* ---------- login ---------- */
.login { padding-top: calc(var(--safe-top) + 18vh); }
.login__title { font: 470 clamp(44px, 13vw, 64px)/1 var(--serif); letter-spacing: -0.016em; }
.login__lede { margin-top: 14px; font: italic 18px/1.45 var(--serif); color: var(--ink-2); max-width: 22em; }
.login__form { margin-top: 40px; max-width: 22rem; }
.login__label { display: block; margin-bottom: 8px; font-weight: 650; font-size: 13.5px; color: var(--ink-2); }
.login__input { width: 100%; height: 50px; padding: 0 14px; border: 1.5px solid var(--rule-strong); border-radius: 12px; background: var(--paper-2); font-size: 17px; }
.login__input:focus { outline: 2px solid var(--mark); outline-offset: 1px; border-color: transparent; }
.login__form .leader-button { margin-top: 14px; }
.login__error { min-height: 1.5em; margin-top: 12px; font-weight: 600; color: var(--ink); }

/* ---------- e-ink: black on white, no motion, nothing that needs colour ---------- */
:root[data-theme="eink"] *, :root[data-theme="eink"] *::before, :root[data-theme="eink"] *::after { transition: none !important; animation: none !important; }
:root[data-theme="eink"] #tabs, :root[data-theme="eink"] .reader__bar { background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; border-color: #000; }
:root[data-theme="eink"] .reader__bar { border-bottom: 2px solid #000; }
:root[data-theme="eink"] #tabs { border-top-width: 2px; }
:root[data-theme="eink"] .tab.is-active .tab__label { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; font-weight: 800; }
:root[data-theme="eink"] .tab__badge { background: #000; color: #fff; }
:root[data-theme="eink"] .prose mark.hl { background: none; text-decoration-thickness: 2.5px; }
:root[data-theme="eink"] .search, :root[data-theme="eink"] .select, :root[data-theme="eink"] .note__input, :root[data-theme="eink"] .login__input { border: 1.5px solid #000; }
:root[data-theme="eink"] #sheet-root .sheet { border-top: 2px solid #000; box-shadow: none; }
:root[data-theme="eink"] .entry__why, :root[data-theme="eink"] .before__body { color: #000; }
:root[data-theme="eink"] .chip.is-active, :root[data-theme="eink"] .segment.is-active { border-bottom-width: 3px; font-weight: 800; }
:root[data-theme="eink"] .progress, :root[data-theme="eink"] .reader__progress { background: #fff; border-bottom: 1px solid #000; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
@media (min-width: 760px) {
  .page__title { font-size: 40px; }
  .title-page__why { font-size: 21px; }
}
