/* ============================================================
   Litheca — "Serious reading room"
   See PRODUCT.md for the strategy this implements.

   Replaces "Direction B: Precision White" (Inter + coral #ff5b4f +
   uniform 8px radii), which was the textbook AI-default stack and read
   as generic. What changed and why:

     TYPE   Literata (reading text + headings) and Archivo (UI, labels,
            numerals). Inter is gone. One flat scale became a real one
            with >=1.25 between steps — the old page used six sizes
            spanning only 1.8:1, which is what made it feel monotonous.
     COLOR  Cool off-white paper and warm near-black ink. Pure black on
            pure white is a screen convention, not a paper one.
            --library-green is the ONE bold accent and is rationed: the
            primary CTA and the statement band, nothing else. Brass is
            the quiet secondary. Deliberately NOT cream + terracotta,
            the cliché every book site reaches for first.
     FORM   Radii are near-flat (3px). The old uniform 8px pill-rounding
            on every card was a template tell.

   Accent discipline: if you are about to use --library-green on a third
   kind of element, use --brass or ink instead. Spread evenly, it stops
   reading as emphasis.
   ============================================================ */

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --bg:           #F7F6F3;  /* paper, cool off-white */
  --bg-subtle:    #EFEDE7;
  --fg:           #181C1A;  /* ink, warm near-black */
  --fg-muted:     #4A524D;
  /* Both of these were set by eye and measured 3.29:1 and 2.99:1 against
     the panel surface — below the 4.5:1 AA floor for normal text, and
     used site-wide for secondary copy, star ratings and badges. Darkened
     until they measure above it on --bg-subtle, the harder of the two
     grounds. Verified in-browser, not by eye. */
  --fg-faint:     #61685F;
  --accent:       #2F4A3C;  /* library green — the one bold accent */
  --accent-bg:    #E7ECE7;
  --accent-hover: #24382D;
  --brass:        #7F5E33;  /* quiet secondary */
  --blue:         #2F4A3C;  /* links inherit the green; no stray 4th hue */
  --blue-bg:      #E7ECE7;
  --surface:      #EFEDE7;
  --border:       #DFDCD4;
  --border-med:   #C4C0B6;
  --rule:         #181C1A;  /* hairline rules read as ink, not as chrome */

  --font: 'Literata', Georgia, 'Times New Roman', serif;
  --font-ui: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI',
             Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  /* Type scale — every step >=1.25 from the last. Five sizes doing real
     work beats eight that all look alike; the old scale spanned 1.8:1
     across six sizes and impeccable flagged it as a flat hierarchy.
     13 → 17 → 22 → 33 → 52 (1.31, 1.29, 1.50, 1.58) */
  --t-label: 13px;
  --t-body:  17px;
  --t-lead:  22px;
  --t-title: 33px;
  --t-hero:  clamp(40px, 6vw, 52px);

  /* Product-surface steps (account, library, tools). Authenticated UI is
     a different register from the marketing pages: it carries far more
     type elements, so the wide brand ratio above turns into noise there.
     Fixed px rather than clamp — a heading that shrinks inside a panel
     looks worse, not better — and a tighter ~1.15-1.2 progression.
     13 -> 15 -> 18 -> 22 */
  --ui-sm:    13px;
  --ui-body:  15px;
  --ui-head:  18px;
  --ui-title: 22px;

  /* Semantic state colours. Previously each surface hardcoded its own
     (#f5a623 here, #d33 there), which is how a product UI ends up with
     three different reds. */
  --danger:      #A3342A;
  --danger-bg:   #F7E9E7;
  --warn:        #A9824F;
  --warn-bg:     #F6EFE4;
  --success:     #2F6B4F;
  --border-subtle: #E8E5DD;  /* was referenced but never defined */

  /* Near-flat. The old 8px-on-everything was the template tell. */
  --r:    3px;
  --r-sm: 2px;
  --r-lg: 4px;

  --container: 1120px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  /* Weighted curve for anything that moves; linear/ease-in-out read as
     default-CSS. Motion here is restrained by intent, not by neglect. */
  --ease-out: cubic-bezier(0.32, 0.72, 0, 1);
}

