/* ============================================================
   AGENT QUEST — Design System
   Dark-first, electric cyan/teal neural pathway aesthetic
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: 4rem;
  font-size: 16px;
}

/* --- Theme Variables --- */
:root, [data-theme="dark"] {
  --bg: #0d1117;
  --bg-secondary: #131921;
  --surface: #161b22;
  --surface-2: #1c2333;
  --surface-3: #21283a;
  --border: #2a3142;
  --border-subtle: #1e2535;
  --text: #e2e8f0;
  --text-muted: #8b95a5;
  --text-faint: #4a5568;
  --accent: #22d3ee;
  --accent-hover: #06b6d4;
  --accent-dim: rgba(34, 211, 238, 0.12);
  --accent-glow: rgba(34, 211, 238, 0.25);
  --accent-2: #818cf8;
  --accent-2-dim: rgba(129, 140, 248, 0.12);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.12);
  --yellow: #fbbf24;
  --yellow-dim: rgba(251, 191, 36, 0.12);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.12);
  --orange: #fb923c;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --transition: 180ms var(--ease);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f8fafc;
  --bg-secondary: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --border: #d1d5db;
  --border-subtle: #e5e7eb;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --accent: #0891b2;
  --accent-hover: #0e7490;
  --accent-dim: rgba(8, 145, 178, 0.08);
  --accent-glow: rgba(8, 145, 178, 0.15);
  --accent-2: #6366f1;
  --accent-2-dim: rgba(99, 102, 241, 0.08);
  --green: #059669;
  --green-dim: rgba(5, 150, 105, 0.08);
  --yellow: #d97706;
  --yellow-dim: rgba(217, 119, 6, 0.08);
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.08);
  --orange: #ea580c;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);
  color-scheme: light;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

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

code, pre { font-family: var(--font-mono); }
::selection { background: var(--accent-dim); color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

/* --- App Layout --- */
.app-layout {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}
.mobile-header { display: none; }

/* --- Sidebar --- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  width: 280px;
  min-width: 280px;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.logo-icon { color: var(--text); flex-shrink: 0; }
.logo-text {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-actions { display: flex; gap: 0.25rem; }
.icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: none; background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* --- XP Panel --- */
.xp-panel {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}
.level-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.level-icon { font-size: 1.25rem; }
.level-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.level-name {
  font-weight: 650;
  font-size: 0.8125rem;
  color: var(--accent);
  line-height: 1.2;
}
.level-label {
  font-size: 0.6875rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.xp-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}
.xp-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}
.xp-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.6s var(--ease);
  position: relative;
}
.xp-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shimmer 2s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.xp-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--text-faint);
  margin-top: 0.25rem;
}

/* --- Overall Progress --- */
.overall-progress {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}
.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
  font-weight: 500;
}
.progress-bar-thin {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress-bar-thin-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--green);
  transition: width 0.6s var(--ease);
}

/* --- Track Nav --- */
.track-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}
.track-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  margin-bottom: 2px;
}
.track-item:hover { background: var(--surface-2); }
.track-item.active {
  background: var(--accent-dim);
  border-color: rgba(34, 211, 238, 0.15);
}
.track-item-icon {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  background: var(--surface-3);
  flex-shrink: 0;
}
.track-item.active .track-item-icon { background: var(--accent-dim); }
.track-item-info { flex: 1; min-width: 0; }
.track-item-name {
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--text);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-item.active .track-item-name { color: var(--accent); }
.track-item-progress {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.125rem;
}
.track-minibar {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}
.track-minibar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.4s var(--ease);
}
.track-item-pct {
  font-size: 0.625rem;
  font-family: var(--font-mono);
  color: var(--text-faint);
  min-width: 2.5em;
  text-align: right;
}
.track-item-lessons {
  padding-left: 2.625rem;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.35s var(--ease);
}
.track-item.active + .track-item-lessons,
.track-item-lessons.expanded { max-height: 1200px; }
.lesson-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3125rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.lesson-link:hover { color: var(--text); background: var(--surface-2); }
.lesson-link.active { color: var(--accent); }
.lesson-link.completed { color: var(--green); }
.lesson-check {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.5rem;
  transition: all var(--transition);
}
.lesson-link.completed .lesson-check {
  background: var(--green);
  border-color: var(--green);
  color: white;
}
.lesson-link.active .lesson-check { border-color: var(--accent); }

/* --- Achievements Button --- */
.achievements-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8125rem;
  font-family: inherit;
  font-weight: 500;
  transition: all var(--transition);
}
.achievements-btn:hover { background: var(--surface-3); color: var(--text); }
.achievement-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-faint);
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 2rem 3rem 4rem;
  overflow-y: auto;
}

