/* ── The site's own measurements ──────────────────────────────────
   Wider than `--ui-container`: documentation reads in two columns —
   a navigation tree and an article — where an application screen is
   one. The three surfaces are named so `_template.md` can retint
   them per theme without touching a rule. */
:root {
	--kb-max-width: 75rem;
	--kb-sidebar-width: 16.25rem;
	--kb-nav-background: var(--ui-surface-raised);
	--kb-sidebar-background: transparent;
	--kb-hero-background: var(--ui-surface-sunken);
	/* what a table widened past the prose measure keeps clear of
	   the content column's right edge (and its scrollbar) */
	--kb-table-gutter: var(--ui-space-large);

	/* Code-block colours (CodeHighlighter's `hl-*` classes), drawn from
	   the system's semantic tokens so both themes and the site's accent
	   come for free; `_template.md`'s `code-*-color` keys retint them.
	   Types are the accent mixed with red, because the system's info
	   blue is the default accent's blue. "Variable" is also a JSON or
	   YAML key and a shell `$VAR`. */
	--kb-code-comment: var(--ui-text-subtle);
	--kb-code-keyword: var(--ui-accent-text);
	--kb-code-type: color-mix(in oklab, var(--ui-accent-text), var(--ui-danger-text));
	--kb-code-string: var(--ui-success-text);
	--kb-code-number: var(--ui-warning-text);
	--kb-code-meta: var(--ui-text-muted);
	--kb-code-variable: var(--ui-info-text);
}

/* ── The frame ────────────────────────────────────────────────────
   The page itself never scrolls: the bar and the footer stay put and
   the two columns scroll independently, so a reader loses neither
   the article they are in nor the tree around it. */
html {
	height: 100vh;
	overflow: hidden;
}

body {
	height: 100vh;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

/* The two panes scroll with the shared system's `ui-scroll`, which is
   also where their scrollbar treatment comes from — the generator
   puts the class on both, so there is no second opinion here about
   what a scrollbar looks like. */

/* ── Navigation bar ───────────────────────────────────────────────
   The bar is `.ui-navbar` from the shared system; these rules only
   place it and hold the parts the system has no component for.

   Two rules hold for ANY bar, the generated one and a site's own
   `_navbar.html` alike: it sits at the top of the frame, and it takes
   the documentation site's background (and the rule beneath it) — the
   one thing a borrowed bar is expected to change. Everything else here is the GENERATED bar's
   own measurements (it is the bar with `.nav-inner` in it), so a
   custom bar keeps the height, padding and placement it has on the
   site it was borrowed from. */
.ui-navbar {
	background: var(--kb-nav-background);
	/* The rule under the bar is drawn against THIS site's background,
	   so it takes this site's border colour too — a borrowed bar that
	   brings its own rule in its own background's colour (engeene's
	   does) would otherwise vanish against ours. */
	border-block-end-color: var(--ui-border);
	position: sticky;
	top: 0;
	z-index: var(--ui-z-sticky);
}

.ui-navbar:has(> .nav-inner) {
	/* Stated rather than left to the tallest thing in the bar: an
	   application that serves pages of its own beside this site
	   repeats the bar there, and can only match a height that is
	   a number. */
	--ui-navbar-height: 4rem;
	/* The bar spans the window; `.nav-inner` is what holds the
	   content to the page's measure, so the padding belongs there
	   and not on both. */
	padding-inline: 0;
}

.nav-inner {
	max-width: var(--kb-max-width);
	margin: 0 auto;
	width: 100%;
	display: flex;
	align-items: center;
	gap: var(--ui-space-normal);
	padding-inline: var(--ui-space-normal);
}

/* Tone and size are `ui-muted ui-text-sm` on the element itself; only
   its place in the bar is decided here. */
.nav-heading {
	flex: 1;
	text-align: center;
}

.nav-heading p {
	margin-bottom: 0;
	display: inline;
}

.nav-buttons {
	display: flex;
	gap: var(--ui-space-small);
	align-items: center;
}

/* Pushed to the far end of the generated bar. In a custom bar the
   markup's own layout places the slot — a second auto margin there
   would split the free space with the bar's own hamburger. */
.nav-inner > .nav-buttons {
	margin-inline-start: auto;
}

/* In a custom bar the controls are the bar's own flex items: a
   wrapper there would add one more gap even with nothing in it shown
   (the sidebar button is a phone's, the site menu pinned outside the
   bar), and the bar would no longer lay out as on its own site. */
.ui-navbar:not(:has(.nav-inner)) .nav-buttons {
	display: contents;
}

/* ── Language menu ────────────────────────────────────────────────
   A <details> whose summary is a shared ghost button; the list drops
   below it, over the page, and scrolls when the languages are many. */
/* The shared system draws every <details> as a card; in the bar it
   is only the button, so the card is taken off again. */
.language-menu {
	position: relative;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
}

.language-menu > summary {
	cursor: pointer;
}

.language-menu[open] > summary {
	margin-block-end: 0;
}

/* The shared disclosure arrow sits before the text and points sideways,
   which is right for a section that unfolds in place. A menu that drops
   down says so with a chevron after its label. */
.language-menu > summary::before {
	display: none;
}

.language-menu > summary::after {
	content: "";
	flex: none;
	border-inline: 4px solid transparent;
	border-block-start: 5px solid currentColor;
	color: var(--ui-text-muted);
	transition: transform var(--ui-transition);
}

.language-menu[open] > summary::after {
	transform: rotate(180deg);
}

.language-menu > ul {
	position: absolute;
	inset-inline-end: 0;
	top: 100%;
	z-index: var(--ui-z-sticky);
	min-width: 10rem;
	max-height: 70vh;
	overflow-y: auto;
	margin: var(--ui-space-1) 0 0;
	padding: var(--ui-space-small);
	list-style: none;
	background: var(--ui-surface-raised);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-sm);
}

