/* Flow - book-native reader. Kindle-first baseline with minimal modern enhancements. */

/* Body-bg bleed fix — guarantees paper covers the viewport on every surface. */
html, body { background: var(--paper); min-height: 100vh; }

/* ---------------------------------------------------------------
   Design tokens. Per the April 2026 redesign handoff: six colors,
   three radii (cards are gone — no --radius-l), three rhythm values.
   If a value isn't here, don't add one.
   ---------------------------------------------------------------- */
:root {
  /* color */
  --paper:    #f3ede1;             /* page background */
  --paper-2:  #ece4d2;             /* subtle inset (composer shell, callout) */
  --ink:      #1e1b18;             /* body text, titles */
  --ink-2:    #4f473d;             /* lede, secondary */
  --ink-3:    #6a6258;             /* eyebrows, small-caps, mono */
  --live:     #2f8f57;             /* connected / on / TTS playing */
  --rule:     rgba(30, 27, 24, 0.14);
  --rule-2:   rgba(30, 27, 24, 0.07);
  --rule-soft: rgba(30,27,24,0.09);
  --orange:   #c45428; /* featured story cover accent */
  /* Promoted from .home-landing so the desktop composer, reused inline on the
     mobile cover (.home-cover), renders styled at ≤759px. .home-landing keeps
     its own scoped overrides for the desktop palette. */
  --paper-card: #fffdf8;
  --lp-shadow: 0 1px 2px rgba(40, 30, 20, 0.05), 0 18px 44px -18px rgba(40, 30, 20, 0.22);
  --lp-serif: "Source Serif 4", Georgia, "Times New Roman", serif;

  /* radius */
  --radius-s:    8px;              /* small chips, pills */
  --radius-m:    14px;             /* inputs, the composer */
  --radius-pill: 999px;            /* status badges only */

  /* rhythm */
  --space-row:     12px;           /* between rows in a list */
  --space-section: 36px;           /* between named groups within a page */
  --space-page:    72px;           /* above the page title only */
}

/* ---------------------------------------------------------------
   Design Review v5 finish (2026-05-01) — rhythm sweep override block.
   Applies the three rhythm tokens uniformly across long-form and
   Setup pages so /privacy, /terms, /safety, /setup all read with the
   same vertical cadence. Lives at the top of the file so it overrides
   page-specific tweaks below; if a downstream rule is more specific,
   it wins on purpose (e.g. .legal-copy .page-title needs --space-page
   override, but Setup's page-title sits in a .page-head and uses its
   own context).
   ---------------------------------------------------------------- */

/* Page title: 72px above the title regardless of which container it
   sits in. .page-head wraps it on Setup/Library; .legal-copy wraps it
   on /privacy /terms /safety. */
.shell--page > .page-head > .page-title,
.shell--page .legal-copy > .page-title {
  margin-top: var(--space-page);
}

/* Long-form copy rhythm. Headings open a section, paragraphs flow at
   row spacing, accordion summaries pad consistently. */
.legal-copy p {
  margin-bottom: var(--space-row);
}
.legal-copy p:last-child {
  margin-bottom: 0;
}
.legal-copy h2,
.legal-copy h3 {
  margin-top: var(--space-section);
  margin-bottom: var(--space-row);
}
.legal-copy h2:first-child,
.legal-copy h3:first-child {
  margin-top: 0;
}
.long-form__accordion > summary {
  padding-bottom: var(--space-row);
}
.long-form__accordion[open] > summary {
  padding-bottom: var(--space-row);
}

/* Setup ruled sections inherit the same rhythm: section above, row
   spacing within, no extra padding under the heading. */
.shell--page .ruled + .ruled {
  margin-top: var(--space-section);
}


/* Credit-pill halo strip. Active pill = ink bg + paper text, no glow.
   Paid (secondary) pills lose the focus-shadow on click; focus-visible
   keyboard ring stays so keyboard users can still see focus. */
.credits-buy-row .button,
.credits-buy-row .button--secondary {
  box-shadow: none;
}
.credits-buy-row .button:focus:not(:focus-visible),
.credits-buy-row .button--secondary:focus:not(:focus-visible) {
  box-shadow: none;
}

/* Privacy/Terms/Safety drop the standalone Return pill — the section-nav
   strip already owns navigation and Esc / browser back close the page.
   .back-link rule lives down the file so this hides it on those pages
   only. */
.page-privacy .back-link,
.page-terms .back-link,
.page-safety .back-link {
  display: none;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  height: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 1rem;
  line-height: 1.55;
}

::selection {
  background: rgba(49, 41, 32, 0.18);
  color: var(--ink);
}

a {
  color: inherit;
  text-decoration-thickness: 0.07em;
  text-underline-offset: 0.16em;
}

a:hover {
  text-decoration-thickness: 0.1em;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

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

code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-size: 0.94em;
}

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

.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  padding: 0.5rem 0.75rem;
  background: #1d1812;
  color: var(--paper);
  text-decoration: none;
  border-radius: 0 0 6px 0;
  font-size: 0.94rem;
  transform: translateY(-110%);
  transition: transform 120ms ease;
  z-index: 1000;
}

.skip-link:focus {
  transform: translateY(0);
  outline: 2px solid #1d1812;
  outline-offset: 2px;
}


/* --- layout shell (Kindle baseline) --- */

.shell {
  --shell-space-y: 1.5rem;
  width: 100%;
  max-width: 52rem;
  margin-left: auto;
  margin-right: auto;
  min-height: 0;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding-left: 1rem;
  padding-right: 1rem;
  padding-top: calc(var(--shell-space-y) + env(safe-area-inset-top));
  padding-bottom: calc(var(--shell-space-y) + env(safe-area-inset-bottom));
}

.shell--home {
  align-items: center;
  justify-content: flex-start;
}

/* P7: home-page anchor — top-anchored composer, no dead vertical space.
   The mobile nav strip ("Library · About · Settings") above the wordmark
   was removed in favor of section links in the site footer; the desktop
   rail still carries the same nav at ≥900px. */
.shell--home > .hero {
  margin-top: calc(var(--shell-space-y) + 12px);
}

@media (max-width: 480px) {
  .shell--home > .hero {
    margin-top: var(--shell-space-y);
  }
}

/* Resume line under composer when a story is in progress. */
.home-resume {
  width: 100%;
  max-width: 42rem;
  margin: 0.85rem 0 0;
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 11px;
  letter-spacing: 0.07em;
  color: var(--ink-3);
}

.home-resume__link {
  color: var(--ink-3);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.home-resume__link:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* Design Review v5 §02/§06 — Saved-stories strip on Home. */
.home-saved {
  width: 100%;
  max-width: 42rem;
  margin: var(--space-section, 36px) auto 0;
  padding: 0;
  border-top: 1px solid var(--rule, var(--ink-4));
}

.home-saved__head {
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0.75rem 0 0.5rem;
}

.home-saved__row {
  margin: 0;
  padding: 0;
  border-bottom: 1px solid var(--rule, var(--ink-4));
}

.home-saved__row:last-of-type {
  border-bottom: 0;
}

.home-saved__row-button {
  display: flex;
  width: 100%;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.65rem 0;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}

.home-saved__row-button:hover .home-saved__title {
  text-decoration: underline;
}

.home-saved__title {
  font-size: 1rem;
  line-height: 1.3;
}

.home-saved__meta {
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}

.home-saved__more {
  margin: 0.6rem 0 0;
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 11px;
  letter-spacing: 0.07em;
}

.shell--page,
.shell--book {
  align-items: center;
}

.shell--page {
  padding-top: clamp(8px, 4vh, 40px);
}

.shell--home > * + * {
  margin-top: 1.75rem;
}

.shell--page,
.shell--book {
  width: 100%;
}

.shell--page > * + *,
.shell--book > * + * {
  margin-top: 1.25rem;
}

.shell--narrow {
  max-width: 44rem;
}

/* --- stack rhythm (gap fallback via margin) --- */

.stack {
  display: flex;
  flex-direction: column;
}

.stack > * + * {
  margin-top: 1rem;
}

.stack--tight > * + * {
  margin-top: 0.5rem;
}

.hero {
  width: 100%;
  max-width: 42rem;
}

/* --- typography (book-coded, serif throughout) --- */

.status-line,
.footer-strip,
.aux-link,
.examples-line,
.page-intro,
.muted {
  color: var(--ink-2);
}

/* Eyebrow / small-caps label — Source Serif 4, tracked, --ink-3.
   .h-eyebrow is the canonical class; .kicker / .eyebrow / .source-line are
   pre-existing aliases kept until P3 components rewrite their callers. */
.h-eyebrow,
.kicker,
.eyebrow,
.source-line {
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-variant: small-caps;
  font-feature-settings: "smcp" 1;
  color: var(--ink-3);
}

.wordmark,
.page-title,
.h-page,
.h-section,
.book-title,
.panel-title {
  margin: 0;
  font-weight: 500;
  letter-spacing: -0.02em;
}

/* Page title — Fraunces 500, SOFT 30, opsz 96, tracking -0.018em, 32–36px. */
.page-title,
.h-page {
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 2.125rem;
  line-height: 1.05;
  font-weight: 500;
  letter-spacing: -0.018em;
  font-variation-settings: "SOFT" 30, "opsz" 96;
  color: var(--ink);
}

/* Section title — Fraunces 500, 20–22px / 1.2. */
.h-section {
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 1.32rem;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: -0.012em;
  color: var(--ink);
}

/* Wordmark — Fraunces 600, SOFT 50, opsz 144, tracking -0.02em, 44–56px. */
.wordmark {
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 2.8rem;
  line-height: 0.98;
  font-weight: 600;
  font-style: normal;
  font-variation-settings: "SOFT" 50, "opsz" 144;
}

/* Lede — Source Serif 4 400, 17–19px / 1.55, --ink-2. */
.lede {
  margin: 0;
  max-width: 38rem;
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 1.15rem;
  line-height: 1.55;
  font-weight: 400;
  color: var(--ink-2);
}

/* Body — Source Serif 4 400, 16px / 1.55. .h-body marks an explicit body
   block; the html body element already inherits the family. */
.h-body {
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 16px;
  line-height: 1.55;
  font-weight: 400;
  color: var(--ink);
}

/* Mono / status — JetBrains Mono 500, 11px, tracked. */
.mono {
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.07em;
  color: var(--ink-3);
}

.page-intro {
  margin: 0;
  max-width: 38rem;
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 1.02rem;
  line-height: 1.55;
}

.status-line,
.examples-line,
.footer-strip p,
.footer-link-row,
.message {
  margin: 0;
}

.status-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.status-line > * + * {
  margin-left: 0.72rem;
}

.status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: rgba(30, 27, 24, 0.28);
  display: inline-block;
  flex: 0 0 auto;
}

