/* Bluewell Design reader: the reflowable profile, first draft (spec 15).
   Every colour, font and size comes from tokens/bluewell.css (--bluewell-*).
   Themes: html[data-theme] (set by reader.js from the reader's choice, the system's
   colour scheme, or an e-ink/grayscale display). */

/* Fonts: IBM Plex from the repository. A hosted site would serve subset WOFF2 files. */
@font-face { font-family: "IBM Plex Serif"; src: url("../fonts/IBMPlexSerif-Regular.otf"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Serif"; src: url("../fonts/IBMPlexSerif-Italic.otf"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "IBM Plex Serif"; src: url("../fonts/IBMPlexSerif-Light.otf"); font-weight: 300; font-display: swap; }
@font-face { font-family: "IBM Plex Serif"; src: url("../fonts/IBMPlexSerif-SemiBold.otf"); font-weight: 600; font-display: swap; }
/* Hebrew, which IBM Plex Serif lacks: IBM Plex Sans Hebrew within the serif family, loaded only by a
   page that holds Hebrew letters */
@font-face { font-family: "IBM Plex Serif"; src: url("../fonts/IBMPlexSansHebrew-Regular.ttf"); font-weight: 300 400;
  font-display: swap; unicode-range: U+0590-05FF, U+FB1D-FB4F; }
@font-face { font-family: "IBM Plex Serif"; src: url("../fonts/IBMPlexSansHebrew-SemiBold.ttf"); font-weight: 600;
  font-display: swap; unicode-range: U+0590-05FF, U+FB1D-FB4F; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/IBMPlexSans-Regular.otf"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/IBMPlexSans-Light.otf"); font-weight: 300; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/IBMPlexSans-SemiBold.otf"); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/IBMPlexSans-Bold.otf"); font-weight: 700; font-display: swap; }

:root {
  --t: var(--bluewell-ink);
  --ground: var(--bluewell-paper);
  --accent: var(--bluewell-primary);
  --mist: var(--bluewell-mist);
  --size: 18px;                       /* reader setting: A− / A+ */
  --leading: var(--bluewell-layout-literary-line-height);
  --measure: 34em;                    /* about 66 characters of Plex Serif */
  --bar: 44px;
  --gap: 48px;                        /* gutter between pages in paged mode */
  /* a highlight is the theme's highlight colour (the result tint): ink stays at 7:1 or better */
  --hl: var(--bluewell-highlight);
  color-scheme: light;
}
html[data-theme$="-dark"] { color-scheme: dark; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: auto; } .bar, .rail { transition: transform 0.2s ease, height 0.15s ease; } }

* { box-sizing: border-box; }
html { background: var(--ground); }
body {
  margin: 0; background: var(--ground); color: var(--t);
  font-family: var(--bluewell-font-serif); font-size: var(--size); line-height: var(--leading);
  font-kerning: normal; font-variant-ligatures: common-ligatures;
  -webkit-text-size-adjust: 100%;
}
body.classical { font-variant-numeric: oldstyle-nums; }
a { color: var(--accent); }
html[data-link-underline="false"] .book a { text-decoration: none; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 10; background: var(--ground); padding: 6px 10px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Bar: the reader's only chrome ─────────────────────────────────── */
.bar {
  position: sticky; top: 0; z-index: 5; height: var(--bar);
  display: flex; align-items: center; gap: 4px; padding: 0 12px;
  background: var(--ground); border-bottom: 0.5pt solid var(--mist);
  font-family: var(--bluewell-font-sans); font-size: 13px;
  font-variant-numeric: lining-nums;
}
/* The bar is the book's running head (spec 12.3): the title in the voice's running-title style, the
   short rule, then the place between the chapter arrows; the controls at the right */
.running-head { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; padding-left: 6px; }
.bar-book, .bar-title { font-family: var(--bluewell-font-serif); font-style: italic;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.bar-book { flex: 0 1 auto; max-width: 38%; color: var(--t); text-decoration: none; }
a.bar-book:hover { color: var(--accent); }
/* the short rule is also the book's gauge, read in Primary on Mist as the rail is (Ink against
   Primary falls below 3:1 in the dark, warm and monochrome themes) */
.bar-rule { flex: none; position: relative; width: 9mm; height: 1.5pt; margin: 0 10px; background: var(--mist); }
.bar-rule-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent); }
.bar-title { flex: 0 1 auto; }
.bar-arrow { padding: 4px 8px 6px; font-family: var(--bluewell-font-serif); font-size: 22px; font-weight: 400;
  letter-spacing: 0; text-transform: none; line-height: 1; }
