:root {
	/* Premium Light Theme Palette */
	--bg-body: #f8fafc;
	/* Slate-50 */
	--bg-surface: #ffffff;
	--bg-surface-secondary: #f1f5f9;
	--bg-rgb: 255, 255, 255;
	/* Slate-100 */
	--border: #e2e8f0;
	/* Slate-200 */

	--text-primary: #0f172a;
	/* Slate-900 */
	--text-secondary: #475569;
	/* Slate-600 */
	--text-tertiary: #94a3b8;
	/* Slate-400 */

	--accent: #2563eb;
	/* Blue-600 */
	--accent-light: #eff6ff;
	/* Blue-50 */
	--accent-hover: #1d4ed8;
	/* Blue-700 */

	--brand-gradient: linear-gradient(135deg, #2563eb, #7c3aed);
	/* Blue to Violet */

	--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
	--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
	--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

	--radius-sm: 0.5rem;
	--radius-md: 0.75rem;
	--radius-lg: 1rem;

	--font-sans: 'Manrope', system-ui, -apple-system, sans-serif;
	--font-display: 'Space Grotesk', var(--font-sans);
	--font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

	--header-height: 72px;
	--sidebar-width: 280px;
	--content-max-width: 900px;
}

[data-theme="dark"] {
	--bg-body: #0f172a;
	--bg-surface: #1e293b;
	--bg-surface-secondary: #334155;
	--bg-rgb: 30, 41, 59;
	/* #1e293b */
	--border: #475569;

	--text-primary: #f8fafc;
	--text-secondary: #cbd5e1;
	--text-tertiary: #94a3b8;

	--accent: #3b82f6;
	--accent-light: #1e3a8a;
	--accent-hover: #60a5fa;

	--brand-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);

	--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
	--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.5);
	--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
}

/* Reset & Base */
*,
*::before,
*::after {
	box-sizing: border-box;
}

body.docs-body {
	margin: 0;
	background-color: var(--bg-body);
	color: var(--text-primary);
	font-family: var(--font-sans);
	-webkit-font-smoothing: antialiased;
	line-height: 1.6;
}

a {
	color: inherit;
	text-decoration: none;
	transition: color 0.15s ease;
}

/* Background Decoration (Subtle Aurora) */
.bg-aurora {
	position: fixed;
	inset: 0;
	z-index: -1;
	pointer-events: none;
	overflow: hidden;
	background: var(--bg-body);
}

.bg-aurora::before {
	content: '';
	position: absolute;
	top: -20%;
	left: -10%;
	width: 50%;
	height: 50%;
	background: radial-gradient(circle, rgba(37, 99, 235, 0.08) 0%, transparent 70%);
	filter: blur(60px);
}

.bg-aurora::after {
	content: '';
	position: absolute;
	bottom: -20%;
	right: -10%;
	width: 50%;
	height: 50%;
	background: radial-gradient(circle, rgba(124, 58, 237, 0.08) 0%, transparent 70%);
	filter: blur(60px);
}

/* Page Shell */
.page-shell {
	max-width: 1920px;
	margin: 0 auto;
	padding: 0 2rem;
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

/* Header */
.topbar {
	height: var(--header-height);
	position: sticky;
	top: 0;
	z-index: 50;
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: rgba(var(--bg-rgb), 0.85);
	/* fallback value */
	backdrop-filter: blur(12px);
	border-bottom: 1px solid var(--border);
	margin: 0 -2rem;
	/* Extend to fill width */
	padding: 0 2rem;
	box-shadow: var(--shadow-sm);
}

.topbar-actions {
	display: flex;
	align-items: center;
	gap: 1rem;
	flex: 1;
	justify-content: flex-end;
	min-width: 0;
}

.brand {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	text-decoration: none;
}

.brand-mark {
	width: 36px;
	height: 36px;
	border-radius: var(--radius-sm);
	background: var(--brand-gradient);
	color: white;
	font-family: var(--font-display);
	font-weight: 700;
	font-size: 1.1rem;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3);
}

.brand-text {
	display: flex;
	flex-direction: column;
	line-height: 1.1;
}

.brand-name {
	font-weight: 700;
	font-size: 1rem;
	color: var(--text-primary);
	letter-spacing: -0.01em;
}

