:root {
  --paper: #f3efe6;
  --ink: #1c1915;
  --muted: #5e584e;
  --line: #ddd4c4;
  --seal: #7d2e24;
  --seal-soft: #f3e4df;
  --sidebar: #231f1b;
  --sidebar-text: #f4eee4;
  --sidebar-dim: #b7aea0;
  --code: #efe6d8;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 17.5rem 1fr;
  background: var(--paper);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.55;
}

a { color: var(--seal); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 1.25rem 1rem 2rem;
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  color: inherit;
  text-decoration: none;
  margin-bottom: 1rem;
}

.mark {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  background: var(--seal);
  color: var(--paper);
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 1.25rem;
  border-radius: 0.4rem;
}

.brand strong {
  display: block;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand em {
  display: block;
  font-style: normal;
  color: var(--sidebar-dim);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.search {
  width: 100%;
  margin: 0 0 1rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid #3a342e;
  border-radius: 0.4rem;
  background: #2c2823;
  color: var(--sidebar-text);
  font: inherit;
  font-size: 0.9rem;
}

.search:focus {
  outline: 2px solid var(--seal);
  border-color: transparent;
}

.nav-section { margin: 0 0 1rem; }

.nav-section h2 {
  margin: 0 0 0.35rem;
  color: var(--sidebar-dim);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-section a {
  display: block;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.86rem;
  line-height: 1.35;
  padding: 0.28rem 0.45rem;
  border-radius: 0.3rem;
  border-left: 2px solid transparent;
}

.nav-section a:hover { background: #2e2924; }

.nav-section a[aria-current="page"] {
  background: #3a2a26;
  border-left-color: #e07a68;
}

.nav-section a[hidden] { display: none; }

main {
  min-width: 0;
  padding: 2.5rem 2.5rem 4rem;
}

.prose {
  max-width: 44rem;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.prose h1 { font-size: 2.15rem; margin: 0 0 0.8rem; }

.prose h2 {
  font-size: 1.45rem;
  margin: 2rem 0 0.6rem;
  padding-top: 0.4rem;
}

.prose h3 { font-size: 1.15rem; margin: 1.4rem 0 0.4rem; }

.prose p,
.prose ul,
.prose ol { margin: 0.7rem 0; }

.prose ul,
.prose ol { padding-left: 1.25rem; }

.prose li + li { margin-top: 0.25rem; }

.prose a { text-underline-offset: 0.15em; }

.prose code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--code);
  padding: 0.1em 0.3em;
  border-radius: 0.25rem;
}

.prose pre {
  overflow: auto;
  background: #2a2521;
  color: #f6f1e7;
  padding: 0.9rem 1rem;
  border-radius: 0.5rem;
  line-height: 1.45;
}

.prose pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: 0.82rem;
}

.prose blockquote {
  margin: 1rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 3px solid var(--seal);
  color: var(--muted);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin: 1rem 0 1.4rem;
}

.prose th,
.prose td {
  text-align: left;
  vertical-align: top;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
}

.prose th {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2rem 0;
}

.prose .mermaid {
  background: white;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.75rem;
  overflow: auto;
}

.missing h1 { margin-top: 0; }

@media (max-width: 800px) {
  body { display: block; }
  .sidebar {
    position: relative;
    height: auto;
    max-height: 40vh;
  }
  main { padding: 1.5rem 1.1rem 3rem; }
  .prose h1 { font-size: 1.7rem; }
}