.bar-arrow:disabled { opacity: 0.25; cursor: default; }
.bar-arrow:disabled:hover { color: var(--t); }
/* while reading, the bar slides away; the rail stays */
body.chrome-hidden .bar { transform: translateY(-100%); }
.bar-progress { font-weight: 300; text-align: right; margin-right: 6px; white-space: nowrap; }
/* the book's title gives way first, on narrower screens; the rule stays, as the book's gauge */
@media (max-width: 860px) { .bar-book { display: none; } }
.bar-btn, .settings button, .panel-btn, .hl-tool button, .nb-actions button {
  font: inherit; font-family: var(--bluewell-font-sans); color: var(--t); background: none;
  border: 0; padding: 6px 10px; cursor: pointer;
  font-size: 14px; font-weight: 400;
}
.bar-btn:hover, .bar-btn[aria-expanded="true"], .panel-btn:hover, .nb-actions button:hover { color: var(--accent); }
/* the settings button: a capital A and a smaller capital A, on one baseline */
.aa { letter-spacing: 0.02em; } .aa span { font-size: 0.75em; }

/* ── Sidebar: the contents or the notebook, one at a time ──────────── */
.sidebar {
  position: fixed; z-index: 6; top: var(--bar); bottom: 0; left: 0; width: min(320px, 86vw);
  overflow-y: auto; padding: 8px 20px 40px; background: var(--ground);
  border-right: 0.5pt solid var(--mist); font-size: 15px; line-height: 1.4;
}
/* beside the text: in scroll mode on a wide screen the column moves right of the open sidebar, and
   full-width openers start at its edge */
@media (min-width: 1000px) {
  body.side-open:not(.paged) main { margin-left: 320px; }
  body.side-open:not(.paged) :is(.cover, .part-opener) { margin-left: calc(50% - 50vw + 160px); margin-right: calc(50% - 50vw + 160px); }
}
.toc, .toc ol, .nb-list { list-style: none; padding: 0; margin: 0; }
.toc > li { margin: 10px 0; }
.toc > li > a { font-weight: 600; }
.toc ol { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 4px; font-size: 14px; }
.toc a, .nb-quote { color: var(--t); text-decoration: none; }
.toc a:hover, .nb-quote:hover { color: var(--accent); }
.toc a[aria-current] { color: var(--accent); }
.toc ol a[aria-current] { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.toc > li > a[aria-current] { text-decoration: underline; text-underline-offset: 3px; }
.hl-where { display: block; font-family: var(--bluewell-font-sans); font-size: 12px;
  color: var(--bluewell-graphite); margin-bottom: 2px; }
/* the place, at the top of the contents: on phones, where the bar has no room for it */
.here { display: none; margin: 4px 0 10px; font-family: var(--bluewell-font-sans); font-size: 12px;
  color: var(--bluewell-graphite); }
/* a panel's head: its title as a label above a rule (the contents: the book, linking to its page;
   the notebook: Highlights & Notes), and an action at the right (Library; Export) */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-bottom: 1.5pt solid var(--t); margin: 4px 0 2px; }
a.panel-title { color: var(--t); text-decoration: none; }
a.panel-title:hover { color: var(--accent); }
a.panel-btn { color: var(--accent); text-decoration: none; white-space: nowrap; }
[data-panel="toc"] .panel-head { margin-bottom: 10px; }
.panel-title { margin: 0; padding: 6px 0; font-family: var(--bluewell-font-sans); font-size: 15px;
  font-weight: 600; }
.panel-btn { margin-right: -10px; }
.notebook .empty { font-family: var(--bluewell-font-sans); font-size: 13px; }
.nb-list li { padding: 10px 0 4px; border-bottom: 0.5pt solid var(--mist); }
.nb-quote { display: block; }
.nb-note { margin: 6px 0 0; font-family: var(--bluewell-font-sans); font-size: 14px; white-space: pre-wrap; }
.nb-edit { display: block; box-sizing: border-box; width: 100%; margin: 8px 0 0; padding: 6px 8px; resize: vertical;
  font: 14px/1.4 var(--bluewell-font-sans); color: var(--t); background: var(--bluewell-surface-neutral);
  border: 0; border-bottom: 1.5pt solid var(--accent); }
.nb-edit:focus-visible { outline: none; }
.nb-actions { display: flex; gap: 4px; margin: 2px 0 0 -10px; }

.settings {
  position: fixed; z-index: 6; top: var(--bar); right: 8px; width: 280px; padding: 12px 16px;
  max-height: calc(100vh - var(--bar) - 8px); max-height: calc(100dvh - var(--bar) - 8px); overflow-y: auto;
  background: var(--ground); border: 0.5pt solid var(--mist);
  font-family: var(--bluewell-font-sans); font-size: 14px;
}
.settings fieldset { border: 0; padding: 0; margin: 0 0 12px; }
.settings legend { font-size: 13px; font-weight: 600; color: var(--t); margin-bottom: 4px; }
.settings label { display: block; padding: 3px 0; }
/* Theme swatches: each is its theme's page, "Aa" in its ink, bordered in its primary. The chip
   carries data-theme, so the token variables inside it are that theme's; outside it, the page's. */
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 8px; }
.settings label.swatch { display: flex; flex-direction: column; gap: 5px; padding: 2px; cursor: pointer; position: relative; }
.swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.chip { display: flex; align-items: center; justify-content: center; height: 46px;
  background: var(--bluewell-paper); color: var(--bluewell-ink);
  border: 2px solid var(--bluewell-primary);
  font-family: var(--bluewell-font-serif); font-size: 21px; line-height: 1; }
