.book-reader {
  --book-paper: #fffdf8;
  --book-paper-edge: #e8dfcf;
  --book-ink: var(--ink, #2c2a26);
  --book-muted: var(--muted, #6f6a5e);
  --book-accent: var(--accent, #a34d28);
  --book-wash: #f1ebdd;
  max-width: 1120px;
  margin: 0 auto;
  color: var(--book-ink);
}

/* Only the reader needs room for its index; shared site widths stay unchanged. */
.content:has(.book-reader) { max-width: 1120px; }

.book-masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0 0 13px;
  border-bottom: 1px solid var(--line);
}
.book-home {
  color: var(--book-ink);
  text-decoration: none;
  font: 600 0.92rem Georgia, "Times New Roman", serif;
  letter-spacing: .015em;
}
.book-home span { color: var(--book-accent); padding: 0 .18rem; }
.book-masthead-actions { display: flex; align-items: center; gap: 1rem; }
.book-progress-label { color: var(--book-muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.book-contents-trigger {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--book-ink);
  background: var(--card);
  font-size: .88rem;
  text-decoration: none;
}
.book-contents-trigger:hover { border-color: var(--book-accent); color: var(--book-accent); }
.book-progress-track {
  height: 3px;
  overflow: hidden;
  margin: 0 0 1.45rem;
  background: var(--book-paper-edge);
}
.book-progress-track span {
  display: block;
  height: 100%;
  background: var(--book-accent);
  transition: width .35s ease;
}
.book-layout { display: grid; grid-template-columns: 215px minmax(0, 1fr); align-items: start; gap: clamp(1.2rem, 3.5vw, 3.6rem); }
.book-index {
  max-height: min(76vh, 760px);
  overflow-y: auto;
  position: sticky;
  top: 94px;
  padding: 4px 8px 14px 0;
  scrollbar-color: var(--book-paper-edge) transparent;
  scrollbar-width: thin;
}
.book-index-kicker, .book-eyebrow, .book-small-label {
  margin: 0;
  color: var(--book-accent);
  font-size: .71rem;
  font-weight: 700;
  letter-spacing: .12em;
  line-height: 1.5;
  text-transform: uppercase;
}
.book-index-kicker { margin-bottom: 13px; }
.book-index-link {
  display: block;
  padding: 7px 9px;
  color: var(--book-ink);
  font-size: .86rem;
  text-decoration: none;
  border-radius: 5px;
}
.book-index-link:hover, .book-index-chapter:hover { background: var(--book-wash); }
.book-index-part { margin: 18px 0 0; }
.book-index-part h2 {
  margin: 0 0 5px;
  padding: 0 8px;
  color: var(--book-muted);
  font: 600 .8rem/1.35 Georgia, "Times New Roman", serif;
}
.book-index-part h2 span { display: block; color: var(--book-accent); font: 700 .63rem/1.5 sans-serif; letter-spacing: .1em; text-transform: uppercase; }
.book-index-chapter {
  display: grid;
  grid-template-columns: 1.8rem minmax(0, 1fr);
  align-items: baseline;
  gap: 5px;
  padding: 6px 8px;
  color: var(--book-ink);
  font-size: .78rem;
  line-height: 1.35;
  text-decoration: none;
  border-radius: 5px;
}
.book-index-chapter[aria-current="page"] { background: #f3e9da; color: var(--accent-dark); }
.book-index-number { color: var(--book-muted); font-size: .69rem; font-variant-numeric: tabular-nums; }
.book-index-title { min-width: 0; }
.book-index-chapter .book-badge { grid-column: 2; justify-self: start; }
.book-index-dot { width: 5px; height: 5px; align-self: center; border-radius: 50%; background: #72806a; }
.book-index-chapter.is-in-progress .book-index-dot { background: #c6bba7; }
.book-stage { min-width: 0; perspective: 1500px; touch-action: pan-y pinch-zoom; }
.book-page { min-width: 0; scroll-margin-top: 170px; }
.book-page[hidden] { display: none !important; }
.book-paper {
  position: relative;
  min-height: 580px;
  padding: clamp(28px, 5vw, 66px) clamp(24px, 6vw, 82px) 28px;
  background: var(--book-paper);
  border: 1px solid var(--book-paper-edge);
  border-radius: 3px 10px 10px 3px;
  box-shadow: 0 2px 5px rgba(69, 52, 29, .035), 8px 12px 28px rgba(69, 52, 29, .055), inset 8px 0 12px -12px rgba(69, 52, 29, .3);
}
.book-page-heading { margin-bottom: 2rem; }
.book-page-heading h1, .book-cover h1, .book-end h1 {
  max-width: 20ch;
  margin: .45rem 0 .75rem;
  color: #302a22;
  font: 400 clamp(2.05rem, 4.5vw, 3.45rem)/1.08 Georgia, "Times New Roman", serif;
  overflow-wrap: anywhere;
}
.book-heading-note { margin: .6rem 0 0; color: var(--book-muted); }
.book-chapter-number {
  display: block;
  margin-bottom: .55rem;
  color: var(--book-accent);
  font: 700 .72rem/1.4 sans-serif;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.book-chapter-subtitle {
  max-width: 58ch;
  margin: 0;
  color: var(--book-muted);
  font: 1.05rem/1.55 Georgia, "Times New Roman", serif;
}
.book-cover { min-height: 435px; display: flex; flex-direction: column; align-items: flex-start; }
.book-cover-rule { display: block; width: 54px; height: 2px; margin: 1.45rem 0 1.1rem; background: var(--book-accent); }
.book-cover h1 { font-size: clamp(2.65rem, 6.4vw, 4.65rem); max-width: 13ch; margin: 0 0 1.1rem; }
.book-cover .book-subtitle {
  max-width: 52ch;
  margin: 0;
  color: #655b4d;
  font: 1.08rem/1.6 Georgia, "Times New Roman", serif;
}
.book-author { margin: 1.35rem 0 1.7rem; color: var(--book-ink); font-size: .95rem; }
.book-framework { border-top: 1px solid var(--book-paper-edge); padding-top: 14px; max-width: 57ch; }
.book-framework p { margin: 5px 0 0; color: var(--book-muted); font-size: .83rem; line-height: 1.6; }
.book-small-label { display: block; font-size: .65rem; }
.book-availability { margin: 1.35rem 0 .7rem; color: var(--book-muted); font-size: .87rem; }
.book-start { margin-left: 0; }
.book-start span { padding-left: .55rem; }
.book-page-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: end;
  gap: 12px;
  margin-top: 3rem;
  padding-top: 16px;
  border-top: 1px solid var(--book-paper-edge);
}
.book-page-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--book-ink);
  text-decoration: none;
  font-size: .87rem;
  line-height: 1.35;
}
.book-page-nav a:hover { color: var(--book-accent); }
.book-page-nav a > span:first-child:not(:last-child) { color: var(--book-accent); font-size: 1.12rem; }
.book-page-nav .book-nav-next { justify-self: end; text-align: right; }
.book-page-nav small { display: block; margin-bottom: 3px; color: var(--book-muted); font-size: .68rem; letter-spacing: .04em; }
.book-skip-note {
  grid-column: 1 / -1;
  margin: 0;
  padding: 10px 12px;
  background: #f7f0e5;
  border-left: 2px solid var(--book-accent);
  color: #615545;
  font-size: .85rem;
}
.book-skip-note + .book-nav-next { grid-column: 2; }
.book-preface { max-width: 43ch; margin: 1rem 0 5rem; color: #4a4136; font: clamp(1.3rem, 2.5vw, 1.8rem)/1.65 Georgia, "Times New Roman", serif; }
.book-contents-groups { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 28px; }
.book-contents-part { margin: 0 0 1.55rem; }
.book-contents-part h2 { margin: 0 0 .65rem; color: #473d31; font: 600 1rem/1.35 Georgia, "Times New Roman", serif; }
.book-contents-part h2 span { display: block; margin-bottom: 2px; color: var(--book-accent); font: 700 .65rem/1.5 sans-serif; letter-spacing: .1em; text-transform: uppercase; }
.book-contents-part ol { list-style: none; padding: 0; margin: 0; }
.book-contents-part li + li { border-top: 1px solid #eee7da; }
.book-contents-part li a { display: grid; grid-template-columns: 1.65rem minmax(0, 1fr) auto; align-items: center; gap: 7px; padding: 9px 0; color: var(--book-ink); font-size: .82rem; line-height: 1.35; text-decoration: none; }
.book-contents-part li a:hover .book-contents-title { color: var(--book-accent); text-decoration: underline; text-underline-offset: 3px; }
.book-contents-number { color: var(--book-muted); font-size: .7rem; font-variant-numeric: tabular-nums; }
.book-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 7px; background: #e9eee4; color: #4b6343; font-size: .62rem; font-weight: 600; white-space: nowrap; }
.book-badge.is-pending { background: #f2eee6; color: #766d5d; }
.book-special-pages { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--book-paper-edge); font-size: .85rem; }
.book-essay-list { display: grid; gap: 12px; max-width: 62ch; }
.book-essay-card {
  position: relative;
  display: block;
  padding: 18px 45px 18px 19px;
  border: 1px solid var(--book-paper-edge);
  border-radius: 7px;
  color: var(--book-ink);
  background: #fffefa;
  text-decoration: none;
  transition: transform .18s ease, border-color .18s ease, background-color .18s ease;
}
.book-essay-card:hover { transform: translateY(-2px); border-color: #c9b89d; background: #fffaf0; }
.book-essay-label { display: block; margin-bottom: 5px; color: var(--book-accent); font-size: .66rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.book-essay-title { display: block; font: 1.08rem/1.4 Georgia, "Times New Roman", serif; }
.book-essay-arrow { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); color: var(--book-accent); font-size: 1.15rem; }
.book-preview { max-width: 54ch; padding: 19px 21px; border: 1px solid var(--book-paper-edge); border-radius: 7px; background: #faf6ed; }
.book-preview .book-small-label { margin-top: 13px; color: var(--book-muted); }
.book-preview p:last-child { margin: 5px 0 0; color: #50483c; font: 1.05rem/1.65 Georgia, "Times New Roman", serif; }
.book-end { min-height: 420px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; }
.book-end h1 { max-width: 14ch; margin-bottom: 0; }
.book-end > p { color: var(--book-muted); }
.book-end .book-end-contents { margin: .6rem 0 1rem; }
.book-end .book-follow { margin-top: 1.5rem; font-size: .9rem; }
.book-cover-nav { grid-template-columns: 1fr; }
.book-cover-nav .book-nav-previous { justify-self: start; }
.book-live-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.book-page.is-turning-forward { animation: book-turn-forward .65s cubic-bezier(.2,.72,.22,1) both; transform-origin: left center; }
.book-page.is-turning-back { animation: book-turn-back .65s cubic-bezier(.2,.72,.22,1) both; transform-origin: right center; }
@keyframes book-turn-forward { from { opacity: .55; transform: rotateY(-38deg); } to { opacity: 1; transform: rotateY(0); } }
@keyframes book-turn-back { from { opacity: .55; transform: rotateY(38deg); } to { opacity: 1; transform: rotateY(0); } }
.book-page.is-turning-forward .book-paper::after,
.book-page.is-turning-back .book-paper::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(55, 37, 15, .22), transparent 75%);
  pointer-events: none;
  animation: book-shadow .65s ease-out both;
}
.book-page.is-turning-back .book-paper::after { background: linear-gradient(270deg, rgba(55, 37, 15, .22), transparent 75%); }
@keyframes book-shadow { from { opacity: 1; } to { opacity: 0; } }
.book-contents-dialog {
  width: min(440px, 92vw);
  max-width: none;
  height: min(100dvh, 900px);
  max-height: none;
  margin: 0 0 0 auto;
  padding: 20px 22px;
  border: 0;
  border-left: 1px solid var(--book-paper-edge);
  background: var(--book-paper);
  color: var(--book-ink);
  box-shadow: -16px 0 48px rgba(41, 31, 18, .16);
  overflow: hidden;
}
.book-contents-dialog[open] { animation: book-drawer-in .24s ease-out both; }
.book-contents-dialog::backdrop { background: rgba(39, 34, 26, .42); }
@keyframes book-drawer-in { from { opacity: .5; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
.book-dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-bottom: 1px solid var(--book-paper-edge); padding-bottom: 12px; }
.book-dialog-header h2 { margin: 0; color: var(--book-ink); font: 400 1.65rem/1.2 Georgia, "Times New Roman", serif; }
.book-dialog-close { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--book-ink); font: inherit; cursor: pointer; }
.book-dialog-close span { font-size: 1.2rem; line-height: 1; }
.book-dialog-index { height: calc(100% - 58px); overflow: auto; padding: 12px 4px 24px 0; }
.book-dialog-index .book-index-chapter { grid-template-columns: 1.8rem minmax(0, 1fr); }
.book-dialog-index .book-badge { grid-column: 2; justify-self: start; }

@media (max-width: 760px) {
  .book-layout { display: block; }
  .book-index { display: none; }
  .book-paper { min-height: 510px; padding: clamp(26px, 7vw, 42px) clamp(20px, 6vw, 34px) 22px; }
  .book-contents-groups { grid-template-columns: 1fr; }
  .book-page-heading h1 { font-size: clamp(2rem, 9vw, 3rem); }
  .book-page { scroll-margin-top: 150px; }
}
@media (max-width: 480px) {
  .book-masthead { align-items: flex-start; }
  .book-masthead-actions { align-items: flex-end; flex-direction: column-reverse; gap: 2px; }
  .book-progress-label { font-size: .74rem; }
  .book-contents-trigger { min-height: 34px; padding: 4px 11px; }
  .book-page-nav { gap: 6px; }
  .book-page-nav a { font-size: .78rem; }
  .book-contents-part li a { grid-template-columns: 1.5rem minmax(0, 1fr); }
  .book-contents-part .book-badge { grid-column: 2; justify-self: start; }
  .book-availability { max-width: 26ch; }
}
@media (prefers-reduced-motion: reduce) {
  .book-page.is-turning-forward, .book-page.is-turning-back { animation: book-fade .16s ease both; }
  .book-contents-dialog[open] { animation: book-fade .16s ease both; }
  .book-progress-track span, .book-essay-card { transition: none; }
  .book-page.is-turning-forward .book-paper::after,
  .book-page.is-turning-back .book-paper::after { display: none; }
  @keyframes book-fade { from { opacity: .55; } to { opacity: 1; } }
}
