@font-face {
	font-family: 'CascadiaCode';
	font-style: normal;
	font-weight: 200 700;
	src: url("../fonts/CascadiaCode-VariableFont_wght.ttf") format("truetype");
}

@font-face {
	font-family: 'CascadiaCode';
	font-style: italic;
	font-weight: 200 700;
	src: url("../fonts/CascadiaCode-Italic-VariableFont_wght.ttf") format("truetype");
}

@font-face {
	font-family: 'Madimi One';
	font-style: normal;
	font-weight: normal;
	src: url("../fonts/MadimiOne-Regular.ttf") format("truetype");
}

:root {
	--font-mono: 'CascadiaCode', ui-monospace, Consolas, monospace;
	--font-display: 'Madimi One', system-ui, sans-serif;
	--font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
	--text: #f4f4ec;
	--text-muted: #a8b0c2;
	--text-faded: #3e485d;
	--background: #181c26;
	--surface: #11161f;
	--surface-raised: #1f2532;
	--border: #2c3445;
	--accent: #5ce0fa;
	--error: #ff6b7f;
	--error-background: rgba(255, 107, 127, 0.1);
	--code-teal: #5ce0fa;
	--code-pink: #ff7ac6;
	--code-green: #95ffa1;
	--code-yellow: #ffea61;
	--code-orange: #ffc595;
	--code-purple: #af84ff;
	--shadow: rgba(0, 0, 0, 0.4);
	--topbar-height: 56px;
	--sidebar-width: 290px;
	--toc-width: 230px;
	color-scheme: dark;
}

:root.light-mode {
	--text: #14161c;
	--text-muted: #586178;
	--text-faded: #c5cbd8;
	--background: #ffffff;
	--surface: #f4f4ec;
	--surface-raised: #f0f1f4;
	--border: #dfe2e8;
	--accent: #1e8094;
	--error: #c4223b;
	--error-background: rgba(196, 34, 59, 0.08);
	--code-teal: #1e8094;
	--code-pink: #ad397b;
	--code-green: #339b3f;
	--code-yellow: #8a7a0c;
	--code-orange: #b1682c;
	--code-purple: #5a34a2;
	--shadow: rgba(0, 0, 0, 0.12);
	color-scheme: light;
}

* {
	box-sizing: border-box;
}

html {
	-webkit-font-smoothing: antialiased;
	scroll-padding-top: calc(var(--topbar-height) + 16px);
}

body {
	margin: 0;
	color: var(--text);
	background: var(--background);
	font-family: var(--font-body);
	font-size: 17px;
	line-height: 1.65;
}

a {
	color: var(--accent);
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

button {
	font: inherit;
	color: inherit;
	cursor: pointer;
}

.topbar {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 10;
	height: var(--topbar-height);
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 0 20px;
	background: var(--background);
	border-bottom: 1px solid var(--border);
}

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	color: var(--text);
	font-family: var(--font-display);
	font-size: 24px;
	white-space: nowrap;
}

.brand:hover {
	text-decoration: none;
}

.brand img {
	width: 34px;
	height: 34px;
}

.version {
	font-family: var(--font-mono);
	font-size: 13px;
	color: var(--text-muted);
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 0 6px;
}

.search {
	position: relative;
	margin-left: auto;
	width: min(340px, 40vw);
}

.search input {
	width: 100%;
	height: 34px;
	padding: 0 12px;
	border-radius: 8px;
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-size: 15px;
}

.search input:focus {
	outline: 2px solid var(--accent);
	outline-offset: -1px;
}

#search-results {
	position: absolute;
	top: 40px;
	right: 0;
	width: min(520px, 90vw);
	max-height: 70vh;
	overflow-y: auto;
	background: var(--surface-raised);
	border: 1px solid var(--border);
	border-radius: 10px;
	box-shadow: 0 8px 24px var(--shadow);
	padding: 6px;
}

#search-results a {
	display: block;
	padding: 8px 10px;
	border-radius: 6px;
	color: var(--text);
}

#search-results a:hover, #search-results a.active {
	background: var(--surface);
	text-decoration: none;
}

#search-results .result-page {
	font-size: 12px;
	color: var(--text-muted);
}

#search-results .result-title {
	font-weight: 600;
}

#search-results .result-text {
	font-size: 14px;
	color: var(--text-muted);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

#search-results mark {
	background: none;
	color: var(--accent);
	font-weight: 600;
}

#search-results .empty {
	padding: 8px 10px;
	color: var(--text-muted);
}

.home, .source {
	color: var(--text);
	font-size: 15px;
	white-space: nowrap;
}

.theme-button, .menu-button {
	width: 34px;
	height: 34px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--surface) center / 20px no-repeat;
	flex: none;
}

.theme-button {
	background-image: url("../img/sun.svg");
}

