:root {
  --primary: #2563eb;
  --primary-light: #eff6ff;
  --primary-hover: #1d4ed8;
  --primary-dark: #1e40af;
  --secondary: #0f172a;

  --accent: #10b981;
  --accent-light: #f0fdf4;
  --accent-dark: #047857;

  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --warning-dark: #b45309;

  --danger: #ef4444;
  --danger-light: #fef2f2;
  --danger-dark: #b91c1c;

  --info: #0ea5e9;
  --info-light: #f0f9ff;
  --info-dark: #0369a1;

  /* Thème clair avec fond blanc pur */
  --bg-main: #ffffff;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-subtle: #f8fafc;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-inverse: #ffffff;
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-focus: #3b82f6;

  /* Blocs de code (Thème clair haute lisibilité pour GeSHi) */
  --code-bg: #f8fafc;
  --code-header-bg: #f1f5f9;
  --code-border: #e2e8f0;
  --code-text: #0f172a;
  --code-kw: #0000ff;
  --code-type: #0284c7;
  --code-var: #0f172a;
  --code-str: #b91c1c;
  --code-com: #64748b;
  --code-num: #0284c7;
  --code-func: #0369a1;

  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --sidebar-width: 290px;
}

/* Thème sombre optionnel */
[data-theme="dark"] {
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #1e293b;
  --bg-subtle: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;
  --border-subtle: #1e293b;

  --primary-light: #1e3a8a;
  --accent-light: #064e3b;
  --warning-light: #78350f;
  --danger-light: #7f1d1d;
  --info-light: #0c4a6e;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.75;
  display: flex;
  min-height: 100vh;
  transition: background-color 0.25s ease, color 0.25s ease;
  -webkit-font-smoothing: antialiased;
}

/* Sidebar navigation */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.02);
}

.sidebar-header {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background-color: var(--bg-sidebar);
}

.course-badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 9999px;
  margin-bottom: 0.6rem;
}

.sidebar-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.35;
}

.sidebar-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar-nav {
  padding: 1rem 0;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background-color: var(--primary-light);
  color: var(--primary);
}

.nav-item.active {
  background-color: var(--primary-light);
  color: var(--primary-dark);
  border-left-color: var(--primary);
  font-weight: 600;
}

.nav-time {
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.nav-item.active .nav-time {
  background: #ffffff;
  border-color: rgba(37, 99, 235, 0.2);
  color: var(--primary-dark);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-sidebar);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.theme-toggle-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.2s;
}

.theme-toggle-btn:hover {
  background: var(--border);
}

/* Main content wrapper */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 3rem 4rem;
  max-width: 1120px;
  background-color: var(--bg-main);
}

/* Header Banner */
.course-hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #ffffff;
  padding: 2.5rem 2.25rem;
  border-radius: var(--radius-lg);
  margin-bottom: 3.5rem;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.2rem;
}

.hero-tag {
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(4px);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.course-hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.9rem;
  line-height: 1.25;
}

.course-hero p {
  font-size: 1.08rem;
  opacity: 0.95;
  max-width: 820px;
  line-height: 1.65;
}

.objectives-box {
  margin-top: 1.75rem;
  background: rgba(0, 0, 0, 0.22);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.6rem;
  border-left: 4px solid #60a5fa;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-sizing: border-box;
  max-width: 100%;
}

.objectives-box h4 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.85rem;
  color: #bfdbfe;
  font-weight: 700;
}

.objectives-box ul {
  list-style-type: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0;
  margin: 0;
}

.objectives-box li {
  position: relative;
  padding-left: 1.85rem;
  font-size: 0.95rem;
  line-height: 1.65;
  color: #ffffff;
  display: block;
  text-align: left;
  word-break: normal;
  overflow-wrap: break-word;
}

.objectives-box li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: #4ade80;
  font-weight: 800;
  font-size: 1.15rem;
  line-height: 1.65;
}

.objectives-box li strong {
  font-weight: 700;
  color: #ffffff;
}

.attention-box {
  margin-top: 1.75rem;
  background: #7c1a1a;
  border-radius: var(--radius-md);
  padding: 1.25rem 1.6rem;
  border-left: 4px solid #9c3A3A;
  border-top: 1px solid lightgray;
  border-right: 1px solid lightgray;
  border-bottom: 1px solid lightgray;
  box-sizing: border-box;
  max-width: 100%;
}

