:root {
  --ink: #17221d;
  --muted: #56655e;
  --page: #fbfcfb;
  --panel: #eef3f0;
  --rule: #cbd6d0;
  --green: #1e4d3b;
  --link: #0f6b55;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e4ebe7; --muted: #9fb0a8; --page: #121916; --panel: #1b2520;
    --rule: #2e3c35; --green: #7fc4a4; --link: #8fd6b6;
  }
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 5rem); }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 400 1.125rem/1.7 var(--serif);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--link); text-underline-offset: 0.18em; }
a:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 2px; }

/* Header */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: var(--page); border-bottom: 1px solid var(--rule);
}
.bar {
  max-width: 72rem; margin: 0 auto; padding: 0.85rem 1.25rem;
  display: flex; align-items: center; gap: 2rem; font-family: var(--sans);
}
.brand { font-weight: 600; font-size: 1.05rem; color: var(--green); text-decoration: none; white-space: nowrap; }
.brand span { font-weight: 400; color: var(--muted); }
.docs { display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; }
.docs::-webkit-scrollbar { display: none; }
.docs a {
  font-size: 0.9rem; color: var(--muted); text-decoration: none; white-space: nowrap;
  padding: 0.35rem 0.7rem; border-radius: 999px;
}
.docs a:hover { color: var(--ink); background: var(--panel); }
.docs a[aria-current="page"] { color: var(--page); background: var(--green); }

/* Layout */
.layout {
  max-width: 72rem; margin: 0 auto; padding: 2.5rem 1.25rem 4rem;
  display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 3.5rem;
}
.toc { position: sticky; top: 5.5rem; align-self: start; max-height: calc(100vh - 7rem); overflow-y: auto; font-family: var(--sans); }
.toc-h { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.6rem; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc a {
  display: flex; gap: 0.6rem; padding: 0.3rem 0 0.3rem 0.9rem; margin-left: -1px;
  font-size: 0.875rem; line-height: 1.35; color: var(--muted); text-decoration: none;
  border-left: 2px solid transparent;
}
.toc a span { min-width: 2.1rem; color: var(--green); font-variant-numeric: tabular-nums; }
.toc a:hover { color: var(--ink); border-left-color: var(--green); }

main { min-width: 0; max-width: 42rem; }
h1 {
  font: 500 clamp(2.1rem, 4.5vw, 3rem)/1.1 var(--serif);
  letter-spacing: -0.015em; margin: 0 0 1.25rem; color: var(--ink);
}
.meta { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; margin: 0 0 0.75rem; font-family: var(--sans); font-size: 0.9rem; }
.meta div { display: flex; gap: 0.4rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; font-weight: 500; }
.pin {
  font-family: var(--sans); font-size: 0.875rem; color: var(--muted);
  background: var(--panel); padding: 0.7rem 0.9rem; border-radius: 6px; margin: 0 0 2.5rem;
  overflow-wrap: anywhere;
}

/* Document body: clause numbers hang in the margin like a statute */
.doc h3 {
  position: relative; font: 600 1.2rem/1.35 var(--sans); color: var(--ink);
  margin: 2.75rem 0 0.75rem; padding-top: 1.25rem; border-top: 1px solid var(--rule);
}
.doc h3 .num {
  position: absolute; left: -4.25rem; width: 3.5rem; text-align: right;
  color: var(--green); font-weight: 500; font-variant-numeric: tabular-nums;
}
.doc p, .doc li { max-width: 66ch; }
.doc ol, .doc ul { padding-left: 1.4rem; }
.doc li { margin: 0.35rem 0; }
.doc li::marker { color: var(--green); font-family: var(--sans); font-size: 0.95em; }
.doc strong { font-weight: 600; }

.tablewrap { overflow-x: auto; margin: 1.25rem 0 1.5rem; border: 1px solid var(--rule); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; font: 400 0.9rem/1.5 var(--sans); }
th, td { text-align: left; vertical-align: top; padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--rule); }
th { background: var(--panel); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

.foot { margin-top: 4rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); font: 0.85rem/1.5 var(--sans); color: var(--muted); }
.hash code { font-size: 0.78rem; word-break: break-all; overflow-wrap: anywhere; }
main { width: 100%; }

/* Hub */
.hub { max-width: 42rem; margin: 0 auto; padding: 3rem 1.25rem 4rem; }
.lead { color: var(--muted); max-width: 60ch; }
.list { list-style: none; padding: 0; margin: 2rem 0 0; border-top: 1px solid var(--rule); }
.list li { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.list a { text-decoration: none; font-size: 1.2rem; }
.list a strong { font-weight: 500; }
.list span { font: 0.85rem/2 var(--sans); color: var(--muted); }

@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 1.75rem; }
  .toc { display: none; }
  main { margin: 0 auto; }
  .doc h3 .num { position: static; display: inline-block; width: auto; margin-right: 0.6rem; }
}
@media (max-width: 640px) {
  body { font-size: 1.0625rem; }
  .bar { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
  .docs { width: 100%; }
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
@media print {
  .top, .toc, .pin { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .layout { display: block; padding: 0; }
  .doc h3 .num { position: static; margin-right: 0.5rem; }
  a { color: #000; }
}
