:root {
  --bg: #fbf9f6;
  --text: #241f2b;
  --muted: #655c70;
  --line: #d9d2e3;
  --head-bg: #f0eaf6;
  --accent: #5b2d82;          /* purple: headings, links, the brand */
  --accent-soft: #e9dff3;
  --green: #6f9b3c;           /* the green: small marks only */
  --green-soft: #e3ecd3;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Liberation Serif", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17131d; --text: #e9e4ee; --muted: #a79fb3;
    --line: #3a3144; --head-bg: #241d2e;
    --accent: #c9a9ee; --accent-soft: #2b2238;
    --green: #9cc45f; --green-soft: #26301a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 1.125rem/1.6 var(--serif); }
.wrap { max-width: 42rem; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); text-decoration-color: var(--green); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 0; background: var(--bg); padding: .5rem; z-index: 10; }

.site-header { border-bottom: 3px solid var(--green); background: var(--head-bg); }
.header-inner { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1.5rem; padding-top: .9rem; padding-bottom: .9rem; }
.brand { font-weight: 700; color: var(--accent); text-decoration: none; letter-spacing: .01em; }
.site-header ul { display: flex; gap: 1.1rem; list-style: none; margin: 0; padding: 0; font-size: 1rem; }
.site-header nav a { color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; }
.site-header nav a:hover { color: var(--accent); }
.site-header nav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--green); }

h1 { font-size: 2.1rem; line-height: 1.2; margin: 2.2rem 0 .9rem; color: var(--accent); }
h1::after { content: ""; display: block; width: 3rem; height: 4px; margin-top: .8rem; background: var(--green); border-radius: 2px; }
h2 { font-size: 1.4rem; line-height: 1.25; margin: 2.4rem 0 .7rem; padding-bottom: .25rem; border-bottom: 1px solid var(--line); color: var(--accent); }
h3 { font-size: 1.15rem; margin: 1.6rem 0 .5rem; color: var(--accent); }
h4 { font-size: 1rem; font-style: italic; margin: 1.3rem 0 .4rem; }
p, ul, ol { margin: 0 0 1rem; }
li { margin-bottom: .3rem; }
code { font-family: var(--mono); font-size: .88em; overflow-wrap: anywhere; }
img { max-width: 100%; height: auto; }
/* A figure on its own line: scrolls sideways on a phone, breaks out of the column on a wide screen. */
p:has(> img:only-child) { overflow-x: auto; margin: 1.2rem 0 1.5rem; -webkit-overflow-scrolling: touch; }
p > img:only-child { display: block; min-width: 40rem; margin: 0 auto; border: 1px solid var(--line); border-radius: 12px; }
@media (min-width: 48rem) {
  p:has(> img:only-child) { width: min(100vw - 32px, 60rem); margin-left: calc(50% - min(50vw - 16px, 30rem)); }
  p > img:only-child { min-width: 0; }
}

/* "#" links: faint until the heading or row is hovered; a click copies the address. */
a.anchor { color: var(--muted); text-decoration: none; font-weight: 400; opacity: .35; position: relative; }
h2:hover a.anchor, h3:hover a.anchor, tr:hover a.anchor, a.anchor:focus { opacity: 1; color: var(--green); }
a.anchor.copied::after { content: "copied"; position: absolute; left: 1.2em; top: 0; font-size: .7rem; font-family: var(--mono); color: var(--green); white-space: nowrap; }
:target { scroll-margin-top: 1rem; }
tr:target td { background: var(--green-soft); }
h2:target, h3:target { color: var(--green); }

.table-wrap { overflow-x: auto; margin: .5rem 0 1.2rem; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; font-size: .95rem; line-height: 1.45; min-width: 36rem; width: 100%; }
th, td { border: 1px solid var(--line); padding: .35rem .6rem; vertical-align: top; text-align: left; }
th { background: var(--head-bg); color: var(--accent); border-bottom: 2px solid var(--green); }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--head-bg) 45%, transparent); }
th:first-child, td:first-child { min-width: 8rem; }

.diagram { overflow-x: auto; margin: 1rem 0 1.5rem; }
/* On a wide screen the loop breaks out of the text column, up to 68rem. */
@media (min-width: 48rem) {
  .diagram { width: min(100vw - 32px, 68rem); margin-left: calc(50% - min(50vw - 16px, 34rem)); }
}
pre.mermaid { margin: 0; text-align: center; min-width: 36rem; font-family: var(--mono); font-size: .8rem; }

.site-footer { border-top: 3px solid var(--green); background: var(--head-bg); margin-top: 3.5rem; padding: 1.2rem 0 2.5rem; font-size: .9rem; color: var(--muted); }
.site-footer p { margin: 0 0 .3rem; }