.chip-auto { display: grid; grid-template-columns: 1fr 1fr; }
.chip-auto > span { display: flex; align-items: center; height: 100%;
  background: var(--bluewell-paper); color: var(--bluewell-ink); }
.chip-auto > span:first-child { justify-content: flex-end; }
.swatch-name { font-size: 11px; line-height: 1.25; text-align: center; color: var(--t); }
/* the chosen theme: a ring in the page's ink around the chip, and its name in SemiBold */
.swatch input:checked + .chip { outline: 2px solid var(--t); outline-offset: 2px; }
.swatch input:checked ~ .swatch-name { font-weight: 600; }
.swatch input:focus-visible ~ .swatch-name { text-decoration: underline; text-underline-offset: 3px; }
.swatch:hover .swatch-name { color: var(--accent); }
/* Style swatches: the page's own colours, "Aa" in each voice's display type */
.chip-classical, .chip-modern { background: var(--ground); color: var(--t); border-color: var(--accent); }
.chip-classical { font-weight: 300; font-size: 22px; }
.chip-modern { font-family: var(--bluewell-font-sans); font-weight: 700; font-size: 20px; }

/* ── The text ──────────────────────────────────────────────────────── */
main { padding: 0 20px; }
.book { max-width: var(--measure); margin: 0 auto; padding-bottom: 30vh; }
.book p {
  margin: 0; text-indent: 1.4em; text-align: justify; hyphens: auto; hanging-punctuation: first;
}
html.ragged .book p { text-align: left; }
/* One chapter at a time (spec 15.4): the other units are not laid out at all */
.unit-away { display: none !important; }
.unit-nav { display: none; }
body:is(.chaptered, .collection):not(.paged) .book { padding-bottom: 3em; }
body:is(.chaptered, .collection):not(.paged) .unit-nav {
  display: flex; gap: 24px; justify-content: space-between; max-width: var(--measure); margin: 0 auto;
  padding: 1.1em 0 30vh; border-top: 0.5pt solid var(--mist); font-family: var(--bluewell-font-sans);
}
.unit-nav a { display: flex; flex-direction: column; gap: 4px; max-width: 48%; color: var(--t); text-decoration: none; }
.unit-nav .next { margin-left: auto; align-items: flex-end; text-align: right; }
.unit-label { font-size: 13px; color: var(--bluewell-graphite); }
.unit-title { font-family: var(--bluewell-font-serif); line-height: 1.3; }
.unit-nav a:hover .unit-title { color: var(--accent); }
.book h3 + p, .book .scene-break + p, .book .opening, .front p, .cover p { text-indent: 0; }

/* Raised initial and lead-in: styling only, the text stays as written */
.opening::first-letter {
  font-weight: 300; font-size: 3.1em; line-height: 1; color: var(--accent);
  padding-right: 0.04em;
}
.lead-in { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.86em; }
.smcaps { text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.84em; }

/* Sections: numeral under the short Ink rule */
.section {
  margin: 2.4em 0 1.25em; font-weight: 400; font-size: 1.05em; letter-spacing: 0.08em;
  color: var(--accent); line-height: 1;
}
.section::before { content: ""; display: block; width: 9mm; height: 1.5pt; background: var(--t); margin-bottom: 8pt; }

/* Scene break: three Primary squares; an <hr> is announced as a separator */
.scene-break {
  border: 0; width: calc(3 * 3.2pt + 14px); height: 3.2pt; margin: 1.3em auto;
  --sq: linear-gradient(var(--accent), var(--accent));
  background: var(--sq) 0 0 / 3.2pt 3.2pt no-repeat, var(--sq) 50% 0 / 3.2pt 3.2pt no-repeat,
              var(--sq) 100% 0 / 3.2pt 3.2pt no-repeat;
}