/* ── Site menu ────────────────────────────────────────────────────
   A square, icon-only ghost button (sliders, "settings") opening a panel of
   the site's own settings — the theme today. It is the last of the
   bar's controls; script.js reveals it (it is written `hidden`) and,
   when the window leaves room right of the bar's content, `pinned`
   takes it out of the bar's flow to the window's right edge, centred
   on the bar (the script sets `top` and `height` to the bar's), so a
   borrowed bar lays out exactly as on its own site. A <details>, so
   the shared card look is taken off as for the language menu. */
.site-menu {
	position: relative;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	/* its button's width, never a row of the bar's own */
	flex: none;
	width: max-content;
}

.site-menu[hidden] {
	display: none;
}

.site-menu > summary {
	width: 2.5rem;
	height: 2.5rem;
	padding: 0;
	justify-content: center;
	list-style: none;
	cursor: pointer;
}

.site-menu > summary::-webkit-details-marker,
.site-menu > summary::before,
.site-menu > summary::after {
	display: none;
}

.site-menu[open] > summary {
	margin-block-end: 0;
}

.site-menu.pinned {
	position: fixed;
	inset-inline-end: 0;
	display: flex;
	align-items: center;
	padding-inline: var(--ui-space-small);
	z-index: calc(var(--ui-z-sticky) + 1);
}

.site-menu-panel {
	position: absolute;
	inset-inline-end: 0;
	top: 100%;
	z-index: var(--ui-z-popover);
	min-width: 12rem;
	margin: var(--ui-space-1) 0 0;
	padding: var(--ui-space-small);
	background: var(--ui-surface-raised);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-sm);
	box-shadow: var(--ui-shadow-md);
}

.site-menu.pinned > .site-menu-panel {
	inset-inline-end: var(--ui-space-small);
}

.site-menu-heading {
	margin: 0 0 var(--ui-space-1);
	padding-inline: var(--ui-space-small);
	color: var(--ui-text-muted);
	font-size: var(--ui-text-small);
}

