/* Linked only from pages with formulas, after KaTeX's stylesheet. Headings are
   uppercase, but a formula's letters must keep their case. */
.markdown-body .katex, .markdown-body .katex-error { text-transform: none; }
.markdown-body .katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; scrollbar-width: thin; scrollbar-color: var(--dim) transparent; }
/* Padding on the scrolled box itself is not reachable at the end of the scroll. */
.markdown-body .katex-display > .katex { display: inline-block; min-width: 100%; padding: 0 4px; }
/* An inline formula that cannot break (matrix, long \text) scrolls with its paragraph instead of being cut off. */
.markdown-body :is(p, .li-text, td, th):has(> .katex) { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scrollbar-color: var(--dim) transparent; }
.markdown-body .li-text { display: block; }
/* A sub/superscript's 2px spacer can poke past the line end and make the paragraph scroll for nothing. */
.markdown-body :is(p, .li-text):has(> .katex) { padding-inline-end: 2px; margin-inline-end: -2px; }
/* KaTeX pins an equation number to the visible right edge, over a formula that has to
   scroll: lay it out after the formula instead. Both sides grow from zero, so the formula
   stays centred until the number (gap included in its minimum width) needs the room. */
.markdown-body .katex-display > .katex > .katex-html:has(> .katex-tag) { display: flex; align-items: baseline; width: max-content; min-width: 100%; }
.markdown-body .katex-display > .katex > .katex-html:has(> .katex-tag)::before { content: ''; flex: 1 0 0; }
.markdown-body .katex-display > .katex > .katex-html > .katex-tag { position: static; flex: 1 0 0; text-align: right; }
.markdown-body .katex-display > .katex > .katex-html > .katex-tag::before { content: ''; display: inline-block; width: 1em; }
.markdown-body .math-nobr { white-space: nowrap; }
