/* An open book: two facing pages of a measured text block, old-style serif,
   indented paragraphs, running heads above, folios below, and the thickness
   of the pages read / unread visible at the outer edges.
   The reader's layout (app/layout.py) overrides the tokens below in a <style> after this file; the values here are
   the shipped look, and the fallbacks in var() repeat them for the tokens it may set. */
:root {
  --paper: #fbf8f1; --ink: #1d1a16; --ink-soft: #6a645a; --rule: #d6cfbf; --edge: #c9c1ae;
  --text-size: 1.2rem; --leading: 1.55; --measure: 34em;
  --font-body: "EB Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --p-indent: 1.4em; --p-gap: 0; --justify: justify;
  --page-w: min(var(--measure), calc((100vw - 10rem) / 2));  /* overridden in px by reader.js */
  --gutter: 4rem;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #1b1915; --ink: #e8e2d4; --ink-soft: #9c958a; --rule: #3a362f; --edge: #4a453b; }
}
html, body { height: 100%; margin: 0; }
body {
  color: var(--ink); background: var(--paper); overflow: hidden;
  font-family: var(--font-body);
  font-size: var(--text-size); line-height: var(--leading);
  font-feature-settings: "onum" 1, "liga" 1, "kern" 1; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }

/* the open book */
.book { height: 100%; display: grid; grid-template-rows: auto 1fr auto; position: relative; }
.spread-head, .spread-foot {
  width: var(--page-w); margin: 0 auto;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: baseline;
  font-variant: small-caps; letter-spacing: 0.08em; font-size: 0.8em; color: var(--ink-soft);
}
.spread-head { padding: 1.6rem 0 0.4rem; border-bottom: 1px solid var(--rule); grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
#running-chapter { min-width: 0; padding-left: .9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spread-head > :last-child { text-align: right; }
#toc-btn { opacity: 0.55; } #toc-btn:hover { opacity: 1; }
.spread-foot { padding: 0.6rem 0 1.4rem; border-top: 1px solid var(--rule); grid-template-columns: 1fr; }
.spread-foot .folio:last-child { text-align: right; }

.spread { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; min-height: 0; }
.viewport { width: var(--page-w); height: 100%; overflow: hidden; padding: 2.5rem 0 1rem; box-sizing: border-box; touch-action: pan-y; user-select: text; }
.flow { height: 100%; column-count: 1; column-gap: var(--gutter); column-fill: auto; }
/* page-edge progress: stacks of page edges to either side of the spread */
.edge { align-self: center; height: 92%; max-width: 2.2rem; width: 0; box-sizing: border-box;
  background: repeating-linear-gradient(90deg, var(--edge) 0 1px, transparent 1px 3px);
  opacity: 0.8; transition: width 300ms ease; }
.edge.left { justify-self: end; margin-right: 0.6rem; }
.edge.right { display: none; }

/* page turning */
.turn { position: absolute; top: 0; bottom: 0; width: 5rem; font-size: 2.4em; color: var(--ink-soft);
  opacity: 0.25; transition: opacity 200ms; }
.turn:hover { opacity: 0.8; } .turn:disabled { opacity: 0 !important; cursor: default; }
.turn-prev { left: 0; } .turn-next { right: 0; }

/* the reader's footnotes (footnotes.js): a mark in the text, the note in the right margin, opened by hovering or tapping */
.fn-mark { line-height: 0; }
.fn-mark::after { content: attr(data-n); font-size: .68em; padding: 0 .12em; color: var(--ink-soft); cursor: pointer; }
.fn-mark.lit::after { color: var(--ink); background: rgba(214,178,94,.3); border-radius: 2px; }
body.fn-off .fn-mark, body.fn-off #fn-margin { display: none; }
#fn-margin { position: absolute; right: .5rem; z-index: 6; pointer-events: none; }
.fn-note { position: absolute; left: 0; right: 0; box-sizing: border-box; padding: .1em .2em .1em .45em; pointer-events: auto; background: var(--paper);
  border-left: 1px solid var(--rule); font-size: .74em; line-height: 1.3; color: var(--ink-soft); outline: none; cursor: default; }
.fn-n { font-size: .85em; margin-right: .35em; }
.fn-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.fn-note:hover, .fn-note:focus, .fn-note.open { left: auto; width: min(22rem, 80vw); z-index: 2; padding: .5em .7em; color: var(--ink);
  border: 1px solid var(--rule); box-shadow: 0 6px 18px rgba(0,0,0,.14); }
.fn-note:hover .fn-text, .fn-note:focus .fn-text, .fn-note.open .fn-text { display: block; max-height: 50vh; overflow-y: auto; }
#fn-margin.narrow .fn-note { padding: 0 .1em; border-left: 0; background: none; text-align: center; }
#fn-margin.narrow .fn-text { display: none; }
#fn-margin.narrow .fn-note:hover, #fn-margin.narrow .fn-note:focus, #fn-margin.narrow .fn-note.open { padding: .5em .7em; background: var(--paper); text-align: left; }
#fn-margin.narrow .fn-note:hover .fn-text, #fn-margin.narrow .fn-note:focus .fn-text, #fn-margin.narrow .fn-note.open .fn-text { display: block; }
.fn-toggle { position: absolute; right: .9rem; bottom: .7rem; z-index: 7; font-variant: small-caps; letter-spacing: .06em; font-size: .8em; color: var(--ink-soft); }
.fn-toggle:hover { color: var(--ink); }
.fn-toggle[aria-pressed="false"] { opacity: .55; text-decoration: line-through; }

/* front matter */
.title-page { text-align: center; padding-top: 25%; break-after: column; }
.book-title { font-weight: 400; font-size: 2.1em; letter-spacing: 0.04em; margin: 0 0 0.3rem; font-variant: small-caps; }
.book-subtitle { font-style: italic; font-size: 1.1em; }
.book-author { margin-top: 2rem; font-variant: small-caps; letter-spacing: 0.1em; }
.book-translator { font-size: 0.85em; color: var(--ink-soft); margin-top: 0.3rem; }
.contents { break-before: column; }
.contents-heading, .toc-part { text-align: center; font-weight: 400; font-variant: small-caps; letter-spacing: 0.12em; }
.contents-heading { font-size: 1.1em; margin: 0 0 1.5rem; }
.toc-part { font-size: 0.9em; margin: 1.4rem 0 0.6rem; color: var(--ink-soft); break-after: avoid; }
.toc-list { list-style: none; padding: 0; margin: 0; font-size: 0.95em; }
.toc-list li a { display: flex; gap: 0.7em; padding: 0.1em 0; }
.toc-list .num { min-width: 3.2em; text-align: right; color: var(--ink-soft); font-variant: small-caps; }
.toc-list .pg { margin-left: auto; color: var(--ink-soft); font-size: 0.85em; }

/* parts and chapters */
.part-opening { break-before: column; break-after: column; text-align: center; padding-top: 30%; }
.part-title { font-weight: 400; font-variant: small-caps; letter-spacing: 0.2em; font-size: 1.3em; margin: 0; }
.epigraph { max-width: 24em; margin: 2.5rem auto 0; font-style: italic; font-size: 0.95em; text-align: left; }
.epigraph p { text-indent: 0; margin-bottom: 0.6em; }
.chapter { break-before: column; }
.chapter-heading { text-align: center; padding-top: 3rem; margin-bottom: 2.2rem; break-after: avoid; }
.chapter-number { font-variant: small-caps; letter-spacing: 0.15em; color: var(--ink-soft); }
.chapter-title { font-weight: 400; font-size: 1.4em; letter-spacing: 0.06em; margin: 0.3rem 0 0; font-variant: small-caps; }

/* body text */
.chapter p { margin: 0 0 var(--p-gap); text-indent: var(--p-indent); text-align: var(--justify); hyphens: auto; -webkit-hyphens: auto; orphans: 2; widows: 2; }
.chapter-heading + p, .section-number + p, .verse + p { text-indent: 0; }
.section-number { text-align: center; margin: 2rem 0 1.1rem; font-variant: small-caps; color: var(--ink-soft); break-after: avoid; }
.verse { margin: 1.1em 0 1.1em 2.2em; }
.verse .line { display: block; text-indent: -1.5em; padding-left: 1.5em; }

/* the roll-up contents */
.toc-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.25); display: flex; justify-content: flex-end; z-index: 10; }
.toc-overlay[hidden] { display: none; }
.toc-panel { width: 22em; max-width: 90vw; height: 100%; overflow-y: auto; box-sizing: border-box; padding: 2rem 1.6rem 3rem;
  background: var(--paper); border-left: 1px solid var(--rule); box-shadow: -12px 0 30px rgba(0,0,0,0.12); font-size: 0.9em; }