/* one row per choice, a check mark before the one in use */
.site-menu-item {
	width: 100%;
	justify-content: flex-start;
}

.site-menu-item::before {
	content: "";
	width: 1em;
	flex: none;
}

.site-menu-item[aria-pressed="true"] {
	--ui-btn-color: var(--ui-accent-text);
}

.site-menu-item[aria-pressed="true"]::before {
	content: "\2713";
}

/* ── Search ───────────────────────────────────────────────────────
   The box at the top of the sidebar (written hidden, revealed by
   script.js, so a reader without JavaScript never sees a box that
   does nothing) and its results, dropping below it over the page
   like the language menu's list — wider than the column, so they
   overlap the article rather than squeezing into the tree. */
.search {
	position: relative;
	flex-shrink: 0;
	margin-block-end: var(--ui-space-normal);
}

.search[hidden],
.search-results[hidden] {
	display: none;
}

.search input {
	width: 100%;
}

.search-results {
	position: absolute;
	inset-inline-start: 0;
	top: 100%;
	z-index: var(--ui-z-popover);
	width: min(32rem, calc(100vw - 2 * var(--ui-space-normal)));
	max-height: 70vh;
	overflow-y: auto;
	margin: var(--ui-space-1) 0 0;
	padding: var(--ui-space-small);
	list-style: none;
	background: var(--ui-surface-raised);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-sm);
	box-shadow: var(--ui-shadow-lg);
}

.search-results a {
	display: block;
	padding: var(--ui-space-small);
	border-radius: var(--ui-radius-sm);
	color: var(--ui-text);
	text-decoration: none;
}

.search-results a:hover,
.search-results [aria-selected="true"] a {
	background: var(--ui-surface-hover);
}

.search-result-title {
	display: block;
	font-weight: var(--ui-weight-medium);
}

.search-result-snippet,
.search-empty {
	display: block;
	font-size: var(--ui-text-small);
	color: var(--ui-text-muted);
}

.search-empty {
	padding: var(--ui-space-small);
}

.search-results mark {
	background: var(--ui-accent-soft);
	color: inherit;
	border-radius: var(--ui-radius-sm);
}

/* ── The two columns ──────────────────────────────────────────── */
.container {
	max-width: var(--kb-max-width);
	margin: 0 auto;
	padding: var(--ui-space-none) var(--ui-space-normal);
	display: flex;
	gap: var(--ui-space-12);
	flex: 1;
	width: 100%;
	overflow: hidden;
	min-height: 0;
}

/* The column is the search box over the tree. Only the tree
   scrolls: the box stays at the top, and its results may spill
   out of the column over the article instead of being clipped by
   a scrolling parent. */
.sidebar {
	width: var(--kb-sidebar-width);
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	min-height: 0;
	background: var(--kb-sidebar-background);
	padding-block-start: var(--ui-space-normal);
}

.sidebar > nav {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding-block-end: var(--ui-space-large);
}

/* A section of the tree is a `<details>`, and the shared system draws
   a `<details>` as a bordered card on a raised surface — right for a
   disclosure in a form, wrong for a column of navigation, which
   would become a stack of cards. So the chrome comes off here. Its
   *marker* stays: the shared triangle that rotates on open is
   exactly what a tree wants, and this file used to draw a second one
   of its own. */
.sidebar details {
	border: none;
	background: none;
	padding: 0;
	margin: var(--ui-space-1) var(--ui-space-none);
}

.sidebar details:first-child {
	margin-top: 0;
}

.sidebar details[open] > summary {
	margin-block-end: var(--ui-space-1);
}

/* Sentence case, deliberately: the shared design system upper-cases
   nothing, and a knowledgebase ships in languages where upper-casing
   DESTROYS information — Turkish dotted/dotless i, German ß, every
   accented Greek vowel. The tracking went with it; it existed only to
   make the upper-cased run legible. */
