:root {
	--ink: #141414;
	--paper: #f7f5ef;
	--surface: #ffffff;
	--track: #efeae0;
	--red: #b3261e;
	--red-soft: #e6b8b5;
	--green: #266341;
	--muted: #6b6a66;
	--rule: #dcd9d0;
	--tree-line: #cfc9bc;
	--bar-bg: #ebe7dc;
	--bar-muted: #bdb7a8;
	--bar-ink: #2b2a27;
	--bar-height: 45px;
	--serif: "Latin Modern Roman", "CMU Serif", Georgia, serif;
	--mono: "IBM Plex Mono", ui-monospace, monospace;
}

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

html {
	background: var(--paper);
	color: var(--ink);
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scrollbar-width: thin;
	scrollbar-color: var(--bar-muted) var(--paper);
}

.tree, .outline, pre, .table-wrap, .search-results {
	scrollbar-width: thin;
	scrollbar-color: var(--bar-muted) transparent;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
	background: var(--bar-muted);
	border: 2px solid transparent;
	background-clip: content-box;
	border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
	background: var(--muted);
	border: 2px solid transparent;
	background-clip: content-box;
}
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-button { display: none; }

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font: 17.5px/1.55 var(--serif);
}

a {
	color: var(--ink);
	text-decoration: underline;
	text-decoration-color: var(--red);
	text-underline-offset: 3px;
}

a:hover { color: var(--red); }

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

.skip {
	position: absolute;
	left: -9999px;
}

.skip:focus {
	left: 12px;
	top: 8px;
	z-index: 100;
	background: var(--surface);
	padding: 4px 10px;
	border: 1px solid var(--red);
}

/* Sticky top bar and non-shifting mobile drawer. */
.bar {
	position: sticky;
	top: 0;
	z-index: 30;
	background: var(--paper);
	border-bottom: 1px solid var(--rule);
}

.bar-inner {
	max-width: 48rem;
	min-height: 44px;
	margin: 0 auto;
	padding: 6px 1.25rem;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 1.25rem;
}

.layout-documentation .bar-inner {
	max-width: none;
	padding: 6px 1.5rem;
}

.bar-home {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	text-decoration: none;
	font-style: italic;
	font-size: 1.05rem;
	letter-spacing: 0.01em;
	color: var(--ink);
}

.bar-home img { display: block; }

.bar-menu {
	flex: 1 1 auto;
	min-width: 0;
}

.bar-menu-content {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 1.25rem;
}

.bar-sections ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem 1.15rem;
	font-size: 0.94rem;
}

.bar-sections li { margin: 0; }

.bar-sections a {
	display: inline-block;
	padding: 2px 0;
	text-decoration: none;
	border-bottom: 2px solid transparent;
}

.bar-sections a:hover {
	color: var(--red);
	border-bottom-color: var(--red-soft);
}

.bar-sections a[aria-current="page"] {
	color: var(--red);
	border-bottom-color: var(--red);
}

.bar-menu-button {
	list-style: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	margin-left: auto;
	cursor: pointer;
	color: var(--ink);
	background: var(--surface);
	border: 1px solid var(--rule);
}

.bar-menu-button::-webkit-details-marker { display: none; }

.bar-menu-name {
	position: absolute;
	left: -9999px;
}

.bar-menu-button .icon-close { display: none; }
.bar-menu[open] > .bar-menu-button { border-color: var(--red); color: var(--red); }
.bar-menu[open] > .bar-menu-button .icon-menu { display: none; }
.bar-menu[open] > .bar-menu-button .icon-close { display: block; }

@media (min-width: 720px) {
	.bar-menu[open] > .bar-menu-button { display: none; }
}

@supports selector(::details-content) {
	@media (min-width: 720px) {
		.bar-menu > .bar-menu-button { display: none; }
		.bar-menu::details-content { content-visibility: visible; }
	}
}

/* Global search in top bar. */
.search {
	margin-left: auto;
	position: relative;
}

.search-label {
	position: absolute;
	left: -9999px;
}

.search input {
	width: 210px;
	height: 28px;
	padding: 0 8px;
	font: 13.5px/1 var(--mono);
	color: var(--ink);
	background: var(--surface);
	border: 1px solid var(--rule);
	border-radius: 0;
}