.brand-subtitle {
	font-size: 0.75rem;
	color: var(--text-tertiary);
	font-weight: 500;
}

/* Theme Toggle */
.theme-toggle {
	background: transparent;
	border: none;
	color: var(--text-secondary);
	cursor: pointer;
	padding: 0.5rem;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--radius-sm);
	transition: all 0.2s;
}

.theme-toggle:hover {
	color: var(--accent);
	background: var(--bg-surface-secondary);
}

.moon-icon {
	display: none;
}

[data-theme="dark"] .sun-icon {
	display: none;
}

[data-theme="dark"] .moon-icon {
	display: block;
}

/* Search Area */
.search-shell {
	position: relative;
	width: 100%;
	max-width: 480px;
}

.search-input {
	width: 100%;
	padding: 0.6rem 1rem 0.6rem 2.8rem;
	background: var(--bg-surface-secondary);
	border: 1px solid transparent;
	border-radius: var(--radius-md);
	color: var(--text-primary);
	font-family: var(--font-sans);
	font-size: 0.9rem;
	transition: all 0.2s ease;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: 0.8rem center;
	background-size: 1rem;
}

.search-input:focus {
	outline: none;
	background: var(--bg-surface);
	border-color: var(--accent);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-results {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	background: var(--bg-surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-lg);
	max-height: 400px;
	overflow-y: auto;
	z-index: 100;
	padding: 0.5rem;
	display: none;
	/* hidden when empty */
}

.search-results:not(:empty) {
	display: block;
}

.search-result {
	display: block;
	padding: 0.75rem;
	border-radius: var(--radius-sm);
	color: var(--text-primary);
}

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

.search-result-title {
	font-weight: 600;
	font-size: 0.95rem;
	color: var(--accent);
	margin-bottom: 0.2rem;
}

.search-result-excerpt {
	font-size: 0.85rem;
	color: var(--text-secondary);
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* Layout Grid */
.layout {
	display: grid;
	grid-template-columns: var(--sidebar-width) minmax(0, 1fr) 240px;
	gap: 3rem;
	padding-top: 2rem;
	padding-bottom: 4rem;
}

/* Sidebar Navigation */
.sidebar {
	position: sticky;
	top: calc(var(--header-height) + 2rem);
	max-height: calc(100vh - var(--header-height) - 4rem);
	overflow-y: auto;
	padding-right: 1rem;
}

/* Global Scrollbars */
*::-webkit-scrollbar {
	width: 6px;
	height: 6px;
}

*::-webkit-scrollbar-track {
	background: transparent;
}

*::-webkit-scrollbar-thumb {
	background: var(--border);
	border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
	background: var(--text-tertiary);
}

.panel-title {
	font-size: 0.8rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--text-tertiary);
	margin-bottom: 1rem;
	padding-left: 0.75rem;
}

#nav ul {
	list-style: none;
	padding: 0;
	margin: 0;
}

#nav li {
	margin-bottom: 0.25rem;
}

/* Navigation Links */
#nav a {
	display: block;
	padding: 0.5rem 0.75rem;
	font-size: 0.925rem;
	color: var(--text-secondary);
	border-radius: var(--radius-sm);
	font-weight: 500;
}

#nav a:hover {
	color: var(--text-primary);
	background: var(--bg-surface-secondary);
}

#nav a.active {
	color: var(--accent);
	background: var(--accent-light);
	font-weight: 600;
}

/* Nested Nav */
#nav ul ul {
	margin-top: 0.25rem;
	margin-left: 1rem;
	padding-left: 0.75rem;
	border-left: 1px solid var(--border);
}

.nav-group-title {
	display: block;
	padding: 0.5rem 0.75rem;
	font-weight: 700;
	color: var(--text-primary);
	margin-top: 0.5rem;
}

/* Main Content */
.content {
	min-width: 0;
	width: 100%;
}

.doc-card {
	/* No card style for main content in premium design, just clean text on background */
	padding-bottom: 4rem;
	min-width: 0;
	width: 100%;
}

h1:first-child {
	margin-top: 0;
}

/* Markdown Typography */
.markdown-body {
	font-family: var(--font-sans);
	color: var(--text-secondary);
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
	color: var(--text-primary);
	font-family: var(--font-display);
	font-weight: 700;
	letter-spacing: -0.02em;
	scroll-margin-top: calc(var(--header-height) + 2rem);
	position: relative;
}