.sidebar summary {
	font-size: var(--ui-text-small);
	color: var(--ui-text-muted);
	cursor: pointer;
	padding: 0;
	user-select: none;
}

.sidebar summary:hover {
	color: var(--ui-text);
}

.sidebar ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.sidebar li {
	margin: var(--ui-space-1) var(--ui-space-none);
}

/* Every article link is the shared `ui-nav-link`, including its
   hover and its `[aria-current]` state — so "you are here" looks the
   same in a knowledgebase sidebar as in an application's navigation.
   The one thing added is filling the column: the shared component is
   built for a row of links in a bar. */
.sidebar .ui-nav-link {
	display: block;
}

/* A section's own link is a `ui-nav-link` too, so hovering it fills the
   row with the shared hover surface and never underlines it, and being
   on the section's page marks it current exactly like an article. It
   sits beside the shared disclosure triangle, which still folds the
   section without leaving the page. */
.sidebar .section-link {
	display: inline-block;
	color: var(--ui-text);
	font-weight: var(--ui-weight-bold);
}

.sidebar a:hover {
	text-decoration: none;
}

/* A section's articles sit under its heading, not flush with the
   root articles beside the disclosure triangle. */
.sidebar details > ul {
	padding-inline-start: var(--ui-space-normal);
}

.sidebar details details {
	padding-left: var(--ui-space-small);
}

.content {
	flex: 1;
	min-width: 0;
	overflow-y: auto;
	padding-block: var(--ui-space-normal) var(--ui-space-large);
	container-type: inline-size;
}

/* ── Tables ───────────────────────────────────────────────────────
   Every table is written in the shared `.ui-table-scroll`
   (KnowledgebaseMarkdownRenderer.wrapTables). One that needs more
   room than the prose measure takes it from the content column
   (`100cqi`, measured by `.content` above) instead of wrapping every
   cell; only one wider than the column scrolls — on its own, never
   the article. Either stops `--kb-table-gutter` short of the column's
   right edge, so it never runs into the scrollbar, and short of the
   strip the table of contents takes (`--kb-toc-room`, set by script.js
   on the column while the window leaves room for it). A narrow table
   still fills the measure, and one in a list or a quote stays inside it. `.content` is a size container,
   so nothing inside it may be `position: fixed` (the term panel
   lives on `<body>`). */
.content article > .ui-table-scroll {
	width: max-content;
	min-width: 100%;
	max-width: calc(100cqi - var(--kb-table-gutter) - var(--kb-toc-room, 0px));
}

/* A Markdown column alignment (`---:`, `:---:`) is written as the
   cell's `align` attribute, a presentational hint that the theme's
   `th, td { text-align: start }` would otherwise override — and an
   inline `style` is refused under a `style-src 'self'` policy. */
.content th[align="right"], .content td[align="right"] {
	text-align: end;
}

.content th[align="center"], .content td[align="center"] {
	text-align: center;
}

/* ── Landing page ──────────────────────────────────────────────────
   Only a base with no articles at all has one of its own: the root
   otherwise opens the first article of the navigation.

   The hero carries `ui-surface-sunken`; `--kb-hero-background` is
   here only so a template can retint that one block without
   retinting every sunken surface on the site. */
.hero {
	background: var(--kb-hero-background);
	padding: var(--ui-space-10);
	border-radius: var(--ui-radius-lg);
	margin-bottom: var(--ui-space-10);
}

.hero h1 {
	margin-block: var(--ui-space-none) var(--ui-space-small);
}

.hero p {
	color: var(--ui-text-muted);
	font-size: var(--ui-text-large);
	margin-bottom: 0;
}