/* --- Welcome Screen --- */
.welcome {
  text-align: center;
  padding: 3rem 0;
  max-width: 860px;
  margin: 0 auto;
}
.welcome-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
  display: block;
}
.welcome h1 {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.welcome p {
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 2rem;
  font-size: 1rem;
  line-height: 1.65;
}
.welcome-tracks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  text-align: left;
  max-width: 720px;
  margin: 0 auto;
}
.welcome-track-card {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
}
.welcome-track-card:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.welcome-track-card .track-num {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.welcome-track-card h3 {
  font-size: 0.875rem;
  font-weight: 650;
  margin-top: 0.25rem;
  line-height: 1.3;
}

/* --- Lesson Content --- */
.lesson-view { animation: fadeIn 0.3s var(--ease); max-width: 860px; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.lesson-breadcrumb {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.lesson-breadcrumb a {
  color: var(--text-muted);
  cursor: pointer;
}
.lesson-breadcrumb a:hover { color: var(--accent); text-decoration: none; }
.lesson-header {
  margin-bottom: 2rem;
}
.lesson-header h1 {
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}
.lesson-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.lesson-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Content Typography */
.lesson-body h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 2rem 0 0.75rem;
  letter-spacing: -0.01em;
  color: var(--text);
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--border-subtle);
}
.lesson-body h3 {
  font-size: 1.0625rem;
  font-weight: 650;
  margin: 1.5rem 0 0.5rem;
  color: var(--text);
}
.lesson-body p {
  margin-bottom: 1rem;
  max-width: 72ch;
  line-height: 1.7;
}
.lesson-body ul, .lesson-body ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}
.lesson-body li {
  margin-bottom: 0.375rem;
  line-height: 1.6;
  max-width: 72ch;
}
.lesson-body li::marker { color: var(--accent); }
.lesson-body strong { font-weight: 650; color: var(--text); }
.lesson-body em { font-style: italic; color: var(--text-muted); }

/* Inline code */
.lesson-body code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.8125em;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--accent);
  font-weight: 500;
}

/* Code blocks */
.code-block {
  position: relative;
  margin: 1.25rem 0;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.875rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-2);
}
.code-lang {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.copy-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-faint);
  font-size: 0.6875rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}
.copy-btn:hover { color: var(--accent); background: var(--accent-dim); }
.copy-btn.copied { color: var(--green); }
.code-block pre {
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.8125rem;
  line-height: 1.65;
  tab-size: 2;
}
.code-block code {
  font-family: var(--font-mono);
  font-weight: 450;
}

