:root {
  --paper: #f4efe6;
  --paper-2: #ebe4d6;
  --ink: #1c1916;
  --muted: #5f584e;
  --line: #d8d0c2;
  --red: #9e2a2b;
  --gold: #8a6a32;
  --measure: 42rem;
  --nav: 15rem;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 1.125rem;
  line-height: 1.55;
}

a { color: var(--red); text-underline-offset: 0.18em; }
a:hover { color: var(--ink); }

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.4rem 0.7rem;
}
.skip:focus { top: 0.6rem; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: inherit;
  text-decoration: none;
  font-variant: small-caps;
  letter-spacing: 0.14em;
  font-size: 1.05rem;
}

.brand img { width: 2rem; height: 2rem; }

.site-nav {
  display: flex;
  gap: 1.25rem;
  font-size: 0.95rem;
}

.site-nav a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.site-nav a[aria-current="page"] { border-bottom-color: var(--red); color: var(--red); }
.site-nav a:hover { border-bottom-color: var(--ink); }

main { padding: 2.5rem 1.5rem 4rem; }

.wrap { max-width: 72rem; margin: 0 auto; }

.kicker {
  margin: 0 0 0.4rem;
  color: var(--gold);
  font-variant: small-caps;
  letter-spacing: 0.16em;
  font-size: 0.85rem;
}

h1 {
  font-weight: 500;
  font-size: clamp(2.4rem, 5vw, 4.2rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
}

.lede {
  max-width: var(--measure);
  font-size: 1.3rem;
  line-height: 1.45;
}

h2 {
  font-weight: 500;
  font-size: 1.7rem;
  margin: 2.4rem 0 0.6rem;
  letter-spacing: -0.015em;
}

h3 {
  font-weight: 500;
  font-size: 1.25rem;
  margin: 1.8rem 0 0.4rem;
}

p { max-width: var(--measure); }

.tree, pre, code {
  font-family: "Cascadia Code", "Segoe UI Mono", ui-monospace, monospace;
  font-size: 0.86rem;
}

.tree, pre {
  background: var(--paper-2);
  border-left: 3px solid var(--red);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  max-width: 100%;
  line-height: 1.45;
}

code {
  background: var(--paper-2);
  padding: 0.05em 0.28em;
}

pre code { background: none; padding: 0; }

.table-scroll { overflow-x: auto; max-width: 100%; margin: 1rem 0 1.4rem; }

table {
  border-collapse: collapse;
  width: max-content;
  min-width: min(100%, 36rem);
  font-size: 0.98rem;
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.4rem 0.9rem 0.4rem 0;
  border-bottom: 1px solid var(--line);
}

th {
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.spec {
  display: grid;
  grid-template-columns: var(--nav) minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
}

.toc {
  position: sticky;
  top: 4.5rem;
  font-size: 0.92rem;
  max-height: calc(100vh - 6rem);
  overflow: auto;
  padding-right: 0.5rem;
}

.toc p {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-variant: small-caps;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
}

.toc a {
  display: block;
  color: var(--ink);
  text-decoration: none;
  padding: 0.18rem 0;
}

.toc a.sub { padding-left: 0.8rem; color: var(--muted); }
.toc a:hover { color: var(--red); }

.article h1 { font-size: clamp(2rem, 4vw, 3.1rem); }
.article h2 { scroll-margin-top: 5rem; }
.article h3 { scroll-margin-top: 5rem; }

.file-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  max-width: 40rem;
}

.file-list li { border-bottom: 1px solid var(--line); }

.file-list a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--ink);
  text-decoration: none;
  padding: 0.35rem 0;
  font-family: "Cascadia Code", "Segoe UI Mono", ui-monospace, monospace;
  font-size: 0.86rem;
}

.file-list a:hover { color: var(--red); }
.file-list span { color: var(--muted); }

.license {
  white-space: pre-wrap;
  max-width: 42rem;
  border-left-color: var(--ink);
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.2rem 1.5rem 2rem;
  color: var(--muted);
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-footer a { color: var(--muted); }

@media (max-width: 800px) {
  .spec { grid-template-columns: 1fr; }
  .toc { position: static; max-height: none; border-bottom: 1px solid var(--line); padding-bottom: 1rem; }
  .site-header { align-items: flex-start; flex-direction: column; }
}

@media print {
  .site-header, .toc, .skip, .site-footer { display: none; }
  body { background: white; }
  a { color: inherit; text-decoration: none; }
  pre, .tree { border-left-color: black; }
}
