/* ================= BASE THEME ================= */
:root {
	/* Primary colors */
	--primary-color: #5e4b8b;
	--primary-light: #8a77b5;
	--primary-dark: #724a95;

	/* Section colors (default to CSS purple) */
	--section-color: #9163b8;
	--section-color-light: #a87dc8;
	--section-color-dark: #724a95;
	--section-color-rgb: 145, 99, 184;

	/* Secondary colors */
	--secondary-color: #444444;
	--secondary-dark: #222222;

	/* Text colors */
	--text-color: #333333;
	--dark-text: #111111;
	--light-text: #666666;
	--editor-text: #d4d4d4;
	--white-text: #ffffff;

	/* Background colors */
	--bg-color: #f8f7fc;
	--panel-bg: #ffffff;
	--code-bg: #f7f5fa;
	--editor-bg: #1e1e1e;
	--editor-highlight: #303030;

	/* Border colors */
	--border-color: #e0e0e0;

	/* Status colors */
	--info-color: #7a93fe;
	--success-color: #9b6dd4;
	--success-color-dark: #7c4dff;
	--success-color-light: #c9b8e8;
	--error-color: #cb6e75;
	--danger-color: #dc3545;

	/* Special colors */
	--primary-bg-light: rgba(94, 75, 139, 0.05);
	--primary-bg-medium: rgba(94, 75, 139, 0.1);
	--primary-bg-instruction: rgba(125, 92, 203, 0.9);
	--success-bg-light: rgba(155, 109, 212, 0.15);
	--modal-bg: rgba(0, 0, 0, 0.5);

	/* Typography */
	--font-main: "Inter", "Segoe UI", Roboto, sans-serif;
	--font-code: "JetBrains Mono", "Fira Code", monospace;

	/* Effects */
	--shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
	--shadow-modal: 0 4px 20px rgba(0, 0, 0, 0.15);

	/* Sizes */
	--header-height: 50px;
	--sidebar-width: 280px;
	--border-radius-sm: 4px;
	--border-radius-md: 6px;
	--border-radius-lg: 8px;
	--spacing-xs: 0.5rem;
	--spacing-sm: 0.75rem;
	--spacing-md: 1rem;
	--spacing-lg: 1.5rem;
	--spacing-xl: 2rem;
}

/* ================= RESET ================= */
* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

/* ================= ACCESSIBILITY ================= */
.skip-link {
	position: absolute;
	top: -100%;
	left: 16px;
	padding: 8px 16px;
	background: var(--primary-dark);
	color: var(--white-text);
	text-decoration: none;
	border-radius: var(--border-radius-sm);
	z-index: 10000;
	transition: top 0.2s ease;
}

.skip-link:focus {
	top: 8px;
}

/* Focus styles - let browser defaults handle most cases */
/* Only enhance for our interactive elements */

/* ================= BASE STYLES ================= */
body {
	font-family: var(--font-main);
	background-color: var(--bg-color);
	color: var(--text-color);
	line-height: 1.5;
	overflow: hidden;
}

code,
kbd {
	font-family: var(--font-code);
}

/* ================= APP CONTAINER ================= */
.app-container {
	display: flex;
	flex-direction: column;
	height: 100vh;
	overflow: hidden;
}

/* ================= HEADER ================= */
.header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	height: var(--header-height);
	padding: 0 var(--spacing-md);
	background: var(--panel-bg);
	border-bottom: 1px solid var(--border-color);
	flex-shrink: 0;
}

.menu-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	background: none;
	border: none;
	cursor: pointer;
	padding: 4px;
	border-radius: var(--border-radius-sm);
}

.menu-toggle:hover {
	background: var(--primary-bg-light);
}

.header-level-pill {
	display: none;
	padding: 4px 12px;
	background: var(--primary-bg-light);
	border-radius: 16px;
	font-size: 0.8rem;
	color: var(--text-muted);
	white-space: nowrap;
	margin-left: var(--spacing-sm);
	text-decoration: none;
	transition:
		background 0.2s,
		color 0.2s;
}

.header-level-pill:hover {
	background: var(--primary-bg-medium);
	color: var(--primary-color);
}

.header-module-name {
	font-weight: 600;
	color: var(--text-color);
}

.header-level {
	margin-left: 0.5em;
}

.header-left {
	display: flex;
	align-items: center;
	gap: var(--spacing-sm);
}

@media (min-width: 769px) {
	.header-level-pill {
		display: block;
	}

	.header {
		display: grid;
		grid-template-columns: 1fr auto 1fr;
		align-items: center;
	}

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

	.header .logo {
		justify-self: center;
	}

	.header-actions {
		justify-self: end;
	}
}

.hamburger-icon {
	position: relative;
	width: 18px;
	height: 2px;
	background-color: var(--text-color);
	border-radius: 1px;
}

.hamburger-icon::before,
.hamburger-icon::after {
	content: "";
	position: absolute;
	left: 0;
	width: 100%;
	height: 2px;
	background-color: var(--text-color);
	border-radius: 1px;
}

.hamburger-icon::before {
	top: -6px;
}

.hamburger-icon::after {
	top: 6px;
}

.logo {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	text-decoration: none;
	cursor: pointer;
}

.logo h1 {
	font-size: 1rem;
	font-weight: 800;
	color: var(--text-color);
	line-height: 1;
	display: flex;
	align-items: center;
	gap: 0.15rem;
}

.logo h1 .code-text {
	color: #9163b8;
}

.logo h1 .crispies-text {
	background: #9163b8;
	color: white;
	padding: 0.15rem 0.35rem;
	border-radius: 4px;
	letter-spacing: 0.05em;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Logo section color coding */
/* CSS uses default colors */

[data-section="html"] .logo h1 .code-text {
	color: #d45aa0;
}

[data-section="html"] .logo h1 .crispies-text {
	background: #d45aa0;
}

[data-section="tailwind"] .logo h1 .code-text {
	color: #1aafb8;
}

[data-section="tailwind"] .logo h1 .crispies-text {
	background: #1aafb8;
}

[data-section="markdown"] .logo h1 .code-text {
	color: #5b8dd9;
}

[data-section="markdown"] .logo h1 .crispies-text {
	background: #5b8dd9;
}

[data-section="javascript"] .logo h1 .code-text {
	color: #d4a017;
}

[data-section="javascript"] .logo h1 .crispies-text {
	background: #d4a017;
}

.help-toggle {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: 2px solid var(--border-color);
	background: none;
	font-weight: bold;
	cursor: pointer;
	color: var(--light-text);
	transition:
		color 0.2s,
		border-color 0.2s;
}

.help-toggle:hover {
	border-color: var(--primary-color);
	color: var(--primary-color);
}

.header-actions {
	display: flex;
	align-items: center;
	gap: var(--spacing-sm);
}

#auth-trigger-header {
	display: none;
}

@media (min-width: 769px) {
	#auth-trigger-header {
		display: inline-flex;
	}
}

/* ================= GAME LAYOUT ================= */
.game-layout {
	display: flex;
	flex: 1;
	min-height: 0;
	overflow: hidden;
	transition: transform 0.3s ease;
}

/* ================= LEFT PANEL ================= */
.left-panel {
	width: 50%;
	display: flex;
	flex-direction: column;
	border-right: 1px solid var(--border-color);
	background: var(--panel-bg);
	min-height: 0;
}

.instructions {
	padding: var(--spacing-md);
	border-bottom: 1px solid var(--border-color);
	max-height: calc(50vh - 60px);
	overflow-y: auto;
}

/* Smooth lesson transition */
#lesson-title,
.lesson-description,
.task-instruction {
	transition: opacity 0.1s ease;
}

.editor-section.transitioning #lesson-title,
.editor-section.transitioning .lesson-description,
.editor-section.transitioning .task-instruction {
	opacity: 0.3;
}

/* Loading fallback notice */
.loading-fallback {
	text-align: center;
	padding: 3rem 1rem;
	color: var(--light-text);
	animation: fadeIn 0.5s ease;
}

.loading-fallback p {
	margin-bottom: 1rem;
}

@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

.module-pill {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	background: var(--primary-bg-medium);
	color: var(--primary-color);
	min-width: 0;
	padding: 4px 12px;
	border-radius: 16px;
	font-size: 0.8rem;
	font-weight: 600;
	min-width: 0;
	flex-shrink: 1;
}

.module-name {
	text-transform: uppercase;
	letter-spacing: 0.5px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	min-width: 0;
}

.module-pill .level-indicator {
	color: var(--primary-dark);
	font-weight: 500;
	opacity: 0.8;
	white-space: nowrap;
	flex-shrink: 0;
}

.lesson-title-row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: var(--spacing-sm);
}

.lesson-title-row .difficulty-wrapper {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-left: auto;
}

#lesson-title {
	font-size: 1.25rem;
	color: var(--primary-dark);
	margin: 0;
}

.share-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	padding: 0;
	background: transparent;
	border: none;
	cursor: pointer;
	color: var(--light-text);
	border-radius: var(--border-radius-sm);
	transition:
		color 0.2s,
		background 0.2s;
}

.share-btn:hover {
	color: var(--primary-color);
	background: var(--primary-bg-light);
}

.share-btn svg {
	width: 16px;
	height: 16px;
}

.completion-badge {
	display: inline-block;
	padding: 0.15rem 0.5rem;
	background: linear-gradient(135deg, #9163b8, #d45aa0, #1aafb8, #7c4dff);
	color: white;
	font-size: 0.7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	border-radius: var(--border-radius-sm);
	vertical-align: middle;
}

.difficulty-badge {
	display: inline-flex;
	align-items: flex-end;
	gap: 2px;
	vertical-align: middle;
}

.difficulty-badge .bar {
	width: 3px;
	border-radius: 1px;
	background: var(--border-color);
}

.difficulty-badge .bar:nth-child(1) { height: 6px; }
.difficulty-badge .bar:nth-child(2) { height: 9px; }
.difficulty-badge .bar:nth-child(3) { height: 12px; }

.difficulty-easy .bar:nth-child(1),
.difficulty-medium .bar:nth-child(1),
.difficulty-medium .bar:nth-child(2),
.difficulty-hard .bar { background: var(--light-text); }

.lesson-description {
	font-size: 0.95rem;
	line-height: 1.6;
	color: var(--text-color);
	margin-top: var(--spacing-lg);
	margin-bottom: var(--spacing-md);
}

.lesson-description kbd,
.lesson-description code {
	background: var(--primary-bg-medium);
	padding: 2px 6px;
	border-radius: 3px;
	font-size: 0.85rem;
}

.lesson-description pre {
	background: var(--code-bg);
	padding: var(--spacing-md);
	border-radius: var(--border-radius-sm);
	overflow-x: auto;
	font-size: 0.85rem;
	margin: var(--spacing-sm) 0;
}

.task-instruction {
	background: var(--primary-bg-instruction);
	color: var(--white-text);
	padding: var(--spacing-sm) var(--spacing-md);
	border-radius: var(--border-radius-sm);
	font-size: 0.9rem;
	line-height: 1.6;
}

.task-instruction kbd,
.task-instruction code {
	background: rgba(255, 255, 255, 0.25);
	padding: 2px 8px;
	border-radius: 4px;
	font-size: 0.9em;
	font-weight: 500;
}

/* ================= EDITOR SECTION ================= */
.editor-section {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 50vh;
	position: relative;
}

/* Playground mode - full height editor */
.editor-section.playground-mode {
	flex: 1;
	min-height: 0;
}

.code-editor {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.editor-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: var(--spacing-xs) var(--spacing-md);
	background: var(--code-bg);
	border-bottom: 1px solid var(--border-color);
}

.editor-label {
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--light-text);
}

