:root {
  --bg: #f3efe4;
  --bg-2: #e8e0ce;
  --paper: #fffaf1;
  --ink: #1b1712;
  --muted: #5d574c;
  --rule: #d5ccb6;
  --accent: #8c2f18;
  --accent-ink: #fffaf1;
  --forest: #1e3d30;
  --warn-bg: #f4e3b6;
  --warn-ink: #3a2a0e;
  --ok-bg: #dce8dc;
  --focus: #8c2f18;
  --shadow: 0 1px 0 rgba(27, 23, 18, 0.06);
  --max: 72rem;
  --prose: 42rem;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; display: block; }
a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { color: #6d2412; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap { width: min(var(--max), calc(100% - 2rem)); margin-inline: auto; }
.prose { max-width: var(--prose); }
.prose p, .prose li { max-width: 65ch; }

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 20;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

.topbar {
  background: var(--ink);
  color: #f3efe4;
  font-size: 0.875rem;
  letter-spacing: 0.01em;
}
.topbar .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  padding: 0.45rem 0;
}
.topbar a { color: #f4e3b6; }
.topbar strong { font-weight: 650; }

header.site {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 8;
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
}
.brand {
  color: inherit;
  text-decoration: none;
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
  flex: 0 0 auto;
}
.brand span { display: block; font-family: inherit; }
.brand small {
  display: block;
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.15rem;
}
nav.primary { display: flex; flex-wrap: wrap; gap: 0.15rem 0.15rem; justify-content: flex-end; }
nav.primary a, nav.primary summary {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
}
nav.primary a:hover, nav.primary a[aria-current="page"] {
  background: var(--bg-2);
}
nav.primary details { position: relative; }
nav.primary summary { list-style: none; cursor: pointer; }
nav.primary summary::-webkit-details-marker { display: none; }
nav.primary details div {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 0.6rem;
  padding: 0.4rem;
  min-width: 13rem;
  box-shadow: 0 8px 24px rgba(27, 23, 18, 0.08);
}
nav.primary details a { display: block; border-radius: 0.4rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  font-weight: 650;
  font-size: 0.95rem;
  line-height: 1.2;
  padding: 0.7rem 1.05rem;
  border-radius: 0.45rem;
  border: 0;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.btn:hover { background: #6d2412; color: var(--accent-ink); }
.btn-forest { background: var(--forest); }
.btn-forest:hover { background: #13281f; color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
}
.btn-ghost:hover { background: var(--ink); color: var(--bg); }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.1rem 0; }

.hero {
  padding: 2.4rem 0 1.5rem;
  border-bottom: 1px solid var(--rule);
}
.hero h1, h1 {
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  font-size: clamp(1.85rem, 4vw, 2.7rem);
  margin: 0 0 0.8rem;
}
.lede { font-size: 1.15rem; color: var(--muted); margin: 0 0 1rem; max-width: 60ch; }
.kicker {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 650;
  margin: 0 0 0.5rem;
}

main { padding: 1.75rem 0 3rem; }
h2 {
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 2rem 0 0.7rem;
}
h3 { font-size: 1.12rem; margin: 1.5rem 0 0.45rem; }
p { margin: 0 0 1rem; }
ul, ol { margin: 0 0 1rem; padding-left: 1.2rem; }
li { margin: 0 0 0.35rem; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

.callout, .warn, .note {
  border-radius: 0.6rem;
  padding: 0.95rem 1.05rem;
  margin: 1.1rem 0 1.3rem;
}
.callout { background: var(--ok-bg); }
.warn { background: var(--warn-bg); color: var(--warn-ink); }
.note { background: var(--bg-2); }
.callout p, .warn p, .note p { margin-bottom: 0.4rem; }
.callout p:last-child, .warn p:last-child, .note p:last-child { margin-bottom: 0; }

.code {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  background: var(--ink);
  color: #f4e3b6;
  padding: 0.12rem 0.4rem;
  border-radius: 0.3rem;
  font-size: 0.95em;
}

.grid-2, .grid-3, .cards {
  display: grid;
  gap: 1rem;
  margin: 1.2rem 0 1.6rem;
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 0.7rem;
  padding: 1.05rem 1.1rem;
}
.card h3 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.2rem;
  font-size: 0.95rem;
  background: var(--paper);
}
th, td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
th { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

.tool {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 0.8rem;
  padding: 1.15rem;
  margin: 1rem 0 1.5rem;
}
.tool fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 0.9rem;
}
.tool label {
  display: block;
  font-size: 0.82rem;
  font-weight: 650;
  margin: 0 0 0.3rem;
}
.tool input, .tool select, .tool button {
  font: inherit;
}
.tool input[type="text"],
.tool input[type="number"],
.tool select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 0.4rem;
  background: #fff;
  color: var(--ink);
}
.fields { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
.result {
  background: var(--forest);
  color: #f3efe4;
  border-radius: 0.55rem;
  padding: 0.9rem 1rem;
  margin-top: 0.6rem;
}
.result strong { color: #fff; }
.result .err { color: #f4e3b6; }
.leg-row {
  display: grid;
  grid-template-columns: 8.5rem 1fr auto;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
  align-items: end;
}
.muted { color: var(--muted); }
.tiny { font-size: 0.88rem; color: var(--muted); }

footer.site {
  background: var(--ink);
  color: #d9d3c4;
  padding: 2rem 0 2.4rem;
  font-size: 0.92rem;
}
footer.site a { color: #f4e3b6; }
footer.site h2, footer.site h3 {
  color: #f3efe4;
  font-size: 0.95rem;
  font-family: inherit;
  margin: 0 0 0.5rem;
}
footer.site .cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1.2rem 2rem;
  margin-bottom: 1.4rem;
}
footer.site ul { list-style: none; padding: 0; margin: 0; }
footer.site li { margin: 0 0 0.3rem; }
.legal { border-top: 1px solid #3a342b; padding-top: 1rem; }
.legal p { margin: 0 0 0.55rem; max-width: 80ch; }

.toc { columns: 2; gap: 1.5rem; max-width: 40rem; }
.toc { list-style: none; padding: 0; }
.toc li { break-inside: avoid; }

@media (max-width: 800px) {
  nav.primary { display: none; }
  .mobile-nav { display: block; }
  .leg-row { grid-template-columns: 1fr; }
  .toc { columns: 1; }
}
@media (min-width: 801px) {
  .mobile-nav { display: none; }
}

.mobile-nav details summary {
  cursor: pointer;
  font-weight: 650;
  padding: 0.35rem 0.2rem;
}
.mobile-nav div { display: flex; flex-direction: column; padding: 0.4rem 0 0.6rem; }
.mobile-nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--rule);
}
