:root {
  --paper: #F4F1EA;
  --ink: #24383C;
  --preview: #FFFFFF;
  --accent: #B9674F;
  --accent-2: #648B83;
  --panel: #263D42;
  --border: #D7D5CB;
  --muted: #75817D;
  --highlight: #E9DFC4;
  --focus: #B9674F;
  --max: 1260px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent 24px, rgba(36, 56, 60, 0.04) 24px, rgba(36, 56, 60, 0.04) 25px, transparent 25px),
    var(--paper);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.55;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

img, svg { max-width: 100%; height: auto; }

a {
  color: #6F3E31;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  background: var(--panel);
  color: #fff;
  padding: 0.5rem 0.8rem;
  z-index: 20;
}

.skip-link:focus { top: 0.5rem; }

.wrap {
  width: min(100% - 2rem, var(--max));
  margin-inline: auto;
}

.site-header {
  height: 68px;
  border-bottom: 1px solid var(--border);
  background: rgba(244, 241, 234, 0.96);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.wordmark {
  display: grid;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.05;
  color: var(--panel);
  text-decoration: none;
  font-size: 0.92rem;
}

.wordmark span { display: block; }

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 0.4rem 0.7rem;
  font: inherit;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav a {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
}

.section-kicker {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.35rem;
}

h1, h2, h3, h4 {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  font-weight: 650;
  line-height: 1.2;
  color: var(--panel);
}

h1 { font-size: clamp(1.8rem, 3vw, 2.4rem); margin: 0 0 0.6rem; }
h2 { font-size: 1.45rem; margin: 0 0 0.55rem; }
h3 { font-size: 1.12rem; margin: 0 0 0.4rem; }

.lede, .muted { color: var(--muted); }

.page-section {
  padding: 2.4rem 0;
  border-top: 1px solid var(--border);
  position: relative;
}

.page-section::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 0;
  width: 9px;
  height: 9px;
  border: 1px solid var(--muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem 2rem;
}

.note-list, .mistake-list, .ref-list {
  display: grid;
  gap: 1.1rem;
}

.note-card, .mistake-card, .ref-card {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}

.num {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}

.example-row {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: 0.8rem;
  border-top: 1px solid var(--border);
  padding: 1rem 0;
}

.tech-line, code, .encoded-box {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.86rem;
  word-break: break-word;
}

.diagram {
  width: min(100%, 280px);
  background: var(--preview);
  border: 1px solid var(--border);
  padding: 0.7rem;
}

.article-index a { display: block; margin: 0.4rem 0; }

.prose { max-width: 42rem; }
.prose p { margin: 0 0 1rem; }
.prose h2 { margin-top: 1.8rem; }
.prose h3 { margin-top: 1.2rem; }
.prose ul, .prose ol { padding-left: 1.2rem; }

.address {
  font-style: normal;
  white-space: pre-line;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.4rem 0 2rem;
  font-size: 0.9rem;
}

.footer-id {
  font-family: "Iowan Old Style", Palatino, serif;
  margin: 0 0 0.8rem;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  padding: 0;
  margin: 0 0 0.8rem;
  list-style: none;
}

.reg-marks {
  pointer-events: none;
  position: absolute;
  inset: 0.4rem;
  border: 1px dashed rgba(117, 129, 125, 0.35);
}

.btn {
  appearance: none;
  border: 1px solid var(--panel);
  background: var(--panel);
  color: #F4F1EA;
  font: inherit;
  letter-spacing: 0.04em;
  padding: 0.62rem 0.9rem;
  cursor: pointer;
}

.btn:hover { background: #1b2d31; }

.btn-secondary {
  background: transparent;
  color: var(--panel);
}

.btn-secondary:hover { background: var(--highlight); }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.status {
  min-height: 1.4em;
  font-size: 0.92rem;
}

.status.is-error { color: #7A3A2C; }

@media (max-width: 759px) {
  .nav-toggle { display: inline-block; }
  .site-nav {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 68px;
    background: var(--paper);
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 1rem 1rem;
  }
  .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; gap: 0.55rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .example-row { grid-template-columns: 1fr; }
  .btn { width: 100%; }
  .btn-row .btn { width: auto; flex: 1 1 10rem; }
}
