@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap");

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

html,
body {
	height: 100%;
	overflow: hidden;
}

.doc-root {
	--bg: #fafaf9;
	--bg-secondary: #f4f3f0;
	--bg-code: #f0efec;
	--text: #1a1a18;
	--text-muted: #6b6b66;
	--text-faint: #a8a8a2;
	--accent: #3b5bdb;
	--accent-bg: #eef2ff;
	--accent-light: #c5d0fa;
	--border: rgba(0, 0, 0, 0.08);
	--border-strong: rgba(0, 0, 0, 0.14);
	--nav-w: 16.25rem;
	--font: "Inter", system-ui, sans-serif;
	--mono: "JetBrains Mono", "Fira Code", monospace;

	position: relative;
	display: flex;
	min-height: 100vh;
	height: 100%;
	overflow: hidden;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: 0.875rem;
	line-height: 1.6;
}

.doc-root.dark {
	--bg: #141413;
	--bg-secondary: #1e1e1c;
	--bg-code: #252523;
	--text: #e8e8e4;
	--text-muted: #9a9a94;
	--text-faint: #5a5a56;
	--accent: #7b93f5;
	--accent-bg: #1a1f3a;
	--accent-light: #2d3560;
	--border: rgba(255, 255, 255, 0.07);
	--border-strong: rgba(255, 255, 255, 0.12);
}

.sidebar {
	width: var(--nav-w);
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	border-right: 0.5px solid var(--border);
	transition:
		width 0.18s ease,
		opacity 0.18s ease;
	height: 100vh;
}

.doc-root.nav-collapsed .sidebar {
	width: 0;
	border-right: none;
	pointer-events: none;
	opacity: 0;
}

.sidebar-header {
	flex-shrink: 0;
	padding: 1.15rem 1.25rem 0.5rem;
	border-bottom: 0.5px solid var(--border);
}

.logo-row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.25rem;
}

.logo-mark {
	width: 1.7rem;
	height: 1.7rem;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	border-radius: 0.3125rem;
	background: var(--accent);
}

.logo-mark svg {
	width: 0.75rem;
	height: 0.75rem;
	fill: white;
}

.logo-name {
	color: var(--text);
	font-size: 1.0955rem;
	font-weight: 600;
	margin-left: 0.225rem;
	letter-spacing: -0.01em;
}

.sidebar-search {
	margin-top: 0.625rem;
	display: flex;
	align-items: center;
	gap: 0.375rem;
	padding: 0.3125rem 0.5rem;
	border: 0.5px solid var(--border);
	border-radius: 0.375rem;
	background: var(--bg-secondary);
	cursor: pointer;
}

.sidebar-search span {
	flex: 1;
	color: var(--text-faint);
	font-size: 0.75rem;
}

.kbd {
	padding: 0.0625rem 0.25rem;
	border: 0.5px solid var(--border-strong);
	border-radius: 0.1875rem;
	background: var(--bg);
	color: var(--text-faint);
	font-family: var(--mono);
	font-size: 0.625rem;
}

.nav-scroll {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 0.625rem 0 1.25rem;
	line-height: 1.6em;
}

.nav-scroll::-webkit-scrollbar,
.content::-webkit-scrollbar {
	width: 0.1875rem;
}

.nav-scroll::-webkit-scrollbar-thumb,
.content::-webkit-scrollbar-thumb {
	border-radius: 0.125rem;
}

.nav-scroll::-webkit-scrollbar-thumb {
	background: var(--border-strong);
}

.content::-webkit-scrollbar-thumb {
	background: var(--border);
}

.nav-section-label {
	padding: 0.3rem 0.875rem;
	color: var(--text);
	font-weight: 700;
	letter-spacing: 0.02em;
}

.nav-section-label:first-child {
	border-top: none;
	margin-top: 0;
}

.nav-separator {
	margin: 0.5rem auto;
	height: 2.5px;
	width: 91%;
	background: var(--border);
}

.nav-item {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.375rem;
	padding: 0.3125rem 1.25rem;
	border-left: 0.125rem solid transparent;
	color: var(--text-muted);
	text-decoration: none;
	cursor: pointer;
	transition:
		background 0.1s,
		color 0.1s;
}

.nav-item:hover {
	color: var(--text);
	background: var(--bg-secondary);
}

