[data-sp="rc"] {
  --c: var(--sp-rc);
}
/* chapters and sections */
.story {
  min-width: 0;
  padding-bottom: calc(var(--s) * 2);
}
.ch-head {
  margin-block: var(--m);
  padding-block: var(--s);
  border-top: var(--l-3px) double var(--rule-2);
  border-bottom: var(--l-3px) double var(--rule-2);
}
.chapter:first-child .ch-head {
  margin-top: var(--s);
}
.ch-head h2 {
  margin: 0;
  font: 800 clamp(var(--l-1-9rem), 4.5vw, var(--l-2-6rem)) / 1.05 var(--serif);
  letter-spacing: -0.015em;
}
/* tabbed view */
.book-tabs {
  display: flex;
  gap: var(--l-0-25rem);
  overflow-x: auto;
  padding-block: var(--l-0-5rem);
  margin-top: var(--s);
}
.book-tabs .tab {
  font-weight: 600;
}
.tabbed .chapter:first-of-type .ch-head,
.tabbed .ch-head {
  margin-block: var(--s);
}
.ch-tabs {
  display: flex;
  gap: var(--l-0-25rem);
  overflow-x: auto;
  padding-block: var(--l-0-5rem);
}
.tabbed .ch-tabs {
  display: flex;
}
.ch-tabs[hidden] {
  display: none;
}
.tabbed .sec[hidden] {
  display: none;
}
.sec-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--s);
  margin-block: var(--s);
}
.sec-nav button,
.sec-nav a {
  padding: var(--l-0-4rem) var(--l-0-8rem);
  border: var(--l-1px) solid var(--rule-2);
  background: transparent;
  color: var(--ink);
  font: 500 var(--l-0-85rem) var(--sans);
  text-decoration: none;
  cursor: pointer;
}
.sec-nav button:hover,
.sec-nav a:hover {
  border-color: var(--ink-2);
}
/* in tabbed view the link to the next part sits in the section navigation,
   so the button under the end mark leaves */
.tabbed .part-next {
  display: none;
}
.sec-nav button[disabled] {
  visibility: hidden;
}
.sec h3 {
  display: flex;
  align-items: center;
  gap: var(--l-0-75rem);
  margin-block: 0;
  padding-block: var(--l-0-6rem);
  font: 600 var(--l-0-82rem) / 1.3 var(--mono);
  letter-spacing: var(--l-0-14em);
  text-transform: uppercase;
  color: var(--ink-2);
}
.sec h3::after {
  content: "";
  flex: 1;
  border-top: var(--l-1px) solid var(--rule);
  order: 2;
}
/* the chapter header carries its own margin, so the first section heading
   drops its top padding */
.ch-head + .ch-tabs[hidden] + .sec > h3 {
  padding-top: 0;
}
.sec-n {
  color: var(--sp-k);
}
.plink {
  order: 3;
  font: 500 var(--l-0-85rem) var(--mono);
  color: var(--mute);
  background: none;
  border: 0;
  padding: 0 var(--l-0-2rem);
  cursor: pointer;
}
.plink:hover {
  color: var(--ink);
}
/* scene narration */
.scene {
  margin-block: var(--s);
  padding-left: var(--s);
  border-left: var(--l-1px) solid var(--rule-2);
  font: 400 1.14rem/1.6 var(--serif);
  color: var(--ink-2);
}
.scene p + p {
  margin-top: var(--s);
}
.scene-mid {
  margin-block: var(--xs);
}
/* a perspective shift: the story changes the character it follows, as with Marc and
   Lucretia or the people of Albert's dreams. Same scene type, a dashed rule and a cooler gray so
   the cut reads at a glance */
.scene-shift {
  border-left-style: dashed;
  border-left-color: var(--mute);
  color: color-mix(in srgb, var(--ink-2) 82%, var(--mute));
}
/* a time shift: the story jumps forward in time and stays with the same people.
   Same scene type, a dotted rule, so it reads apart from the dashed cut to
   another place */
.scene-time {
  padding-left: calc(var(--s) - 1px);
  border-left: 2px dotted var(--mute);
}
/* a scene that opens a section takes the smaller spacing and sits under the heading */
.sec > h3 + .scene {
  margin-block: 0 var(--xs);
}
/* dialogue lines */
.ln {
  position: relative;
  display: grid;
  /* --sp-w is set by js/text/names.js to the width of the longest speaker name */
  grid-template-columns: var(--sp-w, 8rem) minmax(0, 1fr);
  align-items: center;
  column-gap: var(--s);
  padding-block: var(--l-0-6rem);
  padding-right: var(--l-0-6rem);
  border-top: var(--l-1px) solid var(--rule);
}
/* close the last reply before a screen, a scene or the end of a section */
.ln:last-child,
.ln:has(+ :not(.ln)) {
  border-bottom: var(--l-1px) solid var(--rule);
}
.sp {
  font: 600 0.88rem/1.3 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c);
  text-align: right;
}
/* the same reply carried on after a screen: the name is left out and the
   text stays in the reply's own column, so it reads as one reply resumed */
/* a reply of several paragraphs keeps them all in the text column, the name
   beside the first */
.ln > p {
  grid-column: 2;
}
.ln:has(> p + p) {
  align-items: start;
  row-gap: var(--xs);
}
.ln-cont {
  border-top: 0;
}
.ln-cont > p {
  grid-column: 2;
}
.ln-cont > .sp-cont {
  display: none;
}
/* with the screen before it folded, the reply stands on its own: its name
   comes back and a rule separates it like any other reply */