.markdown-body h1 {
	font-size: 2.5rem;
	margin-bottom: 1.5rem;
	line-height: 1.2;
}

.markdown-body h1::after {
	content: '';
	display: block;
	width: 60px;
	height: 4px;
	background: var(--brand-gradient);
	border-radius: 2px;
	margin-top: 1rem;
}

.markdown-body h2 {
	font-size: 1.75rem;
	margin-top: 2.5rem;
	margin-bottom: 1rem;
	padding-bottom: 0.5rem;
	border-bottom: 1px solid var(--border);
}

.markdown-body h3 {
	font-size: 1.25rem;
	margin-top: 2rem;
	margin-bottom: 0.75rem;
}

.markdown-body p {
	margin-bottom: 1.25rem;
	line-height: 1.7;
	font-size: 1rem;
}

.markdown-body ul,
.markdown-body ol {
	margin-bottom: 1.25rem;
	padding-left: 1.5rem;
}

.markdown-body li {
	margin-bottom: 0.5rem;
}

.markdown-body li::marker {
	color: var(--accent);
}

.markdown-body .task-list-item {
	list-style-type: none;
	margin-left: -1.5rem;
	/* pull back out the padding-left for list items so it aligns with text */
}

.markdown-body .task-list-item-checkbox {
	margin-right: 0.5rem;
	vertical-align: middle;
	accent-color: var(--accent);
	width: 1.1em;
	height: 1.1em;
	position: relative;
	top: -0.1em;
}

.markdown-body a {
	color: var(--accent);
	font-weight: 500;
	border-bottom: 1px solid transparent;
}

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

.markdown-body code {
	font-family: var(--font-mono);
	font-size: 0.875em;
	background: var(--bg-surface-secondary);
	color: var(--text-primary);
	padding: 0.2rem 0.4rem;
	border-radius: 4px;
	border: 1px solid var(--border);
}

.markdown-body pre {
	background: #1e293b;
	/* Keep code blocks dark for contrast */
	color: #f8fafc;
	padding: 1.25rem;
	border-radius: var(--radius-md);
	overflow-x: auto;
	margin: 1.5rem 0;
	box-shadow: var(--shadow-md);
	max-width: 100%;
}

.markdown-body pre code {
	background: transparent;
	padding: 0;
	border: none;
	color: inherit;
	font-size: 0.9em;
}

.markdown-body blockquote {
	margin: 1.5rem 0;
	padding: 1rem 1.5rem;
	background: var(--accent-light);
	border-left: 4px solid var(--accent);
	border-radius: var(--radius-sm);
	color: var(--text-primary);
	font-style: italic;
}

.markdown-body table {
	width: 100%;
	max-width: 100%;
	border-collapse: collapse;
	margin: 1.5rem 0;
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	display: block;
	overflow-x: auto;
}

.markdown-body th {
	background: var(--bg-surface-secondary);
	text-align: left;
	font-weight: 600;
	padding: 0.75rem 1rem;
}

.markdown-body td {
	padding: 0.75rem 1rem;
	border-top: 1px solid var(--border);
}

/* Table of Contents */
.toc {
	position: sticky;
	top: calc(var(--header-height) + 2rem);
	max-height: calc(100vh - var(--header-height) - 4rem);
	overflow-y: auto;
}

#toc-sticky {
	margin-top: 0.5rem;
}

#toc-sticky ul {
	list-style: none;
	padding: 0;
	margin: 0;
}

#toc-sticky li {
	margin-bottom: 0.5rem;
}

#toc-sticky a {
	display: block;
	font-size: 0.875rem;
	color: var(--text-tertiary);
	padding-left: 0.75rem;
	border-left: 2px solid transparent;
	transition: all 0.2s;
}

#toc-sticky a:hover {
	color: var(--text-primary);
}

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

#toc-sticky .level-3 {
	padding-left: 1.5rem;
	font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 1280px) {
	.layout {
		grid-template-columns: 260px 1fr;
	}
}

.toc.mobile-mode {
	position: static;
	max-height: none;
	margin: 1.5rem 0 2.5rem 0;
	padding: 1.5rem;
	background: var(--bg-surface-secondary);
	border-radius: var(--radius-md);
	border: 1px solid var(--border);
	width: auto;
}

