:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, "Liberation Mono", Menlo, monospace;

  --color-bg: #f6f3ec;
  --color-bg-alt: #fcfaf6;
  --color-surface: #ffffff;
  --color-surface-2: #f1ede4;
  --color-border: #e5dfd3;
  --color-border-strong: #d3cbbb;
  --color-text: #221f1a;
  --color-text-muted: #6b6559;

  --color-ink: #26231e;
  --color-ink-hover: #3a352d;
  --color-on-ink: #fbf9f4;

  --color-primary: var(--color-ink);
  --color-primary-dark: #17150f;
  --color-primary-soft: #f1ede4;
  --color-accent: #a65b36;
  --color-accent-soft: #f4e8e0;

  --color-success: #4c7350;
  --color-success-bg: #e9efe6;
  --color-danger: #a64b3c;
  --color-danger-bg: #f7e9e5;

  --color-streak: #b4653a;
  --color-xp: #8a7136;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --shadow-sm: 0 1px 2px rgba(56, 45, 30, 0.05);
  --shadow-md: 0 10px 30px -12px rgba(56, 45, 30, 0.22);

  --topbar-h: 58px;
  --bottomnav-h: 64px;
  --max-width: 640px;
  --sidebar-w: 232px;
  --sidebar-w-collapsed: 72px;
  --max-width-desktop: 1280px;
  --reading-width: 720px;

  --editor-bg: #262320;
  --editor-fg: #ece5d9;
  --editor-border: #38332b;
}

:root[data-theme="dark"] {
  --color-bg: #171613;
  --color-bg-alt: #1d1c18;
  --color-surface: #221f1a;
  --color-surface-2: #2c2823;
  --color-border: #38332b;
  --color-border-strong: #4a443a;
  --color-text: #f3efe6;
  --color-text-muted: #a79f91;

  --color-ink: #efe9de;
  --color-ink-hover: #ffffff;
  --color-on-ink: #201d18;

  --color-primary-dark: #efe9de;
  --color-primary-soft: #2c2823;
  --color-accent: #d08a5f;
  --color-accent-soft: #3a2c23;

  --color-success: #86ab86;
  --color-success-bg: #1f2a20;
  --color-danger: #d2796a;
  --color-danger-bg: #2e1e1b;

  --color-streak: #d08a5f;
  --color-xp: #c6aa63;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, 0.6);

  --editor-bg: #12110f;
  --editor-fg: #ece5d9;
  --editor-border: #2c2823;
}

* { box-sizing: border-box; }

/* .topbar/.bottomnav ont un display: flex qui masquerait l'attribut hidden
   utilisé par les routes plein écran (login, leçon). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

button, input {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a { color: inherit; }

h1, h2, h3, p, ul, ol {
  margin: 0 0 var(--space-3) 0;
}

h1, h2, h3 { letter-spacing: -0.015em; }

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.icon {
  display: block;
  flex-shrink: 0;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-4);
  padding-top: calc(var(--topbar-h) + var(--space-5));
  padding-bottom: calc(var(--bottomnav-h) + var(--space-5));
}

.view.full-bleed {
  max-width: none;
  padding: 0;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-border);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-inner {
  width: 100%;
  max-width: var(--max-width);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  gap: var(--space-2);
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.topbar-brand::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
}

.topbar-stats {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  padding: 5px 10px 5px 8px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  color: var(--color-text);
}

.stat-pill .icon { width: 15px; height: 15px; }

.stat-pill.streak .icon { color: var(--color-streak); }
.stat-pill.xp .icon { color: var(--color-xp); }

.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--bottomnav-h);
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: center;
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottomnav-inner {
  width: 100%;
  max-width: var(--max-width);
  display: flex;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 0;
  color: var(--color-text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  transition: color 0.15s ease;
}

.nav-item .icon { width: 22px; height: 22px; }

.nav-item.active {
  color: var(--color-text);
  font-weight: 700;
}

.nav-item.active .icon { color: var(--color-accent); }

/* --- Sidebar desktop : remplace le bottomnav au-delà du breakpoint (voir media query
   plus bas), reprend aussi les pastilles streak/xp de la topbar (masquée à cette largeur). */
