:root {
  --ink: #12211b;
  --muted: #5d6964;
  --paper: #f7f8f4;
  --panel: #ffffff;
  --line: #d9ded4;
  --green: #075f48;
  --red: #a03d3d;
  --rm-bg: #fbeceb;
  --ad-bg: #e7f4ec;
  --highlight-bg: #e3eee7;
  --code-bg: #eceee7;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e4e9e4;
    --muted: #97a29c;
    --paper: #101613;
    --panel: #161e1a;
    --line: #2a3630;
    --green: #4fd6a0;
    --red: #e08b8b;
    --rm-bg: #2c1c1d;
    --ad-bg: #123024;
    --highlight-bg: #20352b;
    --code-bg: #1d2723;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 24px;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 920px;
  margin: 0 auto;
  padding: 72px 0 96px;
}

/* ---------- typography ---------- */

h1 {
  margin: 8px 0 0;
  font-size: 40px;
  line-height: 1.12;
  letter-spacing: -0.03em;
  font-weight: 640;
}

h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--green);
}

h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 650;
}

p { margin: 12px 0; }

mark {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--highlight-bg);
  color: inherit;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

mark code {
  padding: 0;
  background: transparent;
}

.meta, .eyebrow {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.lede {
  font-size: 19px;
  line-height: 1.55;
  color: var(--muted);
  margin-top: 18px;
}

.page-header { padding-bottom: 8px; }

section {
  padding-top: 40px;
  margin-top: 40px;
  border-top: 1px solid var(--line);
}

.caption, footer p {
  font-size: 13px;
  color: var(--muted);
}

footer {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* ---------- inline code ---------- */

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  white-space: pre;
}

/* ---------- summary rules ---------- */

ol.rules {
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: rule;
}

ol.rules li {
  counter-increment: rule;
  position: relative;
  padding: 0 0 0 38px;
  margin-bottom: 14px;
}

ol.rules li::before {
  content: counter(rule, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 1px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
}

/* ---------- tables ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 22px 0;
  font-size: 14px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.reference-table code,
.mapping code,
.coverage-table code {
  white-space: normal;
  overflow-wrap: anywhere;
}

.reference-table td:first-child { width: 27%; }
.endpoint-matrix td:nth-child(2) { width: 19%; }
.endpoint-matrix td:nth-child(3) { width: 24%; }
.parameter-table td:first-child { width: 17%; }
.parameter-table td:nth-child(2) { width: 18%; }
.parameter-table td:nth-child(3) { width: 21%; }
.coverage-table td:first-child { width: 39%; }

.status {
  display: inline-block;
  margin: 5px 0 0 2px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font: 9px/1.6 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.note {
  margin-top: 18px;
  padding: 13px 15px;
  border-left: 3px solid var(--green);
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
}

.examples {
  margin: 20px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.examples > div {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(220px, 1fr);
  gap: 20px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}

.examples > div:last-child { border-bottom: 0; }

.examples code {
  padding: 0;
  background: none;
  color: var(--green);
  white-space: normal;
  overflow-wrap: anywhere;
}

.examples span {
  color: var(--muted);
  font-size: 13px;
}

thead th {
  text-align: left;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 12px 8px 0;
  border-bottom: 1px solid var(--line);
}

td {
  vertical-align: top;
  padding: 12px 12px 12px 0;
  border-bottom: 1px solid var(--line);
}

td:last-child, th:last-child { padding-right: 0; }

.map td:first-child { font-weight: 600; width: 27%; }

.map small {
  display: block;
  font-weight: 400;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
  margin-top: 3px;
}

.map code, .sizes td, .pages code {
  white-space: normal;
  overflow-wrap: anywhere;
}

code.old, td.old { color: var(--red); }
code.new, td.new { color: var(--green); }
.sizes td.old, .sizes td.new { font-family: var(--mono); font-weight: 600; }
.sizes td:last-child { color: var(--muted); }

.pages td:first-child { width: 34%; }
.pages code { display: inline-block; margin: 0 6px 4px 0; }

/* ---------- endpoint families ---------- */

.families {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 28px;
}

.families div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.families h3 {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.families code {
  display: block;
  background: none;
  padding: 0;
  font-size: 12.5px;
  line-height: 1.9;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* ---------- diff ---------- */

.response-shapes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 32px;
}

.response-shapes > div { min-width: 0; }

.response-shapes > div > p {
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.response-shapes > div > p code {
  white-space: normal;
  overflow-wrap: anywhere;
}

.json-example {
  min-height: 100%;
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--green);
  font: 12.5px/1.7 var(--mono);
}

.diff {
  margin: 24px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.diff figcaption,
.diff-file {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.legend { display: flex; gap: 12px; font-style: normal; }
.legend i { font-style: normal; }
.legend .rm { color: var(--red); }
.legend .ad { color: var(--green); }

.diff-body {
  padding: 10px 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.75;
}

.diff-body > span {
  display: block;
  width: max-content;
  min-width: 100%;
  padding-right: 14px;
  white-space: pre;
}

.diff-body > span i {
  display: inline-block;
  width: 26px;
  padding-left: 10px;
  font-style: normal;
  opacity: 0.75;
}

.diff-body .del {
  color: var(--red);
  background: var(--rm-bg);
  box-shadow: inset 2px 0 0 var(--red);
}

.diff-body .add {
  color: var(--green);
  background: var(--ad-bg);
  box-shadow: inset 2px 0 0 var(--green);
}

.diff-body .gap { min-height: 10px; }

.l {
  white-space: pre;
  width: max-content;
  min-width: 100%;
  padding-right: 14px;
}

.l i {
  display: inline-block;
  width: 26px;
  padding-left: 10px;
  font-style: normal;
  opacity: 0.75;
}

.l.rm { background: var(--rm-bg); box-shadow: inset 2px 0 0 var(--red); }
.l.ad { background: var(--ad-bg); box-shadow: inset 2px 0 0 var(--green); }

.k { color: var(--green); }
.s { color: var(--muted); }
.n { font-weight: 600; }
.l.rm .k, .l.rm .s, .l.rm .n { color: var(--red); }

/* ---------- contract notes ---------- */

.notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 24px;
}

.notes div {
  border-top: 2px solid var(--green);
  padding-top: 12px;
}

.notes p {
  margin: 6px 0 10px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
}

.notes > div > code {
  display: block;
  font-size: 12px;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* ---------- aside ---------- */

.aside {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  border-radius: 0 8px 8px 0;
  padding: 16px 18px;
  font-size: 14.5px;
  line-height: 1.6;
}

/* ---------- definition list ---------- */

dl { margin: 22px 0 0; }

.decisions > div {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 18px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.decisions dt { margin: 2px 0 0; }
.decisions dd { margin: 0; }

dt {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--green);
  margin-top: 16px;
}

dd {
  margin: 4px 0 0;
  font-size: 14.5px;
  line-height: 1.6;
}

/* ---------- questions ---------- */

ol.questions {
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: q;
}

ol.questions li {
  counter-increment: q;
  position: relative;
  padding: 0 0 0 38px;
  margin-bottom: 20px;
}

ol.questions li::before {
  content: counter(q, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 2px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

ol.questions p {
  margin: 4px 0 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  body { padding: 0 18px; }
  main { padding: 44px 0 64px; }
  h1 { font-size: 30px; }
  .lede { font-size: 17px; }
  .families, .notes { grid-template-columns: 1fr; gap: 14px; }

  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--line); padding: 14px 0; }
  td { border: none; padding: 2px 0; }
  .map td:first-child, .pages td:first-child { width: auto; margin-bottom: 6px; }
  .sizes td::before {
    content: attr(data-label);
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
    color: var(--muted);
    margin-right: 8px;
  }

  .reference-table td,
  .mapping td,
  .coverage-table td { margin-top: 5px; }

  .reference-table td::before,
  .mapping td::before,
  .coverage-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 1px;
    color: var(--muted);
    font: 10px/1.5 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .reference-table td:first-child,
  .endpoint-matrix td:nth-child(2),
  .endpoint-matrix td:nth-child(3),
  .parameter-table td:first-child,
  .parameter-table td:nth-child(2),
  .parameter-table td:nth-child(3),
  .coverage-table td:first-child { width: auto; }

  .examples > div { grid-template-columns: 1fr; gap: 3px; }
  .response-shapes { grid-template-columns: 1fr; }
  .decisions > div { grid-template-columns: 1fr; gap: 3px; }
}

@media print {
  body { background: #fff; }
  section { break-inside: avoid; }
}