/* Footnotes: a Primary number that opens the note in place */
.fn {
  font: inherit; font-size: 0.7em; vertical-align: super; line-height: 0; color: var(--accent);
  background: none; border: 0; padding: 0 0.1em; cursor: pointer; font-variant-numeric: lining-nums;
}
.note {
  inset: auto; margin: 0; max-width: min(32em, 90vw); padding: 12px 16px;
  font-size: 0.85em; line-height: 1.45; text-indent: 0; text-align: left;
  color: var(--t); background: var(--bluewell-surface-definition); border: 0;   /* the Primary tint, like its number */
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
}
.note-n { color: var(--accent); margin-right: 0.6em; font-family: var(--bluewell-font-sans); font-weight: 600; }
/* The notes listed at the end of a unit: quiet, smaller, after a Mist hairline; each number leads back */
.unit-notes { margin: 3em 0 0; padding-top: 0.9em; border-top: 0.5pt solid var(--mist); font-size: 0.85em; line-height: 1.45; }
.unit-notes-title { margin-bottom: 0.7em; font-family: var(--bluewell-font-sans); font-size: 13px; font-weight: 600;
  color: var(--bluewell-graphite); }
.unit-notes ol { list-style: none; margin: 0; padding: 0; }
.unit-notes li { display: grid; grid-template-columns: 2.4em 1fr; margin: 0 0 0.55em; break-inside: avoid; }
.unit-note-n { color: var(--accent); text-decoration: none; font-family: var(--bluewell-font-sans); font-weight: 600;
  font-variant-numeric: lining-nums; }
.unit-note-n:hover { text-decoration: underline; text-underline-offset: 3px; }
.unit-note-body .note-p { display: block; } .unit-note-body .note-p + .note-p { margin-top: 0.35em; }
.unit-note-body :is(.note-verse, .note-quote) { display: block; margin: 0.35em 0 0.35em 1.2em; }
.unit-note-body .note-verse .line { display: block; }
.unit-note-body .cite { display: block; margin-top: 0.2em; }
/* the mark a note's number led back to, for a moment */
.fn.flash { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Cover and part openers: the artwork, full width, title lower left ─ */
.cover, .part-opener { position: relative; margin: 0 calc(50% - 50vw) 3em; min-height: 72vh;
  display: flex; align-items: flex-end; }
.cover-art, .opener-art { position: absolute; inset: 0; }
.cover-art img, .opener-art img { width: 100%; height: 100%; object-fit: cover; display: none; }
html:is([data-theme="computational"], :not([data-theme])) .art-light,
html[data-theme="computational-dark"] .art-dark,
html[data-theme="editorial"] .art-cerulean,
html[data-theme="editorial-dark"] .art-cerulean-dark,
html[data-theme="monochrome"] .art-mono,
html[data-theme="stone"] .art-stone,
html[data-theme="lotus"] .art-lotus { display: block; }
html[data-theme="stone"], html[data-theme="lotus"] { color-scheme: light; }
.opener-text { position: relative; width: min(var(--measure), 100% - 40px); margin: 0 auto 6vh; }
.cover h1, .part-opener h2 { font-weight: 300; font-size: 2.6em; line-height: 1.05; margin: 0; }
.part-opener h2 { font-size: 1.9em; }
html[data-theme$="-dark"] .cover h1, html[data-theme$="-dark"] .part-opener h2,
html[data-theme$="-dark"] .author { color: var(--bluewell-on-art-fg); }
.opener-rule { border: 0; border-top: 0.8pt solid currentColor; margin: 16px 0 8px; color: var(--t); }
.author { margin: 0; letter-spacing: 0.16em; text-transform: uppercase; font-size: 0.8em; }
/* a story's byline on its opener (its translator, its year), as on the title page (12.7): Serif Italic */
.book .opener-text p.byline { margin: 0; text-indent: 0; text-align: left; font-style: italic; font-size: 0.9em; line-height: 1.4; }
html[data-theme$="-dark"] .opener-text .byline { color: var(--bluewell-on-art-fg); }
/* read by assistive technology, not shown (a collection's story page names its book in an h1) */
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.front { margin: 0 0 4em; font-size: 0.8em; line-height: 1.5; }
.front .translator { font-style: italic; }

/* ── Highlights ────────────────────────────────────────────────────── */
mark.hl { background: var(--hl); color: inherit; padding: 0.05em 0; cursor: pointer; }
/* a link inside a highlight is underlined: its colour alone is too close to the tint */
html .book a:has(> mark.hl) { text-decoration: underline; text-underline-offset: 0.15em; }
.hl-tool { position: fixed; z-index: 7; background: var(--bluewell-label-bg); padding: 2px;
  max-width: min(320px, calc(100vw - 16px)); }
.hl-actions { display: flex; }
.hl-note-text { margin: 0; padding: 8px 10px 4px; color: var(--bluewell-label-fg); max-height: 9em; overflow: auto;
  font-family: var(--bluewell-font-sans); font-size: 13px; line-height: 1.4; white-space: pre-wrap; }
/* a highlight with a note ends in a small square, the system's own mark */
mark.hl.note-end::after { content: ""; display: inline-block; width: 0.3em; height: 0.3em; margin-left: 0.12em;
  vertical-align: 0.55em; background: var(--accent); }
.hl-tool button { color: var(--bluewell-label-fg); }
.hl-tool button[hidden] { display: none; }

/* ── Paged mode (tablets): the text in columns one screen wide ─────── */
/* the visible height (dvh), so nothing sits under a phone browser's toolbar */
body.paged { overflow: hidden; height: 100vh; height: 100dvh; }
/* the bar floats over a reserved top margin, so showing or hiding it never reflows the pages */
body.paged .bar { position: fixed; left: 0; right: 0; }
body.paged main { position: relative; height: 100vh; height: 100dvh; padding: 0; overflow: hidden;
  touch-action: pinch-zoom; overscroll-behavior: contain; }   /* swipes are the reader's, zoom stays the browser's */
body.paged .book {
  max-width: none; height: 100%; padding: calc(var(--bar) + 24px) 0 36px;
  column-width: var(--page-w); column-gap: var(--gap); column-fill: auto;
  margin: 0 var(--side);
}
body.paged .cover, body.paged .part-opener { margin: 0; min-height: calc(100dvh - var(--bar) - 64px);
  break-inside: avoid; break-after: column; }
body.paged .part-opener { break-before: column; }
body.paged .book p { orphans: 2; widows: 2; }
body.paged .section { break-after: avoid; }
/* ── Progress rail: the chapter on screen (the book, when the whole book is) along the foot ── */
.rail { position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; height: 4px; cursor: pointer;
  background: var(--mist); touch-action: none; }
.rail:hover, .rail:focus-visible { height: 10px; }
.rail-fill { height: 100%; width: 0; background: var(--accent); }
/* its divisions (a chapter's sections, or the book's parts) are gaps in the page colour, so the rail
   reads as segments sized by real length rather than as a ruler */
.rail-tick { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--ground); }

