:root {
  --paper: #efe4d0;
  --paper-deep: #dfcba8;
  --paper-shadow: rgba(39, 26, 18, 0.12);
  --ink: #17120f;
  --ink-soft: #57463a;
  --line: rgba(23, 18, 15, 0.16);
  --accent: #a4482d;
  --accent-deep: #6f2916;
  --moss: #283833;
  --card: rgba(255, 248, 236, 0.72);
  --shadow-lg: 0 24px 80px rgba(26, 18, 12, 0.12);
  --shadow-sm: 0 8px 28px rgba(26, 18, 12, 0.08);
  --serif: "Iowan Old Style", "Baskerville", "Palatino Linotype", "URW Palladio L", "Book Antiqua", serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(164, 72, 45, 0.18), transparent 34%),
    radial-gradient(circle at 88% 12%, rgba(40, 56, 51, 0.18), transparent 24%),
    linear-gradient(180deg, #f4ebdd 0%, var(--paper) 45%, #e8dac2 100%);
  font-family: var(--serif);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.14), transparent 20%, transparent 80%, rgba(255, 255, 255, 0.12)),
    repeating-linear-gradient(180deg, transparent 0, transparent 28px, rgba(23, 18, 15, 0.02) 29px, transparent 30px);
  pointer-events: none;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--accent-deep);
}

.shell {
  width: min(1180px, calc(100vw - 2rem));
  margin: 0 auto;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image: radial-gradient(rgba(23, 18, 15, 0.18) 0.5px, transparent 0.5px);
  background-size: 8px 8px;
  mix-blend-mode: multiply;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 0 1rem;
  backdrop-filter: blur(14px);
  background: linear-gradient(180deg, rgba(244, 235, 221, 0.94), rgba(244, 235, 221, 0.72));
  border-bottom: 1px solid rgba(23, 18, 15, 0.08);
}

.wordmark {
  font-size: 0.95rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-decoration: none;
}

.header-nav {
  display: flex;
  gap: 1rem;
  font-size: 0.95rem;
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.4rem;
  padding: 2rem 0 3rem;
}

.side-panel {
  display: none;
}

.main-panel {
  position: relative;
}

.cover,
.chapter-page,
.section-page,
.not-found,
.edition-note-block,
.chapter-grid-wrap {
  position: relative;
  background: var(--card);
  border: 1px solid rgba(23, 18, 15, 0.08);
  box-shadow: var(--shadow-lg);
  border-radius: 28px;
  overflow: hidden;
}

.cover,
.chapter-page,
.section-page,
.not-found {
  padding: clamp(2rem, 5vw, 4rem);
}

.edition-note-block,
.chapter-grid-wrap {
  margin-top: 1.2rem;
  padding: clamp(1.4rem, 3vw, 2.4rem);
}

.cover::after,
.chapter-page::after,
.section-page::after,
.not-found::after,
.edition-note-block::after,
.chapter-grid-wrap::after {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(111, 41, 22, 0.12);
  border-radius: 20px;
  pointer-events: none;
}

.cover {
  min-height: min(86vh, 900px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: settle 800ms ease both;
}

.cover-mark {
  width: 104px;
  margin-bottom: 1.75rem;
}

.eyebrow,
.section-overline,
.chapter-card-number,
.section-meta,
.toc-eyebrow {
  margin: 0 0 0.7rem;
  color: var(--accent-deep);
  font-size: 0.82rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.cover h1,
.chapter-page h1,
.section-page h1,
.not-found h1 {
  margin: 0;
  font-size: clamp(3rem, 9vw, 6rem);
  line-height: 0.92;
  font-weight: 500;
  max-width: 11ch;
}

.subtitle {
  margin: 1rem 0 0;
  font-size: clamp(1.05rem, 2.2vw, 1.45rem);
  color: var(--ink-soft);
  max-width: 34rem;
}

.intro,
.chapter-summary,
.section-deck,
.edition-note-block p,
.not-found p {
  max-width: 43rem;
  font-size: clamp(1.05rem, 1rem + 0.35vw, 1.28rem);
  line-height: 1.75;
  color: var(--ink-soft);
}

.cover-actions,
.chapter-actions,
.chapter-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 1.8rem;
}

.button-primary,
.button-secondary,
.text-link,
.pager-link {
  text-decoration: none;
}

.button-primary,
.button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.8rem 1.25rem;
  border-radius: 999px;
  font-size: 0.98rem;
  letter-spacing: 0.04em;
}

.button-primary {
  background: var(--ink);
  color: #f7f0e3;
  box-shadow: var(--shadow-sm);
}

.button-primary:hover {
  color: #f7f0e3;
  background: #271a12;
}

.button-secondary {
  background: transparent;
  border: 1px solid rgba(23, 18, 15, 0.16);
}

.text-link {
  font-size: 0.98rem;
  color: var(--accent-deep);
}

.epigraph {
  margin: 2rem 0 0;
  padding: 1.2rem 0 0;
  max-width: 28rem;
  border-top: 1px solid rgba(23, 18, 15, 0.14);
}

.epigraph blockquote {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.6;
}