.sidebar {
  display: none;
  flex-direction: column;
  width: var(--sidebar-w);
  flex-shrink: 0;
  padding: var(--space-5) var(--space-3);
  background: var(--color-bg-alt);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.16s ease, padding 0.16s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 var(--space-2);
  margin-bottom: var(--space-6);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.sidebar-brand .icon { width: 22px; height: 22px; color: var(--color-accent); flex-shrink: 0; }

.sidebar-brand-texte { flex: 1; white-space: nowrap; }

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-toggle:hover { background: var(--color-surface-2); color: var(--color-text); }
.sidebar-toggle .icon { width: 16px; height: 16px; transform: rotate(180deg); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav .nav-item {
  flex-direction: row;
  justify-content: flex-start;
  gap: var(--space-3);
  padding: 11px var(--space-3);
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav .nav-item .icon { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar-nav .nav-item:hover { background: var(--color-surface-2); }

.sidebar-nav .nav-item.active { background: var(--color-surface); box-shadow: var(--shadow-sm); }
.sidebar-nav .nav-item.active .icon { color: var(--color-accent); }

.sidebar-stats {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.sidebar-stats .stat-pill { justify-content: flex-start; width: 100%; white-space: nowrap; }

/* Repliée : rail à icônes seules, pour rendre à la colonne de contenu la place que
   --sidebar-w (232px) lui prenait. État mémorisé (localStorage), posé par app.js. */
.sidebar.collapsed { width: var(--sidebar-w-collapsed); padding-left: var(--space-2); padding-right: var(--space-2); }
.sidebar.collapsed .sidebar-brand { justify-content: center; margin-bottom: var(--space-5); }
.sidebar.collapsed .sidebar-brand-texte { display: none; }
.sidebar.collapsed .sidebar-toggle .icon { transform: rotate(0deg); }
.sidebar.collapsed .sidebar-nav .nav-item { justify-content: center; padding: 11px 0; }
.sidebar.collapsed .sidebar-nav .nav-item span { display: none; }
.sidebar.collapsed .sidebar-stats { align-items: center; }
.sidebar.collapsed .sidebar-stats .stat-pill { width: auto; justify-content: center; padding: 5px 8px; }

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

.year-switch {
  display: flex;
  gap: 3px;
  padding: 3px;
  margin-bottom: var(--space-5);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
}

.year-switch button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.year-switch button .count {
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--color-bg);
  color: var(--color-text-muted);
}

.year-switch button[aria-pressed="true"] {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

.year-switch button[aria-pressed="true"] .count {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.continue-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: var(--space-5);
  background:
    radial-gradient(120% 140% at 100% 0%, var(--color-accent-soft), transparent 60%),
    var(--color-surface);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-6);
  position: relative;
  overflow: hidden;
}

.continue-card-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent);
}

.continue-card-label::before {
  content: "";
  width: 16px;
  height: 1.5px;
  background: currentColor;
  border-radius: 2px;
}

.continue-card h2 {
  font-size: 1.35rem;
  line-height: 1.25;
  margin: var(--space-3) 0 var(--space-5) 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin: var(--space-6) 0 var(--space-3) 0;
}

.section-compte {
  font-size: 0.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  letter-spacing: 0;
}

.parcours-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.parcours-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.parcours-card:hover {
  border-color: var(--color-border-strong);
  background: var(--color-bg-alt);
}

.parcours-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--color-accent) 12%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--color-accent) 22%, transparent);
  color: var(--color-accent);
  flex-shrink: 0;
}

.parcours-icon svg { width: 22px; height: 22px; }

.parcours-info { flex: 1; min-width: 0; }

.parcours-info h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 3px 0;
}