/* ── Keys ──────────────────────────────────────────────────────────── */
.help { position: fixed; z-index: 8; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(360px, 90vw); padding: 16px 20px; background: var(--ground); border: 0.5pt solid var(--mist);
  font-family: var(--bluewell-font-sans); font-size: 14px; line-height: 1.5; font-variant-numeric: lining-nums; }
.help-title { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.help dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 16px; margin: 0; }
.help dt { font-weight: 600; } .help dd { margin: 0; }
.help-note { margin: 10px 0 0; font-weight: 300; }

@media (max-width: 600px) { :root { --size: 17px; } .bar-title { font-size: 12px; } }
/* phones: the chapter arrows, the percentage, Contents, Notebook and the settings; the place and the
   minutes left move into the contents, the mode into the settings */
@media (max-width: 520px) {
  .bar-title, .bar-progress .minutes, #mode-btn { display: none; }
  .running-head { gap: 0; padding-left: 0; }
  .here { display: block; }
}
@media (max-width: 380px) { .bar { padding: 0 4px; gap: 0; } .bar-btn { padding: 6px 7px; } .bar-arrow { padding: 6px 6px; } }

/* Paged mode's margin arrows: faint, and only where a pointer can hover near them (touch screens
   turn pages by tapping the outer quarters) */
.page-turn { display: none; }
@media (hover: hover) {
  body.paged .page-turn {
    display: flex; position: fixed; z-index: 4; top: calc(var(--bar) + 8px); bottom: 18px;
    width: max(44px, calc(var(--side) - 16px)); align-items: center; justify-content: center;
    padding: 0; border: 0; background: none; color: var(--t); cursor: pointer; opacity: 0;
    font: 300 44px/1 var(--bluewell-font-serif); transition: opacity 0.2s;
  }
  body.paged .page-turn.prev { left: 0; }
  body.paged .page-turn.next { right: 0; }
  body.paged .page-turn:hover, body.paged .page-turn:focus-visible { opacity: 0.5; }
  body.paged .page-turn:disabled { opacity: 0; cursor: default; }
}
@media (prefers-reduced-motion: reduce) { .page-turn { transition: none; } }
/* Back to the top (scroll mode): a square at the foot's right, past the first screen, coming and
   going with the bar; the page's own ground and a Mist hairline, the arrow in Ink, Primary on hover */
.to-top { position: fixed; z-index: 5; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; padding: 0;
  background: var(--ground); border: 0.5pt solid var(--mist); color: var(--t); cursor: pointer;
  font: 400 20px/1 var(--bluewell-font-sans); visibility: hidden; opacity: 0; }
.to-top.far { visibility: visible; opacity: 1; }
body.paged .to-top, body.chrome-hidden .to-top { visibility: hidden; opacity: 0; }
.to-top:hover, .to-top:focus-visible { color: var(--accent); }
@media (prefers-reduced-motion: no-preference) { .to-top { transition: opacity 0.2s ease, visibility 0.2s; } }
@media print { .bar, .sidebar, .settings, .hl-tool, .to-top { display: none; } }

