:root {
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --measure: 42rem;
  --reading-size: 1.08rem;
  --gold: #e49c24;
  --rust: #ef7424;
  --moss: #183030;
  --ink: #0c1214;
  --panel-radius: 8px;
}

html[data-theme="dark"] {
  --bg: #0c1114;
  --surface: #102020;
  --surface-2: #183030;
  --text: #f4ecdc;
  --muted: #b8ad9c;
  --line: #253838;
  --accent: #e49c24;
  --accent-2: #ef7424;
  --mark: #4a3018;
  --button-primary-bg: #f0a329;
  --button-primary-fg: #101116;
  --button-selected-bg: #f0a329;
  --button-selected-fg: #101116;
  --button-secondary-bg: #111c1f;
  --button-disabled-bg: #172225;
  --button-disabled-fg: #9fa8aa;
  color-scheme: dark;
}

html[data-theme="sepia"] {
  --bg: #eee0c6;
  --surface: #f8ecd5;
  --surface-2: #e4d0ad;
  --text: #332d24;
  --muted: #776b5a;
  --line: #cdb894;
  --accent: #a85e12;
  --accent-2: #bd4f18;
  --mark: #f4cd7f;
  --button-primary-bg: #102424;
  --button-primary-fg: #fff4df;
  --button-selected-bg: #102424;
  --button-selected-fg: #fff4df;
  --button-secondary-bg: #fff8eb;
  --button-disabled-bg: #efe5d4;
  --button-disabled-fg: #596165;
  color-scheme: light;
}

html[data-theme="light"] {
  --bg: #f7f3ea;
  --surface: #fffdfa;
  --surface-2: #e9e2d3;
  --text: #24262c;
  --muted: #6b7280;
  --line: #d8d0c1;
  --accent: #9b5d12;
  --accent-2: #b54f18;
  --mark: #ffe29d;
  --button-primary-bg: #102424;
  --button-primary-fg: #fff4df;
  --button-selected-bg: #102424;
  --button-selected-fg: #fff4df;
  --button-secondary-bg: #fffdfa;
  --button-disabled-bg: #eee8dd;
  --button-disabled-fg: #59616a;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  line-height: 1.65;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.progress-bar {
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 100;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.site-nav {
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 58px;
  padding: 0.6rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(16px);
}

.brand {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-decoration: none;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.nav-button,
.primary-action,
.secondary-action,
.segmented button,
.icon-button,
.close-button {
  min-height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: var(--panel-radius);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 750;
  text-decoration: none;
}

.nav-button,
.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.8rem;
}

.primary-action {
  min-width: 9rem;
  border-color: color-mix(in srgb, var(--button-primary-bg) 84%, black);
  background: var(--button-primary-bg);
  color: var(--button-primary-fg);
  box-shadow: 0 1px 0 color-mix(in srgb, white 16%, transparent) inset;
}

.secondary-action {
  min-width: 8rem;
  background: var(--button-secondary-bg);
  color: var(--text);
}

.nav-button:hover,
.secondary-action:hover,
.segmented button:hover,
.icon-button:hover,
.close-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.primary-action:hover {
  filter: brightness(1.06);
}

.soon-action {
  border-color: color-mix(in srgb, var(--line) 82%, var(--text));
  background: var(--button-disabled-bg);
  color: var(--button-disabled-fg);
  box-shadow: none;
  opacity: 1;
}

.soon-action:disabled {
  cursor: not-allowed;
}

.segmented {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--panel-radius);
}

.segmented button {
  min-width: 2.25rem;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.segmented button.is-active {
  background: var(--button-selected-bg);
  color: var(--button-selected-fg);
}

.compact button {
  min-width: 2.7rem;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.35rem;
  padding: 0;
}

.icon-button span {
  display: block;
  width: 1rem;
  height: 2px;
  margin: 2px 0;
  background: currentColor;
}

.mobile-only {
  display: none;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.72fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
  min-height: calc(100vh - 128px);
  min-height: calc(100svh - 128px);
  padding: clamp(2.2rem, 5vw, 5rem) clamp(1rem, 5vw, 5rem) 2rem;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 78% 48%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 28rem),
    linear-gradient(120deg, color-mix(in srgb, var(--surface) 82%, transparent), transparent 54%),
    repeating-linear-gradient(90deg, transparent 0 52px, color-mix(in srgb, var(--line) 45%, transparent) 52px 53px);
}

