.reading-room {
  --ink: #f5f5f5;
  --copy: #aaa;
  --book-turn: 360ms cubic-bezier(.32,.72,0,1);
}
/* Same width and left edge as the front page. */
.books-page { padding: clamp(1rem, 3.2vh, 2.4rem) clamp(1.4rem, 4.5vw, 5rem) 3rem; }
.home-link { display: inline-flex; align-items: center; gap: .55em; min-height: 44px; font-size: .95rem; text-decoration: none; color: var(--copy); }
.home-link:hover { color: var(--ink); }
/* The way back draws its line from the right, toward the arrow. */
.home-link::after { clip-path: inset(0 0 0 100%); }
.shelf-heading { margin: clamp(1.5rem, 5vh, 3.7rem) 0 .5rem; }
.shelf-heading h1 { font-size: clamp(2.25rem, 4.4vw, 4.2rem); font-weight: 415; line-height: .99; letter-spacing: -.037em; text-wrap: balance; }
.shelf-heading h1 span { display: block; color: var(--copy); }
/* The links remain an ordinary reading list without scripting. */
.shelf { padding: 0 0 0 2ch; margin: 1.75rem 0 0; }
.shelf li { margin-block: .65em; }
.shelf li > a span { margin-left: .65em; color: var(--copy); font-weight: 400; }
.shelf cite { font-style: normal; }
.shelf-window { --unit: clamp(15px, min(1.78vw, 3.15vh), 24px); }
.reading-room.loading-shelf .shelf-window { visibility: hidden; height: calc(17 * var(--unit)); overflow: hidden; }
.shelf-window.ready {
  font-size: var(--unit); overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
}
.shelf-window.ready::-webkit-scrollbar { display: none; }
.ready .shelf { position: relative; width: max(100%, var(--shelf-width)); height: 17em; padding: 0; margin: 0; list-style: none; isolation: isolate; }
.ready .shelf::after { content: ''; position: absolute; bottom: .85em; left: 0; right: 0; height: 3px; background: #aaa; clip-path: polygon(0 49%, 17% 20%, 39% 40%, 64% 10%, 84% 34%, 100% 27%, 100% 56%, 70% 68%, 40% 78%, 17% 66%, 0 83%); pointer-events: none; }
.ready .shelf li { position: absolute; left: 0; bottom: .93em; margin: 0; width: var(--thickness); height: var(--height); transition: transform var(--book-turn); }
.ready .shelf li.selected { width: calc(var(--face) + .18em); z-index: 1; }
.volume { position: relative; display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; font: inherit; color: var(--ink); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.volume:focus-visible, .step-controls button:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }
.binding, .hinge, .spine, .cover { position: absolute; bottom: 0; left: 0; height: 100%; }
.binding, .hinge { width: var(--thickness); }
.binding { transform-origin: 50% 100%; transform: rotate(var(--lean)); transition: transform var(--book-turn); }
.spine, .cover { transform-origin: left center; transition: transform var(--book-turn); }
.selected .binding { transform: rotate(-1deg); }
.selected .spine { transform: rotateY(-90deg); }
.spine { width: 100%; display: grid; place-items: center; }
.spine svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
/* The spine board is a shade lighter than the page; books.js draws it first. */
.spine path:first-child { fill: #1d1613; }
.spine path { stroke: #dedede; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spine-title { position: relative; writing-mode: vertical-rl; text-orientation: sideways; font-size: .71em; line-height: 1; font-weight: 500; letter-spacing: -.035em; white-space: nowrap; }
.shelf li:nth-child(3n + 2) .spine-title { font-family: Georgia, serif; font-style: italic; font-size: .80em; }
.shelf li[data-long] .spine-title { font-size: .59em; }
.cover {
  --edge: calc(var(--thickness) * .28);
  width: var(--face);
  transform: translateX(var(--thickness)) rotateY(90deg);
}
.selected .cover { transform: translateX(0) rotateY(0deg) skewY(-1.6deg); }
.cover img, .cover-fallback {
  position: relative;
  display: block;
  width: calc(100% - var(--edge));
  height: 100%;
  border: 1px solid #aaa;
  border-radius: 2% .6% .7% 1.5% / .7% .4% .5% .8%;
}
.cover-fallback { display: grid; align-content: center; padding: .7em; background: #1d1613; font-family: Georgia, serif; }
.cover::before, .cover::after {
  content: '';
  box-sizing: border-box;
  position: absolute;
  pointer-events: none;
}
/* Two paper surfaces share a corner behind the front board. */
.cover::before {
  left: .05em;
  right: var(--edge);
  bottom: calc(100% - 1px);
  height: calc(var(--edge) * .47);
  transform-origin: left bottom;
  transform: skewX(-65deg);
  border: 1px solid #303030;
  border-top: 2px solid #aaa;
  background: repeating-linear-gradient(0deg, #cbcbcb 0 1px, #eee 1px 3px);
}
.cover::after {
  left: calc(100% - var(--edge) - 1px);
  top: 0;
  bottom: .06em;
  width: var(--edge);
  transform-origin: left center;
  transform: skewY(-25deg);
  border: 1px solid #393939;
  border-right: 2px solid #aaa;
  background: repeating-linear-gradient(90deg, #ddd 0 2px, #b0b0b0 2px 3px, #eee 3px 5px);
}
.hinge::after {
  content: '';
  position: absolute;
  top: .05em;
  bottom: .05em;
  left: .16em;
  width: .15em;
  pointer-events: none;
  opacity: 0;
  border-left: 1px solid rgb(255 255 255 / 36%);
  background: linear-gradient(90deg, rgb(0 0 0 / 30%), transparent);
  transition: opacity 120ms;
}
.selected .hinge::after { opacity: 1; }
@media (hover: hover) and (pointer: fine) {
  .shelf li:not(.selected) .volume:hover .binding { transform: translateY(-.32em) rotate(var(--lean)); }
}
.selection { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: .12rem 1.5rem; }
.selection[hidden] { display:none; }
.selection-actions, .step-controls, .shelf-index { display: flex; align-items: center; }
.shelf-index { grid-column: 1 / -1; gap: .7rem; }
.book-picker {
  --slot: calc(100% / var(--book-count));
  --tick: #818181;
  --mark: linear-gradient(var(--ink), var(--ink)) center / 3px 15px no-repeat;
  appearance: none; width: min(13rem, 65%); height: 44px; margin: 0; padding: 0; border: 0; cursor: pointer;
  background: linear-gradient(90deg, transparent calc(50% - 1px), var(--tick) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) left center / var(--slot) 7px repeat-x;
}
/* A thumb one slot wide puts its center over the first and last tick at either end. */
.book-picker::-webkit-slider-thumb { appearance: none; width: var(--slot); height: 22px; border: 0; background: var(--mark); }
.book-picker::-moz-range-thumb { width: var(--slot); height: 22px; border: 0; border-radius: 0; background: var(--mark); }
.book-picker::-moz-range-track { background: none; }
.book-picker:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
@media (forced-colors: active) {
  .book-picker { forced-color-adjust: none; --tick: GrayText; --ink: Highlight; }
}
.position { white-space: nowrap; color: var(--copy); font-size: .8rem; font-variant-numeric: tabular-nums; }
.selection h2 { color: var(--ink); font-size: clamp(1.32rem, 2.4vw, 2.1rem); font-weight: 450; letter-spacing: -.037em; line-height: 1.14; margin: 0; text-wrap: balance; }
.author { margin-top: .3em; }
.selection-actions { gap: clamp(1rem, 3vw, 2.7rem); flex-shrink: 0; }
.edition { display: inline-flex; align-items: center; min-height: 44px; gap: .3em; font-size: .93rem; font-weight: 500; }
.step-controls { gap: .25rem; }
.step-controls button { width: 44px; height: 44px; display: grid; place-items: center; font: 400 1.3rem/1 system-ui,sans-serif; cursor: pointer; border: 1px solid #777; background: transparent; color: var(--ink); border-radius: 50%; }
.step-controls button:hover { border-color: var(--ink); }
@media(max-width: 700px) {
  .shelf-heading { margin: 1.4rem 0 1rem; }
  .shelf-window { --unit: clamp(17px, 4.4vw, 21px); }
  .shelf-window.ready { margin-inline: -.4rem; }
  .selection { grid-template-columns: minmax(0, 1fr); row-gap: .35rem; }
  .selection-actions { width: 100%; justify-content: space-between; }
  .selection-copy { min-height: 3.2rem; }
}
@media(prefers-reduced-motion: reduce) {
  .ready .shelf li, .binding, .spine, .cover, .hinge::after { transition: none; }
  .shelf li:not(.selected) .volume:hover .binding { transform: rotate(var(--lean)); }
}
