/* Datasheet
   Posts are versioned documents: numbered, revised, with numbered sections,
   figures and tables. Colour has two jobs only:
   signal blue = you can follow it, redline = it changed or needs attention. */

/* Fonts ------------------------------------------------------------------ */
/* font-display: fallback waits ~100ms for a font before drawing text. Cached
   or local fonts arrive within that, so pages appear in their final font
   instead of flashing a fallback and reflowing, which "swap" does. */

/* Sofia Sans for running text; Sofia Sans Condensed, a separate family rather
   than a width axis, for headings, tables and labels. Both cover Latin and
   Cyrillic. Each family's faces share the same weight range and differ only
   by unicode-range, which is what lets the browser combine them into one font. */

@font-face {
  font-family: "Sofia Sans";
  src: url("fonts/sofia-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 1 1000;
  font-style: normal;
  font-display: fallback;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Sofia Sans";
  src: url("fonts/sofia-sans-cyrillic-wght-normal.woff2") format("woff2");
  font-weight: 1 1000;
  font-style: normal;
  font-display: fallback;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Sofia Sans";
  src: url("fonts/sofia-sans-latin-wght-italic.woff2") format("woff2");
  font-weight: 1 1000;
  font-style: italic;
  font-display: fallback;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Sofia Sans";
  src: url("fonts/sofia-sans-cyrillic-wght-italic.woff2") format("woff2");
  font-weight: 1 1000;
  font-style: italic;
  font-display: fallback;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Sofia Sans Condensed";
  src: url("fonts/sofia-sans-condensed-latin-wght-normal.woff2") format("woff2");
  font-weight: 1 1000;
  font-style: normal;
  font-display: fallback;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Sofia Sans Condensed";
  src: url("fonts/sofia-sans-condensed-cyrillic-wght-normal.woff2") format("woff2");
  font-weight: 1 1000;
  font-style: normal;
  font-display: fallback;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* Iosevka for code, split like Sofia Sans: Latin and Cyrillic files with the
   same weights, so Cyrillic in code stays monospaced. */
@font-face {
  font-family: "Iosevka";
  src: url("fonts/iosevka-400.woff2") format("woff2");
  font-weight: 400;
  font-display: fallback;
  unicode-range: U+0000-00FF, U+2010-2027, U+2190-21FF, U+2212, U+2500-257F;
}
@font-face {
  font-family: "Iosevka";
  src: url("fonts/iosevka-cyrillic-400.woff2") format("woff2");
  font-weight: 400;
  font-display: fallback;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Iosevka";
  src: url("fonts/iosevka-700.woff2") format("woff2");
  font-weight: 700;
  font-display: fallback;
  unicode-range: U+0000-00FF, U+2010-2027, U+2190-21FF, U+2212, U+2500-257F;
}
@font-face {
  font-family: "Iosevka";
  src: url("fonts/iosevka-cyrillic-700.woff2") format("woff2");
  font-weight: 700;
  font-display: fallback;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* Tokens ----------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  --paper: #FFFFFF;
  --ink: #000000;
  --ink-2: #4A5059;     /* secondary text: abstracts, captions */
  --faded: #5E6470;     /* labels in the title block, meta */
  --grid: #C4C7CC;      /* table rules */
  --cell: #EEF0F2;      /* header cells, code */
  --cell-2: #E2E5E9;    /* file-name strip above code */
  --signal: #0047AB;    /* you can follow it */
  --redline: #C8102E;   /* changed, or needs attention */
  --mark: #D6E4FA;

  --sans: "Sofia Sans", "Helvetica Neue", Arial, sans-serif;
  --sans-condensed: "Sofia Sans Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --mono: "Iosevka", ui-monospace, "Cascadia Mono", "DejaVu Sans Mono", monospace;

  --measure: 38rem;     /* about 80 characters of body text; wider gets harder to read */
  --num-col: 4.5rem;    /* section numbers and change bars, wide screens */
  --margin-col: 18rem;  /* title block, footnotes, sidenotes; wide screens */
  --gap: 2.5rem;
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1C1E22;
    --ink: #E6E8EB;
    --ink-2: #A9AFB8;
    --faded: #9AA1AD;
    --grid: #3A3E45;
    --cell: #262A30;
    --cell-2: #2F343B;
    --signal: #6FA8FF;
    --redline: #FF6B6B;
    --mark: #23406B;
  }
}

/* Base ------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Reserve the scrollbar's space on every page, so short pages without one
     don't shift sideways and change width compared to long pages. */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.125rem;  /* Sofia Sans is narrow; 18px keeps lines near 80 characters */
  line-height: 1.6;
  font-kerning: normal;
}

