/* =====================================================================================================
 * Study Quest — codex.css · THE CODEX (the statistics & progress book)
 * SPEC 0b UPDATE 21:50 + UPDATE 07:05 · DESIGN.md "Ember & Iron" §8 Codex: an IRON-BOUND BOOK. Boards of
 * scorched black leather under forged-iron corner guards, spine bosses and clasp straps; the fore-edge of the leaves
 * catches the firelight from below (the ember-lit edge). The spread is the game's one big parchment surface:
 * iron-gall ink, oxblood Cinzel headings, large tabular numbers. Chapter tabs are stitched leather straps with iron
 * tips; the open chapter's strap is pulled out and ember-lit.
 *
 * Load after theme.css (base → theme → hud → panels → world-ui → music-ui → codex). Module prefix: .book-*
 * (theme.css owns .codex-*, .ei-* and .cx-*; only scoped tweaks of those appear here, always under .book-layer).
 * READABILITY FIRST (user): reading text 18 px (16 px single page), headings ≥ 24 px, figures 36 px tabular,
 * every ink ≥ 5.6:1 on the parchment (body ink 11:1).
 * Energy: no idle animation — the firelight is static gradients, no embers, nothing breathing. Only opacity /
 * transform transitions on open, page turn and hover.
 * ===================================================================================================== */

.book-layer {
  /* geometry read by ui-codex.js (pagination): keep these in px */
  --book-band: 28px;           /* the boards around the text block */
  --book-head: 64px;           /* running head */
  --book-foot: 56px;           /* folio + page corner */
  --book-outer: 52px;          /* outer margin of a page */
  --book-inner: 42px;          /* inner margin, towards the gutter */
  --book-fs: 18px;             /* reading text */
  --book-lh: 1.56;
  --book-fig: 36px;            /* large figures */
  --book-h2: 26px;
  --book-h3: 20px;
  --book-label: 15px;          /* Cinzel labels (≥ 12 px capitals floor) */
  --book-small: 16px;          /* captions, meta — never below 15 px on desktop */
  --book-rule: rgba(122, 29, 16, 0.24);   /* oxblood hairlines */
  --book-hair: rgba(58, 34, 20, 0.22);    /* ink hairlines */
  position: fixed;
  inset: 0;
  z-index: 950;                /* over windows (50+) and the map (140); under travel card (960+), modals (1000), tooltips (5000) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 24px;
  box-sizing: border-box;
  color: var(--cx-ink-text);
  font-family: var(--cx-font-body);
  -webkit-user-select: text;
  user-select: text;
  opacity: 0;
  transition: opacity var(--cx-dur-calm) var(--cx-ease);
}
.book-layer.is-open { opacity: 1; }
.book-layer *, .book-layer *::before, .book-layer *::after { box-sizing: border-box; }

/* the room goes dark: soot, cold smoke from above, a pool of firelight on the table under the book (static) */
.book-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 58% 34% at 50% 102%, rgba(226, 84, 31, 0.22), rgba(226, 84, 31, 0) 72%),
    radial-gradient(ellipse 70% 46% at 50% -6%, rgba(125, 136, 149, 0.13), rgba(125, 136, 149, 0) 72%),
    radial-gradient(ellipse 90% 80% at 50% 48%, rgba(8, 9, 11, 0.66), rgba(3, 3, 4, 0.95) 82%);
}

/* ------------------------------------------------------------------------------------------ the book */
.book {
  position: relative;
  width: min(1240px, calc(100vw - 270px));
  height: min(840px, calc(100vh - 40px));
  margin-right: 186px;          /* room for the straps on the fore-edge; keeps the whole group centred */
  transform: translateY(8px);
  transition: transform var(--cx-dur-calm) var(--cx-ease);
  outline: none;
}
.book-layer.is-open .book { transform: none; }