.nav-item.active {
	border-left-color: var(--accent);
	background: var(--accent-bg);
	color: var(--accent);
	font-weight: 500;
}

.nav-item.depth-0 {
	padding-left: 1.25rem;
}

.nav-item.depth-1 {
	padding-left: 2.125rem;
	font-size: 0.78125rem;
}

.nav-item.depth-2 {
	padding-left: 3rem;
	font-size: 0.78125rem;
}

.nav-item.depth-3 {
	padding-left: 3.875rem;
	font-size: 0.75rem;
}

.nav-item.depth-4 {
	padding-left: 4.75rem;
	font-size: 0.75rem;
}

.nav-item .chevron {
	margin-left: auto;
	display: flex;
	color: var(--text-faint);
	transition: transform 0.15s;
}

.nav-item.page-expanded .chevron {
	transform: rotate(90deg);
}

.nav-version {
	padding: 0.0625rem 0.3125rem;
	border: 0.5px solid var(--border);
	border-radius: 0.1875rem;
	background: var(--bg-secondary);
	color: var(--text-faint);
	font-family: var(--mono);
	font-size: 0.625rem;
	font-weight: 500;
}

/* .page-toc {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.18s ease;
}

.page-toc.open {
  max-height: 20rem;
} */
/* 

.toc-sub-item {
  display: block;
  padding: 0.25rem 1.25rem 0.25rem 2.75rem;
  border-left: 0.125rem solid transparent;
  color: var(--text-faint);
  font-size: 0.75rem;
  line-height: 1.5;
  text-decoration: none;
  cursor: pointer;
}

.toc-sub-item:hover {
  color: var(--text-muted);
}

.toc-sub-item.active {
  color: var(--accent);
  font-weight: 500;
}

.toc-sub-item.indent-1 {
  padding-left: 3.5rem;
}

.toc-sub-item.indent-2 {
  padding-left: 4.25rem;
}

.toc-sub-item.indent-3 {
  padding-left: 5rem;
} */

.nav-footer {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.75rem 1.25rem;
	border-top: 0.5px solid var(--border);
}

.nav-footer a {
	gap: 0.25rem;
	color: var(--text-faint);
	text-decoration: none;
	cursor: pointer;
}

.nav-footer a:hover {
	color: var(--text-muted);
}

.main {
	flex: 1;
	min-width: 0;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

.topbar {
	height: 2.95rem;
	flex-shrink: 0;
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	padding: 0 1.25rem;
	border-bottom: 0.5px solid var(--border);
	background: var(--bg);
}

.topbar button {
	width: 1.75rem;
	height: 1.75rem;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	border: 0.5px solid var(--border);
	border-radius: 0.375rem;
	background: var(--bg);
	color: var(--text-muted);
	cursor: pointer;
	transition:
		background 0.1s,
		color 0.1s;
}

.topbar button:hover {
	background: var(--bg-secondary);
	color: var(--text);
}

.topbar-left,
.topbar-right {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	min-width: 0;
}

.topbar-left {
	justify-self: start;
}

.topbar-right {
	justify-self: end;
}

.topbar-title {
	justify-self: center;
	max-width: min(60vw, 24rem);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: var(--text);
	font-size: 0.875rem;
	font-weight: 600;
	letter-spacing: -0.01em;
}

.topbar-link {
	height: 1.75rem;
	padding: 0 0.625rem;
	border: 0.5px solid var(--border);
	border-radius: 0.375rem;
	background: var(--bg);
	color: var(--text-muted);
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	text-decoration: none;
	cursor: pointer;
	transition:
		background 0.1s,
		color 0.1s,
		border-color 0.1s;
	font-family: var(--font);
	font-size: 0.75rem;
}

.topbar-link:hover {
	background: var(--bg-secondary);
	color: var(--text);
	border-color: var(--border-strong);
}

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

.search-overlay {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: flex;
	justify-content: center;
	align-items: flex-start;
	padding-top: 10vh;
	background: rgba(0, 0, 0, 0.55);
	backdrop-filter: blur(6px);
}

.search-modal {
	position: relative;
	width: min(48rem, calc(100% - 2rem));
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
	background: rgba(255, 255, 255, 0.55);
}

.search-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem 1rem 0.875rem;
	border-bottom: 0.5px solid var(--border);
}

.search-head-left {
	min-width: 0;
}

.search-head-title {
	color: var(--text);
	font-size: 0.875rem;
	font-weight: 600;
}