.hero-copy {
  min-width: 0;
  width: 100%;
  max-width: 58rem;
}

.eyebrow,
.byline,
.book-strip span,
.toc-header,
.pager span,
.search-head,
.chapter-kicker,
.part-label {
  font-family: var(--font-sans);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 0.8rem;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 5.65rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.88;
  overflow-wrap: normal;
  white-space: nowrap;
}

.subtitle {
  max-width: 38rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 2rem;
  font-style: italic;
  line-height: 1.18;
}

.byline {
  margin: 1rem 0 0;
  color: color-mix(in srgb, var(--accent) 72%, var(--text));
}

.epigraph {
  max-width: 40rem;
  margin: clamp(1.4rem, 3vw, 2.1rem) 0 0;
  padding: 1rem 0 1rem 1.1rem;
  border-left: 3px solid var(--rust);
  color: var(--muted);
}

.epigraph p {
  margin: 0;
  font-size: 1.05rem;
}

.epigraph cite {
  display: block;
  margin-top: 0.65rem;
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-style: normal;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.book-cover {
  justify-self: center;
  width: min(70vw, 320px);
  margin: 0;
  transform: rotate(1.2deg);
}

.book-cover img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--panel-radius);
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.42),
    0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
}

.book-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.book-strip div {
  min-width: 0;
  padding: 1rem clamp(1rem, 4vw, 2rem);
  border-right: 1px solid var(--line);
}

.book-strip div:last-child {
  border-right: 0;
}

.book-strip strong {
  display: block;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 1.9rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-strip span {
  color: var(--muted);
}

.reader-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  max-width: 1280px;
  margin: 0 auto;
}

.toc-panel {
  position: sticky;
  top: 58px;
  height: calc(100vh - 58px);
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 0.45rem;
  color: var(--muted);
}

.toc-header p {
  margin: 0;
}

.toc-part {
  margin: 1rem 0.75rem 0.35rem;
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.toc-list {
  display: grid;
  gap: 0.15rem;
  padding: 0 0.6rem 1.4rem;
}

.toc-link {
  display: block;
  padding: 0.55rem 0.65rem;
  border-radius: var(--panel-radius);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.25;
  text-decoration: none;
}

.toc-link:hover,
.toc-link.is-active {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: color-mix(in srgb, var(--accent) 82%, var(--text));
}

.reading-pane {
  min-width: 0;
  padding: clamp(2rem, 5vw, 4rem) clamp(1rem, 5vw, 4rem) 5rem;
}

.chapter-frame {
  max-width: var(--measure);
  margin: 0 auto;
  font-size: var(--reading-size);
}

.part-banner {
  margin: 0 0 2.6rem;
  padding: 0 0 1.35rem;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.part-label {
  color: var(--accent);
}

.part-title {
  margin-top: 0.35rem;
  font-size: 1.35rem;
  font-style: italic;
}

.chapter-head {
  margin-bottom: 2.35rem;
  text-align: center;
}

.chapter-kicker {
  color: var(--muted);
}

.chapter-head h2 {
  margin: 0.55rem auto 0;
  font-family: var(--font-serif);
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.08;
}

.chapter-subtitle {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 1.18rem;
  font-style: italic;
}

.book-body p {
  margin: 0 0 1.15em;
}

.book-body h3 {
  margin: 2.35em 0 0.65em;
  color: color-mix(in srgb, var(--text) 92%, var(--accent));
  font-size: 1.45rem;
  line-height: 1.25;
}

.book-body h4 {
  margin: 2em 0 0.65em;
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 1rem;
  letter-spacing: 0.03em;
}

.book-body ul {
  margin: 0 0 1.25em;
  padding-left: 1.25em;
}

.book-body li {
  margin: 0.35em 0;
}

.book-body blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.15rem;
  border-left: 3px solid var(--accent-2);
  border-radius: 0 var(--panel-radius) var(--panel-radius) 0;
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  font-style: italic;
}

.book-body mark {
  border-radius: 0.2em;
  background: var(--mark);
  color: inherit;
  padding: 0 0.12em;
}

.pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  max-width: var(--measure);
  margin: 3rem auto 0;
}

.pager a {
  display: grid;
  gap: 0.25rem;
  min-height: 5rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--panel-radius);
  text-decoration: none;
}

.pager a:hover {
  border-color: var(--accent);
}

