:root {
  color-scheme: dark;
  --background: #100e13;
  --panel: #1d1820;
  --soft: #c7b7bd;
  --text: #f6ece7;
  --copper: #efb58b;
  --border: #594039;
  font: 16px/1.5 system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  background: radial-gradient(ellipse at 40% 26%, #33212a 0%, var(--background) 66%) fixed;
}
button, input, select { font: inherit; }
button, .file-button, select, input:not([type="range"]) {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
}
button, .file-button {
  padding: .53rem .8rem;
  cursor: pointer;
  touch-action: manipulation;
}
button:hover:not(:disabled), .file-button:hover { border-color: var(--copper); background: #33232c; }
button:disabled { opacity: .44; cursor: default; }
:focus-visible { outline: 2px solid #ffd3a9; outline-offset: 4px; }
input:not([type="range"]) { padding: .54rem .7rem; min-width: 0; }
input[type="range"] { width: 7.5rem; accent-color: #eab08a; vertical-align: middle; }
select { padding: .35rem; }
a { color: var(--copper); }
button.primary {
  background: #eab08a;
  border-color: #eab08a;
  color: #211413;
  font-weight: 700;
}
button.primary:hover:not(:disabled) { background: #ffd3ad; }
.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: max(.7rem,env(safe-area-inset-top)) max(clamp(1rem,4vw,4rem),env(safe-area-inset-right)) .7rem max(clamp(1rem,4vw,4rem),env(safe-area-inset-left));
  min-height: 4.1rem;
  border-bottom: 1px solid #ecc19c28;
  background: #100e13b8;
}
.wordmark {
  font: 700 .82rem/1.25 system-ui, sans-serif;
  letter-spacing: .18em;
  text-decoration: none;
}
.room-label { color: var(--soft); border-left: 1px solid var(--border); padding-left: 1rem; }
.quiet { margin-left: auto; background: transparent; }
.masthead > * {min-width:0;max-width:100%;overflow-wrap:anywhere}
/* The controls reserve their own row, including when their labels wrap. */
.reader-settings, .reader-mute {
  position:relative; grid-row:1;
  z-index:40; display:inline-flex; align-items:center; justify-content:center; gap:.5rem;
  min-width:0; max-width:calc(100% - min(1.5rem,6vw)); min-height:48px; margin:.35rem min(.75rem,3vw); padding:.55rem min(.85rem,4vw); border-color:#d9a77f;
  border-radius:999px; color:#fff0de; background:#241a1ef5;
  box-shadow:0 3px 18px #0008; font:600 .95rem/1.3 system-ui,sans-serif;
  white-space:normal; overflow-wrap:anywhere;
}
.reader-settings {grid-column:1;justify-self:start}
.reader-mute {grid-column:2;justify-self:end}
.reader-mute svg { flex:none; }
.reader-mute .sound-muted,.reader-mute[aria-pressed="true"] .sound-waves { display:none; }
.reader-mute[aria-pressed="true"] .sound-muted { display:initial; }
.reader-mute[aria-pressed="true"] { border-color:#f4d6bd; }
@media(max-width:520px) { .room-label {display:none;} }
.gate {
  display: grid;
  grid-template-columns: minmax(13rem, .85fr) minmax(16rem, 1fr);
  align-items: center;
  gap: clamp(2rem, 8vw, 8rem);
  min-height: calc(100dvh - 4.1rem);
  max-width: 78rem;
  margin: auto;
  padding: clamp(2rem, 6vw, 6rem);
}
.gate-art {
  display: grid;
  place-items: center;
  position: relative;
  isolation: isolate;
  aspect-ratio: 1;
  perspective: 900px;
}
.gate-art::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -18%;
  background: radial-gradient(ellipse, #c8794d30, transparent 64%);
}
.cloth {
  width: 70%;
  aspect-ratio: 2/3;
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid #b28165;
  border-radius: 5px 9px 9px 5px;
  background:
    linear-gradient(90deg, #07060e 0%, #282039 4%, transparent 9%, #81695917 95%, #1c1326),
    repeating-linear-gradient(44deg, #ffffff05 0 1px, #0000000c 1px 3px),
    radial-gradient(ellipse at 58% 32%, #2b2439, #10101f 70%);
  box-shadow: 6px 4px #9f8272, 11px 7px #392826, 19px 16px 35px #000a, 35px 45px 90px #0008;
  transform: rotateY(-16deg) rotateZ(-7deg);
}
.foil { position: absolute; inset: 5% 7% 5% 10%; border: 1px solid #bb8a6690; border-radius: 2px; }
.foil::before, .foil::after { content: ""; position: absolute; border: 1px solid #b7815775; inset: 3%; }
.foil::after { inset: 20% 14%; border-radius: 50%; transform: rotate(24deg); border-color: #c9906d32; }
.foil i {
  position: absolute;
  width: 1rem;
  aspect-ratio: 1;
  translate: -50% -50%;
  background: #ffe2b5;
  filter: drop-shadow(0 0 6px #dc9d67);
  clip-path: polygon(50% 0%, 59% 40%, 100% 50%, 59% 60%, 50% 100%, 41% 60%, 0% 50%, 41% 40%);
}
.foil i:nth-child(1) { top: 30%; left: 49%; }
.foil i:nth-child(2) { top: 47%; left: 28%; }
.foil i:nth-child(3) { top: 45%; left: 70%; }
.foil i:nth-child(4) { top: 67%; left: 54%; }
.foil i:nth-child(5) { top: 54%; left: 61%; width: .63rem; }
.eyebrow { color: var(--copper); text-transform: uppercase; letter-spacing: .21em; font-size: .78rem; font-weight: 650; }
.gate h1 { margin: .7rem 0 2rem; font: 400 clamp(2.4rem, 5.8vw, 5.7rem)/.97 Georgia, serif; letter-spacing: -.045em; text-wrap: balance; }
.gate label { display: block; color: var(--soft); margin-bottom: .35rem; }
.unlock-fields { display: flex; gap: .6rem; max-width: 25rem; }
.unlock-fields input { flex: 1; }
.status { color: var(--soft); min-height: 1.5em; }
#reader { max-width: 110rem; margin-inline: auto; padding: 0 clamp(.6rem, 3vw, 2rem) 2rem; }
.reader-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .65rem; margin: 1rem 0; }
.reader-bar h1 { margin: 0; font: 400 clamp(1.3rem, 3vw, 2.1rem)/1.2 Georgia, serif; overflow-wrap: anywhere; }
.tools { display: flex; flex-wrap: wrap; gap: .35rem; font-size: .89rem; align-items: center; }
#import:focus-visible + button, .tools:has(#import:focus-visible) .file-button { outline: 2px solid #ffd3a9; outline-offset: 4px; }
.theatre {
  --view-height: clamp(22rem, 71dvh, 60rem);
  --content-scale: 1;
  --ratio: .666667;
  --columns: 2;
  --book-width: min(calc((100vw - 2.4rem) / var(--columns)), calc(var(--view-height) * var(--ratio)));
  position: relative;
  overflow: auto;
  border: 1px solid #ad856d33;
  border-radius: 14px;
  background: radial-gradient(ellipse at 50% 33%, #211a20, #100e13 76%);
  touch-action: pan-x pan-y pinch-zoom;
}
.theatre[data-single="true"] { --columns: 1; }
.desk {
  display: grid;
  place-items: center;
  min-width: 100%;
  width: max-content;
  min-height: calc(var(--view-height) + 1rem);
  padding: .5rem;
}
.book {
  --base-leaf: var(--book-width);
  --leaf-width: min(var(--max-leaf,24000px),max(calc(var(--base-leaf) * var(--content-scale)),var(--fit-leaf,0px)));
  --leaf-height: max(calc(var(--leaf-width) / var(--ratio)),var(--fit-height,0px));
  position: relative;
  width: calc(var(--leaf-width) * var(--columns));
  height: var(--leaf-height);
  perspective: calc(var(--leaf-width) * 4);
  isolation: isolate;
}
.leaves { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--columns), minmax(0, 1fr)); grid-template-rows:minmax(0,1fr); }
.page {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--paper, #fffdf7);
  color: var(--ink, #28211d);
  box-shadow: 0 14px 25px #0008, 0 0 1px #4c3727;
}
.print-sheet > canvas, .print-sheet > img { display: block; width: 100%; height: 100%; object-fit: contain; }
.print-viewport { position:absolute; inset:0; overflow:clip; }
.print-sheet { position:relative; width:100%; height:100%; }
.page[data-side="left"] { border-radius: 4px 0 0 4px; }
.page[data-side="right"] { border-radius: 0 4px 4px 0; }
.page[data-side="left"]::after, .page[data-side="right"]::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.page[data-side="left"]::after { background: linear-gradient(90deg, transparent 94%, #30211a2a); }
.page[data-side="right"]::after { background: linear-gradient(90deg, #30211a35, transparent 6%); }
/* The standing spine and the turning layer share the same centre shadow. */
.book { --binding-width: clamp(1rem, 6%, 4rem); --binding-shadow: linear-gradient(to right, transparent, #30211a2a 50%, #30211a35 50%, transparent); }
.theatre[data-single="false"] .book[data-pose="open"]::after,
.theatre[data-single="false"].cover-in-motion .book::after,
.turn-binding {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - var(--binding-width) / 2);
  width: var(--binding-width);
  z-index: 8;
  opacity: 1;
  pointer-events: none;
  background: var(--binding-shadow);
}
.theatre[data-single="false"].cover-in-motion .book::after {
  transform: translateX(var(--spine-shift,0px));
  opacity: var(--spine-opacity,1);
}
.theatre[data-single="false"] .book[data-pose="open"]:has(>.turn-binding)::after { visibility: hidden; }
.theatre[data-single="false"]:not(.cover-in-motion) .book[data-pose="open"] .page[data-side]::after {
  background: none;
}
.page[data-cover="true"] { border-radius: 3px 6px 6px 3px; box-shadow: 3px 2px #8a6e5a, 6px 4px #48352f, 0 18px 36px #000b; }
.page[data-cover="true"]::after { background: linear-gradient(90deg, #0003, transparent 5%, transparent 96%, #ffffff12); }
.theatre[data-theme="paper"] .page:not([data-cover="true"]) canvas { filter: sepia(.22) brightness(.98); }
.theatre[data-theme="night"] .page:not([data-cover="true"]) canvas { filter: invert(.9) hue-rotate(180deg); }
.theatre[data-theme="contrast"] .page:not([data-cover="true"]) canvas { filter: contrast(1.28); }
.theatre[data-theme="custom"] .page:not([data-cover="true"]) canvas { mix-blend-mode: multiply; }
.readable {
  width: 100%;
  height: 100%;
  overflow: auto;
  /* Keep room around enlarged type without consuming a narrow page. */
  padding: clamp(8%, 1.2em, 18%);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: var(--text-size, 22px)/var(--line-space, 1.65) var(--text-face, "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif);
}
.theatre {
  scrollbar-width: none;
}
.theatre::-webkit-scrollbar {
  display: none;
}
.book[data-pose="front"] .leaves, .book[data-pose="back"] .leaves { width: var(--leaf-width); left: 50%; translate: -50% 0; grid-template-columns: 1fr; }
.paper-canvas, .paper-leaf { position: absolute; z-index: 3; pointer-events: none; }
.paper-canvas { top: 50%; left: 50%; translate: -50% -50%; }
.paper-leaf { top: 0; left: 50%; height: 100%; transform-style: preserve-3d; }
.paper-face { position: absolute; inset: 0; overflow: hidden; backface-visibility: hidden; border-radius: var(--edge-round, 0); }
.paper-face + .paper-face { transform: rotateY(180deg); }
.paper-face .page { height: 100%; box-shadow: none; }
.paper-light {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #3a2524, #291a1700 36%, #ffffff44 64%, #372927);
  opacity: var(--curl-shade, 0);
  pointer-events: none;
}
.reader-nav { display: flex; gap: .65rem; justify-content: center; align-items: center; margin-top: .8rem; }
.jump { display: flex; flex-wrap:wrap; align-items: center; justify-content:center; gap: .4rem; min-width:0; max-width:100%; color: var(--soft); }
.jump input { width: 4.6rem; text-align: center; }
#reader-status { text-align: center; margin: .4rem 0 .65rem; }
.bookmarks { max-width: 66rem; margin: auto; padding: 1rem 0 .2rem; border-top: 1px solid #ad856d44; }
.bookmark-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.bookmark-heading h2, dialog h2 { font: 400 1.4rem/1.1 Georgia, serif; margin: 0; }
.bookmark-heading span { color: var(--soft); font-size: .86rem; }
#slots { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(10rem,100%),1fr)); gap: .5rem; list-style: none; margin: .75rem 0 0; padding: 0; }
#slots li { display: flex; align-items: stretch; min-width: 0; }
#slots button:first-child { flex: 1; text-align: left; min-width: 0; padding: .4rem .53rem; }
#slots button span { display: block; font-size: .8rem; color: var(--soft); }
#slots .remove { padding: .4rem .52rem; margin-left: .18rem; }
#slots .saved { border-color: #a47d63; }
.sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
dialog {
  width: min(calc(100% - 1.6rem - env(safe-area-inset-left) - env(safe-area-inset-right)), 32rem);
  max-height: min(calc(85dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)), 48rem);
  margin: auto;
  padding: 1rem 1.15rem;
  background: #1d1820;
  color: var(--text);
  border: 1px solid #ae816b;
  border-radius: 12px;
  box-shadow: 0 24px 70px #000a;
}
dialog::backdrop { background: #08060bd6; }
dialog > header { display: flex; flex-wrap:wrap; justify-content: space-between; align-items: center; gap:.6rem 1rem; }
dialog > header h2 {flex:1 1 10rem;min-width:0;overflow-wrap:anywhere}
dialog :is(button,select,input) {min-width:0;max-width:100%}
dialog button {white-space:normal;overflow-wrap:anywhere}
dialog form { margin: 0; }
.setting-list { display: grid; gap: .3rem; margin: .85rem 0; }
.setting-list label { display: flex; flex-wrap:wrap; justify-content: space-between; align-items: center; gap: .6rem; }
.setting-list label > :is(select,span) {flex:0 1 14rem;min-width:0;max-width:100%}
.setting-list label > span {display:flex;flex-wrap:wrap;align-items:center;gap:.35rem}
.dialog-note { color: var(--soft); font-size: .87rem; }
.settings-defaults { display:flex; flex-wrap:wrap; align-items:center; gap:.45rem .8rem; margin-top:1rem; }
.settings-defaults .dialog-note { flex:1 1 12rem; margin:0; }
#defaults-status:empty { display:none; }
#defaults-status { color:var(--copper); margin:.55rem 0; }
.listening-settings > select { width:100%; margin:.3rem 0 .65rem; }
.listening-settings .transport { display:flex; flex-wrap:wrap; gap:.4rem; }
.listening-settings .listening-volume { display:flex; flex-wrap:wrap; justify-content:space-between; width:100%; margin-top:.65rem; }
.listening-catalogue { margin-top:.7rem; }
.listening-catalogue summary { cursor:pointer; color:var(--copper); }
#listening-list { list-style:none; padding:0; display:grid; gap:.6rem; }
#listening-list li { padding:.65rem; background:#110e15; border:1px solid #594039; border-radius:7px; }
#listening-list strong,#listening-list span,#listening-list time { display:block; overflow-wrap:anywhere; }
#listening-list span,#listening-list time { font-size:.8rem; color:var(--soft); }
.search-form { display: flex; gap: .5rem; margin-top: .75rem; }
.search-form input { flex: 1; }
.link-list { list-style: none; margin: .5rem 0; padding: 0; display: grid; gap: .4rem; }
.link-list button { width: 100%; text-align: left; overflow-wrap: anywhere; }
.link-list span { font-size: .87rem; color: var(--soft); display: block; }
body.focus-reader .masthead, body.focus-reader .reader-bar { display: none; }
@media (max-width: 740px) {
  .gate { grid-template-columns: 1fr; align-content: center; gap: 1.15rem; }
  .gate-art { width: min(54vw, 14rem); margin: 0 auto; }
  .gate h1 { margin-bottom: 1.4rem; }
  #slots { grid-template-columns: repeat(2, 1fr); }
  .theatre { --view-height: 65dvh; }
  .masthead { gap: .55rem; }
  .room-label { padding-left: .6rem; }
}
@media (max-width: 360px) {
  .reader-nav { gap: .35rem; }
  .reader-nav button { padding-inline: .45rem; }
  .jump input { width: 3.6rem; }
}
.turn-underlay { position: absolute; top: 0; height: var(--leaf-height); width: var(--leaf-width); z-index: 2; pointer-events: none; }
.resume { display: flex; justify-content: center; }
.resume:has(button:not([hidden])) { margin: .35rem 0 .8rem; }
.vr-status:empty { display: none; }
.vr-status { grid-column:1 / -1;grid-row:2;margin: .4rem 0 .75rem; }

.room-switch { margin-left: auto; }
.room-switch a { text-underline-offset: .2em; white-space: nowrap; }
.masthead .quiet { margin-left: 0; white-space: nowrap; }
.public-choice { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem 1rem; margin-top: .9rem; }
.public-choice span { color: var(--soft); font-size: .875rem; }
a.file-button { display: inline-block; text-decoration: none; }
@media (max-width: 570px) {
  .masthead { flex-wrap: wrap; }
  .room-switch { margin-left: auto; }
}

.room-music {
  width: fit-content;
  max-width: 100%;
  margin: 0 0 .75rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #1f1922;
}
.room-music summary {
  padding: .5rem .9rem;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 650;
  color: var(--copper);
}
.room-music[open] { width: 100%; }
.music-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem 1rem;
  padding: .3rem .85rem .8rem;
}
.track-display { display: grid; min-width: min(12rem,100%); }
.track-display span, .music-panel a { font-size: .85rem; }
.track-display span { color: var(--soft); }
.transport { display: flex; gap: .35rem; }
.transport button { min-width: 4.2rem; }
.music-volume { display: flex; gap: .4rem; align-items: center; font-size: .86rem; }
.music-volume input { width: 5.4rem; }

.cover-in-motion .leaves { visibility: hidden; }
.cover-block, .hinged-board {
  position: absolute; left: 50%; top: 0; height: 100%; pointer-events: none;
}
.cover-block {
  overflow: hidden;
  box-shadow: 0 2px #dbccb6, 0 3px #978472, 1px 5px #c2aa90, 1px 7px #4a322c, 2px 13px 25px #0007;
}
.cover-shadow { position: absolute; inset: 0; }
.hinged-board {
  --thickness: clamp(2px,.38vw,4px);
  transform-style: preserve-3d;
  z-index: 2;
}
.board-panel {
  position: absolute; inset: 0; overflow: hidden; backface-visibility: hidden;
  border-radius: 2px; background: #ded1b8;
}
.board-panel .page { height: 100%; box-shadow: none; }
.board-panel.outside { transform: translateZ(var(--thickness)); }
.board-panel.inside { transform: rotateY(180deg); }
.board-panel::after {
  content: ''; position: absolute; inset: 0; opacity: var(--board-light);
  background: linear-gradient(115deg,#fff2d91f,transparent 42%,#22131038);
}
.board-edge {
  position: absolute; top: 0; height: 100%; width: var(--thickness);
  transform-origin: left center; transform: rotateY(-90deg);
  background: linear-gradient(to right,#513729,#b69a76,#624937);
}

.ambience-library { display:grid;grid-template-columns:repeat(auto-fit,minmax(min(15rem,100%),1fr));gap:.75rem 1rem;margin:.3rem .85rem .8rem;padding:.75rem 0;border:0;border-bottom:1px solid var(--border); }
.ambience-library legend { color:var(--copper);font:1.45rem Georgia,serif; }
.ambience-library label { display:grid;gap:.35rem;font-size:.9rem;align-content:start; }
.ambience-library select { width:100%;min-width:0;padding:.6rem;color:inherit;background:#34252b;border:1px solid #93725d;border-radius:.45rem; }
.ambience-library input { width:100%;accent-color:var(--copper); }
#room-scene-status:empty { display:none; }

.page .printed-link {position:absolute;z-index:1;padding:0;min-height:0;min-width:0;background:transparent;border:0;border-radius:0;color:transparent;font-size:0;}
.page .printed-link:hover,.page .printed-link:focus-visible {background:#ce92452b;outline:1px solid #916137;}
.readable .chapter-jump {display:block;padding:.3em 0;background:none;color:inherit;border:0;text-align:start;text-decoration:underline;font:inherit;}

[data-reader-controls],.masthead {transition:opacity 280ms ease;}
body.reader-controls-hidden #reader [data-reader-controls] {visibility:hidden; transition:none;}
body.reading-controls-idle:has(#reader:not([hidden])) :is([data-reader-controls],.masthead) {opacity:0;pointer-events:none;visibility:hidden;}
@media(prefers-reduced-motion:reduce) { [data-reader-controls],.masthead {transition:none;} }


#room-chart-note { grid-column: 1 / -1; color: var(--soft); line-height: 1.45; }

#ai-scene { grid-column: 1 / -1; color: var(--soft); }

.reader-dock { position:relative; margin-top:clamp(.8rem,2vh,1.4rem);
  padding:.35rem .75rem max(.5rem,env(safe-area-inset-bottom)); background:#171219f5;
  border-top:1px solid var(--border); }
#appearance .room-switch { display:inline-flex; margin:.35rem .7rem .25rem 0; }

.reader-dock { display:flex; justify-content:center; gap:.5rem; }
#appearance .tools { margin:.7rem 0; }
#appearance .room-music { margin:.6rem 0; }
body.focus-reader { overflow:hidden; }
body.focus-reader #reader {
  position:fixed; inset:0; height:100dvh; max-width:none; padding:0;
  display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); grid-template-rows:auto auto minmax(0,1fr) auto; overflow:auto;
  padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
body.focus-reader .theatre {
  grid-column:1 / -1; grid-row:3; container-type:size; min-height:0; max-height:none; overflow:auto; border:0; border-radius:0;
}
body.focus-reader .desk { width:max-content; min-width:100%; height:max-content; min-height:100%; padding:.5rem; }
body.focus-reader .book {
  --base-leaf:min(calc((100cqw - 1rem) / var(--columns)),calc((100cqh - 1rem) * var(--ratio)));
}
body.focus-reader .book:is([data-pose="front"],[data-pose="back"]) { --columns:1; }
body.focus-reader .reader-dock { grid-column:1 / -1; grid-row:4; padding:.25rem .5rem; }

body.focus-reader #vr-status { position:static; margin:0; }

.page:not([data-cover="true"])::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image: var(--page-stock, none);
  background-size: 288px 288px;
  mix-blend-mode: hard-light;
  opacity: .23;
}

.reader-dock { flex-wrap:wrap; align-items:center; column-gap:1.2rem; row-gap:.3rem; }
.reader-dock .reader-nav, .reader-dock #reader-status { margin:0; }
.reader-actions { display:flex; align-items:center; gap:.5rem; }
.reader-group { min-width:0; margin:.75rem 0; }
.reader-group > label { display:inline-flex; align-items:center; gap:.4rem; }
.reader-dock .reader-nav { flex-wrap:wrap; }

.reader-dock { font-size:.85rem; }
.reader-dock button, .reader-dock input { font-size:inherit; padding:.25rem .45rem; min-height:44px; min-width:0; max-width:100%; }
.reader-dock button {white-space:normal;overflow-wrap:anywhere}

.theatre {container-type:inline-size;max-height:calc(var(--view-height) + 1rem)}
.desk {width:max-content; min-width:100%}
.book {--book-width:min(calc((100cqw - 1rem) / var(--columns)),calc(var(--view-height) * var(--ratio)))}
.book:is([data-pose="front"],[data-pose="back"]) {--columns:1}
/* Cap the measured fit even when the viewport changes between layout passes. */
.theatre[data-fit-width="true"] .book {
  --leaf-width: min(calc((100cqw - 1rem) / var(--columns)),max(var(--base-leaf),var(--fit-leaf,0px)));
}
/* Paper belongs to a page; unused leaves and image letterboxing stay dark. */
.page:empty, .page:has(.print-sheet) { background:#100e13; }
.theatre[data-theme="custom"] .page:has(.print-sheet canvas) { background:var(--paper); }
.page:empty { box-shadow:none; }
.page:empty::before, .page:empty::after { display:none; }

.reader-dock {display:grid; grid-template-columns:minmax(0,1fr); justify-items:center; align-content:start}
.reader-dock .reader-nav {display:flex; flex-wrap:wrap; justify-content:center; min-width:0; max-width:100%; align-items:center}
.reader-nav #previous {justify-self:end}
.reader-nav #next {justify-self:start}
.reader-actions {justify-content:center; flex-wrap:wrap; max-width:100%; gap:.35rem}
.reader-font-controls {display:flex; justify-content:center; align-items:center; flex-wrap:wrap; gap:.35rem; max-width:100%}
#font-current {color:var(--soft); text-align:center; font-size:.8rem; min-width:8.7rem; font-variant-numeric:tabular-nums}
.reader-dock #reader-status {min-height:0; line-height:1.2}
@media(max-width:360px) {
  .reader-dock .reader-nav,.reader-dock .jump {gap:.2rem}
  .reader-dock .jump input {width:3rem}
}

body.focus-reader #leaves {
  -webkit-user-select:none; user-select:none; -webkit-touch-callout:none;
}
/* A scroll container exposes the full padded content height to the page fitter. */
.readable { position:absolute; inset:0; max-inline-size:calc((100cqw - 1rem) * max(1,var(--content-scale))); margin-inline:auto; overflow:hidden; white-space:pre-wrap; overflow-wrap:anywhere; }
.readable button { max-width:100%; white-space:normal; overflow-wrap:anywhere; }
html:has(dialog:modal) { overflow:hidden; }
dialog:modal { inset:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); overscroll-behavior:contain; }
@media (max-height:420px) {
  body.focus-reader #reader { display:block; overflow:auto; }
  body.focus-reader .theatre { container-type:inline-size; }
  body.focus-reader .book { --base-leaf:var(--book-width); }
}
/* Oversized books can be panned without putting scrollbars beside the print. */
html:has(#reader:not([hidden])), body.focus-reader #reader { scrollbar-width:none; }
html:has(#reader:not([hidden]))::-webkit-scrollbar, body.focus-reader #reader::-webkit-scrollbar { display:none; }

.readable { font-size:var(--fitted-text,var(--text-size,22px)); }
#spread-pan { width:100%; min-width:0; overflow-x:scroll; overflow-y:hidden; scrollbar-color:#be9478 #241b20; }
#spread-pan > div { height:1px; }

.reader-dock { display:flex; flex-wrap:wrap; justify-content:center; align-items:center; gap:.35rem .85rem; }
.reader-dock #reader-status { flex-basis:100%; }
.reader-dock .reader-actions {display:flex;align-items:center;}
.reader-zoom {display:inline-flex;flex-wrap:wrap;justify-content:center;gap:.35rem;flex:0 1 auto;min-width:0;max-width:100%}
@media(any-pointer:fine) {
  .theatre.can-pan-book #leaves .page {cursor:grab}
  .theatre.book-panning,.theatre.book-panning #leaves .page {cursor:grabbing}
}
.theatre.book-panning {-webkit-user-select:none;user-select:none}

.reader-dock #spread-pan { flex-basis:100%; height:16px; scrollbar-color:auto; }
#spread-pan::-webkit-scrollbar { height:12px; }
#spread-pan::-webkit-scrollbar-track { background:#241b20; border-radius:6px; }
#spread-pan::-webkit-scrollbar-thumb { background:#be9478; border-radius:6px; }
@media(max-height:500px) and (orientation:landscape){
  body:has(#reader:not([hidden])) .masthead {min-height:2.5rem;padding-block:.25rem;}
  .reader-bar {margin:.25rem 0;}
  .reader-bar h1 {font-size:1.15rem;}
  .reader-dock {margin-top:.25rem;padding-block:.25rem;}
  .reader-dock #reader-status {flex-basis:auto;}
}

.narration-status:empty{display:none}
.narration-status{margin:.2rem 0;text-align:center;font-size:.85rem;color:var(--soft)}
.narration-progress{font-size:.78rem}
.full-nav .narration-status{flex-basis:100%;color:#f0dfd0}
#full-reader[open]{position:fixed;inset:0;box-sizing:border-box;width:100%;height:100%;height:100dvh;max-width:none;max-height:none;margin:0;padding:0;border:0;border-radius:0;display:grid;grid-template-rows:minmax(0,1fr) auto;grid-template-columns:minmax(0,1fr) max(1rem,env(safe-area-inset-right));background:#151317;color:#f4f0e6;overflow:hidden}
#full-sheet{position:relative;overflow-x:hidden;overflow-y:auto;scrollbar-width:none;overscroll-behavior:contain;min-height:0;container-type:size;background-size:320px;background-blend-mode:normal}
#full-sheet::-webkit-scrollbar{display:none}
#full-scrollbar{position:relative;grid-column:2;grid-row:1;min-height:0;margin:6px 3px;border-radius:999px;background:#352730;box-shadow:inset 0 0 0 1px #a982693d;touch-action:none;cursor:pointer}
#full-scrollbar span{position:absolute;inset:0 0 auto;height:28px;border-radius:inherit;background:#c19a80;box-shadow:inset 0 0 0 1px #ead2bc66;cursor:grab}
#full-scrollbar:active span{cursor:grabbing}
#full-scrollbar:focus-visible{outline:2px solid #f8ddbd;outline-offset:1px}
#full-sheet:focus-visible{outline:2px solid currentColor;outline-offset:-3px}
.full-prose{box-sizing:border-box;max-width:76ch;margin:auto;padding:min(18vw,max(1.2em,clamp(1.5rem,6vw,5rem)));white-space:pre-wrap;overflow-wrap:anywhere;font:inherit;line-height:1.6;min-height:100%}
.full-prose .chapter-jump{display:block;color:inherit;font:inherit;text-align:left}
.full-plate{position:relative;top:50%;transform:translateY(-50%);max-width:100%;margin:auto}
.full-nav{grid-column:1 / -1;position:relative;z-index:2;display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.2rem 1.4rem;padding:.45rem max(.5rem,env(safe-area-inset-right)) max(.45rem,env(safe-area-inset-bottom)) max(.5rem,env(safe-area-inset-left));background:#201c23;font:1rem/1.4 system-ui,sans-serif}
.full-pagination,.full-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:clamp(.25rem,2vw,.8rem)}
#full-page-number{min-width:6.3em;text-align:center;font-variant-numeric:tabular-nums}
@media(max-width:380px){.full-nav{font-size:.875rem}#full-page-number{min-width:0}}
.full-nav button,.full-nav summary{cursor:pointer;min-height:44px;padding:.4rem .65rem}
.full-nav .full-pop{position:absolute;bottom:100%;right:.5rem;max-width:calc(100% - 1rem);max-height:65dvh;overflow:auto;padding:.75rem;background:#29242e;color:#fffaf2;border:1px solid #817787;border-radius:.5rem;box-shadow:0 .3rem 1rem #0005}
.full-nav .full-pop label{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:.5rem 1rem;margin:.4rem 0}
.full-nav :is(button,summary,select,input){min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere}

/* Deep magnification is a scrollable layout, not an enormous 3D texture. */
.theatre { overflow-anchor:none; }
.theatre.deep-zoom .book { perspective:none;isolation:auto; }
.theatre.deep-zoom .page { box-shadow:none; }
.theatre.deep-zoom .page:not([data-cover="true"])::before { display:none; }
.theatre.deep-zoom .book { --binding-width:1.6rem; }
.book[data-text-overflow="true"] .readable { overflow:auto;scrollbar-width:none; }
.book[data-text-overflow="true"] .readable::-webkit-scrollbar { display:none; }

/* Grain is behind the ink, with a lighter touch on text than on original plates. */
.page:has(>.readable)::before {z-index:0;opacity:.14;mix-blend-mode:normal}
.page>.readable {z-index:1}
.page>.readable, .full-prose {font-weight:700}

/* Fit the open book to the space left by the actual header and controls. */
.masthead .reader-bar { display:none; }
body:has(#reader:not([hidden])) .masthead .reader-bar { display:block; margin:0; min-width:0; }
body:has(#reader:not([hidden])) .reader-bar h1 { font-size:clamp(.95rem,2vw,1.3rem); }
body:not(.focus-reader):has(#reader:not([hidden])) {
  height:100dvh;
  display:grid;
  grid-template-rows:auto minmax(0,1fr);
}
body:has(#reader:not([hidden])) .masthead { min-height:3.25rem; padding-block:max(.35rem,env(safe-area-inset-top)) .35rem; }
body:not(.focus-reader) #reader:not([hidden]) {
  height:100%; min-height:0; max-width:none; padding:0 env(safe-area-inset-right) 0 env(safe-area-inset-left); overflow:auto;
  display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); grid-template-rows:auto auto minmax(10rem,1fr) auto;
}
body:not(.focus-reader) #theatre {
  grid-column:1 / -1; grid-row:3; min-height:0; max-height:none; container-type:size;
  border:0; border-radius:0;
}
body:not(.focus-reader) #desk { min-height:100%; padding:2px; }
body:not(.focus-reader) #book {
  --base-leaf:min(calc((100cqw - 4px) / var(--columns)),calc((100cqh - 4px) * var(--ratio)));
}
body:not(.focus-reader) .reader-dock {grid-column:1 / -1; grid-row:4; margin:0; padding-block:.25rem max(.25rem,env(safe-area-inset-bottom));}
@media(max-width:700px){
  body:has(#reader:not([hidden])) .masthead { flex-wrap:wrap; gap:.1rem .5rem; }
  body:has(#reader:not([hidden])) .masthead .reader-bar { flex-basis:100%; }
}

body:not(.focus-reader) .theatre[data-fit-width="true"] .book { --leaf-width:min(calc((100cqw - 4px) / var(--columns)),max(var(--base-leaf),var(--fit-leaf,0px))); }
body.reader-controls-hidden:has(#reader:not([hidden])) .masthead, body.reader-controls-hidden #reader .reader-dock {display:none;}
body.reader-controls-hidden #reader :is(.reader-settings,.reader-mute) {display:none;}
body.reader-controls-hidden:not(.focus-reader):has(#reader:not([hidden])) {grid-template-rows:minmax(0,1fr);}

/* Playback explanations reserve a row and remain visible when controls sleep. */
.reader-dock > .copper-music-feedback,.full-nav > .copper-music-feedback {flex:0 0 100%;min-width:0;max-width:100%;margin:.35rem 0;white-space:normal;overflow-wrap:anywhere;text-align:left}
body.reading-controls-idle #reader .reader-dock:has(> #reader-music-feedback:not([hidden])) {opacity:1;pointer-events:auto;visibility:visible}
body.reading-controls-idle #reader .reader-dock:has(> #reader-music-feedback:not([hidden])) > :not([data-music-feedback]) {visibility:hidden;pointer-events:none}
body.reader-controls-hidden #reader .reader-dock:has(> #reader-music-feedback:not([hidden])) {display:flex;visibility:visible;opacity:1}
body.reader-controls-hidden #reader .reader-dock:has(> #reader-music-feedback:not([hidden])) > :not([data-music-feedback]) {display:none}

#graphic-novel-section{max-width:68rem;margin:0 auto;padding:1.5rem clamp(1rem,4vw,3rem) 3rem;border-top:1px solid #806d5e}
#graphic-novel-section h2{margin:0;font-size:clamp(1.6rem,4vw,2.5rem)}
#graphic-novel-section p{color:var(--soft)}
#graphic-novel-reader{display:block;width:100%;height:80vh;border:0}

.frank-tribute .room-label {display:inline-flex;align-items:center;min-height:44px;text-decoration:underline;}
.frank-tribute .reader-nav button {min-height:44px;min-width:4.5rem;font-size:1rem;}
.frank-tribute .masthead{flex-wrap:wrap}.frank-share{display:inline-flex;align-items:center;min-height:44px;min-width:0;max-width:100%;padding:0 .7rem;border:1px solid #b99870;border-radius:.3rem;color:#f7dfb3;text-decoration:underline;font-size:1rem;white-space:normal;overflow-wrap:anywhere}
.frank-tribute .frank-ebook-download {background:#eadcc0;color:#152025;font-weight:650}
.frank-book-notice {flex:1 0 100%;margin:.25rem 0;padding:.5rem .75rem;border-left:3px solid #d0b78c;font-size:1rem;line-height:1.5}
.frank-page {white-space:normal;font-weight:600}
.page > .frank-page,.full-prose.frank-page {font-weight:600}
.frank-page .frank-page-heading {margin:0 0 .85em;font-family:inherit;font-size:1.25em;font-weight:700;line-height:1.3;overflow-wrap:anywhere}
.frank-page .frank-paragraph {margin:0 0 .85em;white-space:pre-wrap;line-height:inherit}
.frank-page .guest-signature {margin:0 0 .85em;font-family:"Palatino Linotype",Palatino,Georgia,serif;font-size:1.3em;font-style:italic;font-weight:500;line-height:1.5;letter-spacing:.01em;overflow-wrap:anywhere}
.frank-page .frank-draft-status,.frank-page .frank-continuation {margin:0 0 1em;font-style:italic;font-size:.9em;line-height:1.5}
.frank-page .frank-guest-photo {display:block;max-width:100%;max-height:65vh;width:auto;height:auto;object-fit:contain;margin:.75em auto}
.frank-page[data-frank-kind="title"] {text-align:center}
.frank-page .chapter-jump {display:block;min-height:44px;max-width:100%;margin:0 0 .55em;padding:.25em 0;background:none;color:inherit;border:0;font:inherit;line-height:1.5;text-align:left;text-decoration:underline;text-underline-offset:.2em;white-space:normal;overflow-wrap:anywhere}
.frank-page .chapter-jump:focus-visible {outline:3px solid currentColor;outline-offset:3px}
.frank-tribute .frank-page .frank-motif-banner {display:block;width:48%;height:auto;max-width:14em;object-fit:contain;margin:1.15em auto 1.4em;opacity:1;filter:none}
.frank-tribute .frank-page .frank-illustration-image {display:block;width:38%;height:auto;max-width:9em;object-fit:contain;margin:1.5em auto;opacity:1;filter:none}
.frank-tribute .frank-page[data-frank-kind="illustration"] .frank-page-heading {margin-bottom:.35em;text-align:center}
.frank-tribute .frank-page .frank-portrait-image {display:block;width:100%;height:auto;max-width:100%;object-fit:contain;margin:0 auto .7em;opacity:1;filter:none}
.frank-tribute .frank-page .frank-illustration-caption {margin:0;font-size:.9em;font-style:italic;line-height:1.5}