.attention-box h4 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.85rem;
  color: #d7b014;
  font-weight: 700;
}

.course-hero .objectives-box code,
.objectives-box li code,
.objectives-box code {
  background: rgba(255, 255, 255, 0.22) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.35) !important;
  padding: 0.1rem 0.45rem !important;
  border-radius: 4px !important;
  font-size: 0.88em !important;
  font-weight: 600 !important;
  display: inline-block;
}

/* Sections */
.course-section {
  margin-bottom: 4.5rem;
  scroll-margin-top: 2.5rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.85rem;
  margin-bottom: 2rem;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.section-num {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary-dark);
  background: var(--primary-light);
  border: 1px solid rgba(37, 99, 235, 0.2);
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.course-section h2 {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.section-duration {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-dark);
  background: var(--primary-light);
  border: 1px solid rgba(37, 99, 235, 0.2);
  padding: 0.25rem 0.85rem;
  border-radius: 9999px;
}

.course-section h3 {
  font-size: 1.22rem;
  font-weight: 700;
  margin: 2rem 0 0.85rem 0;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.course-section p {
  margin-bottom: 1.25rem;
  color: var(--text-main);
  font-size: 1rem;
}

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

.course-section li {
  margin-bottom: 0.4rem;
}

/* Callout boxes */
.callout {
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-md);
  margin: 1.75rem 0;
  border-left: 4px solid;
  box-shadow: var(--shadow-sm);
}

.callout-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.callout-analogy {
  background-color: var(--info-light);
  border-color: var(--info);
  color: var(--text-main);
  border-top: 1px solid rgba(14, 165, 233, 0.15);
  border-right: 1px solid rgba(14, 165, 233, 0.15);
  border-bottom: 1px solid rgba(14, 165, 233, 0.15);
}

.callout-analogy .callout-title {
  color: var(--info-dark);
}

.callout-tip {
  background-color: var(--accent-light);
  border-color: var(--accent);
  color: var(--text-main);
  border-top: 1px solid rgba(16, 185, 129, 0.15);
  border-right: 1px solid rgba(16, 185, 129, 0.15);
  border-bottom: 1px solid rgba(16, 185, 129, 0.15);
}

.callout-tip .callout-title {
  color: var(--accent-dark);
}

.callout-warning {
  background-color: var(--warning-light);
  border-color: var(--warning);
  color: var(--text-main);
  border-top: 1px solid rgba(245, 158, 11, 0.15);
  border-right: 1px solid rgba(245, 158, 11, 0.15);
  border-bottom: 1px solid rgba(245, 158, 11, 0.15);
}

.callout-warning .callout-title {
  color: var(--warning-dark);
}

.callout-danger {
  background-color: var(--danger-light);
  border-color: var(--danger);
  color: var(--text-main);
  border-top: 1px solid rgba(239, 68, 68, 0.15);
  border-right: 1px solid rgba(239, 68, 68, 0.15);
  border-bottom: 1px solid rgba(239, 68, 68, 0.15);
}

.callout-danger .callout-title {
  color: var(--danger-dark);
}

/* Comparison Tables */
.table-wrapper {
  overflow-x: auto;
  margin: 1.75rem 0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  background: var(--bg-card);
  font-size: 0.94rem;
}

.comparison-table th,
.comparison-table td {
  padding: 0.95rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.comparison-table th {
  background-color: #f8fafc;
  color: var(--secondary);
  font-weight: 700;
  border-bottom: 2px solid var(--border);
}

[data-theme="dark"] .comparison-table th {
  background-color: rgba(37, 99, 235, 0.2);
  color: #93c5fd;
}

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

.comparison-table tr:hover {
  background-color: #f8fafc;
}

/* ==========================================================================
   Code Blocks & Highlighting (Fond clair adapté à la coloration GeSHi)
   ========================================================================== */

/* Structure de conteneur avec en-tête de fichier */
.code-container {
  background: var(--code-bg);
  border-radius: var(--radius-md);
  margin: 1.75rem 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--code-border);
}

.code-header {
  background: var(--code-header-bg);
  padding: 0.65rem 1.15rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--code-border);
}

