:root {
	--bg: #ffffff;
	--bg-elevated: #f8f7fa;
	--text: #16151a;
	--text-muted: #57545e;
	--border: #e4e2e8;
	--accent: #7e25f4;
	--accent-strong: #430891;
	--accent-soft: #e3d1fa;
	--accent-contrast: #ffffff;
	--shadow: 0 1px 2px rgba(20, 16, 30, 0.06), 0 4px 10px rgba(20, 16, 30, 0.06);
	--radius: 10px;
	--sidebar-width: 280px;
	--font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

[data-theme='dark'] {
	--bg: #131217;
	--bg-elevated: #1c1b22;
	--text: #f3f2f5;
	--text-muted: #a9a6b0;
	--border: #322f3a;
	--accent: #a45cff;
	--accent-strong: #d9bdff;
	--accent-soft: #2f174f;
	--accent-contrast: #ffffff;
	--shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.35);
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
}

/* Hide the scrollbar everywhere while keeping content scrollable. */
html {
	scrollbar-width: none;
	-ms-overflow-style: none;
}
html::-webkit-scrollbar {
	display: none;
}

body {
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	line-height: 1.65;
	-webkit-font-smoothing: antialiased;
}

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

h1,
h2,
h3,
h4 {
	line-height: 1.25;
	font-weight: 600;
}

/* Header */
.site-header {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 0.75rem 1.25rem;
	border-bottom: 1px solid var(--border);
	background: var(--bg);
	position: sticky;
	top: 0;
	z-index: 20;
}
.site-header .brand {
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--accent);
	margin-right: auto;
}
.site-header form.search-form {
	flex: 1;
	max-width: 420px;
}
.site-header input[type='search'] {
	width: 100%;
}
.theme-toggle,
.menu-toggle {
	background: none;
	border: 1px solid var(--border);
	border-radius: 8px;
	color: var(--text);
	padding: 0.4rem 0.6rem;
	cursor: pointer;
	font-size: 1rem;
	line-height: 1;
}
.menu-toggle {
	display: none;
}

/* Layout: sidebar + content */
.layout {
	display: grid;
	grid-template-columns: var(--sidebar-width) 1fr;
}

.sidebar {
	border-right: 1px solid var(--border);
	background: var(--bg-elevated);
	padding: 1rem 0.75rem;
	overflow-y: auto;
	scrollbar-width: none;
	-ms-overflow-style: none;
}
.sidebar::-webkit-scrollbar {
	display: none;
}
.sidebar nav > ul {
	list-style: none;
	margin: 0;
	padding: 0;
}
.sidebar .category-group {
	margin-bottom: 0.4rem;
}
.sidebar .category-group summary {
	cursor: pointer;
	list-style: none;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.45rem 0.6rem;
	border-radius: 8px;
	font-weight: 600;
	font-size: 0.95rem;
}
.sidebar .category-group summary::-webkit-details-marker {
	display: none;
}
.sidebar .category-group summary:hover {
	background: var(--accent-soft);
}
.sidebar .category-group summary .caret {
	transition: transform 0.15s ease;
	color: var(--text-muted);
}
.sidebar .category-group[open] summary .caret {
	transform: rotate(90deg);
}
.sidebar .tutorial-list {
	list-style: none;
	margin: 0.15rem 0 0.5rem 0;
	padding-inline-start: 0.6rem;
	border-inline-start: 1px solid var(--border);
}
.sidebar .tutorial-list li a {
	display: block;
	padding: 0.35rem 0.6rem;
	border-radius: 6px;
	color: var(--text-muted);
	font-size: 0.9rem;
}
.sidebar .tutorial-list li a:hover {
	background: var(--accent-soft);
	color: var(--text);
	text-decoration: none;
}
.sidebar .tutorial-list li a[aria-current='page'] {
	background: var(--accent);
	color: var(--accent-contrast);
	font-weight: 600;
}
.sidebar .empty {
	color: var(--text-muted);
	font-size: 0.85rem;
	padding: 0.2rem 0.6rem 0.5rem;
}

main.content {
	padding: 2rem clamp(1.25rem, 4vw, 3rem);
	max-width: 860px;
}