.search input::placeholder { color: var(--muted); opacity: 1; }
.search input:focus { outline: none; border-color: var(--red); }

.search-panel {
	position: absolute;
	right: 0;
	top: 32px;
	z-index: 40;
	width: 440px;
	max-width: calc(100vw - 24px);
	max-height: min(65vh, 420px);
	overflow-y: auto;
	background: var(--surface);
	border: 1px solid var(--rule);
	border-left: 3px solid var(--red);
	box-shadow: 0 8px 24px rgba(20, 20, 20, 0.12);
}

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

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

.search-list li {
	margin: 0;
	border-bottom: 1px solid var(--rule);
}

.search-list li:last-child { border-bottom: none; }

.search-list a {
	display: block;
	padding: 0.45rem 0.7rem;
	text-decoration: none;
	border-left: 2px solid transparent;
}

.search-list a:hover,
.search-list [aria-selected="true"] a {
	background: var(--paper);
	border-left-color: var(--red);
}

.search-row-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.6rem;
}

.search-name {
	font: 13.5px/1.3 var(--mono);
	color: var(--ink);
	overflow-wrap: anywhere;
}

.search-kind {
	font: 11.5px/1.2 var(--mono);
	color: var(--muted);
	white-space: nowrap;
}

.search-doc {
	margin: 0.15rem 0 0;
	font: 13.5px/1.35 var(--serif);
	color: var(--muted);
}

.search-empty {
	margin: 0;
	padding: 0.55rem 0.7rem;
	font: 13px/1.3 var(--mono);
	color: var(--muted);
}

/* Single-column presentation layout (Home). */
.page {
	max-width: 48rem;
	margin: 0 auto;
	padding: 1.5rem 1.25rem 3rem;
}

/* Three-column documentation layout. */
.documentation {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0 2rem;
	padding: 1rem 1.5rem 3rem;
}

.documentation > .text { min-width: 0; }

.text :is(p, li, dt, dd, blockquote, h1, h2, h3, h4) { max-width: 76ch; }
.text :is(td, th) :is(p, li) { max-width: none; }
.text img, .text svg { max-width: 100%; height: auto; }

/* Breadcrumbs. */
.crumbs ol {
	list-style: none;
	margin: 0 0 0.65rem;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem;
	font: 13px/1.4 var(--mono);
	color: var(--muted);
}

.crumbs li { margin: 0; }
.crumbs li + li::before { content: "/"; margin-right: 0.3rem; color: var(--bar-muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--red); text-decoration: underline; }

/* Left sidebar tree + crisp CSS tree lines. */
.tree {
	font: 14px/20px var(--serif);
	color: var(--ink);
}

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

.tree a {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.4rem;
	padding: 2px 8px;
	text-decoration: none;
	border-left: 2px solid transparent;
	overflow-wrap: anywhere;
}

.tree a:hover {
	color: var(--red);
	background: var(--track);
}

.tree a[aria-current="page"] {
	color: var(--red);
	border-left-color: var(--red);
	background: var(--track);
	font-weight: 600;
}

.tree-sections > li { margin-bottom: 0.9rem; }
.tree-sections > li > a { font-style: italic; font-size: 15px; font-weight: 600; }

/* Right sidebar "On this page" outline. */
.outline {
	font: 13.5px/20px var(--serif);
	margin: 0 0 1.1rem;
	padding: 0.5rem 0.75rem;
	background: var(--surface);
	border: 1px solid var(--rule);
}

.outline > summary {
	cursor: pointer;
	font-style: italic;
	color: var(--muted);
}

.outline-title {
	display: none;
	margin: 0 0 0.45rem;
	font-style: italic;
	font-size: 13.5px;
	color: var(--muted);
}

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

.outline a {
	display: block;
	padding: 2px 8px;
	text-decoration: none;
	border-left: 2px solid transparent;
	color: var(--muted);
	overflow-wrap: anywhere;
}

.outline a:hover { color: var(--ink); }

.outline a[aria-current="location"] {
	color: var(--red);
	border-left-color: var(--red);
}