.epigraph figcaption {
  margin-top: 0.8rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.section-heading {
  margin-bottom: 1.2rem;
}

.section-heading h2,
.chapter-sections h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 500;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.chapter-card,
.section-list-item a {
  display: block;
  padding: 1.2rem;
  border-radius: 22px;
  background: rgba(255, 253, 247, 0.72);
  border: 1px solid rgba(23, 18, 15, 0.08);
  box-shadow: var(--shadow-sm);
}

.chapter-card h3 {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.02;
}

.chapter-card-summary {
  color: var(--ink-soft);
  line-height: 1.65;
  min-height: 7em;
}

.section-list {
  padding: 0;
  margin: 1.5rem 0 0;
  list-style: none;
  display: grid;
  gap: 1rem;
}

.section-list-item strong,
.section-list-item span {
  display: block;
}

.section-list-item strong {
  margin-top: 0.25rem;
  font-size: 1.5rem;
  font-weight: 500;
}

.section-list-item span:last-child {
  margin-top: 0.45rem;
  color: var(--ink-soft);
  line-height: 1.6;
}

.section-page {
  animation: settle 680ms ease both;
}

.breadcrumb {
  margin: 0.9rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.reading-ornament {
  width: 110px;
  margin: 2rem 0;
}

.prose {
  max-width: 42rem;
}

.prose a {
  color: var(--accent-deep);
  text-decoration-thickness: 1px;
}

.prose p {
  margin: 0 0 1.28rem;
  font-size: clamp(1.08rem, 1rem + 0.38vw, 1.28rem);
  line-height: 1.9;
}

.prose p.lead::first-letter {
  float: left;
  margin: 0.08em 0.08em 0 0;
  font-size: 4.3em;
  line-height: 0.78;
  color: var(--accent-deep);
}

.section-page.is-brief .prose {
  max-width: 35rem;
}

.section-page.is-brief .prose p {
  font-size: clamp(1.22rem, 1.08rem + 0.5vw, 1.55rem);
  line-height: 1.72;
}

.toc-drawer {
  margin-bottom: 1rem;
  border-radius: 18px;
  border: 1px solid rgba(23, 18, 15, 0.12);
  background: rgba(255, 252, 245, 0.82);
}

.toc-drawer summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.1rem;
  font-size: 0.96rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.toc-drawer summary::-webkit-details-marker {
  display: none;
}

.toc-drawer .toc-nav {
  padding: 0 1.1rem 1.1rem;
}

.toc-chapter-list,
.toc-section-list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.toc-chapter {
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(23, 18, 15, 0.08);
}

.toc-chapter:last-child {
  border-bottom: 0;
}

.toc-chapter-link {
  display: block;
  text-decoration: none;
}

.toc-number,
.toc-title,
.toc-section a {
  display: block;
}

.toc-title {
  font-size: 1.2rem;
  line-height: 1.18;
}

.toc-section-list {
  margin-top: 0.55rem;
  padding-left: 0.7rem;
}

.toc-section {
  margin-top: 0.45rem;
}

.toc-section a {
  color: var(--ink-soft);
  text-decoration: none;
  line-height: 1.45;
}

.toc-chapter.is-active .toc-title,
.toc-section.is-active a {
  color: var(--accent-deep);
}

.pager {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 2.4rem;
  padding-top: 1.6rem;
  border-top: 1px solid rgba(23, 18, 15, 0.12);
}

.pager-link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255, 250, 242, 0.78);
  border: 1px solid rgba(23, 18, 15, 0.08);
}

.pager-link span {
  font-size: 0.82rem;
  color: var(--accent-deep);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.pager-link strong {
  font-size: 1.12rem;
  font-weight: 500;
}

.site-footer {
  padding: 0 0 2rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

@keyframes settle {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 980px) {
  .page-shell {
    grid-template-columns: 290px minmax(0, 1fr);
    align-items: start;
  }

  .side-panel {
    display: block;
    position: sticky;
    top: 5.8rem;
  }

  .side-panel .toc-nav {
    padding: 1.3rem;
    border-radius: 24px;
    background: rgba(255, 251, 244, 0.84);
    border: 1px solid rgba(23, 18, 15, 0.08);
    box-shadow: var(--shadow-sm);
  }

  .toc-drawer {
    display: none;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 1rem, 1180px);
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-nav {
    gap: 0.75rem;
    flex-wrap: wrap;
  }

  .cover,
  .chapter-page,
  .section-page,
  .not-found {
    padding: 1.4rem;
  }

  .edition-note-block,
  .chapter-grid-wrap {
    padding: 1.1rem;
  }

  .cover h1,
  .chapter-page h1,
  .section-page h1,
  .not-found h1 {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .cover,
  .section-page {
    animation: none;
  }
}

@media print {
  body {
    background: #fff;
  }

  .grain,
  .site-header,
  .side-panel,
  .toc-drawer,
  .site-footer,
  .pager {
    display: none;
  }

  .cover,
  .chapter-page,
  .section-page,
  .not-found,
  .edition-note-block,
  .chapter-grid-wrap {
    box-shadow: none;
    border: 0;
    background: #fff;
  }
}