/* the boards: scorched black leather, an iron binding along every edge, forged corner guards (.codex-frame) */
.book-cover {
  --cx-band: var(--book-band);
  position: absolute;
  inset: 0;
  z-index: 2;
  padding: var(--book-band);
}
.book-layer .book-cover.codex-frame {
  border: 1px solid #000;
  border-radius: 5px;
  background:
    linear-gradient(180deg, rgba(200, 212, 228, 0.12), rgba(200, 212, 228, 0) 2px),                       /* cold top lip */
    radial-gradient(ellipse 64% 26% at 50% 100%, rgba(255, 128, 44, 0.24), rgba(255, 128, 44, 0) 100%),     /* firelight on the lower board */
    radial-gradient(ellipse 80% 60% at 30% 0%, rgba(140, 156, 178, 0.07), rgba(140, 156, 178, 0) 70%),     /* cold key light, top-left */
    var(--cx-tex-leather),
    linear-gradient(180deg, #221813 0%, #140e0b 55%, #0d0907 100%);
  box-shadow:
    inset 0 -2px 0 rgba(255, 150, 70, 0.42),                                                              /* the lower edge catches the fire */
    inset 0 0 0 1px #5d646d, inset 0 0 0 2px #30343a, inset 0 0 0 7px #1c1f23, inset 0 0 0 8px #000,      /* forged iron binding */
    inset 0 0 0 9px rgba(176, 122, 60, 0.35),                                                             /* bronze seam on the leather */
    0 2px 0 #000,
    0 34px 70px rgba(0, 0, 0, 0.72),
    0 22px 60px -18px rgba(226, 84, 31, 0.38);                                                            /* warm spill under the book */
}
/* corner guards: heavy thorned iron brackets on the boards (the leaves lie over their inner arms) */
.book-layer .book-cover.codex-frame::before {
  top: -9px; right: -9px; bottom: -9px; left: -9px;
  background:
    var(--cx-orn-corner-tl) left top / 84px 84px no-repeat,
    var(--cx-orn-corner-tr) right top / 84px 84px no-repeat,
    var(--cx-orn-corner-bl) left bottom / 84px 84px no-repeat,
    var(--cx-orn-corner-br) right bottom / 84px 84px no-repeat;
}
/* the rim where the boards meet the leaves: a dark-bronze hairline and a deep shadow line */
.book-layer .book-cover.codex-frame::after { border-color: rgba(176, 122, 60, 0.45); }

/* the spine between the boards, seen above and below the leaves: rounded leather with an iron boss at head and tail */
.book-spine {
  position: absolute;
  top: 2px; bottom: 2px; left: 50%;
  width: 46px;
  margin-left: -23px;
  z-index: 1;
  border-radius: 4px;
  background:
    var(--cx-orn-boss) center top 1px / 22px 22px no-repeat,
    var(--cx-orn-boss) center bottom 1px / 22px 22px no-repeat,
    linear-gradient(90deg, rgba(0, 0, 0, 0.75), rgba(255, 214, 160, 0.06) 28%, rgba(255, 214, 160, 0.12) 50%, rgba(255, 214, 160, 0.04) 72%, rgba(0, 0, 0, 0.8)),
    #120d0a;
  pointer-events: none;
}
/* clasp straps hang open off the left board; their catches sit on the right board below the bookmarks */
.book-layer .book-cover .codex-clasp { z-index: 1; width: 56px; height: 28px; margin-top: -14px; }
.book-layer .book-cover .codex-clasp--l { left: -44px; top: 24%; background-image: var(--cx-orn-clasp-l); }
.book-layer .book-cover .book-clasp2 { top: 76%; }

/* the text block: two parchment leaves; the stack of leaves shows at the edges, the lower fore-edge is ember-lit */
.book-block {
  position: relative;
  z-index: 6;
  width: 100%;
  height: 100%;
  border-radius: 2px;
  box-shadow:
    -1px 0 0 #d8c59b, -2px 1px 0 #8f7348, -3px 1px 0 #cdb685, -4px 2px 0 #7d6038, -5px 2px 0 #b99d6c, -6px 3px 0 #3a2a18,
    1px 0 0 #d8c59b, 2px 1px 0 #8f7348, 3px 1px 0 #cdb685, 4px 2px 0 #7d6038, 5px 2px 0 #b99d6c, 6px 3px 0 #3a2a18,
    0 2px 0 #e7b878, 0 3px 0 #8a4c1e, 0 4px 0 #f2a456, 0 5px 0 #7a3a12, 0 6px 0 #e08a3c, 0 7px 0 #4a200a,
    0 9px 22px rgba(255, 112, 32, 0.30),
    0 10px 16px rgba(0, 0, 0, 0.55);
}
.book-page {
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
  overflow: hidden;
  /* the parchment recipe under a calming wash: fibres and smoke stains stay, but never fight the ink */
  background:
    /* low-key firelight: warm from below, cold smoke settling on the head, the leaf darkening towards its edges */
    radial-gradient(ellipse 110% 26% at 50% 106%, rgba(255, 150, 70, 0.12), rgba(255, 150, 70, 0) 100%),
    linear-gradient(180deg, rgba(46, 52, 62, 0.10), rgba(46, 52, 62, 0) 22%),
    radial-gradient(ellipse 125% 110% at 50% 52%, rgba(86, 48, 18, 0) 64%, rgba(86, 48, 18, 0.13) 86%, rgba(62, 32, 10, 0.30) 100%),
    linear-gradient(180deg, rgba(240, 230, 203, 0.42), rgba(226, 210, 174, 0.42)),
    var(--cx-bg-vellum);
  color: var(--cx-ink-text);
}
.book-page--l { left: 0; border-radius: 2px 0 0 2px; box-shadow: inset 18px 0 30px -16px rgba(58, 30, 10, 0.5), var(--cx-vellum-burn); }
.book-page--r { right: 0; border-radius: 0 2px 2px 0; box-shadow: inset -18px 0 30px -16px rgba(58, 30, 10, 0.5), var(--cx-vellum-burn); }
/* the gutter: the leaves curve down into the binding */
.book-page::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 74px;
  pointer-events: none;
}
.book-page--l::after { right: 0; background: linear-gradient(90deg, rgba(50, 26, 8, 0) 0%, rgba(255, 248, 230, 0.16) 38%, rgba(50, 26, 8, 0.12) 70%, rgba(40, 20, 6, 0.42) 100%); }
.book-page--r::after { left: 0; background: linear-gradient(270deg, rgba(50, 26, 8, 0) 0%, rgba(255, 248, 230, 0.16) 38%, rgba(50, 26, 8, 0.12) 70%, rgba(40, 20, 6, 0.42) 100%); }
/* head and foot rules of the text block: oxblood hairlines */
.book-page::before {
  content: '';
  position: absolute;
  top: calc(var(--book-head) - 12px);
  bottom: calc(var(--book-foot) - 10px);
  pointer-events: none;
  border-top: 1px solid var(--book-rule);
  border-bottom: 1px solid var(--book-rule);
}
.book-page--l::before { left: var(--book-outer); right: var(--book-inner); }
.book-page--r::before { left: var(--book-inner); right: var(--book-outer); }

/* running heads & folios */
.book-runhead {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: calc(var(--book-head) - 12px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px 60px 0;
  font: 700 14px/1.1 var(--cx-font-label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cx-ink-rubric);
  white-space: nowrap;
  overflow: hidden;
}
.book-runhead .cx-fleuron { width: 13px; height: 13px; opacity: 0.9; background-image: var(--cx-orn-fleuron-ink); }
.book-runhead b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.book-runhead i { font: 600 15px/1 var(--cx-font-num); letter-spacing: 0.02em; text-transform: none; font-style: normal; color: var(--cx-ink-text-dim); }
.book-folio {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--book-foot) - 10px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-bottom: 2px;
  font: 500 15px/1 var(--cx-font-num);
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: 0.04em;
  color: var(--cx-ink-text-dim);
}
.book-folio::before, .book-folio::after {
  content: '';
  width: 6px; height: 6px;
  transform: rotate(45deg);
  background: rgba(122, 29, 16, 0.55);
}
.book-folio:empty { display: none; }