/* Tree lines. */
ul.tree-lines { margin-left: 8px; }
ul.tree-lines > li { position: relative; padding-left: 8px; }

ul.tree-lines > li::before,
ul.tree-lines > li::after {
	content: "";
	position: absolute;
	left: 0;
	border: 0 solid var(--tree-line);
	pointer-events: none;
}

ul.tree-lines > li::before {
	top: 0;
	width: 8px;
	height: 12px;
	border-left-width: 1px;
	border-bottom-width: 1px;
}

ul.tree-lines > li::after {
	top: 12px;
	bottom: 0;
	border-left-width: 1px;
}

ul.tree-lines > li:last-child::after { display: none; }
ul.tree-lines > li:has([aria-current])::before { border-color: var(--red); }
ul.tree-lines > li:has(~ li [aria-current])::before,
ul.tree-lines > li:has(~ li [aria-current])::after { border-left-color: var(--red); }

.tree a:focus-visible, .outline a:focus-visible { position: relative; z-index: 1; }

@media (max-width: 719px) {
	.bar { height: var(--bar-height); }
	.bar-inner,
	.layout-documentation .bar-inner {
		height: var(--bar-height);
		min-height: var(--bar-height);
		padding: 0 1rem;
		flex-wrap: nowrap;
		align-items: center;
		gap: 0.75rem;
	}
	.bar-home { flex-shrink: 0; }
	.bar-menu { flex: 0 0 auto; margin-left: auto; }
	.bar-menu-button { margin-left: 0; }
	.bar-menu[open] > .bar-menu-content {
		position: fixed;
		top: var(--bar-height);
		left: 0;
		right: 0;
		z-index: 29;
		display: flex;
		flex-direction: column;
		align-items: stretch;
		gap: 0.85rem;
		max-height: calc(100dvh - var(--bar-height));
		overflow-y: auto;
		background: var(--paper);
		border-bottom: 1px solid var(--rule);
		padding: 14px 20px 18px;
		box-shadow: 0 12px 28px rgba(20, 20, 20, 0.08);
	}
	.bar-sections ul { flex-direction: column; align-items: stretch; gap: 0.25rem; }
	.bar-sections a { display: block; padding: 4px 0; }
	.search { margin-left: 0; width: 100%; }
	.search input { width: 100%; height: 34px; }
	.search-panel { position: static; width: 100%; max-width: none; margin-top: 4px; box-shadow: none; }
	.layout-documentation .tree {
		padding-top: 0.6rem;
		border-top: 1px solid var(--rule);
	}
}

@media (min-width: 720px) {
	.layout-documentation { padding-left: 256px; }
	.layout-documentation .tree {
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		width: 256px;
		overflow-y: auto;
		padding: 14px 10px 24px;
		background: #f2efe7;
		border-right: 1px solid var(--rule);
	}
}

@media (min-width: 1100px) {
	.documentation { grid-template-columns: minmax(0, 1fr) 240px; }
	.documentation > .text { grid-column: 1; grid-row: 1; }
	.documentation > .outline {
		grid-column: 2;
		grid-row: 1;
		position: sticky;
		top: calc(var(--bar-height) + 12px);
		align-self: start;
		max-height: calc(100vh - var(--bar-height) - 24px);
		overflow-y: auto;
		margin: 0;
		padding: 0.25rem 0 1rem 0.75rem;
		background: transparent;
		border: none;
		border-left: 1px solid var(--rule);
	}
	.outline[open] > summary { display: none; }
	.outline[open] > .outline-title { display: block; }
}

@supports selector(::details-content) {
	@media (min-width: 1100px) {
		.outline > summary { display: none; }
		.outline > .outline-title { display: block; }
		.outline::details-content { content-visibility: visible; }
	}
}

/* Headings and prose. */
h1 { font-weight: normal; font-style: italic; font-size: 2rem; line-height: 1.2; margin: 0 0 0.85rem; }
h2 { font-weight: normal; font-style: italic; font-size: 1.35rem; margin: 2.1rem 0 0.55rem; scroll-margin-top: calc(var(--bar-height) + 16px); }
h3 { font-weight: normal; font-style: italic; font-size: 1.1rem; margin: 1.5rem 0 0.4rem; scroll-margin-top: calc(var(--bar-height) + 16px); }
p { margin: 0 0 1rem; }