.status-dot--live {
  background: var(--live);
}

.examples-block {
  width: 100%;
  max-width: 34rem;
}

.hero-top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
}

.hero-kicker {
  margin: 0 0 0.42rem;
}

.resume-link {
  width: 100%;
  max-width: 42rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.92rem 1rem;
  border: 1px solid rgba(30, 27, 24, 0.1);
  border-radius: var(--radius-m);
  background: rgba(255, 253, 249, 0.68);
  box-shadow: none;
  text-decoration: none;
}

.resume-link:hover {
  border-color: rgba(30, 27, 24, 0.16);
}

.resume-link__copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.16rem;
}

.resume-title {
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 1.12rem;
  line-height: 1.1;
  font-weight: 600;
}

.resume-meta {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--ink-2);
}

.resume-progress {
  font-size: 0.82rem;
  color: var(--ink-3);
}

.resume-link__icon {
  flex: 0 0 auto;
  color: #433b33;
}

.icon-button,
.back-link {
  width: 2.9rem;
  height: 2.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(30, 27, 24, 0.18);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  text-decoration: none;
  flex: 0 0 auto;
  position: relative;
}

.back-link--text {
  width: auto;
  height: auto;
  gap: 0.35rem;
  padding: 0.6rem 0.9rem 0.6rem 0.75rem;
}

.back-link__label {
  font-size: 0.96rem;
  line-height: 1;
}

.icon-button:hover,
.back-link:hover {
  border-color: rgba(30, 27, 24, 0.36);
}

.icon-button:focus-visible,
.back-link:focus-visible {
  outline: none;
  border-color: rgba(30, 27, 24, 0.42);
  box-shadow: 0 0 0 3px rgba(30, 27, 24, 0.08);
}

.resume-link:focus-visible {
  outline: none;
  border-color: rgba(30, 27, 24, 0.42);
  box-shadow: 0 0 0 3px rgba(30, 27, 24, 0.08);
}

.icon-button--primary {
  background: #312920;
  border-color: #312920;
  color: #f5f0e6;
}

.icon-button--primary:hover {
  background: var(--ink);
  border-color: var(--ink);
}

.icon-button--quiet {
  background: rgba(255, 255, 255, 0.78);
}

.icon-button[disabled],
.icon-button[data-busy="true"] {
  cursor: wait;
  opacity: 0.72;
}

.icon-button__busy {
  font-size: 0.72rem;
  line-height: 1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.page-head {
  width: 100%;
  max-width: 40rem;
}

.page-head > .back-link {
  align-self: flex-start;
  margin-bottom: 0.1rem;
}

.page-head--minimal {
  gap: 0.75rem;
}

/* --- ruled section (P3 component #1).
   Replaces every rounded `.panel` outside the composer. A small-caps header
   above a hairline rule. Used for groups on Library, Settings, About. */

.ruled {
  width: 100%;
  max-width: 44rem;
  margin-top: var(--space-section);
}

.ruled__head {
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-variant: small-caps;
  font-feature-settings: "smcp" 1;
  color: var(--ink-3);
  margin: 0 0 12px;
  padding-top: 14px;
  border-top: 1px solid var(--ink);
  font-weight: 500;
}

.ruled__body {
  display: flex;
  flex-direction: column;
}

/* --- field row (P3 component #2).
   One component for every setting. label left, value/status right.
   Tap target = whole row. No bordered input boxes inline. */

.field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0.75rem;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule-2);
  text-decoration: none;
  color: var(--ink);
}

.field:last-child {
  border-bottom: 0;
}

.field__label {
  font-weight: 500;
}

.field__val {
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 12px;
  color: var(--ink-3);
  text-align: right;
}

.field__val--plain {
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 1rem;
  color: var(--ink);
}

.field__val--smallcaps {
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-variant: small-caps;
  color: var(--ink-3);
}

a.field:hover {
  background: rgba(30, 27, 24, 0.03);
}

a.field:focus-visible {
  outline: none;
  background: rgba(30, 27, 24, 0.05);
  box-shadow: inset 0 0 0 2px rgba(30, 27, 24, 0.18);
}

/* --- status pill (P3 component #4).
   Used only for state badges, never for buttons. */

.pill {
  display: inline-flex;
  align-items: center;
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--rule);
  color: var(--ink-2);
  background: transparent;
  text-transform: uppercase;
}

.pill--good {
  color: var(--live);
  border-color: rgba(47, 143, 87, 0.25);
  background: rgba(47, 143, 87, 0.08);
}

.pill--warn {
  color: #8a6a1f;
  border-color: rgba(138, 106, 31, 0.25);
  background: rgba(138, 106, 31, 0.08);
}

.pill--flag {
  color: #b9381f;
  border-color: rgba(185, 56, 31, 0.25);
  background: rgba(185, 56, 31, 0.08);
}

/* --- inline action (P3 component #5).
   Replaces ~80% of black pill buttons. Short verb, 1px ink underline. */

.act {
  color: var(--ink);
  border-bottom: 1px solid var(--ink);
  padding-bottom: 1px;
  text-decoration: none;
  font-weight: 500;
  background: transparent;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  padding-left: 0;
  padding-right: 0;
}

.act:hover {
  border-bottom-width: 2px;
}

.act:focus-visible {
  outline: none;
  border-bottom-width: 2px;
  background: rgba(30, 27, 24, 0.04);
}

/* --- panel-title typography (kept until P6 cleanup) --- */

.panel-title {
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.08;
}

.library-item {
  width: 100%;
  padding: 1rem 0;
  border-top: 1px solid rgba(30, 27, 24, 0.14);
}

.library-item:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.library-item > * + * {
  margin-top: 0.8rem;
}

.library-toolbar {
  display: grid;
  gap: 0.85rem;
}

.library-toolbar .inline-field {
  width: 100%;
}

/* --- settings sub-routes (P5) -------------------------------------- */

.page-settings-sub .ruled {
  margin-top: var(--space-section);
}

.settings-sub-form,
.settings-form {
  width: 100%;
  max-width: 38rem;
  margin: 0 0 var(--space-section);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.settings-sub-form__body,
.settings-form__body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.settings-sub-form__label,
.settings-form__label {
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-variant: small-caps;
  color: var(--ink-3);
  margin: 0;
}

.settings-sub-form__input,
.settings-form__input {
  width: 100%;
  font: inherit;
  background: rgba(255, 253, 249, 0.94);
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
  padding: 0.7rem 0.85rem;
  color: var(--ink);
}

.settings-sub-form__input:focus,
.settings-form__input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(30, 27, 24, 0.06);
}

.settings-sub-form__textarea,
.settings-form__textarea {
  min-height: 8rem;
  resize: vertical;
  line-height: 1.55;
}

/* Reading level & pacing — match the field-row visual: a single bottom rule
   instead of an outline box. */
.settings-form__textarea--field {
  border: none;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  padding: var(--space-row) 0;
  background: transparent;
  box-shadow: none;
}
.settings-form__textarea--field:focus {
  outline: none;
  border-bottom-color: var(--ink);
  box-shadow: none;
}

.settings-sub-form__check,
.settings-form__check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  color: var(--ink);
}

.settings-sub-form__actions,
.settings-form__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.settings-sub-form .button,
.settings-form .button {
  flex: 0 0 auto;
}

.settings-sub-delete,
.settings-form__delete {
  margin: 1rem 0 0;
}

/* Long-form pages — accordions on /safety, anchored TOC on /privacy & /terms. */
.long-form__accordion {
  border-top: 1px solid var(--rule);
  padding: 12px 0;
  margin: 0;
}
.legal-copy p + .long-form__accordion,
.legal-copy .legal-lede + .long-form__accordion {
  margin-top: var(--space-section);
}

/* Defeat margin-collapse: the first long-form accordion on /safety needs a
   visible 36px gap above. Padding-top on the parent rather than margin-top
   on the child sidesteps the collapse. */
main.shell--page > .legal-copy > .long-form__accordion:first-of-type,
.page-safety .legal-copy .long-form__accordion:first-of-type {
  padding-top: var(--space-section);
}

/* Privacy: the paragraph immediately after the scope <dl> needs --space-section
   above it so "To remove Flow entirely…" doesn't sit flush. */
.legal-copy .privacy-after-scope {
  margin-top: var(--space-section);
}
.long-form__accordion[open] { padding-bottom: 16px; }
.long-form__accordion[open] > summary { padding-bottom: var(--space-row); }
.long-form__accordion:last-of-type { border-bottom: 1px solid var(--rule); }
.long-form__accordion > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 28px;
  display: flex;
  align-items: baseline;
}
.long-form__accordion > summary::-webkit-details-marker { display: none; }
.long-form__accordion > summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  color: var(--ink-3);
  font-size: 18px;
}
.long-form__accordion[open] > summary::after { content: "−"; }
.long-form__accordion > summary > h2 {
  margin: 0;
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 1.18rem;
  line-height: 1.25;
  font-weight: 500;
}
.long-form__accordion > p,
.long-form__accordion > ul {
  margin-top: var(--space-row);
}
.long-form__accordion > p + p {
  margin-top: var(--space-row);
}

.long-form__toc {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink-2);
}
.long-form__toc-head {
  margin: 0 0 8px;
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-variant: small-caps;
  color: var(--ink-3);
}
.long-form__toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.long-form__toc a {
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.long-form__toc a:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}
@media (max-width: 899px) {
  .long-form__toc ul {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px 14px;
  }
}

/* Credits section primitives — 2026-04-30 sweep. */
.credits-balance {
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 500;
  color: var(--ink);
  margin: 4px 0 18px;
}
.credits-buy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}
.credits-buy-form {
  margin: 0;
  display: inline-flex;
}
.credits-buy-form .button,
.credits-buy-form .button--secondary {
  padding: 14px 22px;
  border-radius: 999px;
  min-height: 2.9rem;
}

/* Design Review v5 §08 — Custom amount pill expands to an inline number
   input + Charge button. Uses <details>/<summary> for JS-off-friendly
   reveal; the summary itself is styled as a pill. */
.credits-custom { display: inline-block; }
.credits-custom__summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 22px;
  border-radius: 999px;
  min-height: 2.9rem;
}
.credits-custom__summary::-webkit-details-marker { display: none; }
.credits-custom[open] .credits-custom__summary { display: none; }
.credits-custom__form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--paper-2, #ece4d2);
  border: 1px solid var(--ink, #1e1b18);
  border-radius: 999px;
  margin: 0;
}
.credits-custom__label {
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 1rem;
  color: var(--ink-2);
  margin: 0 2px 0 6px;
}
.credits-custom__input {
  width: 4.5rem;
  padding: 6px 8px;
  border: 0;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 6px;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  text-align: center;
}
.credits-custom__input:focus {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}
.credits-custom__submit {
  padding: 8px 14px;
  border-radius: 999px;
  min-height: 2.2rem;
  font-size: 0.95rem;
}