.settings-note { margin: 0; font-weight: 300; font-size: 13px; }
/* reporting a problem: a quiet line under the settings, and what to do when no email opens */
.settings-report { margin: 10px 0 0; font-size: 13px; }
.settings-report a { color: var(--bluewell-graphite); text-underline-offset: 3px; text-decoration-thickness: 0.5pt; }
.settings-report a:hover, .settings-report a:focus-visible { color: var(--bluewell-primary); }
.report-note { margin: 4px 0 0; font-size: 12px; color: var(--bluewell-graphite); }
/* the report dialog (with a host's form handler): in the middle of the screen, the page dimmed
   behind it; the settings panel's ground, hairline and type */
.report-dialog { width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 20px 22px; overflow-y: auto;
  background: var(--ground); color: var(--t); border: 0.5pt solid var(--mist);
  font-family: var(--bluewell-font-sans); font-size: 14px; }
.report-dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.report-dialog h2 { margin: 0 0 4px; font-family: var(--bluewell-font-serif); font-weight: 400; font-size: 1.35rem; }
.rd-where { margin: 0 0 14px; color: var(--bluewell-graphite); font-size: 13px; }
.rd-passage { margin: 0 0 14px; padding: 6px 0 6px 12px; border-left: 2px solid var(--accent); max-height: 7.5em; overflow: auto;
  font-family: var(--bluewell-font-serif); font-style: italic; font-size: 15px; line-height: 1.45; }