.editor-actions {
	display: flex;
	align-items: center;
	gap: var(--spacing-sm);
}

.editor-content {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
	background: var(--editor-bg);
	overflow: hidden;
}

/* CodeMirror container styles */
.editor-content .cm-editor {
	flex: 1;
	height: 100%;
}

/* Read-only zones (codePrefix/codeSuffix) */
.cm-readonly-zone {
	opacity: 0.5;
	background: rgba(100, 100, 120, 0.1);
}

.editor-content .cm-scroller {
	overflow: auto;
}

/* Legacy textarea (fallback) */
.code-input {
	flex: 1;
	width: 100%;
	padding: var(--spacing-md);
	background: var(--editor-bg);
	color: var(--editor-text);
	border: none;
	font-family: var(--font-code);
	font-size: 14px;
	line-height: 1.5;
	resize: none;
	outline: none;
}

.code-input::placeholder {
	color: #666;
}

/* ================= HINT AREA ================= */
.hint-area {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: var(--spacing-sm) var(--spacing-md);
	background: rgba(30, 30, 30, 0.9);
	backdrop-filter: blur(4px);
	z-index: 5;
}

.hint-area:empty {
	display: none;
}

.hint {
	display: flex;
	align-items: center;
	gap: var(--spacing-sm);
	padding: var(--spacing-xs) var(--spacing-sm);
	background: rgba(94, 75, 139, 0.3);
	border-left: 3px solid var(--primary-light);
	border-radius: var(--border-radius-sm);
	color: var(--editor-text);
}

.hint-progress {
	background: var(--primary-color);
	color: white;
	padding: 2px 8px;
	border-radius: 10px;
	font-size: 0.75rem;
	font-weight: bold;
	flex-shrink: 0;
}

.hint-message {
	font-size: 0.9rem;
	color: var(--editor-text);
}

.hint-message kbd,
.hint-message code {
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	padding: 2px 6px;
	border-radius: 3px;
	font-size: 0.85rem;
	font-family: var(--font-code);
}

.hint-success {
	background: var(--success-bg-light);
	border-left-color: var(--success-color);
}

.hint-success .hint-progress {
	background: var(--success-color);
}

/* ================= RIGHT PANEL ================= */
.right-panel {
	width: 50%;
	display: flex;
	flex-direction: column;
	background: var(--bg-color);
	min-height: 0;
}

.preview-section {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
	position: relative;
}

/* Glow behind preview-wrapper when matched */
.preview-section.matched::before {
	content: "";
	position: absolute;
	inset: var(--spacing-md);
	border-radius: var(--border-radius-md);
	background: conic-gradient(from var(--border-angle), #9163b8, #d45aa0, #1aafb8, #7c4dff, #9163b8);
	filter: blur(30px);
	opacity: 0;
	animation: spin-glow 3s ease-out forwards;
	pointer-events: none;
}

/* Persistent glow for completed lessons */
.preview-section.completed-glow::before {
	content: "";
	position: absolute;
	inset: var(--spacing-md);
	border-radius: var(--border-radius-md);
	background: conic-gradient(from 0deg, #9163b8, #d45aa0, #1aafb8, #7c4dff, #9163b8);
	filter: blur(30px);
	opacity: 0.35;
	pointer-events: none;
}

.preview-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: var(--spacing-xs) var(--spacing-md) var(--spacing-md);
	background: transparent;
}

.preview-label {
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--light-text);
}

.preview-wrapper {
	flex: 1;
	position: relative;
	background: var(--panel-bg);
	margin: var(--spacing-md);
	border-radius: var(--border-radius-md);
	box-shadow: var(--shadow);
	overflow: hidden;
	min-height: 0;
	border: 6px solid transparent;
	z-index: 1;
}

.preview-frame {
	width: 100%;
	height: 100%;
	padding: var(--spacing-xs);
}

.preview-frame iframe {
	width: 100%;
	height: 100%;
	border: none;
	border-radius: var(--border-radius-sm);
}

/* Expected Overlay (toggleable) */
.expected-overlay {
	position: absolute;
	inset: 0;
	background: var(--panel-bg);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease;
	display: flex;
	align-items: center;
	justify-content: center;
}

.expected-overlay.visible {
	opacity: 1;
	pointer-events: auto;
}

.expected-frame {
	width: 100%;
	height: 100%;
	padding: var(--spacing-xs);
}

.expected-frame iframe {
	width: 100%;
	height: 100%;
	border: none;
	border-radius: var(--border-radius-sm);
}

/* Success Match Animation - Rotating gradient border */
@property --border-angle {
	syntax: "<angle>";
	initial-value: 0deg;
	inherits: false;
}

/* Persistent gradient border for completed lessons */
.preview-wrapper.completed-glow {
	border: 6px solid transparent;
	background:
		linear-gradient(var(--panel-bg), var(--panel-bg)) padding-box,
		conic-gradient(from 0deg, #9163b8, #d45aa0, #1aafb8, #7c4dff, #9163b8) border-box;
}

.preview-wrapper.matched {
	--border-angle: 0deg;
	border: 6px solid transparent;
	background:
		linear-gradient(var(--panel-bg), var(--panel-bg)) padding-box,
		conic-gradient(from var(--border-angle), #9163b8, #d45aa0, #1aafb8, #7c4dff, #9163b8) border-box;
	animation: spin-border 3s ease-out forwards;
	overflow: visible;
}

/* Animated CRISPY speech bubble with SVG tail */
.preview-wrapper.matched::after {
	content: var(--crispy-quote, "Crispyyyyyy!");
	position: absolute;
	left: 55%;
	bottom: 0;
	transform: translateX(-50%) translateY(100%) scale(0.5);
	font-family:
		system-ui,
		-apple-system,
		sans-serif;
	font-size: 2rem;
	font-weight: 800;
	letter-spacing: 0.05em;
	color: white;
	background: linear-gradient(135deg, #9163b8 0%, #d45aa0 50%, #7c4dff 100%);
	padding: 1.25rem 2rem 1.75rem;
	z-index: 10;
	pointer-events: none;
	animation: crispy-bounce 2.7s ease-in-out 0.3s forwards;
	opacity: 0;
	white-space: nowrap;
	filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 120' preserveAspectRatio='none'%3E%3Cpath d='M20,0 h160 a20,20 0 0 1 20,20 v60 a20,20 0 0 1 -20,20 h-65 l-15,20 l-15,-20 h-65 a20,20 0 0 1 -20,-20 v-60 a20,20 0 0 1 20,-20 z' fill='white'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 120' preserveAspectRatio='none'%3E%3Cpath d='M20,0 h160 a20,20 0 0 1 20,20 v60 a20,20 0 0 1 -20,20 h-65 l-15,20 l-15,-20 h-65 a20,20 0 0 1 -20,-20 v-60 a20,20 0 0 1 20,-20 z' fill='white'/%3E%3C/svg%3E");
	-webkit-mask-size: 100% 100%;
	mask-size: 100% 100%;
}

@keyframes spin-border {
	0% {
		--border-angle: 0deg;
	}
	80% {
		--border-angle: -288deg;
	}
	100% {
		--border-angle: -360deg;
	}
}

@keyframes spin-glow {
	0% {
		--border-angle: 0deg;
		opacity: 0;
	}
	10% {
		opacity: 0.8;
	}
	80% {
		--border-angle: -288deg;
		opacity: 0.6;
	}
	100% {
		--border-angle: -360deg;
		opacity: 0.35;
	}
}

/* Bowl smiley peek animation from bottom right corner */
.preview-wrapper.matched .preview-frame {
	position: relative;
	overflow: hidden;
}

.preview-wrapper.matched .preview-frame::before {
	content: "";
	position: absolute;
	bottom: 0;
	left: 50%;
	width: max(200px, 50%);
	aspect-ratio: 1;
	background: url("/bowl.png") center/contain no-repeat;
	z-index: 5;
	pointer-events: none;
	animation: bowl-peek 3s ease-in-out forwards;
	transform: translateX(-50%) translateY(100%);
}

@keyframes bowl-peek {
	0% {
		transform: translateX(-50%) translateY(100%);
		opacity: 0;
	}
	20% {
		transform: translateX(-50%) translateY(25%);
		opacity: 1;
	}
	35% {
		transform: translateX(-50%) translateY(30%);
	}
	65% {
		transform: translateX(-50%) translateY(28%);
	}
	100% {
		transform: translateX(-50%) translateY(100%);
		opacity: 0;
	}
}

@keyframes crispy-bounce {
	0% {
		transform: translateX(-50%) translateY(100%) scale(0.5);
		opacity: 0;
	}
	20% {
		transform: translateX(-50%) translateY(-180%) scale(1.1);
		opacity: 1;
	}
	35% {
		transform: translateX(-50%) translateY(-170%) scale(1);
	}
	65% {
		transform: translateX(-50%) translateY(-172%) scale(1);
	}
	100% {
		transform: translateX(-50%) translateY(100%) scale(0.5);
		opacity: 0;
	}
}

/* ================= GAME CONTROLS ================= */
.game-controls {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	gap: var(--spacing-md);
	align-items: center;
	padding: var(--spacing-md);
	background: var(--panel-bg);
	border-bottom: 1px solid var(--border-color);
	box-shadow: 0 10px 20px -10px rgba(0, 0, 0, 0.08);
}

.game-controls #prev-btn {
	justify-self: start;
}

.game-controls .module-pill {
	justify-self: center;
}

.game-controls #next-btn {
	justify-self: end;
}

/* ================= SIDEBAR ================= */
.sidebar-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.4);
	opacity: 0;
	visibility: hidden;
	transition:
		opacity 0.3s,
		visibility 0.3s;
	z-index: 199;
}

.sidebar-backdrop.visible {
	opacity: 1;
	visibility: visible;
}