.parcours-info p {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ring {
  transform: rotate(-90deg);
  flex-shrink: 0;
}

.ring-bg { fill: none; stroke: var(--color-border); stroke-width: 3.5; }

.ring-fg {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 3.5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

.ring-label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  color: var(--color-text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.08s ease;
}

.btn:active { transform: scale(0.985); }

.btn-primary {
  background: var(--color-ink);
  color: var(--color-on-ink);
  width: 100%;
}

.btn-primary:hover:not(:disabled) { background: var(--color-ink-hover); }

.btn-primary:disabled {
  opacity: 0.35;
  transform: none;
  cursor: not-allowed;
}

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

.btn-ghost:hover:not(:disabled) { background: var(--color-surface-2); }

.btn-block { width: 100%; }

.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background:
    radial-gradient(90% 60% at 50% 0%, var(--color-bg-alt), transparent 70%),
    radial-gradient(70% 50% at 80% 100%, var(--color-accent-soft), transparent 65%),
    var(--color-bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.login-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto var(--space-4) auto;
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-logo svg { width: 26px; height: 26px; }

.login-card h1 {
  font-size: 1.3rem;
  margin-bottom: var(--space-1);
}

.login-card p {
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.login-field {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-strong);
  background: var(--color-bg-alt);
  color: var(--color-text);
  font-size: 1rem;
  margin: var(--space-4) 0;
}

.login-field:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.login-error {
  color: var(--color-danger);
  font-size: 0.85rem;
  min-height: 1.2em;
  margin-bottom: var(--space-2);
}

.path-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.path-back {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.path-back:hover { background: var(--color-surface-2); }
.path-back svg { width: 18px; height: 18px; }

.path-header h1 {
  font-size: 1.2rem;
  margin: 0;
}

.path-header p {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--color-text-muted);
  margin: 3px 0 0 0;
}

.chapter-heading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin: var(--space-6) 0 var(--space-3) 0;
}

.chapter-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.path-wrap {
  position: relative;
}

.lesson-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.lesson-tile {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.lesson-tile:hover:not(:disabled) {
  border-color: var(--color-border-strong);
  background: var(--color-bg-alt);
}

.lesson-tile:disabled {
  cursor: default;
  background: transparent;
  border-style: dashed;
}

.lesson-tile-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-on-ink);
  background: var(--color-border-strong);
}

.lesson-tile-icon svg { width: 16px; height: 16px; }

.lesson-tile.locked .lesson-tile-icon {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

.lesson-tile.available .lesson-tile-icon,
.lesson-tile.in_progress .lesson-tile-icon {
  background: var(--color-accent);
  color: #fff;
}

.lesson-tile.completed .lesson-tile-icon {
  background: color-mix(in srgb, var(--color-success) 14%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--color-success) 35%, transparent);
  color: var(--color-success);
}

.lesson-tile.perfect .lesson-tile-icon {
  background: color-mix(in srgb, var(--color-xp) 16%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--color-xp) 40%, transparent);
  color: var(--color-xp);
}

.lesson-tile-texte {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lesson-tile-meta {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.lesson-tile-meta.reprise {
  color: var(--color-accent);
}

.lesson-tile-title {
  min-width: 0;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--color-text);
}

.lesson-tile.locked .lesson-tile-title {
  color: var(--color-text-muted);
  font-weight: 500;
}

.lesson-tile-chevron {
  flex-shrink: 0;
  color: var(--color-border-strong);
  display: flex;
}

.lesson-tile-chevron svg { width: 16px; height: 16px; }

.lesson-screen {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.lesson-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  padding-top: max(var(--space-4), env(safe-area-inset-top));
}

.lesson-close {
  color: var(--color-text-muted);
  width: 44px;
  height: 44px;
  margin-left: -11px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
}

.lesson-close svg { width: 20px; height: 20px; }

.segbar {
  flex: 1;
  display: flex;
  gap: 4px;
}

.seg {
  flex: 1;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  overflow: hidden;
}

.seg::after {
  content: "";
  display: block;
  height: 100%;
  width: 0%;
  background: var(--color-accent);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.seg.done::after { width: 100%; }
.seg.current::after { width: 55%; }



.lesson-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) var(--space-5) var(--space-6) var(--space-5);
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
}

.lesson-footer {
  position: sticky;
  bottom: 0;
  padding: var(--space-4) var(--space-5);
  padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
}

.lesson-footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.step-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent);
  margin-bottom: var(--space-2);
}

.step-title {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: var(--space-4);
}

.markdown { line-height: 1.65; }
.markdown p { line-height: 1.65; }
.markdown h1, .markdown h2, .markdown h3 { margin-top: var(--space-5); }
.markdown ul, .markdown ol { padding-left: 1.3em; line-height: 1.65; }
.markdown li { margin-bottom: var(--space-2); }
.markdown strong { font-weight: 700; }

.markdown code {
  font-family: var(--font-mono);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.88em;
}

/* Une expression longue passe à la ligne : chaque fragment garde son fond,
   ses bords arrondis et son padding, sinon la pastille paraît coupée. */
