/* ====== CSS Variables ====== */
:root {
  --font-sans: "Inter", "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
  --bg: #0a0e14;
  --bg-elev: #111820;
  --bg-soft: #182030;
  --bg-hover: #1e2a3d;
  --text: #e4ecf7;
  --text-muted: #8899b0;
  --accent: #4ade80;
  --accent-2: #60a5fa;
  --accent-3: #c084fc;
  --danger: #f87171;
  --success: #4ade80;
  --warning: #fbbf24;
  --border: rgba(136, 153, 176, 0.15);
  --border-accent: rgba(74, 222, 128, 0.3);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: 0.2s ease;
  --sidebar-w: 280px;
}

:root.light {
  --bg: #f0f4f9;
  --bg-elev: #ffffff;
  --bg-soft: #e8eef6;
  --bg-hover: #dde5f0;
  --text: #111827;
  --text-muted: #4b5c73;
  --accent: #16a34a;
  --accent-2: #2563eb;
  --accent-3: #9333ea;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --border: rgba(17, 24, 39, 0.12);
  --border-accent: rgba(22, 163, 74, 0.3);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.12);
}

/* ====== RESET ====== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100vh; font-family: var(--font-sans); color: var(--text); background: var(--bg); line-height: 1.6; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
a { color: var(--accent-2); text-decoration: none; }

/* ====== APP SHELL ====== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ====== SIDEBAR ====== */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 1.2rem;
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  z-index: 100;
  transition: transform var(--transition);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.5rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.brand h1 { font-size: 1.05rem; font-weight: 700; }
.brand p { color: var(--text-muted); font-size: 0.78rem; margin-top: 0.1rem; }

.side-nav { display: flex; flex-direction: column; gap: 0.3rem; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
}

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

.nav-link.active {
  background: var(--bg-soft);
  color: var(--accent);
  border-color: var(--border-accent);
  font-weight: 600;
}

.nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }

/* Ghost button */
.ghost-btn, .lab-toggle {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  font-size: 0.82rem;
  transition: all var(--transition);
  text-align: center;
}
.ghost-btn:hover, .lab-toggle:hover { border-color: var(--accent); background: var(--bg-hover); }
.file-label { display: block; cursor: pointer; }

/* XP panel */
.xp-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #000;
  font-weight: 800;
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}
.xp-text { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.3rem; }

.progress-wrap {
  width: 100%;
  height: 6px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.4s ease;
}

.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }

/* ====== MAIN ====== */
.main-content {
  padding: 1.2rem 1.5rem 2rem;
  overflow-y: auto;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 0.8rem; }
.topbar-right { display: flex; align-items: center; gap: 0.8rem; }
.topbar h2 { font-size: 1.35rem; font-weight: 700; }
.topbar p { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.15rem; }
.sidebar-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.5rem; }

.search-wrap input {
  width: 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--text);
  background: var(--bg-soft);
  font-size: 0.85rem;
  transition: border-color var(--transition);
}
.search-wrap input:focus { border-color: var(--accent); outline: none; }

.badge-preview { display: flex; gap: 0.3rem; font-size: 1.2rem; }

/* ====== VIEWS ====== */
.view { display: none; animation: fadeIn 0.25s ease; }
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ====== PANEL ====== */
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  padding: 1rem;
}
.panel.compact { padding: 0.8rem; }
.panel h2, .panel h3, .panel h4 { margin-top: 0; }

/* ====== HOME ====== */
.hero-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.08) 0%, rgba(96, 165, 250, 0.08) 50%, rgba(192, 132, 252, 0.08) 100%), var(--bg-elev);
}
.hero-card h3 { font-size: 1.4rem; margin-bottom: 0.5rem; }
.hero-content p { color: var(--text-muted); max-width: 600px; }
.hero-actions { display: flex; gap: 0.6rem; margin-top: 1rem; }

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-top: 1.2rem;
}

.metric {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  padding: 0.7rem;
  text-align: center;
}
.metric span { display: block; 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; }
.metric small { color: var(--text-muted); font-size: 0.78rem; }