.search-head-hint {
	margin-top: 0.125rem;
	color: var(--text-faint);
	font-size: 0.71875rem;
}

.search-close {
	flex-shrink: 0;
	padding: 0.125rem 0.5rem;
	border: 0.5px solid var(--border);
	border-radius: 0.375rem;
	background: var(--bg);
	color: var(--text-faint);
	cursor: pointer;
	font-family: var(--font);
	font-size: 0.75rem;
}

.search-close:hover {
	background: var(--bg-secondary);
	color: var(--text);
	border-color: var(--border-strong);
}

.search-input-row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.875rem 1rem;
	border-bottom: 0.5px solid var(--border);
	color: var(--text-faint);
}

.search-input {
	width: 100%;
	border: none;
	outline: none;
	background: transparent;
	color: var(--text);
	font-family: var(--font);
	font-size: 0.875rem;
}

.search-results {
	max-height: min(60vh, 32rem);
	overflow-y: auto;
}

.search-result {
	display: block;
	width: 100%;
	padding: 0.9rem 1rem;
	border: none;
	border-top: 0.5px solid var(--border);
	background: none;
	color: inherit;
	text-align: left;
	text-decoration: none;
	cursor: pointer;
}

.search-result:first-child {
	border-top: none;
}

.search-result:hover {
	background: var(--bg-secondary);
}

.search-result-title {
	color: var(--text);
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.3;
}

.search-result-desc {
	margin-top: 0.25rem;
	color: var(--text-muted);
	font-size: 0.75rem;
	line-height: 1.5;
}

.search-result-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 0.375rem;
	margin-top: 0.5rem;
}

.search-tag {
	padding: 0.0625rem 0.375rem;
	border: 0.5px solid var(--border);
	border-radius: 999px;
	background: var(--bg-secondary);
	color: var(--text-faint);
	font-family: var(--mono);
	font-size: 0.625rem;
}

.search-empty {
	padding: 1rem;
	color: var(--text-faint);
	font-size: 0.8125rem;
}

.breadcrumb {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	color: var(--text-faint);
	font-size: 0.75rem;
}

.breadcrumb .current {
	color: var(--text-muted);
}