/* ── Base ────────────────────────────────────────────────── */
body {
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--fg); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3, h4 {
  color: var(--fg);
  line-height: 1.15;
  /* Literata is a text face: it does not need the tight tracking a
     grotesk display setting wants, and negative tracking muddies it. */
  letter-spacing: -0.01em;
  font-weight: 600;
}

/* Anything that is interface rather than reading matter: nav, labels,
   buttons, numerals, metadata. The two-family split is the point. */
.u-ui, button, input, select, textarea,
.site-header, .site-footer { font-family: var(--font-ui); }

/* Small caps-y label. One kicker can be voice; repeating it above every
   section is AI scaffolding, so this is used sparingly and on purpose. */
.u-label {
  font-family: var(--font-ui);
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

img { display: block; max-width: 100%; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ── Container ───────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #F7F6F3;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  padding: 11px 20px;
  font-family: var(--font-ui);
  font-size: var(--t-label);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s var(--ease-out), border-color 0.2s var(--ease-out);
  white-space: nowrap;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #F7F6F3;
  text-decoration: none;
}
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn-primary:hover { color: #12160F; }

.btn-sm { padding: 8px 15px; font-size: var(--t-label); }

/* Keyboard focus has to survive a redesign. */
a:focus-visible, button:focus-visible,
input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
html[data-theme="dark"] a:focus-visible,
html[data-theme="dark"] button:focus-visible,
html[data-theme="dark"] input:focus-visible { outline-color: var(--accent); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border-med);
  border-radius: var(--r-sm);
  padding: 9px 18px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover {
  border-color: var(--fg);
  color: var(--fg);
  text-decoration: none;
}

/* ── HEADER ──────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  /* Tinted to the paper, not white. This was rgba(255,255,255,.92) from
     the era when --bg actually was #ffffff; against the warmer paper it
     left a visible seam under the header on every page. */
  background: rgba(247, 246, 243, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  height: 56px;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 100%;
}

/* Logo */
.site-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}
.site-logo:hover { text-decoration: none; }
.logo-mark { display: block; flex-shrink: 0; }
.logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.03em;
  line-height: 1;
}

/* Nav links */
.site-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover {
  color: var(--fg);
  background: var(--bg-subtle);
  text-decoration: none;
}
.nav-link.active { color: var(--fg); }

.header-right { margin-left: auto; }

/* Hamburger */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-left: auto;
}
.hamburger-line {
  display: block;
  width: 20px; height: 1.5px;
  background: var(--fg);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

/* ── HERO ────────────────────────────────────────────────── */
/* ── HERO ────────────────────────────────────────────────────
   Was: a 4-metric SaaS status strip, a gradient, tick-mark feature
   pills, and a scrolling cover marquee. That is four components
   competing for one fold, and the marquee was the first of three on
   the page. Now: a thesis headline, the search (the primary CTA), and
   a still shelf of real covers as the imagery.
   ──────────────────────────────────────────────────────────── */
.hero {
  border-bottom: 1px solid var(--rule);
  padding: clamp(48px, 8vw, 96px) 0 clamp(40px, 6vw, 72px);
}

/* Asymmetric: the text column carries the fold, the shelf supports it.
   Deliberately not 50/50 — an even split has no focal point. */
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(32px, 5vw, 72px);
  align-items: center;
}

.hero-body { max-width: 40rem; }

.hero-kicker { display: block; margin-bottom: 20px; }

.hero-heading {
  font-size: var(--t-hero);
  font-weight: 600;
  color: var(--fg);
  line-height: 1.08;
  letter-spacing: -0.015em;
  margin-bottom: 20px;
  text-wrap: balance;
}
/* The one italic on the page, on the one word the thesis turns on. */
.hero-heading em {
  font-style: italic;
  font-weight: 600;
}

.hero-sub {
  font-size: var(--t-lead);
  color: var(--fg-muted);
  line-height: 1.5;
  margin-bottom: 36px;
  max-width: 34rem;
}

/* ── The shelf: real covers, held still ──────────────────────
   Books stood on a shelf, slightly overlapping. Static by choice —
   this is the proof-of-coverage the marquee was making, without a
   third moving rail. */