details:not([open]) + .ln-cont {
  border-top: var(--l-1px) solid var(--rule);
}
details:not([open]) + .ln-cont > .sp-cont {
  display: block;
}
.sp-probe {
  position: absolute;
  visibility: hidden;
  white-space: nowrap;
  pointer-events: none;
}
.act {
  font-style: italic;
  color: var(--mute);
}
.ln-act p {
  color: var(--mute);
}
/* the end of the book: the last scene stands on its own in the middle of the
   column, and the end mark sits under it between two short rules */
.scene.scene-final {
  margin: calc(var(--s) * 2) auto;
  padding: 0;
  border-left: 0;
  text-align: center;
  font-size: 1.22rem;
  line-height: 1.7;
  color: var(--ink);
}
/* the post-mortem of part 2: one card per thread, each under a small mono
   label, set side by side and wrapping onto the next row like the closing
   cards of a game */
.coda {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s);
  margin: 0;
}
/* the last line keeps the same step from the cards above it as the cards
   keep from each other */
.coda + .scene.scene-final {
  margin-block: var(--s);
}
.coda-card {
  flex: 1 1 18rem;
  padding: var(--s);
  border: var(--l-1px) solid var(--rule-2);
  border-radius: var(--l-6px);
  background: var(--panel);
  font: 400 1.1rem/1.65 var(--serif);
  color: var(--ink-2);
}
.coda-card p {
  margin: 0;
}
.coda-card .coda-k {
  margin-bottom: var(--l-0-5rem);
  font: 600 var(--l-0-72rem) / 1.4 var(--mono);
  letter-spacing: var(--l-0-2em);
  text-transform: uppercase;
  color: var(--sp-k);
}
/* the end mark under the last scene of a part, between two short rules */
.the-end {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s);
  margin: 0;
}
.the-end::before,
.the-end::after {
  content: "";
  width: 4rem;
  border-top: var(--l-1px) solid var(--rule-2);
}
.the-end p {
  margin: 0;
  font: 600 var(--l-0-85rem) / 1 var(--mono);
  letter-spacing: 0.4em;
  margin-right: -0.4em;
  text-transform: uppercase;
  color: var(--sp-k);
}
/* the button from the end of part 1 to part 2, styled like the settings
   buttons */
.part-next {
  display: flex;
  justify-content: center;
  margin: var(--s) 0 0;
}
/* folded screens and printed matter open and fold like a drawer, in CSS
   alone. The browser keeps a details element's content in its own box,
   ::details-content, and hides it with content-visibility while the element
   is shut. That box is made a one-row grid whose row runs from 0fr to 1fr,
   a change every current browser animates, and content-visibility waits
   with allow-discrete until the row has closed, so the drawer is seen
   shutting before its content goes. The clip is vertical only, so shadows
   at the sides stay. */
details.app::details-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 0fr;
  overflow-y: clip;
  transition:
    grid-template-rows 0.28s cubic-bezier(0.3, 0, 0.2, 1),
    content-visibility 0.28s allow-discrete;
}
details.app[open]::details-content {
  grid-template-rows: 1fr;
}
/* the content keeps its own full height while the row around it opens and
   shuts, so nothing inside it is laid out again on every frame; the row
   only uncovers it */
details.app > :not(summary) {
  min-height: 0;
  min-width: 0;
  align-self: start;
  contain: layout;
}
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) details.app::details-content {
    transition: none;
  }
}
:root[data-motion="reduced"] details.app::details-content {
  transition: none;
}
/* a translation printed as its own line, under the words it translates, in
   documents and on screens. It stays a .tr, so whatever shows or hides the
   translations elsewhere does the same here */
.tr.tr-line {
  display: block;
  margin-top: 0.15em;
  font-family: var(--sans);
  font-size: 0.86em;
  font-style: normal;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}
/* the translation switch (js/reading/glosses.js): the original alone hides
   the translations; the translation alone hides the foreign words it
   translates and its brackets, and reads like the rest of the reply. In both
   modes every reply or screen holding a translation offers a button back to
   the normal mode, like a reply hidden with the stage directions */
.gloss-original .tr {
  display: none;
}
.gloss-translation .tr-orig,
.gloss-translation .tr-p {
  display: none;
}
/* with the original hidden, the translation takes the place and the look of
   the words it translates: same color, size, face and weight as the text
   around it, in the dialogue, in documents and on screens */
body.gloss-translation .tr,
body.gloss-translation .tr.tr-line {
  color: inherit;
  font-style: inherit;
  font-size: inherit;
  font-family: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
}
body.gloss-translation .tr.tr-line {
  margin-top: 0;
}
.gloss-restore,
.gloss-back {
  display: none;
}
/* the same size as the button that brings back the stage directions */
.gloss-original .gloss-restore,
.gloss-translation .gloss-restore {
  display: inline-block;
  margin-left: 0.4em;
  font-style: normal;
}
.gloss-original .gloss-back,
.gloss-translation .gloss-back {
  display: flex;
  justify-content: center;
  margin-top: var(--xs);
}
/* a reply that follows a reply by the same speaker: no rule above it and no visible name.
   The name stays for screen readers */
.ln.ln-same {
  border-top: 0;
  padding-top: 0;
}
.ln-same > .sp {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
/* the post-mortem's documents sit closer together than the screens of the story */
body[data-part="2"] .app {
  margin-block: var(--xs);
}