.content {
	flex: 1;
	width: 100%;
	min-width: 0;
	max-width: 47.5rem;
	margin: 2rem auto;
	overflow-y: auto;
	padding: 1.8rem 1.5rem 2.5rem;
	font-size: 1rem;

	h1 {
		margin-bottom: 0.5rem;
		color: var(--text);
		font-size: 1.8rem;
		font-weight: 600;
		line-height: 1.25;
		letter-spacing: -0.025em;
	}

	h2 {
		display: flex;
		align-items: center;
		gap: 0.5rem;
		margin: 2.25rem 0 0.75rem;
		color: var(--text);
		font-size: 1.2rem;
		font-weight: 600;
		letter-spacing: -0.015em;
		scroll-margin-top: 1rem;
	}

	h3 {
		margin: 1.5rem 0 0.5rem;
		color: var(--text);
		font-size: 0.95rem;
		font-weight: 600;
		scroll-margin-top: 1rem;
	}

	h4 {
		margin: 1.125rem 0 0.375rem;
		color: var(--text-muted);
		font-size: 0.875rem;
		font-weight: 600;
		scroll-margin-top: 1rem;
	}

	p,
	ul,
	ol {
		margin: 0 0 0.875rem;
		color: var(--text);
		font-size: 0.98rem;
		line-height: 1.75;
	}

	ul,
	ol {
		padding-left: 1.375rem;
	}

	li {
		margin-bottom: 0.25rem;
	}

	a:not(h1 a, h2 a, h3 a, h4 a, h5 a, h6 a) {
		color: var(--accent);
		text-decoration: none;
		border-bottom: 0.5px solid var(--accent-light);
	}

	a:hover {
		border-bottom-color: var(--accent);
	}

	h1 a,
	h2 a,
	h3 a,
	h4 a,
	h5 a,
	h6 a {
		color: inherit;
		text-decoration: inherit;
		font: inherit;
	}

	blockquote {
		margin: 0.875rem 0;
		padding: 0.125rem 0 0.125rem 0.875rem;
		border-left: 0.125rem solid var(--border-strong);
		color: var(--text-muted);
	}

	table {
		width: 100%;
		border-collapse: collapse;
		margin: 1rem 0 1.25rem;
		font-size: 0.89rem;
		line-height: 1.6;
		color: var(--text);
		border: 0.5px solid var(--border);
		background: var(--bg);
	}

	th {
		text-align: left;
		font-weight: 600;
		font-size: 0.78rem;
		letter-spacing: 0.04em;
		text-transform: uppercase;
		color: var(--text-faint);
		padding: 0.625rem 0.75rem;
		border-bottom: 0.5px solid var(--border-strong);
		background: var(--bg-secondary);
	}

	td {
		padding: 0.625rem 0.75rem;
		border-bottom: 0.5px solid var(--border);
		vertical-align: top;
	}

	tr:hover td {
		background: var(--bg-secondary);
	}

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

	td code,
	th code {
		font-family: var(--mono);
		font-size: 0.86rem;
		background: var(--bg-code);
		border: 0.5px solid var(--border);
		padding: 0.0625rem 0.3125rem;
		border-radius: 0.25rem;
	}

	@media (max-width: 768px) {
		table {
			display: block;
			overflow-x: auto;
			white-space: nowrap;
		}
	}

	img {
		max-width: 100%;
		height: auto;
		display: block;
		margin: 1rem auto;
		border-radius: 0.5rem;
		border: 0.5px solid var(--border);
		background: var(--bg-secondary);
		transition:
			filter 0.15s ease,
			transform 0.15s ease;
	}

	img:hover {
		transform: scale(1.01);
		filter: brightness(1.03);
	}

	figure {
		margin: 1.25rem 0;
		text-align: center;
	}

	figcaption {
		margin-top: 0.5rem;
		font-size: 0.75rem;
		color: var(--text-faint);
		line-height: 1.5;
	}

	video,
	iframe {
		width: 100%;
		aspect-ratio: 16 / 9;
		border-radius: 0.5rem;
		border: 0.5px solid var(--border);
		margin: 1rem 0;
		background: var(--bg-secondary);
	}

	:not(pre) code {
		font-family: var(--mono);
		font-size: 0.86rem;
		background: var(--bg-code);
		border: 1px solid var(--border);
		border-radius: 0.25rem;
		padding: 0.1rem 0.35rem;
	}

	pre {
		background: var(--bg-secondary);
		border: 1px solid var(--border);
		border-radius: 10px;
		overflow-x: auto;
		margin: 1rem 0 1.25rem;
	}

	pre code {
		display: block;
		padding: 0.875rem 1rem;
		font-family: var(--mono);
		font-size: 0.86rem;
		line-height: 1.7;
		color: var(--text);
		background: transparent;
	}

	pre[data-lang]::before {
		content: attr(data-lang);
		display: block;
		padding: 0.5rem 0.875rem;
		font-size: 0.75rem;
		font-family: var(--mono);
		color: var(--text-faint);
		border-bottom: 1px solid var(--border);
		text-transform: uppercase;
		letter-spacing: 0.04em;
	}

	pre button {
		float: right;
		margin-top: -2rem;
		margin-right: 0.5rem;
		background: none;
		border: none;
		font-size: 0.75rem;
		color: var(--text-faint);
		cursor: pointer;
	}

	pre button:hover {
		color: var(--text);
	}
}

@media (max-width: 768px) {
	.content img,
	.content video,
	.content iframe {
		border-radius: 0.375rem;
	}
}

.page-nav {
	display: flex;
	gap: 0.75rem;
	margin-top: 2.5rem;
	padding-top: 1.5rem;
	border-top: 0.5px solid var(--border);
}

.page-nav-btn {
	flex: 1;
	display: block;
	padding: 0.625rem 0.875rem;
	border: 0.5px solid var(--border);
	border-radius: 0.5rem;
	background: none;
	color: inherit;
	font-family: var(--font);
	text-align: left;
	text-decoration: none;
	cursor: pointer;
	transition: all 0.1s;
}

.page-nav-btn:hover {
	border-color: var(--border-strong);
	background: var(--bg-secondary);
}

.page-nav-btn.next {
	text-align: right;
}

.page-nav-dir {
	margin-bottom: 0.125rem;
	color: var(--text-faint);
	font-size: 0.625rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.page-nav-title {
	color: var(--accent);
	font-size: 0.8125rem;
	font-weight: 500;
}
