:root {
  --bg: #f4efe7;
  --bg-strong: #e4d5c3;
  --paper: rgba(255, 250, 243, 0.88);
  --ink: #1e1b18;
  --muted: #665b52;
  --line: rgba(30, 27, 24, 0.12);
  --accent: #a24a2f;
  --accent-deep: #6f2f1c;
  --shadow: 0 24px 80px rgba(74, 44, 24, 0.14);
  --radius: 28px;
  --sidebar-width: 280px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Charter, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  background:
    radial-gradient(circle at top left, rgba(162, 74, 47, 0.18), transparent 30%),
    radial-gradient(circle at top right, rgba(111, 47, 28, 0.12), transparent 24%),
    linear-gradient(180deg, #f8f4ee 0%, var(--bg) 100%);
}

a {
  color: inherit;
}

.page-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: rgba(248, 242, 234, 0.9);
  backdrop-filter: blur(20px);
}

.brand {
  display: block;
  margin-bottom: 28px;
  padding: 18px;
  border-radius: 20px;
  text-decoration: none;
  background: linear-gradient(145deg, rgba(162, 74, 47, 0.18), rgba(255, 255, 255, 0.5));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.brand__eyebrow,
.hero__eyebrow,
.chapter-card__meta {
  margin: 0 0 8px;
  color: var(--accent-deep);
  font-family: "Avenir Next Condensed", "Franklin Gothic Medium", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

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

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 14px;
  color: var(--muted);
  text-decoration: none;
}

.nav-link:hover,
.nav-link:focus-visible,
.nav-link--active {
  color: var(--ink);
  background: rgba(162, 74, 47, 0.12);
}

.main-content {
  padding: 32px;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 42px;
  border: 1px solid rgba(111, 47, 28, 0.14);
  border-radius: calc(var(--radius) + 8px);
  background: linear-gradient(135deg, rgba(255, 248, 239, 0.95), rgba(228, 213, 195, 0.85));
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -5% -30% auto;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(162, 74, 47, 0.18), transparent 68%);
}

.hero h1 {
  margin: 0;
  max-width: 12ch;
  font-size: clamp(2.6rem, 7vw, 5.2rem);
  line-height: 0.96;
  letter-spacing: -0.05em;
}

.hero__description {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 18px 0 0;
  font-size: 1.08rem;
  line-height: 1.7;
  color: var(--muted);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 28px;
  margin-top: 28px;
}

.prose,
.toc {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.prose {
  padding: 34px;
}

.prose > :first-child {
  margin-top: 0;
}

.prose p,
.prose li,
.prose blockquote {
  font-size: 1.05rem;
  line-height: 1.8;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  margin-top: 1.8em;
  margin-bottom: 0.55em;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.prose h2 {
  font-size: 2rem;
}

.prose h3 {
  font-size: 1.45rem;
}

.prose pre {
  overflow-x: auto;
  padding: 18px;
  border-radius: 20px;
  background: #201b18;
  color: #fef7ed;
}

.prose code {
  padding: 0.1em 0.35em;
  border-radius: 6px;
  background: rgba(162, 74, 47, 0.1);
  font-size: 0.92em;
}

.prose pre code {
  padding: 0;
  background: transparent;
}

.prose blockquote {
  margin: 1.5rem 0;
  padding-left: 18px;
  border-left: 4px solid var(--accent);
  color: var(--muted);
}

.intro-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
}

.intro-grid__lead,
.intro-grid__note,
.chapter-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.chapter-card h2 {
  margin: 0 0 10px;
  font-size: 1.55rem;
}

.chapter-card p {
  margin: 0;
  color: var(--muted);
}

.chapter-card a {
  text-decoration: none;
}

.toc {
  position: sticky;
  top: 24px;
  align-self: start;
  padding: 24px 20px;
}

.toc h2 {
  margin-top: 0;
  margin-bottom: 14px;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.toc-list {
  display: grid;
  gap: 10px;
}

.toc-item a {
  color: var(--muted);
  text-decoration: none;
}

.toc-item--level-3 {
  padding-left: 12px;
}

.pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.pager-link {
  display: flex;
  min-height: 102px;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.pager-link span {
  color: var(--muted);
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.pager-link strong {
  font-size: 1.08rem;
}

.pager-link--empty {
  visibility: hidden;
}

.menu-toggle {
  display: none;
  margin-bottom: 20px;
  padding: 10px 14px;
  border: 1px solid rgba(111, 47, 28, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  font: inherit;
}

@media (max-width: 1024px) {
  .content-grid,
  .intro-grid {
    grid-template-columns: 1fr;
  }

  .toc {
    position: static;
  }
}

@media (max-width: 860px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    width: min(82vw, 320px);
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  .sidebar--open {
    transform: translateX(0);
  }

  .main-content {
    padding: 18px;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .hero,
  .prose,
  .toc,
  .intro-grid__lead,
  .intro-grid__note,
  .chapter-card,
  .pager-link {
    border-radius: 22px;
  }

  .hero {
    padding: 28px;
  }

  .prose {
    padding: 24px;
  }

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