.code-lang {
  color: var(--primary-dark);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.code-filename {
  color: #334155;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

/* Éléments <pre> (Tous les blocs de code reçoivent un fond clair lisible) */
pre {
  background: var(--code-bg) !important;
  color: var(--code-text) !important;
  border-radius: var(--radius-md);
  padding: 1.15rem 1.35rem;
  margin: 1rem 0;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.65;
  border: 1px solid var(--code-border);
  box-shadow: var(--shadow-sm);
}

/* Quand pre est dans un code-container, retirer la double bordure */
.code-container pre {
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: var(--code-bg) !important;
  color: var(--code-text) !important;
}

code {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

/* Code en ligne (inline) dans les paragraphes, listes, cellules, cartes */
p code,
li code,
td code,
.diagram-box code,
.quiz-question code,
.card>p code {
  background: #eff6ff;
  color: #1d4ed8;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.88em;
  font-weight: 600;
  border: 1px solid #dbeafe;
}

[data-theme="dark"] p code,
[data-theme="dark"] li code,
[data-theme="dark"] td code,
[data-theme="dark"] .diagram-box code,
[data-theme="dark"] .quiz-question code {
  background: rgba(37, 99, 235, 0.25);
  color: #93c5fd;
  border-color: rgba(37, 99, 235, 0.3);
}

/* Coloration syntaxique C++ */
.kw {
  color: var(--code-kw);
  font-weight: 600;
}

/* class, public, int, return, etc. */
.type {
  color: var(--code-type);
  font-weight: 600;
}

/* std::string, Compte, double, size_t */
.var {
  color: var(--code-var);
  font-weight: 500;
}

/* variables d'instance / paramètres */
.str {
  color: var(--code-str);
}

/* chaînes de caractères */
.com {
  color: var(--code-com);
  font-style: italic;
}

/* commentaires */
.num {
  color: var(--code-num);
  font-weight: 600;
}

/* nombres */
.func {
  color: var(--code-func);
  font-weight: 600;
}

/* noms de fonctions et méthodes */
.pre {
  color: #f472b6;
}

/* #include, #define */

/* Visual Diagrams (CSS / SVG) */
.diagram-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.6rem;
  margin: 2rem 0;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.diagram-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1.35rem;
}

.diagram-grid {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  align-items: stretch;
  flex-wrap: wrap;
}

.diagram-box {
  background: #ffffff;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.15rem 1.35rem;
  min-width: 230px;
  flex: 1;
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.diagram-box.active {
  border-color: var(--primary);
  background: #f8fafc;
}

.diagram-box-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary-dark);
  margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
}

.diagram-box ul {
  list-style: none;
  font-size: 0.86rem;
  color: var(--text-muted);
  padding-left: 0;
}

.diagram-box li {
  margin: 0.35rem 0;
}

.diagram-arrow {
  display: flex;
  align-items: center;
  font-size: 1.4rem;
  color: var(--primary);
  font-weight: 700;
}

/* Two Columns Layout */
.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.75rem;
  margin: 1.75rem 0;
}

@media (max-width: 900px) {
  .two-cols {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.6rem;
  box-shadow: var(--shadow-sm);
}

.card h4 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
  color: var(--primary-dark);
}

/* Interactive Quiz / Exercises */
.quiz-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.6rem;
  margin: 1.75rem 0;
  box-shadow: var(--shadow-sm);
}

.quiz-question {
  font-weight: 700;
  font-size: 1.02rem;
  margin-bottom: 1.15rem;
  color: var(--text-main);
  line-height: 1.5;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.15rem;
}

.quiz-option {
  padding: 0.85rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.92rem;
  line-height: 1.5;
}

.quiz-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.solution-toggle {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.solution-toggle:hover {
  background: var(--primary-hover);
}

.solution-content {
  display: none;
  margin-top: 1.15rem;
  padding: 1.15rem;
  background: var(--accent-light);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-top: 1px solid rgba(16, 185, 129, 0.2);
  border-right: 1px solid rgba(16, 185, 129, 0.2);
  border-bottom: 1px solid rgba(16, 185, 129, 0.2);
  font-size: 0.92rem;
  line-height: 1.6;
}

.solution-content.show {
  display: block;
}

/* Rule of 3 banner */
.rule-three-banner {
  background: linear-gradient(135deg, #4338ca 0%, #3b82f6 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 1.75rem;
  margin: 2.25rem 0;
  box-shadow: var(--shadow-md);
}

.rule-three-banner h4 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 0.6rem;
}

.rule-three-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.15rem;
  margin-top: 1.25rem;
}

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