/* page corners: a dog-eared corner to turn the page (also ← → keys) */
.book-corner {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  bottom: 0;
  z-index: 8;
  width: 60px;
  height: 60px;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.book-corner::before {
  /* the folded flap: its back towards the page, a shade under it */
  content: '';
  position: absolute;
  bottom: 0;
  width: 42px;
  height: 42px;
  transition: transform var(--cx-dur-quick) var(--cx-ease);
  filter: drop-shadow(-1px -1px 2px rgba(50, 26, 8, 0.4));
}
.book-corner--next { right: 0; }
.book-corner--next::before {
  right: 0;
  transform-origin: 100% 100%;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0) 49%, #f4e8cb 50%, #e2cfa4 66%, #c6a670 100%);
  border-radius: 0 0 2px 0;
}
.book-corner--prev { left: 0; }
.book-corner--prev::before {
  left: 0;
  transform-origin: 0 100%;
  background: linear-gradient(225deg, rgba(0, 0, 0, 0) 49%, #f4e8cb 50%, #e2cfa4 66%, #c6a670 100%);
  border-radius: 0 0 0 2px;
  filter: drop-shadow(1px -1px 2px rgba(50, 26, 8, 0.4));
}
.book-corner::after {
  /* the arrow, inked in oxblood: always faintly there, clear on hover */
  position: absolute;
  bottom: 7px;
  font: 700 24px/1 var(--cx-font-label);
  color: var(--cx-ink-rubric);
  opacity: 0.55;
  transition: opacity var(--cx-dur-quick) var(--cx-ease);
}
.book-corner--next::after { content: '\203A\FE0E'; right: 10px; }
.book-corner--prev::after { content: '\2039\FE0E'; left: 10px; }
.book-corner:hover::before, .book-corner:focus-visible::before { transform: scale(1.2); }
.book-corner:hover::after, .book-corner:focus-visible::after { opacity: 1; }
.book-corner:focus { outline: none; }
.book-corner:focus-visible::before { filter: drop-shadow(0 0 5px rgba(255, 138, 61, 0.9)); }
.book-corner[hidden] { display: none; }

/* the reading viewport spans both pages; the flow is laid out in columns = pages, one spread at a time */
.book-view {
  position: absolute;
  z-index: 4;
  top: var(--book-head);
  bottom: var(--book-foot);
  left: var(--book-outer);
  right: var(--book-outer);
  overflow: hidden;
}
.book-flow {
  position: relative;
  height: 100%;
  column-fill: auto;
  -webkit-column-fill: auto;
  font: 400 var(--book-fs)/var(--book-lh) var(--cx-font-body);
  color: var(--cx-ink-text);
  font-kerning: normal;
  outline: none;
  will-change: transform;
}
.book-layer .book-flow.codex-vellum { background: none; box-shadow: none; }   /* ink-on-parchment type rules; the page paints the parchment */
.book-flow.is-turning { transition: opacity 0.14s var(--cx-ease-in); opacity: 0; }
.book-flow.is-arriving { transition: opacity 0.32s var(--cx-ease), transform 0.32s var(--cx-ease); }

/* the iron close boss rides on the top board, clear of the corner guard */
.book-layer .book-close { top: -14px; right: 92px; width: 32px; height: 32px; z-index: 9; }

/* ------------------------------------------------------------------------------------------ chapter straps */
/* stitched leather straps with forged iron tips, tucked between the leaves on the fore-edge */
.book-marks {
  position: absolute;
  z-index: 1;                    /* under the boards' edge */
  top: 78px;
  left: 100%;
  margin-left: -36px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.book-mark {
  --_lea: linear-gradient(180deg, #33251c 0%, #221812 48%, #140d09 100%);
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 246px;
  height: 44px;
  margin: 0;
  padding: 0 30px 0 54px;
  border: 0;
  text-align: left;
  color: var(--cx-text);
  text-shadow: 0 1px 0 #000;
  background:
    /* the iron tip: a forged point with a bronze rivet */
    radial-gradient(circle at calc(100% - 18px) 50%, #cf9f5a 0 1px, #7a5229 2px, #241608 3px, rgba(0, 0, 0, 0) 3.6px),
    linear-gradient(180deg, rgba(200, 212, 228, 0.35), rgba(200, 212, 228, 0) 2px) right 0 top 0 / 30px 100% no-repeat,
    linear-gradient(180deg, #5a6068 0%, #33373d 38%, #1a1c20 72%, #0b0c0e 100%) right 0 top 0 / 30px 100% no-repeat,
    linear-gradient(90deg, #000 0 1px, rgba(0, 0, 0, 0) 1px) right 29px top 0 / 2px 100% no-repeat,
    /* saddle stitching along both edges */
    repeating-linear-gradient(90deg, rgba(222, 200, 160, 0.34) 0 6px, rgba(0, 0, 0, 0) 6px 10px) left 0 top 5px / calc(100% - 34px) 1px no-repeat,
    repeating-linear-gradient(90deg, rgba(222, 200, 160, 0.30) 0 6px, rgba(0, 0, 0, 0) 6px 10px) left 0 bottom 5px / calc(100% - 34px) 1px no-repeat,
    linear-gradient(180deg, rgba(255, 225, 190, 0.08), rgba(255, 225, 190, 0) 40%),
    var(--cx-tex-grain),
    var(--_lea);
  -webkit-clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%);
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%);
  box-shadow: inset 0 1px 0 rgba(255, 220, 180, 0.10), inset 0 -2px 0 rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transform: translateX(-14px);
  transition: transform var(--cx-dur-calm) var(--cx-ease), color var(--cx-dur-quick) var(--cx-ease);
}
.book-mark::after {
  /* the ember light on the open chapter's strap: a glow from the book, a hot edge along the top */
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 170, 90, 0.7), rgba(255, 170, 90, 0) 2px),
    radial-gradient(ellipse 70% 120% at 0% 50%, rgba(255, 120, 40, 0.42), rgba(255, 120, 40, 0) 100%);
  opacity: 0;
  transition: opacity var(--cx-dur-calm) var(--cx-ease);
  pointer-events: none;
}
.book-mark__i {
  position: relative;
  z-index: 1;
  flex: none;
  width: 28px;
  font: 700 15px/1 var(--cx-font-label);
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--cx-gold-text);
}
.book-mark__in { display: none; }
.book-mark__t {
  position: relative;
  z-index: 1;
  font: 700 15px/1 var(--cx-font-label);
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-mark:hover { transform: translateX(-6px); color: var(--cx-gold-leaf); }
.book-mark.is-active { transform: translateX(8px); color: var(--cx-gold-leaf); }
.book-mark.is-active::after { opacity: 1; }
.book-mark.is-active .book-mark__i { color: var(--cx-molten); text-shadow: 0 0 8px rgba(255, 140, 50, 0.85), 0 1px 0 #000; }
.book-mark:focus { outline: none; }
.book-mark:focus-visible { color: var(--cx-gold-leaf); }
.book-mark:focus-visible::after { opacity: 0.8; }
/* each chapter's leather keeps a faint dye so the straps can be told apart; ember stays for the open one */
.book-mark--oxblood { --_lea: linear-gradient(180deg, #3d1a14 0%, #29100b 48%, #170806 100%); }
.book-mark--lapis { --_lea: linear-gradient(180deg, #232a36 0%, #171c25 48%, #0c1016 100%); }
.book-mark--verdigris { --_lea: linear-gradient(180deg, #1f2c28 0%, #141e1b 48%, #0b1110 100%); }
.book-mark--gold { --_lea: linear-gradient(180deg, #3b2a17 0%, #281b0e 48%, #170f07 100%); }

/* ------------------------------------------------------------------------------------------ type in the flow */
.book-flow p { margin: 0 0 0.62em; }
.book-flow a { color: var(--cx-ink-lapis); text-decoration: underline; text-decoration-color: rgba(31, 58, 118, 0.45); text-underline-offset: 3px; }
.book-flow a:hover { color: var(--cx-ink-rubric); }
.book-flow b, .book-flow strong { font-weight: 700; }
.book-num { font-variant-numeric: lining-nums tabular-nums; }

/* chapter opener: "Chapter II" in spaced capitals, the chapter name carved in oxblood Cinzel, an inked rule */
.book-opener { margin: 0 0 16px; text-align: center; break-inside: avoid; -webkit-column-break-inside: avoid; break-after: avoid; -webkit-column-break-after: avoid; }
.book-opener__no { display: block; margin: 0 0 8px; font: 700 13px/1 var(--cx-font-label); letter-spacing: 0.32em; text-transform: uppercase; color: var(--cx-ink-text-dim); }
.book-opener__t { margin: 0; font: 700 34px/1.08 var(--cx-font-title); letter-spacing: 0.03em; color: var(--cx-ink-rubric-lg); }
.book-opener__orn { display: block; width: min(300px, 86%); height: 18px; margin: 12px auto 0; background: var(--cx-orn-filler) center / 100% 18px no-repeat; }

/* lead paragraph with an illuminated initial (the one focal ornament of a chapter) */
.book-lead { --cx-dropcap: 82px; margin: 0 0 0.9em; }
.book-lead::after { content: ''; display: block; clear: both; }
.book-layer .book-lead .codex-dropcap { margin: 6px 12px 0 0; }

.book-h2 {
  margin: 1.05em 0 0.42em;
  font: 700 var(--book-h2)/1.12 var(--cx-font-head);
  letter-spacing: 0.02em;
  color: var(--cx-ink-rubric-lg);
  break-after: avoid;
  -webkit-column-break-after: avoid;
  break-inside: avoid;
}
.book-h2 small { margin-left: 8px; font: italic 400 var(--book-small)/1 var(--cx-font-body); color: var(--cx-ink-text-dim); }
.book-h3 {
  margin: 0.9em 0 0.3em;
  font: 700 var(--book-h3)/1.15 var(--cx-font-head);
  letter-spacing: 0.02em;
  color: var(--cx-ink-rubric);
  break-after: avoid;
  -webkit-column-break-after: avoid;
}
.book-note { margin: 0.2em 0 0.8em; font: italic 400 var(--book-small)/1.45 var(--cx-font-body); color: var(--cx-ink-text-dim); }
.book-empty { margin: 0.4em 0 1em; padding: 12px 16px; border-left: 3px solid rgba(122, 29, 16, 0.4); font: italic 400 var(--book-fs)/1.5 var(--cx-font-body); color: var(--cx-ink-text-dim); background: rgba(255, 250, 236, 0.35); break-inside: avoid; -webkit-column-break-inside: avoid; }
.book-sep { height: 18px; margin: 14px 0; break-after: avoid; }
.book-break { break-before: column; -webkit-column-break-before: always; }
.book-keep { break-inside: avoid; -webkit-column-break-inside: avoid; }

/* figures: big tabular numbers with a small-caps label, separated by rubric hairlines (no boxes) */
.book-figs {
  display: grid;
  grid-template-columns: repeat(3, minmax(min-content, 1fr));
  margin: 4px 0 14px;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
}
.book-figs--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.book-fig {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 8px 12px 10px;
  border-left: 1px solid rgba(122, 29, 16, 0.26);
}
.book-fig:nth-child(3n + 1) { border-left: 0; padding-left: 0; }
.book-figs--2 .book-fig { border-left: 1px solid rgba(122, 29, 16, 0.26); padding-left: 12px; }
.book-figs--2 .book-fig:nth-child(2n + 1) { border-left: 0; padding-left: 0; }
.book-fig:nth-child(n + 4) { border-top: 1px solid rgba(122, 29, 16, 0.16); }
.book-figs--2 .book-fig:nth-child(n + 3) { border-top: 1px solid rgba(122, 29, 16, 0.16); }
.book-figs--2 .book-fig:nth-child(-n + 2) { border-top: 0; }
.book-fig__v {
  font: 700 var(--book-fig)/1 var(--cx-font-num);
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: -0.01em;
  color: var(--cx-ink-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-fig__v small { margin-left: 3px; font-size: 0.5em; font-weight: 500; color: var(--cx-ink-text-dim); }
.book-fig__k { font: 700 var(--book-label)/1.25 var(--cx-font-label); letter-spacing: 0.05em; color: var(--cx-ink-text-dim); }
.book-fig--rubric .book-fig__v { color: var(--cx-ink-rubric); }
.book-fig--gold .book-fig__v { color: var(--cx-ink-gold); }

/* a ledger: label …… value (an index in the back of a book) */
.book-ledger { margin: 2px 0 12px; padding: 0; list-style: none; }
.book-ledger > li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
}
.book-ledger__k { flex: 0 1 auto; min-width: 0; }
.book-ledger__dots { flex: 1 1 24px; min-width: 18px; border-bottom: 2px dotted rgba(74, 53, 34, 0.38); transform: translateY(-5px); }
.book-ledger__v { flex: none; max-width: 62%; font-weight: 500; font-variant-numeric: lining-nums tabular-nums; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-ledger__v small { font: italic 400 var(--book-small)/1 var(--cx-font-body); color: var(--cx-ink-text-dim); }
.book-ledger--dim .book-ledger__k { color: var(--cx-ink-text-dim); }

/* bars from theme.css, with readable labels outside */
.book-meter { margin: 6px 0 14px; break-inside: avoid; -webkit-column-break-inside: avoid; }
.book-meter__top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 7px; }
.book-meter__top b { font: 700 var(--book-h3)/1.1 var(--cx-font-head); letter-spacing: 0.02em; color: var(--cx-ink-rubric); }
.book-meter__top span { font: 500 17px/1.1 var(--cx-font-num); font-variant-numeric: lining-nums tabular-nums; color: var(--cx-ink-text-dim); white-space: nowrap; }
.book-meter__sub { margin-top: 6px; font: italic 400 var(--book-small)/1.35 var(--cx-font-body); color: var(--cx-ink-text-dim); }
.book-layer .book-meter .codex-bar { height: 20px; }
.book-mini { position: relative; height: 8px; margin: 6px 0 2px; border-radius: 2px; background: rgba(90, 60, 30, 0.14); box-shadow: inset 0 1px 1px rgba(60, 30, 8, 0.25); overflow: hidden; }
.book-mini > i { position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(var(--v, 0)); background: linear-gradient(180deg, #e0ad52, #b07a2c 55%, #6b4a20); }   /* quest progress = molten gold (DESIGN §2.4) */
.book-mini--gold > i { background: linear-gradient(180deg, #e0ad52, #a8772f 60%, #6b4a20); }

/* charts (inline SVG drawn by ui-codex.js) */
.book-chart { margin: 4px 0 16px; break-inside: avoid; -webkit-column-break-inside: avoid; }
.book-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.book-chart figcaption { margin-top: 6px; font: italic 400 var(--book-small)/1.4 var(--cx-font-body); color: var(--cx-ink-text-dim); }
.book-chart [data-tip] { cursor: help; }
.book-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 8px; font: 700 var(--book-label)/1.2 var(--cx-font-label); letter-spacing: 0.03em; color: var(--cx-ink-text-dim); }
.book-legend i { display: inline-block; width: 16px; height: 16px; margin-right: 2px; vertical-align: -3px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(90, 60, 30, 0.3); }
.book-legend .book-legend__dot { width: 11px; height: 11px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #ffc06a, #e2541f 60%, #9a2c0c); box-shadow: 0 0 0 1.2px #3a1206; vertical-align: -1px; }

/* filters: iron tabs on the parchment (theme component), scoped size */
.book-layer .book-filters { margin: 6px 0 14px; padding: 0 4px; break-after: avoid; }
.book-layer .book-filters .codex-tab { font-size: 15px; padding: 9px 14px 8px; }
.book-layer .book-filters .codex-tab.is-active { padding-top: 12px; }

/* exercise tree */
.book-ex {
  margin: 0 0 12px;
  padding: 2px 0 8px;
  border-bottom: 1px solid rgba(80, 46, 14, 0.16);
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
}
.book-ex__head { display: flex; align-items: baseline; gap: 10px; }
.book-ex__name { flex: 1 1 auto; min-width: 0; font: 700 21px/1.2 var(--cx-font-head); letter-spacing: 0.02em; color: var(--cx-ink-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-ex__when { flex: none; font: italic 400 var(--book-small)/1 var(--cx-font-body); color: var(--cx-ink-text-dim); }
.book-ex__sum { margin: 1px 0 4px; font: italic 400 var(--book-small)/1.35 var(--cx-font-body); color: var(--cx-ink-text-dim); }
.book-parts { margin: 2px 0 0; padding: 0; list-style: none; }
.book-part {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 3px 4px 3px 26px;
  border-radius: 2px;
}
.book-part::before { content: ''; position: absolute; left: 7px; top: 0.66em; width: 7px; height: 7px; transform: rotate(45deg); background: var(--cx-ink-rubric); box-shadow: 0 0 0 1px rgba(255, 246, 225, 0.5); }
.book-part.r2::before { background: var(--cx-ink-lapis); }
.book-part.r4::before { background: var(--cx-con-red-ink); }
.book-part.r1::before { left: 3px; top: 0.36em; width: 0.92em; height: 0.92em; transform: none; box-shadow: none; background: var(--cx-orn-check) center / contain no-repeat; }
.book-part__n { flex: none; min-width: 3.4em; font-weight: 700; font-variant-numeric: lining-nums tabular-nums; }
.book-part__r { flex: 1 1 auto; min-width: 0; font: 700 var(--book-label)/1.2 var(--cx-font-label); letter-spacing: 0.04em; }
.book-part__x { flex: none; font-variant-numeric: lining-nums tabular-nums; color: var(--cx-ink-text-dim); }
.book-part.r1 .book-part__r { color: var(--cx-ink-text-dim); }
.book-part.r2 .book-part__r { color: var(--cx-ink-lapis); }
.book-part.r3 .book-part__r { color: var(--cx-ink-rubric); }
.book-part.r4 .book-part__r { color: var(--cx-con-red-ink); }
.book-part.is-click { cursor: pointer; }
.book-part.is-click:hover { background: rgba(120, 60, 20, 0.07); }
.book-part.is-click:hover .book-part__n { color: var(--cx-ink-rubric); text-decoration: underline; text-decoration-color: rgba(122, 29, 16, 0.4); text-underline-offset: 3px; }
.book-part.is-click:focus { outline: none; }
.book-part.is-click:focus-visible { box-shadow: inset 3px 0 0 var(--cx-ember), inset 0 0 0 1px rgba(226, 84, 31, 0.55); background: rgba(255, 150, 70, 0.10); }
.book-tag { display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid rgba(31, 58, 118, 0.4); border-radius: 2px; font: 700 13px/1.45 var(--cx-font-label); letter-spacing: 0.04em; color: var(--cx-ink-lapis); vertical-align: 2px; }
.book-tag--rubric { border-color: rgba(122, 29, 16, 0.45); color: var(--cx-ink-rubric); }

/* list rows from theme.css on the parchment (ink rows, oxblood selection), sized for reading */
.book-layer .book-flow .codex-list { margin: 2px 0 12px; }
.book-layer .book-flow .codex-row { min-height: 50px; padding: 6px 8px 6px 4px; break-inside: avoid; -webkit-column-break-inside: avoid; }
.book-layer .book-flow .codex-row__title { font-size: 21px; font-family: var(--cx-font-body); font-weight: 700; font-variant-numeric: lining-nums tabular-nums; }
.book-layer .book-flow .codex-row__meta { font-size: var(--book-small); line-height: 1.3; }
.book-layer .book-flow .codex-row__aside { font-size: var(--book-label); font-weight: 700; letter-spacing: 0.03em; }
.book-layer .book-flow .codex-row:focus { outline: none; }
.book-layer .book-flow .codex-row:focus-visible { outline: none; box-shadow: inset 3px 0 0 var(--cx-ember), inset 0 0 0 1px rgba(226, 84, 31, 0.55); background: rgba(255, 150, 70, 0.10); }

/* the Repeat list: one ledger line per entry — number, where it was met, when it was added */
.book-h3--rep { display: flex; align-items: baseline; gap: 8px; }
.book-h3--rep .book-note, .book-h3--ch .book-note, .book-h3--music .book-note { margin: 0; font-size: var(--book-small); }
.book-reps { margin: 0; padding: 0; list-style: none; }
.book-reps--more { margin-bottom: 12px; }
.book-rep {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 4px 6px 4px 26px;
  border-bottom: 1px dotted rgba(74, 53, 34, 0.24);
  border-radius: 2px;
  cursor: pointer;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
}
.book-rep::before { content: ''; position: absolute; left: 8px; top: 50%; width: 7px; height: 7px; margin-top: -4px; transform: rotate(45deg); background: var(--cx-ink-rubric); box-shadow: 0 0 0 1px rgba(255, 246, 225, 0.5); }
.book-rep.r2::before { background: var(--cx-ink-lapis); }
.book-rep.r4::before { background: var(--cx-con-red-ink); }
.book-rep__n { flex: none; min-width: 4.4em; font-weight: 700; font-size: 19px; font-variant-numeric: lining-nums tabular-nums; color: var(--cx-ink-text); white-space: nowrap; }
.book-rep__n .book-tag { font-weight: 700; }
.book-rep__z { flex: 1 1 auto; min-width: 0; color: var(--cx-ink-text-dim); font-size: var(--book-small); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-rep__p { flex: none; font: 700 var(--book-label)/1.2 var(--cx-font-label); letter-spacing: 0.03em; color: var(--cx-ink-gold); }
.book-rep__w { flex: none; min-width: 3.6em; text-align: right; font: italic 400 var(--book-small)/1.2 var(--cx-font-body); font-variant-numeric: lining-nums tabular-nums; color: var(--cx-ink-text-dim); }
.book-rep:hover { background: rgba(120, 60, 20, 0.07); }
.book-rep:hover .book-rep__n { color: var(--cx-ink-rubric); text-decoration: underline; text-decoration-color: rgba(122, 29, 16, 0.4); text-underline-offset: 3px; }
.book-rep:focus { outline: none; }
.book-rep:focus-visible { outline: none; box-shadow: inset 3px 0 0 var(--cx-ember), inset 0 0 0 1px rgba(226, 84, 31, 0.55); background: rgba(255, 150, 70, 0.10); }

/* the exercise ledger: textbook chapters with a thumb index */
.book-h3--ch { display: flex; align-items: baseline; gap: 8px; margin-top: 1.1em; padding-bottom: 3px; border-bottom: 1px solid rgba(122, 29, 16, 0.28); font-size: 22px; }
.book-thumbs { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 2px; margin: 0 0 10px; }
.book-thumbs__h { flex: 0 0 100%; margin: 0 0 2px; font: 700 var(--book-label)/1.2 var(--cx-font-label); letter-spacing: 0.04em; color: var(--cx-ink-rubric); }
.book-thumb {
  -webkit-appearance: none;
  appearance: none;
  min-width: 2.1em;
  margin: 0;
  padding: 2px 6px 1px;
  border: 1px solid rgba(74, 53, 34, 0.35);
  border-radius: 2px;
  background: rgba(255, 250, 236, 0.45);
  font: 700 17px/1.35 var(--cx-font-body);
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--cx-ink-text);
  cursor: pointer;
}
.book-thumbs--words .book-thumb { font: 700 var(--book-label)/1.5 var(--cx-font-label); letter-spacing: 0.03em; }
.book-thumb:hover { border-color: var(--cx-ink-rubric); color: var(--cx-ink-rubric); background: rgba(255, 250, 236, 0.85); }
.book-thumb:focus { outline: none; }
.book-thumb:focus-visible { border-color: var(--cx-ember); box-shadow: 0 0 0 1px var(--cx-ember), 0 0 8px rgba(226, 84, 31, 0.45); }
.book-parts--solo { margin: 0; padding: 2px 0; border-bottom: 1px dotted rgba(74, 53, 34, 0.24); break-inside: avoid; -webkit-column-break-inside: avoid; }
.book-part__w { flex: none; min-width: 3.6em; text-align: right; font: italic 400 var(--book-small)/1.2 var(--cx-font-body); font-variant-numeric: lining-nums tabular-nums; color: var(--cx-ink-text-dim); }
.book-parts > .book-part { break-inside: avoid; -webkit-column-break-inside: avoid; }

/* the oxblood flag: a part still on the Repeat list; "again": a repeat attempt */
.book-flag {
  display: inline-block;
  width: 10px;
  height: 16px;
  margin-left: 8px;
  vertical-align: -3px;
  background: linear-gradient(90deg, #6a1610, #a3301f 45%, #6a1610);
  -webkit-clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 74%, 0 100%);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 74%, 0 100%);
}
.book-note--key .book-flag { margin: 0 4px 0 0; }
.book-again { font: italic 400 var(--book-small)/1 var(--cx-font-body); letter-spacing: 0; color: var(--cx-ink-text-dim); }
.book-part__r .book-again { margin-left: 6px; }

/* a quiet text link on the parchment (oxblood capitals) */
.book-link {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  padding: 4px 2px;
  border: 0;
  background: none;
  font: 700 var(--book-label)/1.3 var(--cx-font-label);
  letter-spacing: 0.04em;
  color: var(--cx-ink-rubric);
  text-decoration: underline;
  text-decoration-color: rgba(122, 29, 16, 0.35);
  text-underline-offset: 4px;
  cursor: pointer;
}
.book-link:hover { color: var(--cx-ink-text); text-decoration-color: var(--cx-ink-rubric); }
.book-link:focus { outline: none; }
.book-link:focus-visible { outline: none; text-decoration-color: var(--cx-ember); text-decoration-thickness: 2px; box-shadow: 0 6px 10px -8px rgba(226, 84, 31, 0.9); }
.book-go { margin: -0.3em 0 0.8em; }

/* the tailpiece at the end of each chapter */
.book-colophon { margin: 22px 0 8px; text-align: center; break-inside: avoid; -webkit-column-break-inside: avoid; }
.book-colophon__orn { margin: 0 auto 10px; }
.book-colophon__t { margin: 0 0 4px; font: italic 400 var(--book-small)/1.4 var(--cx-font-body); color: var(--cx-ink-text-dim); }
.book-colophon__go { font-size: calc(var(--book-label) + 1px); }

/* zones & frames */
.book-zone { margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid rgba(80, 46, 14, 0.16); break-inside: avoid; -webkit-column-break-inside: avoid; }
.book-zone__head { display: flex; align-items: baseline; gap: 10px; }
.book-zone__name { flex: 1 1 auto; min-width: 0; font: 700 21px/1.2 var(--cx-font-head); letter-spacing: 0.02em; color: var(--cx-ink-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-zone.is-here .book-zone__name { color: var(--cx-ink-rubric); }
.book-zone.is-locked .book-zone__name { color: var(--cx-con-grey-ink); }
.book-zone__lv { flex: none; font-weight: 700; font-variant-numeric: lining-nums tabular-nums; }
.book-zone__meta { margin: 2px 0 0; color: var(--cx-ink-text-dim); font-size: var(--book-small); }
.book-zone__meta b { color: var(--cx-ink-text); font-weight: 500; font-variant-numeric: lining-nums tabular-nums; }
.book-frames { margin: 6px 0 0; padding: 0; list-style: none; font-size: var(--book-small); }
.book-frames > li { display: flex; align-items: baseline; gap: 8px; padding: 1px 0 1px 22px; position: relative; }
.book-frames > li::before { content: ''; position: absolute; left: 4px; top: 0.5em; width: 7px; height: 7px; transform: rotate(45deg); border: 1px solid rgba(74, 53, 34, 0.55); }
.book-frames > li.is-visited::before { background: rgba(122, 29, 16, 0.75); border-color: rgba(74, 20, 10, 0.9); }
.book-frames > li.is-here { color: var(--cx-ink-rubric); font-weight: 700; }
.book-frames--more { margin-top: 0; }
.book-frames > li { break-inside: avoid; -webkit-column-break-inside: avoid; }
.book-frames__n { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-frames__q { flex: none; font-variant-numeric: lining-nums tabular-nums; color: var(--cx-ink-text-dim); }
.book-frames > li.is-done .book-frames__q { color: var(--cx-con-green-ink); font-weight: 700; }
.book-seal { display: inline-block; width: 26px; height: 26px; margin-left: 6px; vertical-align: -7px; background: var(--cx-orn-seal-gold) center / contain no-repeat; }
.book-seal--lapis { background-image: var(--cx-orn-seal-lapis); }

/* table of contents on a chapter's opening page */
.book-toc { margin: 4px 0 14px; padding: 10px 0 4px; border-top: 1px solid rgba(122, 29, 16, 0.22); border-bottom: 1px solid rgba(122, 29, 16, 0.22); break-inside: avoid; -webkit-column-break-inside: avoid; }
.book-toc__h { display: block; margin-bottom: 4px; font: 700 var(--book-label)/1.2 var(--cx-font-label); letter-spacing: 0.05em; color: var(--cx-ink-rubric); }
.book-toc .book-ledger { margin: 0; }
.book-toc__row { cursor: pointer; border-radius: 2px; }
.book-toc__row:hover .book-ledger__k, .book-toc__row:focus-visible .book-ledger__k { color: var(--cx-ink-rubric); text-decoration: underline; text-decoration-color: rgba(122, 29, 16, 0.4); text-underline-offset: 3px; }
.book-toc__row:focus { outline: none; }
.book-toc__row:focus-visible { outline: none; box-shadow: inset 3px 0 0 var(--cx-ember); background: rgba(255, 150, 70, 0.10); }
.book-toc__p { font: italic 400 var(--book-small)/1 var(--cx-font-body); color: var(--cx-ink-text-dim); }

/* zone lines: the zone in small capitals with a count, the details under it */
.book-zl { margin: 2px 0 10px; padding: 0; list-style: none; }
.book-zl > li { padding: 5px 0 7px; border-bottom: 1px dotted rgba(74, 53, 34, 0.24); break-inside: avoid; -webkit-column-break-inside: avoid; }
.book-zl__top { display: flex; align-items: baseline; gap: 10px; }
.book-zl__z { flex: 1 1 auto; min-width: 0; font: 700 18px/1.25 var(--cx-font-head); letter-spacing: 0.02em; color: var(--cx-ink-text); }
.book-zl__c { flex: none; font: italic 400 var(--book-small)/1 var(--cx-font-body); font-variant-numeric: lining-nums tabular-nums; color: var(--cx-ink-text-dim); }
.book-zl__d { margin-top: 1px; line-height: 1.45; }
.book-zl__d b { font-weight: 500; color: var(--cx-ink-text); }
.book-dim { color: var(--cx-ink-text-dim); opacity: 0.85; }

/* items & achievements */
.book-items { margin: 2px 0 12px; padding: 0; list-style: none; }
.book-items > li { display: flex; align-items: baseline; gap: 10px; padding: 3px 0; border-bottom: 1px dotted rgba(74, 53, 34, 0.22); break-inside: avoid; -webkit-column-break-inside: avoid; }
.book-items__slot { flex: none; width: 6.2em; font: 700 var(--book-label)/1.2 var(--cx-font-label); letter-spacing: 0.03em; color: var(--cx-ink-text-dim); }
.book-items__n { flex: 1 1 auto; min-width: 0; font-weight: 500; line-height: 1.3; }
.book-items__m { flex: none; color: var(--cx-ink-text-dim); font-size: var(--book-small); font-variant-numeric: lining-nums tabular-nums; }
.book-layer .q-ink-poor { color: var(--cx-q-poor-ink); }
.book-layer .q-ink-common { color: var(--cx-q-common-ink); }
.book-layer .q-ink-uncommon { color: var(--cx-q-uncommon-ink); }
.book-layer .q-ink-rare { color: var(--cx-q-rare-ink); }
.book-layer .q-ink-epic { color: var(--cx-q-epic-ink); }
.book-layer .q-ink-legendary { color: var(--cx-q-legendary-ink); }
.book-layer .con-ink-grey { color: var(--cx-con-grey-ink); }
.book-layer .con-ink-green { color: var(--cx-con-green-ink); }
.book-layer .con-ink-yellow { color: var(--cx-con-yellow-ink); }
.book-layer .con-ink-orange { color: var(--cx-con-orange-ink); }
.book-layer .con-ink-red { color: var(--cx-con-red-ink); }

.book-ach { margin: 0 0 4px; padding: 0; list-style: none; }
.book-ach > li { position: relative; padding: 5px 0 6px 30px; border-bottom: 1px dotted rgba(74, 53, 34, 0.2); break-inside: avoid; -webkit-column-break-inside: avoid; }
.book-ach > li::before { content: ''; position: absolute; left: 2px; top: 9px; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid rgba(74, 53, 34, 0.35); }
.book-ach > li.is-earned::before { border: 0; width: 22px; height: 22px; left: 0; top: 7px; background: var(--cx-orn-seal-gold) center / contain no-repeat; }
.book-ach__top { display: flex; align-items: baseline; gap: 10px; }
.book-ach__n { flex: 1 1 auto; min-width: 0; font-weight: 700; }
.book-ach__p { flex: none; font-variant-numeric: lining-nums tabular-nums; color: var(--cx-ink-gold); font-weight: 700; }
.book-ach__d { display: block; color: var(--cx-ink-text-dim); font-size: var(--book-small); line-height: 1.35; }
.book-ach > li:not(.is-earned) .book-ach__n { color: var(--cx-ink-text-dim); font-weight: 500; }

/* runs (dungeons) */
.book-run { margin: 0 0 10px; padding: 0 0 8px; border-bottom: 1px solid rgba(80, 46, 14, 0.16); break-inside: avoid; -webkit-column-break-inside: avoid; }
.book-run__top { display: flex; align-items: baseline; gap: 10px; }
.book-run__n { flex: 1 1 auto; min-width: 0; font: 700 19px/1.2 var(--cx-font-head); letter-spacing: 0.02em; }
.book-run__b { flex: none; font: 700 var(--book-label)/1.2 var(--cx-font-label); letter-spacing: 0.04em; color: var(--cx-ink-rubric); }
.book-run__m { color: var(--cx-ink-text-dim); font-size: var(--book-small); }
.book-run__m small, .book-zl__d small, .book-flow p small { font-size: 15px; color: var(--cx-ink-text-dim); }
.book-layer.is-single .book-run__m small, .book-layer.is-single .book-zl__d small, .book-layer.is-single .book-flow p small { font-size: 13px; }

/* music */
.book-tracks { margin: 0 0 10px; padding: 0; list-style: none; }
.book-tracks > li { position: relative; padding: 2px 0 2px 24px; break-inside: avoid; }
.book-tracks > li::before { content: '\266A\FE0E'; position: absolute; left: 2px; top: 2px; color: var(--cx-ink-rubric-lg); font: 400 0.95em/1.6 var(--cx-font-body); }

.book-tracks > li.is-playing { color: var(--cx-ink-rubric); font-weight: 700; }
.book-tracks > li.is-off { color: var(--cx-ink-text-dim); }
.book-keep > .book-tracks { margin-bottom: 0; }
.book-tracks--more { margin-bottom: 10px; }
.book-h3--music { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 8px; }
.book-credit__links a { font-weight: 700; }
.book-credit { margin: 6px 0 14px; padding: 14px 16px 12px; border: 1px solid rgba(122, 29, 16, 0.3); box-shadow: inset 0 0 0 3px rgba(255, 250, 236, 0.4), inset 0 0 0 4px rgba(122, 29, 16, 0.18); break-inside: avoid; -webkit-column-break-inside: avoid; }
.book-credit p { margin: 0 0 0.4em; }

/* keyboard hint at the end of a chapter */
.book-keys { margin: 14px 0 6px; font: italic 400 var(--book-small)/1.5 var(--cx-font-body); color: var(--cx-ink-text-dim); break-inside: avoid; }
.book-layer .book-keys .codex-kbd { font-style: normal; }
.book-k { display: inline-block; min-width: 1.6em; padding: 0 5px; margin: 0 2px; border: 1px solid rgba(74, 53, 34, 0.45); border-bottom-width: 2px; border-radius: 3px; font: 700 14px/1.45 var(--cx-font-label); text-align: center; font-style: normal; color: var(--cx-ink-text); background: rgba(255, 250, 236, 0.5); }

.book-end { display: block; height: 0; overflow: hidden; }
.book-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.book-coin { white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; }
.book-coin small { margin-left: 1px; font: 700 0.78em/1 var(--cx-font-label); }
.book-coin--g small { color: #7d5719; }
.book-coin--s small { color: #5a5a5a; }
.book-coin--c small { color: #7a3a14; }

/* ------------------------------------------------------------------------------------------ SINGLE PAGE (compact) */
.book-layer.is-single {
  --book-band: 8px;
  --book-head: 50px;
  --book-foot: 36px;
  --book-outer: 22px;
  --book-inner: 22px;
  --book-fs: 16px;
  --book-lh: 1.5;
  --book-fig: 28px;
  --book-h2: 22px;
  --book-h3: 18px;
  --book-label: 13px;
  --book-small: 14px;
  padding: 6px;
}
.book-layer.is-single .book { width: 100%; max-width: 940px; height: 100%; margin: 0; }   /* a wide window keeps a readable line */
.book-layer.is-single .book-spine,
.book-layer.is-single .book-page--r,
.book-layer.is-single .codex-clasp { display: none; }
.book-layer.is-single .book-page--l { width: 100%; border-radius: 2px; }
.book-layer.is-single .book-page::after { display: none; }
.book-layer.is-single .book-page--l::before { left: calc(var(--book-outer) - 10px); right: calc(var(--book-outer) - 10px); top: calc(var(--book-head) - 6px); bottom: calc(var(--book-foot) - 6px); }
.book-layer.is-single .book-cover.codex-frame::before { background: var(--cx-caps); top: 1px; right: 1px; bottom: 1px; left: 1px; }
.book-layer.is-single .book-block { box-shadow: 0 2px 0 #a88a58, 0 3px 6px rgba(0, 0, 0, 0.5); }
.book-layer.is-single .book-runhead { justify-content: flex-start; height: calc(var(--book-head) - 6px); padding: 4px 250px 0 18px; font-size: 14px; letter-spacing: 0.1em; }
.book-layer.is-single .book-runhead .cx-fleuron, .book-layer.is-single .book-runhead i { display: none; }
.book-layer.is-single .book-folio { height: calc(var(--book-foot) - 4px); font-size: 14px; }
.book-layer.is-single .book-corner { width: 44px; height: 44px; }
.book-layer.is-single .book-corner::before { width: 30px; height: 30px; }
.book-layer.is-single .book-corner--prev::after { left: 6px; }
.book-layer.is-single .book-corner--next::after { right: 6px; }
/* the smallest page (480×360 beside a PDF): the chapter's banderole is enough, the lead paragraph and its initial step aside */
.book-layer.is-single:not(.is-roomy) .book-lead { display: none; }
.book-layer.is-single .book-close { top: 4px; right: 4px; width: 26px; height: 26px; }
/* the straps hang down over the head of the page, initials only, iron tips at the foot */
.book-layer.is-single .book-marks {
  top: calc(var(--book-band) - 2px);
  left: auto;
  right: 40px;
  margin: 0;
  z-index: 5;
  flex-direction: row;
  gap: 3px;
}
.book-layer.is-single .book-mark {
  flex-direction: column;
  justify-content: flex-start;
  width: 24px;
  height: 36px;
  padding: 7px 0 0;
  background:
    /* the iron tip at the foot of the strap */
    radial-gradient(circle at 50% calc(100% - 11px), #f0c47a 0 1px, #b07a3c 1.4px, #4a311a 2.4px, rgba(0, 0, 0, 0) 3px),
    linear-gradient(90deg, #5a6068 0%, #33373d 38%, #1a1c20 72%, #0b0c0e 100%) left 0 bottom 0 / 100% 16px no-repeat,
    linear-gradient(#000, #000) left 0 bottom 15px / 100% 1px no-repeat,
    repeating-linear-gradient(180deg, rgba(222, 200, 160, 0.32) 0 4px, rgba(0, 0, 0, 0) 4px 7px) left 3px top 0 / 1px calc(100% - 17px) no-repeat,
    repeating-linear-gradient(180deg, rgba(222, 200, 160, 0.32) 0 4px, rgba(0, 0, 0, 0) 4px 7px) right 3px top 0 / 1px calc(100% - 17px) no-repeat,
    var(--cx-tex-grain),
    var(--_lea);
  -webkit-clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), 50% 100%, 0 calc(100% - 8px));
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), 50% 100%, 0 calc(100% - 8px));
  transform: none;
  transition: transform var(--cx-dur-calm) var(--cx-ease);
}
.book-layer.is-single .book-mark::after {
  background:
    linear-gradient(90deg, rgba(255, 170, 90, 0.55), rgba(255, 170, 90, 0) 2px),
    radial-gradient(ellipse 140% 70% at 50% 0%, rgba(255, 120, 40, 0.5), rgba(255, 120, 40, 0) 100%);
}
.book-layer.is-single .book-mark:hover { transform: translateY(3px); }
.book-layer.is-single .book-mark.is-active { transform: translateY(8px); }
.book-layer.is-single .book-mark__i { width: auto; font: 900 13px/1 var(--cx-font-initial); letter-spacing: 0; }
.book-layer.is-single .book-mark__rn { display: none; }
.book-layer.is-single .book-mark__in { display: inline; }
.book-layer.is-single .book-mark__t { display: none; }
.book-layer.is-single .book-opener { margin-bottom: 10px; }
.book-layer.is-single .book-opener__no { margin-bottom: 4px; font-size: 12px; }
.book-layer.is-single .book-opener__t { font-size: 25px; }
.book-layer.is-single .book-opener__orn { height: 14px; margin-top: 6px; background-size: 100% 14px; }
.book-layer.is-single .book-lead { --cx-dropcap: 66px; }
.book-layer.is-single .book-ex__name { font-size: 18px; }
.book-layer.is-single .book-zone__name { font-size: 19px; }
.book-layer.is-single .book-run__n { font-size: 18px; }
.book-layer.is-single .book-flow .codex-row__title { font-size: 18px; }
.book-layer.is-single .book-flow .codex-row { min-height: 42px; }
.book-layer.is-single .book-fig { padding: 6px 8px 8px; }
.book-layer.is-single .book-filters .codex-tab { font-size: 13px; padding: 7px 9px 6px; }
.book-layer.is-single .book-filters .codex-tab.is-active { padding-top: 9px; }
/* a single page is short: long blocks may run on to the next page (their headings travel with the first rows) */
.book-layer.is-single .book-zone,
.book-layer.is-single .book-ex { break-inside: auto; -webkit-column-break-inside: auto; }
.book-layer.is-single .book-ex__head, .book-layer.is-single .book-ex__sum { break-after: avoid; -webkit-column-break-after: avoid; }
.book-layer.is-single .book-rep__n { font-size: 17px; }
.book-layer.is-single .book-h3--ch { font-size: 19px; }
.book-layer.is-single .book-thumb { font-size: 15px; }
/* mid-size single page (a narrow but tall window): a little more room */
.book-layer.is-single.is-roomy {
  --book-head: 58px;
  --book-foot: 44px;
  --book-outer: 34px;
  --book-fs: 17px;
  --book-fig: 32px;
  --book-h2: 24px;
  --book-label: 14px;
  --book-small: 15px;
  padding: 14px;
}
.book-layer.is-single.is-roomy .book-runhead { padding-left: 28px; }
/* a roomy single page keeps real boards: a wider leather band and thorned corner guards */
.book-layer.is-single.is-roomy { --book-band: 16px; }
.book-layer.is-single.is-roomy .book-cover.codex-frame::before {
  top: -7px; right: -7px; bottom: -7px; left: -7px;
  background:
    var(--cx-orn-corner-tl) left top / 56px 56px no-repeat,
    var(--cx-orn-corner-tr) right top / 56px 56px no-repeat,
    var(--cx-orn-corner-bl) left bottom / 56px 56px no-repeat,
    var(--cx-orn-corner-br) right bottom / 56px 56px no-repeat;
}
.book-layer.is-single.is-roomy .book-marks { right: 56px; }
.book-layer.is-single.is-roomy .book-runhead { padding-right: 256px; }
.book-layer.is-single.is-roomy .book-close { top: 8px; right: 8px; width: 30px; height: 30px; }

/* ------------------------------------------------------------------------------------------ motion off */
@media (prefers-reduced-motion: reduce) {
  .book-layer, .book, .book-flow, .book-mark, .book-corner::before { transition: none !important; }
}
body.reduced-motion .book-layer, body.reduced-motion .book, body.reduced-motion .book-flow,
body.reduced-motion .book-mark, body.reduced-motion .book-corner::before { transition: none !important; }