.credits-tertiary {
  margin: 4px 0 0;
  font-size: 0.96rem;
  color: var(--ink-2);
}
.credits-cancel-banner {
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
  background: rgba(255, 253, 249, 0.78);
  font-size: 0.96rem;
  color: var(--ink);
}

/* Inline edit-in-place row (settings ?open=KEY). Stacks label + form
   vertically on mobile and desktop alike. */
.field--expanded {
  display: block;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule-2);
}
.field--expanded:last-child { border-bottom: 0; }
.field__label--block {
  display: block;
  font-weight: 500;
  margin: 0 0 12px;
}
.field__expand { display: block; }
.field__expand .settings-form,
.field__expand .settings-form__delete { margin-left: 0; }

.settings-status-line {
  margin: 0;
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 11px;
  letter-spacing: 0.07em;
  color: var(--ink-3);
}

/* --- library v3 (P4) ----------------------------------------------- */

.library-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  max-width: 44rem;
  margin: 0;
  padding: 1.15rem 1.25rem;
  background: var(--paper-2);
  border: 1px solid var(--ink);
  border-radius: var(--radius-m);
}

.library-callout__copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.library-callout__title {
  margin: 0;
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 1.2rem;
  line-height: 1.15;
  font-weight: 500;
  letter-spacing: -0.012em;
  color: var(--ink);
}

.library-callout__meta {
  margin: 0;
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 11px;
  letter-spacing: 0.07em;
  color: var(--ink-3);
}

.library-callout__continue {
  flex: 0 0 auto;
}

.library-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.6rem 0.75rem;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule-2);
}

.library-row:last-child {
  border-bottom: 0;
}

.library-row__copy {
  min-width: 0;
}

.library-row__title {
  margin: 0 0 4px;
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 1.05rem;
  line-height: 1.2;
  font-weight: 500;
  color: var(--ink);
}

.library-row__meta {
  margin: 0;
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 11px;
  letter-spacing: 0.07em;
  color: var(--ink-3);
}

.library-row__action {
  flex: 0 0 auto;
}

.library-row__more {
  grid-column: 1 / -1;
  margin: 0;
}

.library-row__more > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 6px 0;
}

.library-row__more > summary::-webkit-details-marker {
  display: none;
}

.library-row__more-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  padding: 4px 0 8px;
  align-items: baseline;
}

.library-row__rename {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.library-row__rename-input {
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  padding: 4px 2px;
  min-width: 0;
  width: auto;
  font: inherit;
}

.library-row__rename-input:focus {
  outline: none;
  border-bottom-color: var(--ink);
}

.library-search {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin: 0 0 0.6rem;
}

.library-search__input {
  flex: 1 1 auto;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  padding: 6px 2px;
  min-width: 0;
  font: inherit;
}

.library-search__input:focus {
  outline: none;
  border-bottom-color: var(--ink);
}

.library-empty {
  margin: 8px 0;
  font-size: 0.96rem;
  color: var(--ink-2);
}

.library-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  margin-top: 0.85rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--rule-2);
}

.library-action {
  display: inline-block;
  margin: 0;
}

.library-quarantine {
  margin: 0 0 0.6rem;
  font-size: 0.92rem;
}

.book {
  width: 100%;
  max-width: 42rem;
  margin-left: auto;
  margin-right: auto;
}

.book-head {
  padding-top: 0.3rem;
}

.book-head > .back-link {
  align-self: flex-start;
  margin-bottom: 0.35rem;
}

.book-head .source-line {
  margin: 0 0 0.35rem;
}

.book-head .source-line + .book-title {
  margin-top: 0;
}

.book-title {
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 2.4rem;
  line-height: 1.02;
  font-weight: 600;
}

.book-byline {
  margin: 0;
  font-size: 1rem;
  line-height: 1.45;
  color: #433b33;
  font-weight: inherit;
}

.prose {
  max-width: 42rem;
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 1.22rem;
  line-height: 1.78;
  overflow-wrap: break-word;
  hyphens: auto;
  text-wrap: pretty;
}

html[data-text-size="lg"] .prose {
  font-size: 1.34rem;
  line-height: 1.88;
}

.prose p {
  margin: 0 0 1.15em;
}

.prose p:last-child {
  margin-bottom: 0;
}

/* --- story flow (papyrus) --- */

.story-flow {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  width: 100%;
  max-width: 42rem;
  margin: 0;
  padding: 0;
}

.story-flow__turn {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(30, 27, 24, 0.08);
  padding-bottom: 1.75rem;
}

.story-flow__turn:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.story-flow__prose {
  width: 100%;
}

.story-flow__figure {
  margin: 0.5rem 0 0;
  padding: 0;
}

.story-flow__figure img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(30, 27, 24, 0.1);
}

.story-steer {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.4rem 0 0.4rem 1rem;
  border-left: 3px solid rgba(93, 84, 73, 0.35);
  font-style: italic;
  color: rgba(30, 27, 24, 0.72);
  width: 100%;
  max-width: 42rem;
}

.story-steer--active {
  margin-top: 0.5rem;
}

.story-steer__lede {
  font-style: normal;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(93, 84, 73, 0.65);
}

.story-steer__quote {
  quotes: '"' '"';
  font-size: 1rem;
  line-height: 1.5;
  color: rgba(30, 27, 24, 0.78);
}

.story-steer__quote::before {
  content: open-quote;
}

.story-steer__quote::after {
  content: close-quote;
}

@media print {
  .story-flow__turn {
    border-bottom: 0;
    page-break-inside: avoid;
  }
  .story-steer__lede {
    display: none;
  }
}

/* --- v1 reader surfaces --- */

.reader-tools {
  width: 100%;
  max-width: 42rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(30, 27, 24, 0.1);
}

.reader-tools__group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.55rem;
}

.reader-tools-more > summary.reader-tool,
.reader-tools-more > summary {
  display: inline-flex;
  align-items: center;
}

.reader-tool,
.next-action-button {
  display: inline-flex;
  align-items: center;
  min-height: 2.45rem;
  border: 1px solid rgba(30, 27, 24, 0.16);
  background: rgba(255, 255, 255, 0.54);
  color: var(--ink);
  text-decoration: none;
}

.reader-tool {
  gap: 0.42rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  font-size: 0.88rem;
}

.reader-tool--read::before {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  background: var(--live);
  flex: 0 0 auto;
}

.reader-tool[data-active="true"],
.reader-tool--active {
  border-color: rgba(47, 143, 87, 0.36);
  background: rgba(47, 143, 87, 0.1);
}

.next-actions {
  width: 100%;
  max-width: 42rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.next-action-button {
  flex: 1 1 12rem;
  justify-content: flex-start;
  padding: 0.75rem 0.95rem;
  border-radius: 14px;
  text-align: left;
  white-space: normal;
}

.next-action-button:hover,
.reader-tool:hover {
  border-color: rgba(30, 27, 24, 0.34);
}

.next-actions--empty {
  display: block;
}

.next-actions__empty {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-3);
  font-style: italic;
}

.generated-media,
.generated-image,
.generated-audio {
  width: 100%;
  max-width: 42rem;
}

.generated-media {
  display: flex;
  flex-direction: column;
}

.generated-media > * + * {
  margin-top: 0.75rem;
}

.generated-image,
.generated-audio {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.generated-image img {
  width: 100%;
  border-radius: var(--radius-s, 10px);
}

.generated-image__download {
  display: block;
  text-decoration: none;
  cursor: pointer;
}

.generated-image__download:focus-visible {
  outline: 2px solid var(--ink, #1e1b18);
  outline-offset: 3px;
  border-radius: var(--radius-s, 10px);
}

.generated-image figcaption,
.generated-audio__caption {
  margin: 0.55rem 0 0;
  font-size: 0.8rem;
  line-height: 1.42;
  color: #5d5449;
}

.generated-image figcaption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-style: italic;
}

.generated-audio {
  padding: 0.75rem;
  border: 1px solid rgba(30, 27, 24, 0.1);
  border-radius: 14px;
  background: rgba(255, 253, 249, 0.76);
}

.image-replace-form {
  flex: 0 0 auto;
}

.image-replace {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 0.78rem;
  line-height: 1.2;
  text-decoration: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.18em;
}

.generated-audio audio {
  width: 100%;
}

.mic-panel,
.transcription-panel,
.stream-preview {
  width: 100%;
  max-width: 42rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid rgba(30, 27, 24, 0.1);
  border-radius: 14px;
  background: rgba(255, 253, 249, 0.72);
}

.mic-panel > * + *,
.transcription-panel > * + *,
.stream-preview > * + * {
  margin-top: 0.55rem;
}

.mic-status,
.transcription-status,
.stream-status {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.4;
  color: #5d5449;
}

.mic-status--listening,
.stream-status--active {
  color: #2f6f46;
}

.mic-status--error,
.transcription-status--error,
.stream-status--error {
  color: #7b2d22;
}

.mic-control[data-state="recording"] {
  border-color: rgba(123, 45, 34, 0.32);
  background: rgba(123, 45, 34, 0.08);
}

.mic-control[disabled] {
  cursor: wait;
  opacity: 0.64;
}

.transcription-text,
.stream-preview__body {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.62;
  color: #2f2924;
}

.stream-preview {
  border-left-width: 3px;
  border-left-color: rgba(49, 41, 32, 0.24);
}

.stream-preview[data-state="active"] {
  border-left-color: rgba(47, 143, 87, 0.55);
}

.cost-display {
  position: fixed;
  left: calc(0.85rem + env(safe-area-inset-left));
  bottom: calc(0.85rem + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: 14rem;
  padding: 0.45rem 0.62rem;
  border: 1px solid rgba(30, 27, 24, 0.1);
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.9);
  box-shadow: 0 8px 22px rgba(49, 41, 32, 0.06);
  font-size: 0.78rem;
  line-height: 1.3;
  color: #5d5449;
}

html[data-cost-display="hidden"] .cost-display {
  display: none;
}

.report-control {
  margin: 1.4rem 0 0;
  padding: 0.4rem 0;
  border-top: 1px solid rgba(49, 41, 32, 0.08);
  font-size: 0.85rem;
  color: #5d5449;
}

.report-control > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.45rem 0;
  font-size: 0.82rem;
  color: #6b6155;
  text-decoration: underline;
  text-decoration-color: rgba(49, 41, 32, 0.25);
  text-underline-offset: 3px;
}

.report-control > summary::-webkit-details-marker {
  display: none;
}

.report-control[open] > summary {
  color: #312920;
}

.report-form {
  margin-top: 0.6rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid rgba(49, 41, 32, 0.12);
  border-radius: 6px;
  background: rgba(255, 253, 249, 0.7);
}