/* ── Article ──────────────────────────────────────────────────────
   The article element carries `ui-prose ui-markdown ui-markdown-spacious`:
   the measure is `ui-prose`, and the vertical rhythm of the RENDERED
   markdown — every heading, paragraph, list, quote, `code` and `pre` — is
   `ui-markdown`, opened up by `ui-markdown-spacious` because an article
   is the whole page rather than a note in a card. More or less air above
   a heading, between paragraphs or around a picture is a change to that
   variant in `theme.css`, never a margin here.
   The generator emits those children, so nothing at the call site can
   put a class on them and the rhythm has to be stated by element,
   which is exactly what that component is for. This file used to be
   the third copy of it (beside an application's markdown viz and a
   marketing site's legal pages); it states none of it now.

   Left here: deep-linking only. The `h4`–`h6` continuation this file
   carried as a gap-filler is gone — `ui-theme` scales the whole
   outline now, so keeping a local copy would make this the second
   opinion the paragraph above says it no longer is. */
article h1[id], article h2[id], article h3[id],
article h4[id], article h5[id], article h6[id] {
	scroll-margin-top: var(--ui-space-normal);
}

/* The actions `script.js` appends to every article heading: `#` links to the
   heading and copies that link, the copy icon copies the section. Both show
   a check mark once the clipboard took it. Each sits in a fixed 1em square,
   so the `#`, the copy icon and the check mark are all one size and the
   swap never moves the heading. `.ui-markdown a` underlines every link in
   the article, so the selectors are qualified to outrank it. */
.heading-actions {
	margin-left: var(--ui-space-small);
	font-weight: var(--ui-weight-normal);
	white-space: nowrap;
	opacity: 0;
	transition: opacity var(--ui-transition);
}

.heading-actions .heading-action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: content-box;
	width: 1em;
	height: 1em;
	vertical-align: middle;
	padding: 0 0.15em;
	border: 0;
	background: none;
	font: inherit;
	color: var(--ui-text-muted);
	text-decoration: none;
	cursor: pointer;
	opacity: 0.6;
}

/* outlines: the shared system fills every button svg */
.heading-actions .heading-action svg {
	flex: none;
	width: 0.8em;
	height: 0.8em;
	fill: none;
}

article h1:hover .heading-actions,
article h2:hover .heading-actions,
article h3:hover .heading-actions,
article h4:hover .heading-actions,
article h5:hover .heading-actions,
article h6:hover .heading-actions,
.heading-actions:focus-within,
.heading-actions .copied {
	opacity: 1;
}

.heading-actions .heading-action:hover,
.heading-actions .heading-action:focus-visible,
.heading-actions .copied {
	opacity: 1;
	color: var(--ui-text);
}

/* ── Page and article furniture ─────────────────────────────────── */
.page-header {
	flex: 1;
	text-align: center;
}

.page-footer {
	border-top: 1px solid var(--ui-border);
	padding: var(--ui-space-small) var(--ui-space-normal);
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: var(--ui-space-normal);
}

.page-footer-right {
	text-align: right;
}

.page-header p,
.page-footer p,
.page-footer-right p {
	margin-bottom: 0;
	font-size: var(--ui-text-small);
	color: var(--ui-text-muted);
}

.page-header p {
	display: inline;
}

.article-header {
	border-bottom: 1px solid var(--ui-border);
	padding-bottom: var(--ui-space-normal);
	margin-bottom: var(--ui-space-normal);
}

.article-footer {
	border-top: 1px solid var(--ui-border);
	padding-top: var(--ui-space-normal);
	margin-top: var(--ui-space-large);
}

.article-nav {
	display: flex;
	justify-content: space-between;
	margin-top: var(--ui-space-12);
	padding-top: var(--ui-space-normal);
	border-top: 1px solid var(--ui-border);
	gap: var(--ui-space-normal);
}

.article-nav a {
	font-weight: var(--ui-weight-medium);
}

.article-nav-next {
	margin-left: auto;
}

/* ── Selection highlight for #text= links ──────────────────────────
   Deliberately not the accent: this marks where the *reader's* link
   pointed, which is a different fact from what the site considers
   current, and it has to stay legible over both themes' ink. */
