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

:root {
	--sidebar-w: 260px;
	--bg-deep: #07090f;
	--bg-surface: #0c0f17;
	--bg-elevated: #11151f;
	--border: rgba(255, 255, 255, 0.06);
	--border-strong: rgba(255, 255, 255, 0.12);
	--text: #e2e4ed;
	--text-muted: #7c82a0;
	--text-dim: #4a4f6a;
	--accent: #2dd4bf;
	--accent-dim: #0d9488;
	--accent-soft: rgba(45, 212, 191, 0.1);
	--amber: #f59e0b;
	--amber-soft: rgba(245, 158, 11, 0.1);
	--code-bg: #0d111c;
	--code-text: #e2e4ed;
	--radius-sm: 4px;
	--radius-md: 8px;
	--radius: 12px;
	--font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--font-heading: var(--font);
	--mono:
		ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

html {
	font-size: 16px;
	scroll-behavior: smooth;
}

body {
	font-family: var(--font);
	color: var(--text);
	background: var(--bg-deep);
	line-height: 1.7;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

.layout {
	display: flex;
	min-height: 100vh;
	position: relative;
	z-index: 1;
}

/* ── Sidebar ── */
.sidebar {
	width: var(--sidebar-w);
	min-width: var(--sidebar-w);
	background: var(--bg-surface);
	border-right: 1px solid var(--border);
	display: flex;
	flex-direction: column;
	position: fixed;
	top: 0;
	left: 0;
	bottom: 0;
	z-index: 40;
	overflow-y: auto;
	padding: 0;
}

.sidebar-header {
	padding: 28px 24px 20px;
	border-bottom: 1px solid var(--border);
}

.brand {
	font-family: var(--font-heading);
	font-size: 1.35rem;
	font-weight: 700;
	color: #fff;
	text-decoration: none;
	letter-spacing: -0.02em;
}

.brand:hover {
	color: var(--accent);
}

.tagline {
	font-size: 0.8125rem;
	color: var(--text-muted);
	margin-top: 4px;
	line-height: 1.5;
}

/* ── Navigation ── */
.sidebar-nav {
	flex: 1;
	padding: 12px 16px;
	display: flex;
	flex-direction: column;
	gap: 1px;
}

.nav-section {
	font-size: 0.65rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: var(--text-dim);
	padding: 20px 8px 6px;
}

.nav-section:first-child {
	padding-top: 4px;
}

.nav-link {
	display: block;
	padding: 7px 10px;
	border-radius: var(--radius-sm);
	color: var(--text-muted);
	text-decoration: none;
	font-size: 0.875rem;
	font-weight: 400;
	transition:
		background 0.15s ease,
		color 0.15s ease;
	margin: 0;
}

.nav-link:hover {
	background: var(--accent-soft);
	color: var(--accent);
}

.nav-link.active {
	background: var(--accent-soft);
	color: var(--accent);
	font-weight: 600;
	border-left: 2px solid var(--accent);
	padding-left: 8px;
}

.nav-group {
	display: block;
}

.nav-group .nav-link {
	padding-left: 20px;
	font-size: 0.8125rem;
}

/* ── Sidebar Footer ── */
.sidebar-footer {
	margin-top: auto;
	padding: 16px 24px 24px;
	border-top: 1px solid var(--border);
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.sidebar-link {
	color: var(--text-dim);
	text-decoration: none;
	font-size: 0.8125rem;
	font-weight: 400;
	transition: color 0.15s ease;
}

.sidebar-link:hover {
	color: var(--accent);
}

/* ── Content Area ── */
.content-container {
	margin-left: var(--sidebar-w);
	flex: 1;
	display: flex;
	justify-content: space-between;
	min-width: 0;
	position: relative;
}

.content {
	flex: 1;
	min-width: 0;
	padding: 48px 48px 96px 64px;
	max-width: 820px;
	position: relative;
}

/* ── Mobile Menu ── */
.menu-toggle {
	display: none;
}

.menu-btn {
	display: none;
	flex-direction: column;
	gap: 5px;
	cursor: pointer;
	padding: 8px;
	margin-bottom: 12px;
	width: 36px;
}

.menu-btn span {
	display: block;
	height: 2px;
	background: var(--text);
	border-radius: 2px;
	transition:
		transform 0.2s,
		opacity 0.2s;
}

.menu-overlay {
	display: none;
}

/* ── Typography ── */
.content h1 {
	font-family: var(--font-heading);
	font-size: 2.25rem;
	font-weight: 700;
	letter-spacing: -0.03em;
	margin-bottom: 0.5em;
	line-height: 1.2;
	color: #f0f2f8;
}

.content h2 {
	font-family: var(--font-heading);
	font-size: 1.4rem;
	font-weight: 600;
	margin: 2.5em 0 0.5em;
	padding-bottom: 0.4em;
	border-bottom: 1px solid var(--border);
	color: #f0f2f8;
	letter-spacing: -0.01em;
}

.content h3 {
	font-family: var(--font-heading);
	font-size: 1.1rem;
	font-weight: 600;
	margin: 1.8em 0 0.4em;
	color: #f0f2f8;
}

.content h4 {
	font-size: 1rem;
	font-weight: 600;
	margin: 1.5em 0 0.3em;
	color: #f0f2f8;
}

.content p {
	margin: 0.8em 0;
	color: var(--text);
}

.content a {
	color: var(--accent);
	text-decoration: none;
	transition: color 0.15s ease;
	border-bottom: 1px solid transparent;
}

.content a:hover {
	color: #5eead4;
	border-bottom-color: var(--accent-dim);
}

.content strong {
	font-weight: 600;
	color: #f0f2f8;
}

.content ul,
.content ol {
	padding-left: 1.5em;
	margin: 0.8em 0;
}
.content li {
	margin: 0.25em 0;
}
.content li > p {
	margin: 0.2em 0;
}

.content blockquote {
	border-left: 2px solid var(--accent-dim);
	margin: 1.2em 0;
	padding: 0.75em 1.25em;
	color: var(--text-muted);
	background: var(--bg-elevated);
	border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.content blockquote p {
	margin: 0.3em 0;
}

.content hr {
	border: none;
	border-top: 1px solid var(--border);
	margin: 2.5em 0;
}

/* ── Code ── */
.content code {
	font-family: var(--mono);
	font-size: 0.85em;
	background: var(--code-bg);
	color: var(--accent);
	padding: 0.15em 0.45em;
	border-radius: 4px;
	font-weight: 450;
	border: 1px solid rgba(45, 212, 191, 0.12);
}

.content pre {
	font-family: var(--mono);
	background: var(--code-bg);
	color: var(--code-text);
	padding: 20px 24px;
	border-radius: var(--radius);
	border: 1px solid var(--border);
	max-width: 100%;
	overflow-x: auto;
	margin: 1.2em 0;
	font-size: 0.85rem;
	line-height: 1.7;
}

.content pre code {
	display: block;
	min-width: 0;
	background: none;
	color: inherit;
	padding: 0;
	font-size: inherit;
	font-weight: 400;
	border: none;
}

@media (max-width: 640px) {
	.content pre {
		padding: 16px;
	}

	.content pre code {
		overflow-wrap: anywhere;
		white-space: pre-wrap;
	}
}

/* ── Tables ── */
/* build.mjs wraps every table in .table-scroll: a table wider than the
   column scrolls inside it instead of widening the page. */
.content .table-scroll {
	max-width: 100%;
	overflow-x: auto;
	margin: 1.2em 0;
}

.content table {
	width: 100%;
	border-collapse: collapse;
	margin: 1.2em 0;
	font-size: 0.9375rem;
}

.content .table-scroll > table {
	margin: 0;
}

.content th {
	text-align: left;
	font-weight: 600;
	padding: 10px 14px;
	border-bottom: 2px solid var(--border-strong);
	color: var(--text-muted);
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.content td {
	padding: 10px 14px;
	border-bottom: 1px solid var(--border);
	vertical-align: top;
}

.content tr:hover td {
	background: rgba(255, 255, 255, 0.02);
}

/* ── Images ── */
.content img {
	max-width: 100%;
	border-radius: var(--radius-md);
	border: 1px solid var(--border);
}

/* ── Hero / Buttons ── */
.hero-links {
	margin: 1.5rem 0;
	display: flex;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.button {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 0.65rem 1.35rem;
	border-radius: var(--radius-sm);
	text-decoration: none;
	font-weight: 600;
	font-size: 0.9rem;
	transition:
		background 0.15s ease,
		border-color 0.15s ease,
		color 0.15s ease;
}

.button.primary {
	background: var(--accent-dim);
	color: #fff;
}

.button.primary:hover {
	background: #0f766e;
}

.button.secondary {
	border: 1px solid var(--border-strong);
	color: var(--text-muted);
}

.button.secondary:hover {
	border-color: var(--accent);
	color: var(--accent);
	background: var(--accent-soft);
}

/* ── Responsive ── */
@media (max-width: 768px) {
	:root {
		--sidebar-w: 240px;
	}

	.sidebar {
		transform: translateX(-100%);
		transition: transform 0.25s ease;
	}

	.menu-toggle:checked ~ .layout .sidebar {
		transform: translateX(0);
	}

	.menu-toggle:checked ~ .layout .menu-overlay {
		display: block;
		position: fixed;
		inset: 0;
		background: rgba(0, 0, 0, 0.6);
		z-index: 30;
	}

	.content-container {
		margin-left: 0;
	}

	.content {
		padding: 24px 20px 64px;
		max-width: 100%;
	}

	.menu-btn {
		display: flex;
	}

	.content h1 {
		font-size: 1.75rem;
	}
	.content h2 {
		font-size: 1.25rem;
	}
}

/* Hide TOC on screens narrower than 1200px */
@media (max-width: 1200px) {
	.toc-sidebar {
		display: none;
	}
	.content {
		padding: 48px 32px 96px;
	}
}

/* ── Theme Compatibility map for Demo Widgets ── */
:root {
	--surface-1: var(--bg-surface);
	--line: var(--border);
	--line-strong: var(--border-strong);
	--ink-soft: var(--text-muted);
}

/* ── Scroll Progress Bar ── */
#progress {
	position: fixed;
	left: 0;
	top: 0;
	width: 100%;
	height: 3px;
	background: var(--accent);
	z-index: 100;
	transform-origin: 0 50%;
	transform: scaleX(0);
}

@media (prefers-reduced-motion: no-preference) {
	@supports (animation-timeline: scroll()) {
		@keyframes grow-progress {
			from {
				transform: scaleX(0);
			}
			to {
				transform: scaleX(1);
			}
		}
		#progress {
			animation: grow-progress auto linear;
			animation-timeline: scroll();
		}
	}
}

/* ── Table of Contents ── */
.toc-sidebar {
	width: 240px;
	min-width: 240px;
	position: sticky;
	top: 0;
	height: 100vh;
	overflow-y: auto;
	padding: 48px 24px 96px 16px;
	border-left: 1px solid var(--border);
}

.toc-title {
	font-family: var(--font-heading);
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--text-dim);
	margin-bottom: 12px;
}

.toc-links {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.toc-link {
	font-size: 0.8rem;
	color: var(--text-muted);
	text-decoration: none;
	line-height: 1.4;
	transition:
		color 0.15s ease,
		border-color 0.15s ease;
	border-left: 1.5px solid transparent;
	padding: 2px 0 2px 10px;
	display: block;
}

.toc-link:hover {
	color: var(--accent);
}

.toc-link.active {
	color: var(--accent);
	font-weight: 500;
	border-left-color: var(--accent);
}

.toc-link.depth-3 {
	padding-left: 20px;
}

/* ── Code Block Floating Copy Button ── */
.content pre {
	position: relative;
}

.copy-btn {
	position: absolute;
	top: 8px;
	right: 8px;
	background: var(--bg-surface);
	border: 1px solid var(--border);
	color: var(--text-muted);
	padding: 4px 8px;
	border-radius: var(--radius-sm);
	font-family: var(--font);
	font-size: 0.75rem;
	font-weight: 500;
	cursor: pointer;
	opacity: 0;
	transition:
		opacity 0.2s ease,
		background 0.2s ease,
		border-color 0.2s ease,
		color 0.2s ease;
	z-index: 10;
	display: flex;
	align-items: center;
	gap: 4px;
}

.content pre:hover .copy-btn {
	opacity: 1;
}

.copy-btn:hover {
	background: var(--bg-elevated);
	border-color: var(--accent);
	color: var(--text);
}

.copy-btn.copied {
	border-color: var(--accent-dim);
	color: var(--accent);
	background: var(--accent-soft);
}

/* ── Sidebar Search Trigger ── */
.sidebar-search {
	padding: 12px 16px 8px;
}

.search-trigger {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 10px;
	background: var(--code-bg);
	border: 1px solid var(--border);
	color: var(--text-muted);
	padding: 8px 12px;
	border-radius: var(--radius-md);
	font-family: var(--font);
	font-size: 0.8125rem;
	text-align: left;
	cursor: pointer;
	transition:
		border-color 0.15s ease,
		background 0.15s ease,
		color 0.15s ease;
	position: relative;
}

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

.search-trigger .search-icon {
	color: var(--text-dim);
	flex-shrink: 0;
}

.search-trigger:hover .search-icon {
	color: var(--text-muted);
}

.search-trigger .search-shortcut {
	position: absolute;
	right: 12px;
	font-size: 0.65rem;
	background: var(--bg-surface);
	border: 1px solid var(--border);
	padding: 2px 4px;
	border-radius: 3px;
	color: var(--text-dim);
}

/* ── Global Search Modal ── */
.search-modal-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(3, 5, 10, 0.7);
	z-index: 1000;
	display: none;
	justify-content: center;
	padding-top: 10vh;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.search-modal-backdrop.open {
	display: flex;
	opacity: 1;
}

.search-modal {
	background: var(--bg-surface);
	border: 1px solid var(--border-strong);
	width: 90%;
	max-width: 580px;
	max-height: 70vh;
	border-radius: var(--radius);
	display: flex;
	flex-direction: column;
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
	overflow: hidden;
	transform: translateY(-20px);
	transition: transform 0.2s ease;
}

.search-modal-backdrop.open .search-modal {
	transform: translateY(0);
}

.search-modal-header {
	padding: 16px;
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
	gap: 12px;
	background: var(--bg-elevated);
}

.search-modal-input-wrapper {
	flex: 1;
	display: flex;
	align-items: center;
	position: relative;
}

.search-modal-input-wrapper .search-icon {
	position: absolute;
	left: 0;
	color: var(--text-dim);
	pointer-events: none;
}

.search-modal-input {
	width: 100%;
	background: none;
	border: none;
	color: var(--text);
	font-family: var(--font);
	font-size: 1rem;
	padding: 6px 12px 6px 28px;
}

.search-modal-input:focus {
	outline: none;
}

.search-modal-close {
	background: none;
	color: var(--text-muted);
	cursor: pointer;
	font-size: 0.8125rem;
	padding: 4px 8px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	font-family: var(--font);
}

.search-modal-close:hover {
	color: var(--text);
	background: var(--bg-deep);
}

.search-modal-results {
	flex: 1;
	overflow-y: auto;
	padding: 8px 0;
}

.search-modal-footer {
	padding: 12px 16px;
	border-top: 1px solid var(--border);
	background: var(--bg-elevated);
	display: flex;
	gap: 16px;
	font-size: 0.7rem;
	color: var(--text-dim);
}

.search-modal-footer kbd {
	background: var(--bg-surface);
	border: 1px solid var(--border-strong);
	padding: 2px 5px;
	border-radius: 3px;
	font-family: var(--mono);
	font-size: 0.65rem;
	color: var(--text-muted);
}

/* ── Features Grid ── */
.features-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 1.25rem;
	margin: 2rem 0;
}

.feature-card {
	background: var(--bg-surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: 1.5rem;
}

.feature-card h3 {
	font-family: var(--font-heading);
	font-size: 1rem;
	font-weight: 600;
	color: #f0f2f8;
	margin: 0 0 0.5rem;
	border-bottom: none;
	padding-bottom: 0;
}

.feature-card p {
	font-size: 0.8125rem;
	color: var(--text-muted);
	margin: 0;
	line-height: 1.5;
}

/* ── Use Case Grid ── */
.usecase-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 1.25rem;
	margin: 2rem 0;
}

.usecase-card {
	background: var(--bg-surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: 1.5rem;
	display: flex;
	flex-direction: column;
	min-height: 100%;
}

.usecase-card h3 {
	font-family: var(--font-heading);
	font-size: 1.05rem;
	font-weight: 600;
	color: #f0f2f8;
	margin: 0 0 0.5rem;
	border-bottom: none;
	padding-bottom: 0;
}

.usecase-card p {
	font-size: 0.8125rem;
	color: var(--text-muted);
	margin: 0 0 1.25rem;
	line-height: 1.5;
	flex: 1;
}

.usecase-steps {
	font-size: 0.78rem;
	color: var(--text-dim);
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
	padding-top: 0.85rem;
	border-top: 1px solid var(--border);
}

.usecase-steps a {
	color: var(--accent);
	text-decoration: none;
	font-weight: 500;
	transition: color 0.15s ease;
}

.usecase-steps a:hover {
	color: #5eead4;
}

/* ── Split Columns ── */
.split-columns {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 1.5rem;
	margin: 2rem 0;
}

.column-card {
	background: var(--bg-surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: 1.5rem;
}

.column-card.focus {
	border-left: 3px solid var(--accent);
}

.column-card.out-of-scope {
	border-left: 3px solid var(--amber);
}

.column-card h4 {
	margin: 0 0 1rem;
	font-size: 1.05rem;
	font-weight: 600;
	color: #f0f2f8;
}

.column-card ul {
	margin: 0;
	padding-left: 1.25rem;
}

.column-card li {
	margin-bottom: 0.5rem;
	font-size: 0.85rem;
	color: var(--text-muted);
}

.column-card li strong {
	color: var(--text);
}