.light-mode .theme-button {
	background-image: url("../img/moon.svg");
}

.menu-button {
	display: none;
	background-image: linear-gradient(var(--text), var(--text)), linear-gradient(var(--text), var(--text)),
		linear-gradient(var(--text), var(--text));
	background-size: 16px 2px;
	background-position: center 10px, center 15px, center 20px;
}

.layout {
	display: grid;
	grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--toc-width);
	padding-top: var(--topbar-height);
}

.chapters {
	position: sticky;
	top: var(--topbar-height);
	height: calc(100vh - var(--topbar-height));
	overflow-y: auto;
	padding: 20px 12px 40px 16px;
	border-right: 1px solid var(--border);
	font-size: 15px;
}

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

.chapters li a {
	display: block;
	padding: 4px 10px;
	border-radius: 6px;
	color: var(--text-muted);
	line-height: 1.4;
}

.chapters li a:hover {
	color: var(--text);
	background: var(--surface-raised);
	text-decoration: none;
}

.chapters li a.current {
	color: var(--text);
	background: var(--surface-raised);
	font-weight: 600;
}

.chapters .number {
	display: inline-block;
	min-width: 1.6em;
	color: var(--text-muted);
	font-weight: normal;
}

.chapters .part {
	margin: 18px 10px 6px;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--text-muted);
}

.chapters .part:first-child {
	margin-top: 0;
}

main {
	min-width: 0;
	padding: 28px 48px 80px;
}

.content {
	max-width: 820px;
	margin: 0 auto;
}

.content h1, .content h2, .content h3, .content h4 {
	line-height: 1.25;
	font-weight: normal;
	font-family: var(--font-display);
}

.content h1 {
	font-size: 44px;
	margin: 8px 0 24px;
}

.content h2 {
	font-size: 30px;
	margin: 48px 0 16px;
	padding-bottom: 6px;
	border-bottom: 1px solid var(--border);
}

.content h3 {
	font-size: 23px;
	margin: 32px 0 12px;
}

.content h4 {
	font-size: 19px;
	margin: 24px 0 8px;
}

.content .anchor {
	color: inherit;
}

.content .anchor:hover {
	text-decoration: none;
}

.content .anchor:hover::after {
	content: " #";
	color: var(--text-faded);
}

.content p, .content ul, .content ol {
	margin: 0 0 16px;
}

.content ul, .content ol {
	padding-left: 26px;
}

.content li {
	margin: 4px 0;
}

.content li > ul, .content li > ol {
	margin: 4px 0 0;
}

.content code {
	font-family: var(--font-mono);
	font-variant-ligatures: none;
	font-size: 0.88em;
	background: var(--surface-raised);
	border: 1px solid var(--border);
	border-radius: 5px;
	padding: 0.05em 0.35em;
	white-space: nowrap;
}

.content pre code {
	font-size: inherit;
	background: none;
	border: 0;
	border-radius: 0;
	padding: 0;
	white-space: normal;
}

.content a code {
	color: var(--accent);
}

.note {
	margin: 0 0 20px;
	padding: 12px 16px;
	border-left: 4px solid var(--accent);
	background: var(--surface-raised);
	border-radius: 0 8px 8px 0;
}

.note p {
	margin: 0;
}

.table-wrap {
	overflow-x: auto;
	margin: 0 0 20px;
}

table {
	border-collapse: collapse;
	width: 100%;
	font-size: 15px;
}

th, td {
	text-align: left;
	vertical-align: top;
	padding: 7px 12px;
	border-bottom: 1px solid var(--border);
}

th {
	font-weight: 600;
	border-bottom-width: 2px;
}

td code, th code {
	white-space: nowrap;
}

.code, .output {
	position: relative;
	margin: 0 0 20px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface);
	overflow: hidden;
}

.code pre, .output pre {
	margin: 0;
	padding: 14px 18px;
	overflow-x: auto;
	font-family: var(--font-mono);
	font-size: 15px;
	line-height: 1.55;
	tab-size: 4;
	-moz-tab-size: 4;
	font-variant-ligatures: none;
}

.code code {
	display: block;
	min-width: max-content;
}

.code .line {
	display: block;
	white-space: pre;
}

.code-title, .output .label {
	padding: 6px 18px;
	font-family: var(--font-mono);
	font-size: 13px;
	color: var(--text-muted);
	border-bottom: 1px solid var(--border);
	background: var(--surface-raised);
}