.toc-panel .toc-part:first-child { margin-top: 0; }
.toc-panel a { border-radius: 2px; padding: 0.15em 0.4em; margin: 0 -0.4em; }
.toc-panel a:hover { background: rgba(127,127,127,0.12); }
.toc-panel a.current { background: rgba(127,127,127,0.18); font-weight: 500; }
.toc-panel a.current::before { content: "▸"; position: absolute; margin-left: -1.1em; color: var(--ink-soft); }

/* ---- annotations in the book ---- */
.chapter p, .chapter .verse, .chapter .section-number { position: relative; }
.mark { position: absolute; left: -1.6em; top: 0.05em; font-size: 0.85em; color: var(--ink-soft); opacity: 0.45; text-decoration: none; }
.mark:hover { opacity: 1; color: var(--accent); }
.hl { text-decoration: underline dotted var(--edge); text-underline-offset: 0.2em; cursor: pointer; }
.hl:hover { background: rgba(176, 120, 40, 0.12); }
.hl[data-passage] { pointer-events: auto; }
.focus { background: rgba(176, 120, 40, 0.14); box-shadow: 0 0 0 6px rgba(176, 120, 40, 0.14); border-radius: 2px; transition: background 1.2s, box-shadow 1.2s; }
.head-centre { display: flex; gap: 1.4em; }
.ideas-link { opacity: 0.55; } .ideas-link:hover { opacity: 1; }
:root { --accent: #8a5a1c; }

/* ---- trail ---- */
.trail { display: flex; flex-wrap: wrap; gap: 0.3em 0.5em; align-items: baseline; font-size: 0.78em; color: var(--ink-soft);
  width: var(--page-w); margin: 0 auto; padding: 0 0 0.9rem; min-height: 1.2em; }
.trail:empty { visibility: hidden; }
.trail-label { font-variant: small-caps; letter-spacing: 0.1em; margin-right: 0.4em; }
.trail .sep { opacity: 0.5; }
.trail .crumb { border-bottom: 1px dotted transparent; white-space: nowrap; max-width: 18em; overflow: hidden; text-overflow: ellipsis; }
.trail .crumb:hover { border-bottom-color: var(--ink-soft); text-decoration: none; }
.trail .crumb.current { color: var(--ink); font-weight: 500; }
.trail .crumb.k-book::before { content: "📖 "; font-size: 0.8em; }

/* ---- idea view ---- */
.ideas { max-width: 44em; margin: 0 auto; padding: 1.6rem 1.5rem 5rem; min-height: 100%; box-sizing: border-box; }
body:has(.ideas) { overflow: auto; }
.ideas-head { display: flex; gap: 1.6em; align-items: baseline; font-variant: small-caps; letter-spacing: 0.08em; font-size: 0.8em;
  color: var(--ink-soft); border-bottom: 1px solid var(--rule); padding-bottom: 0.4rem; margin-bottom: 0.8rem; }
.ideas-head .search { margin-left: auto; }
.ideas-head input { font: inherit; font-variant: normal; letter-spacing: 0; font-size: 1em; background: transparent; border: 0;
  border-bottom: 1px solid var(--rule); color: var(--ink); padding: 0.1em 0; width: 13em; outline: none; }
.ideas .trail { width: auto; padding: 0.4rem 0 1.4rem; }
.ideas-title { font-weight: 400; font-size: 1.7em; font-variant: small-caps; letter-spacing: 0.04em; margin: 0.2em 0 0.1em; }
.lede { color: var(--ink-soft); font-style: italic; margin: 0 0 1.5rem; }
.idea-columns { columns: 2; column-gap: 3em; }
.idea-columns section { break-inside: avoid; margin-bottom: 1.6rem; }
.idea-group, .part-divider { font-weight: 400; font-variant: small-caps; letter-spacing: 0.12em; font-size: 0.85em; color: var(--ink-soft);
  margin: 2rem 0 0.6rem; }
.part-divider { text-align: center; }
.idea-list { list-style: none; padding: 0; margin: 0; }
.idea-list li { display: flex; gap: 0.6em; align-items: baseline; padding: 0.1em 0; }
.idea-list .count { margin-left: auto; color: var(--ink-soft); font-size: 0.8em; font-feature-settings: "tnum"; }
.idea-list .muted, .muted { color: var(--ink-soft); font-size: 0.85em; }
.idea-head .kind { font-variant: small-caps; letter-spacing: 0.12em; font-size: 0.8em; color: var(--ink-soft); }
.german { font-style: italic; color: var(--ink-soft); }
.gloss { margin: 0.6em 0 0; }
.tag { display: inline-block; font-size: 0.85em; padding: 0.05em 0.55em; border: 1px solid var(--rule); border-radius: 1em; margin: 0.15em 0.3em 0.15em 0; color: var(--ink); }
.tag:hover { border-color: var(--ink-soft); text-decoration: none; }
.tag.concept { border-style: solid; } .tag.character { border-style: dashed; } .tag.scene { border-style: dotted; } .tag.chapter { font-variant: small-caps; }
.tags { margin: 0.5em 0; }
.rel-list { list-style: none; padding: 0; margin: 0; }
.rel-list li { display: flex; gap: 0.5em; align-items: baseline; }
.rel-list .rel { font-size: 0.8em; color: var(--ink-soft); font-style: italic; min-width: 7em; }
.passage-card { margin: 0 0 1.6rem; padding-left: 1em; border-left: 2px solid var(--rule); }
.p-head { display: flex; gap: 0.8em; align-items: baseline; flex-wrap: wrap; }
.p-title { font-weight: 500; } .p-title:hover { color: var(--accent); }
.p-where { color: var(--ink-soft); font-size: 0.8em; font-variant: small-caps; letter-spacing: 0.06em; }
.p-excerpt { margin: 0.4em 0; font-size: 0.95em; color: var(--ink); }
.p-excerpt.sentence { font-style: italic; }
.p-note { margin: 0.2em 0; font-size: 0.9em; color: var(--ink-soft); }
.p-open { font-size: 0.8em; font-variant: small-caps; letter-spacing: 0.08em; color: var(--accent); }
.passage-text { margin: 1.5rem 0; }
.passage-text p { margin: 0; text-indent: 1.4em; text-align: justify; hyphens: auto; }
.passage-text p:first-child, .passage-text .section-number + p { text-indent: 0; }
.why-list { list-style: none; padding: 0; margin: 1rem 0; }
.why-list li { display: flex; gap: 0.8em; align-items: baseline; margin-bottom: 0.4em; font-size: 0.9em; }
.why-list .why { color: var(--ink-soft); }
.ideas .pager { margin-top: 2.5rem; border-top: 1px solid var(--rule); padding-top: 0.8rem; }
@media (max-width: 700px) { .idea-columns { columns: 1; } }

/* ---- commentary: visibly not the book ---- */
:root { --crit: #4a6a8a; --comp: #8a5a1c; }
@media (prefers-color-scheme: dark) { :root { --crit: #8fb0d0; --comp: #d0a060; } }
.excerpt-card { margin: 0 0 1.3rem; padding: 0.1rem 0 0.1rem 1em; border-left: 2px solid var(--crit);
  font-family: "Helvetica Neue", "Segoe UI", system-ui, sans-serif; font-size: 0.78em; line-height: 1.5; }
.excerpt-card.k-companion { border-left: 2px dotted var(--comp); font-family: inherit; font-size: 0.92em; font-style: italic; }
.excerpt-card .p-title { font-style: normal; }
.x-claim { margin: 0.25em 0; }
.x-claim.big { font-family: "Helvetica Neue", system-ui, sans-serif; font-size: 0.9em; color: var(--ink-soft); border-left: 2px solid var(--crit); padding-left: 0.8em; }
.stance { font-size: 0.75em; font-variant: small-caps; letter-spacing: 0.08em; padding: 0 0.45em; border-radius: 0.8em; border: 1px solid var(--rule); color: var(--ink-soft); font-style: normal; }
.stance.s-evaluation { border-color: var(--crit); color: var(--crit); }
.stance.s-primary { border-color: var(--comp); color: var(--comp); }
.critic { font-size: 0.85em; font-variant: small-caps; letter-spacing: 0.05em; margin: 1.2rem 0 0.5rem; color: var(--crit); }
.caution { font-size: 0.8em; color: #a04030; font-style: italic; font-variant: normal; letter-spacing: 0; }
.commentary.criticism > .idea-group { color: var(--crit); }
.commentary.companion > .idea-group { color: var(--comp); }
.excerpt-text.k-criticism { font-family: "Helvetica Neue", system-ui, sans-serif; font-size: 0.85em; line-height: 1.6; }
.library-list { list-style: none; padding: 0; } .library-list li { margin-bottom: 1rem; }
.library-list.criticism li { border-left: 2px solid var(--crit); padding-left: 0.8em; }
.library-list.companion li { border-left: 2px dotted var(--comp); padding-left: 0.8em; }
.idea-list .xcount { margin-left: 0.4em; min-width: 1.6em; text-align: right; color: var(--crit); }
.tag.passage { font-style: italic; }

/* ---- emblem cards (experiment) ---- */
.card-row { display: flex; gap: 1.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.card { display: block; width: 13rem; text-align: center; }
.card img { width: 100%; height: auto; display: block; border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.25); transition: transform .2s; }
.card:hover img { transform: translateY(-4px) rotate(-0.6deg); }
.card:hover { text-decoration: none; }
.card-name { font-size: 0.85em; font-variant: small-caps; letter-spacing: 0.06em; color: var(--ink-soft); margin-top: 0.5em; }

/* ---- cards in use ---- */
.idea-head.with-card::after { content: ""; display: block; clear: both; }
.idea-card { float: right; width: 13rem; height: auto; margin: 0 0 1rem 1.6rem; border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
@media (max-width: 700px) { .idea-card { float: none; display: block; margin: 0 auto 1rem; width: 60%; } }
.list-tablet { width: 0.9em; height: auto; flex: none; align-self: center; }
/* tablets at the head of each unit: the section-number line, or under the chapter title */
.panchor { display: none; }
.section-number { display: flex; align-items: center; justify-content: center; gap: 0.9em; }
.section-number .ut-left, .section-number .ut-right { flex: 1; display: flex; gap: 0.35em; }
.section-number .ut-left { justify-content: flex-end; }
.section-number .ut-right { justify-content: flex-start; }
.unit-tablets { display: flex; justify-content: center; gap: 0.35em; margin-top: 0.9rem; flex-wrap: wrap; }
.ut { display: block; width: 1.05em; line-height: 0; opacity: .92; transition: transform .15s; }
.ut img { width: 100%; height: auto; display: block; filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.25)); }
.ut:hover { opacity: 1; transform: translateY(-2px) scale(1.15); }

/* ---- card peek: any tablet, raised to the full card with its description (static/cards.js) ---- */
.card-peek { position: fixed; z-index: 50; display: flex; gap: 1.2rem; align-items: center; width: 33rem; max-width: calc(100vw - 24px);
  padding: 0.9rem 1.2rem 0.9rem 0.9rem; box-sizing: border-box; background: var(--paper); border: 1px solid var(--rule); border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,.28); pointer-events: none;
  opacity: 0; transform: scale(0.15); transition: opacity 160ms ease-out, transform 200ms cubic-bezier(.2,.8,.25,1); }
.card-peek.open { opacity: 1; transform: none; }
.card-peek[hidden] { display: none; }
.peek-card { width: 15rem; height: auto; flex: none; border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.peek-text { flex: 1; min-width: 0; font-size: 0.95rem; line-height: 1.5; }
.peek-kind { font-variant: small-caps; letter-spacing: 0.12em; font-size: 0.8em; color: var(--ink-soft); }
.peek-name { font-variant: small-caps; letter-spacing: 0.04em; font-size: 1.35em; line-height: 1.2; margin: 0.15em 0 0.25em; color: var(--ink); }
.peek-sub { font-style: italic; color: var(--ink-soft); font-size: 0.95em; }
.peek-sub:empty { display: none; }
.peek-gloss { margin: 0.6em 0 0; color: var(--ink); }
.list-tablet[data-card] { cursor: help; }
@media (max-width: 600px) { .card-peek { flex-direction: column; width: 17rem; } .peek-card { width: 100%; } }
@media (prefers-reduced-motion: reduce) { .card-peek { transition: opacity 120ms; transform: none; } }

/* ---- settings menu (upper left) ---- */
.head-left { display: flex; align-items: baseline; gap: 1.2em; }
.settings { position: relative; font-variant: small-caps; letter-spacing: 0.08em; z-index: 30; }
.settings-toggle { list-style: none; cursor: pointer; color: var(--ink-soft); opacity: .75; user-select: none; }
.settings-toggle::-webkit-details-marker { display: none; }
.settings-toggle::after { content: none; }
.settings[open] .settings-toggle, .settings-toggle:hover { opacity: 1; color: var(--ink); }
.settings-panel { position: absolute; top: 1.7em; left: 0; min-width: 17em; padding: .8em 1em .9em; background: var(--paper);
  border: 1px solid var(--rule); box-shadow: 0 8px 24px rgba(0,0,0,.14); font-variant: normal; letter-spacing: 0; font-size: 1.05rem; }
.settings-label { font-variant: small-caps; letter-spacing: .1em; color: var(--ink-soft); font-size: .8em; margin-bottom: .4em; }
.settings-panel .opt { display: block; padding: .2em .4em; margin: 0 -.4em; border-radius: 2px; color: var(--ink); }
.settings-panel .opt:hover { background: rgba(127,127,127,.12); text-decoration: none; }
.settings-panel .opt.current::before { content: "▸ "; color: var(--ink-soft); }
.settings-panel .opt.current { font-weight: 500; }
.settings-panel .opt + .settings-label { margin-top: .8em; }
.orig-label { font-variant: small-caps; letter-spacing: .08em; font-size: .8em; color: var(--ink-soft); margin-top: 1.2rem; }
.head-left { white-space: nowrap; min-width: 0; }
.head-left > span { overflow: hidden; text-overflow: ellipsis; }
.settings-toggle { white-space: nowrap; }

/* ---- the companion ---- */
/* the switch at the top: an arrow between the book and the podcast, pointing at the one the reader is in; the companion's
   states show on the arrow (static/agent.js). The lion knocker it replaced still greets visitors on the welcome card (.welcome-lion). */
#knocker { position: fixed; top: 2px; left: 50%; transform: translateX(-50%); width: 104px; padding: 0; z-index: 60; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; background: none; border: 0; }
#knocker img { width: 38px; height: 38px; display: block; opacity: .72; transition: opacity .3s, transform .2s; }
#knocker .d-needle { width: 22px; height: auto; flex: none; overflow: visible; transition: transform .45s cubic-bezier(.3,1.4,.5,1); transform: rotate(0deg); }
#knocker.mode-podcast .d-needle { transform: rotate(180deg); }
#knocker .d-arrow { fill: var(--ink); transition: fill .3s; }
#knocker.mode-book .d-book, #knocker.mode-podcast .d-pod, #knocker:hover img { opacity: 1; }
#knocker.mode-book .d-book, #knocker.mode-podcast .d-pod { transform: scale(1.08); }
#knocker.knocking .d-needle { animation: knock .7s ease-out; }
@keyframes knock { 0% { translate: 0 } 18% { translate: 0 -1px } 32% { translate: 0 1px } 50% { translate: 0 -1px } 100% { translate: 0 } }
#knocker.awake .d-arrow { fill: #b8891f; }
#knocker.thinking .d-arrow { animation: glint 1.1s ease-in-out infinite; }
@keyframes glint { 50% { fill: #f0cf72; } }
#knocker.off { opacity: .45; }

@keyframes popin { from { opacity: 0; transform: translateX(-50%) translateY(-14px) scale(.96); } }
.cmp-head { display: flex; align-items: center; gap: .3em; padding: .45em .7em; border-bottom: 1px solid var(--rule);
  font-variant: small-caps; letter-spacing: .08em; font-size: .8em; color: var(--ink-soft); }
.cmp-title { flex: 1; }
.cmp-head button { background: none; border: 0; font-size: 1.25em; color: var(--ink-soft); cursor: pointer; padding: 0 .3em; line-height: 1; }
.cmp-head button:hover { color: var(--ink); }
.cmp-turns { overflow-y: auto; padding: .8em 1em; flex: 1; }
.cturn { margin-bottom: .9em; }
.cturn.user { text-align: right; } .cturn.user p { display: inline-block; text-align: left; background: rgba(127,127,127,.1); padding: .35em .7em; border-radius: 10px; margin: 0; max-width: 85%; }
.cturn.assistant p { margin: 0 0 .55em; } .cturn.assistant blockquote { margin: .5em 0; padding-left: .9em; border-left: 2px solid var(--rule); font-style: italic; }
.cturn.assistant ul, .cturn.assistant ol { margin: .3em 0 .6em; padding-left: 1.3em; }
.cturn.greeting { color: var(--ink-soft); font-style: italic; }
.cmp-status { color: var(--ink-soft); font-size: .85em; font-style: italic; margin: -.4em 0 .6em; display: flex; align-items: center; gap: .5em; }
.cmp-status .sand { width: .9em; height: 1.25em; flex: none; animation: sand-turn 2.4s ease-in-out infinite; }
.cmp-status .sand-glass { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.cmp-status .sand-top, .cmp-status .sand-bottom { fill: currentColor; }
.cmp-status .sand-top { animation: sand-drain 2.4s ease-in-out infinite; transform-origin: 10px 6px; }
.cmp-status .sand-bottom { animation: sand-fill 2.4s ease-in-out infinite; transform-origin: 10px 24px; }
@keyframes sand-turn { 0%, 80% { transform: rotate(0); } 100% { transform: rotate(180deg); } }
@keyframes sand-drain { 0% { transform: scaleY(1); } 80%, 100% { transform: scaleY(.1); } }
@keyframes sand-fill { 0% { transform: scaleY(.1); } 80%, 100% { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) { .cmp-status .sand, .cmp-status .sand-top, .cmp-status .sand-bottom { animation: none; } }
.cmp-input { display: flex; gap: .5em; padding: .6em .8em; border-top: 1px solid var(--rule); }
.cmp-input textarea { flex: 1; font: inherit; color: var(--ink); background: transparent; border: 1px solid var(--rule); border-radius: 6px; padding: .35em .5em; resize: none; }
.cmp-input button { font: inherit; font-variant: small-caps; letter-spacing: .06em; background: none; border: 1px solid var(--rule); border-radius: 6px; padding: 0 .8em; color: var(--ink); cursor: pointer; }
.cmp-sel { display: flex; gap: .5em; padding: .3em .9em; font-size: .85em; color: var(--ink-soft); font-style: italic; border-top: 1px dashed var(--rule); }
.cmp-sel .cmp-sel-text { flex: 1; } .cmp-sel button { background: none; border: 0; color: var(--ink-soft); cursor: pointer; }
.chip { display: inline-flex; align-items: center; gap: .3em; padding: .05em .5em .05em .25em; border: 1px solid var(--rule); border-radius: 1em; font-size: .9em; white-space: nowrap; }
.chip img { width: .85em; height: auto; }
button.ask { display: inline-block; margin: .25em .3em .1em 0; font: inherit; font-size: .88em; background: none; border: 1px solid var(--accent); color: var(--accent);
  border-radius: 1em; padding: .1em .75em; cursor: pointer; text-align: left; }
button.ask:hover { background: rgba(176,120,40,.1); }
.agent-hl { background: rgba(214,178,94,.22); box-shadow: 0 0 0 4px rgba(214,178,94,.22); border-radius: 2px; }
mark.agent-q { background: rgba(214,178,94,.55); color: inherit; padding: 0 .05em; }
.cmp-toast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 70; background: var(--paper); border: 1px solid var(--rule);
  padding: .5em 1em; font-size: .9rem; color: var(--ink-soft); box-shadow: 0 8px 20px rgba(0,0,0,.15); }

/* ---- the reader's page ---- */
.vessel-row { display: flex; gap: 2rem; align-items: center; margin: 1rem 0 1.5rem; }
.vessel { width: 9rem; height: auto; color: var(--ink-soft); flex: none; }
.vessel-num { font-size: 2.6em; font-variant: small-caps; line-height: 1; }
.gauge { display: inline-block; width: 6em; height: .45em; background: rgba(127,127,127,.15); border-radius: 1em; overflow: hidden; vertical-align: middle; margin-left: auto; }
.gauge > span { display: block; height: 100%; background: linear-gradient(90deg, #9a7428, #e6c56d); }
.gauge.wide { width: 100%; max-width: 18em; margin: .3em 0; }
.mastery-list { list-style: none; padding: 0; margin: 0; }
.mastery-row { display: flex; align-items: center; gap: .55em; padding: .12em 0; font-size: .95em; }
.facts { list-style: none; padding: 0; } .facts li { display: flex; gap: .8em; align-items: baseline; }
.fact-k { font-variant: small-caps; color: var(--ink-soft); min-width: 9em; } .fact-v { flex: 1; }
.forget { font: inherit; font-size: .8em; background: none; border: 0; color: var(--accent); cursor: pointer; }
.conv-list { list-style: none; padding: 0; } .conv-list li { margin-bottom: 1.1rem; }
.conv-tablets { display: flex; gap: .3em; } .conv-tablets .ut { width: .9em; }
.transcript .cturn { margin: 1rem 0; } .transcript .who { font-variant: small-caps; color: var(--ink-soft); font-size: .8em; }
#companion[hidden], .cmp-sel[hidden] { display: none !important; }
.cmp-turns { flex: 1 1 auto; min-height: 4.5em; }
.ideas-head .flex-gap { flex: 1; }
.ideas-head .search { margin-left: 0; }
#knocker.slotted { position: relative; top: -2px; left: auto; transform: none; margin: -0.75em auto -0.75em; }
.knocker-slot { display: inline-block; width: 108px; flex: none; vertical-align: top; }

/* ---- the podcast (app/podcast.py): an episode's turns, the host as a glyph in the margin ---- */
.episode p.utt { text-indent: 0; position: relative; padding-left: 1.6em; }
.episode .who { position: absolute; left: 0; top: .35em; width: 1.05em; height: 1.05em; border-radius: 50%; opacity: .85; }
.episode .who-eagle { background: radial-gradient(circle at 40% 40%, #e8c25a, #a8822f); box-shadow: inset 0 0 0 1px #8f7639; }
.episode .who-serpent { background: radial-gradient(circle at 40% 40%, #9bb673, #4f6a33); box-shadow: inset 0 0 0 1px #3d5226; }
.episode-about { font-size: .85em; font-style: italic; opacity: .8; margin-top: .3em; }
.episode-about a { color: inherit; }
/* from a chapter to its episode, and back: the icon alone, its words in the tooltip */
.chapter-switch { display: block; width: 3.6rem; transition: transform .2s; }
.chapter-switch img { display: block; width: 100%; aspect-ratio: 1; }   /* its size known before it loads: the pages are counted from this */
.chapter-switch:hover, .chapter-switch:focus-visible { transform: scale(1.08); }
/* at the head of a chapter it sits in the space above the number, out of the flow: it cannot be pushed to another page,
   and a chapter's pages stay where they were */
.chapter-heading:has(.chapter-switch) { position: relative; padding-top: 4rem; }
.chapter-heading .chapter-switch { position: absolute; top: 0; left: calc(50% - 1.8rem); }
.episode > .chapter-switch { width: 4.6rem; margin: 1.8rem auto 0; break-before: avoid; }
@media (prefers-reduced-motion: reduce) { .chapter-switch { transition: none; } .chapter-switch:hover { transform: none; } }

/* ---- sign-in ---- */
#companion.signed-out .cmp-input, #companion.signed-out .cmp-close, #companion.signed-out .cmp-sel { display: none; }
.google-btn { display: inline-block; margin-top: .4em; padding: .45em 1.1em; border: 1px solid var(--rule); border-radius: 6px;
  font-variant: small-caps; letter-spacing: .06em; color: var(--ink); background: var(--paper); }
.google-btn:hover { border-color: var(--ink-soft); text-decoration: none; }
.settings-rule { border: 0; border-top: 1px solid var(--rule); margin: .6em 0; }
.settings-who { font-size: .85em; color: var(--ink-soft); margin: .1em 0 .3em; word-break: break-all; }
.settings-panel form { margin: 0; }
.opt.linkish { font: inherit; background: none; border: 0; padding: .2em .4em; margin: 0 -.4em; cursor: pointer; text-align: left; width: calc(100% + .8em); color: var(--ink); }
.opt.linkish:hover { background: rgba(127,127,127,.12); }

/* ---- today's candle: the daily conversation budget, burning down ---- */
.cmp-candle { display: inline-block; width: 18px; height: 37px; margin: -9px .4em -9px .6em; vertical-align: middle; cursor: help; flex: none; }
.cmp-candle svg { width: 100%; height: 100%; overflow: visible; display: block; }
.cmp-candle .c-dish { fill: #a07c34; } .cmp-candle .c-dish-rim { fill: none; stroke: #6f5420; stroke-width: 1; }
.cmp-candle .c-wax { fill: #efe3c4; stroke: #c9b58a; stroke-width: .7; }
.cmp-candle .c-pool { fill: #f8efd6; } .cmp-candle .c-drip { fill: none; stroke: #e2d2a6; stroke-width: 1.6; stroke-linecap: round; }
.cmp-candle .c-wick { stroke: #3b2c14; stroke-width: 1.1; stroke-linecap: round; }
.cmp-candle .c-glow { fill: #ffcf6a; opacity: .22; }
.cmp-candle .c-outer { fill: #f2a93b; } .cmp-candle .c-inner { fill: #fff3c4; }
.cmp-candle .c-flame { animation: flicker 1.9s ease-in-out infinite; }
@keyframes flicker { 0%,100% { transform: scale(1,1) skewX(0) } 22% { transform: scale(.94,1.06) skewX(-3deg) } 48% { transform: scale(1.04,.95) skewX(2deg) }
                     70% { transform: scale(.97,1.04) skewX(-1deg) } }
.cmp-candle .c-smoke { fill: none; stroke: #9a9a9a; stroke-width: .9; opacity: .6; animation: smoke 3.2s ease-in-out infinite; }
@keyframes smoke { 0% { opacity: .0; transform: translateY(2px) } 40% { opacity: .6 } 100% { opacity: 0; transform: translateY(-4px) } }
@media (prefers-reduced-motion: reduce) { .cmp-candle .c-flame, .cmp-candle .c-smoke { animation: none; } }
#companion.burned-out textarea { opacity: .6; }
/* ---- admin ---- */
.admin-table { border-collapse: collapse; width: 100%; font-size: .92em; margin-top: .6em; }
.admin-table th { text-align: left; font-weight: 500; border-bottom: 1px solid var(--rule); padding: .3em .5em; }
.admin-table td { border-bottom: 1px solid var(--rule); padding: .35em .5em; vertical-align: top; }
.admin-table td.num { text-align: right; font-variant-numeric: tabular-nums; } .admin-table td.over { color: #a33; }
.admin-inline { display: inline-flex; gap: .4em; align-items: center; margin: 0; }
.admin-num { width: 5.5em; font: inherit; padding: .1em .3em; } .admin-btn { font: inherit; padding: .05em .6em; cursor: pointer; }

/* ---- the menu's crystal ball ---- */
.settings-toggle { display: inline-flex; align-items: center; }
.orb { width: 1.35em; height: 1.35em; display: block; overflow: visible; }
.orb .orb-glass { fill: rgba(140,160,210,.18); stroke: currentColor; stroke-width: 1.2; }
.orb .orb-glint { fill: none; stroke: currentColor; stroke-width: 1.1; stroke-linecap: round; opacity: .7; }
.orb .orb-spark { fill: currentColor; opacity: .5; }
.orb .orb-base { fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linejoin: round; }
.settings[open] .orb .orb-glass, .settings-toggle:hover .orb .orb-glass { fill: rgba(140,160,210,.35); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* ---- the welcome ---- */
#welcome { position: fixed; inset: 0; z-index: 100; background: rgba(30,26,20,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
#welcome[hidden] { display: none !important; }
.welcome-card { background: var(--paper); color: var(--ink); max-width: 31rem; width: 100%; padding: 1.8rem 2rem 1.6rem; border: 1px solid var(--rule);
  box-shadow: 0 18px 48px rgba(0,0,0,.25); text-align: center; animation: popin .25s ease-out; max-height: 92vh; overflow-y: auto; box-sizing: border-box; }
.welcome-title { font-weight: 400; font-variant: small-caps; letter-spacing: .06em; margin: .2em 0 .7em; font-size: 1.6em; }
.welcome-text { text-align: left; line-height: 1.55; hyphens: auto; }
.welcome-lion { display: block; width: 34px; margin: .4em auto .2em; }
.welcome-lion svg { width: 100%; height: auto; overflow: visible; }
.welcome-lion .k-mane path { fill: #b8913f; } .welcome-lion .k-face { fill: #d6b25e; stroke: #8f7639; stroke-width: 1; }
.welcome-lion .k-brow, .welcome-lion .k-mouth { fill: none; stroke: #5a4318; stroke-width: 1.4; stroke-linecap: round; }
.welcome-lion .k-eye, .welcome-lion .k-nose { fill: #5a4318; }
.welcome-lion .k-ring-o { fill: none; stroke: #c9a24f; stroke-width: 3.2; } .welcome-lion .k-ring-i { fill: none; stroke: #8f7639; stroke-width: .8; }
.welcome-ask { font-style: italic; font-size: 1.1em; margin: .3em 0 1em; }
.welcome-choices { display: flex; flex-direction: column; gap: .6em; align-items: center; }
.welcome-browse { background: none; border: 0; color: var(--ink-soft); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.welcome-browse:hover { color: var(--ink); }
.gloss a, .lede a { text-decoration: underline; text-underline-offset: 3px; }

/* ---- the two voices ---- */
.voice { display: inline-block; width: 1.45em; height: 1.45em; vertical-align: -0.22em; margin-right: .25em; }
.voice svg { width: 100%; height: 100%; display: block; overflow: visible; }
.voice.eagle .e-body { fill: #6b4423; } .voice.eagle .e-head { fill: #f5f0e4; stroke: #6b4423; stroke-width: .8; }
.voice.eagle .e-beak { fill: #d9a520; stroke: #8a6a10; stroke-width: .4; } .voice.eagle .e-eye { fill: #2b1d0e; }
.voice.eagle .e-brow { stroke: #2b1d0e; stroke-width: .9; stroke-linecap: round; }
.voice.serpent .v-body { fill: none; stroke: #3f6b4a; stroke-width: 2.3; stroke-linecap: round; }
.voice.serpent ellipse { fill: #3f6b4a; } .voice.serpent .v-eye { fill: #e8e2a0; }
.voice.serpent .v-tongue { fill: none; stroke: #a33; stroke-width: .7; stroke-linecap: round; }

/* a passage begun in an earlier section, still running here */
.ut.cont { opacity: .45; } .ut.cont:hover { opacity: 1; }

/* ---- the companion's column: the right side of the screen, always there ---- */
:root { --cmp-w: clamp(22rem, 38vw, 36rem); }
#companion { position: fixed; top: 0; right: 0; bottom: 0; width: var(--cmp-w); z-index: 55; display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink); border-left: 1px solid var(--rule); box-shadow: -8px 0 24px rgba(0,0,0,.06); box-sizing: border-box; }
.book, .ideas { margin-right: var(--cmp-w); }
.cmp-expand { display: none; }

/* ---- a phone: the book has the whole width, the companion a sheet docked at the bottom that opens over it ---- */
@media (max-width: 720px) {
  :root { --sheet: 44dvh; }
  .book, .ideas { margin-right: 0; }
  .book { height: calc(100% - var(--sheet)); }
  .ideas { padding-bottom: var(--sheet); }
  #companion { top: auto; left: 0; right: 0; width: 100%; height: var(--sheet); border-left: 0; border-top: 1px solid var(--rule);
    box-shadow: 0 -8px 24px rgba(0,0,0,.06); transition: height 220ms ease-out; }
  body.sheet-open #companion { height: 100dvh; }
  .cmp-expand { display: inline-block; }
  .turn { width: 2.4rem; font-size: 1.8em; opacity: .35; }
  .spread-head { padding-top: .8rem; }
  #running-chapter { display: none; }   /* the trail under the page says where the reader is, and the switch needs the room */
  #knocker { width: 84px; } #knocker img { width: 32px; height: 32px; } #knocker .d-needle { width: 17px; }
  .knocker-slot { width: 86px; }
  .viewport { padding-top: 1.4rem; }
}
#companion .cmp-turns { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: .8em 1em; }
#companion .cmp-input { padding: .6em .8em .8em; border-top: 1px solid var(--rule); display: flex; gap: .5em; align-items: flex-end; flex-wrap: wrap; }
#companion .cmp-input textarea { flex: 1 1 10em; min-width: 8em; }
.cmp-head button { white-space: nowrap; }
.cturn.openers { display: flex; flex-wrap: wrap; gap: .5em; background: none; padding: 0 0 .6em; }
.cturn.openers button { font-size: .9em; padding: .35em .9em; border: 1px solid var(--rule); border-radius: 1.2em; color: var(--ink); background: var(--paper); }
.cturn.openers button:hover { border-color: var(--ink-soft); }
.cmp-stop { color: #a33 !important; font-size: 1em !important; }
.cmp-note { font-size: .85em; color: var(--ink-soft); padding: .3em 1em; border-top: 1px dotted var(--rule); }
.cmp-note[hidden] { display: none; }
/* speech mode */
.cmp-speech { padding: 0 .3em !important; opacity: .55; }
.cmp-speech svg { width: 1.6em; height: 1.2em; display: block; }
.cmp-speech .h-bell { fill: #c9a24f; stroke: #8f7639; stroke-width: .8; stroke-linejoin: round; }
.cmp-speech .h-line { stroke: #8f7639; stroke-width: .8; }
.cmp-speech .h-wave { fill: none; stroke: #8f7639; stroke-width: 1; stroke-linecap: round; opacity: .35; }
.cmp-speech.on { opacity: 1; } .cmp-speech.on .h-wave { opacity: 1; stroke: #b8913f; }
.cmp-speech:hover { opacity: 1; }
.cmp-player { display: flex; gap: .5em; align-items: center; flex-wrap: wrap; padding: .4em 1em; border-top: 1px dotted var(--rule); font-size: .9em; }
.cmp-player[hidden] { display: none; }
.cmp-player button, .cmp-speak { font: inherit; padding: .25em .8em; border: 1px solid var(--rule); border-radius: 3px; background: rgba(127,127,127,.06); cursor: pointer; }
.cmp-player button:hover, .cmp-speak:hover { background: rgba(127,127,127,.14); }
.cmp-player-note { color: var(--ink-soft); font-size: .9em; }
.cmp-speak { flex: 1 1 100%; padding: .7em 1em; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; font-variant: small-caps; letter-spacing: .08em;
  border-color: #b8913f; background: rgba(201,162,79,.12); }
.cmp-speak[hidden] { display: none; }
.cmp-speak.recording { background: #a33; border-color: #a33; color: #fff; }
#companion.speech .cmp-input textarea { flex-basis: 100%; font-size: .9em; }
.cturn.assistant.speaking { border-right: 2px solid #c9a24f; }
/* the book read aloud */
.reading { background: rgba(201,162,79,.10); box-shadow: 0 0 0 5px rgba(201,162,79,.10); border-radius: 2px; }
::highlight(heard) { background: rgba(201,162,79,.55); color: inherit; }
.cmp-mic { flex: 1 1 100%; font: inherit; font-size: .8em; color: var(--ink-soft); background: transparent; border: 1px solid var(--rule); border-radius: 3px; padding: .15em .3em; max-width: 100%; }
.cmp-mic[hidden] { display: none; }