.report-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.report-form__label {
  font-size: 0.78rem;
  color: #5d5449;
}

.report-form select,
.report-form textarea {
  font: inherit;
  padding: 0.4rem 0.55rem;
  border: 1px solid rgba(49, 41, 32, 0.2);
  border-radius: 4px;
  background: #fffdf7;
  color: #312920;
}

.report-form textarea {
  resize: vertical;
  min-height: 4.4rem;
}

.report-form__note {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: #6b6155;
  line-height: 1.45;
}

.reader-tool--report {
  align-self: flex-start;
}

.reader-tools__connect {
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: #6b6155;
}

.reader-tools__connect a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.18em;
}

.site-footer .report-control {
  margin: 0;
  padding: 0;
  border: 0;
  font: inherit;
  color: inherit;
}

.site-footer .report-control > summary {
  display: inline;
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: none;
}

.site-footer .report-control > summary:hover {
  text-decoration: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.18em;
}

.site-footer .report-control[open] {
  flex-basis: 100%;
  width: 100%;
  margin-top: 0.45rem;
}

.site-footer .report-form {
  width: min(100%, 38rem);
  margin: 0.55rem auto 0;
  text-align: left;
  font-size: 0.85rem;
}

/* --- forms --- */

.form-field {
  display: flex;
  flex-direction: column;
}

.form-field > * + * {
  margin-top: 0.45rem;
}

.field-label,
.legend-label,
.fieldset-inline legend {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}

.field-helper,
.settings-helper,
.settings-warning {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.42;
}

.field-helper,
.settings-helper {
  color: #5d5449;
}

.api-key-link {
  margin: 0.35rem 0 0;
  text-align: center;
  font-size: 0.85rem;
  color: rgba(93, 84, 73, 0.65);
}

.api-key-link a {
  color: inherit;
  text-decoration: none;
}

.api-key-link a:hover,
.api-key-link a:focus {
  color: rgba(93, 84, 73, 0.95);
  text-decoration: none;
}

.settings-warning {
  padding: 0.68rem 0.78rem;
  border: 1px solid rgba(123, 45, 34, 0.18);
  border-radius: 12px;
  background: rgba(123, 45, 34, 0.07);
  color: #7b2d22;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.82rem 0.95rem;
  border: 1px solid rgba(30, 27, 24, 0.2);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 7rem;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(30, 27, 24, 0.45);
  box-shadow: 0 0 0 3px rgba(30, 27, 24, 0.08);
}

.fieldset-inline {
  margin: 0;
  padding: 0;
  border: 0;
}

.choice-row,
.actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

/* Forms in actions-row are layout-transparent so their inner button is
   the direct flex item alongside bare anchors — same baseline, same
   alignment. Was causing 'Disconnect Google' and 'Open library' to
   sit on slightly different lines. */
.actions-row form {
  margin: 0;
  display: contents;
}

.choice-row > * + *,
.actions-row > * + * {
  margin-left: 0.75rem;
}

.choice-row > *,
.actions-row > * {
  margin-top: 0.4rem;
}

.choice-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.72rem 0.9rem;
  border: 1px solid rgba(30, 27, 24, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
}

.choice-pill > * + * {
  margin-left: 0.5rem;
}

.choice-pill input {
  width: auto;
  margin: 0;
}

.key-sync-stack {
  display: grid;
  gap: 0.65rem;
}

.key-sync-confirm {
  margin: 0;
}

.key-sync-confirm > summary {
  cursor: pointer;
  list-style: none;
}

.key-sync-confirm > summary::-webkit-details-marker {
  display: none;
}

.key-sync-confirm__form {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.api-key-group {
  display: grid;
  gap: 0.65rem;
  padding: 0.85rem 0;
  border-top: 1px solid rgba(30, 27, 24, 0.08);
}

.api-key-group:first-of-type {
  padding-top: 0.25rem;
  border-top: 0;
}

.api-key-group__title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #5d5449;
}

.key-sync-row {
  margin: 0;
}

.key-sync-choice {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.key-sync-choice input {
  flex: 0 0 auto;
  width: auto;
  margin: 0.2rem 0 0;
}

.key-sync-choice span {
  min-width: 0;
  line-height: 1.45;
}

.classroom-confirm {
  flex: 0 0 auto;
  min-width: 11.5rem;
  margin-left: auto;
}

.classroom-confirm summary {
  list-style: none;
  cursor: pointer;
}

.classroom-confirm summary::-webkit-details-marker {
  display: none;
}

.classroom-confirm[open] {
  flex: 1 1 100%;
}

.classroom-confirm[open] summary {
  width: fit-content;
}

/* Flattened: was a sub-card with its own border/background, which
   read as a card-inside-the-card. Just give it breathing room. */
.classroom-confirm__panel {
  margin-top: 0.85rem;
  padding: 0;
  border: 0;
  background: transparent;
}

.classroom-confirm__panel > * + * {
  margin-top: 0.75rem;
}

.classroom-status {
  display: inline-flex;
  align-items: center;
  min-height: 1.8rem;
  padding: 0.32rem 0.6rem;
  border: 1px solid rgba(30, 27, 24, 0.12);
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.82);
  font-size: 0.8rem;
  line-height: 1.1;
  color: #5d5449;
}

.classroom-status--on {
  border-color: rgba(47, 143, 87, 0.28);
  color: #2f6f46;
}

.classroom-status--off {
  color: var(--ink-3);
}

.card-status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 1.65rem;
  padding: 0.18rem 0.58rem;
  border: 1px solid rgba(30, 27, 24, 0.16);
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.72);
  color: var(--ink-3);
  font-size: 0.74rem;
  line-height: 1.15;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.card-status svg {
  flex: none;
}

.card-status--on {
  color: #2f6f46;
  border-color: rgba(47, 143, 87, 0.3);
  background: rgba(47, 143, 87, 0.07);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  padding: 0.75rem 1.2rem;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
}

.button > * + * {
  margin-left: 0.5rem;
}

.button--primary {
  background: #312920;
  color: #f5f0e6;
}

.button--primary:hover {
  background: var(--ink);
}

.button--primary:disabled {
  opacity: 0.55;
  cursor: wait;
}

.button--quiet {
  background: rgba(255, 255, 255, 0.42);
  border-color: rgba(30, 27, 24, 0.2);
}

.button--quiet:hover {
  border-color: rgba(30, 27, 24, 0.4);
}

/* Plain paragraph flow — was a flex container which made each text run
   and inline link wrap onto its own visual line. */
.model-help-links,
.help-link-row {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #5d5449;
  text-align: left;
}

.model-help-link,
.help-link {
  color: inherit;
  text-decoration-thickness: 0.06em;
}

/* --- composer --- */

.composer-wrap {
  width: 100%;
  max-width: 46rem;
  margin-left: auto;
  margin-right: auto;
  position: static;
}

.composer {
  padding: 0.55rem;
  border: 1px solid rgba(30, 27, 24, 0.08);
  border-radius: var(--radius-m);
  background: var(--paper-2);
  box-shadow: 0 12px 30px rgba(49, 41, 32, 0.04);
}

.composer-row {
  display: flex;
  align-items: center;
}

.composer-row > * + * {
  margin-left: 0.55rem;
}

.composer-main {
  flex: 1 1 auto;
  min-width: 0;
}

.composer-main input {
  margin: 0;
  background: rgba(255, 255, 255, 0.94);
}

.composer-submit {
  flex: 0 0 auto;
}

.composer-main input:focus {
  box-shadow: none;
}


/* Design Review v5 §02 — composer geometry: 14/16/14/14 outer padding,
   52px total height, "+" attach glyph baseline-aligned in left padding. */
.home-input-shell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 14px 14px;
  border: 1px solid rgba(30, 27, 24, 0.1);
  border-radius: var(--radius-m);
  background: var(--paper-2);
  box-shadow: 0 10px 24px rgba(49, 41, 32, 0.045);
}

.home-input-shell:focus-within {
  border-color: rgba(30, 27, 24, 0.42);
  box-shadow: 0 0 0 3px rgba(30, 27, 24, 0.06), 0 12px 28px rgba(49, 41, 32, 0.06);
}

.home-input-shell input,
.home-input-shell textarea {
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.home-input-shell textarea {
  resize: none;
  overflow: hidden;
  line-height: 1.5;
  min-height: 0;
  max-height: 22rem;
}

.home-input-shell input:focus,
.home-input-shell textarea:focus {
  box-shadow: none;
}

/* Design Review v5 §04 — Setup-as-sheet. Slides up from the bottom on
   phone, slides in from the right on tablet+. Dim layer behind the
   panel; tap dim, X, or press Esc to close. JS-off: the section-nav
   "Settings" link still navigates to /settings as a real page. */
.setup-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}
.setup-sheet[hidden] { display: none; }
/* Design Review v5 finish (2026-05-01): backdrop is a body::before
   layer at 40% black so the page is fully obscured behind the sheet
   instead of bleeding through. body scroll lock is at the bottom of
   this block (overflow:hidden when [data-setup-open] is set). */
body[data-setup-open]::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 55;
  pointer-events: auto;
}
.setup-sheet__dim {
  position: absolute;
  inset: 0;
  background: transparent;
  opacity: 0;
  pointer-events: none;
}
.setup-sheet.is-open .setup-sheet__dim { opacity: 1; pointer-events: auto; }
.setup-sheet__panel {
  position: absolute;
  background: var(--paper, #f3ede1);
  box-shadow: 0 -10px 30px rgba(30, 27, 24, 0.12);
  border-top: 1px solid rgba(30, 27, 24, 0.14);
  pointer-events: auto;
  z-index: 1;
  outline: none;
  transition: transform 220ms ease;
  display: flex;
  flex-direction: column;
}
@media (max-width: 719px) {
  .setup-sheet__panel {
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 88vh;
    border-radius: 14px 14px 0 0;
    transform: translateY(100%);
  }
  .setup-sheet.is-open .setup-sheet__panel { transform: translateY(0); }
}
@media (min-width: 720px) {
  .setup-sheet__panel {
    top: 0;
    right: 0;
    bottom: 0;
    width: min(34rem, 90vw);
    border-top: 0;
    border-left: 1px solid rgba(30, 27, 24, 0.14);
    transform: translateX(100%);
  }
  .setup-sheet.is-open .setup-sheet__panel { transform: translateX(0); }
}
.setup-sheet__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(30, 27, 24, 0.07);
  flex: 0 0 auto;
}
.setup-sheet__head-label {
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.setup-sheet__close {
  background: transparent;
  border: 0;
  color: var(--ink-3);
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 999px;
}
.setup-sheet__close:hover { color: var(--ink); background: var(--paper-2); }
.setup-sheet__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 22px 26px;
  -webkit-overflow-scrolling: touch;
}
.setup-sheet__loading,
.setup-sheet__error {
  margin: 0;
  padding: 24px 0;
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}
.setup-sheet__error a { color: var(--ink); }
body[data-setup-open] {
  overflow: hidden;
}