.pager a:last-child {
  text-align: right;
}

.pager span {
  color: var(--muted);
}

.pager strong {
  align-self: end;
  overflow-wrap: anywhere;
  font-size: 1rem;
  line-height: 1.25;
}

.pager .is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.search-panel {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  align-items: start;
  justify-content: center;
  padding: 6rem 1rem 1rem;
  background: rgba(0, 0, 0, 0.58);
}

.search-panel.is-open {
  display: flex;
}

.search-shell {
  width: min(720px, 100%);
  max-height: min(76vh, 760px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--panel-radius);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}

.search-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  color: var(--muted);
}

.close-button {
  width: 2.25rem;
  padding: 0;
}

#bookSearch {
  width: calc(100% - 2rem);
  margin: 0 1rem 1rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--panel-radius);
  outline: 0;
  background: var(--bg);
  color: var(--text);
}

#bookSearch:focus {
  border-color: var(--accent);
}

.search-results {
  display: grid;
  gap: 0.5rem;
  padding: 0 1rem 1rem;
}

.result-link {
  display: block;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--panel-radius);
  color: var(--text);
  text-decoration: none;
}

.result-link:hover {
  border-color: var(--accent);
}

.result-link strong {
  display: block;
  font-family: var(--font-sans);
  line-height: 1.25;
}

.result-link span {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.result-link mark {
  border-radius: 0.2em;
  background: color-mix(in srgb, var(--accent) 42%, transparent);
  color: var(--text);
  padding: 0 0.12em;
}

.empty-search {
  margin: 0;
  padding: 1rem 0;
  color: var(--muted);
  font-family: var(--font-sans);
}

.site-footer {
  padding: 2rem 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.86rem;
  text-align: center;
}

.site-footer p {
  margin: 0.25rem 0;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

.more-books {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.35rem clamp(1rem, 5vw, 5rem);
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.more-books .eyebrow {
  margin: 0 0 0.25rem;
}

.more-books h2 {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.45rem;
  line-height: 1.1;
}

.drawer-scrim {
  display: none;
}

body.drawer-open {
  overflow: hidden;
}

@media (max-width: 980px) {
  h1 {
    font-size: 5.1rem;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .book-cover {
    width: min(64vw, 320px);
  }

  .reader-layout {
    grid-template-columns: 1fr;
  }

  .mobile-only {
    display: inline-grid;
  }

  .toc-panel {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 110;
    width: min(86vw, 340px);
    height: auto;
    transform: translateX(-104%);
    transition: transform 180ms ease;
    border-right: 1px solid var(--line);
    background: var(--surface);
  }

  body.drawer-open .toc-panel {
    transform: translateX(0);
  }

  body.drawer-open .drawer-scrim {
    position: fixed;
    inset: 0;
    z-index: 105;
    display: block;
    background: rgba(0, 0, 0, 0.54);
  }
}

@media (min-width: 1400px) {
  h1 {
    font-size: 5.95rem;
  }

  .book-cover {
    width: min(70vw, 360px);
  }
}

@media (max-width: 680px) {
  .site-nav {
    align-items: start;
  }

  .nav-actions {
    flex-wrap: wrap;
    justify-content: end;
  }

  .brand {
    padding-top: 0.54rem;
  }

  .hero {
    gap: 1rem;
    padding-top: 1.4rem;
    padding-bottom: 1rem;
  }

  h1 {
    font-size: 3rem;
  }

  .subtitle {
    font-size: 1.25rem;
  }

  .epigraph {
    display: none;
  }

  .hero-actions {
    margin-top: 1.2rem;
  }

  .hero-actions > * {
    width: 100%;
  }

  .book-cover {
    width: min(48vw, 210px);
  }

  .book-strip {
    grid-template-columns: 1fr;
  }

  .book-strip div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .book-strip div:last-child {
    border-bottom: 0;
  }

  .book-strip strong {
    font-size: 1.35rem;
  }

  .reading-pane {
    padding-inline: 1rem;
  }

  .chapter-head h2 {
    font-size: 2.05rem;
  }

  .pager {
    grid-template-columns: 1fr;
  }

  .pager a:last-child {
    text-align: left;
  }

  .more-books {
    align-items: stretch;
    flex-direction: column;
  }

  .more-books .primary-action {
    width: 100%;
  }
}

@media (max-width: 360px) {
  h1 {
    font-size: 2.65rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