.output .label {
	font-family: var(--font-body);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.output pre {
	color: var(--text-muted);
}

.code.error {
	border-color: color-mix(in srgb, var(--error) 45%, var(--border));
}

.diagnostic {
	display: block;
	white-space: pre-wrap;
	margin: 1px 0 6px;
}

.squiggle {
	display: block;
	height: 3px;
	border-radius: 2px;
	background: var(--error);
}

.diagnostic-text {
	display: block;
	width: fit-content;
	max-width: 64ch;
	margin-top: 4px;
	padding: 2px 10px;
	border-radius: 6px;
	color: var(--error);
	background: var(--error-background);
	font-family: var(--font-body);
	font-size: 14px;
	line-height: 1.5;
	white-space: normal;
}

.diagnostic-note {
	display: block;
	color: var(--text-muted);
}

.copy {
	position: absolute;
	top: 6px;
	right: 6px;
	z-index: 1;
	width: 30px;
	height: 30px;
	border: 1px solid transparent;
	border-radius: 7px;
	background: url("../img/copy.svg") center / 18px no-repeat;
	opacity: 0;
	transition: opacity 0.15s;
}

.light-mode .copy {
	background-image: url("../img/copy-dark.svg");
}

.code:hover .copy, .copy:focus-visible {
	opacity: 0.8;
}

.copy:hover {
	opacity: 1;
	border-color: var(--border);
	background-color: var(--surface-raised);
}

.code-title + .copy {
	top: 36px;
}

.c-keyword { color: var(--code-teal); }
.c-type { font-weight: 700; }
.c-trait { font-weight: 700; font-style: italic; }
.c-typeparam { font-weight: 700; color: var(--code-purple); }
.c-function { color: var(--code-pink); }
.c-case { color: var(--code-purple); }
.c-parameter { color: var(--code-orange); }
.c-module { color: var(--code-green); }
.c-literal { color: var(--code-yellow); }
.c-constant { color: var(--code-purple); }
.c-field { }
.c-comment { color: var(--text-muted); font-style: italic; opacity: 0.8; }

.toml .c-field { color: var(--code-orange); }

.pager {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
	max-width: 820px;
	margin: 56px auto 0;
}

.pager a {
	display: block;
	padding: 12px 16px;
	border: 1px solid var(--border);
	border-radius: 10px;
	color: var(--text);
	font-weight: 600;
}

.pager a:hover {
	border-color: var(--accent);
	text-decoration: none;
}

.pager a span {
	display: block;
	font-size: 13px;
	font-weight: normal;
	color: var(--text-muted);
}

.pager .next {
	text-align: right;
	grid-column: 2;
}

.toc {
	position: sticky;
	top: var(--topbar-height);
	height: calc(100vh - var(--topbar-height));
	overflow-y: auto;
	padding: 28px 16px 40px 8px;
	font-size: 14px;
}

.toc-title {
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--text-muted);
	margin: 0 0 8px 10px;
}

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

.toc a {
	display: block;
	padding: 3px 10px;
	color: var(--text-muted);
	line-height: 1.4;
	border-left: 2px solid transparent;
	margin-left: -1px;
}

.toc a:hover {
	color: var(--text);
	text-decoration: none;
}

.toc a.active {
	color: var(--text);
	border-left-color: var(--accent);
}

.toc .level-3 a {
	padding-left: 22px;
}

#message {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translate(-50%, 16px);
	padding: 4px 14px;
	border-radius: 8px;
	background: var(--surface-raised);
	border: 1px solid var(--border);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s, transform 0.2s;
}

#message.visible {
	opacity: 1;
	transform: translate(-50%, 0);
}

@media (max-width: 1240px) {
	.layout {
		grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
	}

	.toc {
		display: none;
	}
}

@media (max-width: 900px) {
	.layout {
		grid-template-columns: minmax(0, 1fr);
	}

	.menu-button {
		display: block;
	}

	.chapters {
		position: fixed;
		z-index: 9;
		left: 0;
		top: var(--topbar-height);
		width: min(var(--sidebar-width), 85vw);
		background: var(--background);
		box-shadow: 4px 0 16px var(--shadow);
		transform: translateX(-105%);
		transition: transform 0.2s;
	}

	body.menu-open .chapters {
		transform: none;
	}

	main {
		padding: 20px 16px 60px;
	}

	.content h1 {
		font-size: 34px;
	}

	.content h2 {
		font-size: 26px;
	}

	.version, .home, .source {
		display: none;
	}

	.search {
		width: auto;
		flex: 1;
	}

	#search-results {
		position: fixed;
		top: calc(var(--topbar-height) + 4px);
		left: 8px;
		right: 8px;
		width: auto;
	}

	.brand {
		font-size: 20px;
	}

	.code pre, .output pre {
		font-size: 13.5px;
		padding: 12px 14px;
	}
}

@media (max-width: 480px) {
	.brand span, .brand {
		font-size: 0;
		gap: 0;
	}

	.pager {
		grid-template-columns: 1fr;
	}

	.pager .next {
		grid-column: 1;
	}
}