/* Design Review v5 §03 — error renders BELOW the composer as a mono
   one-liner, with the long-form detail tucked into a closed <details>.
   Composer stays in position even when the model run fails. */
.composer-error {
  margin: 14px 0 0;
}
.composer-error__line {
  margin: 0;
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--flag, #b9381f);
}
.composer-error__details {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-2);
}
.composer-error__details > summary {
  cursor: pointer;
  list-style: none;
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.composer-error__details > summary::-webkit-details-marker { display: none; }
.composer-error__details[open] > summary { color: var(--ink-2); }
.composer-error__details > p {
  margin: 6px 0 0;
  font-style: italic;
}

.home-file-name {
  margin: 0.4rem 0 0;
  padding: 0 0.45rem;
  font-size: 0.92rem;
  color: var(--ink-2);
  min-height: 1.2em;
  word-break: break-word;
}


/* Composer attach affordance: flush-left mono "+", no circle, sits inside
   the shell's left padding region and baseline-aligns with the placeholder
   per Design Review v5 §02. */
.composer-attach {
  flex: 0 0 auto;
  width: 1.4rem;
  height: 1.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 16px;
  line-height: 1;
  color: var(--ink-3);
  background: transparent;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
}

.composer-attach:hover {
  color: var(--ink);
}

.composer-attach:focus-within,
.composer-attach:focus-visible {
  outline: none;
  color: var(--ink);
}

.file-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.file-picker-control {
  position: relative;
  display: inline-flex;
}

.file-picker-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-picker-control:focus-within .file-picker-button {
  border-color: rgba(30, 27, 24, 0.42);
  box-shadow: 0 0 0 3px rgba(30, 27, 24, 0.08);
}

.file-picker-button {
  pointer-events: none;
  min-width: 8.8rem;
}

.file-picker-name {
  font-size: 0.96rem;
  line-height: 1.45;
  color: var(--ink-2);
  word-break: break-word;
  min-height: 1.45em;
}

.source-panel-footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
}

.source-upload-group {
  display: grid;
  gap: 0.45rem;
}

.source-upload-group[hidden],
.source-panel-footer [hidden] {
  display: none;
}

.busy-status {
  display: none;
  margin: 0.55rem 0 0;
  font-size: 0.92rem;
  line-height: 1.2;
  color: var(--ink-2);
  text-align: right;
}

body[data-thinking="true"] .busy-status {
  display: block;
}

body[data-thinking="true"] .reader-tools,
body[data-thinking="true"] .next-actions,
body[data-thinking="true"] .generated-image .image-replace {
  opacity: 0.5;
  pointer-events: none;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.35rem 0.35rem 0.95rem;
  border: 1px solid rgba(30, 27, 24, 0.2);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
}

.inline-field:focus-within {
  border-color: rgba(30, 27, 24, 0.45);
  box-shadow: 0 0 0 3px rgba(30, 27, 24, 0.08);
}

.inline-field input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.8rem 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.inline-field input:focus {
  box-shadow: none;
}

.inline-field__action {
  width: 2.7rem;
  height: 2.7rem;
}

.inline-field__action--submit {
  flex: 0 0 auto;
  width: auto;
  height: auto;
  min-height: 2.55rem;
  min-width: 8.25rem;
  padding: 0.7rem 1.35rem;
  justify-content: center;
  white-space: nowrap;
}

.footer-strip {
  width: 100%;
  max-width: 42rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(30, 27, 24, 0.12);
  font-size: 0.92rem;
  color: var(--ink-2);
}

.footer-strip a {
  text-decoration: none;
}

.footer-strip a:hover {
  text-decoration: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.18em;
}

.affiliate-line {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.4;
  color: #5d5449;
}

.affiliate-link {
  color: inherit;
}

.affiliate-link em {
  font-style: italic;
}

.footer-strip > * + * {
  margin-top: 0.55rem;
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
}

.footer-row > * + * {
  margin-left: 0.55rem;
}

.message {
  padding: 0.8rem 0.95rem;
  border-radius: 12px;
  border: 1px solid rgba(30, 27, 24, 0.12);
}

.message--notice {
  background: rgba(49, 41, 32, 0.08);
}

.message--error {
  background: rgba(123, 45, 34, 0.08);
  border-color: rgba(123, 45, 34, 0.18);
  color: #7b2d22;
}

.message--error-detail {
  margin-top: 0.25rem;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 0.88rem;
  color: #5d5449;
}

.quiet-link {
  color: inherit;
}

.turn-echo {
  margin: 0;
  font-size: 0.88rem;
  font-style: italic;
  color: #5d5449;
  opacity: 0.72;
}

/* --- chat page: brought into the book world --- */

.shell--chat {
  max-width: 44rem;
}

.page-chat .panel { width: 100%; max-width: 40rem; }

.chat-thread {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  overflow: visible;
  padding: 0.5rem 0;
}

.chat-thread > * + * {
  margin-top: 1.5rem;
}

.chat-message {
  padding: 0;
  background: transparent;
  border: 0;
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
}

.chat-message--user,
.chat-message--assistant {
  margin-left: 0;
  margin-right: 0;
  background: transparent;
  border: 0;
}

.chat-message--system {
  background: rgba(49, 41, 32, 0.06);
  border: 1px solid rgba(30, 27, 24, 0.12);
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
  text-align: center;
  align-self: center;
  max-width: 32rem;
  font-size: 0.92rem;
  font-style: italic;
  color: #5d5449;
}

.chat-role {
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-variant: small-caps;
  color: #5d5449;
  margin: 0 0 0.35rem;
  opacity: 0.65;
}

.chat-body {
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--ink);
}

.chat-body p {
  margin: 0.4em 0;
}

.chat-body p:first-child {
  margin-top: 0;
}

.chat-body p:last-child {
  margin-bottom: 0;
}

.chat-input-wrap {
  flex: 0 0 auto;
  border-top: 1px solid rgba(30, 27, 24, 0.12);
  padding-top: 0.9rem;
  margin-top: 1rem;
}

.chat-input-form {
  display: flex;
  align-items: flex-end;
}

.chat-input-form > * + * {
  margin-left: 0.5rem;
}

.chat-input-form textarea {
  flex: 1;
  resize: vertical;
  min-height: 2.8rem;
  background: rgba(255, 255, 255, 0.9);
}

/* Legal-copy rhythm.
   `.legal-copy` is always rendered as `<section class="panel stack legal-copy">`,
   so `.stack > * + * { margin-top: 1rem }` already supplies the baseline gap
   between every direct child. We only override that baseline to give headings
   a section break above them. Type sizes still live here because legal pages
   read at a slightly larger size than the rest of the app. */

.legal-copy p {
  margin: 0;
  font-size: 1.04rem;
  line-height: 1.65;
  color: #2f2924;
}

.legal-copy h2 {
  margin: 0;
  margin-top: var(--space-section);
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 1.32rem;
  line-height: 1.2;
  font-weight: 600;
  color: var(--ink);
}

/* Design Review v5 §11 — apply rhythm tokens uniformly across legal copy.
   --space-row (12px): paragraph-to-paragraph inside a section, heading
   to its first paragraph.
   --space-section (36px): between named H2/H3 sections, above the lede.
   --space-page (72px): between top section-nav strip and page H1. */

.legal-copy p + p {
  margin-top: var(--space-row);
}

.legal-copy h3 {
  margin: 0;
  margin-top: var(--space-section);
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--ink);
}

.legal-copy h2 + p,
.legal-copy h3 + p {
  margin-top: var(--space-row);
}

.legal-copy .page-title {
  margin: var(--space-page) 0 0;
}

.legal-copy .page-title + p {
  margin-top: var(--space-row);
}

/* Privacy lede (§09): standalone summary paragraph between the page title
   and the first H2. Reads at intro size, ink-2 colour. */
.legal-copy .legal-lede {
  margin-top: var(--space-row);
  font-size: 1.08rem;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 38rem;
}
.legal-copy .legal-lede + h2 {
  margin-top: var(--space-section);
}

/* Scope list — used on /privacy "What Google sees" to render the four
   OAuth scope names + their plain-language descriptions as term/def rows
   instead of a bulleted prose list. */
.scope-list {
  display: grid;
  grid-template-columns: minmax(11rem, 14rem) 1fr;
  gap: 0.45rem 1.4rem;
  margin: 0.4rem 0 0;
}
.scope-list > div { display: contents; }
.scope-list dt {
  margin: 0;
  padding-top: 2px;
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  word-break: break-word;
}
.scope-list dt code {
  font: inherit;
  color: var(--ink);
  background: transparent;
  padding: 0;
}
.scope-list dd {
  margin: 0;
  color: #2f2924;
  font-size: 1rem;
  line-height: 1.55;
}
@media (max-width: 540px) {
  .scope-list {
    grid-template-columns: 1fr;
    gap: 0.25rem 0;
  }
  .scope-list > div {
    display: block;
    margin-bottom: 0.6rem;
  }
}
.legal-copy .scope-list + p,
.legal-copy dl + p,
.legal-copy table + p,
.legal-copy ul + p,
.legal-copy ol + p {
  margin-top: var(--space-section);
}

.page-privacy .legal-copy,
.page-terms .legal-copy,
.page-safety .legal-copy {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.site-footer {
  width: 100%;
  max-width: 52rem;
  margin: 0 auto;
  padding: 0 1rem calc(1.15rem + env(safe-area-inset-bottom));
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--ink-3);
  text-align: center;
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.72rem;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.18em;
}

.site-footer__copyright {
  white-space: nowrap;
}

.thinking-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(30, 27, 24, 0.44);
}

.thinking-overlay[hidden] {
  display: none;
}

.thinking-card {
  width: 100%;
  max-width: 19rem;
  padding: 1.15rem 1.2rem;
  border: 1px solid rgba(255, 253, 249, 0.22);
  border-radius: var(--radius-m);
  background: #fffdf9;
  color: var(--ink);
  box-shadow: 0 18px 50px rgba(30, 27, 24, 0.24);
  text-align: left;
}

.thinking-card > * + * {
  margin-top: 0.5rem;
}

.thinking-spinner {
  width: 1.4rem;
  height: 1.4rem;
  margin-left: 0;
  margin-right: 0;
  display: block;
  border-radius: 999px;
  border: 2px solid rgba(49, 41, 32, 0.14);
  border-top-color: #312920;
  animation: thinking-spin 760ms linear infinite;
}

.thinking-title {
  display: block;
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, ui-serif, serif;
  font-size: 1.15rem;
  line-height: 1.1;
  font-weight: 600;
}