.hero-shelf { position: relative; padding-bottom: 14px; }
.hero-shelf-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.hero-shelf img {
  width: clamp(72px, 9.5vw, 116px);
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: var(--bg-subtle);
  border: 1px solid var(--border-med);
  margin-right: -14px;
  box-shadow: 0 10px 24px -12px rgba(24, 28, 26, 0.45);
  transition: transform 0.4s var(--ease-out);
}
.hero-shelf img:last-child { margin-right: 0; }
/* Spines lean as they would on a real shelf; the outer books lean out. */
.hero-shelf img:nth-child(1) { transform: rotate(-2.5deg) translateY(3px); }
.hero-shelf img:nth-child(2) { transform: rotate(-1deg); }
.hero-shelf img:nth-child(3) { transform: translateY(-6px); z-index: 2; }
.hero-shelf img:nth-child(4) { transform: rotate(1deg); }
.hero-shelf img:nth-child(5) { transform: rotate(2.5deg) translateY(3px); }
/* The shelf itself. */
.hero-shelf::after {
  content: "";
  position: absolute;
  left: 4%; right: 4%; bottom: 0;
  height: 1px;
  background: var(--rule);
}

/* ── Search: the primary CTA ─────────────────────────────────
   Underlined rather than boxed. A ruled line reads as something to
   write on, which is the action being asked for, and it keeps the
   green for the button alone. */
.hero-search {
  display: flex;
  align-items: stretch;
  max-width: 34rem;
  border-bottom: 2px solid var(--rule);
  background: transparent;
  transition: border-color 0.2s var(--ease-out);
  margin-bottom: 20px;
}
.hero-search:focus-within { border-bottom-color: var(--accent); }
.hero-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: var(--t-lead);
  color: var(--fg);
  padding: 6px 4px 12px;
  outline: none;
  min-width: 0;
}
.hero-search-input::placeholder {
  color: var(--fg-faint);
  font-style: italic;
}
/* The input's own focus ring is redundant with the rule turning green. */
.hero-search-input:focus-visible { outline: none; }
.hero-search-btn {
  font-family: var(--font-ui);
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #F7F6F3;
  background: var(--accent);
  border: none;
  padding: 12px 22px;
  margin: 0 0 8px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s var(--ease-out);
  flex-shrink: 0;
  align-self: flex-end;
}
.hero-search-btn:hover { background: var(--accent-hover); }
html[data-theme="dark"] .hero-search-btn { color: #12160F; }

/* What every guide includes. Same content the tick-mark pills carried,
   set as one line of running text so it informs without adding seven
   more bordered objects to the fold. */
.hero-includes {
  font-family: var(--font-ui);
  font-size: var(--t-label);
  line-height: 1.7;
  color: var(--fg-muted);
  margin-bottom: 18px;
  max-width: 34rem;
}
.hero-includes-label {
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-right: 10px;
}

/* The colophon line: the old status strip's facts, one rule, no bars. */
.hero-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px clamp(24px, 4vw, 52px);
  list-style: none;
  margin-top: clamp(40px, 5vw, 64px);
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: var(--t-label);
  color: var(--fg-muted);
}
.hero-facts b {
  font-weight: 600;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

/* Quick-pick tags — set as running text, not as chips. A row of
   pill-shaped buttons was more chrome than four book titles need. */
.hero-picks {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-family: var(--font-ui);
  font-size: var(--t-label);
}
.picks-label {
  color: var(--fg-faint);
  font-weight: 500;
}
.pick-tag {
  font-family: var(--font-ui);
  font-size: var(--t-label);
  font-weight: 500;
  color: var(--fg-muted);
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-med);
  border-radius: 0;
  padding: 2px 0;
  cursor: pointer;
  transition: color 0.2s var(--ease-out), border-color 0.2s var(--ease-out);
}
.pick-tag:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: none;
}

/* ── TOOLS SECTION ───────────────────────────────────────── */
.tools-section {
  padding: clamp(48px, 6vw, 72px) 0 0;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 0;
  gap: 16px;
}
/* Section titles were 15px while the hero was 56px: a big jump with
   nothing in between, so the page had two sizes rather than a scale.
   These now sit at a real step on it. */
