:root {
  --paper: #f3e9d6;
  --paper-deep: #e6d8bd;
  --ink: #2b2118;
  --ink-soft: #5d4b39;
  --ink-faint: #8f7a61;
  --rule: rgba(92, 70, 45, 0.22);
  --gilt: #c9a35f;
  --gilt-bright: #ecd29b;
  --cream: #efe4cf;
  --cream-dim: rgba(239, 228, 207, 0.62);
  --cream-faint: rgba(239, 228, 207, 0.28);

  /* Desk colour drifts with the era; app.js updates these. */
  --desk-h: 30;
  --desk-s: 30%;

  --serif: "EB Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --display: "Cormorant Garamond", "EB Garamond", Garamond, Georgia, serif;
  --fell: "IM Fell English", "EB Garamond", Georgia, serif;

  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .36 0 0 0 0 .26 0 0 0 0 .13 0 0 0 .11 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }

.timeline, .book { -webkit-user-select: none; user-select: none; }
.entry-body { -webkit-user-select: text; user-select: text; }

body {
  margin: 0;
  background: #17120e;
  color: var(--cream);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font: inherit; color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ───────────────────────── Desk & masthead ───────────────────────── */

.desk {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(16px, env(safe-area-inset-left, 0px));
  background:
    radial-gradient(ellipse 80% 70% at 50% 42%, hsl(var(--desk-h) var(--desk-s) 19%) 0%, hsl(var(--desk-h) var(--desk-s) 10%) 62%, hsl(var(--desk-h) 20% 6%) 100%);
}

@property --desk-h { syntax: "<number>"; inherits: true; initial-value: 30; }
@property --desk-s { syntax: "<percentage>"; inherits: true; initial-value: 30%; }
html { transition: --desk-h 1.4s ease, --desk-s 1.4s ease; }

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ───────────────────────── Running head (printed on the book) ───────────────────────── */

.book-head {
  position: absolute;
  inset: 0 0 auto;
  height: var(--head);
  z-index: 5000; /* above turning leaves */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding-inline: 4.6cqi;
  pointer-events: none;
  color: var(--ink);
}
.book-head > * { pointer-events: auto; }

.wordmark,
.running-head {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(13px, 1.25cqi, 19px);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.4s;
}
.wordmark { justify-self: start; }
.wordmark em { font-style: italic; font-weight: 500; color: #8a5a28; text-transform: none; letter-spacing: 0.04em; font-size: 1.12em; }
.wordmark:hover { color: var(--ink); }
.wordmark:focus-visible { outline: 2px solid var(--gilt); outline-offset: 4px; border-radius: 4px; }
.running-head { justify-self: end; font-weight: 500; font-style: italic; text-transform: none; letter-spacing: 0.04em; font-size: clamp(13px, 1.3cqi, 19px); }

.yearnav {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.4cqi, 22px);
}

.turn {
  width: clamp(32px, 3cqi, 44px);
  height: clamp(32px, 3cqi, 44px);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px rgba(92, 70, 45, 0.35), 0 1px 3px rgba(40, 25, 10, 0.18);
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, opacity 0.2s, transform 0.2s;
}
.turn svg { width: 46%; height: 46%; fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.turn:hover { background: #fbf4e6; box-shadow: inset 0 0 0 1px rgba(92, 70, 45, 0.6), 0 2px 6px rgba(40, 25, 10, 0.25); }
.turn:active { transform: scale(0.94); }
.turn:focus-visible { outline: 2px solid var(--gilt); outline-offset: 2px; }
.turn:disabled { opacity: 0; pointer-events: none; }

.year-wrap {
  position: relative;
  padding: 0.1em 0.5em;
  border-radius: 999px;
  background: radial-gradient(closest-side, rgba(243, 233, 214, 0.85) 55%, transparent);
}

.year {
  display: flex;
  align-items: baseline;
  gap: 0.28em;
  min-width: 5.6ch;
  justify-content: center;
  border: 0;
  background: none;
  padding: 0 6px;
  cursor: text;
  font-family: var(--display);
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
  border-radius: 8px;
  transition: color 0.3s, text-shadow 0.3s;
}
.year:hover .year-num { color: #6b4520; }
.year:focus-visible { outline: 2px solid var(--gilt); outline-offset: 4px; }
.year-num {
  font-size: clamp(28px, 3.6cqi, 54px);
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: 0.01em;
}
.year-era {
  font-size: clamp(11px, 1.15cqi, 17px);
  letter-spacing: 0.18em;
  color: #9a6b33;
}

/* On the title page the endpaper is dark and the title says it all. */
.book.is-cover .wordmark,
.book.is-cover .running-head,
.book.is-cover .year-num,
.book.is-cover .year-era { opacity: 0; }
.book.is-cover .year-wrap { background: none; }

/* While travelling the pages dissolve, so the counter glows on its own. */
.is-travelling .wordmark,
.is-travelling .running-head { opacity: 0; }
.is-travelling .year-wrap { background: none; }
.is-travelling .year { color: var(--gilt-bright); text-shadow: 0 0 18px rgba(236, 210, 155, 0.55), 0 1px 2px rgba(0, 0, 0, 0.6); }
.is-travelling .year-era { color: var(--gilt-bright); }

.year-form {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  margin: 0;
  padding: 10px 12px 8px;
  text-align: center;
  background: var(--paper);
  background-image: var(--noise);
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4), inset 0 0 0 1px var(--gilt);
}
.year-form input {
  width: 9ch;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(24px, 3cqi, 40px);
  text-align: center;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 2px 4px;
  outline: none;
}
.year-form input::placeholder { color: var(--ink-faint); font-weight: 500; }
.year-form.is-invalid { animation: shake 0.35s; box-shadow: 0 14px 34px rgba(0,0,0,.4), inset 0 0 0 2px #b4553f; }
.year-hint {
  margin: 6px 0 0;
  font-size: 0.82rem;
  white-space: nowrap;
  color: var(--ink-soft);
}
@keyframes shake {
  20%, 60% { transform: translateX(calc(-50% - 6px)); }
  40%, 80% { transform: translateX(calc(-50% + 6px)); }
}

/* Original-tongue chip, tooltip and the ink write-out */
.tongue-chip {
  display: inline-flex;
  align-items: stretch;
  margin-left: 0.7em;
  padding: 2px;
  border: 0;
  border-radius: 999px;
  background: rgba(201, 163, 95, 0.12);
  box-shadow: inset 0 0 0 1px rgba(201, 163, 95, 0.55);
  color: #7c4f22;
  font-family: var(--serif);
  font-size: 0.92em;
  letter-spacing: 0;
  text-transform: none;
  vertical-align: 0.1em;
  cursor: pointer;
}
.tongue-seg {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  max-width: 14em;
  padding: 0.02em 0.6em 0.08em;
  border-radius: 999px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-style: italic;
  opacity: 0.7;
  transition: background 0.25s, color 0.25s, opacity 0.25s;
}
.tongue-seg.is-on {
  background: #7c4f22;
  color: var(--paper);
  font-style: normal;
  opacity: 1;
}
.tongue-chip:hover .tongue-seg:not(.is-on) { opacity: 1; background: rgba(201, 163, 95, 0.22); }
.tongue-chip:focus-visible { outline: 2px solid var(--gilt); outline-offset: 2px; }
.tongue-seg svg { flex: none; width: 0.95em; height: 0.95em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.entry-body.has-era { cursor: pointer; }
.entry-body.has-era:hover .entry-text { color: #1f170f; }

.tongue-tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9000;
  padding: 5px 11px 6px;
  border-radius: 8px;
  background: rgba(33, 25, 17, 0.94);
  color: var(--cream);
  font-family: var(--serif);
  font-size: 0.9rem;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.18s;
}
.tongue-tip.is-on { opacity: 1; }
.tongue-tip.is-muted { color: var(--cream-dim); font-style: italic; }
.tongue-tip strong { font-weight: 500; color: var(--gilt-bright); }

.entry-body.is-blotting { animation: blot 0.22s ease-in forwards; }
@keyframes blot { to { opacity: 0; filter: blur(2px); transform: translateY(-0.15em); } }

.ink {
  animation: ink 0.6s ease-out both;
  animation-delay: calc(var(--i) * var(--step, 12ms));
}
@keyframes ink {
  0% { opacity: 0; color: #a8783e; text-shadow: 0 0 0.35em rgba(168, 120, 62, 0.55); }
  35% { opacity: 1; color: #8a5a28; text-shadow: 0 0 0.2em rgba(168, 120, 62, 0.35); }
  100% { opacity: 1; }
}

/* ───────────────────────── Book ───────────────────────── */

.book-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  container-type: size;
  padding-block: max(14px, 2vh) 8px;
}

.book {
  --ratio: 1.62;
  --head: clamp(52px, 6.4cqi, 96px);
  position: relative;
  width: min(100cqw, 100cqh * var(--ratio), 1640px);
  aspect-ratio: var(--ratio);
  container-type: inline-size;
  touch-action: pan-y;
}

/* stacked page edges below the spread */
.book::before {
  content: "";
  position: absolute;
  inset: 6px -6px -8px;
  border-radius: 6px;
  background:
    repeating-linear-gradient(0deg, #d8c8a8 0 1px, #efe3cb 1px 3px);
  z-index: -1;
}

.spread {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  box-shadow: 0 24px 44px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.35);
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.leaves {
  position: absolute;
  inset: 0;
  perspective: 2600px;
  pointer-events: none;
}

.whirl {
  position: absolute;
  inset: -12%;
  width: 124%;
  height: 124%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.whirl.is-on { opacity: 1; }

/* Pages */
.page {
  position: relative;
  height: 100%;
  overflow: hidden;
  color: var(--ink);
  background-color: var(--paper);
  background-image: var(--noise);
  font-size: clamp(13px, 1.5cqi, 19px);
}
.page::after { /* gutter shading */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.page--verso { border-radius: 6px 0 0 6px; }
.page--verso::after {
  background:
    linear-gradient(to left, rgba(60, 40, 20, 0.28), rgba(60, 40, 20, 0.08) 4%, transparent 12%),
    linear-gradient(to right, rgba(255, 255, 255, 0.18), transparent 3%);
}
.page--recto { border-radius: 0 6px 6px 0; }
.page--recto::after {
  background:
    linear-gradient(to right, rgba(60, 40, 20, 0.3), rgba(60, 40, 20, 0.08) 4%, transparent 12%),
    linear-gradient(to left, rgba(0, 0, 0, 0.06), transparent 3%);
}

.page-inner {
  position: absolute;
  inset: 0;
  padding: calc(var(--head) + 1.2cqi) 9% 9% 10%;
  display: flex;
  flex-direction: column;
}
.page--verso .page-inner { padding: calc(var(--head) + 1.2cqi) 10% 9% 9%; }

.folio {
  position: absolute;
  bottom: 3.4%;
  font-family: var(--display);
  font-size: 0.82em;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  font-variant-numeric: oldstyle-nums;
}
.page--verso .folio { left: 9%; }
.page--recto .folio { right: 9%; }
.page--single .folio { display: none; }

/* Plate (left page) */
.plate {
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9em;
  min-height: 0;
}
.plate-frame {
  position: relative;
  width: min(100%, 100cqi * 0.36);
  aspect-ratio: 1;
  padding: 2.4%;
  background: #fbf6ea;
  box-shadow: 0 1px 2px rgba(60, 40, 20, 0.25), 0 6px 18px rgba(60, 40, 20, 0.18);
  transform: rotate(var(--tilt, 0deg));
}
.plate-img {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #cdbb98 center / cover no-repeat;
  background-image: var(--thumb, none);
}
.plate-img img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.45s ease;
}
.plate-img img.is-loaded { opacity: 1; }
.plate-img.is-blank {
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(45deg, #e9dcc1 0 6px, #e2d3b5 6px 12px);
  color: var(--ink-faint);
  font-style: italic;
  text-align: center;
  padding: 10%;
}
.plate figcaption {
  font-family: var(--display);
  font-size: 0.95em;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* Entry (right page) */
.entry-head { margin-bottom: 1.1em; }
.entry-year {
  margin: 0 0 0.3em;
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.86em;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #9a6b33;
}
.entry-who {
  margin: 0;
  font-family: var(--fell);
  font-weight: 400;
  font-size: 1.55em;
  line-height: 1.15;
  text-wrap: balance;
}
.entry-place {
  margin: 0.35em 0 0;
  font-style: italic;
  color: var(--ink-soft);
}
.entry-head::after {
  content: "";
  display: block;
  width: 3.2em;
  height: 1px;
  margin-top: 0.9em;
  background: var(--gilt);
}

.entry-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
  overscroll-behavior: contain;
  margin-right: -0.6em;
  padding-right: 0.6em;
}
.entry-text p {
  margin: 0 0 0.8em;
  line-height: 1.56;
  hyphens: auto;
  text-wrap: pretty;
}
.entry-text p:first-child::first-letter {
  font-family: var(--fell);
  float: left;
  font-size: 3.15em;
  line-height: 0.82;
  padding: 0.06em 0.08em 0 0;
  color: #7c4f22;
}
.entry-text[dir="rtl"] p:first-child::first-letter,
.entry-text.no-initial p:first-child::first-letter {
  float: none; font-size: inherit; padding: 0; color: inherit; font-family: inherit;
}
.entry-text[dir="rtl"] p { text-align: right; line-height: 1.8; }
.entry-text.is-cjk p { line-height: 1.9; letter-spacing: 0.04em; hyphens: none; }

.entry-body.is-fresh { animation: inkIn 0.5s ease both; }
@keyframes inkIn { from { opacity: 0; filter: blur(2px); } to { opacity: 1; filter: none; } }

.pending-line {
  height: 0.62em;
  margin: 0.95em 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--paper-deep), #ede2cb, var(--paper-deep));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* Original-tongue blocks */
.tongue-label {
  margin: -0.4em 0 0.9em;
  font-size: 0.86em;
  color: var(--ink-faint);
  font-style: italic;
}
.tongue-label strong { font-style: normal; font-weight: 500; color: var(--ink-soft); }
.tongue-note {
  margin: 0 0 1em;
  padding: 0.7em 0.9em;
  font-size: 0.9em;
  line-height: 1.5;
  color: var(--ink-soft);
  background: rgba(201, 163, 95, 0.12);
  border-left: 2px solid var(--gilt);
}
.glimpse { margin: 0 0 1.1em; display: grid; gap: 0.75em; }
.glimpse-line { display: grid; gap: 0.1em; }
.glimpse-text { font-size: 2.1em; line-height: 1.2; color: #3d2a17; }
.glimpse-translit { font-style: italic; color: var(--ink-soft); }
.glimpse-gloss { font-size: 0.92em; color: var(--ink-faint); }
.modern-divider {
  display: flex;
  align-items: center;
  gap: 0.8em;
  margin: 0.2em 0 0.9em;
  font-family: var(--display);
  font-size: 0.8em;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.modern-divider::before, .modern-divider::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

/* Page corners and outer edges: click to turn, or drag to turn by hand */
.corner,
.edge {
  position: absolute;
  z-index: 3;
  touch-action: none;
  cursor: grab;
}
.edge {
  top: 0;
  bottom: 0;
  width: 3.2%;
  min-width: 14px;
}
.edge[data-turn="next"] { right: 0; }
.edge[data-turn="prev"] { left: 0; }
.corner {
  bottom: 0;
  width: 13%;
  aspect-ratio: 1;
  max-width: 76px;
  border: 0;
  padding: 0;
  background: transparent;
}
.corner::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
}
.corner[data-turn="next"] { right: 0; }
.corner[data-turn="next"]::before {
  background: linear-gradient(315deg, transparent 50%, #e2d2b3 50%, #f7efdf 62%, rgba(0,0,0,0.12) 64%, transparent 72%);
  transform-origin: 100% 100%;
  transform: scale(0.5);
}
.corner[data-turn="prev"] { left: 0; }
.corner[data-turn="prev"]::before {
  background: linear-gradient(45deg, transparent 50%, #e2d2b3 50%, #f7efdf 62%, rgba(0,0,0,0.12) 64%, transparent 72%);
  transform-origin: 0 100%;
  transform: scale(0.5);
}
/* Touch has no hover, and single pages can't peek backwards: those keep the drawn hint.
   Mouse hovers lift the real page instead (see startCurl's peek). */
@media (hover: none) {
  .corner:active::before { opacity: 1; transform: scale(1); }
}
.is-single .corner[data-turn="prev"]:hover::before { opacity: 1; transform: scale(1); }
.corner:focus-visible { outline: none; }
.is-turning, .is-turning * { cursor: grabbing !important; }
.is-turning .corner::before { opacity: 0 !important; transition: none; }
.leaves .corner, .leaves .edge { display: none; }
.page--single .corner { max-width: 64px; width: 16%; }

/* Front cover: gilt on oxblood leather */
.page--cover {
  --leather: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='l'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.12 0 0 0 0 0.04 0 0 0 0 0.02 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23l)'/%3E%3C/svg%3E");
  cursor: pointer;
  color: #e7c987;
  border-radius: 4px 10px 10px 4px;
  background-color: #5b2419;
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.5), rgba(255, 220, 180, 0.08) 2.2%, rgba(0, 0, 0, 0.15) 4%, transparent 7%),
    radial-gradient(ellipse 90% 75% at 55% 40%, rgba(255, 190, 140, 0.12), rgba(0, 0, 0, 0.42) 100%),
    var(--leather);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 0 26px rgba(0, 0, 0, 0.45);
}
.page--cover::after { display: none; }
.cover-frame {
  position: absolute;
  inset: 7% 8% 7% 11%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px solid rgba(231, 201, 135, 0.7);
  outline: 1px solid rgba(231, 201, 135, 0.35);
  outline-offset: 5px;
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.5), 0 1px 0 rgba(255, 230, 170, 0.12);
}
.cover-corner {
  position: absolute;
  font-size: 1.3em;
  color: #d7b56d;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}
.cover-corner--tl { top: 6px; left: 8px; transform: rotate(180deg) scaleX(-1); }
.cover-corner--tr { top: 6px; right: 8px; transform: rotate(180deg); }
.cover-corner--bl { bottom: 6px; left: 8px; transform: scaleX(-1); }
.cover-corner--br { bottom: 6px; right: 8px; }
/* Gold leaf: a metallic gradient clipped to the letters, with a pressed-in edge. */
.cover-title, .cover-dates, .cover-rule, .cover-sub, .cover-open {
  background: linear-gradient(175deg, #f6e2a8 0%, #c9993f 45%, #f0d48d 62%, #a87a31 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.55)) drop-shadow(0 -0.5px 0 rgba(255, 235, 190, 0.25));
}
.cover-dates {
  margin: 0 0 1.6em;
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.9em;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}
.cover-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 3.6em;
  line-height: 0.95;
  letter-spacing: 0.03em;
}
.cover-title span, .cover-title em { display: block; }
.cover-title em { font-weight: 500; font-size: 0.92em; }
.cover-rule { margin: 0.9em 0 0.8em; font-size: 1.4em; letter-spacing: 0.3em; }
.cover-sub {
  margin: 0 auto;
  max-width: 17em;
  font-family: var(--fell);
  font-style: italic;
  font-size: 1.05em;
  line-height: 1.45;
}
.cover-open {
  position: absolute;
  bottom: 9%;
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.8em;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  animation: coverHint 2.6s ease-in-out infinite;
}
@keyframes coverHint { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.page--cover:hover .cover-open { animation-duration: 1.2s; }
.page--void { background: none; box-shadow: none; }
.page--void::after { display: none; }

/* The closed book sits centred on the desk; opening slides it over as the cover swings. */
.book {
  transition: transform 1.25s cubic-bezier(.55, .05, .2, 1);
}
.book.is-closed { transform: translateX(-25%); }
.is-single .book.is-closed { transform: none; }
.spread { transition: box-shadow 0.5s ease 0.75s; }
.book.is-closed .spread { box-shadow: none; transition: none; }
.book.is-closed .slot:last-child .page--cover,
.is-single .book.is-closed .page--cover {
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 0 26px rgba(0, 0, 0, 0.45), 0 24px 44px rgba(0, 0, 0, 0.55), 0 2px 4px rgba(0, 0, 0, 0.4);
}
.book::before { transition: left 0.01s linear 0.9s; }
.book.is-closed::before { left: calc(50% + 2px); transition: none; }
.is-single .book.is-closed::before { left: 2px; }
.book.is-closed .book-head { opacity: 0; pointer-events: none; }
.book-head { transition: opacity 0.5s ease 0.6s; }

.title-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6em; margin-top: 1.4em; }
.title-actions .begin { margin-top: 0; }
.begin.begin--quiet { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px rgba(43, 33, 24, 0.45); }
.begin.begin--quiet:hover { background: rgba(43, 33, 24, 0.07); }

/* Title page */
.endpaper {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.12) 0 8%, transparent 9%),
    radial-gradient(circle at 70% 60%, rgba(0,0,0,.18) 0 11%, transparent 12%),
    radial-gradient(circle at 40% 80%, rgba(255,255,255,.08) 0 14%, transparent 15%),
    radial-gradient(circle at 85% 15%, rgba(0,0,0,.14) 0 9%, transparent 10%),
    conic-gradient(from 30deg at 30% 60%, #3b4f5c, #6b3b2e, #2f3d36, #8a6a3d, #3b4f5c);
  filter: saturate(0.8);
}
.endpaper::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-radial-gradient(circle at 60% 40%, rgba(255,255,255,0.05) 0 2px, transparent 2px 7px);
}
.bookplate {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: 48%;
  padding: 1.4em 1em;
  text-align: center;
  background: var(--paper);
  background-image: var(--noise);
  color: var(--ink-soft);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35), inset 0 0 0 4px var(--paper), inset 0 0 0 5px var(--gilt);
  font-family: var(--fell);
  font-style: italic;
  font-size: 1.05em;
}
.bookplate span { display: block; font-family: var(--display); font-style: normal; font-size: 0.75em; letter-spacing: 0.3em; text-transform: uppercase; margin-top: 0.5em; }

.title-page { text-align: center; justify-content: center; align-items: center; gap: 0.2em; }
.title-page h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 3.2em;
  line-height: 1;
  letter-spacing: 0.02em;
}
.title-page h1 em { display: block; font-weight: 500; color: #8a5a28; }
.title-rule { width: 40%; height: 1px; background: var(--gilt); margin: 1.1em auto; }
.title-page p { margin: 0 auto; max-width: 26em; line-height: 1.55; color: var(--ink-soft); text-wrap: balance; }
.title-page .title-span { font-family: var(--display); letter-spacing: 0.2em; text-transform: uppercase; font-size: 0.85em; color: var(--ink); margin-bottom: 0.8em; }
.title-page .title-small { font-size: 0.85em; font-style: italic; margin-top: 0.9em; }
.begin {
  margin-top: 1.4em;
  border: 0;
  padding: 0.55em 1.5em;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05em;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.begin:hover { background: #4a3523; transform: translateY(-1px); }
.begin:focus-visible { outline: 2px solid var(--gilt); outline-offset: 3px; }

/* ───────────────────────── Turning leaves ───────────────────────── */

.leaf {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  transform-style: preserve-3d;
  will-change: transform;
}
.leaf--fwd { left: 50%; transform-origin: 0 50%; }
.leaf--back { left: 0; transform-origin: 100% 50%; }
.leaf-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.leaf-face--back { transform: rotateY(180deg); }
.leaf-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}
.leaf--fwd .leaf-face--front .leaf-shade,
.leaf--back .leaf-face--back .leaf-shade { background: linear-gradient(to left, rgba(40, 25, 10, 0.45), rgba(40, 25, 10, 0.15)); }
.leaf--fwd .leaf-face--back .leaf-shade,
.leaf--back .leaf-face--front .leaf-shade { background: linear-gradient(to right, rgba(40, 25, 10, 0.45), rgba(40, 25, 10, 0.15)); }

.page-ghost {
  position: absolute;
  inset: 0;
  transform: scaleX(-1);
  opacity: 0.09;
  filter: blur(0.4px);
  pointer-events: none;
}

/* Hand-turned page: the fold, the back of the sheet, and its shadows */
.curl {
  position: absolute;
  z-index: 3000;
  pointer-events: none;
  --curl-shadow: 0;
}
.curl-under, .curl-front, .curl-sheen, .curl-flapwrap { position: absolute; inset: 0; }
.curl-front > .page { position: absolute; inset: 0; }
.curl-flap { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.curl-flap > .page { height: 100%; }
.curl-flapwrap { filter: drop-shadow(0 2px 10px rgba(30, 18, 6, calc(0.4 * var(--curl-shadow)))); }
.curl-band { position: absolute; left: 0; top: 0; height: 400%; transform-origin: 0 0; }
.curl-under .curl-band {
  opacity: var(--curl-shadow);
  background: linear-gradient(to right, rgba(40, 25, 10, 0.5), rgba(40, 25, 10, 0.16) 30%, rgba(40, 25, 10, 0) 100%);
}
.curl-sheen .curl-band {
  opacity: var(--curl-shadow);
  background: linear-gradient(to right,
    rgba(60, 40, 20, 0.28) 0%, rgba(255, 250, 238, 0.5) 5%, rgba(255, 250, 238, 0.14) 22%,
    rgba(60, 40, 20, 0) 55%, rgba(60, 40, 20, 0.14) 100%);
}
.curl.is-flat .curl-under, .curl.is-flat .curl-flapwrap, .curl.is-flat .curl-sheen { display: none; }

/* Big jumps: the spread dissolves into the whirl and re-forms */
.spread.whirl-out { animation: whirlOut var(--whirl-out, 600ms) cubic-bezier(.5, 0, .75, .3) forwards; }
.spread.whirl-in { animation: whirlIn var(--whirl-in, 700ms) cubic-bezier(.2, .7, .3, 1) both; }
@keyframes whirlOut {
  to { opacity: 0; transform: scale(0.9) rotate(-5deg); filter: blur(10px) sepia(0.6); }
}
@keyframes whirlIn {
  from { opacity: 0; transform: scale(1.06) rotate(4deg); filter: blur(12px) sepia(0.6); }
  to { opacity: 1; transform: none; filter: none; }
}
.spread.fade-in { animation: fadeIn 0.3s ease both; }
@keyframes fadeIn { from { opacity: 0; } }

/* ───────────────────────── Timeline ───────────────────────── */

.timeline {
  padding-block: 0 10px;
  width: min(1240px, 100%);
  margin-inline: auto;
}

.timeline { position: relative; }
.tape-tip {
  position: absolute;
  left: 0;
  bottom: calc(100% - 4px);
  max-width: min(560px, calc(100vw - 16px));
  padding: 4px 11px 5px;
  border-radius: 7px;
  background: var(--cream);
  color: var(--ink);
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  z-index: 10;
}
.tape-tip strong { font-weight: 500; margin-right: 2px; }
.tape-tip-place { color: var(--ink-soft); font-style: italic; }
.tape-tip-lang { color: #8a5a28; }
.tape {
  position: relative;
  height: 46px;
  cursor: grab;
  touch-action: none;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
}
.tape.is-dragging { cursor: grabbing; }
.tape canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.tape-needle {
  position: absolute;
  left: 50%;
  top: 2px;
  bottom: 6px;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--gilt-bright);
  box-shadow: 0 0 10px rgba(236, 210, 155, 0.6);
}
.tape-needle::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--gilt-bright);
}

.rail {
  position: relative;
  height: 40px;
  margin-inline: 30px;
  cursor: pointer;
  touch-action: none;
  outline: none;
}
.rail-track {
  position: absolute;
  left: 0; right: 0;
  top: 12px;
  height: 2px;
  border-radius: 1px;
  background: var(--cream-faint);
}
.rail-ticks { position: absolute; inset: 0; }
.rail-tick {
  position: absolute;
  top: 9px;
  width: 1px;
  height: 8px;
  background: var(--cream-faint);
}
.rail-tick--major { top: 6px; height: 14px; background: var(--cream-dim); }
.rail-label {
  position: absolute;
  top: 22px;
  transform: translateX(-50%);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  color: var(--cream-dim);
  white-space: nowrap;
}
.rail-handle {
  position: absolute;
  top: 13px;
  left: 0;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: var(--gilt-bright);
  box-shadow: 0 0 0 4px rgba(236, 210, 155, 0.18), 0 0 16px rgba(236, 210, 155, 0.55);
  transition: transform 0.15s;
}
.rail:hover .rail-handle, .rail.is-dragging .rail-handle { transform: scale(1.18); }
.rail:focus-visible .rail-handle { box-shadow: 0 0 0 3px #17120e, 0 0 0 5px var(--gilt-bright); }
.rail-ghost {
  position: absolute;
  top: 0;
  height: 26px;
  width: 1px;
  background: var(--cream-dim);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.rail:hover .rail-ghost { opacity: 1; }
.rail.is-dragging .rail-ghost { opacity: 0; }
.rail-ghost span {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--cream);
  color: var(--ink);
  font-size: 0.82rem;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}

.keys {
  margin: 2px 0 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--cream-faint);
}
.keys kbd {
  font: inherit;
  padding: 0 5px;
  margin-right: 2px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px var(--cream-faint);
}

/* ───────────────────────── Single-page layout (phones, tall windows) ───────────────────────── */

.is-single .book-head { padding-inline: 14px; grid-template-columns: auto 1fr; gap: 8px; }
.is-single .yearnav { justify-self: end; }
.is-single .running-head { display: none; }
.is-single .wordmark { font-size: 13px; letter-spacing: 0.14em; }
.is-single .year-num { font-size: 30px; }
.is-single .year-era { font-size: 12px; }
.is-single .turn { width: 36px; height: 36px; }
.is-single .book {
  --head: 64px;
  width: min(100cqw, 620px);
  height: 100cqh;
  aspect-ratio: auto;
}
.is-single .spread { grid-template-columns: 1fr; }
.is-single .leaf { width: 100%; left: 0; transform-origin: 0 50%; }
.is-single .page { font-size: clamp(14.5px, 3.9cqi, 17.5px); border-radius: 6px; }
.is-single .page::after {
  background: linear-gradient(to right, rgba(60, 40, 20, 0.22), transparent 5%);
}
.page--single .page-inner { padding: calc(var(--head) + 8px) 7% 7%; overflow-y: auto; overscroll-behavior: contain; }
.page--single .page-inner > * { flex-shrink: 0; }
.page--single .plate { margin: 0 0 1.2em; }
.page--single .plate-frame { width: 100%; aspect-ratio: 4 / 3; }
.page--single .entry-body { overflow: visible; flex: none; }
.page--single.title-page-single .page-inner { justify-content: center; }

@media (max-width: 760px) {
  .keys { display: none; }
  .tape { height: 40px; }
  .rail-label { font-size: 0.66rem; }
  .rail-label--minor { display: none; }
}
@media (max-width: 420px) {
  .is-single .wordmark em { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { transition: none; }
  .entry-body.is-fresh { animation: none; }
  .pending-line { animation: none; }
  .ink, .entry-body.is-blotting { animation: none; }
}