.home-head { margin: 0 0 1.6rem; }
.wordmark { display: block; width: min(17rem, 100%); margin: 0 0 0.85rem; }
.tagline { font-size: 1.24rem; font-style: italic; margin: 0 0 0.55rem; }
.home-lead { margin: 0; color: var(--muted); max-width: 40rem; }

.home-index {
	list-style: none;
	padding: 0;
	margin: 2rem 0 2.1rem;
	border-top: 1px solid var(--rule);
}

.home-index li {
	margin: 0;
	padding: 0.9rem 0;
	border-bottom: 1px solid var(--rule);
}

.home-index-title {
	font-size: 1.12rem;
	font-style: italic;
	display: inline-block;
	margin-bottom: 0.2rem;
}

.home-index-desc {
	margin: 0;
	color: var(--muted);
	font-size: 0.95rem;
}

.home-build { margin: 2rem 0 2.1rem; }
.home-build h2 { margin-top: 0; }
.home-build-note { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.95rem; }

.source-list {
	list-style: none;
	padding: 0;
	margin: 0.8rem 0 1.8rem;
	border-top: 1px solid var(--rule);
}

.source-list li {
	margin: 0;
	padding: 0.85rem 0;
	border-bottom: 1px solid var(--rule);
}

.note-callout {
	border-left: 3px solid var(--bar-muted);
	padding: 0.25rem 0 0.25rem 0.9rem;
	margin: 1rem 0 1.4rem;
	color: var(--muted);
	font-size: 0.94rem;
}

code {
	font: 0.84em/1.4 var(--mono);
	background: var(--track);
	padding: 0.06em 0.28em;
	border-radius: 2px;
}

pre {
	background: var(--surface);
	border: 1px solid var(--rule);
	border-left: 3px solid var(--red);
	padding: 0.9rem 1.15rem;
	margin: 1.15rem 0;
	overflow-x: auto;
	font: 14px/1.55 var(--mono);
}

pre code {
	background: transparent;
	padding: 0;
	font: inherit;
}

.eval-out {
	margin: -0.95rem 0 1.25rem;
	padding: 0.45rem 1.15rem;
	background: #faf8f3;
	border: 1px solid var(--rule);
	border-top: none;
	border-left: 3px solid var(--green);
	font: 13px/1.45 var(--mono);
	color: var(--green);
	overflow-x: auto;
}

.eval-out-label {
	color: var(--muted);
	margin-right: 0.5rem;
	user-select: none;
}