.sidebar-drawer {
	position: fixed;
	left: calc(-1 * var(--sidebar-width));
	top: 0;
	width: var(--sidebar-width);
	height: 100vh;
	background: var(--panel-bg);
	box-shadow: var(--shadow-modal);
	transition: left 0.3s ease;
	z-index: 200;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.sidebar-drawer.open {
	left: 0;
}

/* Shift main content when sidebar is open */
.app-container:has(.sidebar-drawer.open) .game-layout {
	transform: translateX(calc(var(--sidebar-width) * 0.8));
}

.sidebar-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: var(--spacing-md);
	border-bottom: 1px solid var(--border-color);
	flex-shrink: 0;
}

.sidebar-header h3 {
	font-size: 1.1rem;
	color: var(--primary-dark);
}

.close-btn {
	width: 32px;
	height: 32px;
	border: none;
	background: none;
	font-size: 1.5rem;
	cursor: pointer;
	color: var(--light-text);
	border-radius: var(--border-radius-sm);
}

.close-btn:hover {
	background: var(--primary-bg-light);
	color: var(--primary-color);
}

.sidebar-section {
	padding: var(--spacing-md);
	border-bottom: 1px solid var(--border-color);
}

.sidebar-section:last-child {
	border-bottom: none;
}

/* Mobile navigation in sidebar */
.sidebar-nav-mobile {
	display: flex;
	flex-direction: column;
	gap: 0;
}

.sidebar-nav-link {
	display: block;
	padding: 0.6rem var(--spacing-md);
	font-size: 0.9rem;
	font-weight: 500;
	text-decoration: none;
	color: var(--text-color);
	border-bottom: 1px solid var(--border-color);
}

.sidebar-nav-link:last-child {
	border-bottom: none;
}

.sidebar-nav-link:hover {
	background: var(--primary-bg-light);
	color: var(--primary-color);
}

.sidebar-auth-link {
	width: calc(100% - 2 * var(--spacing-md));
	margin: var(--spacing-sm) var(--spacing-md);
	padding: 0.5rem 1rem;
	text-align: center;
	background: var(--primary-color);
	color: var(--white-text);
	border: none;
	border-radius: var(--border-radius-md);
	cursor: pointer;
	font-family: inherit;
	font-weight: 500;
}

.sidebar-auth-link:hover {
	background: var(--primary-dark);
}

@media (min-width: 769px) {
	.sidebar-nav-mobile {
		display: none;
	}
}

/* Make the lessons nav section fill available space */
nav.sidebar-section:not(.sidebar-nav-mobile) {
	flex: 1;
	overflow-y: auto;
	min-height: 0;
	padding-bottom: var(--spacing-md);
}

.sidebar-nav-mobile {
	flex: none;
	padding: 0;
}

.sidebar-section h4 {
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 1px;
	color: var(--light-text);
	margin-bottom: var(--spacing-sm);
}

/* Progress Display */
.progress-display {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-xs);
}

.progress-bar {
	height: 8px;
	background: var(--border-color);
	border-radius: 4px;
	overflow: hidden;
}

.progress-fill {
	height: 100%;
	background: linear-gradient(90deg, #9163b8, #d45aa0, #1aafb8, #7c4dff);
	background-size: calc(100% * 100 / var(--progress-percent, 100)) 100%;
	border-radius: 4px;
	transition: width 0.3s ease;
	width: 0%;
}

.progress-text {
	font-size: 0.85rem;
	color: var(--light-text);
}

.progress-bar-row {
	display: flex;
	align-items: center;
	gap: var(--spacing-sm);
}

.progress-bar-row .progress-bar {
	flex: 1;
}

.progress-current {
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--text-color);
	white-space: nowrap;
}

.progress-total {
	font-size: 0.75rem;
	color: var(--light-text);
}

/* Milestone Progress */
.milestone-progress {
	gap: var(--spacing-sm);
}

.milestones {
	display: flex;
	justify-content: space-between;
	padding: 0 2px;
}

.milestone {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 24px;
	height: 24px;
	font-size: 0.7rem;
	font-weight: 600;
	color: var(--light-text);
	background: var(--border-color);
	border-radius: 50%;
	transition: all 0.3s ease;
}

.milestone.reached {
	color: white;
}

/* Each milestone gets a color evenly distributed across the gradient
   Gradient: #9163b8 (0%) → #d45aa0 (33%) → #1aafb8 (67%) → #7c4dff (100%) */
.milestone.reached:nth-child(1) { background: #a55eac; } /* ~14% */
.milestone.reached:nth-child(2) { background: #c459a2; } /* ~28% */
.milestone.reached:nth-child(3) { background: #d45aa0; } /* ~33% pink */
.milestone.reached:nth-child(4) { background: #a874a8; } /* ~43% */
.milestone.reached:nth-child(5) { background: #7785ac; } /* ~50% */
.milestone.reached:nth-child(6) { background: #33a3b6; } /* ~62% */
.milestone.reached:nth-child(7) { background: #4889d8; } /* ~80% */
.milestone.reached:nth-child(8) { background: #7c4dff; } /* 100% */

.milestone.current {
	color: white;
	transform: scale(1.15);
	box-shadow: 0 2px 8px rgba(145, 99, 184, 0.4);
}

.milestone.next {
	border: 2px dashed var(--light-text);
	background: transparent;
}

/* Milestone celebration animation */
@keyframes milestone-pop {
	0% {
		transform: scale(1);
	}
	50% {
		transform: scale(1.4);
	}
	100% {
		transform: scale(1.15);
	}
}

.milestone.just-reached {
	animation: milestone-pop 0.5s ease-out;
}

/* Sidebar section grouping headers */
.sidebar-section-header {
	font-size: 0.7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--light-text);
	padding: 0.75rem 0.75rem 0.25rem;
	margin: 0.5rem 0 0;
	border-left: 3px solid transparent;
}

.sidebar-section-header:first-child {
	margin-top: 0;
}

/* Module List in Sidebar */
.module-list {
	/* No max-height - parent nav.sidebar-section handles overflow */
}

.module-container {
	margin-bottom: 4px;
}

.module-header {
	display: flex;
	align-items: center;
	padding: var(--spacing-xs) var(--spacing-sm);
	cursor: pointer;
	border-radius: var(--border-radius-sm);
	font-weight: 600;
	font-size: 0.9rem;
	transition: background 0.2s;
}

.module-header:hover {
	background: var(--primary-bg-light);
}

/* Native details/summary styling */
details.module-container {
	margin: 0;
}

summary.module-header {
	list-style: none;
	cursor: pointer;
}

summary.module-header::-webkit-details-marker {
	display: none;
}

summary.module-header::before {
	content: "";
	display: block;
	flex-shrink: 0;
	width: 10px;
	height: 10px;
	margin-right: 8px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M3 1 L7 5 L3 9' stroke='%23666' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-size: contain;
	background-repeat: no-repeat;
	transition: transform 0.2s;
}

details.module-container[open] > summary.module-header::before {
	transform: rotate(90deg);
}

.module-header.completed::after {
	content: "✓";
	margin-left: 8px;
	color: var(--success-color);
}

.lessons-container {
	margin-left: 16px;
	border-left: 2px solid var(--border-color);
	padding-left: 8px;
}

.lesson-list-item {
	padding: 6px 10px;
	border-radius: var(--border-radius-sm);
	cursor: pointer;
	font-size: 0.85rem;
	margin: 2px 0;
	transition: background 0.2s;
}

.lesson-list-item:hover {
	background: var(--primary-bg-light);
}

.lesson-list-item.active {
	background: var(--primary-bg-medium);
	font-weight: 600;
}

.lesson-list-item.completed::before {
	content: "✓";
	margin-right: 6px;
	color: var(--success-color);
}

/* Sidebar focus styles - enhance visibility without overriding defaults */
.module-header:focus,
.lesson-list-item:focus {
	background: var(--primary-bg-light);
}

/* Button reset for sidebar items (when converted to buttons) */
button.module-header,
button.lesson-list-item {
	border: none;
	background: none;
	text-align: left;
	width: 100%;
	font-family: inherit;
	color: inherit;
}

/* ================= BUTTONS ================= */
.btn {
	padding: var(--spacing-xs) var(--spacing-md);
	border-radius: var(--border-radius-sm);
	border: 1px solid var(--border-color);
	background: var(--panel-bg);
	color: var(--text-color);
	cursor: pointer;
	font-family: var(--font-main);
	font-size: 0.9rem;
	transition:
		background 0.2s,
		color 0.2s,
		border-color 0.2s;
}

.btn:hover {
	background: var(--code-bg);
}

.btn img {
	width: 0.8rem;
	height: 0.8rem;
	margin-right: 0.3rem;
}

.btn-primary {
	background: var(--section-color, var(--primary-color));
	color: var(--white-text);
	border-color: var(--section-color-dark, var(--primary-dark));
}

.btn-primary:hover {
	background: var(--section-color-dark, var(--primary-dark));
}

.btn-run {
	background: var(--secondary-color);
	color: var(--white-text);
	border-color: var(--secondary-dark);
}

.btn-run:hover {
	background: var(--secondary-dark);
}

.btn-run.success {
	background: var(--success-color);
	border-color: var(--success-color-dark);
}

.btn-small {
	padding: 4px 10px;
	font-size: 0.8rem;
}

.btn-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 4px 8px;
	font-size: 1rem;
	min-width: 32px;
	background: transparent;
	color: var(--light-text);
	border: 1px solid var(--border-color);
}

.btn-icon:hover {
	background: var(--bg-color);
	color: var(--text-color);
	border-color: var(--section-color, var(--primary-color));
}

.btn-icon img,
.btn-icon svg {
	width: 1rem;
	height: 1rem;
	margin: 0;
	display: block;
}

.editor-tools {
	display: flex;
	gap: 4px;
}

.btn-ghost {
	background: transparent;
	color: var(--light-text);
	border: 1px solid var(--border-color);
}

.btn-ghost:hover {
	background: var(--bg-color);
	color: var(--danger-color);
	border-color: var(--danger-color);
}

.btn-text {
	background: transparent;
	color: var(--light-text);
	border: none;
	font-size: 0.85rem;
	text-decoration: underline;
	padding: var(--spacing-xs) 0;
}

.btn-text:hover {
	background: transparent;
	color: var(--danger-color);
}

.btn-danger {
	background: var(--danger-color);
	color: white;
	border-color: var(--danger-color);
}

.btn-danger:hover {
	background: #c82333;
	border-color: #bd2130;
}

.btn-text.btn-danger {
	background: transparent;
	color: var(--danger-color);
	border: none;
}

.btn-text.btn-danger:hover {
	color: #c82333;
	text-decoration: underline;
}

#reset-code-btn {
	background: var(--section-color, var(--primary-color));
	color: white;
	border-color: var(--section-color, var(--primary-color));
}

#reset-code-btn:hover {
	background: var(--section-color-dark, var(--primary-dark));
	border-color: var(--section-color-dark, var(--primary-dark));
}

/* Hide Run button - live preview is stable */
#run-btn {
	display: none;
}

/* ================= SETTINGS CARD ================= */
.settings-card {
	background: var(--bg-color);
	border: 1px solid var(--border-color);
	border-radius: var(--border-radius-md);
	overflow: hidden;
}

.settings-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.75rem 1rem;
	border-bottom: 1px solid var(--border-color);
}

.settings-row:last-child {
	border-bottom: none;
}

.settings-label {
	font-size: 0.9rem;
	color: var(--text-color);
}

.settings-toggle {
	width: 40px;
	height: 22px;
	appearance: none;
	background: var(--border-color);
	border-radius: 11px;
	position: relative;
	cursor: pointer;
	transition: background 0.2s;
}

.settings-toggle::before {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 18px;
	height: 18px;
	background: white;
	border-radius: 50%;
	transition: transform 0.2s;
}

.settings-toggle:checked {
	background: var(--primary-color);
}

.settings-toggle:checked::before {
	transform: translateX(18px);
}

/* Legacy setting row (for label + control) */
.setting-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: var(--spacing-sm);
}

.setting-label {
	font-size: 0.9rem;
	color: var(--text-color);
}

/* Language select */
.lang-select {
	padding: 6px 10px;
	border: 1px solid var(--border-color);
	border-radius: var(--radius-sm);
	background: var(--panel-bg);
	color: var(--text-color);
	font-size: 0.85rem;
	cursor: pointer;
	min-width: 120px;
}

.lang-select:hover {
	border-color: var(--primary-color);
}

.lang-select:focus {
	outline: none;
	border-color: var(--primary-color);
	box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.toggle-switch {
	display: flex;
	align-items: center;
	cursor: pointer;
	margin-bottom: var(--spacing-sm);
}

.toggle-switch input {
	opacity: 0;
	width: 0;
	height: 0;
}

.toggle-slider {
	position: relative;
	display: inline-block;
	width: 36px;
	height: 20px;
	background: #ccc;
	border-radius: 20px;
	transition: background 0.3s;
	margin-right: 8px;
	flex-shrink: 0;
}

.toggle-slider::before {
	content: "";
	position: absolute;
	height: 16px;
	width: 16px;
	left: 2px;
	bottom: 2px;
	background: white;
	border-radius: 50%;
	transition: transform 0.3s;
}

input:checked + .toggle-slider {
	background: var(--primary-color);
}

input:checked + .toggle-slider::before {
	transform: translateX(16px);
}

.toggle-label {
	font-size: 0.9rem;
	color: var(--text-color);
}

/* ================= DIALOG (Native HTML) ================= */
.dialog {
	border: none;
	border-radius: var(--border-radius-lg);
	box-shadow: var(--shadow-modal);
	padding: 0;
	width: 90%;
	max-width: 600px;
	max-height: 80vh;
	overflow-y: auto;
	background: var(--panel-bg);
	/* Ensure centering - native dialog should center, but explicit for safety */
	margin: auto;
	position: fixed;
	inset: 0;
	height: fit-content;
}

.dialog::backdrop {
	background: var(--modal-bg);
}

.dialog-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: var(--spacing-md);
	border-bottom: 1px solid var(--border-color);
}

.dialog-header h3 {
	margin: 0;
}

.dialog-close {
	background: none;
	border: none;
	font-size: 1.5rem;
	cursor: pointer;
	color: var(--light-text);
	line-height: 1;
	padding: 0;
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition:
		background 0.2s,
		color 0.2s;
}

.dialog-close:hover {
	background: var(--primary-bg-light);
	color: var(--primary-color);
}

.dialog-content {
	padding: var(--spacing-lg);
}

.dialog-content h4 {
	margin-top: var(--spacing-md);
	margin-bottom: var(--spacing-xs);
	color: var(--dark-text);
}

.dialog-content h4:first-child {
	margin-top: 0;
}

.dialog-content p {
	margin-bottom: var(--spacing-md);
}

.dialog-content ul,
.dialog-content ol {
	margin: 0 0 var(--spacing-md) 0;
	padding-left: var(--spacing-lg);
}

.dialog-content li {
	margin-bottom: var(--spacing-xs);
}

.dialog-content kbd {
	background: var(--code-bg);
	padding: 2px 6px;
	border-radius: var(--border-radius-sm);
	font-size: 0.85em;
	border: 1px solid var(--border-color);
}

.help-nav-links {
	font-size: 0.9rem;
	color: var(--light-text);
	padding: var(--spacing-sm) var(--spacing-md);
	background: var(--bg-color);
	border-radius: var(--border-radius-sm);
	margin-top: var(--spacing-sm);
}

.help-nav-links a {
	color: var(--primary-color);
	text-decoration: none;
	font-weight: 500;
}

.help-nav-links a:hover {
	text-decoration: underline;
}

.dialog-actions {
	display: flex;
	justify-content: flex-end;
	gap: var(--spacing-sm);
	margin-top: var(--spacing-lg);
}

/* Share Dialog */
.share-url-container {
	display: flex;
	gap: var(--spacing-sm);
	margin: var(--spacing-md) 0;
}

.share-url-input {
	flex: 1;
	padding: var(--spacing-sm);
	border: 1px solid var(--border-color);
	border-radius: var(--border-radius-sm);
	font-family: var(--font-code);
	font-size: 0.85rem;
	background: var(--code-bg);
	color: var(--text-color);
}

.share-url-input:focus {
	outline: none;
	border-color: var(--primary-color);
}

.copy-feedback {
	color: var(--success-color);
	font-size: 0.9rem;
	margin-top: var(--spacing-sm);
}

[dir="rtl"] .share-url-container {
	flex-direction: row-reverse;
}

/* ================= AUTH DIALOG ================= */
.auth-dialog {
	max-width: 400px;
}

.auth-form {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-md);
}