::selection { background: var(--signal); color: var(--paper); }

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

a {
  color: var(--signal);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}
a:hover { text-decoration-thickness: 2px; }

mark { background: var(--mark); color: var(--ink); padding: 0 0.1em; }

img, svg { max-width: 100%; height: auto; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -3rem;
  background: var(--signal);
  color: var(--paper);
  padding: 0.3rem 0.6rem;
}
.skip:focus { top: 0.5rem; }

/* Page frame ------------------------------------------------------------- */

.wrap {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

@media (min-width: 68rem) {
  .wrap {
    max-width: calc(var(--num-col) + var(--measure) + var(--gap) + var(--margin-col) + 2 * var(--gutter));
  }
  /* Body text sits right of the number column; headers and registers use the full width. */
  .doc > .prose, .doc > .toc, .doc > .notice, .doc > .revisions, .doc > .doc-foot {
    margin-left: var(--num-col);
  }
  .doc > .prose > *, .doc > .toc, .doc > .notice, .doc > .revisions, .doc > .doc-foot,
  .intro, .doc-head .abstract {
    max-width: var(--measure);
  }
  /* Everything in the text column shares its edges; the margin only holds notes
     about it: the title block, footnotes, sidenotes, and figure captions, which
     sit beside the foot of their image. */
  .doc > .prose > figure.fig {
    max-width: calc(var(--measure) + var(--gap) + var(--margin-col));
    display: grid;
    grid-template-columns: var(--measure) var(--margin-col);
    column-gap: var(--gap);
    align-items: end;
  }
  .doc > .prose > figure.fig figcaption { margin-top: 0; }
  /* Title on the left, the title block as a panel in the margin beside it. */
  .doc-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--margin-col);
    column-gap: var(--gap);
    align-items: start;
    margin-bottom: 2.5rem;
  }
  .doc-head .titleblock { margin-bottom: 0; }
}

header.site {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 1.1rem 0.6rem;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 2.5rem;
}
.site-name {
  color: var(--ink);
  font-weight: 800;
  font-family: var(--sans-condensed);
  font-size: 1.3rem;
  text-decoration: none;
}
header.site nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-inline: -0.45rem;
  font-family: var(--sans-condensed);
}
header.site nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 0.1rem 0.45rem;
}
header.site nav a:hover { text-decoration: underline; text-decoration-thickness: 2px; }
header.site nav a[aria-current="page"] {
  background: var(--ink);
  color: var(--paper);
}

footer.site {
  margin-top: 5rem;
  padding-block: 0.9rem 2.5rem;
  border-top: 1px solid var(--grid);
  color: var(--ink-2);
  font-size: 0.85em;
  font-family: var(--sans-condensed);
}

footer.site .store-path { margin-top: 0.4em; }
footer.site .store-path code { overflow-wrap: anywhere; }

/* Tables: registers, revision history, and tables in posts ---------------- */

table {
  border-collapse: collapse;
  font-size: 0.92em;
  font-family: var(--sans-condensed);
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}
th, td {
  border: 1px solid var(--grid);
  padding: 0.4rem 0.6rem;
  text-align: left;
  vertical-align: top;
}
thead th {
  background: var(--cell);
  font-weight: 700;
}
.table-scroll { overflow-x: auto; }
.table-scroll > table { width: 100%; }

/* Markdown tables have no wrapper, so the table scrolls itself. */
.prose table {
  display: block;
  overflow-x: auto;
  width: max-content;
  max-width: 100%;
  margin: 1.4em 0;
}

.register td.no,
.register td.rev,
.register td.date,
.register td.count {
  white-space: nowrap;
}
.register .no { width: 5.5rem; }
.register .rev { width: 3rem; }
.register .date { width: 7rem; }
.register .count { width: 7rem; }
.register .status { width: 6.5rem; }
.register td.no { font-weight: 600; }
.register td.title a { font-weight: 600; text-decoration: none; }
.register td.title a:hover { text-decoration: underline; }
.register td.topic { color: var(--ink-2); }
.register tbody tr:hover { background: var(--cell); }
.register .empty { color: var(--ink-2); }