.section-title {
  font-size: var(--t-title);
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.015em;
  line-height: 1.15;
}
.section-sub {
  font-size: var(--t-body);
  color: var(--fg-muted);
  margin-top: 8px;
  max-width: 42rem;
}

/* ── TOOLS ───────────────────────────────────────────────────
   Was six bordered cards, each with a rounded icon tile and a badge.
   That icon-box-above-every-heading grid is the single most template-
   like pattern on the page. Now it is a ruled index: the tool name
   does the work, the rule does the separating, and the icons are
   gone rather than shrunk.
   ──────────────────────────────────────────────────────────── */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 clamp(32px, 5vw, 64px);
  border-top: 1px solid var(--rule);
  /* Without this the grid's top rule sits flush under the section
     subtitle and reads as an underline on that sentence. */
  margin-top: 28px;
}

.tool-card {
  position: relative;
  display: block;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 22px 32px 22px 0;
  text-decoration: none;
  color: inherit;
  transition: padding-left 0.3s var(--ease-out);
  cursor: pointer;
}
.tool-card:hover {
  text-decoration: none;
  color: inherit;
  padding-left: 10px;
}
.tool-card:hover .tool-card-title { color: var(--accent); }
.tool-card:hover .tool-card-arrow { opacity: 1; transform: translate(2px, -2px); }

/* The featured tool is the primary CTA's twin, so it gets the green
   rule. Nothing else in this list is allowed it. */
.tool-card--featured { border-bottom-color: var(--accent); }

.tool-card-top {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}
/* Icon tiles removed; the markup's icon slot collapses to nothing. */
.tool-card-icon { display: none; }

.tool-badge {
  font-family: var(--font-ui);
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  line-height: 1;
}
.tool-badge--hot { color: var(--brass); background: none; border: none; }

.tool-card-title {
  font-size: var(--t-lead);
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
  transition: color 0.2s var(--ease-out);
}

.tool-card-desc {
  font-size: var(--t-body);
  color: var(--fg-muted);
  line-height: 1.55;
  max-width: 30rem;
}

.tool-card-arrow {
  position: absolute;
  top: 24px; right: 4px;
  font-family: var(--font-ui);
  font-size: var(--t-body);
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.2s var(--ease-out), transform 0.3s var(--ease-out);
}

/* ── THE STATEMENT BAND ──────────────────────────────────────
   The one bold gesture on the page (see PRODUCT.md, principle 3).
   Full-bleed library green breaking the paper, carrying the single
   claim the whole product rests on, plus the day's quote set as a
   real pull-quote instead of a third card in a grid.

   This is the ONLY place --library-green is used as a ground. If a
   second drenched section appears, the gesture stops being one.
   ──────────────────────────────────────────────────────────── */
.statement {
  background: #23382D;
  color: #E8E4DA;
  padding: clamp(64px, 9vw, 112px) 0;
  /* Light-on-dark reads lighter than it is and needs more air. */
  line-height: 1.7;
}
/* One column by default and two only once the quote actually arrives.
   The quote is fetched, so it can legitimately never show (cold API,
   offline, a day with no quote); a fixed 1fr 1fr left the claim in a
   half-width column beside a large empty one whenever that happened. */
