:root {
  --bg: #f3efe5;
  --panel: rgba(255, 252, 247, 0.9);
  --panel-strong: #fffdf8;
  --text: #2b2318;
  --muted: #6c6254;
  --line: rgba(78, 59, 33, 0.12);
  --accent: #1f5c4a;
  --accent-soft: #dcece5;
  --shadow: 0 24px 60px rgba(52, 40, 19, 0.12);
  --max-width: 1240px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(31, 92, 74, 0.12), transparent 28%),
    radial-gradient(circle at right, rgba(182, 140, 74, 0.18), transparent 24%),
    var(--bg);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  line-height: 1.6;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px);
  background-size: 30px 30px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent 80%);
}

.site-header,
.page-shell {
  position: relative;
  z-index: 1;
  width: min(calc(100% - 32px), var(--max-width));
  margin: 0 auto;
}

.site-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding: 48px 0 24px;
}

.site-header h1,
.content h1,
.content h2,
.content h3 {
  font-family: "Charter", "Iowan Old Style", "Palatino Linotype", serif;
  line-height: 1.15;
}

.site-header h1 {
  margin: 6px 0 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.eyebrow,
.panel-label {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  font-weight: 700;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.top-nav a,
.toc-link {
  text-decoration: none;
}

.top-nav a {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--text);
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.top-nav a:hover,
.top-nav a:focus-visible,
.top-nav a.active {
  transform: translateY(-1px);
  border-color: rgba(31, 92, 74, 0.35);
  background: rgba(31, 92, 74, 0.12);
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 24px;
  padding-bottom: 48px;
}

.sidebar {
  position: sticky;
  top: 20px;
  align-self: start;
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.sidebar .panel {
  padding: 20px;
}

.content {
  padding: 36px;
  overflow: hidden;
}

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

#toc {
  display: grid;
  gap: 10px;
}

.toc-link {
  color: var(--muted);
  font-size: 0.96rem;
}

.toc-link:hover,
.toc-link:focus-visible,
.toc-link.active {
  color: var(--accent);
}

.toc-link.depth-3 {
  padding-left: 16px;
}

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

.content h1 {
  margin: 0 0 20px;
  font-size: clamp(2rem, 3vw, 3rem);
}

.content h2 {
  margin-top: 40px;
  font-size: 1.75rem;
}

.content h3 {
  margin-top: 28px;
  font-size: 1.25rem;
}

.content p,
.content li,
.content td,
.content th {
  font-size: 1rem;
}

.content ul,
.content ol {
  padding-left: 24px;
}

.content li + li {
  margin-top: 8px;
}

.content a {
  color: var(--accent);
}

.content code {
  padding: 0.15rem 0.4rem;
  border-radius: 8px;
  background: rgba(31, 92, 74, 0.1);
  font-size: 0.95em;
}

.content pre {
  overflow-x: auto;
  padding: 18px;
  border-radius: 18px;
  background: #1e1a14;
  color: #f8f2e7;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  overflow: hidden;
  border-radius: 18px;
}

.content th,
.content td {
  padding: 14px 16px;
  border: 1px solid var(--line);
  vertical-align: top;
}

.content th {
  background: var(--accent-soft);
  text-align: left;
}

.content img {
  display: block;
  max-width: 100%;
  margin: 22px auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 16px 32px rgba(52, 40, 19, 0.12);
}

.content hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 32px 0;
}

.noscript {
  width: min(calc(100% - 32px), var(--max-width));
  margin: 0 auto 32px;
  padding: 16px 18px;
  border: 1px solid #b6503a;
  border-radius: 16px;
  background: rgba(255, 245, 242, 0.95);
  color: #7c2b1d;
}

@media (max-width: 980px) {
  .site-header,
  .page-shell {
    width: min(calc(100% - 24px), var(--max-width));
  }

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

  .page-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }
}

@media (max-width: 640px) {
  .site-header {
    padding-top: 28px;
  }

  .content,
  .sidebar .panel {
    padding: 22px;
    border-radius: 20px;
  }

  .content table {
    display: block;
    overflow-x: auto;
  }
}