@media (max-width: 40rem) {
  .register .topic, .register .rev { display: none; }
}

/* Home and section pages ------------------------------------------------- */

.intro { font-size: 1.1em; margin-bottom: 2.5rem; }
.intro p { margin: 0; text-wrap: pretty; }

.register-block h2 {
  font-size: 1.35em;
  font-weight: 800;
  font-family: var(--sans-condensed);
  line-height: 1.2;
  margin: 2.5rem 0 0.6rem;
}
.more { margin-top: 0.6rem; font-family: var(--sans-condensed); }

.page-title,
.doc-head h1 {
  font-size: clamp(2.1rem, 1.5rem + 3vw, 3.4rem);
  font-weight: 800;
  font-family: var(--sans-condensed);
  line-height: 1.02;
  letter-spacing: -0.005em;
  margin: 0 0 0.75rem;
  max-width: 22ch;
  text-wrap: balance;
}
.page-title { margin-bottom: 1.5rem; }

.empty { color: var(--ink-2); }

/* Document header -------------------------------------------------------- */

.doc-head .abstract {
  font-size: 1.15em;
  line-height: 1.45;
  color: var(--ink-2);
  margin: 0 0 1.5rem;
  text-wrap: pretty;
}

/* The title block: a ruled grid of labelled values. Below the wide layout it's
   rows of cells that grow to fill each row, so no row ends in an empty gap. */
.titleblock {
  display: flex;
  flex-wrap: wrap;
  margin: 0 0 2.5rem;
  border-top: 1px solid var(--grid);
  border-left: 1px solid var(--grid);
  font-family: var(--sans-condensed);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.titleblock > div {
  flex: 1 0 auto;
  border-right: 1px solid var(--grid);
  border-bottom: 1px solid var(--grid);
  padding: 0.4rem 0.6rem 0.45rem;
}
.titleblock dt {
  font-size: 0.75rem;
  color: var(--faded);
}
.titleblock dd {
  margin: 0.1rem 0 0;
  font-weight: 600;
  white-space: nowrap;
}
@media (min-width: 68rem) {
  /* In the margin panel: one field per row, label left, value right. */
  .titleblock {
    display: grid;
    grid-template-columns: 1fr;
  }
  .titleblock > div {
    display: grid;
    grid-template-columns: 5.5rem minmax(0, 1fr);
    align-items: baseline;
    padding-block: 0.3rem;
  }
  .titleblock dd { margin: 0; white-space: normal; overflow-wrap: anywhere; }
}

.toc {
  margin-bottom: 2.5rem;
  padding-block: 0.75rem;
  border-block: 1px solid var(--grid);
  font-family: var(--sans-condensed);
}
.toc h2 {
  font-size: 1em;
  font-weight: 700;
  margin: 0 0 0.35rem;
}
.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: toc;
}
.toc ol ol { padding-left: 2.25rem; }
.toc li { counter-increment: toc; }
.toc.numbered li::before {
  content: counters(toc, ".");
  display: inline-block;
  min-width: 2.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--faded);
}

/* Prose ------------------------------------------------------------------ */

.prose { counter-reset: h2 fig tbl sidenote; }
.prose p { margin: 0 0 1em; text-wrap: pretty; }

.prose h2, .prose h3, .prose h4 {
  position: relative;
  line-height: 1.2;
  text-wrap: balance;
}
.prose h2 {
  font-size: 1.5em;
  font-weight: 750;
  font-family: var(--sans-condensed);
  margin: 2.2em 0 0.6em;
  padding-top: 0.45em;
  border-top: 1px solid var(--grid);
}
.prose h3 {
  font-size: 1.15em;
  font-weight: 700;
  font-family: var(--sans-condensed);
  margin: 1.8em 0 0.5em;
}
.prose h4 { font-size: 1em; font-weight: 700; margin: 1.5em 0 0.4em; }

/* Section numbers. Zola inserts an anchor link into each heading; in numbered
   documents the number is the anchor, so every section has a citable link. */
.numbered h2 { counter-increment: h2; counter-reset: h3; }
.numbered h3 { counter-increment: h3; }