/* Syntax highlighting */
.code-block .kw { color: #c792ea; }
.code-block .fn { color: #82aaff; }
.code-block .str { color: #c3e88d; }
.code-block .num { color: #f78c6c; }
.code-block .cm { color: #546e7a; font-style: italic; }
.code-block .op { color: #89ddff; }
.code-block .var { color: #f07178; }
.code-block .tp { color: #ffcb6b; }
.code-block .dc { color: #82aaff; font-style: italic; }
.code-block .pr { color: #c792ea; }
[data-theme="light"] .code-block .kw { color: #7c3aed; }
[data-theme="light"] .code-block .fn { color: #2563eb; }
[data-theme="light"] .code-block .str { color: #059669; }
[data-theme="light"] .code-block .num { color: #d97706; }
[data-theme="light"] .code-block .cm { color: #9ca3af; }
[data-theme="light"] .code-block .op { color: #0891b2; }
[data-theme="light"] .code-block .var { color: #dc2626; }
[data-theme="light"] .code-block .tp { color: #b45309; }

/* Callout boxes */
.callout {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin: 1.25rem 0;
  border-left: 3px solid;
  font-size: 0.875rem;
}
.callout-info {
  background: var(--accent-dim);
  border-color: var(--accent);
}
.callout-warning {
  background: var(--yellow-dim);
  border-color: var(--yellow);
}
.callout-tip {
  background: var(--green-dim);
  border-color: var(--green);
}
.callout-danger {
  background: var(--red-dim);
  border-color: var(--red);
}
.callout-title {
  font-weight: 650;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.callout-info .callout-title { color: var(--accent); }
.callout-warning .callout-title { color: var(--yellow); }
.callout-tip .callout-title { color: var(--green); }
.callout-danger .callout-title { color: var(--red); }

/* Comparison Table */
.comparison-table {
  overflow-x: auto;
  margin: 1.25rem 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.comparison-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
.comparison-table th {
  padding: 0.625rem 0.875rem;
  text-align: left;
  font-weight: 650;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.comparison-table td {
  padding: 0.5rem 0.875rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
}
.comparison-table tr:last-child td { border-bottom: none; }
.comparison-table tr:hover td { background: var(--surface-2); }

/* --- Lesson Actions --- */
.lesson-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #000;
  font-weight: 650;
  font-size: 0.8125rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 550;
  font-size: 0.8125rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-secondary:hover { background: var(--surface-3); border-color: var(--text-faint); }
.btn-complete {
  background: linear-gradient(135deg, var(--green), #059669);
  box-shadow: 0 2px 12px rgba(52,211,153,0.2);
}
.btn-complete:hover {
  box-shadow: 0 4px 20px rgba(52,211,153,0.3);
}

/* --- Quiz --- */
.quiz-container {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.quiz-header h3 {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.quiz-progress-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.quiz-question {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 1rem;
  line-height: 1.5;
}
.quiz-options { display: flex; flex-direction: column; gap: 0.5rem; }
.quiz-option {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--text);
  text-align: left;
  transition: all var(--transition);
  display: flex;
  gap: 0.625rem;
  align-items: flex-start;
  line-height: 1.5;
  width: 100%;
}
.quiz-option:hover:not(.selected):not(.correct):not(.incorrect) {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.quiz-option-letter {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  width: 22px; height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-3);
  flex-shrink: 0;
  margin-top: 1px;
}
.quiz-option.correct {
  border-color: var(--green);
  background: var(--green-dim);
}
.quiz-option.correct .quiz-option-letter {
  background: var(--green); color: #fff;
}
.quiz-option.incorrect {
  border-color: var(--red);
  background: var(--red-dim);
}
.quiz-option.incorrect .quiz-option-letter {
  background: var(--red); color: #fff;
}
.quiz-option.selected { pointer-events: none; }
.quiz-explanation {
  margin-top: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  line-height: 1.6;
  animation: fadeIn 0.3s var(--ease);
}
.quiz-explanation.correct-explanation {
  background: var(--green-dim);
  border-left: 3px solid var(--green);
}
.quiz-explanation.incorrect-explanation {
  background: var(--red-dim);
  border-left: 3px solid var(--red);
}
.quiz-nav {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
  gap: 0.75rem;
}

/* --- Command Palette --- */
.command-palette {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20vh;
}
.command-palette.hidden { display: none; }
.command-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}
.command-palette-modal {
  position: relative;
  width: 90%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.command-palette-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
}
.command-palette-input-wrap input {
  flex: 1;
  border: none;
  background: none;
  color: var(--text);
  font-size: 0.9375rem;
  outline: none;
  font-family: inherit;
}
.command-palette-input-wrap input::placeholder { color: var(--text-faint); }
.command-palette-input-wrap kbd {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text-faint);
  border: 1px solid var(--border);
}
.command-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 0.5rem;
}
.command-result-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text);
  transition: background var(--transition);
}
.command-result-item:hover, .command-result-item.active {
  background: var(--accent-dim);
}
.command-result-track {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: var(--text-faint);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  background: var(--surface-3);
  flex-shrink: 0;
}

/* --- Level Up Modal --- */
.level-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
}
.level-modal.hidden { display: none; }
.level-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
}
.level-modal-content {
  position: relative;
  text-align: center;
  padding: 2.5rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 0 60px var(--accent-glow);
  animation: scaleIn 0.4s var(--ease);
  max-width: 340px;
  width: 90%;
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}
.level-modal-badge {
  font-size: 4rem;
  margin-bottom: 1rem;
}
.level-modal-content h2 {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.375rem;
}
.level-modal-content p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

/* --- Achievement Toast --- */
.achievement-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: 0 0 30px var(--accent-glow);
  z-index: 120;
  animation: slideUp 0.4s var(--ease);
}
.achievement-toast.hidden { display: none; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.achievement-icon { font-size: 1.5rem; }
.achievement-info { display: flex; flex-direction: column; }
.achievement-label {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
}
.achievement-name { font-size: 0.8125rem; font-weight: 650; }

/* --- Achievements Panel --- */
.achievements-panel {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
}
.achievements-panel.hidden { display: none; }
.achievements-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}
.achievements-content {
  position: relative;
  width: 90%;
  max-width: 640px;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
}
.achievements-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.achievements-header h2 { font-size: 1.125rem; font-weight: 700; }
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.75rem;
}
.achievement-card {
  padding: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-align: center;
  opacity: 0.5;
  transition: all var(--transition);
}
.achievement-card.unlocked {
  opacity: 1;
  border-color: var(--accent);
  background: var(--accent-dim);
}
.achievement-card-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.achievement-card-name {
  font-size: 0.75rem;
  font-weight: 650;
  margin-bottom: 0.25rem;
}
.achievement-card-desc {
  font-size: 0.6875rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* --- Confetti --- */
#confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
}

/* --- Responsive --- */
@media (max-width: 860px) {
  .app-layout {
    flex-direction: column;
    height: 100dvh;
  }
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
    gap: 0.75rem;
  }
  .mobile-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 0.9375rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
  .mobile-logo .logo-icon {
    -webkit-text-fill-color: initial;
    background: none;
  }
  .menu-toggle, .search-toggle {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    border: none; background: none;
    color: var(--text-muted);
    cursor: pointer;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease);
    z-index: 50;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 45;
    display: none;
  }
  .sidebar.open ~ .sidebar-overlay { display: block; }
  .main-content { padding: 1.5rem 1rem 3rem; }
}

@media (max-width: 480px) {
  .welcome-tracks { grid-template-columns: 1fr; }
  .achievements-grid { grid-template-columns: repeat(2, 1fr); }
  .lesson-actions { flex-direction: column; }
  .lesson-actions .btn-primary,
  .lesson-actions .btn-secondary { width: 100%; justify-content: center; }
}

/* --- Utility --- */
.hidden { display: none !important; }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