.form-field {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.form-field label {
	font-size: 0.875rem;
	font-weight: 500;
	color: var(--light-text);
}

.form-field input {
	padding: 0.75rem 1rem;
	border: 2px solid var(--border-color);
	border-radius: var(--border-radius-md);
	font-size: 1rem;
	font-family: var(--font-main);
	transition: border-color 0.2s;
}

.form-field input:focus {
	outline: none;
	border-color: var(--primary-color);
}

.btn-full {
	width: 100%;
}

.btn-sm {
	padding: 0.375rem 0.75rem;
	font-size: 0.875rem;
}

.auth-error {
	color: var(--danger-color);
	font-size: 0.875rem;
	margin: 0;
}

.auth-success {
	color: var(--success-color);
	font-size: 0.875rem;
	margin: 0;
}

.auth-instructions {
	color: var(--light-text);
	font-size: 0.9rem;
	margin-bottom: var(--spacing-sm);
}

.auth-links {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.5rem;
	margin-top: var(--spacing-md);
	padding-top: var(--spacing-md);
	border-top: 1px solid var(--border-color);
}

.auth-links .btn-text {
	font-size: 0.875rem;
	color: var(--primary-color);
	text-decoration: none;
	cursor: pointer;
}

.auth-links .btn-text:hover {
	color: var(--primary-color-dark, var(--primary-color));
	text-decoration: underline;
}

/* Social Login */
.auth-social {
	margin-top: var(--spacing-lg);
}

.auth-divider {
	display: flex;
	align-items: center;
	gap: var(--spacing-md);
	margin-bottom: var(--spacing-md);
	color: var(--light-text);
	font-size: 0.875rem;
}

.auth-divider::before,
.auth-divider::after {
	content: "";
	flex: 1;
	height: 1px;
	background: var(--border-color);
}

.auth-social-buttons {
	display: flex;
	gap: 0.75rem;
}

.btn-social {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.75rem 1rem;
	border: 2px solid var(--border-color);
	border-radius: var(--border-radius-md);
	background: var(--panel-bg);
	font-weight: 500;
	cursor: pointer;
	transition:
		border-color 0.2s,
		background 0.2s;
}

.btn-social:hover {
	border-color: var(--primary-color);
	background: var(--primary-bg-light);
}

.social-icon {
	width: 1.25rem;
	height: 1.25rem;
}

/* Header Auth Button */
.user-menu {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.user-email {
	font-size: 0.875rem;
	color: var(--light-text);
	max-width: 150px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Sidebar Auth Box (dark design) */
.sidebar-auth-box {
	margin-top: var(--spacing-md);
	padding: var(--spacing-md);
	background: #1a1a2e;
	border-radius: var(--border-radius-md);
	color: #e0e0e0;
}

.sidebar-auth-box h4 {
	color: #fff;
	margin-bottom: var(--spacing-sm);
}

.sidebar-auth-box .btn-outline {
	background: transparent;
	color: #e0e0e0;
	border-color: #444;
}

.sidebar-auth-box .btn-outline:hover {
	background: #2a2a4e;
	border-color: #666;
	color: #fff;
}

.user-menu-sidebar {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.user-menu-sidebar .user-email {
	max-width: none;
	word-break: break-all;
	font-size: 0.875rem;
	color: #aaa;
	font-weight: 500;
}

.sidebar-auth-hint {
	font-size: 0.8rem;
	color: #888;
	margin-top: var(--spacing-sm);
}

/* Footer Legal Links */
.footer-legal {
	margin-top: var(--spacing-xs);
	font-size: 0.85rem;
}

.footer-legal .btn-text {
	color: var(--light-text);
	font-size: 0.85rem;
	text-decoration: none;
	padding: 0;
}

.footer-legal .btn-text:hover {
	color: var(--text-color);
	text-decoration: underline;
}

.footer-separator {
	color: var(--light-text);
	margin: 0 0.5rem;
}

/* Legal Dialogs (Privacy, Imprint) */
.legal-dialog {
	max-width: 600px;
}

.legal-content {
	max-height: 60vh;
	overflow-y: auto;
}

.legal-content h4 {
	margin-top: var(--spacing-md);
	margin-bottom: var(--spacing-xs);
	font-size: 1rem;
	color: var(--text-color);
}

.legal-content p {
	margin-bottom: var(--spacing-sm);
	line-height: 1.6;
	color: var(--light-text);
}

.legal-content a {
	color: var(--primary-color);
}

.legal-updated {
	margin-top: var(--spacing-md);
	font-size: 0.85rem;
	font-style: italic;
	color: var(--lighter-text);
}

/* Project Cards in Help Dialog */
.project-cards {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-sm);
	margin-bottom: var(--spacing-md);
}

.project-card {
	display: block;
	padding: var(--spacing-md);
	background: var(--primary-bg-light);
	border-radius: var(--border-radius-md);
	border: 1px solid var(--primary-bg-medium);
	text-decoration: none;
	color: var(--text-color);
	transition:
		background 0.2s,
		border-color 0.2s,
		transform 0.2s,
		box-shadow 0.2s;
}

.project-card:hover {
	background: var(--primary-bg-medium);
	border-color: var(--primary-color);
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(94, 75, 139, 0.15);
}

.project-card strong {
	display: block;
	color: var(--primary-color);
	font-size: 1rem;
	margin-bottom: 4px;
}

.project-card span {
	font-size: 0.9rem;
	color: var(--light-text);
	line-height: 1.4;
}

/* ================= FOOTER ================= */
.app-footer {
	padding: var(--spacing-md);
	font-size: 0.7rem;
	color: var(--light-text);
	text-align: center;
	border-top: 1px solid var(--border-color);
	margin-top: auto;
}

.app-footer a {
	color: var(--primary-color);
	text-decoration: none;
}

/* ================= MAIN NAV ================= */
.main-nav {
	display: none;
	align-items: center;
	gap: var(--spacing-xs);
}

.nav-link {
	padding: 6px 12px;
	border-radius: var(--border-radius-sm);
	text-decoration: none;
	font-size: 0.85rem;
	font-weight: 500;
	color: var(--light-text);
	transition:
		background 0.2s,
		color 0.2s;
}

.nav-link:hover {
	background: var(--primary-bg-light);
	color: var(--text-color);
}

.nav-link.active {
	background: var(--primary-bg-medium);
	color: var(--primary-color);
}

.nav-link-ref {
	margin-left: 1rem;
}

@media (min-width: 769px) {
	.main-nav {
		display: flex;
	}
}

/* ================= LANDING PAGE ================= */
.landing-page {
	flex: 1;
	overflow-y: auto;
	background: var(--bg-color);
}

.landing-content {
	max-width: 900px;
	margin: 0 auto;
	padding: var(--spacing-lg);
}

.hero {
	text-align: center;
	padding: 3rem 1rem;
}

.hero-logo {
	margin-bottom: 1rem;
}

.hero h1 {
	font-size: 2.5rem;
	font-weight: 800;
	color: var(--text-color);
	line-height: 1.2;
	margin-bottom: 1rem;
}

.hero-highlight {
	color: var(--primary-color);
}

.hero-subtitle {
	font-size: 1.1rem;
	color: var(--light-text);
	max-width: 500px;
	margin: 0 auto 2rem;
}

.hero .cta-button {
	margin-top: 1rem;
}

/* Why It Works Section */
.why-it-works {
	padding: 3rem 1rem;
	text-align: center;
}

.why-it-works h2 {
	font-size: 1.75rem;
	color: var(--primary-dark);
	margin-bottom: 2rem;
}

.benefits-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: var(--spacing-lg);
	text-align: left;
}

.benefit-card {
	background: var(--panel-bg);
	padding: var(--spacing-lg);
	border-radius: var(--border-radius-lg);
	box-shadow: var(--shadow);
	transition:
		transform 0.2s,
		box-shadow 0.2s;
}

.benefit-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.benefit-icon {
	width: 48px;
	height: 48px;
	color: var(--primary-color);
	margin-bottom: var(--spacing-md);
}

.benefit-card h3 {
	font-size: 1.1rem;
	color: var(--primary-dark);
	margin-bottom: var(--spacing-sm);
}

.benefit-card p {
	color: var(--light-text);
	line-height: 1.6;
	font-size: 0.95rem;
}

.benefit-card a {
	color: var(--primary-color);
	text-decoration: none;
}

.benefit-card a:hover {
	text-decoration: underline;
}

/* Learning Paths Section */
.learning-paths {
	padding: 2rem 1rem 3rem;
	text-align: center;
}

.learning-paths h2 {
	font-size: 1.75rem;
	color: var(--primary-dark);
	margin-bottom: 0;
}

/* Section Cards */
.section-cards {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
	gap: var(--spacing-lg);
	margin-top: 2rem;
}

.section-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: var(--spacing-lg);
	background: var(--panel-bg);
	border-radius: var(--border-radius-lg);
	box-shadow: var(--shadow);
	text-decoration: none;
	color: var(--text-color);
	transition:
		transform 0.2s,
		box-shadow 0.2s;
}

.section-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.section-card-icon {
	width: 60px;
	height: 60px;
	border-radius: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 800;
	font-size: 1.2rem;
	color: white;
	margin-bottom: var(--spacing-md);
}

.section-card h2,
.section-card h3 {
	font-size: 1.25rem;
	margin-bottom: var(--spacing-xs);
}

.section-card p {
	font-size: 0.9rem;
	color: var(--light-text);
	text-align: center;
	margin-bottom: var(--spacing-sm);
}

.section-card-progress {
	font-size: 0.8rem;
	color: var(--primary-color);
	font-weight: 500;
}

.section-card-disabled {
	cursor: not-allowed;
	opacity: 0.7;
	position: relative;
}

.section-card-disabled:hover {
	transform: none;
	box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.coming-soon-badge {
	display: inline-block;
	background: linear-gradient(135deg, #7c6f8a, #5e5168);
	color: white;
	font-size: 0.65rem;
	font-weight: 600;
	padding: 3px 8px;
	border-radius: 10px;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.section-card-disabled .coming-soon-badge {
	position: absolute;
	top: 12px;
	right: 12px;
}

.topic-link-disabled {
	cursor: not-allowed;
	opacity: 0.6;
}

.topic-link-disabled .coming-soon-badge {
	margin-left: 8px;
	vertical-align: middle;
}

/* Landing About Section */
.landing-about {
	padding: 3rem 1rem;
	text-align: center;
}

.landing-about h2 {
	font-size: 1.75rem;
	color: var(--primary-dark);
	margin-bottom: 2rem;
}

.about-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 2rem;
	text-align: left;
}

.about-item {
	text-align: center;
}

.about-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 2.5rem;
	background: var(--primary-color);
	color: white;
	font-weight: 700;
	font-size: 1.1rem;
	border-radius: 50%;
	margin-bottom: 1rem;
}

.about-item h3 {
	font-size: 1rem;
	color: var(--primary-dark);
	margin-bottom: 0.5rem;
}

.about-item p {
	color: var(--light-text);
	line-height: 1.6;
}

/* Landing Features */
.landing-features {
	padding: 2rem 1rem;
	max-width: 800px;
	margin: 0 auto;
}

.feature-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 3rem;
}

.feature-text h3 {
	font-size: 1rem;
	color: var(--primary-dark);
	margin-bottom: 0.5rem;
}

.feature-text p {
	color: var(--light-text);
	line-height: 1.6;
	font-size: 0.95rem;
}

@media (max-width: 600px) {
	.feature-row {
		grid-template-columns: 1fr;
		gap: 1.5rem;
	}
}

/* Coming Soon Section */
.coming-soon {
	margin-top: var(--spacing-xl);
	text-align: center;
}

.coming-soon h2 {
	font-size: 1.5rem;
	color: var(--primary-dark);
	margin-bottom: var(--spacing-lg);
}

.coming-soon-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: var(--spacing-md);
}