.text-fragment-highlight {
	background: rgba(255, 200, 0, 0.4);
	border-radius: var(--ui-radius-sm);
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .text-fragment-highlight {
		background: rgba(255, 200, 0, 0.25);
	}
}

[data-theme="dark"] .text-fragment-highlight {
	background: rgba(255, 200, 0, 0.25);
}

/* Centred by `ui-center` on the element; this is the room around it. */
.not-found {
	padding: var(--ui-space-16) var(--ui-space-none);
}

.not-found h1 {
	margin-bottom: var(--ui-space-normal);
}

/* ── Code blocks ──────────────────────────────────────────────────
   A fence naming a known language is coloured at build time
   (CodeHighlighter): each token is a span with one of these
   classes. The block around them is the shared system's. */
.hl-comment { color: var(--kb-code-comment); font-style: italic; }
.hl-keyword, .hl-tag { color: var(--kb-code-keyword); }
.hl-type, .hl-attr { color: var(--kb-code-type); }
.hl-string { color: var(--kb-code-string); }
.hl-number { color: var(--kb-code-number); }
.hl-meta { color: var(--kb-code-meta); }
.hl-variable { color: var(--kb-code-variable); }

/* The copy button `script.js` puts over the top right corner of every
   code block, picture and diagram (each wrapped in `.code-block` /
   `.picture-block` so the button stays put while a long line or a wide
   diagram scrolls): shown while the block is hovered or the button
   focused or confirming, and always on a screen that cannot hover.
   It is a fixed square — the shared icon button's aspect ratio loses to
   the line height and draws it tall and narrow — of 2.25rem (36 px), and
   2.75rem (44 px, the usual touch target) under a coarse pointer. */
.code-block,
.picture-block {
	position: relative;
}

.picture-block {
	width: fit-content;
	max-width: 100%;
}

.picture-block:has(> .diagram) {
	width: auto;
}

.code-block .copy-button,
.picture-block .copy-button {
	position: absolute;
	top: var(--ui-space-small);
	right: var(--ui-space-small);
	width: 2.25rem;
	height: 2.25rem;
	padding: 0;
	opacity: 0;
	transition: opacity var(--ui-transition);
}

/* the shared hover tint (--ui-accent-soft) is translucent, so over a
   picture the image showed through the button; lay it over the
   opaque raised surface instead */
.code-block .copy-button:hover,
.picture-block .copy-button:hover {
	background: linear-gradient(var(--ui-accent-soft), var(--ui-accent-soft)), var(--ui-surface-raised);
}

/* the icons are outlines; the shared system fills every button svg */
.copy-button svg {
	width: 1.25rem;
	height: 1.25rem;
	fill: none;
}

.code-block:hover .copy-button,
.picture-block:hover .copy-button,
.copy-button:focus-visible,
.copy-button.copied {
	opacity: 1;
}

@media (hover: none) {
	.code-block .copy-button,
	.picture-block .copy-button {
		opacity: 1;
	}
}

@media (pointer: coarse) {
	.code-block .copy-button,
	.picture-block .copy-button {
		width: 2.75rem;
		height: 2.75rem;
	}
}

/* ── Diagrams ─────────────────────────────────────────────────────
   A ```mermaid fence is a figure holding inline SVG
   (KnowledgebaseDiagrams). When the reader's browser draws it, the
   source's code-block chrome comes off once drawn; a diagram wider
   than the article scrolls inside its figure instead of widening
   the page. */
.diagram {
	overflow-x: auto;
	text-align: center;
}

.diagram .mermaid[data-processed] {
	background: none;
	border: none;
	padding: var(--ui-space-none);
	white-space: normal;
}

.diagram svg {
	max-width: 100%;
	height: auto;
	margin-inline: auto;
}

/* A D2 drawing (D2Renderer) opens with a rectangle in its theme's
   background; the page's own surface shows through instead. */
.diagram .d2-svg > rect:first-child {
	fill: transparent;
}