.home-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
  margin-top: 1rem;
}

.feature-card {
  padding: 1.2rem;
  transition: all var(--transition);
}
.feature-card:hover { border-color: var(--border-accent); transform: translateY(-2px); }
.feature-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.feature-card h4 { font-size: 0.95rem; margin-bottom: 0.3rem; }
.feature-card p { color: var(--text-muted); font-size: 0.82rem; }

/* Path selector */
.path-selector { margin-top: 1.2rem; }
.path-selector h3 { font-size: 1.1rem; margin-bottom: 0.7rem; }
.path-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.6rem; }
.path-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-elev);
}
.path-card:hover { transform: translateY(-2px); }
.path-card.beginner { border-left: 3px solid var(--success); }
.path-card.intermediate { border-left: 3px solid var(--warning); }
.path-card.advanced { border-left: 3px solid var(--danger); }
.path-card.expert { border-left: 3px solid var(--accent-3); }
.path-level { display: block; font-weight: 700; font-size: 0.9rem; margin-bottom: 0.3rem; }
.path-desc { color: var(--text-muted); font-size: 0.8rem; }

/* ====== PRIMARY BUTTON ====== */
.primary-btn {
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #000;
  font-weight: 600;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  transition: all var(--transition);
}
.primary-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.primary-btn.secondary { background: linear-gradient(135deg, var(--accent-2), var(--accent-3)); color: #fff; }
.primary-btn.danger { background: var(--danger); color: #fff; }

/* ====== COURSE LAYOUT ====== */
.course-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1rem;
  align-items: start;
}

.course-nav { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
.course-nav h4 { margin-bottom: 0.6rem; }
.course-nav-list { display: flex; flex-direction: column; gap: 0.25rem; }

.path-filter { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.6rem; }
.path-filter-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
}
.path-filter-btn.active { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }

.course-page-link {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  text-align: left;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.course-page-link:hover { background: var(--bg-soft); color: var(--text); }
.course-page-link.active { background: var(--bg-soft); color: var(--accent); border-color: var(--border-accent); font-weight: 600; }
.course-page-link .link-icon { width: 18px; text-align: center; font-size: 0.85rem; }
.course-page-link.completed::after { content: "✓"; margin-left: auto; color: var(--success); font-size: 0.75rem; }

/* Slide stage */
.slide-stage {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  background: linear-gradient(145deg, rgba(74, 222, 128, 0.04) 0%, transparent 60%), var(--bg-elev);
  margin-bottom: 0.8rem;
}

.slide-kicker {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.slide-stage h5 { font-size: 1.2rem; margin: 0 0 0.3rem; }
.slide-objective { color: var(--text-muted); margin: 0 0 0.6rem; font-size: 0.88rem; }
.slide-stage ul { padding-left: 1.2rem; }
.slide-stage li { margin-bottom: 0.35rem; color: var(--text); font-size: 0.9rem; }

.slide-extended {
  margin-top: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  background: var(--bg-soft);
  font-size: 0.85rem;
  color: var(--text-muted);
}
.slide-extended h6 { color: var(--accent); margin-bottom: 0.3rem; font-size: 0.8rem; text-transform: uppercase; }

.slide-controls {
  margin-top: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.slide-counter { color: var(--text-muted); font-size: 0.82rem; }
.ctrl-group { display: flex; gap: 0.4rem; }
.ctrl-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition);
}
.ctrl-btn:hover { border-color: var(--accent); }

.path-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  margin-bottom: 0.4rem;
}
.path-badge.beginner { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.path-badge.intermediate { background: rgba(251, 191, 36, 0.15); color: var(--warning); }
.path-badge.advanced { background: rgba(248, 113, 113, 0.15); color: var(--danger); }
.path-badge.expert { background: rgba(192, 132, 252, 0.15); color: var(--accent-3); }

/* ====== LAB ====== */
.lab-meta { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.3rem 0 0.6rem; }
.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.badge.beginner { color: var(--success); border-color: rgba(74, 222, 128, 0.3); }
.badge.intermediate { color: var(--warning); border-color: rgba(251, 191, 36, 0.3); }
.badge.advanced { color: var(--danger); border-color: rgba(248, 113, 113, 0.3); }
.badge.xp-badge { color: var(--accent-3); border-color: rgba(192, 132, 252, 0.3); }

.lab-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.lab-columns h6 { color: var(--accent); font-size: 0.82rem; text-transform: uppercase; margin-bottom: 0.4rem; }
.lab-columns ol, .lab-columns ul { padding-left: 1.2rem; font-size: 0.88rem; }

.lab-solution {
  display: none;
  border: 1px solid rgba(74, 222, 128, 0.2);
  background: rgba(74, 222, 128, 0.05);
  border-radius: var(--radius);
  padding: 0.65rem;
  margin-top: 0.5rem;
}
.lab-solution.visible { display: block; }

.lab-subsection {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px dashed var(--border);
}
.lab-subsection h6 { color: var(--text); font-weight: 600; margin-bottom: 0.5rem; }

/* ====== TERMINAL ====== */
.terminal-shell {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #0d1117;
}

.terminal-header {
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid #1b2838;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #0d1117;
}
.terminal-title { margin-left: 0.5rem; font-size: 0.78rem; color: #6e8198; }

.dot { width: 10px; height: 10px; border-radius: 999px; }
.dot.red { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green { background: #28c840; }

.terminal-output {
  min-height: 180px;
  max-height: 320px;
  overflow-y: auto;
  padding: 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #c9d1d9;
  white-space: pre-wrap;
  line-height: 1.5;
}

.terminal-feedback {
  border-top: 1px solid #1b2838;
  padding: 0.5rem 0.8rem;
  font-size: 0.8rem;
  color: #6e8198;
}
.terminal-feedback.cmd-ok { color: var(--success); }
.terminal-feedback.cmd-err { color: var(--danger); }

.terminal-form {
  display: flex;
  align-items: center;
  border-top: 1px solid #1b2838;
}
.terminal-form .prompt { padding: 0 0 0 0.7rem; color: var(--accent); font-family: var(--font-mono); font-size: 0.85rem; }
.terminal-form input {
  flex: 1;
  border: 0;
  background: transparent;
  color: #e6edf3;
  padding: 0.6rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  outline: none;
}
.terminal-form button {
  border: 0;
  border-left: 1px solid #1b2838;
  color: var(--accent);
  background: rgba(74, 222, 128, 0.08);
  padding: 0.6rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.terminal-form button:hover { background: rgba(74, 222, 128, 0.15); }

/* ====== WORKSPACE / FILE EDITOR ====== */
.workspace-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0.8rem;
  margin-top: 0.6rem;
}

.file-list { display: flex; flex-direction: column; gap: 0.25rem; max-height: 260px; overflow-y: auto; }
.file-item {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.file-item::before { content: "📄"; font-size: 0.7rem; }
.file-item:hover { background: var(--bg-soft); color: var(--text); }
.file-item.active { background: var(--bg-soft); color: var(--accent); border-color: var(--border-accent); }

.editor-controls { display: flex; gap: 0.35rem; margin-top: 0.4rem; }
.file-input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  flex: 1;
}

.editor-pane { min-height: 200px; }
.editor-pane .CodeMirror {
  height: 250px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
}
.editor-pane textarea {
  width: 100%;
  min-height: 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 0.6rem;
  resize: vertical;
}

.workspace-help { color: var(--text-muted); font-size: 0.78rem; margin-top: 0.4rem; }

/* ====== QUIZ ====== */
.quiz-question {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  margin-bottom: 0.6rem;
  background: var(--bg-elev);
}
.quiz-question h5 { font-size: 0.95rem; margin-bottom: 0.5rem; }

.option-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.option-row:hover { background: var(--bg-soft); }
.option-row input[type="radio"] { accent-color: var(--accent); }

.quiz-actions { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.7rem; }
.quiz-result { color: var(--text-muted); font-size: 0.88rem; }

.explanation {
  margin-top: 0.35rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(74, 222, 128, 0.06);
  border-left: 3px solid var(--accent);
  font-size: 0.82rem;
  color: var(--text-muted);
  display: none;
}
.explanation.visible { display: block; }

/* ====== SANDBOX ====== */
.sandbox-layout { display: flex; flex-direction: column; gap: 0.8rem; }
.sandbox-controls { display: flex; justify-content: space-between; align-items: center; }
.sandbox-tabs { display: flex; gap: 0.3rem; }
.sandbox-tab {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.sandbox-tab.active { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 700; }
.sandbox-actions { display: flex; gap: 0.4rem; }

.sandbox-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  min-height: 500px;
}

.sandbox-editor-section { display: flex; flex-direction: column; }
.sandbox-file-tabs {
  display: flex;
  gap: 0.2rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}
.sandbox-file-tab {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.sandbox-file-tab.active { background: var(--bg-elev); color: var(--accent); border-bottom-color: var(--bg-elev); }
.sandbox-file-tab .close-tab { font-size: 0.65rem; opacity: 0.5; cursor: pointer; }
.sandbox-file-tab .close-tab:hover { opacity: 1; color: var(--danger); }

.sandbox-editor-mount {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 400px;
}
.sandbox-editor-mount .CodeMirror { height: 100%; }

.sandbox-file-actions { display: flex; gap: 0.35rem; margin-top: 0.4rem; }

.sandbox-output-section { display: flex; flex-direction: column; }
.sandbox-output-tabs { display: flex; gap: 0.2rem; margin-bottom: 0.4rem; }
.output-tab {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition);
}
.output-tab.active { background: var(--bg-elev); color: var(--text); border-bottom-color: var(--bg-elev); }

.sandbox-output { display: none; flex: 1; }
.sandbox-output.active { display: flex; flex-direction: column; }

.sandbox-output .terminal-shell { flex: 1; display: flex; flex-direction: column; }
.sandbox-output .terminal-output { flex: 1; min-height: 200px; max-height: none; }

.lint-output, .plan-output {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  background: var(--bg-elev);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  overflow-y: auto;
  min-height: 400px;
}

/* ====== CHALLENGES ====== */
.challenges-container { display: flex; flex-direction: column; gap: 1rem; }
.challenge-tabs { display: flex; gap: 0.3rem; margin-bottom: 1rem; }
.challenge-tab {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}
.challenge-tab.active { background: var(--accent); color: #000; border-color: var(--accent); }

.challenge-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  background: var(--bg-elev);
  transition: all var(--transition);
}
.challenge-card:hover { border-color: var(--border-accent); }
.challenge-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.5rem; }
.challenge-header h4 { font-size: 1rem; }
.difficulty-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.difficulty-badge.easy { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.difficulty-badge.medium { background: rgba(251, 191, 36, 0.15); color: var(--warning); }
.difficulty-badge.hard { background: rgba(248, 113, 113, 0.15); color: var(--danger); }
.challenge-desc { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 0.6rem; }
.challenge-xp { font-size: 0.78rem; color: var(--accent-3); font-weight: 600; }
.challenge-status { font-size: 0.78rem; margin-left: 0.6rem; }
.challenge-status.completed { color: var(--success); }

.challenge-workspace { margin-top: 1rem; }

.challenge-validation {
  margin-top: 0.8rem;
  padding: 0.7rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
}
.challenge-validation.pass { background: rgba(74, 222, 128, 0.1); border: 1px solid rgba(74, 222, 128, 0.3); color: var(--success); }
.challenge-validation.fail { background: rgba(248, 113, 113, 0.1); border: 1px solid rgba(248, 113, 113, 0.3); color: var(--danger); }

.hint-list { margin-top: 0.6rem; }
.hint-item {
  padding: 0.5rem;
  background: rgba(96, 165, 250, 0.06);
  border-left: 3px solid var(--accent-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: none;
}
.hint-item.visible { display: block; }

/* ====== PROGRESSION / BADGES ====== */
.progression-container { display: flex; flex-direction: column; gap: 1.2rem; }

.level-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.06) 0%, rgba(192, 132, 252, 0.06) 100%), var(--bg-elev);
  text-align: center;
}
.level-card .level-number { font-size: 3rem; font-weight: 900; background: linear-gradient(135deg, var(--accent), var(--accent-2), var(--accent-3)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.level-card .level-title { font-size: 1.2rem; font-weight: 700; margin: 0.3rem 0; }
.level-card .xp-info { color: var(--text-muted); font-size: 0.9rem; }
.level-progress { width: 60%; margin: 0.8rem auto 0; }

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.6rem;
}

.badge-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  text-align: center;
  background: var(--bg-elev);
  transition: all var(--transition);
  opacity: 0.4;
}
.badge-card.earned { opacity: 1; border-color: var(--border-accent); }
.badge-card .badge-icon { font-size: 2rem; margin-bottom: 0.3rem; }
.badge-card .badge-name { font-weight: 700; font-size: 0.85rem; }
.badge-card .badge-desc { color: var(--text-muted); font-size: 0.75rem; margin-top: 0.2rem; }

.history-list { max-height: 300px; overflow-y: auto; }
.history-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.history-icon { font-size: 1.1rem; }
.history-text { flex: 1; color: var(--text-muted); }
.history-xp { color: var(--accent); font-weight: 700; font-size: 0.82rem; }
.history-time { color: var(--text-muted); font-size: 0.72rem; }

/* ====== TOAST ====== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  background: var(--bg-elev);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 3.7s;
  max-width: 350px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.badge-toast { border-left: 3px solid var(--accent-3); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* ====== MISCELLANEOUS ====== */
.module-note { color: var(--text-muted); font-size: 0.82rem; }

/* ====== TERMINAL COLORIZATION ====== */
.term-ok   { color: #4ade80; }
.term-err  { color: #f87171; }
.term-warn { color: #fbbf24; }
.term-cyan { color: #67e8f9; }
.term-info { color: #60a5fa; }
.term-dim  { color: #4a5568; }
.term-prompt { color: #4ade80; font-weight: 600; }

/* ====== BADGE TOAST ====== */
.toast.badge-toast {
  border-left: 3px solid var(--accent-3);
  background: linear-gradient(135deg, rgba(192, 132, 252, 0.12), var(--bg-elev));
  min-width: 260px;
  gap: 0.8rem;
  padding: 0.9rem 1.1rem;
}
.badge-toast-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

/* ====== SLIDES VISUELLES ====== */
.slide-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.slide-counter-inline {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.75rem;
}
.slide-bullets {
  padding-left: 0;
  list-style: none;
  margin: 0.5rem 0;
}
.slide-bullets li {
  padding: 0.35rem 0 0.35rem 1.2rem;
  position: relative;
  font-size: 0.9rem;
  color: var(--text);
  border-bottom: 1px solid rgba(136, 153, 176, 0.08);
}
.slide-bullets li::before {
  content: "›";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

/* Workflow steps (init → plan → apply) */
.slide-workflow {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.9rem 0;
  flex-wrap: wrap;
}
.workflow-step {
  background: var(--bg-soft);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
}
.workflow-arrow {
  color: var(--text-muted);
  font-size: 1rem;
}

/* Code example in slides */
.slide-code {
  margin: 0.9rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.slide-code-caption {
  background: var(--bg-soft);
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
}
.slide-code-mount .CodeMirror {
  height: 200px;
  font-size: 0.8rem;
}

/* ASCII diagram */
.slide-diagram {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #67e8f9;
  overflow-x: auto;
  line-height: 1.4;
  margin: 0.9rem 0;
}

/* Pro tip */
.slide-tip {
  background: rgba(251, 191, 36, 0.07);
  border-left: 3px solid var(--warning);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.6rem 0.9rem;
  font-size: 0.84rem;
  color: var(--text);
  margin: 0.9rem 0;
}
.slide-tip strong { color: var(--warning); }

/* Deep dive collapsible */
.slide-deepdive {
  margin-top: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.slide-deepdive summary {
  padding: 0.5rem 0.9rem;
  background: var(--bg-soft);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-2);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.slide-deepdive summary::before { content: "▶"; font-size: 0.65rem; transition: transform 0.2s; }
.slide-deepdive[open] summary::before { transform: rotate(90deg); }
.slide-deepdive p {
  padding: 0.7rem 0.9rem;
  font-size: 0.84rem;
  color: var(--text-muted);
  margin: 0;
}

/* ====== HOME PROGRESSION CARDS ====== */
.home-progression {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.7rem;
  margin: 1rem 0;
}
.home-prog-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  background: var(--bg-elev);
  cursor: pointer;
  transition: all var(--transition);
}
.home-prog-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
}
.home-prog-icon { font-size: 1.8rem; flex-shrink: 0; }
.home-prog-info { flex: 1; min-width: 0; }
.home-prog-info strong { display: block; font-size: 0.95rem; font-weight: 700; }
.home-prog-info span { font-size: 0.8rem; color: var(--text-muted); display: block; margin: 0.2rem 0 0.4rem; }
.home-prog-bar {
  height: 5px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}
.home-prog-bar div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ====== RESPONSIVE ====== */
@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); width: var(--sidebar-w); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .course-layout { grid-template-columns: 1fr; }
  .course-nav { position: static; max-height: none; }
  .sandbox-split { grid-template-columns: 1fr; }
  .home-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-metrics { grid-template-columns: repeat(2, 1fr); }
  .path-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .home-grid { grid-template-columns: 1fr; }
  .path-cards { grid-template-columns: 1fr; }
  .hero-metrics { grid-template-columns: repeat(2, 1fr); }
  .lab-columns { grid-template-columns: 1fr; }
  .workspace-layout { grid-template-columns: 1fr; }
}

/* ====== MISSIONS ENTREPRISE ====== */
.mission-header {
  background: linear-gradient(135deg, rgba(99,102,241,.12) 0%, rgba(168,85,247,.08) 100%);
  border: 1px solid rgba(99,102,241,.3);
  border-radius: 12px;
  padding: 1.4rem 1.6rem;
  margin-bottom: 1.4rem;
}
.mission-badge-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}
.mission-tag {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  color: #fff;
  padding: 0.2rem 0.7rem;
  border-radius: 4px;
}
.mission-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0.4rem 0 0.8rem;
  line-height: 1.3;
}
.mission-brief {
  background: rgba(255,255,255,.04);
  border-left: 3px solid #6366f1;
  border-radius: 0 8px 8px 0;
  padding: 0.8rem 1rem;
  margin-bottom: 0.6rem;
}
.mission-brief strong { color: var(--accent-2); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; }
.mission-brief p { margin: 0.3rem 0 0; color: var(--text-secondary); line-height: 1.6; }
.mission-context { font-size: 0.82rem; color: var(--text-muted); font-style: italic; }

.mission-body { margin-bottom: 1.2rem; }
.mission-steps-block { margin-bottom: 1rem; }
.mission-steps-block h5 { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-2); margin-bottom: 0.6rem; }
.mission-step {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  margin-bottom: 0.3rem;
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.05);
  transition: background .15s;
}
.mission-step:hover { background: rgba(99,102,241,.08); }
.mission-step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.mission-deliverables { margin-bottom: 0.8rem; }
.mission-deliverables h5 { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #fbbf24; margin-bottom: 0.4rem; }
.mission-deliverables ul { list-style: none; padding: 0; margin: 0; }
.mission-deliverables li { padding: 0.25rem 0; padding-left: 1.2rem; position: relative; font-size: 0.87rem; color: var(--text-secondary); }
.mission-deliverables li::before { content: "✓"; position: absolute; left: 0; color: var(--success); font-weight: bold; }

.mission-hints { margin-top: 0.6rem; }