.thinking-time,
.thinking-note {
  display: block;
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--ink-2);
}

.thinking-time {
  font-variant-numeric: tabular-nums;
}

@keyframes thinking-spin {
  to {
    transform: rotate(360deg);
  }
}

.button--small {
  font-size: 0.78rem;
  padding: 0.35rem 0.7rem;
  min-height: 2rem;
}

.page-settings .page-head,
.page-settings .ruled,
.page-settings .settings-form {
  width: 100%;
  max-width: 38rem;
}

.page-settings .page-title {
  margin-top: 0;
}

.page-settings .shell--page > * + * {
  margin-top: 1.15rem;
}

.page-settings .source-text-input {
  min-height: 12rem;
}

.page-book .shell--book {
  justify-content: flex-start;
}

.page-book .shell--book > .composer-wrap {
  margin-top: 1rem;
}

.page-book .next-actions {
  margin-top: 1rem;
}

.page-book .reader-tools {
  margin-top: 0.75rem;
  padding-top: 0.85rem;
}

.page-source .page-head,
.page-source .ruled {
  max-width: 40rem;
}

.page-source .page-head {
  min-height: 2.9rem;
}

.page-source textarea[name="source_text"] {
  height: 18rem;
}

/* --- stepped responsive: Kindle-safe media queries replacing clamp() --- */

@media (min-width: 600px) {
  .shell {
    --shell-space-y: 2rem;
    padding-left: 1.6rem;
    padding-right: 1.6rem;
  }
  .shell--page > * + *,
  .shell--book > * + * {
    margin-top: 1.6rem;
  }
  .wordmark {
    font-size: 3.6rem;
  }
  .page-title {
    font-size: 2.8rem;
  }
  .book-title {
    font-size: 2.8rem;
  }
  .panel-title {
    font-size: 1.7rem;
  }
  .field-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.95rem;
  }
}

@media (min-width: 900px) {
  .shell {
    --shell-space-y: 2.5rem;
    padding-left: 2.2rem;
    padding-right: 2.2rem;
  }
  .shell--page > * + *,
  .shell--book > * + * {
    margin-top: 1.85rem;
  }
  .wordmark {
    font-size: 4.5rem;
  }
  .page-title {
    font-size: 3.15rem;
  }
  .book-title {
    font-size: 3.3rem;
  }
  .prose {
    line-height: 1.82;
  }
  .panel-title {
    font-size: 1.85rem;
  }

  /* Reading column stays max 44rem regardless of viewport. */
  .shell--page,
  .shell--book {
    max-width: 44rem;
  }
  .shell--page .ruled,
  .shell--page .library-callout,
  .shell--page .settings-sub-form,
  .shell--page .page-head {
    max-width: 100%;
  }
}

/* --- modern enhancement layers --- */

@supports (transition: transform 120ms ease) {
  .button,
  .icon-button,
  .back-link {
    transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
  }
  .button:hover,
  .icon-button:hover,
  .back-link:hover {
    transform: translateY(-1px);
  }
  .button--primary:disabled,
  .icon-button[disabled],
  .icon-button[data-busy="true"] {
    transform: none;
  }
}

/* --- small viewports --- */

@media (max-width: 680px) {
  .composer {
    padding: 0.5rem;
    border-radius: var(--radius-m);
  }
  .page-title {
    font-size: 2rem;
  }
  .lede {
    font-size: 1.08rem;
    line-height: 1.46;
  }
  .wordmark {
    font-size: 2.4rem;
  }
  .hero-top {
    gap: 0.75rem;
  }
  .page-home .hero-top + .lede {
    margin-top: 1.1rem;
  }
  .resume-link {
    max-width: 100%;
    padding: 0.9rem 0.95rem;
  }
  .page-source textarea[name="source_text"] {
    height: 13rem;
  }
  .source-panel-footer {
    gap: 0.65rem;
  }
  .home-input-shell {
    padding-left: 0.45rem;
  }
  .home-input-shell textarea {
    min-height: 2.7rem;
  }
  .home-input-action,
  .composer-submit,
  .composer-cog,
  .icon-button,
  .back-link {
    width: 2.7rem;
    height: 2.7rem;
  }
  /* Mobile: keep classroom Turn-on/Turn-off button anchored right
     so the Connect Google fallback isn't stranded mid-row. */
  .classroom-confirm {
    margin-left: auto;
  }
  .back-link--text {
    width: auto;
    height: auto;
    padding: 0.58rem 0.82rem 0.58rem 0.68rem;
  }
  .actions-row > * {
    flex: 1 1 auto;
  }
  .actions-row form {
    flex: 1 1 auto;
  }
  .reader-tools,
  .reader-tools__group,
  .next-actions {
    display: flex;
  }
  .reader-tool,
  .next-action-button {
    flex: 1 1 auto;
  }
  .classroom-confirm {
    flex: 1 1 100%;
  }
  .classroom-confirm summary {
    width: 100%;
  }
  .classroom-status {
    max-width: 100%;
  }
  .cost-display {
    position: static;
    align-self: flex-start;
    margin-top: 0.5rem;
    max-width: 100%;
  }
  .inline-field {
    padding-left: 0.82rem;
  }
}

/* Phone-width: stack inline-field rows so input placeholders aren't truncated
   by an adjacent button on a single flex row. Applies to API-key rows on
   /settings, library rename, and the chat password row. */
@media (max-width: 480px) {
  .inline-field {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.6rem 0.82rem;
  }
  .inline-field input {
    padding: 0.5rem 0;
  }
  .inline-field__action--submit {
    min-width: 0;
    width: 100%;
  }
}

/* --- print --- */

@page {
  margin: 0.7in;
}

@media print {
  .composer-wrap,
  .footer-strip,
  .site-footer,
  .affiliate-line,
  .actions-row,
  .aux-link,
  .back-link,
  .icon-button,
  .reader-tools,
  .reader-tool,
  .next-actions,
  .next-action-button,
  .generated-audio,
  .mic-panel,
  .transcription-panel,
  .stream-preview,
  .stream-status,
  .cost-display,
  .thinking-overlay {
    display: none;
  }
  .generated-media,
  .generated-image,
  .story-flow__figure {
    display: block;
    max-width: 100%;
    page-break-inside: avoid;
    margin: 12pt 0;
  }
  .generated-image img,
  .story-flow__figure img {
    max-width: 100%;
    height: auto;
  }
  .generated-image figcaption,
  .image-replace-form {
    display: none;
  }
  html,
  body {
    background: #fff;
  }
  body {
    color: #111;
    font-size: 12pt;
    line-height: 1.55;
  }
  .shell,
  .shell--page,
  .shell--book,
  .book,
  .ruled {
    display: block;
    max-width: none;
    min-height: auto;
    width: auto;
    margin: 0;
    padding: 0;
  }
  .ruled {
    border: 0;
    box-shadow: none;
    background: transparent;
  }
  .book-head,
  .prose {
    max-width: none;
  }
  .book-title {
    font-size: 24pt;
    line-height: 1.1;
  }
  .book-byline,
  .page-intro {
    color: #333;
  }
  .prose {
    font-size: 12.5pt;
    line-height: 1.65;
  }
  .prose p {
    margin: 0 0 0.9em;
    orphans: 3;
    widows: 3;
  }
  a {
    color: #111;
    text-decoration: none;
  }
  body::after {
    content: "Flow · inkflow.ing";
    display: block;
    margin-top: 24pt;
    padding-top: 8pt;
    border-top: 1px solid #ccc;
    font-size: 9pt;
    color: #666;
    text-align: center;
  }
}


/* Quiet utilities --------------------------------------------------- */
.inline-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(30,27,24,0.35);
  text-underline-offset: 0.18em;
}
.inline-link:hover { text-decoration-color: currentColor; }

.link-button {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  color: rgba(30,27,24,0.6);
  text-decoration: underline;
  text-decoration-color: rgba(30,27,24,0.3);
  text-underline-offset: 0.18em;
  cursor: pointer;
}
.link-button:hover { color: var(--ink); }

.actions-row--quiet {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(30,27,24,0.08);
}

/* Reader tools: collapse Share / Print / Save / Email behind a … sheet ----- */
.reader-tools-more {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem 0.55rem;
}
.reader-tools-more > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.reader-tools-more > summary::-webkit-details-marker { display: none; }
.reader-tool--more {
  letter-spacing: 0.06em;
}
.reader-tools-more__sheet {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.55rem;
}

[data-story-flow-active]:focus { outline: none; }

/* ===========================================================================
   FINAL DESIGN SYSTEM — 2026-04-30
   Three shells, four buttons, one pill, three pill states.
   These canonical classes are added alongside the existing implementation.
   HTML migrates onto them in subsequent PRs (settings, credits, long-form,
   surgical fixes). Old classes still resolve — no current page breaks.

   THREE SHELLS
   - .shell--reader   /, /book, /library, /share        (paper full-bleed, 36rem)
   - .shell--page     /about /privacy /terms /safety
                      /settings /credits /404            (32rem column, opt-in 22rem aside)
   - .shell--admin    /admin/*                           (untouched layout)

   FOUR BUTTONS
   - .button             filled ink, white text, 999px, 14×22px (max one per surface)
   - .button--secondary  paper-2 fill, ink text, 1px ink rule, same size
   - .act                plain text, 1px underline, ink-2 → ink hover
   - .icon-button        round 44px, ink fill, white glyph (composer only)

   ONE PILL, THREE STATES
   - .pill              base (use with state modifier)
   - .pill--good        Connected / Active / On / Saved
   - .pill--neutral     Off / Not set
   - .pill--warn        Add key / Action needed / Disconnected
   =========================================================================== */


/* --- .button--secondary (canonical secondary CTA).
   Paper-2 fill, ink text, 1px ink rule, 999px, 14×22 padding. */
.button--secondary {
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 14px 22px;
  min-height: 2.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.button--secondary:hover {
  background: var(--paper);
}
.button--secondary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(30, 27, 24, 0.12);
}
.button--secondary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* --- .pill--neutral (canonical neutral state).
   Off / Not set. Paper-2 bg, ink-3 text, no rule. */
.pill--neutral {
  color: var(--ink-3);
  background: var(--paper-2);
  border-color: var(--rule-2);
}

/* --- Design Review v5 finish (2026-05-01) — Setup expanded panels.
   writer-pills + nested key forms + Parent Mode definition + Advanced
   disclosure. Single block at end of file so any earlier rule loses
   the cascade. */
.writer-pills-form {
  margin: 0;
}
.writer-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 var(--space-row);
}
.writer-pill {
  display: inline-flex;
  flex: 1 1 6.5rem;
  min-width: 6.5rem;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-s);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.writer-pill__label,
