* { box-sizing: border-box }
:root { --printed-paper: #f1e8cd; color-scheme: light; color: #322c24; font: 106.25%/1.58 Baskerville, Georgia, serif; background: #262d2a }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 50% 12%, #445049, transparent 85%) }
a, summary { color: inherit; text-underline-offset: .22em }
:focus-visible { outline: 2px solid currentColor; outline-offset: 3px }
.skip-to-book { position: absolute; z-index: 5; top: .5rem; left: .5rem; padding: .6rem 1rem; background: #302d29; color: #f5ebd2; transform: translateY(-200%); }
.skip-to-book:focus { transform: none; }
.rail, .turns { max-width: 1120px; margin: auto; display: flex; align-items: center; justify-content: space-between; color: #f2e5c8; padding: 14px 8px; gap: 12px }
.rail a, summary, .turns a { min-height: 44px; padding: 8px; cursor: pointer }
main, .rail { width: min(97%, 1140px); margin: auto }
#contents { position: relative; z-index: 3 }
#contents ol { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); width: min(80vw, 340px); max-height: 65vh; overflow-y: auto; overscroll-behavior: contain; margin: 0; border: 1px solid #968160; padding: 18px 24px 18px 46px; background: #f4ecd8; color: #302d26; box-shadow: 0 9px 28px #1115 }
#contents li a { display: block; padding: 4px }
.binding { min-height: 63vh; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: stretch; padding: 8px; background: #683e30; border: 2px solid #392820; border-radius: 8px; box-shadow: 0 5px #c4b594,0 7px #6f624b,0 9px #4e3426,0 20px 55px #12171170 }
.leaf, #book-status { --fold: 90deg; margin: 0; min-width: 0; min-height: min(680px,76vh); display: flex; flex-direction: column; padding: clamp(22px,3.4vw,50px); background: linear-gradient(var(--fold), #6c522737,transparent 7%, transparent 97%,#7c603719), url('binding/rag-paper.webp') }
.leaf.verso, .title-leaf { --fold: 270deg; border-right: 1px solid #827559 }
.leaf[hidden], [hidden], .turns[hidden] { display: none }
.title-leaf { align-items: center; justify-content: center; text-align: center; gap: 12px }
.title-leaf img { height: auto; max-width: 38%; border-radius: 2px; box-shadow: 4px 5px 7px #332a243d }
h1 { margin: 8px 0 0; font-weight: 400; font-size: clamp(32px,4vw,58px); line-height: 1.03 }
.byline { margin: 0; font-style: italic }
.title-rule { width: 42%; height: 4px; margin: 16px; border-block: 1px solid #99845d }
.running, .folio { font-variant: small-caps; color: #63553f; text-align: center }
.running { border-bottom: 1px solid #af9b75; letter-spacing: .07em; padding-bottom: 8px; margin: 0 0 20px; font-size: .84rem }
.folio { margin: auto 0 0; padding-top: 18px; font-size: .85rem }
.prose { width: 100%; max-width: 62ch; margin-inline: auto; overflow-wrap: anywhere; font-size: 1.05rem; line-height: 1.62; }
.prose h2, .prose h3, .chapter-title { font-weight: normal; line-height: 1.15; margin: .6em 0 }
.chapter-title { font-size: clamp(26px,3vw,43px); margin: .2em 0 .6em }
.prose p { margin: .7em 0 }
.prose .post-anchor { display: none }
.prose figure { margin: 1em 0 }
.prose video,.prose img,.prose svg,.prose iframe { max-width: 100%; height: auto }
.prose figcaption { font-size: .85rem; font-style: italic }
.prose pre,.math-display,.post-table { overflow: auto; max-width: 100% }
.prose code { font-size: .88em }
.prose pre { padding: .7em; background-color: #77685612; }
.prose table { font-size: .85rem; border-collapse: collapse }
.prose .post-diagram { overflow: auto; }
.prose .post-diagram > svg { display: block; width: max(100%, 40rem); margin-inline: auto; }
.prose td,.prose th { padding: .35em; border-bottom: 1px solid #b8ab8d; text-align: left }
.turns { padding-block: 20px }
.turns a[aria-disabled=true] { opacity: .45; cursor: default }
#place { font-size: .93rem; text-align: center }
.binding { position: relative; overflow: hidden; background: #e6d7b6; border: 7px solid #613d31; padding: 1px }
.turning-sheet { position:absolute; inset:1px; width:calc(100% - 2px); height:calc(100% - 2px); pointer-events:none }
@media (max-width:760px) {
 .binding { grid-template-columns: minmax(0,1fr); padding: 4px }
 .leaf { padding: 20px clamp(16px,5vw,38px); border-right: none }
 .rail,.turns { padding-inline: 0; font-size: .93rem }
}

:root[data-appearance="night"] { --printed-paper: #2d2a29; color: #e5ddcf; background: #1b1d25; }
[data-appearance="night"] body { background: radial-gradient(ellipse at 50% 12%, #353540, transparent 85%); }
[data-appearance="night"] .binding { background: #403a3a; box-shadow: 0 4px #615749, 0 8px #3b332e, 0 20px 55px #10111788; }
[data-appearance="night"] .leaf,
[data-appearance="night"] #book-status {
    --leaf-color: #302e33;
    background-color: var(--leaf-color);
    background-blend-mode: normal, multiply;
}
[data-appearance="night"] #contents ol { background: #38353b; color: #efe5d5; }
[data-appearance="night"] :is(.running, .folio) { color: #c6bba9; }
[data-appearance="night"] .prose pre { background-color: #201f23; }
[data-appearance="night"] .prose :is(.post-diagram, img) { background-color: #e4e1d8; color: #322c24; }
[data-appearance="night"] .prose .math-display { color: inherit; }
@media (max-width: 440px) {
    .rail { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); justify-items: start; gap: 0 .4rem; }
    .rail > :nth-child(even) { justify-self: end; }
    #contents { position: static; }
    #contents ol { left: 0; top: 2.7rem; width: 100%; transform: none; }
}