.statement-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(40px, 6vw, 88px);
  align-items: start;
}
.statement-inner > :first-child { max-width: 46rem; }
.statement-inner:has(.statement-quote:not([hidden])) {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.statement-claim {
  font-size: var(--t-title);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: #F2EFE6;
  text-wrap: balance;
}
.statement-claim em { font-style: italic; }
.statement-body {
  font-size: var(--t-body);
  color: #B9C4BA;
  margin-top: 20px;
  max-width: 32rem;
}
.statement-label {
  font-family: var(--font-ui);
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8CA292;
  margin-bottom: 20px;
  display: block;
}
/* The day's quote, set as a quote. */
.statement-quote { border-left: 1px solid #40584A; padding-left: clamp(20px, 3vw, 36px); }
.statement-quote blockquote {
  font-size: var(--t-lead);
  font-style: italic;
  line-height: 1.5;
  color: #F2EFE6;
  text-wrap: pretty;
}
.statement-quote figcaption {
  font-family: var(--font-ui);
  font-size: var(--t-label);
  color: #8CA292;
  margin-top: 18px;
}
.statement-quote figcaption a { color: #C6D3C6; text-decoration: underline; text-underline-offset: 3px; }
.statement-quote figcaption a:hover { color: #F2EFE6; }
.statement-quote[hidden] { display: none; }

/* ── THE INDEX (newest guides) ───────────────────────────────
   Was a second marquee, identical to the NYT one. A list of what was
   just published is a list, so it is set as one: numbered, ruled,
   with the cover as a small plate. Only the NYT rail stays a rail,
   because a weekly ranking is the one thing a rail actually suits.
   ──────────────────────────────────────────────────────────── */
.index-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 0 clamp(32px, 5vw, 64px);
  border-top: 1px solid var(--rule);
  margin-top: 28px;
}
.index-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: opacity 0.2s var(--ease-out);
}
.index-item:hover { text-decoration: none; color: inherit; }
.index-item:hover .index-title { color: var(--accent); }
.index-cover {
  width: 44px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: var(--bg-subtle);
  border: 1px solid var(--border-med);
  flex-shrink: 0;
}
.index-text { min-width: 0; flex: 1; }
.index-title, .index-meta { display: block; }
.index-title {
  font-size: var(--t-body);
  font-weight: 600;
  line-height: 1.3;
  color: var(--fg);
  transition: color 0.2s var(--ease-out);
}
.index-meta {
  font-family: var(--font-ui);
  font-size: var(--t-label);
  color: var(--fg-faint);
  margin-top: 4px;
}

/* ── AFFILIATE STRIP ─────────────────────────────────────── */
.affiliate-strip {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.affiliate-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.affiliate-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.affiliate-icon {
  width: 36px; height: 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  flex-shrink: 0;
}

.affiliate-text strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 2px;
}
.affiliate-text span {
  font-size: 12px;
  color: var(--fg-faint);
}

.affiliate-btn {
  background: var(--accent);
  border-color: var(--accent);
  flex-shrink: 0;
}
.affiliate-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--bg);
  text-decoration: none;
}

/* ── TOOL PAGES ──────────────────────────────────────────── */
.tool-page {
  padding: 48px 0 80px;
}

.tool-page-header {
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--fg-faint);
  margin-bottom: 16px;
}
.breadcrumb a {
  color: var(--fg-faint);
  text-decoration: none;
}
.breadcrumb a:hover { color: var(--fg); }
.breadcrumb-sep { color: var(--border-med); }

.tool-page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.035em;
  margin-bottom: 8px;
}
.tool-page-desc {
  font-size: 15px;
  color: var(--fg-muted);
  line-height: 1.6;
}

/* Form */
.tool-form {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 20px;
}
.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 6px;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-med);
  border-radius: var(--r-sm);
  font-family: var(--font-ui);
  font-size: var(--ui-body);
  color: var(--fg);
  background-color: var(--bg-subtle);
  outline: none;
  transition: border-color 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out);
}

/* Custom-styled select. appearance:none was already set but nothing
   replaced the native arrow, so the control read as unstyled. Now: the UI
   face, a custom ink chevron, and hover/focus matching the rest of the
   system. (Only the CLOSED control is styleable — the open option list is
   drawn by the OS and can't be themed with CSS alone.)

   SPLIT OUT of the .form-input/.form-textarea group, which it used to share.
   Everything below is select-specific and was landing on every text field on
   the site: the chevron (a text box that looks like a dropdown and never
   opens one), cursor:pointer, and 38px of right padding — which on My
   Library's 78px-wide page-number field left 26px for the digits and clipped
   the end of any three-digit number. */
.form-select {
  width: 100%;
  padding: 10px 38px 10px 14px;
  border: 1px solid var(--border-med);
  border-radius: var(--r-sm);
  font-family: var(--font-ui);
  font-size: var(--ui-body);
  color: var(--fg);
  background-color: var(--bg-subtle);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234A524D' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  outline: none;
  cursor: pointer;
  transition: border-color 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out);
  appearance: none;
}
.form-select:hover { border-color: var(--fg-faint); }
html[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23A8AEA3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
  background-color: var(--bg);
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--fg-faint); }
.form-textarea { min-height: 100px; resize: vertical; line-height: 1.6; }