.writer-pill__note {
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}
.writer-pill:hover {
  border-color: var(--ink);
}
.writer-pill--selected {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.writer-pill--dimmed {
  opacity: 0.5;
  cursor: pointer;
}
.writer-pill--dimmed:hover {
  opacity: 0.7;
  border-color: var(--ink-3);
}
.writer-pill__label {
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.2;
}
.writer-pill__note {
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}
.writer-pill--selected .writer-pill__note {
  color: rgba(243, 237, 225, 0.7);
}
.writer-cta {
  margin: var(--space-row) 0;
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--ink-3);
}
.writer-helper {
  margin: var(--space-row) 0 0;
  font-size: 0.92rem;
  color: var(--ink-2);
}

/* Inline forms inside Setup expanders — sign-out, key save. */
.settings-form__inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: var(--space-row) 0 0;
  padding: 8px 0;
}
.settings-form__inline-label {
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

/* Nested key block inside Voice / Microphone expanders. The hidden-submit
   form is paired with an external <input> via form="..." — submit button
   triggers the right action without the user juggling two controls. */
.settings-form__nested {
  margin: var(--space-row) 0 0;
  padding: 12px 14px;
  border-left: 2px solid var(--rule);
  background: var(--paper-2);
  border-radius: var(--radius-s);
}
.settings-form__hidden-submit {
  margin: 8px 0 0;
}

/* Parent Mode definition block — concrete description + locked/open
   surfaces side-by-side so the toggle has clear semantics before it's
   touched. */
.parent-mode-def {
  margin: 0 0 var(--space-section);
}
.parent-mode-def__lede {
  margin: 0 0 var(--space-row);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
}
.parent-mode-def__cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}
@media (max-width: 540px) {
  .parent-mode-def__cols {
    grid-template-columns: 1fr;
  }
}
.parent-mode-def h4 {
  margin: 0 0 6px;
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.parent-mode-def ul {
  margin: 0;
  padding: 0 0 0 18px;
  list-style: disc;
  color: var(--ink);
  line-height: 1.55;
}

/* Advanced disclosure inside Image model row. */
.settings-advanced {
  margin: var(--space-row) 0 0;
}
.settings-advanced > summary {
  cursor: pointer;
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  list-style: none;
  padding: 4px 0;
}
.settings-advanced > summary::-webkit-details-marker { display: none; }
.settings-advanced > summary::before {
  content: "▸ ";
  display: inline-block;
  margin-right: 4px;
}
.settings-advanced[open] > summary::before {
  content: "▾ ";
}

/* ---------------------------------------------------------------
   Home page — Cover direction (June 2026 redesign)
   ---------------------------------------------------------------- */

.shell--cover {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow: hidden; /* inner .cover-body scrolls */
  padding: 0; /* cover takes full bleed */
  max-width: none; /* full width for cover */
  /* The home <main> also carries .shell--home, whose align-items:center would
     shrink the hero/body to content width and float them with gutters. Force
     stretch so the cover is genuinely edge-to-edge like the design mockup. */
  align-items: stretch;
}

.cover-hero {
  background: var(--orange);
  /* v2 Cohesion mock: an inset rounded card, not a full-bleed rectangle. */
  margin: 0 16px;
  border-radius: var(--radius-m, 14px);
  min-height: 250px;
  flex-shrink: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 24px 24px;
  overflow: hidden;
}

.cover-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(155deg, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0) 55%);
  pointer-events: none;
}

.cover-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.018 0.022' numOctaves='4' seed='8' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30 -8'/%3E%3C/filter%3E%3Crect width='400' height='260' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.18;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.cover-brand {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
  position: relative;
  z-index: 1;
}

.cover-genre-tag {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  margin-bottom: 10px;
}

.cover-title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-variation-settings: "SOFT" 0, "opsz" 60;
  font-size: 37px;
  line-height: 1.02;
  color: white;
  letter-spacing: -0.025em;
  margin-bottom: 11px;
}

.cover-bottom { position: relative; z-index: 1; }

.cover-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: white;
  color: var(--orange);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  text-decoration: none;
}