.anchor {
  color: var(--signal);
  text-decoration: none;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-right: 0.55em;
}
.anchor::before { content: "#"; }
.numbered h2 .anchor::before { content: counter(h2); }
.numbered h3 .anchor::before { content: counter(h2) "." counter(h3); }
.prose:not(.numbered) .anchor { display: none; }

@media (min-width: 68rem) {
  /* Numbers hang in the number column; the rule above an h2 runs under it too. */
  .doc > .prose :is(h2, h3) {
    margin-left: calc(-1 * var(--num-col));
    padding-left: var(--num-col);
    max-width: calc(var(--measure) + var(--num-col));
  }
  .doc > .prose :is(h2, h3) .anchor {
    position: absolute;
    left: 0;
    margin: 0;
  }
  .doc > .prose:not(.numbered) .anchor { display: inline; opacity: 0; }
  .doc > .prose:not(.numbered) :is(h2, h3):hover .anchor,
  .doc > .prose .anchor:focus-visible { opacity: 1; }
}

.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1em; }
.prose li + li { margin-top: 0.25em; }
.prose li::marker { color: var(--faded); font-variant-numeric: tabular-nums; }
/* Task lists: - [ ] item. The box replaces the bullet. */
.prose li:has(> input[type="checkbox"]) { list-style: none; position: relative; }
.prose li > input[type="checkbox"] {
  position: absolute; left: -1.4em; top: 0.3em;
  width: 0.85em; height: 0.85em; margin: 0;
  accent-color: var(--ink);
}

.prose dl { margin: 0 0 1em; }
.prose dt { font-weight: 700; }
.prose dd { margin: 0 0 0.6em 1.4em; }

.prose blockquote {
  margin: 1.4em 0;
  padding-left: 1rem;
  border-left: 3px solid var(--grid);
  color: var(--ink-2);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--grid);
  margin: 2em 0;
}

/* Callouts: GitHub-style alerts. A coloured bar on the left, the label on
   its own line above the text, so a label of any length fits in any language. */
.prose blockquote[class^="markdown-alert-"] {
  --c: var(--ink);
  margin: 1.5em 0;
  padding: 0.55rem 0.9rem 0.65rem;
  border: 0;
  border-left: 4px solid var(--c);
  background: var(--cell);
  color: var(--ink);
}
.prose blockquote[class^="markdown-alert-"]::before {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--c);
  font-family: var(--sans-condensed);
  font-weight: 700;
  line-height: 1.3;
}
.prose blockquote[class^="markdown-alert-"] > * { margin: 0; }
.prose blockquote[class^="markdown-alert-"] > * + * { margin-top: 0.6em; }
/* Same specificity as the rule above, so these win by coming later. */
.prose blockquote.markdown-alert-note::before { content: "Note"; }
.prose blockquote.markdown-alert-tip::before { content: "Tip"; }
.prose blockquote.markdown-alert-important { --c: var(--signal); }
.prose blockquote.markdown-alert-important::before { content: "Important"; }
.prose blockquote.markdown-alert-warning { --c: var(--redline); }
.prose blockquote.markdown-alert-warning::before { content: "Warning"; }
.prose blockquote.markdown-alert-caution { --c: var(--redline); }
.prose blockquote.markdown-alert-caution::before { content: "Caution"; }

/* Change bars: {% <changed rev="B"> %}…{% </changed> %} ---------------- */

.changed {
  display: block;
  position: relative;
  text-decoration: none;
  padding-left: 0.85rem;
}
.changed::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.15em;
  bottom: 0.2em;
  width: 3px;
  background: var(--redline);
}
@media (min-width: 68rem) {
  .changed { padding-left: 0; }
  .changed::before { left: -1.1rem; }
  .changed::after {
    content: attr(data-rev);
    position: absolute;
    left: -2.3rem;
    top: 0;
    color: var(--redline);
    font-size: 0.8rem;
    font-weight: 700;
    font-family: var(--sans-condensed);
  }
}

/* Figures and numbered tables -------------------------------------------- */