.toc.mobile-mode #toc-sticky {
	margin-top: 1rem;
}

.toc.mobile-mode .panel-title {
	margin-bottom: 0;
	padding-left: 0;
}

@media (max-width: 768px) {
	.layout {
		grid-template-columns: 1fr;
	}

	.sidebar {
		display: none;
	}

	.topbar {
		padding: 0 1rem;
		margin: 0 -1rem;
	}

	.page-shell {
		padding: 0 1rem;
	}
}

/* -- Plugins Support -- */

/* Mermaid Diagrams */
.mermaid {
	display: flex;
	justify-content: center;
	margin: 2rem 0;
	padding: 1rem;
	background: var(--bg-surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	overflow-x: auto;
}

/* GitHub Alerts / Admonitions */
.markdown-body .alert {
	border-left-width: 4px;
	border-left-style: solid;
	background: var(--bg-surface);
	padding: 1rem 1.25rem;
	margin: 1.5rem 0;
	border-radius: var(--radius-sm);
	position: relative;
	font-style: normal;
	/* Reset blockquote italic */
}

.alert-note {
	border-left-color: #2563eb;
	/* Blue */
	background-color: #eff6ff;
	color: #1e40af;
}

.alert-tip {
	border-left-color: #10b981;
	/* Emerald */
	background-color: #ecfdf5;
	color: #065f46;
}

.alert-important {
	border-left-color: #7c3aed;
	/* Violet */
	background-color: #f5f3ff;
	color: #5b21b6;
}

.alert-warning {
	border-left-color: #f59e0b;
	/* Amber */
	background-color: #fffbeb;
	color: #92400e;
}

.alert-caution {
	border-left-color: #ef4444;
	/* Red */
	background-color: #fef2f2;
	color: #991b1b;
}

.alert::before {
	content: '';
	display: inline-block;
}

/* Lightbox / Fullscreen Zoom */
.media-wrapper {
	position: relative;
	display: inline-block;
	max-width: 100%;
	width: 100%;
	/* Ensure it takes full width for block elements */
}

.mermaid-wrapper {
	text-align: center;
}

.fullscreen-btn {
	display: block;
	width: 100%;
	padding: 0.5rem;
	margin-top: 0.5rem;
	background: var(--bg-surface-secondary);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	color: var(--text-secondary);
	font-size: 0.85rem;
	font-weight: 500;
	cursor: pointer;
	text-align: center;
	transition: all 0.2s;
}

.fullscreen-btn:hover {
	background: var(--bg-surface);
	color: var(--accent);
	border-color: var(--accent);
}

.lightbox-modal {
	position: fixed;
	inset: 0;
	z-index: 1000;
	background: rgba(15, 23, 42, 0.9);
	backdrop-filter: blur(4px);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

.lightbox-modal.open {
	opacity: 1;
	pointer-events: auto;
}

.lightbox-content-shell {
	flex: 1;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	position: relative;
}

.lightbox-content {
	max-width: 90vw;
	max-height: 85vh;
	transition: transform 0.1s ease-out;
	cursor: grab;
}

.lightbox-content:active {
	cursor: grabbing;
}

.lightbox-content svg,
.lightbox-content img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	background: white;
	/* Ensure diagrams have background */
	border-radius: var(--radius-sm);
}

.markdown-body img {
	max-width: 100%;
	height: auto;
}

.lightbox-controls {
	position: absolute;
	bottom: 2rem;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	gap: 1rem;
	background: rgba(255, 255, 255, 0.1);
	padding: 0.5rem 1rem;
	border-radius: 2rem;
	backdrop-filter: blur(10px);
	z-index: 1001;
}

.lightbox-btn {
	background: transparent;
	border: 1px solid rgba(255, 255, 255, 0.2);
	color: white;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	font-size: 1.2rem;
	transition: all 0.2s;
}

.lightbox-btn:hover {
	background: rgba(255, 255, 255, 0.2);
	border-color: white;
}

.lightbox-close {
	position: absolute;
	top: 1.5rem;
	right: 1.5rem;
	z-index: 1002;
	background: rgba(0, 0, 0, 0.5);
	border: none;
	color: white;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.5rem;
}

.lightbox-close:hover {
	background: rgba(255, 255, 255, 0.2);
}