:root {
  color-scheme: dark;
  --cream: #fbf3dc;
  --paper: #f3e6c4;
  --ink: #3d3326;
  --brass: #d9bd88;
  --rule: #f5e6b436;
  --gutter: clamp(22px, 4.05vw, 70px);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", SimSun, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-family: var(--serif);
  color: var(--cream);
  background: #27483f;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body { margin: 0; min-width: 280px; background: #27483f; overflow: hidden; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; color: inherit; font: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid #e3c28b; outline-offset: 3px; }

.desk, #stage, #book-canvas { position: fixed; inset: 0; width: 100%; height: 100%; }
.desk {
  pointer-events: none;
  background:
    radial-gradient(ellipse at 53% 52%, #0d211803 37%, #08171042 105%),
    radial-gradient(ellipse at -8% -24%, #c19b5e4d, #9b956322 33%, transparent 63%),
    repeating-linear-gradient(90deg, #d9e1ba05 0 1px, #06181309 1px 2px, transparent 2px 4px),
    repeating-linear-gradient(0deg, #06302a16 0 1px, #aab5a908 1px 2px, transparent 2px 3px),
    #27483f;
  transition: background-color 800ms ease;
}
:root.birthday-desk .desk { background-color: #1d3437; }
#stage { touch-action: none; }
#book-canvas { display: block; }

.masthead {
  position: fixed;
  z-index: 4;
  inset: max(18px, env(safe-area-inset-top)) var(--gutter) auto;
  min-height: 58px;
  padding-bottom: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--rule);
  pointer-events: none;
}
.brand, .utilities, .utilities button { pointer-events: auto; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  padding: 7px 0;
  color: inherit;
  text-decoration: none;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: .06em;
  white-space: nowrap;
}
.brand .icon { color: var(--brass); }
.utilities { display: flex; align-items: center; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 41px;
  padding: 0 14px;
  background: #102820ad;
  color: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 100px;
  font: 500 12px var(--sans);
  white-space: nowrap;
}
.chip:hover { background: #142f27; border-color: #d7ba81a0; }
.chip[aria-pressed="true"] { color: #f7d69b; }
.chip:disabled { opacity: .45; }

.icon { position: relative; display: inline-block; flex: 0 0 auto; width: 15px; height: 15px; color: inherit; }
.icon::before, .icon::after { content: ''; position: absolute; }
.icon-book::before {
  inset: 1px 7px 2px 0;
  border: 1px solid currentColor;
  border-radius: 1px 3px 1px 1px;
  transform: skewY(9deg);
}
.icon-book::after {
  inset: 1px 0 2px 7px;
  border: 1px solid currentColor;
  border-radius: 3px 1px 1px 1px;
  transform: skewY(-9deg);
}
.brand .icon-book { width: 22px; height: 20px; }
.brand .icon-book::before { right: 10px; }
.brand .icon-book::after { left: 10px; }
.icon-reset::before { width: 12px; height: 12px; top: 2px; right: 0; border: 1px solid; border-left-color: transparent; border-radius: 50%; }
.icon-reset::after { width: 5px; height: 5px; top: 2px; left: 0; border: 1px solid; border-right: 0; border-top: 0; }
.icon-sound::before { width: 8px; height: 12px; top: 1px; left: 0; background: currentColor; clip-path: polygon(0 30%, 36% 30%, 100% 0, 100% 100%, 36% 70%, 0 70%); }
.icon-sound::after { height: 1px; width: 8px; top: 7px; right: -1px; background: currentColor; transform: rotate(-55deg); }
[aria-pressed="true"] .icon-sound::after { inset: 2px 0 2px 7px; height: auto; width: auto; border: 1px solid; border-color: transparent currentColor transparent transparent; border-radius: 50%; background: none; transform: none; }
.icon-timeline::before { width: 13px; height: 1px; top: 7px; left: 1px; background: currentColor; }
.icon-timeline::after { width: 4px; height: 4px; left: 1px; top: 5.5px; border-radius: 50%; background: currentColor; box-shadow: 5px -2px currentColor, 10px 0 currentColor; }
.arrow { font: 500 19px/1 Georgia, serif; }

#cover-controls { position: fixed; z-index: 3; left: 8%; top: 72%; pointer-events: none; }
.cover-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 26px;
  min-height: 52px;
  min-width: 166px;
  padding: 0 19px 0 20px;
  margin: 0;
  color: #3d3427;
  background: linear-gradient(160deg, #fbf1d5, #e7d2a4);
  box-shadow: 0 4px 0 #aa8d5e8c, 0 10px 24px #0a211a75;
  border: 1px solid #e7d3a7;
  border-radius: 3px;
  pointer-events: auto;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .06em;
}
.cover-button:hover { background: #fff3d2; }
.cover-button:active { transform: translateY(2px); box-shadow: 0 2px 0 #aa8d5e8c, 0 8px 17px #0a211a75; }

.chapter {
  position: fixed;
  z-index: 2;
  top: max(112px, 14.8svh);
  left: var(--gutter);
  max-width: min(69vw, 670px);
  pointer-events: none;
}
.chapter-heading {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 25px;
  color: var(--brass);
}
.chapter-heading i { width: 27px; height: 1px; background: currentColor; opacity: .55; }
.chapter-index { font: 500 11px/1.3 var(--sans); letter-spacing: .09em; }
.chapter-year { font: italic 20px/1.25 Georgia, serif; letter-spacing: .04em; }
.chapter h1 {
  margin: 8px 0 12px;
  font-size: clamp(38px, 4.5vw, 77px);
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: .045em;
  color: var(--cream);
  text-shadow: 0 3px 17px #12241d59;
}
.reading-controls {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  position: fixed;
  z-index: 3;
  inset: auto var(--gutter) max(21px, env(safe-area-inset-bottom));
  pointer-events: none;
}
.reading-preview { max-width: min(52vw, 570px); }
.reading-preview p { font: clamp(15px, 1.22vw, 20px)/1.45 var(--serif); margin: 0 0 3px; text-shadow: 0 2px 9px #0d211b; }
.keyboard-read {
  position: fixed;
  z-index: 4;
  left: var(--gutter);
  bottom: max(84px, calc(env(safe-area-inset-bottom) + 77px));
  padding: 10px 14px;
  color: var(--cream);
  background: #162f29;
  border-radius: 4px;
  font: 550 13px var(--sans);
  clip-path: inset(50%);
  pointer-events: none;
}
.keyboard-read:focus-visible { clip-path: none; }
.letter-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 41px;
  padding: 0 2px 0 0;
  background: none;
  color: #f3d4a1;
  font: 550 13px var(--sans);
  pointer-events: auto;
}
.letter-link:hover { color: var(--cream); }
.letter-link .arrow { margin-left: 2px; }
.letter-link:disabled { opacity: .55; }
.navigation {
  width: clamp(284px, 28.8vw, 390px);
  flex-shrink: 0;
  padding: 10px 10px 6px;
  background: #142d2770;
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 9px 22px #0f251c16;
  pointer-events: auto;
}
.navigation-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5px 3px;
  color: #e0d6bd;
  font: 500 11px var(--sans);
  letter-spacing: .055em;
}
#page-number { color: var(--brass); font: 16px/1.1 Georgia, serif; letter-spacing: .06em; }
.navigation-body { display: flex; align-items: center; gap: 5px; }
.direction {
  width: 35px;
  min-height: 35px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0 0 4px;
  background: #162f29;
  border: 1px solid var(--rule);
  border-radius: 50%;
  font: 24px/1 Georgia, serif;
}
.direction:hover:not(:disabled) { border-color: var(--brass); }
.direction:disabled { opacity: .32; }
.year-ticks {
  --progress: 0%;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: stretch;
  position: relative;
  flex: 1;
}
.year-ticks::before {
  content: '';
  position: absolute;
  top: 13px;
  left: 10%;
  width: 80%;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(to right, #c9a772 var(--progress), #bfbd9680 var(--progress));
}
.year-tick {
  position: relative;
  min-height: 37px;
  padding: 15px 0 0;
  background: none;
  color: #e0d6bd;
  font: 11px/1 Georgia, serif;
  text-align: center;
}
.year-tick::before {
  content: '';
  position: absolute;
  top: 11px;
  left: calc(50% - 2.5px);
  width: 5px;
  height: 5px;
  background: #a89c77;
  border-radius: 50%;
}
.year-tick[aria-current="page"] { color: #f9d99a; font-weight: 700; }
.year-tick[aria-current="page"]::before { background: #ffe1a7; box-shadow: 0 0 0 3px #dfbd7b58; }
.year-tick:hover { color: #fff0ce; }

/* Paper overlays keep their own scroll areas on short screens. */
dialog {
  --dialog-padding: clamp(24px, 4.1vw, 48px);
  color-scheme: light;
  padding: 0;
  border: 1px solid #ac936c;
  color: var(--ink);
  background: #f9edcf;
  border-radius: 3px;
  overflow: auto;
  overscroll-behavior: contain;
  box-shadow: 0 8px 0 #cfb68738, 0 18px 48px #051b15a8;
  max-height: calc(100svh - 50px);
}
dialog::backdrop { background: #101e17a6; }
.paper-card {
  position: relative;
  padding: var(--dialog-padding);
  background: repeating-linear-gradient(0deg, #8e653307 0 1px, transparent 1px 3px), linear-gradient(145deg,#faf1dc,#f2e1bb);
}
.paper-card::before { content: ''; position: absolute; inset: 8px; border: 1px solid #a2825069; pointer-events: none; }
.paper-card h2 { font: 700 clamp(25px, 4.1vw, 36px)/1.3 var(--serif); margin: 0 0 18px; letter-spacing: .025em; }
.close {
  display: grid;
  place-items: center;
  position: absolute;
  z-index: 1;
  top: 9px;
  right: 9px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 0 4px;
  background: transparent;
  border-radius: 50%;
  color: #775d48;
  font: 26px/1 Georgia, serif;
}
.close:hover { background: #813e3514; }
dialog :focus-visible { outline-color: #814b3e; }
.reader { position: fixed; inset: auto auto max(21px, env(safe-area-inset-bottom)) var(--gutter); margin: 0; width: min(480px, calc(100vw - 2 * var(--gutter))); }
.reader::backdrop { background: #101e174a; }
.paper-year { font: italic 20px/1.25 Georgia, serif; color: #835b39; margin: 0 0 10px; }
.reader-story, .letter p { font: 16px/1.85 var(--sans); margin: 0 0 16px; }
.reader .letter-link { min-height: 44px; color: #813e35; }
.reader .letter-link:hover { color: #59312a; text-decoration: underline; text-underline-offset: 4px; }
.timeline { position: fixed; inset: max(82px, calc(env(safe-area-inset-top) + 61px)) var(--gutter) auto auto; margin: 0; width: min(370px, calc(100vw - 2 * var(--gutter))); }
.timeline .paper-card { padding-top: 32px; }
.timeline h2 { margin-bottom: 10px; }
#timeline-nodes { position: relative; margin: 0; padding: 0; list-style: none; }
#timeline-nodes::before { content: ''; position: absolute; top: 21px; bottom: 21px; left: 6px; width: 1px; background: #ba9271; }
#timeline-nodes li button {
  display: grid;
  position: relative;
  grid-template-columns: 43px 1fr;
  align-items: center;
  gap: 8px;
  text-align: left;
  min-height: 44px;
  width: 100%;
  padding: 0 0 0 22px;
  border-radius: 3px;
  background: none;
  color: #514535;
  font: 550 14px var(--sans);
}
#timeline-nodes button::before { content: ''; position: absolute; width: 7px; height: 7px; left: 3px; top: calc(50% - 3px); border-radius: 50%; background: #9c6351; border: 1px solid #f9ead1; }
#timeline-nodes button[aria-current="page"] { font-weight: 700; color: #813e35; }
#timeline-nodes button[aria-current="page"]::before { box-shadow: 0 0 0 2px #9c6351; }
#timeline-nodes button:hover { background: #90564810; }
.timeline-year { color: #865c45; font: italic 16px/1.1 Georgia, serif; }
.letter { width: min(590px, calc(100vw - 2 * var(--gutter))); }
.letter .paper-card { padding-top: calc(var(--dialog-padding) + 10px); }
.letter h2 { margin-bottom: 22px; }
.letter .signature { text-align: right; margin: 21px 0 0; color: #784c37; font: 700 19px/1.55 var(--serif); }
.signature span { font: italic 14px Georgia, var(--serif); }
.paper-blossom { width: 39px; height: 39px; position: relative; display: inline-grid; place-items: center; }
.paper-blossom::before, .paper-blossom::after, .paper-blossom i { content: ''; display: block; position: absolute; width: 13px; height: 35px; border-radius: 55%; background: linear-gradient(90deg,#d7bd8e,#fff6e1 63%,#ead5b3); }
.paper-blossom::after { transform: rotate(60deg); }
.paper-blossom i { transform: rotate(-60deg); z-index: 1; }
.paper-blossom i::after { content: ''; position: absolute; width: 7px; height: 7px; left: 3px; top: 14px; border-radius: 50%; background: #ad7952; box-shadow: 0 1px 4px #77562c63; }
.letter-seal { margin: 0 0 9px; }
@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: paper-in 260ms cubic-bezier(.2,.75,.32,1) both; }
  .letter[open] { animation-duration: 390ms; }
  @keyframes paper-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
}

/* The two-page layout remains readable when the renderer is unavailable. */
#fallback-book { position: absolute; inset: 0; pointer-events: none; }
#fallback-image { position: absolute; width: 100%; height: 78%; inset: auto 0 5%; object-fit: contain; object-position: center bottom; z-index: 1; }
#fallback-book[data-page="cover"] #fallback-image { width: 75%; height: 77%; inset: 11% 12.5% auto; object-position: center; }
#fallback-book:has(#fallback-image:not([hidden])) .static-book { visibility: hidden; }
.fallback-image-read {
  position: fixed;
  z-index: 2;
  padding: 0;
  background: none;
  border-radius: 3px;
  pointer-events: auto;
}
.static-book {
  position: absolute;
  display: flex;
  top: 62%;
  left: 50%;
  width: min(92vw, 1130px);
  height: min(35vw, 38svh);
  background: #713d35;
  border: 2px solid #714432;
  border-radius: 7px;
  box-shadow: 0 8px 0 #4f2d28, 0 22px 37px #061c139c;
  transform: translate(-50%,-50%) perspective(1100px) rotateX(18deg);
}
.static-leaf {
  position: relative;
  width: 50%;
  padding: clamp(16px, 4.2vw, 60px);
  display: flex;
  flex-direction: column;
  border: 2px solid #bfa278;
  box-shadow: 0 3px 0 #e2cfa0, 0 6px 0 #bca580;
  color: #60462f;
  background: repeating-linear-gradient(0deg,#7e5c3510 0 1px,transparent 1px 3px), #f3e6c4;
}
.static-leaf::before { content: ''; position: absolute; inset: 9px; border: 1px solid #99744780; }
.static-left { border-radius: 6px 0 0 6px; box-shadow: inset -10px 0 20px #9c783c32, 0 5px 0 #c6a678; }
.static-print {
  display: flex;
  flex-direction: column;
  padding: 0;
  min-height: 44px;
  background: none;
  text-align: left;
  pointer-events: auto;
}
.fallback-image-read:focus-visible, .static-print:focus-visible { outline-color: #814b3e; }
.static-right { border-radius: 0 6px 6px 0; box-shadow: inset 8px 0 20px #9c783c27, 0 5px 0 #c6a678; }
.static-leaf strong { font-size: clamp(12px, 3.4vw, 44px); margin: 4px 0 10px; }
.static-leaf i { font: italic clamp(10px, 2.1vw, 24px) Georgia, serif; }
.static-leaf span { max-width: 340px; font-size: clamp(10px, 1.24vw, 17px); line-height: 1.6; }
.static-ribbon { position: absolute; top: 98%; left: 50%; width: 13px; height: 39px; background: #a14b40; clip-path: polygon(0 0,100% 0,100% 100%,49% 88%,0 100%); transform: rotate(6deg); transform-origin: top; }
.static-cover { display: none; }
#fallback-book[data-page="cover"] .static-book { top: 49%; left: 60%; width: min(38vw, 450px); height: min(48vw, 63svh); transform: translate(-50%,-50%) perspective(800px) rotateX(19deg) rotateZ(7deg); }
#fallback-book[data-page="cover"] .static-cover {
  display: flex;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9%;
  border-radius: 5px;
  color: #edcf9e;
  background: repeating-linear-gradient(90deg,#d7ac8c17 0 1px,transparent 1px 3px),repeating-linear-gradient(0deg,#2214082b 0 1px,transparent 1px 3px),#804437;
  box-shadow: inset 8px 0 14px #3d221c66;
  text-shadow: 0 2px #3d211d, 0 -1px #d59969;
}
.static-cover::before { content: ''; position: absolute; inset: 5%; border: 1px solid #c18a5d; outline: 1px solid #a5694b; outline-offset: 4px; }
.static-cover strong { font-size: clamp(23px, 4vw, 55px); }
.static-cover small { font: 600 clamp(13px, 2vw, 21px) Georgia, serif; }
#fallback-book[data-page="cover"] .static-leaf { display: none; }
.static-scene { position: absolute; inset: 0; display: grid; place-items: center; }
.static-scene i { position: absolute; display: block; background: #9d6340; }
[data-page="meet"] .static-scene i:nth-child(1) { width: 65%; height: 15%; top: 54%; transform: rotate(-6deg); box-shadow: 0 9px 0 #764432, 0 14px 11px #755f3b62; }
[data-page="meet"] .static-scene i:nth-child(2) { width: 28%; height: 24%; top: 21%; background: #d29a55; clip-path: polygon(26% 0,74% 0,100% 100%,0 100%); }
[data-page="meet"] .static-scene i:nth-child(3) { width: 24%; height: 18%; top: 48%; left: 38%; background: #f9e4b0; border-radius: 50%; }
[data-page="ride"] .static-scene i:nth-child(-n+3) { width: 70%; height: 44%; border-radius: 51% 61% 10% 3%; top: 22%; background: #819574; transform: translate(-14%,0) rotate(-7deg); }
[data-page="ride"] .static-scene i:nth-child(2) { transform: translate(16%,5%) rotate(5deg); background: #adad85; }
[data-page="ride"] .static-scene i:nth-child(3) { transform: translate(5%,34%) rotate(-8deg); background: #bcc39d; }
[data-page="ride"] .static-scene i:nth-child(4), [data-page="ride"] .static-scene i:nth-child(5) { width: 18%; aspect-ratio: 1; border: 4px solid #545d47; background: #d4c195a0; border-radius: 50%; top: 52%; left: 31%; }
[data-page="ride"] .static-scene i:nth-child(5) { left: 53%; }
[data-page="ride"] .static-scene i:nth-child(6) { width: 32%; height: 19%; top: 48%; left: 34%; background: #7a6947; clip-path: polygon(0 80%,35% 0,65% 0,90% 86%,100% 90%,71% 9%,30% 9%,8% 86%,96% 86%,96% 100%,0 100%); }
[data-page="wedding"] .static-scene i:nth-child(-n+3) { width: 61%; height: 65%; top: 18%; border: 8px solid #a9ac8c; border-bottom: 0; border-radius: 65% 65% 0 0; background: transparent; }
[data-page="wedding"] .static-scene i:nth-child(2) { width: 57%; border-color: #dbca9e; }
[data-page="wedding"] .static-scene i:nth-child(3) { width: 54%; border-color: #fff6de; }
[data-page="wedding"] .static-scene i:nth-child(4) { width: 26%; height: 59%; top: 31%; left: 30%; background: #fff9e8; clip-path: polygon(40% 0,61% 0,66% 20%,59% 29%,100% 99%,0 99%,43% 30%,39% 23%); }
[data-page="wedding"] .static-scene i:nth-child(5) { width: 18%; height: 58%; top: 27%; left: 54%; background: #4e4941; clip-path: polygon(34% 0,66% 0,65% 20%,100% 29%,85% 100%,58% 100%,51% 66%,44% 100%,15% 100%,0 29%,35% 20%); }
[data-page="baby"] .static-scene i:nth-child(1) { width: 43%; height: 60%; top: 18%; background: #b2bbc4; border: 5px double #e0cfac; border-radius: 41% 41% 0 0; }
[data-page="baby"] .static-scene i:nth-child(2) { width: 16%; height: 20%; top: 25%; background: #fbf0c7; clip-path: polygon(44% 0,53% 38%,100% 45%,59% 60%,49% 100%,34% 64%,0 48%,33% 34%); }
[data-page="baby"] .static-scene i:nth-child(3) { width: 56%; height: 31%; top: 58%; border: 2px solid #a58158; border-radius: 4px 4px 32% 30%; background: repeating-linear-gradient(90deg,#b78e65 0 3px,#ddc6a4 3px 8px); transform: rotate(-5deg); }
[data-page="baby"] .static-scene i:nth-child(4) { width: 30%; height: 22%; top: 53%; background: #a8b2bd; border-radius: 45%; transform: rotate(9deg); }
[data-page="birthday"] .static-scene i:nth-child(1), [data-page="birthday"] .static-scene i:nth-child(2) { width: 59%; height: 24%; top: 62%; background: repeating-linear-gradient(90deg,#dcc398 0 2px,#f8ebc6 2px 11px); border: 2px solid #dec393; border-radius: 24% 25% 20% 18%; }
[data-page="birthday"] .static-scene i:nth-child(2) { width: 41%; top: 44%; }
[data-page="birthday"] .static-scene i:nth-child(n+3):nth-child(-n+6) { width: 3%; height: 20%; top: 26%; left: 37%; background: #ac734d; border-radius: 20%; }
[data-page="birthday"] .static-scene i:nth-child(4) { left: 45%; }
[data-page="birthday"] .static-scene i:nth-child(5) { left: 53%; }
[data-page="birthday"] .static-scene i:nth-child(6) { left: 61%; }
[data-page="birthday"] .static-scene i:nth-child(7) { width: 23%; height: 15%; top: 80%; left: 72%; background: linear-gradient(90deg,#f9edd0 40%,#a45a48 40% 52%,#f9edd0 52%); border: 1px solid #b69a71; transform: rotate(-10deg); }

@media (max-width: 750px) and (orientation: portrait) {
  :root { --gutter: clamp(15px, 5vw, 36px); }
  .masthead { inset-block-start: max(11px, env(safe-area-inset-top)); min-height: 55px; padding-bottom: 8px; gap: 7px; }
  .brand { gap: 6px; font-size: clamp(13px, 3.6vw, 19px); letter-spacing: 0; min-height: 44px; }
  .brand .icon-book { width: 17px; height: 16px; }
  .brand .icon-book::before { right: 8px; }
  .brand .icon-book::after { left: 8px; }
  .utilities { gap: 4px; }
  .chip { min-height: 44px; min-width: 44px; padding: 0 8px; gap: 4px; font-size: 11px; }
  .chip .icon { display: none; }
  .chapter { top: max(84px, calc(env(safe-area-inset-top) + 62px)); max-width: 92vw; }
  .chapter-heading { gap: 9px; min-height: 20px; }
  .chapter-heading i { width: 18px; }
  .chapter-index { font-size: 10px; }
  .chapter-year { font-size: 17px; }
  .chapter h1 { margin: 6px 0 8px; font-size: clamp(30px, 7.7vw, 57px); letter-spacing: .025em; }
  #cover-controls { left: 50%; top: 76%; transform: translateX(-50%); }
  .cover-button { min-height: 50px; }
  .reading-controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; inset-block-end: max(11px, env(safe-area-inset-bottom)); }
  .reading-preview { max-width: none; }
  .reading-preview p { font-size: 15px; line-height: 1.42; margin: 0; }
  .keyboard-read { bottom: max(130px, calc(env(safe-area-inset-bottom) + 125px)); }
  .letter-link { min-height: 44px; font-size: 12px; }
  .navigation { width: 100%; padding: 8px 8px 6px; }
  .navigation-heading { padding: 0 5px 2px; }
  .direction { width: 44px; min-height: 44px; }
  .year-tick { min-height: 44px; padding-top: 19px; }
  .year-ticks::before { top: 15px; }
  .year-tick::before { top: 13px; }
  .reader { bottom: max(12px, env(safe-area-inset-bottom)); }
  .reader-story, .letter p { font-size: 15px; }
  .static-book { top: 54%; width: 93vw; height: 36vw; }
  #fallback-image { width: 98%; height: 51%; inset: 17% 1% auto; }
  #fallback-book[data-page="cover"] #fallback-image { width: 87%; height: 49%; inset: 23% 6.5% auto; }
  .static-leaf { padding: 12px; }
  .static-leaf::before { inset: 5px; }
  .static-leaf strong { margin: 1px 0 5px; }
  .static-leaf span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; }
  .static-ribbon { height: 25px; width: 8px; }
  #fallback-book[data-page="cover"] .static-book { top: 47%; left: 50%; width: 64vw; height: min(84vw, 53svh); }
}
@media (max-width: 355px) and (orientation: portrait) {
  :root { --gutter: 11px; }
  .brand { font-size: 12px; }
  .brand .icon-book { width: 14px; }
  .brand .icon-book::before { right: 7px; }
  .brand .icon-book::after { left: 7px; }
  .utilities { gap: 3px; }
  .chip { padding: 0 6px; }
  .timeline .paper-card { padding: 29px 22px 20px; }
}
@media (max-height: 630px) {
  .masthead { inset-block-start: max(8px, env(safe-area-inset-top)); min-height: 47px; padding-bottom: 6px; }
  .chapter { top: max(72px, calc(env(safe-area-inset-top) + 55px)); }
  .chapter h1 { margin: 3px 0 5px; }
  .reading-controls { inset-block-end: max(9px, env(safe-area-inset-bottom)); }
}
@media (max-height: 520px) and (orientation: landscape) {
  .chip { min-height: 35px; }
  .chapter h1 { font-size: clamp(28px, 4.8vw, 45px); }
  .chapter-heading { min-height: 17px; }
  .chapter-index { font-size: 11px; }
  .chapter-year { font-size: 16px; }
  .navigation { width: clamp(240px, 34vw, 330px); padding-top: 5px; }
  .direction { width: 33px; min-height: 33px; }
  .reading-preview p { font-size: 14px; }
  .letter-link { min-height: 33px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