.prose figure { margin: 1.8em 0; }
.prose figure.fig { counter-increment: fig; }
.prose figure.tbl { counter-increment: tbl; }
.prose figure img { display: block; border: 1px solid var(--grid); }
.prose figcaption {
  font-size: 0.9em;
  font-family: var(--sans-condensed);
  line-height: 1.4;
  color: var(--ink-2);
}
.prose figure.fig figcaption { margin-top: 0.5rem; }
.prose figure.tbl figcaption { margin-bottom: 0.4rem; }
.prose figure.tbl table { margin: 0; }
.prose figure.fig figcaption::before {
  content: "Figure " counter(fig) ". ";
  font-weight: 700;
  color: var(--ink);
}
.prose figure.tbl figcaption::before {
  content: "Table " counter(tbl) ". ";
  font-weight: 700;
  color: var(--ink);
}

/* Code ------------------------------------------------------------------- */

code, kbd, samp, pre {
  font-family: var(--mono);
  font-size: 0.88em;
}
:not(pre) > code {
  background: var(--cell);
  padding: 0.05em 0.3em;
  border-radius: 2px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
pre code { font-size: 1em; }

.prose pre {
  --pre-pad: var(--gutter);
  background: var(--cell);
  border-block: 1px solid var(--grid);
  line-height: 1.5;
  tab-size: 4;
  overflow-x: auto;
  margin: 1.4em calc(-1 * var(--gutter));
  padding: 0.8rem var(--pre-pad);
}
@media (min-width: 48rem) {
  .prose pre {
    --pre-pad: 0.9rem;
    margin-inline: 0;
    border-inline: 1px solid var(--grid);
  }
}

/* Required by Zola's highlighter. */
.giallo-l {
  display: inline-block;
  min-height: 1lh;
  width: 100%;
}
.giallo-ln {
  display: inline-block;
  user-select: none;
  margin-right: 0.4em;
  padding: 0 0.4em;
  min-width: 3ch;
  text-align: right;
  color: var(--faded);
}

/* Highlighted lines (hl_lines=...): a signal-blue tint from the theme JSON,
   plus an edge so they still read in greyscale. */
.giallo-l[style*="background"] {
  width: calc(100% + 2 * var(--pre-pad));
  margin-inline: calc(-1 * var(--pre-pad));
  padding-inline: var(--pre-pad);
  box-shadow: inset 3px 0 0 var(--signal);
}

/* File name, from ```lang,name=path — a strip across the top of the block. */
pre code[data-name]::before {
  content: attr(data-name);
  display: block;
  margin: -0.8rem calc(-1 * var(--pre-pad)) 0.7rem;
  padding: 0.25rem var(--pre-pad);
  background: var(--cell-2);
  border-bottom: 1px solid var(--grid);
  color: var(--ink-2);
  font-size: 0.92em;
}

/* Sidenotes -------------------------------------------------------------- */
/* Markup: <label class="sn-ref"><input type="checkbox"></label><span class="sidenote">
   Numbers come from a CSS counter, so notes never need ids. */

.sn-ref {
  counter-increment: sidenote;
  cursor: pointer;
  font-size: 0.7em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  vertical-align: super;
  line-height: 0;
  padding: 0 0.2em;
  margin-left: 0.05em;
  color: var(--signal);
}
.sn-ref::before { content: counter(sidenote); }
.sn-ref input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}
.sn-ref:has(input:focus-visible) {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}
/* Only in the compact layout, where checking actually opens the note. On wide
   screens the label still toggles the hidden checkbox, but nothing unfolds. */
@media not (min-width: 68rem) {
  .sn-ref:has(input:checked) {
    background: var(--signal);
    color: var(--paper);
  }
}

.sidenote {
  display: none;
  font-size: 0.85em;
  font-family: var(--sans-condensed);
  line-height: 1.45;
  color: var(--ink-2);
}
.sidenote::before {
  content: counter(sidenote) "  ";
  white-space: pre;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--signal);
}
.sn-ref:has(input:checked) + .sidenote {
  display: block;
  margin: 0.6em 0 0.8em;
  padding: 0.55em 0.75em;
  background: var(--cell);
  border-left: 3px solid var(--signal);
  animation: open-note 140ms ease-out;
}
@keyframes open-note {
  from { opacity: 0; translate: 0 -0.25em; }
}