/* The rules a D2 drawing's own <style> carried — dropped from the SVG
   so it draws under style-src 'self' (D2Renderer). Its text is set in
   the article's font, as a Mermaid diagram is. */
.diagram .d2-svg text {
	font-family: var(--ui-font-sans);
}

.diagram .d2-svg .text-bold,
.diagram .d2-svg .text-mono-bold {
	font-weight: var(--ui-weight-bold);
}

.diagram .d2-svg .text-italic,
.diagram .d2-svg .text-mono-italic {
	font-style: italic;
}

.diagram .d2-svg .text-mono,
.diagram .d2-svg .text-mono-bold,
.diagram .d2-svg .text-mono-italic {
	font-family: var(--ui-font-mono);
}

.diagram .d2-svg .shape {
	shape-rendering: geometricPrecision;
	stroke-linejoin: round;
}

.diagram .d2-svg .connection {
	stroke-linecap: round;
	stroke-linejoin: round;
}

.diagram .d2-svg .blend {
	mix-blend-mode: multiply;
	opacity: 0.5;
}

/* A D2 shape with a link (D2Renderer) reads as a link: its label in
   the link colour (made to read on the accent's own tint, which is
   the box's fill) and underlined, as a link in prose is; its border
   in the accent on hover; a focus ring for the keyboard. */
.diagram a text.text,
.diagram a text.text-bold {
	fill: var(--ui-accent-text);
	text-decoration: underline;
}

.diagram a:hover .shape > *,
.diagram a:focus-visible .shape > * {
	stroke: var(--ui-accent);
}

.diagram a:focus-visible {
	outline: 2px solid var(--ui-accent-ring);
	outline-offset: 2px;
}

/* The hero: the picture under an article's opening paragraph, at
   the column's full width. With a video it is a link that plays it
   (script.js swaps in the player) and carries a play icon in its
   bottom right corner. */
.article-hero {
	margin: var(--ui-space-normal) 0 var(--ui-space-large);
}

.article-hero img {
	display: block;
	max-width: 100%;
	height: auto;
}

.article-hero-play {
	position: relative;
	display: block;
	width: fit-content;
	max-width: 100%;
	border-radius: var(--ui-radius-lg);
}

.article-hero-play:focus-visible {
	outline: 2px solid var(--ui-accent-ring);
	outline-offset: 2px;
}

.article-hero-play-icon {
	position: absolute;
	right: var(--ui-space-normal);
	bottom: var(--ui-space-normal);
	display: flex;
	align-items: center;
	justify-content: center;
	width: calc(var(--ui-icon-large) * 2);
	height: calc(var(--ui-icon-large) * 2);
	border-radius: var(--ui-radius-full);
	background: var(--ui-accent);
	color: var(--ui-accent-contrast);
	box-shadow: var(--ui-shadow-md);
	transition: transform 0.15s ease, background 0.15s ease;
}

.article-hero-play-icon svg {
	width: var(--ui-icon-large);
	height: var(--ui-icon-large);
}

.article-hero-play:hover .article-hero-play-icon,
.article-hero-play:focus-visible .article-hero-play-icon {
	background: var(--ui-accent-hover);
	transform: scale(1.08);
}

.article-hero-player {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	border: 0;
	border-radius: var(--ui-radius-lg);
	background: var(--ui-surface-sunken);
}

video.article-hero-player {
	aspect-ratio: auto;
	height: auto;
}

/* A diagram drawn at build time carries an SVG per theme
   (DiagramBrowser); only the page's own theme's is shown — the same
   three-way choice as the palette: the toggle's pick, else the
   system's. */
.diagram-dark,
:root[data-theme="dark"] .diagram-light {
	display: none;
}

:root[data-theme="dark"] .diagram-dark {
	display: block;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .diagram-light {
		display: none;
	}

	:root:not([data-theme="light"]) .diagram-dark {
		display: block;
	}
}