/* Depth / segmented control */
.depth-control {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-med);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg-subtle);
  width: fit-content;
}
.depth-btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  padding: 8px 18px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.depth-btn:last-child { border-right: none; }
.depth-btn.active {
  background: var(--fg);
  color: var(--bg);
}
.depth-btn:hover:not(.active) { background: var(--border); }

/* Result area */
.result-area {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  min-height: 200px;
}

.result-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 0;
  gap: 10px;
}
.result-placeholder-icon {
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-faint);
  margin-bottom: 4px;
}
.result-placeholder p {
  font-size: 13px;
  color: var(--fg-faint);
}

/* Loading state */
.result-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 0;
  font-size: 13px;
  color: var(--fg-faint);
}
.spinner {
  width: 16px; height: 16px;
  border: 1.5px solid var(--border-med);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ai-output {
  font-size: 15px;
  line-height: 1.75;
  color: var(--fg);
  white-space: pre-wrap;
}

/* Accent-tinted section headings inside AI summaries — applies to both the
   dynamic summarizer page and static /summary/<slug>/ book pages. */
.ai-output h2 {
  font-size: 17px;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  white-space: normal;
}
.ai-output h2:first-of-type { margin-top: 0; }
.ai-output h3 {
  font-size: 14px;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
  opacity: 0.85;
  white-space: normal;
}

.result-error {
  font-size: 13px;
  color: #c0392b;
  background: #fff5f5;
  border: 1px solid #fdd;
  border-radius: var(--r-sm);
  padding: 12px 16px;
}

/* Transparency notice on static book pages: what generated this page, what
   it's grounded in, and when. Deliberately plain/quiet — a trust signal,
   not a decoration. */
.ai-disclosure-notice {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--fg-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 16px;
  margin: 20px 0 32px;
}
.ai-disclosure-notice strong { color: var(--fg); font-weight: 600; }
/* Collapsible form: closed by default so it stays a quiet trust signal +
   crawlable source attribution without taking over the page. */
.ai-disclosure-notice > summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--fg);
  font-weight: 600;
  list-style: none;
}
.ai-disclosure-notice > summary::-webkit-details-marker { display: none; }
.ai-disclosure-notice > summary::before {
  content: "\25B8"; /* ▸ */
  font-size: var(--t-label);
  color: var(--fg-faint);
  transition: transform 0.15s ease;
}
.ai-disclosure-notice[open] > summary::before { transform: rotate(90deg); }
.ai-disclosure-body { margin-top: 10px; }

/* ── BOOK PAGE ───────────────────────────────────────────── */
.book-page { padding: 48px 0 80px; }

.book-hero {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 40px;
  align-items: start;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}

.book-cover {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.book-cover-placeholder {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--fg-muted);
  letter-spacing: -0.04em;
}

.book-genre {
  font-size: var(--t-label);
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
  font-family: var(--font-mono);
}
.book-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-bottom: 6px;
}
.book-author {
  font-size: 16px;
  color: var(--fg-muted);
  margin-bottom: 20px;
}
.book-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.book-meta-tag {
  font-size: 12px;
  color: var(--fg-faint);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px 10px;
}

/* Book tabs */
.book-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}
.book-tab {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-faint);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 20px;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.book-tab:hover { color: var(--fg); }
.book-tab.active { color: var(--fg); border-bottom-color: var(--fg); }

.book-panel { display: none; }
.book-panel.active { display: block; }

/* ── FOOTER ──────────────────────────────────────────────── */
.site-footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  margin-top: 80px;
}

.footer-inner {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 64px;
  padding: 48px 24px 40px;
}

.footer-logo { margin-bottom: 10px; }
.footer-tagline {
  font-size: 13px;
  color: var(--fg-faint);
  line-height: 1.5;
}

.footer-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}