.markdown code,
.question-text code,
.choice code,
.explanation code {
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  overflow-wrap: break-word;
}

/* Markdown tables */
.table-wrap {
  overflow-x: auto;
  margin: var(--space-4) 0;
}

.markdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.5;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.markdown table thead {
  background: var(--color-surface-2);
}

.markdown table th {
  font-weight: 700;
  padding: 10px 14px;
  text-align: left;
  color: var(--color-text);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.markdown table td {
  padding: 9px 14px;
  border-top: 1px solid var(--color-border);
  color: var(--color-text);
}

.markdown table tbody tr:hover {
  background: var(--color-bg-alt);
}

.markdown table code {
  font-family: var(--font-mono);
  background: var(--color-bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}

.code-block {
  background: var(--editor-bg);
  color: var(--editor-fg);
  border: 1px solid var(--editor-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.65;
  margin: var(--space-4) 0;
}

.code-block code {
  font-family: inherit;
  background: none;
  border: none;
  color: inherit;
  padding: 0;
  white-space: pre;
}

.tok-keyword { color: #d9a05b; font-weight: 600; }
.tok-type { color: #93b4c7; }
.tok-string { color: #a9c08c; }
.tok-number { color: #dd9c7c; }
.tok-comment { color: #8b8377; font-style: italic; }
.tok-preproc { color: #a5c3ce; }
.tok-const { color: #dd9c7c; }
.tok-punct { color: #a8a094; }
.tok-op { color: #a5c3ce; }
.tok-register { color: #93b4c7; font-weight: 600; }
.tok-mnemonic { color: #d9a05b; font-weight: 600; }
.tok-directive { color: #a5c3ce; }
.tok-label { color: #e0c083; font-weight: 700; }

.question-text {
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: var(--space-5);
}

.question-text p {
  margin: 0 0 var(--space-2) 0;
}

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

.choice-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.choice {
  padding: 14px 18px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  text-align: left;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  transition: border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
}

.choice:hover:not(:disabled) {
  border-color: var(--color-text-muted);
  background: var(--color-bg-alt);
}

.choice code {
  font-family: var(--font-mono);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

.choice:active:not(:disabled) { transform: scale(0.99); }

.choice.correct {
  border-color: var(--color-success);
  background: var(--color-success-bg);
  color: var(--color-success);
  font-weight: 600;
}

.choice.correct code {
  background: color-mix(in srgb, var(--color-success) 16%, transparent);
  border-color: color-mix(in srgb, var(--color-success) 30%, transparent);
  color: var(--color-success);
}

.choice.correct:hover:not(:disabled) {
  border-color: var(--color-success);
  background: var(--color-success-bg);
}

.choice.wrong {
  border-color: var(--color-danger);
  background: var(--color-danger-bg);
  color: var(--color-danger);
  font-weight: 600;
  animation: shake 0.4s ease;
}

.choice.wrong code {
  background: color-mix(in srgb, var(--color-danger) 16%, transparent);
  border-color: color-mix(in srgb, var(--color-danger) 30%, transparent);
  color: var(--color-danger);
}

.choice.wrong:hover:not(:disabled) {
  border-color: var(--color-danger);
  background: var(--color-danger-bg);
}

.choice.disabled { opacity: 0.62; pointer-events: none; }

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

.trou-line {
  font-size: 1.1rem;
  font-family: var(--font-mono);
  background: var(--editor-bg);
  color: var(--editor-fg);
  border: 1px solid var(--editor-border);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-4);
}

.trou-input {
  font-family: inherit;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  min-width: 100px;
}

.trou-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(208, 138, 95, 0.25);
}

.trou-input.correct { border-color: #9cc09c; color: #cfe3cf; }
.trou-input.wrong { border-color: #d2796a; color: #f0c3ba; animation: shake 0.4s ease; }

.trou-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.hint-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  transition: background 0.15s ease;
  cursor: pointer;
}

.hint-btn .icon { width: 16px; height: 16px; color: var(--color-accent); }

.hint-btn:hover { background: var(--color-border); }

.explanation {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-border-strong);
  font-size: 0.92rem;
  line-height: 1.6;
}

.explanation p {
  margin: 0 0 var(--space-2) 0;
}

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

.explanation.state-correct { border-left-color: var(--color-success); }
.explanation.state-wrong { border-left-color: var(--color-danger); }

.explanation-hint {
  display: flex;
  gap: var(--space-3);
  border-left-color: var(--color-accent);
}

.explanation-hint .icon {
  width: 18px;
  height: 18px;
  color: var(--color-accent);
  margin-top: 2px;
}

.lesson-complete {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-6) var(--space-5);
  position: relative;
  overflow: hidden;
}

.confetti-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.lesson-complete-badge {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  position: relative;
  animation: popIn 0.6s cubic-bezier(.34, 1.56, .64, 1);
}

.lesson-complete-badge svg { width: 32px; height: 32px; }

.lesson-complete h1 {
  font-size: 1.45rem;
  margin-bottom: var(--space-5);
  position: relative;
}

.recap-stats {
  display: flex;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
  position: relative;
}

.recap-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.recap-stat .big {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.recap-stat .big .icon { width: 18px; height: 18px; color: var(--color-streak); }

.recap-stat .lbl {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-unlocked {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-5);
  width: 100%;
  max-width: 340px;
  position: relative;
  animation: popIn 0.5s cubic-bezier(.34, 1.56, .64, 1);
}

.badge-unlocked .badge-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.badge-unlocked .badge-icon svg { width: 20px; height: 20px; }
.badge-unlocked .badge-text { text-align: left; }
.badge-unlocked .badge-text strong { display: block; font-size: 0.95rem; }
.badge-unlocked .badge-text span { font-size: 0.8rem; color: var(--color-text-muted); }

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}

.profil-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-4) 0 var(--space-6) 0;
}

.profil-avatar {
  width: 76px;
  height: 76px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow-sm);
}

.profil-avatar svg { width: 34px; height: 34px; }

.profil-level {
  font-weight: 700;
  font-size: 1.15rem;
  margin-bottom: var(--space-3);
}

.level-bar {
  width: 100%;
  max-width: 260px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  overflow: hidden;
  margin-bottom: var(--space-2);
}

.level-bar-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.level-caption {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.stat-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-2);
  text-align: center;
}

.stat-tile .val {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 2px;
}

.stat-tile .val .icon { width: 15px; height: 15px; color: var(--color-streak); }

.stat-tile .lbl {
  display: block;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.badge-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-2);
  text-align: center;
}

.badge-tile .icon-wrap {
  width: 34px;
  height: 34px;
  margin: 0 auto var(--space-2) auto;
  border-radius: var(--radius-full);
  background: var(--color-accent-soft);
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge-tile .icon-wrap svg { width: 18px; height: 18px; }

.badge-tile.locked {
  background: transparent;
  border-style: dashed;
}

.badge-tile.locked .icon-wrap {
  background: var(--color-surface-2);
  color: var(--color-border-strong);
}

.badge-tile.locked .name { color: var(--color-text-muted); }

.badge-tile .name {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.3;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}

.setting-row .setting-label {
  font-size: 0.92rem;
  font-weight: 600;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
}

.segmented button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.segmented button .icon { width: 14px; height: 14px; }

.segmented button[aria-pressed="true"] {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

.logout-btn {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: var(--space-6);
  min-height: 48px;
  padding: var(--space-3);
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-md);
}

.logout-btn:hover { background: var(--color-surface-2); color: var(--color-text); }

/* --- Modes d'un parcours : cours, fiches, entraînement --- */
.mode-switch {
  display: flex;
  gap: 3px;
  padding: 3px;
  margin-bottom: var(--space-5);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
}

.mode-switch button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.mode-switch button .icon { width: 16px; height: 16px; }

.mode-switch button[aria-pressed="true"] {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

.mode-switch button[aria-pressed="true"] .icon { color: var(--color-accent); }

.mode-intro {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-4) 0;
}

/* --- Fiche de révision --- */
.fiche-corps {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.fiche-corps h3 {
  margin-top: var(--space-5);
  font-size: 1rem;
}

.fiche-corps h3:first-child { margin-top: 0; }

.fiche-nav {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.fiche-nav button {
  flex: 1;
  min-height: 48px;
  font-size: 0.82rem;
  line-height: 1.3;
  text-align: left;
  gap: 6px;
}

.fiche-nav button .icon { width: 15px; height: 15px; flex-shrink: 0; }

/* Sommaire des chapitres à côté de la fiche : uniquement sur grand écran (media query) */
.fiche-toc { display: none; }
.fiche-toc .section-title { margin-top: 0; }

.lesson-tile.current {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

.lesson-tile.current .lesson-tile-icon {
  background: var(--color-accent);
  color: #fff;
}

/* --- Exercices de programmation --- */
.exo-enonce {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}

.exo-contraintes {
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-accent-soft);
  border: 1px solid color-mix(in srgb, var(--color-accent) 25%, transparent);
  font-size: 0.85rem;
  line-height: 1.5;
}

.exo-contraintes p { margin: 0; }
.exo-contraintes p + p { margin-top: var(--space-2); }

.exo-contraintes-titre {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--color-accent);
  margin-bottom: var(--space-2);
}

.exo-contraintes-titre .icon { width: 16px; height: 16px; }

.exo-enonce-bloc { margin-top: var(--space-4); }

.exo-enonce-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-6) 0 var(--space-3) 0;
}

.exo-enonce-entete .section-title { margin: 0; }

.exo-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.exo-toggle:hover { background: var(--color-surface-2); }
.exo-toggle .icon { width: 14px; height: 14px; transform: rotate(90deg); transition: transform 0.15s ease; }

.exo-enonce-bloc.repliee .exo-toggle .icon { transform: rotate(0deg); }
.exo-enonce-bloc.repliee .exo-enonce-corps { display: none; }

.exo-exemples,
.exo-fixtures {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.exo-fixture {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.exo-fixture-nom {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.exo-exemple {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.exo-test-bloc { display: flex; flex-direction: column; gap: 3px; }

.exo-test-bloc > span {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.exo-sortie {
  margin: 0;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--editor-bg);
  color: var(--editor-fg);
  border: 1px solid var(--editor-border);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-x: auto;
}

.exo-sortie code { font-family: inherit; white-space: pre; }
.exo-sortie.journal { font-size: 0.75rem; max-height: 320px; overflow-y: auto; }

.exo-editeur {
  width: 100%;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-strong);
  background: var(--editor-bg);
  color: var(--editor-fg);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  tab-size: 4;
  resize: vertical;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  min-height: 220px;
  max-height: 52vh;
}

.exo-editeur:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

/* Reste joignable pendant qu'on relit les résultats plus bas : pas besoin de rescroller
   jusqu'en bas de page à chaque nouvel essai. */
.exo-run-bar {
  position: sticky;
  bottom: calc(var(--bottomnav-h) + var(--space-3));
  z-index: 15;
  padding: var(--space-3) 0;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
}

.exo-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-3) 0 var(--space-4) 0;
}

.exo-actions .btn { min-height: 44px; font-size: 0.85rem; padding: 0 16px; }

.exo-note {
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--color-text-muted);
  margin: var(--space-3) 0 0 0;
}

.exo-bilan {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-border-strong);
  background: var(--color-surface);
}

.exo-bilan strong { display: block; font-size: 1rem; margin-bottom: 4px; }
.exo-bilan p { margin: 0; font-size: 0.85rem; line-height: 1.5; color: var(--color-text-muted); }
.exo-bilan.ok { border-left-color: var(--color-success); background: var(--color-success-bg); }
.exo-bilan.ok strong { color: var(--color-success); }
.exo-bilan.ko { border-left-color: var(--color-danger); background: var(--color-danger-bg); }
.exo-bilan.ko strong { color: var(--color-danger); }

.exo-avertissements {
  margin-top: var(--space-3);
  font-size: 0.8rem;
}

.exo-avertissements strong {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--color-xp);
}

.exo-tests {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.exo-test {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.exo-test.ok { border-color: color-mix(in srgb, var(--color-success) 40%, transparent); }
.exo-test.ko { border-color: color-mix(in srgb, var(--color-danger) 40%, transparent); }

.exo-test-tete {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: 0.9rem;
}

.exo-test-badge {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.exo-test-badge.ok { background: var(--color-success-bg); color: var(--color-success); }
.exo-test-badge.ko { background: var(--color-danger-bg); color: var(--color-danger); }

.exo-test-cache {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.exo-test-note {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--color-text-muted);
}

.exo-test-note code {
  font-family: var(--font-mono);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 0.9em;
}

.review-resume {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.taille-switch {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
}

.taille-switch button {
  flex: 1;
  min-height: 44px;
  border-radius: var(--radius-full);
  font-size: 0.92rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.taille-switch button[aria-pressed="true"] {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

.faiblesse-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.faiblesse-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 60px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.faiblesse-row:hover {
  border-color: var(--color-border-strong);
  background: var(--color-bg-alt);
}

.faiblesse-rang {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.faiblesse-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.faiblesse-info strong {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.3;
}

.faiblesse-info span {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  line-height: 1.35;
}

.faiblesse-row .icon {
  width: 16px;
  height: 16px;
  color: var(--color-border-strong);
}

.review-origine {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.review-origine.erreur {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.review-origine.renfort {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.review-note {
  margin-top: var(--space-3);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--color-text-muted);
  text-align: center;
}

.bilan-liste {
  margin: 0;
  padding-left: 1.2em;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--color-text-muted);
}

.bilan-liste li { margin-bottom: var(--space-2); }

.review-progress {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  text-align: center;
}

.review-progress + .segbar {
  margin-bottom: var(--space-4);
}

.review-source {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: var(--space-3);
}

.review-done {
  text-align: center;
  padding: var(--space-7) var(--space-4);
}

.review-done .icon-wrap {
  width: 60px;
  height: 60px;
  margin: 0 auto var(--space-4) auto;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.review-done .icon-wrap svg { width: 28px; height: 28px; }
.review-done h2 { font-size: 1.2rem; }
.review-done p { color: var(--color-text-muted); font-size: 0.92rem; line-height: 1.55; }

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-accent);
  margin: var(--space-7) auto;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 720px) {
  .lesson-list { max-width: 520px; margin-left: auto; margin-right: auto; }
}

/* --- Mise en page desktop : au-delà de ce seuil, le chrome mobile (topbar + bottomnav)
   cède la place à la sidebar, et le contenu profite de la largeur au lieu de rester
   écrasé dans les 640px pensés pour le téléphone. En dessous, rien ne change. --- */
@media (min-width: 960px) {
  #app { flex-direction: row; align-items: stretch; }

  .topbar, .bottomnav { display: none; }

  .sidebar {
    display: flex;
    position: sticky;
    top: 0;
    height: 100dvh;
  }

  /* Par défaut, un écran desktop reste une colonne de lecture confortable (parcours,
     révision, profil, fiche...) : seul .view-wide (accueil, exercice — posé par app.js
     via meta.wide) profite de la pleine largeur avec une grille ou deux colonnes. */
  .view {
    max-width: var(--reading-width);
    margin: 0 auto;
    padding: var(--space-6) var(--space-6) var(--space-7);
  }

  .view.view-wide {
    max-width: var(--max-width-desktop);
  }

  .view.full-bleed {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  /* Accueil : grille plutôt qu'une colonne unique perdue dans le vide */
  .parcours-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
  }

  /* Exercice : énoncé et éditeur côte à côte plutôt qu'empilés */
  .exo-layout {
    display: grid;
    grid-template-columns: minmax(320px, 420px) 1fr;
    gap: var(--space-6);
    align-items: start;
  }

  .exo-col-enonce {
    position: sticky;
    top: var(--space-5);
    max-height: calc(100dvh - var(--space-6) * 2);
    overflow-y: auto;
    padding-right: var(--space-2);
  }

  /* Le repli de l'énoncé n'a de sens que sur mobile (gagner de la place au-dessus de
     l'éditeur) : ici l'énoncé est déjà à côté, pas au-dessus, donc pas de repli. */
  .exo-enonce-bloc.repliee .exo-enonce-corps { display: block; }
  .exo-enonce-entete .exo-toggle { display: none; }

  .exo-run-bar { bottom: var(--space-4); }

  /* Fiche : la fiche reste une colonne de lecture confortable, jamais étirée
     edge-to-edge ; un sommaire des chapitres n'apparaît que si la largeur restante
     le permet vraiment (media query dédiée plus bas). */
  .fiche-layout {
    display: grid;
    grid-template-columns: minmax(0, var(--reading-width));
    justify-content: center;
    gap: var(--space-6);
  }

  .fiche-main { max-width: var(--reading-width); }
}

@media (min-width: 1360px) {
  .fiche-layout {
    grid-template-columns: minmax(0, var(--reading-width)) minmax(220px, 260px);
    justify-content: start;
  }

  .fiche-toc { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