.report-dialog label { display: block; margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.rd-optional { font-weight: 400; color: var(--bluewell-graphite); }
.report-dialog textarea, .report-dialog input { display: block; box-sizing: border-box; width: 100%; margin: 0 0 14px; padding: 8px 10px;
  font: inherit; font-size: 16px; color: var(--t); background: var(--ground); border: 1px solid var(--bluewell-graphite); border-radius: 0; }
.report-dialog textarea { resize: vertical; min-height: 6.5em; font-family: var(--bluewell-font-serif); line-height: 1.45; }
.report-dialog :is(textarea, input, button):focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.report-dialog :is(textarea, input):disabled { opacity: 0.6; }
.rd-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.rd-status { min-height: 1.4em; margin: 0 0 12px; font-size: 13px; }
.rd-status a { color: var(--accent); text-underline-offset: 3px; }
.rd-actions { display: flex; justify-content: flex-end; gap: 10px; }
.rd-actions button { padding: 9px 18px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid var(--mist);
  background: none; color: var(--t); }
.rd-actions button[type="submit"] { background: var(--bluewell-primary-fill); color: var(--bluewell-on-primary); border-color: var(--bluewell-primary-fill); }
.rd-actions button[hidden] { display: none; }
.rd-actions button:disabled { opacity: 0.6; cursor: default; }
.settings kbd { font-family: var(--bluewell-font-mono); font-size: 12px; }

/* ── Text format 2 (docs/book-format.md; experimental, 2026-11-07) ──────────
   Chapters, front matter, verse, letters, plays, tables and lists, after the print rules
   of spec 12.4–12.9. Nothing is boxed or tinted (12.1). */
.part-opener.no-art { min-height: 46vh; }
.cover.no-art { min-height: 62vh; }
.part-opener .num { display: block; font-size: 0.5em; letter-spacing: 0.14em; text-transform: uppercase;
  font-weight: 400; margin-bottom: 0.5em; }
.part-opener .num:only-child { display: inline; font-size: inherit; letter-spacing: normal; text-transform: none;
  font-weight: inherit; margin: 0; }
.cover .subtitle { margin: 0.4em 0 0; font-style: italic; font-size: 1.1em; line-height: 1.2; }
.book .front p { text-align: left; }   /* the source note: links make justified lines gappy */

/* Chapters: the numeral, then the title, flush left, low on the page; no rule (12.5) */
.chapter-head, .matter-head { margin: 6em 0 2.6em; font-weight: 300; font-size: 1em; line-height: 1.1; }
.chapter-head .num { display: block; font-size: 2.4em; color: var(--accent); }
.chapter-head .title, .matter-head .title { display: block; font-size: 1.45em; }
.chapter-head .num + .title { margin-top: 0.35em; }
.matter-head .num { display: block; font-size: 1.45em; }
.book :is(.chapter-head, .matter-head):has(+ :is(.subtitle, .summary)) { margin-bottom: 1em; }
.book :is(p.subtitle, p.summary) { text-indent: 0; text-align: left; hyphens: manual; margin: 0 0 2.4em; }
.book p.subtitle { font-style: italic; }
.book p.summary { font-size: 0.9em; font-style: italic; }
/* Sections run on: the numeral under the short rule, a title after it in italic */
.section .title { color: var(--t); font-style: italic; letter-spacing: 0; margin-left: 12pt; }
.book :is(h2, h3, h4, h5, .subtitle, .summary) + p { text-indent: 0; }
.book p.continued { text-indent: 0; }
body.paged :is(.part.chapter, .part.matter, .division:has(> .chapter-head)) { break-before: column; }
body.paged :is(.chapter-head, .matter-head) { margin-top: 14vh; break-after: avoid; }

/* Dedication and epigraphs (12.4): the epigraph at the right of the measure, italic */
.part.dedication { margin: 8em 0 4em; }
.part.dedication p { text-indent: 0; text-align: left; font-style: italic; }
.quote.epigraph, .part.epigraph :is(.verse, .quote) {
  width: 62%; margin: 1em 0 1.6em auto; font-size: 0.95em; font-style: italic; }
.part.epigraph { margin: 6em 0 4em; }
.epigraph p, .part.epigraph p { text-align: left; hyphens: manual; }
.epigraph .cite, .part.epigraph .cite { font-style: normal; text-align: left; }

/* Block quotations and letters: indented both sides, a size smaller, no bar or box */
.quote { margin: 1.1em 1.2em 1.1em 1.8em; font-size: 0.94em; }
.quote p { text-indent: 0; }
.quote p + p { margin-top: 0.45em; }
.quote :is(.dateline, .valediction, .signature) { text-align: right; }
.quote .salutation { margin-bottom: 0.2em; }
.quote .valediction { margin-top: 0.6em; }
.quote .postscript { margin-top: 0.6em; }
.cite { text-indent: 0; text-align: right; margin-top: 0.45em; font-family: var(--bluewell-font-sans);
  font-weight: 300; font-size: 0.72em; letter-spacing: 0.06em; text-transform: uppercase; line-height: 1.4; }

/* Verse (12.8): one source line per line, stanzas apart, indent steps of 1.5 em, long lines
   turned over with a 2 em hanging indent, ragged, never justified */
.verse { margin: 1.3em 0 1.3em 6%; }
.book .verse p.stanza { text-indent: 0; text-align: left; hyphens: manual; }
.verse .stanza + .stanza { margin-top: 0.55em; }
.verse .line { display: block; padding-left: 2em; text-indent: -2em; }
.verse :is(.i1) { margin-left: 1.5em; } .verse :is(.i2) { margin-left: 3em; }
.verse :is(.i3) { margin-left: 4.5em; } .verse :is(.i4) { margin-left: 6em; }
.verse-title { font-family: var(--bluewell-font-sans); font-weight: 600; font-size: 0.8em; margin: 0 0 0.7em; }
.quote .verse { margin-left: 1.2em; }
.verse.inscription .line { text-indent: 0; padding-left: 0; }

/* Plays (12.9): the speaker's name in spaced capitals, stage directions in italic */
.book p.speaker { text-indent: 0; text-align: left; margin-top: 0.9em; font-family: var(--bluewell-font-sans);
  font-weight: 600; font-size: 0.72em; letter-spacing: 0.08em; text-transform: uppercase; }
.book p.speaker .smcaps { font-size: inherit; letter-spacing: inherit; }
.book p.speaker { font-variant-numeric: lining-nums; }
.book :is(p.direction, p.setting) { text-indent: 0; text-align: left; font-style: italic; margin: 0.8em 0; }
.book :is(p.speaker, p.direction, p.setting) + p { text-indent: 0; }

/* Tables and lists inside the text */
.text-table { margin: 1em 0 1em 1.4em; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.text-table td { padding: 0.1em 1.4em 0.1em 0; vertical-align: top; }
.text-list { margin: 1em 0; padding-left: 1.4em; list-style: none; }
ol.text-list { list-style: decimal; }
.text-list .text-list { margin: 0.4em 0; }
.book .text-list p { text-indent: 0; text-align: left; }
.text-list li + li { margin-top: 0.3em; }

/* A small picture in the line, drawn in the text colour */
.glyph { height: 0.85em; width: auto; vertical-align: -0.08em; }

/* Notes of several paragraphs, verse or quotations open in place too */
.note-p { display: block; } .note-p + .note-p { margin-top: 0.4em; }
.note :is(.note-verse, .note-quote) { display: block; margin: 0.4em 0 0.4em 1.2em; }
.note-verse .line { display: block; }
.note .cite { display: block; margin-top: 0.2em; }

/* Contents: chapters without titles in a row; titled ones one to a line */
.toc li.leaf > a { font-weight: 400; }
.toc-run > ol { margin-top: 0; }
.toc-n { color: var(--accent); margin-right: 0.25em; }
/* a run whose numerals share a word: the word once, in the plural, in Sans and Graphite, hanging in
   the run's margin so a wrapped row lines up under the first numeral; a new word starts a row. Each
   link keeps its word for assistive technology (.vh), and the label is hidden from it. */
.toc ol.toc-labelled { padding-left: 72px; align-items: baseline; }
.toc ol.toc-labelled + ol.toc-labelled { margin-top: 2px; }
.toc .toc-label { width: 72px; margin-left: -72px; margin-right: -10px; font-family: var(--bluewell-font-sans);
  font-size: 12.5px; color: var(--bluewell-graphite); }
.toc .vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ── The modern voice (spec 12.2), a reader setting; classical is the default ──────────
   Display type in Sans Bold at the nominal size (classical: Serif Light at 1.08 times);
   spaced capitals in Sans SemiBold, tracked 0.17 em; lining figures; the running title (the
   bar's place) in Sans Light capitals; the lead-in in Sans SemiBold; numerals in Sans Light. */
body.modern :is(.cover h1, .part-opener h2) { font-family: var(--bluewell-font-sans); font-weight: 700; font-size: 2.4em; }
body.modern .part-opener h2 { font-size: 1.76em; }
body.modern :is(.author, .part-opener .num:not(:only-child)) {
  font-family: var(--bluewell-font-sans); font-weight: 600; letter-spacing: 0.17em; font-size: 0.72em; }
body.modern .part-opener .num:not(:only-child) { font-size: 0.42em; }
body.modern :is(.chapter-head, .matter-head) .title { font-family: var(--bluewell-font-sans); font-weight: 700; font-size: 1.34em; }
body.modern :is(.chapter-head, .matter-head) .num { font-family: var(--bluewell-font-sans); font-weight: 300; }
body.modern .chapter-head .num { font-size: 2.25em; }
body.modern .section { font-family: var(--bluewell-font-sans); font-weight: 600; font-size: 0.95em; letter-spacing: 0.06em; }
body.modern .section .title { font-style: normal; letter-spacing: 0; }
body.modern .lead-in { font-family: var(--bluewell-font-sans); font-weight: 600; font-size: 0.84em; letter-spacing: 0.067em; }
body.modern .opening::first-letter { font-family: var(--bluewell-font-sans); }
body.modern :is(.bar-title, .bar-book) { font-family: var(--bluewell-font-sans); font-style: normal; font-weight: 300;
  text-transform: uppercase; letter-spacing: 0.12em; font-size: 11px; }

/* The edition's details on the title page: labelled fields, the label in the sans, the value in the
   text face, one row each (format 2) */
.front .details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 20px; margin: 0;
  font-size: 0.9em; line-height: 1.45; }
.front .details dt { font-family: var(--bluewell-font-sans); font-size: 0.85em; color: var(--bluewell-graphite);
  padding-top: 0.15em; font-variant-numeric: lining-nums; }
.front .details dd { margin: 0; }
@media (max-width: 520px) {
  .front .details { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .front .details dd { margin-bottom: 8px; }
}

/* A host's arrangement of the contents (web only): "Start here", then group headings over the
   book's own order. A group's title in the sans, in Graphite, with the Mist hairline above it. */
.toc .toc-group-title { display: block; margin: 1.1em 0 0.4em; padding-top: 0.6em; border-top: 0.5pt solid var(--bluewell-mist);
  font-family: var(--bluewell-font-sans); font-size: 13px; font-weight: 600; color: var(--bluewell-graphite); list-style: none; }
.toc > .toc-group-title:first-child, .toc > .toc-start:first-child .toc-group-title { border-top: 0; padding-top: 0; margin-top: 0; }
.toc .toc-start > ol { list-style: none; padding: 0; margin: 0 0 0.6em; }

/* the marker at the last page's edge (reader.js: fixEnd); nothing to see */
.page-end { display: none; }
body.paged .page-end { display: block; position: absolute; top: 0; width: 1px; height: 1px; pointer-events: none; }

/* ── The settings' choices: two boxes side by side, the chosen one filled in Primary ───────── */
.settings .seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.settings .seg legend { padding: 0; }
.settings .seg label { display: block; padding: 0; position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.seg label > span, .settings .seg button {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; padding: 6px 8px;
  border: 1px solid var(--mist); background: none; color: var(--t);
  font-family: var(--bluewell-font-sans); font-size: 14px; line-height: 1.2; text-align: center; }
.seg label:hover > span, .settings .seg button:hover { border-color: var(--accent); color: var(--accent); }
.seg input:checked + span { background: var(--bluewell-primary-fill); border-color: var(--bluewell-primary-fill);
  color: var(--bluewell-on-primary); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings .seg button:active { background: var(--mist); }
/* text size: a small A and a large A, in the text's face */
.size .a-small, .size .a-large { font-family: var(--bluewell-font-serif); line-height: 1; }
.size .a-small { font-size: 15px; } .size .a-large { font-size: 22px; }

/* touch screens: no scroll bar over the text (the rail at the foot shows the place) */
@media (pointer: coarse) { html { scrollbar-width: none; } html::-webkit-scrollbar { display: none; } }
/* phones: the settings take the screen's width */
@media (max-width: 520px) { .settings { left: 8px; right: 8px; width: auto; } }