.coming-soon-card {
	background: var(--panel-bg);
	border-radius: var(--border-radius-md);
	padding: 1.5rem 1rem;
	text-align: center;
	border: 1px dashed var(--border-color);
	opacity: 0.85;
	transition: opacity 0.2s, border-color 0.2s;
}

.coming-soon-card:hover {
	opacity: 1;
	border-color: var(--section-color);
}

.coming-soon-icon {
	display: block;
	margin-bottom: 0.75rem;
}

.coming-soon-icon svg {
	width: 2rem;
	height: 2rem;
	stroke: var(--section-color);
}

.coming-soon-card h3 {
	font-size: 1rem;
	margin-bottom: 0.5rem;
	color: var(--text-color);
}

.coming-soon-card p {
	font-size: 0.85rem;
	color: var(--light-text);
	line-height: 1.5;
	margin: 0;
}

@media (max-width: 900px) {
	.coming-soon-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 500px) {
	.coming-soon-grid {
		grid-template-columns: 1fr;
	}
}

/* Newsletter Signup */
.newsletter-signup {
	margin-top: var(--spacing-lg);
	padding: 1.5rem;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
}

.newsletter-signup p {
	margin: 0;
	color: var(--light-text);
}

.newsletter-form {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
	justify-content: center;
}

.newsletter-form input[type="email"] {
	padding: 0.5rem 1rem;
	border: 2px solid var(--border-color);
	border-radius: var(--border-radius-sm);
	background: var(--panel-bg);
	color: var(--text);
	font-size: 1rem;
	min-width: 200px;
}

.newsletter-form input[type="email"]:focus {
	outline: none;
	border-color: var(--section-color);
}

.newsletter-signup .btn-outline {
	border: 2px solid var(--section-color);
	color: var(--section-color);
	background: transparent;
	padding: 0.5rem 1.5rem;
	font-weight: 500;
	transition: all 0.2s;
}

.newsletter-signup .btn-outline:hover {
	background: var(--section-color);
	color: white;
}

.newsletter-disclaimer {
	font-size: 0.8rem;
	opacity: 0.7;
}

.newsletter-thanks {
	color: var(--success);
	font-weight: 500;
}

.newsletter-thanks.hidden {
	display: none;
}

/* Device Notice */
.device-notice {
	margin-top: var(--spacing-lg);
	text-align: center;
	padding: 0.75rem 1.5rem;
	background: linear-gradient(135deg, rgba(145, 99, 184, 0.1), rgba(212, 90, 160, 0.1), rgba(26, 175, 184, 0.1));
	border-radius: var(--border-radius-md);
	color: var(--light-text);
	font-size: 0.9rem;
}

.device-notice strong {
	color: var(--text-color);
}

/* Landing CTA */
.landing-cta {
	text-align: center;
	padding: 3rem 1rem;
	background: var(--panel-bg);
	border-radius: var(--border-radius-lg);
	margin-top: var(--spacing-lg);
}

.landing-cta h2 {
	font-size: 1.5rem;
	color: var(--primary-dark);
	margin-bottom: var(--spacing-sm);
}