@media (min-width: 68rem) {
  .sn-ref { cursor: default; }
  .sn-ref input { display: none; }
  .sidenote,
  .sn-ref:has(input:checked) + .sidenote {
    display: block;
    float: right;
    clear: right;
    width: var(--margin-col);
    margin: 0.25em calc(-1 * (var(--margin-col) + var(--gap))) 1em 0;
    padding: 0 0 0 0.6rem;
    border-left: 1px solid var(--grid);
    background: none;
    animation: none;
  }
}

/* Footnotes in the margin. margin-notes.js copies each [^1] footnote next to
   its reference as a .margin-footnote; on wide screens those show and the
   list at the end hides. Without the script, or on narrow screens, the list stays. */
.margin-footnote::before { content: attr(data-n) "  "; }
@media (min-width: 68rem) {
  .has-margin-footnotes .doc .prose .footnotes { display: none; }
}

/* Footnotes (the [^1] kind) collect at the end of the post. */
.prose .footnotes {
  margin-top: 2.5rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--grid);
  font-size: 0.88em;
  color: var(--ink-2);
}
.prose .footnotes::before {
  content: "Notes";
  display: block;
  font-weight: 700;
  font-family: var(--sans-condensed);
  color: var(--ink);
  margin-bottom: 0.3rem;
}
.prose .footnotes ol { padding-left: 1.4em; margin: 0; }
.prose sup { line-height: 0; font-variant-numeric: tabular-nums; }
.prose sup a { text-decoration: none; font-weight: 700; }

/* Revision history and document footer ----------------------------------- */

.revisions { margin-top: 3rem; }
.revisions h2 {
  font-size: 1.15em;
  font-weight: 750;
  font-family: var(--sans-condensed);
  margin: 0 0 0.5rem;
}
.revisions td:first-child { width: 3rem; font-weight: 700; }
.revisions td:nth-child(2) { width: 7rem; white-space: nowrap; }

.doc-foot {
  margin-top: 3rem;
  padding-top: 0.9rem;
  border-top: 2px solid var(--ink);
  font-family: var(--sans-condensed);
}
.doc-foot p { margin: 0 0 0.5rem; }

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.pager a {
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
}
.pager a:hover { text-decoration: underline; }
.pager a[rel="next"] { grid-column: 2; text-align: right; }
.pager span {
  display: block;
  font-size: 0.85em;
  font-weight: 400;
  color: var(--faded);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 36rem) {
  .pager { grid-template-columns: 1fr; }
  .pager a[rel="next"] { grid-column: 1; text-align: left; }
}

/* Guides ----------------------------------------------------------------- */

.crumbs {
  margin-bottom: 0.6rem;
  font-size: 0.9em;
  font-family: var(--sans-condensed);
  font-variant-numeric: tabular-nums;
}
.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
  margin: 0;
  padding: 0;
  list-style: none;
}
.crumbs li + li::before {
  content: "/";
  margin-right: 0.4em;
  color: var(--faded);
}
.crumbs [aria-current] { color: var(--ink-2); }

.status { white-space: nowrap; }
.status-draft { color: var(--ink-2); }
.status-outdated { color: var(--redline); font-weight: 700; }

/* A banner for draft and outdated guides, above the contents. */
.notice {
  --c: var(--faded);
  margin: -1rem 0 2rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--grid);
  border-left: 4px solid var(--c);
  font-family: var(--sans-condensed);
}
.notice strong { color: var(--c); }
.notice-outdated { --c: var(--redline); }