.rule-item {
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(6px);
  padding: 1.15rem;
  border-radius: var(--radius-sm);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.rule-item-num {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.3rem;
}

.rule-item-title {
  font-weight: 700;
  font-size: 0.95rem;
}

/* Mobile responsive menu */
.menu-toggle {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--primary);
  color: white;
  border: none;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 50%;
  box-shadow: var(--shadow-lg);
  font-size: 1.5rem;
  z-index: 200;
  cursor: pointer;
}

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-wrapper {
    margin-left: 0;
    padding: 2rem 1.5rem;
  }

  .menu-toggle {
    display: block;
  }
}

/* Chapter Portal Cards (index.html) */
.chapter-card-grid {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  margin: 2rem 0;
}

.chapter-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.8rem 2rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.chapter-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: var(--primary);
  transition: width 0.2s ease;
}

.chapter-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(37, 99, 235, 0.4);
}

.chapter-card:hover::before {
  width: 8px;
}

.chapter-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.chapter-card-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chapter-card-title:hover {
  color: var(--primary);
}

.chapter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.tag-pill {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border-radius: 9999px;
  border: 1px solid var(--border);
}

.chapter-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 1rem;
}

.btn-open-chapter {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  background: var(--primary);
  color: #ffffff !important;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.btn-open-chapter:hover {
  background: var(--primary-hover);
  transform: translateX(3px);
}

/* TD & Exercise styling */
.exercise-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.8rem;
  margin: 2rem 0;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.exercise-card:hover {
  box-shadow: var(--shadow-md);
}

.exercise-header,
.exercice-header {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid var(--border-subtle);
}

.exercise-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.exercise-heading-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.exercise-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1.15rem;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #ffffff !important;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.03em;
  box-shadow: 0 2px 5px rgba(37, 99, 235, 0.25);
  white-space: nowrap;
  text-transform: uppercase;
}

.exercise-title {
  font-size: 1.45rem !important;
  font-weight: 800 !important;
  color: var(--text-main);
  margin: 0 !important;
  line-height: 1.35;
  display: inline-block;
}

.exercise-title code {
  font-size: 1.25rem;
}

.exercise-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* Difficulty Badges */
.diff-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.diff-1 {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.diff-2 {
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.diff-3 {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.diff-4 {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.diff-5 {
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

[data-theme="dark"] .diff-1 {
  background: #064e3b;
  color: #6ee7b7;
  border-color: #047857;
}

[data-theme="dark"] .diff-2 {
  background: #0c4a6e;
  color: #7dd3fc;
  border-color: #0369a1;
}

[data-theme="dark"] .diff-3 {
  background: #78350f;
  color: #fde68a;
  border-color: #b45309;
}

[data-theme="dark"] .diff-4 {
  background: #7c2d12;
  color: #fdba74;
  border-color: #c2410c;
}

[data-theme="dark"] .diff-5 {
  background: #4c1d95;
  color: #c4b5fd;
  border-color: #6d28d9;
}

.exercise-steps {
  margin: 1.2rem 0 1.2rem 1.4rem;
  font-size: 0.95rem;
  line-height: 1.7;
}

.exercise-steps li {
  margin-bottom: 0.6rem;
}

.solution-box {
  margin-top: 1.5rem;
}

.solution-content.td-solution {
  background: #fdfdfd;
  border-left: 4px solid var(--primary);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

[data-theme="dark"] .solution-content.td-solution {
  background: #1e293b;
  border-left: 4px solid var(--primary);
  border-top: 1px solid #334155;
  border-right: 1px solid #334155;
  border-bottom: 1px solid #334155;
}

.terminal-output {
  background: #0f172a;
  color: #38bdf8;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid #334155;
  white-space: pre-wrap;
  overflow-x: auto;
}

span.code {
  font-weight: 600;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

/* Print styles */
@media print {

  .sidebar,
  .menu-toggle,
  .theme-toggle-btn,
  .solution-toggle,
  .btn-open-chapter {
    display: none !important;
  }

  .main-wrapper {
    margin: 0;
    padding: 0;
    max-width: 100%;
  }

  .solution-content {
    display: block !important;
  }

  .course-hero {
    background: #2563eb !important;
    color: white !important;
  }
}