.footer-col-title {
  font-size: var(--t-label);
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.footer-col a {
  display: block;
  font-size: 13px;
  color: var(--fg-faint);
  margin-bottom: 8px;
  text-decoration: none;
  transition: color 0.15s;
}
.footer-col a:hover { color: var(--fg); text-decoration: none; }
.footer-disclosure {
  font-size: 12px;
  color: var(--fg-faint);
  line-height: 1.6;
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding: 16px 24px;
}
.footer-bottom-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-bottom p {
  font-size: var(--t-label);
  color: var(--fg-faint);
}
/* "Cookie preferences" is a real control (re-opens the consent banner), so
   it is a button, styled to sit inline with the surrounding footer text. */
.footer-link-btn {
  font-family: var(--font-ui);
  font-size: inherit;
  color: var(--fg-faint);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.footer-link-btn:hover { color: var(--accent); }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  /* The hero's asymmetric split has no room to be asymmetric here; the
     shelf goes under the text rather than being squeezed beside it. */
  .hero-grid { grid-template-columns: 1fr; gap: 44px; }
  .hero-body { max-width: none; }
  .statement-inner { grid-template-columns: 1fr; gap: 44px; }
  .statement-quote { border-left: none; padding-left: 0; border-top: 1px solid #40584A; padding-top: 32px; }
}

@media (max-width: 768px) {
  /* Tighter gutters + header spacing on phones. The desktop 24px gutters
     and 32px header gap overflow narrow viewports (≤360px), which let the
     whole page scroll sideways and clipped the hamburger/search button. */
  .container { padding: 0 16px; }
  .header-inner { gap: 12px; }
  /* The header's backdrop-filter would become the containing block for the
     drawer's position:fixed (a filtered ancestor traps fixed descendants),
     pinning it inside the 56px header. Drop the blur on phones — the header
     background is 92% opaque, so the visual difference is negligible. */
  .site-header { backdrop-filter: none; -webkit-backdrop-filter: none; }

  /* Mobile nav = right-side drawer (was a dropdown list under the header).
     Kept off-canvas with a transform so it animates in; the huge box-shadow
     spread on .open doubles as the dimmed backdrop without an extra element.
     The existing outside-click handler in main.js closes it. */
  .site-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;   /* left-aligned full-width rows (desktop centers) */
    gap: 4px;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(78vw, 300px);
    background: var(--bg);
    border-left: 1px solid var(--border);
    padding: 72px 18px 24px;
    z-index: 200;
    transform: translateX(105%);
    transition: transform 0.25s var(--ease);
    overflow-y: auto;
  }
  .site-nav.open {
    transform: translateX(0);
    box-shadow: -16px 0 40px rgba(0, 0, 0, 0.18);
  }
  .site-nav .nav-link {
    font-size: 15px;
    padding: 12px 14px;
    border-radius: var(--r);
    text-align: left;
  }
  /* Dimmed backdrop behind the open drawer. A real overlay element —
     Chromium caps huge box-shadow spreads, so that trick doesn't render.
     Taps on it close the drawer via main.js's outside-click handler.
     z-index MUST stay below the header's 100: the drawer lives inside
     .site-header, whose sticky+z-index:100 forms a stacking context, so the
     drawer's own z-index can never escape it — an overlay above 100 covers
     the drawer too (uniform tint, no visible dim). Below 100, the page dims
     while the header bar, hamburger, and drawer stay bright. */
  html.nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90;
  }
  .header-right {
    display: flex !important;
    margin-left: auto;
    gap: 8px;
  }
  .header-right .btn-primary {
    display: none;
  }
  .nav-toggle {
    display: flex;
    margin-left: 4px;
  }

  /* Hero */
  .hero-sub { font-size: var(--t-body); }
  /* Stacked, the underline-and-button treatment stops reading as one
     field, so the search becomes a bordered box on phones. */
  .hero-search {
    flex-direction: column;
    align-items: stretch;
    border: 1px solid var(--border-med);
    border-bottom-width: 1px;
    border-radius: var(--r);
    padding: 4px;
  }
  .hero-search:focus-within { border-color: var(--accent); }
  .hero-search-input { font-size: var(--t-body); padding: 12px; }
  .hero-search-btn {
    margin: 0;
    width: 100%;
    justify-content: center;
    align-self: stretch;
    padding: 14px 22px;
  }
  .hero-shelf img { width: clamp(58px, 17vw, 96px); }

  /* Tools */
  .tools-grid { grid-template-columns: 1fr; }
  .tool-card { padding-right: 24px; }

  .statement-claim { font-size: var(--t-lead); }

  /* Affiliate */
  .affiliate-inner { flex-direction: column; align-items: flex-start; }

  /* Book */
  .book-hero { grid-template-columns: 130px 1fr; gap: 24px; }

  /* Footer */
  .footer-inner { grid-template-columns: 1fr; gap: 32px; padding: 32px 24px; }
  .footer-nav { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .tools-grid { grid-template-columns: 1fr; }
  .book-hero { grid-template-columns: 1fr; }
  .footer-nav { grid-template-columns: 1fr; }
  /* Five covers cannot hold their lean at this width; the outer pair
     drops rather than shrinking the shelf into illegibility. */
  .hero-shelf img:nth-child(1),
  .hero-shelf img:nth-child(5) { display: none; }
}

/* ── ACCESSIBILITY ───────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── THEME SWITCHER & DARK MODE OVERRIDES ────────────────── */
/* Dark mode is the same room at night, not a different palette: the
   green warms and lifts so it still carries contrast on dark ground,
   and the page ground stays green-tinged rather than going blue-black. */
html[data-theme="dark"] {
  --bg:           #12160F;
  --bg-subtle:    #1A1F18;
  --fg:           #EDEAE1;
  --fg-muted:     #A8AEA3;
  /* Lifted from #7A8177, which measured 4.18:1 on the dark panel. */
  --fg-faint:     #8B9287;
  --accent:       #8FB89B;
  --accent-bg:    #1E2A22;
  --accent-hover: #A6C9B0;
  --brass:        #C9A268;
  --blue:         #8FB89B;
  --blue-bg:      #1E2A22;
  --surface:      #1A1F18;
  --border:       #2A3027;
  --border-med:   #3D453A;
  --rule:         #EDEAE1;
  --danger:       #E88A7D;
  --danger-bg:    #2E1D1A;
  --warn:         #C9A268;
  --warn-bg:      #2A2318;
  --success:      #7FBF9B;
  --border-subtle: #232922;
}

/* Adjust header backdrop in dark mode */
html[data-theme="dark"] .site-header {
  /* Matches the current dark ground (#12160F); was the old blue-black. */
  background: rgba(18, 22, 15, 0.88);
}

/* Flip logo colors in dark mode */
html[data-theme="dark"] .logo-mark rect {
  fill: #0b0f19;
}
html[data-theme="dark"] .logo-mark rect:first-child {
  fill: #f9fafb;
}

/* Theme Toggle Button Styles */
.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--border-med);
  color: var(--fg-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .15s var(--ease), background-color .15s var(--ease), color .15s var(--ease);
  padding: 0;
}

.theme-toggle-btn:hover {
  color: var(--fg);
  border-color: var(--fg);
  background: var(--bg-subtle);
}

.theme-icon {
  display: block;
}

/* Fallback/Default Light theme overrides if attribute is missing */
.theme-icon.sun-icon { display: none; }
.theme-icon.moon-icon { display: block; }

html[data-theme="dark"] .sun-icon { display: block; }
html[data-theme="dark"] .moon-icon { display: none; }

html[data-theme="light"] .sun-icon { display: none; }
html[data-theme="light"] .moon-icon { display: block; }

/* ── Toasts (window.bhToast in main.js) ─────────────────── */
#bh-toasts {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 2000; display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none; max-width: min(92vw, 480px);
}
.bh-toast {
  background: var(--fg); color: var(--bg);
  font-size: 13px; font-weight: 600; line-height: 1.45;
  padding: 10px 18px; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
  opacity: 0; transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: auto;
}
.bh-toast.show { opacity: 1; transform: translateY(0); }
.bh-toast-success { background: #1d7a50; color: #fff; }
.bh-toast-error   { background: #b3261e; color: #fff; }

/* ── Accessibility: consistent keyboard focus ───────────── */
/* :focus-visible only — mouse clicks stay outline-free. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