.cover-body {
  flex: 1;
  padding: 20px 20px 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

.mini-list { display: flex; flex-direction: column; }


/* ============================================================
   Responsive home (Josh, 2026-06-29)
   MOBILE  ≤759px → Cover  (.home-cover)   — the orange Lebowski hero + chapters
   DESKTOP ≥760px → Landing (.home-landing) — Claude Design's "Flow - Home.html"
   Both blocks are server-rendered; CSS shows exactly one per viewport.
   ============================================================ */
.shell--responsive-home {
  /* mobile-first: behave like the full-bleed cover shell */
  padding: 0;
  max-width: none;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  align-items: stretch;
}
.home-cover {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.home-landing { display: none; }

@media (min-width: 760px) {
  .shell--responsive-home {
    display: block;
    min-height: 0;
    overflow: visible;
    padding: 0;
    max-width: none;
  }
  .home-cover { display: none; }
  .home-landing { display: block; }
  body.page-home { background: #f6f1e7; } /* match the landing paper edge-to-edge */
}

/* ---------- Desktop landing — ported from Claude Design "Flow - Home.html",
   namespaced .lp-* and with the design palette scoped to .home-landing so no
   global token is touched. Only shown ≥760px (see toggle above). ---------- */
.home-landing {
  --paper: #f6f1e7;
  --paper-card: #fffdf8;
  --paper-2: #efe8d9;
  --ink: #211c18;
  --ink-2: #4d4639;
  --ink-3: #8a8071;
  --rule: rgba(33, 28, 24, 0.13);
  --rule-soft: rgba(33, 28, 24, 0.07);
  --ember: #c0531f;
  --lp-shadow: 0 1px 2px rgba(40, 30, 20, 0.05), 0 18px 44px -18px rgba(40, 30, 20, 0.22);
  --lp-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --lp-display: "Fraunces", Georgia, serif;
  --lp-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  position: relative;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--lp-serif);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.home-landing::before { /* whisper of grain, confined to the landing */
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='ng'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23ng)'/%3E%3C/svg%3E");
}
.lp-page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 40px;
}
.home-landing .lp-eyebrow {
  font-family: var(--lp-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.lp-rule { height: 1px; background: var(--rule); border: 0; }

/* hero */
.lp-hero { max-width: 600px; margin: 0 auto; padding: 110px 0 24px; }
.lp-hero .lp-eyebrow { display: block; margin-bottom: 18px; }
.lp-wordmark {
  font-family: var(--lp-display);
  font-weight: 500;
  font-size: 92px;
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 26px;
}
.lp-lede { font-size: 22px; line-height: 1.5; color: var(--ink-2); max-width: 36ch; }
.lp-lede .lp-free {
  display: block;
  margin-top: 10px;
  font-family: var(--lp-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  text-transform: uppercase;
}

/* composer */
.lp-composer {
  margin-top: 36px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper-card);
  border: 1px solid var(--rule-soft);
  border-radius: 18px;
  padding: 10px 10px 10px 14px;
  box-shadow: var(--lp-shadow);
}
.lp-composer__tune {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.lp-composer__tune:hover { background: var(--paper-2); color: var(--ink); }
.lp-composer__input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  resize: none;
  font-family: var(--lp-serif);
  font-size: 18px;
  line-height: 1.4;
  color: var(--ink);
  padding: 6px 0;
}
.lp-composer__input::placeholder { color: var(--ink-3); }
.lp-composer__send {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.lp-composer__send:hover { transform: translateX(1px); background: #000; }

/* A7 + design fidelity: the mobile cover composer matches the v2 Cohesion mock —
   no oversized top gap, a small FLAT tune icon (not a bordered 42px circle), and an
   orange accent send. Scoped to .home-cover so the desktop .home-landing composer
   keeps the .lp-composer base styling above. */
.home-cover .lp-composer { margin-top: 8px; align-items: flex-end; gap: 8px; padding: 10px 10px 10px 15px; border-radius: var(--radius-m, 14px); }
.home-cover .lp-composer__tune { width: 30px; height: 30px; border: 0; border-radius: 0; background: transparent; color: var(--ink-3); align-self: center; }
.home-cover .lp-composer__tune:hover { background: transparent; color: var(--ink); }
.home-cover .lp-composer__send { width: 38px; height: 38px; border-radius: var(--radius-pill, 999px); background: var(--orange); }
.home-cover .lp-composer__send:hover { transform: translateX(1px); background: var(--orange); filter: brightness(0.94); }

/* example starts */
.lp-starts { margin-top: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.lp-starts__label {
  font-family: var(--lp-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-right: 2px;
}
.lp-chip {
  font-family: var(--lp-serif);
  font-size: 14.5px;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 9999px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.lp-chip:hover { background: var(--paper-card); border-color: var(--ink-3); color: var(--ink); }
.lp-chip--paste { display: inline-flex; align-items: center; gap: 6px; }
.lp-chip--paste svg { width: 13px; height: 13px; }

/* sections */
.lp-section { padding: 88px 0; }
.lp-section__head { max-width: 600px; margin: 0 auto 34px; }
.lp-section__head .lp-eyebrow { display: block; margin-bottom: 12px; }
.lp-section__title {
  font-family: var(--lp-display);
  font-weight: 500;
  font-size: 32px;
  line-height: 1.12;
  letter-spacing: -0.015em;
  color: var(--ink);
}

/* steps */
.lp-steps { max-width: 860px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 34px; }
.lp-step { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
.lp-step__num { font-family: var(--lp-mono); font-size: 12px; font-weight: 600; letter-spacing: 0.1em; color: var(--ember); }
.lp-step__title {
  font-family: var(--lp-display);
  font-weight: 500;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 3px;
}
.lp-step__body { font-size: 16.5px; color: var(--ink-2); line-height: 1.5; }

/* reader preview */
.lp-preview-wrap { max-width: 600px; margin: 0 auto; }
.lp-reader {
  background: var(--paper-card);
  border: 1px solid var(--rule-soft);
  border-radius: 20px;
  box-shadow: var(--lp-shadow);
  overflow: hidden;
}
.lp-reader__page { padding: 36px 38px 26px; }
.lp-reader__byline {
  font-family: var(--lp-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 16px;
}
.lp-reader__title {
  font-family: var(--lp-display);
  font-weight: 500;
  font-size: 24px;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin-bottom: 14px;
}
.lp-reader__prose p { font-size: 18.5px; line-height: 1.66; color: var(--ink); margin-bottom: 14px; }
.lp-reader__prose p:last-child { margin-bottom: 0; }
.lp-illus {
  margin: 18px 0 4px;
  height: 150px;
  border-radius: 12px;
  border: 1px solid var(--rule-soft);
  background-color: var(--paper-2);
  background-image: repeating-linear-gradient(135deg, rgba(33,28,24,0.05) 0 2px, transparent 2px 11px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lp-illus span {
  font-family: var(--lp-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* steering bar */
.lp-steer { border-top: 1px solid var(--rule-soft); background: var(--paper); padding: 16px 18px 18px; }
.lp-steer__suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.lp-choice {
  font-family: var(--lp-serif);
  font-size: 14px;
  color: var(--ink-2);
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 9999px;
  padding: 5px 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.lp-choice::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--ember); flex-shrink: 0; }
.lp-steer__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 8px 8px 8px 16px;
}
.lp-steer__bar > span:first-child { flex: 1; font-family: var(--lp-serif); font-size: 16px; color: var(--ink-3); }
.lp-steer__send {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* capabilities */
.lp-caps {
  max-width: 760px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--rule-soft);
  border: 1px solid var(--rule-soft);
  border-radius: 16px;
  overflow: hidden;
}
.lp-cap { background: var(--paper); padding: 22px 24px; }
.lp-cap__label {
  font-family: var(--lp-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 8px;
}
.lp-cap__body { font-size: 15.5px; line-height: 1.5; color: var(--ink-2); }

/* ============================================================
   Mobile cover — new elements (2026-06-30)
   Additive styles for the responsive mobile home cover.
   ============================================================ */
.cover-eyebrow{display:inline-flex;align-items:center;gap:7px;align-self:flex-start;font-family:"JetBrains Mono",monospace;font-size:9.5px;font-weight:600;letter-spacing:.16em;text-transform:uppercase;color:var(--orange);background:rgba(255,255,255,.92);padding:4px 10px;border-radius:var(--radius-pill);position:relative;z-index:1}
.cover-byline{font-family:"Source Serif 4",Georgia,serif;font-size:13px;font-style:italic;color:rgba(255,255,255,.82);line-height:1.4}
.home-start{padding:30px 24px 4px}
.home-start__lead{font-family:"Source Serif 4",Georgia,serif;font-size:18px;line-height:1.42;color:var(--ink);letter-spacing:-.01em;margin-bottom:18px;text-wrap:pretty}
.home-start__lead b{font-weight:600}
.starts{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-top:16px}
.chip{font-family:"JetBrains Mono",monospace;font-size:11px;letter-spacing:.01em;color:var(--ink-2);background:transparent;border:1px solid var(--rule);border-radius:var(--radius-pill);padding:6px 12px;cursor:pointer;display:inline-flex;align-items:center;gap:6px}
.chip svg{width:13px;height:13px}
.chip--paste{display:inline-flex;align-items:center;gap:6px}
.free-line{font-family:"JetBrains Mono",monospace;font-size:10px;letter-spacing:.05em;color:var(--ink-3);margin-top:18px}
/* calm TOC */
.cover-body{margin-top:32px}
.section-label{font-family:"JetBrains Mono",ui-monospace,monospace;font-size:10px;font-weight:600;letter-spacing:0.2em;text-transform:uppercase;color:var(--ink-3);margin:0 0 14px;padding-top:22px;border-top:1px solid var(--rule-soft)}
.mini-row{display:flex;align-items:flex-start;gap:12px;justify-content:space-between;padding:14px 0;border-bottom:1px solid var(--rule-soft)}
.mini-row:last-child{border-bottom:none}
.mini-row__body{flex:1;min-width:0}
.mini-row__title{font-family:"Source Serif 4","Iowan Old Style",Georgia,serif;font-size:15px;font-weight:600;color:var(--ink);margin-bottom:4px;line-height:1.3}
.mini-row__meta{font-family:"JetBrains Mono",ui-monospace,monospace;font-size:10.5px;letter-spacing:0.02em;color:var(--ink-3);line-height:1.5}
.mini-row__arrow{font-family:"JetBrains Mono",ui-monospace,monospace;font-size:14px;color:var(--ink-3);flex-shrink:0;padding-top:2px}

/* ============================================================
   W3–W25 walkthrough fixes (2026-06-30) — appended so the
   later cascade wins over the base rules above.
   ============================================================ */

/* W3: /book title picks up the home Fraunces display axis. */
.book-title { font-variation-settings: "SOFT" 40, "opsz" 120; letter-spacing: -0.02em; }
/* W3: on-theme tokens for reader chrome (were hardcoded white / #433b33). */
.reader-tool { background: var(--paper-card); }
.book-byline { color: var(--ink-2); }

/* W7: save-state badge (was an unstyled raw span) + its header row. */
.book-head__top { display: flex; align-items: center; justify-content: flex-end; min-height: 1.4rem; }
.save-state-badge {
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-3); opacity: 0.7;
}
.save-state-badge--local { opacity: 0.55; }
.save-state-badge--saved { color: var(--live); opacity: 1; }
.save-state-badge--failed { color: #8b2c1e; opacity: 1; }
.save-state-badge--exported { color: var(--ink-2); opacity: 1; }

/* W4: the /book footer was emitted but had no matching rule (invisible). */
.site-footer--book {
  width: 100%; max-width: 42rem; margin: 2.5rem auto 0;
  padding: 1.25rem 0 2rem; border-top: 1px solid var(--rule-2);
  display: flex; flex-direction: column; gap: 0.75rem; align-items: flex-start;
}
.site-footer--book .site-footer__links { font-size: 0.85rem; color: var(--ink-3); }
.site-footer--book .site-footer__links a { color: var(--ink-2); text-decoration: none; }
.site-footer--book .site-footer__links a:hover { text-decoration: underline; }

/* W5: reader-tool buttons sat "in the air" — each button was wrapped in its own
   <form>, breaking the flex row. display:contents drops the form box so the
   buttons align as direct flex items. */
.reader-tools { align-self: flex-start; }
.reader-tools__group > form { display: contents; }

/* W6: the Google connect CTA is pulled out of the tools row into its own line. */
.book-connect-cta {
  width: 100%; max-width: 42rem; margin: 0.6rem auto 0;
  font-size: 0.82rem; color: var(--ink-3); line-height: 1.4;
}
.book-connect-cta a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }

/* W10: clearer no-key image affordance. */
.reader-tool--setup { font-style: italic; color: var(--ink-3); }

/* W9: home composer microphone, consistent with the tune/send controls. */
.lp-composer__mic {
  flex-shrink: 0; width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink-3);
  cursor: pointer; transition: background 0.15s ease, color 0.15s ease;
}
.lp-composer__mic:hover { background: var(--paper-2); color: var(--ink); }
.lp-composer__mic[aria-pressed="true"] { color: var(--live); }
.home-cover .lp-composer__mic { width: 32px; height: 32px; }

/* W22: prefill text was stuck top/bottom in an oversized field — center the single
   line in the composer and cap growth. */
.lp-composer__input { padding: 2px 0; align-self: center; max-height: 120px; overflow-y: auto; }
.home-cover .lp-composer { align-items: center; }

/* W25: prominent resume affordance (was near-invisible --ink-3 micro text). */
.home-resume-btn {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 18px; padding: 10px 18px;
  background: var(--paper-card); border: 1px solid var(--rule);
  border-radius: var(--radius-pill, 999px);
  font-family: var(--lp-serif); font-size: 15px; color: var(--ink);
  text-decoration: none; transition: background 0.14s ease, border-color 0.14s ease;
}
.home-resume-btn:hover { background: var(--paper-2); border-color: var(--ink-3); }
.home-resume-btn__lead { font-weight: 600; }
.home-resume-btn__meta {
  font-size: 12px; color: var(--ink-3);
  font-family: "JetBrains Mono", ui-monospace, monospace; letter-spacing: 0.03em;
}

/* W15: parent-mode no-Google notice spacing. */
.settings-form--notice { padding: 2px 0; }

/* ============================================================
   §1.7 / §4-A — Page topbar header system
   Used on: page-settings, page-library, page-credits,
   page-privacy, page-terms, page-safety, page-chat.
   ============================================================ */
.page-topbar{width:100%;max-width:44rem;margin:0 auto;display:flex;align-items:baseline;justify-content:space-between;gap:1rem;padding:20px 1rem 14px;border-bottom:1px solid var(--rule);}
.page-topbar__brand{font-family:"Fraunces",Georgia,ui-serif,serif;font-size:1.45rem;font-weight:600;letter-spacing:-.02em;font-variation-settings:"SOFT" 40,"opsz" 90;color:var(--ink);text-decoration:none;line-height:1;}
.page-topbar__nav{display:flex;gap:16px;font-family:"JetBrains Mono",ui-monospace,monospace;font-size:11px;letter-spacing:.11em;text-transform:uppercase;}
.page-topbar__nav a{color:var(--ink-3);text-decoration:none;}
.page-topbar__nav a:hover,.page-topbar__nav a[aria-current="page"]{color:var(--ink);}
.page-title--topbar{width:100%;max-width:44rem;margin:22px auto 4px;text-align:left;}

/* ============================================================
   §C — New utility / component classes
   ============================================================ */

/* Grouping card — calm panel; does not clash with .ruled sections */
.panel { background: var(--paper, #fff); border: 1px solid var(--rule); border-radius: 12px; padding: 20px; }

/* Flat callout replacing old inline yellow card */
.callout { border:1px solid var(--rule); border-left:3px solid var(--ink-3); background:transparent; padding:1rem; border-radius:.5rem; }
.callout--save { }

/* Credits amount */
.amount-lg { font-size:1.25rem; margin:0; }

/* Clear-history form spacing */
.form--clear-history { margin-top:0.25rem; }

/* Admin kill-active link */
.kill-active { color:#a02; font-weight:600; }

/* Admin tables */
.admin-table { width:100%; border-collapse:collapse; font-size:13px; }
.admin-table th,.admin-table td{ text-align:left; padding:6px 10px; border-bottom:1px solid var(--rule-soft); }
.admin-table thead th{ border-bottom:1px solid var(--rule); font-family:"JetBrains Mono",ui-monospace,monospace; font-size:11px; letter-spacing:.08em; text-transform:uppercase; color:var(--ink-3); }
.admin-table tbody tr:nth-child(even){ background:var(--rule-soft); }

/* Centered empty-state block */
.empty-state { display:flex; flex-direction:column; align-items:center; gap:14px; text-align:center; padding:40px 1rem; }
.empty-state__lede { font-family:"Fraunces",Georgia,ui-serif,serif; font-size:1.15rem; color:var(--ink); margin:0; max-width:24rem; }

/* Parent-mode flat rows */
.parent-mode-def__rows { display:flex; flex-direction:column; }
.parent-mode-def__row { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:10px 0; border-bottom:1px solid var(--rule-soft); }
.parent-mode-def__row:last-child{ border-bottom:none; }
.parent-mode-def__row--locked { }
.parent-mode-def__row--open { }
.parent-mode-def__item { color:var(--ink); }
.parent-mode-def__badge { flex:0 0 auto; }

/* Setup sheet bare states — canonical rules already exist at ~line 2426; no duplicate needed. */