.tok-kw  { color: #9e2019; font-weight: 500; }
.tok-dir { color: #7c2d6e; font-weight: 500; }
.tok-ty  { color: #1d5575; }
.tok-fn  { color: #141414; font-weight: 600; }
.tok-lit { color: #266341; }
.tok-op  { color: #6b4c35; font-weight: 500; }
.tok-cm  { color: #6b6a66; font-style: italic; }

/* Hover tooltips (hints.js). */
[data-hint] {
	text-decoration: underline dotted rgba(107, 106, 102, 0.55);
	text-underline-offset: 3px;
	cursor: help;
	border-radius: 2px;
	transition: background 100ms ease;
}

[data-hint]:hover,
[data-hint]:focus-visible,
[data-hint][data-hint-open] {
	background: #f1ecdf;
	outline: none;
}

#hint-tip {
	position: fixed;
	z-index: 1000;
	pointer-events: none;
	user-select: text;
	max-width: min(22rem, calc(100vw - 20px));
	background: #1a1917;
	color: #f7f5ef;
	padding: 0.5rem 0.72rem;
	border-radius: 3px;
	box-shadow: 0 6px 18px rgba(20, 20, 20, 0.22);
	font: 14px/1.45 var(--serif);
	opacity: 0;
	transform: translateY(3px);
	transition: opacity 100ms ease, transform 100ms ease;
}

#hint-tip.visible {
	pointer-events: auto;
	opacity: 1;
	transform: translateY(0);
}

#hint-tip .hint-tok {
	display: inline-block;
	margin-right: 0.45rem;
	font: 600 12.5px/1.2 var(--mono);
	color: #f0b5b1;
}

ul, ol { padding-left: 1.3rem; margin: 0 0 1.2rem; }
li { margin-bottom: 0.35rem; }

/* Home page "For agents" prompt block. */
.agent-section {
	margin: 1.9rem 0 1.8rem;
	padding-top: 1.35rem;
	border-top: 1px solid var(--rule);
}

.agent-heading {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0 0 0.55rem;
}

.agent-heading .icon {
	color: var(--red);
	flex-shrink: 0;
}

.agent-box {
	background: var(--surface);
	border: 1px solid var(--rule);
	border-left: 3px solid var(--red);
	padding: 0.85rem 1rem;
	margin-top: 0.75rem;
}

.agent-prompt {
	margin: 0;
	padding: 0;
	background: transparent;
	border: none;
	overflow-x: visible;
	white-space: pre-wrap;
	word-break: break-word;
	font: 13.5px/1.55 var(--mono);
	color: var(--ink);
}

.agent-prompt code {
	background: transparent;
	padding: 0;
	font: inherit;
	color: inherit;
}

.agent-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.65rem 1rem;
	margin-top: 0.75rem;
	padding-top: 0.7rem;
	border-top: 1px solid var(--rule);
}

.agent-copy {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	height: 30px;
	padding: 0 10px;
	font: 12.5px/1 var(--mono);
	color: var(--ink);
	background: var(--paper);
	border: 1px solid var(--rule);
	cursor: pointer;
	transition: border-color 120ms ease, color 120ms ease;
}

.agent-copy:hover { color: var(--red); border-color: var(--red); }
.agent-copy .icon-check { display: none; }
.agent-copy[data-copied="true"] { color: var(--green); border-color: var(--green); }
.agent-copy[data-copied="true"] .icon-copy { display: none; }
.agent-copy[data-copied="true"] .icon-check { display: inline-block; }

.agent-skill-link {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	font: 12.5px/1.3 var(--mono);
	color: var(--muted);
	text-decoration: none;
	overflow-wrap: anywhere;
}

.agent-skill-link:hover { color: var(--red); text-decoration: underline; }

.table-wrap { overflow-x: auto; margin: 1.15rem 0 1.4rem; }

table {
	width: 100%;
	border-collapse: collapse;
	background: var(--surface);
	border: 1px solid var(--rule);
	font-size: 0.91rem;
}

th, td {
	text-align: left;
	padding: 0.5rem 0.72rem;
	border-bottom: 1px solid var(--rule);
	vertical-align: top;
}

th {
	font-weight: normal;
	font-style: italic;
	color: var(--muted);
	background: #faf8f3;
}

tr:last-child td { border-bottom: none; }

.neighbours {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 0.75rem 1rem;
	margin-top: 2.5rem;
	padding-top: 1.1rem;
	border-top: 1px solid var(--rule);
	font-size: 0.94rem;
}

.neighbours-next { margin-left: auto; }

.foot {
	border-top: 1px solid var(--rule);
	color: var(--muted);
	font-size: 0.88rem;
}

.foot-inner {
	max-width: 48rem;
	margin: 0 auto;
	padding: 1.1rem 1.25rem 2.25rem;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem 1.25rem;
}

.layout-documentation .foot-inner {
	max-width: none;
	padding: 1.1rem 1.5rem 2.25rem;
}

.foot a { color: var(--muted); text-decoration-color: var(--rule); }
.foot a:hover { color: var(--red); text-decoration-color: var(--red); }

@media (max-width: 600px) {
	body { font-size: 16px; }
	.page { padding: 1rem 1rem 2.25rem; }
	.documentation { padding: 0.85rem 1rem 2.25rem; }
	.foot-inner, .layout-documentation .foot-inner { padding: 1rem 1rem 1.75rem; }
	.wordmark { width: min(14.5rem, 74%); margin-bottom: 0.6rem; }
	.tagline { font-size: 1.1rem; margin-bottom: 1rem; }
	h1 { font-size: 1.65rem; }
}