/* ── Explained terms ──────────────────────────────────────────────
   A `.term` (KnowledgebaseExplanations) looks like the text around it.
   Selecting text that holds one opens the panel script.js places in
   the empty gutter beside the article — fixed, sized and placed by
   the script, one property at a time, never over the article. */
.term-panel {
	position: fixed;
	z-index: var(--ui-z-popover);
	overflow-y: auto;
	padding: var(--ui-space-normal);
	background: var(--ui-surface-raised);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-sm);
	box-shadow: var(--ui-shadow-md);
	font-size: var(--ui-text-small);
}

.term-panel[hidden] {
	display: none;
}

/* "Selection" with the heading actions' two buttons on its right, always shown */
.term-panel-heading {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--ui-space-small);
	margin: 0 0 var(--ui-space-small);
	color: var(--ui-text-muted);
}

.term-panel .heading-actions {
	margin-left: 0;
	opacity: 1;
}

.term-panel dl {
	margin: 0;
}

.term-panel dt {
	font-weight: var(--ui-weight-bold);
}

.term-panel dd {
	margin: 0 0 var(--ui-space-small);
}

.term-panel dd:last-child {
	margin-bottom: 0;
}

.term-panel dd p {
	margin: 0;
}

/* ── Table of contents ────────────────────────────────────────────
   The article's `##` / `###` headings, which script.js lists in the
   same empty gutter the term panel uses — fixed at the top of the
   column, sized and placed by the script, hidden when there is no
   room and while the term panel is open. The section being read is
   `aria-current`. */
.toc-panel {
	position: fixed;
	overflow-y: auto;
	font-size: var(--ui-text-small);
}

.toc-panel[hidden] {
	display: none;
}

.toc-panel-heading {
	margin: 0 0 var(--ui-space-small);
	color: var(--ui-text-muted);
	font-weight: var(--ui-weight-bold);
}

.toc-panel ul {
	margin: 0;
	padding: 0;
	list-style: none;
	border-left: 1px solid var(--ui-border);
}

.toc-panel a {
	display: block;
	margin-left: -1px;
	padding: var(--ui-space-1) 0 var(--ui-space-1) var(--ui-space-small);
	border-left: 2px solid transparent;
	color: var(--ui-text-muted);
	text-decoration: none;
}

.toc-panel .toc-level-3 a {
	padding-left: calc(2 * var(--ui-space-small) + var(--ui-space-1));
}

.toc-panel a:hover {
	color: var(--ui-text);
}

.toc-panel a[aria-current] {
	border-left-color: var(--ui-accent);
	color: var(--ui-accent-text);
	font-weight: var(--ui-weight-semibold);
}

/* ── Mobile ───────────────────────────────────────────────────────
   The hamburger is a shared ghost button that simply does not exist
   on a wide screen.

   The breakpoint is the shared system's phone pair, `width < 48rem`
   (`theme.css` § 1) — the query its `.ui-navbar-collapse` folds on.
   It was `max-width: 768px`, which differs at exactly 768 px and at
   any browser default font size other than 16 px, so a custom bar
   could show its desktop links over a phone-layout sidebar. */
.menu-toggle {
	display: none;
}

@media (width < 48rem) {
	html, body {
		height: auto;
		overflow: auto;
	}

	.menu-toggle {
		display: inline-flex;
	}

	.nav-heading,
	.page-header {
		display: none;
	}

	.container {
		flex-direction: column;
		padding: var(--ui-space-normal);
		overflow: visible;
		min-height: 0;
	}

	.sidebar {
		display: none;
		width: 100%;
		border-bottom: 1px solid var(--ui-border);
		padding-bottom: var(--ui-space-normal);
		margin-bottom: var(--ui-space-normal);
		overflow-y: visible;
	}

	.sidebar-open .sidebar {
		display: flex;
	}

	.sidebar > nav {
		overflow-y: visible;
	}

	.content {
		overflow-y: visible;
	}

	.hero {
		padding: var(--ui-space-normal);
	}

	.article-nav {
		flex-direction: column;
	}
}