/* The guides page: one ruled panel per category, two or three across. */
.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  gap: 1.5rem;
  align-items: start;
  margin-bottom: 1.5rem;
}
.shelf-panel {
  border: 1px solid var(--grid);
  font-family: var(--sans-condensed);
}
.shelf-panel header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--cell);
  border-bottom: 1px solid var(--grid);
}
.shelf-panel h2 {
  margin: 0;
  font-size: 1.3em;
  font-weight: 800;
  font-family: var(--sans-condensed);
  line-height: 1.2;
}
.shelf-panel h2 a { color: var(--ink); text-decoration: none; }
.shelf-panel h2 a:hover { text-decoration: underline; }
.shelf-panel header span {
  color: var(--faded);
  font-size: 0.85em;
  white-space: nowrap;
}
.shelf-intro {
  padding: 0.6rem 0.75rem 0;
  color: var(--ink-2);
  font-size: 0.95em;
  line-height: 1.45;
}
.shelf-intro p { margin: 0; }
.shelf-panel ul {
  list-style: none;
  margin: 0;
  padding: 0.4rem 0.75rem 0.6rem;
}
.shelf-panel li {
  display: grid;
  grid-template-columns: 3.75rem minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: baseline;
  padding-block: 0.35rem;
  line-height: 1.35;
}
.shelf-panel li + li { border-top: 1px solid var(--grid); }
.shelf-panel li .no {
  color: var(--faded);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.shelf-panel li a { font-weight: 600; text-decoration: none; }
.shelf-panel li a:hover { text-decoration: underline; }
.shelf-panel li.empty { display: block; color: var(--ink-2); }
.shelf-panel .status { font-size: 0.85em; }
.shelf-more {
  margin: 0;
  padding: 0.45rem 0.75rem;
  border-top: 1px solid var(--grid);
}

/* Landing page ------------------------------------------------------------ */

.landing .prose { margin-bottom: 1rem; }
.landing-block h2 {
  font-size: 1.35em;
  font-weight: 800;
  font-family: var(--sans-condensed);
  line-height: 1.2;
  margin: 2.5rem 0 0.6rem;
}
/* Row headers (channel, section) read as labels, not data. */
.landing-block tbody th {
  background: none;
  font-weight: 700;
  white-space: nowrap;
}
.landing-block tbody th a { text-decoration: none; }
.landing-block tbody th a:hover { text-decoration: underline; }
/* Addresses get copied, so set them in the code face. */
.contacts td.address {
  font-family: var(--mono);
  font-size: 0.9em;
  overflow-wrap: anywhere;
}
@media (min-width: 68rem) {
  .doc.landing > .landing-block { margin-left: var(--num-col); }
}

/* Language switch: set apart from the section links it sits beside. */
header.site nav .lang-switch {
  margin-left: 0.6rem;
  border-left: 1px solid var(--grid);
  padding-left: 0.95rem;
}
@media (max-width: 36rem) {
  /* The nav wraps on phones, and a divider at the start of a line looks stray. */
  header.site nav .lang-switch { margin-left: 0; border-left: 0; padding-left: 0.45rem; }
}

/* Labels that CSS writes, per language. */
:lang(uk) .prose figure.fig figcaption::before { content: "Рисунок " counter(fig) ". "; }
:lang(uk) .prose figure.tbl figcaption::before { content: "Таблиця " counter(tbl) ". "; }
:lang(uk) .prose .footnotes::before { content: "Примітки"; }
:lang(uk) .prose blockquote.markdown-alert-note::before { content: "Примітка"; }
:lang(uk) .prose blockquote.markdown-alert-tip::before { content: "Порада"; }
:lang(uk) .prose blockquote.markdown-alert-important::before { content: "Важливо"; }
:lang(uk) .prose blockquote.markdown-alert-warning::before { content: "Попередження"; }
:lang(uk) .prose blockquote.markdown-alert-caution::before { content: "Обережно"; }

/* Notes ------------------------------------------------------------------ */

.note { margin-top: 2rem; }
.note-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1.25rem;
  margin: 0 0 0.9rem;
  padding: 0.3rem 0.6rem;
  background: var(--cell);
  border: 1px solid var(--grid);
  font-size: 0.9em;
  font-family: var(--sans-condensed);
  font-variant-numeric: tabular-nums;
}
.note-head a { font-weight: 700; }
.note-head time { color: var(--ink-2); }
.note h2 {
  font-size: 1.2em;
  font-weight: 700;
  font-family: var(--sans-condensed);
  margin: 0 0 0.4em;
}

/* Motion and print ------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  header.site nav, .skip, .pager { display: none; }
  body { background: #fff; color: #000; font-size: 10pt; }
  a { color: #000; }
  .sidenote, .sn-ref:has(input:checked) + .sidenote {
    display: inline;
    float: none;
    margin: 0;
    padding: 0;
    width: auto;
    border: 0;
    background: none;
  }
  .sidenote::before { content: " ["; }
  .sidenote::after { content: "]"; }
  /* Print the footnote list once, at the end. */
  .margin-footnote { display: none !important; }
  .has-margin-footnotes .doc .prose .footnotes { display: block; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; }
}