/* Category cards on the home page */
.card-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 1rem;
	margin-top: 1.5rem;
}
.card {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	padding: 1rem 1.1rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
	color: var(--text);
	font-weight: 600;
	box-shadow: var(--shadow);
}
.card:hover {
	border-color: var(--accent);
	text-decoration: none;
}
.card .arrow {
	color: var(--accent);
}

/* Tutorial content (rendered markdown) */
.markdown-body :is(h1, h2, h3, h4) {
	margin-top: 1.75em;
}
.markdown-body pre {
	background: var(--bg-elevated);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 0.9rem 1rem;
	overflow-x: auto;
	font-family: var(--font-mono);
	font-size: 0.875rem;
	scrollbar-width: none;
	-ms-overflow-style: none;
}
.markdown-body pre::-webkit-scrollbar {
	display: none;
}
.markdown-body code {
	font-family: var(--font-mono);
	background: var(--bg-elevated);
	padding: 0.15em 0.4em;
	border-radius: 4px;
	font-size: 0.9em;
}
.markdown-body pre code {
	background: none;
	padding: 0;
}
.markdown-body table {
	border-collapse: collapse;
	width: 100%;
}
.markdown-body th,
.markdown-body td {
	border: 1px solid var(--border);
	padding: 0.5rem 0.7rem;
	text-align: left;
}
.markdown-body blockquote {
	border-inline-start: 3px solid var(--accent);
	margin-inline-start: 0;
	padding-inline-start: 1rem;
	color: var(--text-muted);
}

.breadcrumbs {
	font-size: 0.85rem;
	color: var(--text-muted);
	margin-bottom: 0.5rem;
}
.breadcrumbs a {
	color: var(--text-muted);
}

/* Forms (admin + login) */
.form-field {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	margin-bottom: 1.1rem;
}
.form-field label {
	font-weight: 600;
	font-size: 0.9rem;
}
input[type='text'],
input[type='search'],
input[type='password'],
input[type='number'],
select,
textarea {
	font: inherit;
	color: var(--text);
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 0.55rem 0.7rem;
}
textarea {
	font-family: var(--font-mono);
	font-size: 0.9rem;
	min-height: 320px;
	resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}

.btn {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	border: 1px solid var(--accent);
	background: var(--accent);
	color: var(--accent-contrast);
	border-radius: 8px;
	padding: 0.55rem 1.1rem;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}
.btn:hover {
	text-decoration: none;
	filter: brightness(1.08);
}
.btn.secondary {
	background: transparent;
	color: var(--text);
	border-color: var(--border);
}
.btn.danger {
	background: transparent;
	color: #d1435b;
	border-color: #d1435b;
}

.login-shell {
	min-height: 100vh;
	display: grid;
	place-items: center;
	background: var(--bg);
}
.login-card {
	width: 100%;
	max-width: 340px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 2rem;
	box-shadow: var(--shadow);
}

.error-banner {
	background: var(--accent-soft);
	border: 1px solid var(--accent);
	color: var(--text);
	border-radius: 8px;
	padding: 0.6rem 0.8rem;
	margin-bottom: 1rem;
	font-size: 0.9rem;
}

/* Admin */
.admin-nav {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	padding: 0.75rem 1.25rem;
	border-bottom: 1px solid var(--border);
	align-items: center;
}
.admin-nav .brand {
	font-weight: 700;
	color: var(--accent);
	margin-right: auto;
}
.admin-main {
	padding: 2rem clamp(1.25rem, 4vw, 3rem);
	max-width: 960px;
}
table.admin-table {
	width: 100%;
	border-collapse: collapse;
	margin: 1rem 0 2rem;
}
table.admin-table th,
table.admin-table td {
	text-align: left;
	padding: 0.6rem 0.7rem;
	border-bottom: 1px solid var(--border);
}
table.admin-table .row-actions {
	display: flex;
	gap: 0.5rem;
}

@media (max-width: 860px) {
	.menu-toggle {
		display: inline-flex;
	}
	.layout {
		grid-template-columns: 1fr;
	}
	.sidebar {
		position: fixed;
		inset: 57px 0 0 0;
		z-index: 15;
		transform: translateX(-100%);
		transition: transform 0.2s ease;
		width: 85vw;
		max-width: 320px;
	}
	.sidebar.open {
		transform: translateX(0);
		box-shadow: var(--shadow);
	}
}