.cta-button {
	display: inline-block;
	padding: 1rem 2.5rem;
	background: var(--primary-color);
	color: white;
	text-decoration: none;
	border-radius: var(--border-radius-md);
	font-weight: 600;
	font-size: 1.1rem;
	transition:
		background 0.2s,
		transform 0.2s,
		box-shadow 0.2s;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.cta-button:hover {
	background: var(--primary-dark);
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cta-sub {
	color: var(--light-text);
	font-size: 0.875rem;
	margin-top: 1rem;
}

/* ================= LANDING FOOTER ================= */
.landing-footer {
	margin-top: 3rem;
	padding-top: 2rem;
	border-top: 1px solid var(--border-color);
}

.footer-grid {
	display: grid;
	grid-template-columns: 2fr 1fr 1fr 1fr;
	gap: 2rem;
	margin-bottom: 2rem;
}

.footer-section h4 {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--text-color);
	margin-bottom: 1rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.footer-links {
	list-style: none;
	padding: 0;
	margin: 0;
}

.footer-links li {
	margin-bottom: 0.5rem;
}

.footer-links a {
	color: var(--light-text);
	text-decoration: none;
	font-size: 0.875rem;
	transition: color 0.2s;
}

.footer-links a:hover {
	color: var(--primary-color);
}

#footer-lesson-links,
#ref-footer-lesson-links,
#section-footer-lesson-links {
	display: flex;
	gap: 2rem;
}

.footer-section-group {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	min-width: 0;
}

.footer-section-group strong {
	margin-bottom: 0.5rem;
}

.footer-section-group strong a {
	color: var(--text-color);
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.footer-section-group a {
	display: inline-block;
	color: #888;
	text-decoration: none;
	font-size: 0.7rem;
	font-weight: 500;
	background: rgba(0, 0, 0, 0.03);
	padding: 4px 10px;
	border-radius: 12px;
	max-width: 140px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.footer-section-group a:hover {
	color: var(--primary-color);
	background: rgba(0, 0, 0, 0.06);
}

.footer-support p {
	color: var(--light-text);
	font-size: 0.875rem;
	margin-bottom: 1rem;
}

.footer-bottom {
	text-align: center;
	padding-top: 1.5rem;
	border-top: 1px solid var(--border-color);
}

.footer-bottom p {
	color: var(--light-text);
	font-size: 0.8rem;
	margin: 0;
}

.footer-bottom a {
	color: var(--light-text);
}

.footer-bottom a:hover {
	color: var(--primary-color);
}

@media (max-width: 768px) {
	.footer-grid {
		grid-template-columns: 1fr 1fr;
		gap: 1.5rem;
	}
}

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

/* ================= SECTION PAGE ================= */
.section-page {
	flex: 1;
	overflow-y: auto;
	background: var(--bg-color);
	padding: var(--spacing-lg);
}

.section-hero {
	text-align: center;
	padding: 2rem 1rem;
	max-width: 600px;
	margin: 0 auto;
}

.section-hero h1 {
	font-size: 2rem;
	color: var(--primary-dark);
	margin-bottom: var(--spacing-xs);
}

.section-hero p {
	color: var(--light-text);
	margin-bottom: var(--spacing-md);
}

.section-progress-bar {
	max-width: 400px;
	margin: 0 auto;
}

.section-progress-bar .progress-bar {
	height: 8px;
	margin-bottom: var(--spacing-xs);
}

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

/* Section Intro - Educational Content (GitBook-style side-by-side) */
.section-intro {
	padding: 0 var(--spacing-md);
}

/* Section Overview - intro paragraph */
.section-overview {
	padding: 1.5rem 0 2rem;
	border-bottom: 1px solid var(--border-color);
	margin-bottom: 0.5rem;
}

.section-overview p {
	color: var(--text-color);
	line-height: 1.7;
	margin-bottom: 1rem;
	max-width: 85ch;
}

.section-overview p:last-child {
	margin-bottom: 0;
}

.section-overview strong {
	color: var(--section-color-dark, var(--primary-dark));
}

.section-overview code {
	background: rgba(var(--section-color-rgb, 217, 90, 138), 0.1);
	color: var(--section-color-dark, var(--primary-dark));
	padding: 0.1rem 0.35rem;
	border-radius: 4px;
	font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
	font-size: 0.85em;
}

/* Topic Row - side by side layout */
.topic-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 2rem;
	padding: 2rem 0;
	border-bottom: 1px solid var(--border-color);
	align-items: start;
}

.topic-row:last-child {
	border-bottom: none;
}

.topic-text h2 {
	font-size: 1.25rem;
	color: var(--section-color-dark, var(--primary-dark));
	margin: 0 0 0.75rem;
}

.topic-text h3 {
	font-size: 1rem;
	color: var(--section-color-dark, var(--primary-dark));
	margin: 0 0 0.5rem;
}

.topic-text p {
	color: var(--text-color);
	line-height: 1.6;
	margin: 0 0 1rem;
}

.topic-text p:last-child {
	margin-bottom: 0;
}

.topic-link {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	margin-top: 1.25rem;
	padding: 0.75rem 1.5rem;
	background: var(--section-color, var(--primary-color));
	color: white;
	text-decoration: none;
	border-radius: var(--border-radius-md);
	font-size: 1rem;
	font-weight: 600;
	transition:
		background 0.2s,
		transform 0.2s,
		box-shadow 0.2s;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.topic-link:hover {
	background: var(--section-color-dark, var(--primary-dark));
	transform: translateY(-1px);
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.topic-link::after {
	content: "→";
	transition: transform 0.2s;
}

.topic-link:hover::after {
	transform: translateX(3px);
}

/* Secondary reference link in topic sections */
.topic-ref {
	display: block;
	margin-top: 0.75rem;
	color: var(--light-text);
	font-size: 0.9rem;
	text-decoration: none;
}

.topic-ref:hover {
	color: var(--section-color, var(--primary-color));
	text-decoration: underline;
}

/* See-also in section overviews */
.section-see-also {
	margin-top: var(--spacing-md);
	font-size: 0.9rem;
	color: var(--light-text);
}

.section-see-also a {
	color: var(--section-color, var(--primary-color));
	text-decoration: none;
}

.section-see-also a:hover {
	text-decoration: underline;
}

/* Inline code in topic text */
.topic-text code {
	background: rgba(var(--section-color-rgb, 217, 90, 138), 0.1);
	color: var(--section-color-dark, var(--primary-dark));
	padding: 0.15rem 0.4rem;
	border-radius: 4px;
	font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
	font-size: 0.9em;
}

/* Code Examples */
.topic-code {
	position: sticky;
	top: 1rem;
}

.code-block {
	background: #0d1117;
	border-radius: var(--border-radius-md);
	border: 1px solid #30363d;
	overflow: hidden;
}

/* Fallback styles for pre/code (before CodeMirror initializes) */
.code-block pre {
	margin: 0;
	padding: 1rem;
	overflow-x: auto;
}

.code-block code {
	font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
	font-size: 0.8rem;
	line-height: 1.6;
	color: #e6edf3;
	white-space: pre;
}

/* CodeMirror styles within code blocks */
.code-block .cm-editor {
	background: transparent;
}

.code-block .cm-scroller {
	overflow-x: auto;
}

.code-caption {
	font-size: 0.75rem;
	color: var(--light-text);
	margin-top: 0.5rem;
}

/* Responsive: stack on mobile */
@media (max-width: 900px) {
	.topic-row {
		grid-template-columns: 1fr;
		gap: 1rem;
	}

	.topic-code {
		position: static;
	}
}

/* Module Grid */
.module-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: var(--spacing-md);
	max-width: 1000px;
	margin: 0 auto;
}

.module-card {
	display: block;
	padding: var(--spacing-md);
	background: var(--panel-bg);
	border-radius: var(--border-radius-md);
	box-shadow: var(--shadow);
	text-decoration: none;
	color: var(--text-color);
	border-left: 4px solid var(--primary-color);
	transition:
		transform 0.2s,
		box-shadow 0.2s;
}

.module-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.module-card h3 {
	font-size: 1rem;
	color: var(--primary-dark);
	margin-bottom: var(--spacing-xs);
}

.module-card-meta {
	display: flex;
	justify-content: space-between;
	font-size: 0.8rem;
	color: var(--light-text);
}

.module-card-progress {
	color: var(--success-color);
	font-weight: 500;
}

/* ================= REFERENCE PAGES ================= */
.reference-page {
	flex: 1;
	overflow-y: auto;
	background: var(--bg-color);
}

.reference-content {
	max-width: 900px;
	margin: 0 auto;
	padding: var(--spacing-lg);
}

.reference-nav {
	display: flex;
	flex-wrap: wrap;
	gap: var(--spacing-sm);
	padding: var(--spacing-md);
	background: var(--panel-bg);
	border-radius: var(--border-radius-md);
	margin-bottom: var(--spacing-lg);
}

.ref-nav-link {
	padding: var(--spacing-xs) var(--spacing-sm);
	border-radius: var(--border-radius-sm);
	text-decoration: none;
	color: var(--text-color);
	font-size: 0.9rem;
	font-weight: 500;
	transition:
		background 0.2s,
		color 0.2s;
}

.ref-nav-link:hover {
	background: var(--hover-bg);
}

.ref-nav-link.active {
	background: var(--primary-color);
	color: white;
}

.reference-body h1 {
	font-size: 1.75rem;
	margin-bottom: var(--spacing-sm);
	color: var(--primary-dark);
}

.ref-intro {
	font-size: 1rem;
	color: var(--light-text);
	margin-bottom: var(--spacing-lg);
	line-height: 1.6;
}

.ref-section {
	margin-top: var(--spacing-xl);
	margin-bottom: var(--spacing-xl);
}

.ref-section:first-of-type {
	margin-top: 0;
}

.ref-section h2 {
	font-size: 1.2rem;
	margin-bottom: var(--spacing-md);
	color: var(--text-color);
	border-bottom: 2px solid var(--border-color);
	padding-bottom: var(--spacing-xs);
}

.ref-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9rem;
	background: var(--panel-bg);
	border-radius: var(--border-radius-md);
	overflow: hidden;
	box-shadow: var(--shadow);
}

.ref-table thead {
	background: var(--hover-bg);
}

.ref-table th,
.ref-table td {
	padding: var(--spacing-sm) var(--spacing-md);
	text-align: left;
	border-bottom: 1px solid var(--border-color);
}

.ref-table th {
	font-weight: 600;
	color: var(--text-color);
}

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

.ref-table tr:hover {
	background: var(--hover-bg);
}

.ref-table code {
	background: var(--code-bg);
	padding: 0.15rem 0.4rem;
	border-radius: 4px;
	font-size: 0.85em;
	color: var(--primary-dark);
}

/* Collapsible table rows */
.ref-table-more {
	margin-top: -1px;
}

.ref-table-more summary {
	padding: var(--spacing-sm) var(--spacing-md);
	background: var(--hover-bg);
	cursor: pointer;
	font-size: 0.85rem;
	color: var(--light-text);
	border-radius: 0 0 var(--border-radius-md) var(--border-radius-md);
	list-style: none;
	text-align: center;
}

.ref-table-more summary::-webkit-details-marker {
	display: none;
}

.ref-table-more summary:hover {
	background: var(--border-color);
	color: var(--text-color);
}

.ref-table-more[open] summary {
	border-radius: 0;
}

.ref-table-continuation {
	border-radius: 0 0 var(--border-radius-md) var(--border-radius-md);
	margin-top: 0;
}

.ref-list {
	background: var(--panel-bg);
	border-radius: var(--border-radius-md);
	padding: var(--spacing-md) var(--spacing-md) var(--spacing-md) var(--spacing-xl);
	box-shadow: var(--shadow);
}

.ref-list li {
	padding: var(--spacing-xs) 0;
	line-height: 1.6;
}

.ref-list code {
	background: var(--code-bg);
	padding: 0.15rem 0.4rem;
	border-radius: 4px;
	font-size: 0.85em;
}

/* Reference page code blocks */
.reference-body .code-block {
	margin: var(--spacing-md) 0;
}

/* Cross-reference links in reference pages */
.ref-see-also {
	margin-top: var(--spacing-lg);
	padding: var(--spacing-md);
	background: linear-gradient(135deg, rgba(155, 89, 182, 0.1), rgba(0, 188, 212, 0.1));
	border-radius: var(--border-radius-md);
	font-size: 0.95rem;
	color: var(--text-color);
	border: 1px solid rgba(155, 89, 182, 0.2);
}

.ref-see-also a {
	color: var(--section-color, var(--primary-color));
	text-decoration: none;
	font-weight: 600;
	padding: 0.25rem 0.5rem;
	background: rgba(255, 255, 255, 0.1);
	border-radius: var(--border-radius-sm);
	transition: background 0.2s, transform 0.2s;
}

.ref-see-also a:hover {
	background: var(--section-color, var(--primary-color));
	color: white;
	transform: translateY(-1px);
}

/* Responsive reference tables */
@media (max-width: 600px) {
	.ref-table {
		font-size: 0.8rem;
	}

	.ref-table th,
	.ref-table td {
		padding: var(--spacing-xs) var(--spacing-sm);
	}

	.reference-nav {
		position: static;
	}

	.ref-nav-link {
		font-size: 0.8rem;
	}
}

/* ================= UTILITY ================= */
.hidden {
	display: none !important;
}

/* ================= RESPONSIVE ================= */
@media (max-width: 768px) {
	.game-layout {
		flex-direction: column;
		overflow-y: auto;
	}

	.left-panel,
	.right-panel {
		width: 100%;
		flex-shrink: 0;
		border-right: none;
		display: contents;
	}

	/* Mobile order: nav -> instructions -> preview -> editor */
	.game-controls {
		order: 1;
		padding: var(--spacing-sm);
	}

	.instructions {
		order: 2;
		max-height: none;
		overflow-y: visible;
	}

	.preview-section {
		order: 3;
		display: flex;
		flex-direction: column;
		min-height: 50vh;
	}

	.preview-section .preview-header {
		order: 1;
	}

	.preview-section .preview-wrapper {
		order: 2;
	}

	.editor-section {
		order: 4;
		display: flex;
		flex-direction: column;
		min-height: 50vh;
	}

	.preview-wrapper {
		flex: 1;
		margin: var(--spacing-sm);
		min-height: 40vh;
	}

	.editor-content {
		flex: 1;
		min-height: 45vh;
	}

	.module-pill {
		flex: 1;
		min-width: 0;
		max-width: 100%;
		margin: 0 var(--spacing-sm);
		justify-content: center;
		overflow: hidden;
	}

	.module-name {
		flex: 1;
		min-width: 0;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.level-label {
		display: none;
	}

	.btn {
		padding: var(--spacing-xs) var(--spacing-sm);
		font-size: 0.85rem;
	}
}

@media (max-width: 480px) {
	.logo h1 {
		font-size: 0.9rem;
	}

	.logo img {
		width: 32px;
	}

	#lesson-title {
		font-size: 1.1rem;
	}

	.lesson-description {
		font-size: 0.9rem;
	}

	.task-instruction {
		font-size: 0.85rem;
	}

	.code-input {
		font-size: 13px;
	}
}

/* ================== RTL SUPPORT ================== */

/* RTL: Sidebar slides from right */
[dir="rtl"] .sidebar-drawer {
	left: auto;
	right: calc(-1 * var(--sidebar-width));
	transition: right 0.3s ease;
}

[dir="rtl"] .sidebar-drawer.open {
	right: 0;
}

/* RTL: Content shifts to left when sidebar opens */
[dir="rtl"] .app-container:has(.sidebar-drawer.open) .game-layout {
	transform: translateX(calc(-1 * var(--sidebar-width) * 0.8));
}

/* RTL: Editor tools */
[dir="rtl"] .editor-tools {
	flex-direction: row-reverse;
}

/* RTL: Navigation buttons */
[dir="rtl"] .nav-controls {
	flex-direction: row-reverse;
}

/* RTL: Hint layout */
[dir="rtl"] .hint {
	flex-direction: row-reverse;
	text-align: right;
	border-left: none;
	border-right: 3px solid var(--primary-light);
}

[dir="rtl"] .hint-success {
	border-right-color: var(--success-color);
}

/* RTL: Module list items */
[dir="rtl"] .module-header {
	flex-direction: row-reverse;
}

[dir="rtl"] .lesson-list button {
	text-align: right;
}

/* RTL: Lesson progress indicator */
[dir="rtl"] .lesson-list button::before {
	margin-left: var(--spacing-sm);
	margin-right: 0;
}

/* RTL: Content areas - use auto direction for mixed content */
[dir="rtl"] .lesson-description,
[dir="rtl"] .task-instruction {
	direction: auto;
	unicode-bidi: plaintext;
}

/* RTL: Code editor always LTR */
[dir="rtl"] .editor-content,
[dir="rtl"] .CodeMirror {
	direction: ltr;
	text-align: left;
}

/* RTL: Preview always LTR (code output) */
[dir="rtl"] .preview-wrapper,
[dir="rtl"] #preview-area {
	direction: ltr;
}

/* RTL: Dialog close button */
[dir="rtl"] .dialog-close {
	left: var(--spacing-sm);
	right: auto;
}

/* RTL: Keep logo in LTR order */
[dir="rtl"] .logo {
	direction: ltr;
}

/* RTL: Swap left/right panels */
[dir="rtl"] .game-layout {
	flex-direction: row-reverse;
}

/* RTL: Left panel border flips to left side */
[dir="rtl"] .left-panel {
	border-right: none;
	border-left: 1px solid var(--border-color);
}

/* RTL: Lessons container indentation flips */
[dir="rtl"] .lessons-container {
	margin-left: 0;
	margin-right: 16px;
	border-left: none;
	border-right: 2px solid var(--border-color);
	padding-left: 0;
	padding-right: 8px;
}

/* RTL: Module header - chevron on right, text right-aligned */
[dir="rtl"] summary.module-header {
	justify-content: flex-end;
	text-align: right;
}

[dir="rtl"] summary.module-header::before {
	order: 1;
	margin-left: 8px;
	margin-right: 0;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M7 1 L3 5 L7 9' stroke='%23666' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

[dir="rtl"] details.module-container[open] > summary.module-header::before {
	transform: rotate(-90deg);
}

/* RTL: Lesson items - text right-aligned */
[dir="rtl"] .lesson-list-item {
	text-align: right;
}

/* RTL: Lesson checkmark on right */
[dir="rtl"] .lesson-list-item.completed::before {
	float: right;
	margin-left: 6px;
	margin-right: 0;
}

/* RTL: Module completed checkmark position (::after) */
[dir="rtl"] .module-header.completed::after {
	margin-left: 0;
	margin-right: 8px;
}

/* RTL: Lesson checkmark position */
[dir="rtl"] .lesson-list-item.completed::before {
	margin-left: 6px;
	margin-right: 0;
}

/* RTL: Header level pill */
[dir="rtl"] .header-level-pill {
	margin-left: 0;
	margin-right: var(--spacing-sm);
}

[dir="rtl"] .header-level {
	margin-left: 0;
	margin-right: 0.5em;
}

/* RTL: Toggle switch slider */
[dir="rtl"] .toggle-slider {
	margin-right: 0;
	margin-left: 8px;
}

[dir="rtl"] .preview-controls {
	flex-direction: row-reverse;
}

/* RTL: Lesson title row */
[dir="rtl"] .lesson-title-row {
	flex-direction: row-reverse;
}

/* RTL: Lists - bullets/numbers on right side */
[dir="rtl"] .lesson-description ul,
[dir="rtl"] .lesson-description ol {
	padding-left: 0;
	padding-right: 1.5em;
}

[dir="rtl"] .lesson-description li {
	text-align: right;
}

/* RTL: Pre/code blocks stay LTR */
[dir="rtl"] pre,
[dir="rtl"] code,
[dir="rtl"] kbd {
	direction: ltr;
	text-align: left;
}

/* ================= SECTION COLOR CODING ================= */
/* CSS Section uses default pink from :root */

/* HTML Section - Pink (balanced) */
[data-section="html"] {
	--section-color: #d45aa0;
	--section-color-light: #e07ab5;
	--section-color-dark: #b24485;
	--section-color-rgb: 212, 90, 160;
}

/* Tailwind Section - Teal (balanced) */
[data-section="tailwind"] {
	--section-color: #1aafb8;
	--section-color-light: #3fc1c9;
	--section-color-dark: #0d8f96;
	--section-color-rgb: 26, 175, 184;
}

/* Markdown Section - Blue */
[data-section="markdown"] {
	--section-color: #5b8dd9;
	--section-color-light: #7ba3e5;
	--section-color-dark: #4070b8;
	--section-color-rgb: 91, 141, 217;
}

/* JavaScript Section - Gold */
[data-section="javascript"] {
	--section-color: #d4a017;
	--section-color-light: #e0b840;
	--section-color-dark: #b08610;
	--section-color-rgb: 212, 160, 23;
}

/* Apply section colors to nav links */
.nav-link[data-section="css"] {
	color: #9163b8;
}

.nav-link[data-section="html"] {
	color: #d45aa0;
}

.nav-link[data-section="tailwind"] {
	color: #1aafb8;
}

.nav-link[data-section="markdown"] {
	color: #5b8dd9;
}

.nav-link[data-section="javascript"] {
	color: #d4a017;
}

.nav-link[data-section="css"]:hover,
.nav-link[data-section="css"].active {
	background: rgba(145, 99, 184, 0.1);
	color: #724a95;
}

.nav-link[data-section="html"]:hover,
.nav-link[data-section="html"].active {
	background: rgba(212, 90, 160, 0.1);
	color: #b24485;
}

.nav-link[data-section="tailwind"]:hover,
.nav-link[data-section="tailwind"].active {
	background: rgba(26, 175, 184, 0.1);
	color: #0d8f96;
}

.nav-link[data-section="markdown"]:hover,
.nav-link[data-section="markdown"].active {
	background: rgba(91, 141, 217, 0.1);
	color: #4070b8;
}

.nav-link[data-section="javascript"]:hover,
.nav-link[data-section="javascript"].active {
	background: rgba(212, 160, 23, 0.1);
	color: #b08610;
}

/* Hint section colors */
body[data-section="css"] .hint {
	background: rgba(145, 99, 184, 0.3);
	border-left-color: #a98cd6;
}

body[data-section="css"] .hint-progress {
	background: #9163b8;
}

body[data-section="html"] .hint {
	background: rgba(212, 90, 160, 0.3);
	border-left-color: #d97a94;
}

body[data-section="html"] .hint-progress {
	background: #d45aa0;
}

body[data-section="tailwind"] .hint {
	background: rgba(26, 175, 184, 0.3);
	border-left-color: #4db6ac;
}

body[data-section="tailwind"] .hint-progress {
	background: #1aafb8;
}

body[data-section="markdown"] .hint {
	background: rgba(91, 141, 217, 0.3);
	border-left-color: #7ba3e5;
}

body[data-section="markdown"] .hint-progress {
	background: #5b8dd9;
}

body[data-section="javascript"] .hint {
	background: rgba(212, 160, 23, 0.3);
	border-left-color: #e0b840;
}

body[data-section="javascript"] .hint-progress {
	background: #d4a017;
}

/* RTL hint border */
[dir="rtl"] body[data-section="css"] .hint {
	border-right-color: #a98cd6;
}

[dir="rtl"] body[data-section="html"] .hint {
	border-right-color: #d97a94;
}

[dir="rtl"] body[data-section="tailwind"] .hint {
	border-right-color: #4db6ac;
}

[dir="rtl"] body[data-section="markdown"] .hint {
	border-right-color: #7ba3e5;
}

[dir="rtl"] body[data-section="javascript"] .hint {
	border-right-color: #e0b840;
}

/* Reference nav link colors */
.ref-nav-link[data-ref="css"],
.ref-nav-link[data-ref="selectors"],
.ref-nav-link[data-ref="flexbox"],
.ref-nav-link[data-ref="grid"] {
	color: #9163b8;
}

.ref-nav-link[data-ref="css"]:hover,
.ref-nav-link[data-ref="css"].active,
.ref-nav-link[data-ref="selectors"]:hover,
.ref-nav-link[data-ref="selectors"].active,
.ref-nav-link[data-ref="flexbox"]:hover,
.ref-nav-link[data-ref="flexbox"].active,
.ref-nav-link[data-ref="grid"]:hover,
.ref-nav-link[data-ref="grid"].active {
	background: rgba(145, 99, 184, 0.15);
	color: #724a95;
}

.ref-nav-link[data-ref="html"] {
	color: #d45aa0;
}

.ref-nav-link[data-ref="html"]:hover,
.ref-nav-link[data-ref="html"].active {
	background: rgba(212, 90, 160, 0.15);
	color: #b24485;
}

/* CodeMirror section color overrides */
body[data-section="css"] .cm-editor .cm-content {
	caret-color: #9163b8 !important;
}

body[data-section="css"] .cm-editor .cm-cursor,
body[data-section="css"] .cm-editor .cm-dropCursor {
	border-left-color: #9163b8 !important;
}

body[data-section="css"] .cm-editor .cm-selectionBackground,
body[data-section="css"] .cm-editor .cm-content ::selection {
	background-color: rgba(145, 99, 184, 0.25) !important;
}

body[data-section="css"] .cm-editor .cm-activeLine {
	background-color: rgba(145, 99, 184, 0.08) !important;
}

body[data-section="html"] .cm-editor .cm-content {
	caret-color: #d45aa0 !important;
}

body[data-section="html"] .cm-editor .cm-cursor,
body[data-section="html"] .cm-editor .cm-dropCursor {
	border-left-color: #d45aa0 !important;
}

body[data-section="html"] .cm-editor .cm-selectionBackground,
body[data-section="html"] .cm-editor .cm-content ::selection {
	background-color: rgba(212, 90, 160, 0.25) !important;
}

body[data-section="html"] .cm-editor .cm-activeLine {
	background-color: rgba(212, 90, 160, 0.08) !important;
}

body[data-section="tailwind"] .cm-editor .cm-content {
	caret-color: #1aafb8 !important;
}

body[data-section="tailwind"] .cm-editor .cm-cursor,
body[data-section="tailwind"] .cm-editor .cm-dropCursor {
	border-left-color: #1aafb8 !important;
}

body[data-section="tailwind"] .cm-editor .cm-selectionBackground,
body[data-section="tailwind"] .cm-editor .cm-content ::selection {
	background-color: rgba(26, 175, 184, 0.25) !important;
}

body[data-section="tailwind"] .cm-editor .cm-activeLine {
	background-color: rgba(26, 175, 184, 0.08) !important;
}

body[data-section="markdown"] .cm-editor .cm-content {
	caret-color: #5b8dd9 !important;
}

body[data-section="markdown"] .cm-editor .cm-cursor,
body[data-section="markdown"] .cm-editor .cm-dropCursor {
	border-left-color: #5b8dd9 !important;
}

body[data-section="markdown"] .cm-editor .cm-selectionBackground,
body[data-section="markdown"] .cm-editor .cm-content ::selection {
	background-color: rgba(91, 141, 217, 0.25) !important;
}

body[data-section="markdown"] .cm-editor .cm-activeLine {
	background-color: rgba(91, 141, 217, 0.08) !important;
}

body[data-section="javascript"] .cm-editor .cm-content {
	caret-color: #d4a017 !important;
}

body[data-section="javascript"] .cm-editor .cm-cursor,
body[data-section="javascript"] .cm-editor .cm-dropCursor {
	border-left-color: #d4a017 !important;
}

body[data-section="javascript"] .cm-editor .cm-selectionBackground,
body[data-section="javascript"] .cm-editor .cm-content ::selection {
	background-color: rgba(212, 160, 23, 0.25) !important;
}

body[data-section="javascript"] .cm-editor .cm-activeLine {
	background-color: rgba(212, 160, 23, 0.08) !important;
}

/* Module pill section colors */
body[data-section="css"] .module-pill {
	background: rgba(145, 99, 184, 0.1);
	color: #9163b8;
}

body[data-section="css"] .module-pill .level-indicator {
	color: #724a95;
}

body[data-section="html"] .module-pill {
	background: rgba(212, 90, 160, 0.1);
	color: #d45aa0;
}

body[data-section="html"] .module-pill .level-indicator {
	color: #b24485;
}

body[data-section="tailwind"] .module-pill {
	background: rgba(26, 175, 184, 0.1);
	color: #1aafb8;
}

body[data-section="tailwind"] .module-pill .level-indicator {
	color: #0d8f96;
}

body[data-section="markdown"] .module-pill {
	background: rgba(91, 141, 217, 0.1);
	color: #5b8dd9;
}

body[data-section="markdown"] .module-pill .level-indicator {
	color: #4070b8;
}

body[data-section="javascript"] .module-pill {
	background: rgba(212, 160, 23, 0.1);
	color: #d4a017;
}

body[data-section="javascript"] .module-pill .level-indicator {
	color: #b08610;
}

/* Code block border section colors */
body[data-section="css"] .code-block {
	border-color: rgba(145, 99, 184, 0.4);
}

body[data-section="html"] .code-block {
	border-color: rgba(212, 90, 160, 0.4);
}

body[data-section="tailwind"] .code-block {
	border-color: rgba(26, 175, 184, 0.4);
}

body[data-section="markdown"] .code-block {
	border-color: rgba(91, 141, 217, 0.4);
}

body[data-section="javascript"] .code-block {
	border-color: rgba(212, 160, 23, 0.4);
}

/* Section code block CodeMirror syntax highlighting overrides */
body[data-section="css"] .code-block .cm-editor .cm-line {
	color: #c9c0e0;
}

body[data-section="html"] .code-block .cm-editor .cm-line {
	color: #e8c0cc;
}

body[data-section="tailwind"] .code-block .cm-editor .cm-line {
	color: #c0e0e8;
}

body[data-section="markdown"] .code-block .cm-editor .cm-line {
	color: #c0d0e8;
}

body[data-section="javascript"] .code-block .cm-editor .cm-line {
	color: #e0d8b0;
}

/* Task instruction bubble section colors */
[data-section="css"] .task-instruction {
	background: rgba(145, 99, 184, 0.92);
}

[data-section="html"] .task-instruction {
	background: rgba(212, 90, 160, 0.92);
}

[data-section="tailwind"] .task-instruction {
	background: rgba(26, 175, 184, 0.92);
}

[data-section="markdown"] .task-instruction {
	background: rgba(91, 141, 217, 0.92);
}

[data-section="javascript"] .task-instruction {
	background: rgba(212, 160, 23, 0.92);
}

/* Section page progress bar colors */
body[data-section="css"] .section-progress-bar .progress-fill {
	background: #9163b8;
}

body[data-section="html"] .section-progress-bar .progress-fill {
	background: #d45aa0;
}

body[data-section="tailwind"] .section-progress-bar .progress-fill {
	background: #1aafb8;
}

body[data-section="markdown"] .section-progress-bar .progress-fill {
	background: #5b8dd9;
}

body[data-section="javascript"] .section-progress-bar .progress-fill {
	background: #d4a017;
}

/* Section page header colors */
[data-section="css"] .section-hero h1 {
	color: #9163b8;
}

[data-section="html"] .section-hero h1 {
	color: #d45aa0;
}

[data-section="tailwind"] .section-hero h1 {
	color: #1aafb8;
}

[data-section="markdown"] .section-hero h1 {
	color: #5b8dd9;
}

[data-section="javascript"] .section-hero h1 {
	color: #d4a017;
}

/* Lesson title h2 section colors */
body[data-section="css"] #lesson-title {
	color: #9163b8;
}

body[data-section="html"] #lesson-title {
	color: #d45aa0;
}

body[data-section="tailwind"] #lesson-title {
	color: #1aafb8;
}

body[data-section="markdown"] #lesson-title {
	color: #5b8dd9;
}

body[data-section="javascript"] #lesson-title {
	color: #d4a017;
}

/* Section and Reference footer - override landing-footer styles */
.section-footer.landing-footer,
.reference-footer.landing-footer {
	max-width: 900px;
	margin: 6rem auto 0;
	padding: 0 var(--spacing-lg) var(--spacing-lg);
	border-top: none;
}

.section-footer .footer-links a,
.reference-footer .footer-links a {
	color: var(--light-text);
}

.section-footer .footer-links a:hover,
.reference-footer .footer-links a:hover {
	color: var(--section-color, var(--primary-color));
}
