/* ==========================================================
   Axiome — feuille de style principale
   ========================================================== */
:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f3f2ee;
  --text: #1d1f24;
  --text-soft: #5a5f6b;
  --border: #dedbd2;
  --accent: #3355ff;
  --accent-soft: #e6ebff;
  --ok: #1f9d55;
  --ok-soft: #e3f6ea;
  --ko: #d64545;
  --ko-soft: #fce8e8;
  --warn: #c77700;
  --warn-soft: #fff3dc;

  /* couleurs par thème */
  --t-nombres: #3355ff;
  --t-geometrie: #0f9d76;
  --t-fonctions: #8a3ffc;
  --t-stats: #e8590c;
  --t-algo: #0b8aa8;
  --t-logique: #c2255c;

  --grid: #e6e3da;
  --axis: #6b6f7a;
  --curve1: #3355ff;
  --curve2: #e8590c;
  --curve3: #0f9d76;
  --curve4: #8a3ffc;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 4px 16px rgba(20, 20, 30, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-title: "Fraunces", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161b; --surface: #1e2128; --surface-2: #252932;
    --text: #e9eaee; --text-soft: #a3a8b5; --border: #333845;
    --accent: #7d95ff; --accent-soft: #232b4d;
    --ok: #3ccf7f; --ok-soft: #173325; --ko: #ff7070; --ko-soft: #3a1d1f;
    --warn: #ffb347; --warn-soft: #3a2c14;
    --t-nombres: #7d95ff; --t-geometrie: #33c9a0; --t-fonctions: #b58cff;
    --t-stats: #ff8a4c; --t-algo: #3cc3e0; --t-logique: #ff6b9e;
    --grid: #2a2e38; --axis: #8d93a1;
    --curve1: #7d95ff; --curve2: #ff8a4c; --curve3: #33c9a0; --curve4: #b58cff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161b; --surface: #1e2128; --surface-2: #252932;
  --text: #e9eaee; --text-soft: #a3a8b5; --border: #333845;
  --accent: #7d95ff; --accent-soft: #232b4d;
  --ok: #3ccf7f; --ok-soft: #173325; --ko: #ff7070; --ko-soft: #3a1d1f;
  --warn: #ffb347; --warn-soft: #3a2c14;
  --t-nombres: #7d95ff; --t-geometrie: #33c9a0; --t-fonctions: #b58cff;
  --t-stats: #ff8a4c; --t-algo: #3cc3e0; --t-logique: #ff6b9e;
  --grid: #2a2e38; --axis: #8d93a1;
  --curve1: #7d95ff; --curve2: #ff8a4c; --curve3: #33c9a0; --curve4: #b58cff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 17px; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--font-title); line-height: 1.2; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 4vw, 2.8rem); margin: .2em 0 .3em; }
h2 { font-size: 1.75rem; margin: 2.2em 0 .7em; padding-top: .3em; }
h3 { font-size: 1.3rem; margin: 1.8em 0 .6em; }
h4 { font-size: 1.08rem; margin: 1.2em 0 .4em; }
p { margin: .6em 0; }
code, .mono { font-family: var(--mono); font-size: .9em; }
:not(pre) > code { background: var(--surface-2); padding: .1em .35em; border-radius: 6px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.muted { color: var(--text-soft); }
.small { font-size: .88rem; }
.center { text-align: center; }
table { border-collapse: collapse; }

/* ---------- En-tête ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-title); font-weight: 700; font-size: 1.3rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--text); color: var(--bg); font-size: 1.1rem;
}
.topnav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.topnav a { color: var(--text-soft); padding: 6px 12px; border-radius: 8px; font-size: .95rem; }
.topnav a:hover, .topnav a.active { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 1.05rem;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-2); }
.menu-btn { display: none; }
.nav-links { display: flex; gap: 2px; align-items: center; }
.nav-sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }
.nav-toggle { display: none; width: auto; padding: 0 12px; font-family: var(--font); font-size: .9rem; font-weight: 600; }
@media (max-width: 1060px) {
  .nav-toggle { display: grid; }
  .nav-links {
    display: none; position: absolute; right: 16px; top: 56px; flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 8px; min-width: 220px;
    box-shadow: var(--shadow); z-index: 70;
  }
  .topbar.nav-open .nav-links { display: flex; }
  .nav-links a { padding: 10px 14px; font-size: 1rem; }
  .nav-sep { width: auto; height: 1px; margin: 4px 6px; }
}

/* ---------- Démonstrations mises en valeur ---------- */
.demo-prog {
  position: relative; margin: 26px 0; padding: 18px 20px 12px; border-radius: 16px;
  background: linear-gradient(135deg, color-mix(in srgb, #8a3ffc 9%, var(--surface)), var(--surface));
  border: 2px solid color-mix(in srgb, #8a3ffc 55%, var(--border));
  box-shadow: 0 0 0 4px color-mix(in srgb, #8a3ffc 10%, transparent), var(--shadow);
  overflow-x: auto;
}
.demo-prog:not([data-prog]) { border-style: dashed; box-shadow: var(--shadow); }
.demo-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.demo-badge {
  font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #fff;
  background: linear-gradient(90deg, #8a3ffc, #c2255c); padding: 4px 11px; border-radius: 99px;
}
.demo-prog:not([data-prog]) .demo-badge { background: var(--axis); }
.demo-title { font-family: var(--font-title); font-weight: 600; font-size: 1.15rem; }
.demo-prog details.preuve { margin-top: 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.demo-prog details.preuve > summary { cursor: pointer; padding: 10px 14px; font-weight: 700; color: #8a3ffc; list-style: none; display: flex; gap: 8px; align-items: center; }
.demo-prog details.preuve > summary::before { content: "▸"; transition: transform .2s; }
.demo-prog details.preuve[open] > summary::before { transform: rotate(90deg); }
.demo-prog details.preuve > .inner { padding: 2px 16px 14px; }
:root[data-theme="dark"] .demo-prog details.preuve > summary { color: #b58cff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .demo-prog details.preuve > summary { color: #b58cff; } }
.demo-count { display: inline-block; margin-top: 14px; font-weight: 700; font-size: .9rem; color: #fff; background: linear-gradient(90deg, #8a3ffc, #c2255c); padding: 6px 14px; border-radius: 99px; }
.demo-count:hover { text-decoration: none; filter: brightness(1.1); }
.toc-demos li a { color: #8a3ffc; }
:root[data-theme="dark"] .toc-demos li a { color: #b58cff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toc-demos li a { color: #b58cff; } }
.demo-source { font-size: .85rem; margin: -18px 0 26px 6px; }

/* ---------- Mise en page ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.chapter-layout {
  max-width: 1280px; margin: 0 auto; padding: 0 20px 80px;
  display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 48px;
}
.sidebar { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 90px); overflow: auto; padding: 24px 0; font-size: .92rem; }
.sidebar h4 { font-family: var(--font); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-soft); margin: 0 0 8px; }
.toc { list-style: none; padding: 0; margin: 0 0 24px; border-left: 2px solid var(--border); }
.toc li a { display: block; padding: 5px 12px; color: var(--text-soft); margin-left: -2px; border-left: 2px solid transparent; }
.toc li.sub a { padding-left: 26px; font-size: .86rem; }
.toc li a:hover { color: var(--text); text-decoration: none; }
.toc li a.active { color: var(--theme, var(--accent)); border-left-color: var(--theme, var(--accent)); font-weight: 600; }
.content { min-width: 0; padding-top: 24px; max-width: 860px; }

/* ---------- Hero de chapitre ---------- */
.breadcrumb { font-size: .88rem; color: var(--text-soft); margin: 8px 0 0; }
.breadcrumb a { color: var(--text-soft); }
.chapter-hero {
  border-radius: 20px; padding: 32px; margin: 12px 0 28px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--theme) 16%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--theme) 25%, var(--border));
  position: relative; overflow: hidden;
}
.chapter-hero .tag { display: inline-block; font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--theme); }
.chapter-hero h1 { margin: .15em 0 .35em; }
.chapter-hero .lead { font-size: 1.1rem; color: var(--text-soft); max-width: 640px; }
.chapter-hero .num {
  position: absolute; right: 24px; top: 4px; font-family: var(--font-title); font-size: 8rem; font-weight: 700;
  color: var(--theme); opacity: .12; line-height: 1; pointer-events: none;
}
.objectives { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-top: 18px; padding: 0; list-style: none; }
.objectives li { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px 8px 36px; position: relative; font-size: .93rem; }
.objectives li::before { content: "✓"; position: absolute; left: 12px; color: var(--theme); font-weight: 700; }

/* ---------- Encadrés de cours ---------- */
.box {
  border-radius: var(--radius); padding: 16px 20px; margin: 18px 0;
  background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--c, var(--accent));
  box-shadow: var(--shadow);
}
.box > .box-title { font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; color: var(--c); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.box > .box-title .name { text-transform: none; letter-spacing: 0; color: var(--text); font-size: 1rem; }
.box.def { --c: #3355ff; }
.box.prop { --c: #0f9d76; }
.box.thm { --c: #8a3ffc; }
.box.methode { --c: #e8590c; }
.box.exemple { --c: #0b8aa8; background: var(--surface-2); box-shadow: none; }
.box.attention { --c: #d64545; background: var(--ko-soft); box-shadow: none; }
.box.remarque { --c: #6b6f7a; box-shadow: none; }
.box.histoire { --c: #a8741a; background: var(--warn-soft); box-shadow: none; font-size: .95rem; }
.box.retiens { --c: #c2255c; }
:root[data-theme="dark"] .box.def { --c: #7d95ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .box.def { --c: #7d95ff; } }

details.demo, details.correction, details.indice {
  margin: 12px 0; border-radius: 10px; border: 1px dashed var(--border); background: var(--surface);
}
details.demo > summary, details.correction > summary, details.indice > summary {
  cursor: pointer; padding: 8px 14px; font-weight: 600; font-size: .92rem; list-style: none; color: var(--text-soft);
  display: flex; align-items: center; gap: 8px; user-select: none;
}
details > summary::-webkit-details-marker { display: none; }
details.demo > summary::before, details.correction > summary::before, details.indice > summary::before { content: "▸"; transition: transform .2s; }
details[open] > summary::before { transform: rotate(90deg); }
details.demo > summary::after { content: "Démonstration"; }
details.demo > .inner, details.correction > .inner, details.indice > .inner { padding: 4px 16px 14px; }
details.correction { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
details.correction > summary { color: var(--ok); }
details.indice > summary { color: var(--warn); }

/* ---------- Exercices ---------- */
.exo {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin: 16px 0; box-shadow: var(--shadow);
}
.exo-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.exo-num { font-weight: 700; font-family: var(--font-title); font-size: 1.1rem; }
.exo-title { color: var(--text-soft); font-size: .95rem; }
.level { margin-left: auto; font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.level.l1 { background: var(--ok-soft); color: var(--ok); }
.level.l2 { background: var(--warn-soft); color: var(--warn); }
.level.l3 { background: var(--ko-soft); color: var(--ko); }
.exo ol, .exo ul { padding-left: 1.4em; }
.exo-filter { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 6px 14px; border-radius: 99px; cursor: pointer; font-size: .88rem; font-family: var(--font);
}
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- Interactif : champs, boutons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  font-family: var(--font); font-size: .95rem; font-weight: 600;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  background: var(--theme, var(--accent)); color: #fff; transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 5px 11px; font-size: .85rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input[type="text"], input[type="number"], select, textarea {
  font-family: var(--font); font-size: 1rem; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 10px; padding: 8px 12px; outline: none;
}
input[type="text"]:focus, input[type="number"]:focus, select:focus, textarea:focus { border-color: var(--theme, var(--accent)); }
input.ok { border-color: var(--ok); background: var(--ok-soft); }
input.ko { border-color: var(--ko); background: var(--ko-soft); }
input[type="range"] { accent-color: var(--theme, var(--accent)); width: 100%; }

.ask { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.ask input { width: 140px; }
.feedback { font-weight: 600; font-size: .92rem; }
.feedback.ok { color: var(--ok); }
.feedback.ko { color: var(--ko); }

/* QCM */
.qcm { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin: 14px 0; }
.qcm .q { font-weight: 600; margin-bottom: 10px; }
.qcm .choices { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.qcm .choice {
  text-align: left; font-family: var(--font); font-size: .98rem; color: var(--text);
  background: var(--surface-2); border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 14px; cursor: pointer;
}
.qcm .choice:hover { border-color: var(--theme, var(--accent)); }
.qcm .choice.good { border-color: var(--ok); background: var(--ok-soft); }
.qcm .choice.bad { border-color: var(--ko); background: var(--ko-soft); }
.qcm .expl { margin-top: 10px; font-size: .95rem; display: none; }
.qcm.done .expl { display: block; }

/* ---------- Widgets / mini-jeux ---------- */
.widget {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  margin: 22px 0; box-shadow: var(--shadow); overflow: hidden;
}
.widget-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.widget-head .ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--theme, var(--accent)); color: #fff; font-size: .95rem; }
.widget-head .ttl { font-weight: 700; }
.widget-head .sub { color: var(--text-soft); font-size: .85rem; }
.widget-head .spacer { flex: 1; }
.widget-body { padding: 16px 18px; }
.widget-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.widget-cols > *, .two-col > *, .controls > * { min-width: 0; }
.readout, .box, .exo, .qcm { overflow-x: auto; }
.game-q > * { max-width: 100%; min-width: 0; }
.controls { display: grid; gap: 10px; }
.control label { display: flex; justify-content: space-between; font-size: .9rem; color: var(--text-soft); }
.control label b { color: var(--text); font-family: var(--mono); }
.readout { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; font-size: .95rem; }
.readout .big { font-size: 1.2rem; }
.scorebar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: .92rem; }
.scorebar .stat { background: var(--surface-2); padding: 4px 12px; border-radius: 99px; }
.scorebar .stat b { font-family: var(--mono); }
.game-q { font-size: 1.25rem; text-align: center; padding: 16px 8px; min-height: 70px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; }
.game-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; align-items: center; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.timer-bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.timer-bar > div { height: 100%; background: var(--theme, var(--accent)); transition: width .25s linear; }
.flash-ok { animation: flashok .5s; }
.flash-ko { animation: flashko .5s; }
@keyframes flashok { 0% { background: var(--ok-soft); } 100% { background: transparent; } }
@keyframes flashko { 0% { background: var(--ko-soft); } 100% { background: transparent; } }
@keyframes pop { 0% { transform: scale(.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.pop { animation: pop .25s ease-out; }

/* SVG graphiques */
svg.graph { display: block; width: 100%; height: auto; touch-action: none; user-select: none; background: var(--surface); }
svg.graph .grid line { stroke: var(--grid); stroke-width: 1; }
svg.graph .axis line, svg.graph .axis path { stroke: var(--axis); stroke-width: 1.5; }
svg.graph .axis text, svg.graph text.lbl { fill: var(--text-soft); font-size: 12px; font-family: var(--font); }
svg.graph text { font-family: var(--font); fill: var(--text); }
svg.graph .c1 { stroke: var(--curve1); fill: none; stroke-width: 2.6; }
svg.graph .c2 { stroke: var(--curve2); fill: none; stroke-width: 2.6; }
svg.graph .c3 { stroke: var(--curve3); fill: none; stroke-width: 2.6; }
svg.graph .c4 { stroke: var(--curve4); fill: none; stroke-width: 2.6; }
svg.graph .thin { stroke-width: 1.4; }
svg.graph .dash { stroke-dasharray: 6 5; }
svg.graph .pt { stroke: var(--surface); stroke-width: 2; }
svg.graph .drag { cursor: grab; }
svg.graph .drag:hover { filter: brightness(1.15); }
svg.graph .drag.dragging { cursor: grabbing; }
svg.graph .halo { fill: currentColor; opacity: .15; }

/* Droite graduée, cases, grilles de jeu */
.grid-game { display: grid; gap: 6px; }
.cell {
  display: grid; place-items: center; aspect-ratio: 1; border-radius: 8px; cursor: pointer; font-weight: 600;
  background: var(--surface-2); border: 1.5px solid var(--border); color: var(--text); font-family: var(--font); font-size: .95rem;
  transition: background .15s, transform .1s;
}
.cell:hover { border-color: var(--theme, var(--accent)); }
.cell.on { background: var(--theme, var(--accent)); color: #fff; border-color: transparent; }
.cell.good { background: var(--ok); color: #fff; border-color: transparent; }
.cell.bad { background: var(--ko); color: #fff; border-color: transparent; }
.cell.miss { outline: 3px dashed var(--ok); }

/* Tableaux (signes, variations, stats) */
.tab { border-collapse: collapse; margin: 12px auto; background: var(--surface); font-size: .98rem; }
.tab th, .tab td { border: 1px solid var(--border); padding: 6px 12px; text-align: center; }
.tab th { background: var(--surface-2); font-weight: 600; }
.tab-wrap { max-width: 100%; overflow-x: auto; position: relative; }
.signcell { cursor: pointer; min-width: 46px; font-weight: 700; font-size: 1.1rem; }
.signcell:hover { background: var(--accent-soft); }
.signcell.ok { background: var(--ok-soft); }
.signcell.ko { background: var(--ko-soft); }

/* Code / Python */
.code-editor {
  width: 100%; min-height: 180px; font-family: var(--mono); font-size: .92rem; line-height: 1.5;
  background: #1b1e25; color: #e6e6e6; border-radius: 10px; border: 1px solid #333; padding: 12px; resize: vertical; tab-size: 4;
}
.code-out {
  font-family: var(--mono); font-size: .9rem; white-space: pre-wrap; background: #0f1115; color: #b7f5c5;
  border-radius: 10px; padding: 10px 12px; min-height: 48px; margin-top: 8px; max-height: 300px; overflow: auto;
}
.code-out .err { color: #ff8b8b; }
pre.code {
  background: #1b1e25; color: #e6e6e6; border-radius: 10px; padding: 12px 14px; overflow-x: auto;
  font-family: var(--mono); font-size: .9rem; line-height: 1.5;
}
pre.code .kw { color: #ff7ab2; } pre.code .fn { color: #7ab8ff; } pre.code .str { color: #b6e27a; }
pre.code .cm { color: #7f8595; font-style: italic; } pre.code .num { color: #ffb86b; }

/* ---------- Page d'accueil ---------- */
.home-hero { padding: 64px 0 36px; }
.home-hero h1 { font-size: clamp(2.4rem, 6vw, 4rem); max-width: 820px; }
.home-hero .lead { font-size: 1.2rem; color: var(--text-soft); max-width: 640px; }
.home-hero .hl { color: var(--accent); font-style: italic; }
.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 30px 0 60px; }
.level-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 22px; box-shadow: var(--shadow);
  color: var(--text); display: block; transition: transform .15s, border-color .15s;
}
.level-card:hover { transform: translateY(-3px); border-color: var(--accent); text-decoration: none; }
.level-card .big { font-family: var(--font-title); font-size: 2.2rem; font-weight: 700; }
.theme-block { margin: 30px 0 40px; }
.theme-block h2 { display: flex; align-items: center; gap: 12px; margin-top: 1.2em; }
.theme-block h2 .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--theme); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.ch-card {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px 18px 16px;
  color: var(--text); display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); transition: transform .15s, border-color .15s;
  border-top: 4px solid var(--theme);
}
.ch-card:hover { transform: translateY(-3px); border-color: var(--theme); text-decoration: none; }
.ch-card .n { font-size: .78rem; font-weight: 700; color: var(--theme); text-transform: uppercase; letter-spacing: .07em; }
.ch-card .t { font-family: var(--font-title); font-size: 1.2rem; font-weight: 600; line-height: 1.25; }
.ch-card .d { font-size: .9rem; color: var(--text-soft); }
.ch-card .meta { margin-top: auto; padding-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.ch-card .meta span { font-size: .75rem; background: var(--surface-2); padding: 2px 8px; border-radius: 99px; color: var(--text-soft); }
.ch-card .done-badge { position: absolute; top: 14px; right: 14px; background: var(--ok); color: #fff; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.progress-global { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 18px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.progress-global .bar { flex: 1; min-width: 160px; height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-global .bar div { height: 100%; background: var(--ok); border-radius: 99px; transition: width .4s; }

/* Pied de chapitre */
.chapter-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 50px; flex-wrap: wrap; }
.chapter-foot a { flex: 1; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 18px; color: var(--text); }
.chapter-foot a:hover { border-color: var(--theme, var(--accent)); text-decoration: none; }
.chapter-foot a.next { text-align: right; }
.chapter-foot small { color: var(--text-soft); display: block; }
.done-toggle { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 40px; padding: 18px; border: 2px dashed var(--border); border-radius: 14px; }
footer.site-foot { border-top: 1px solid var(--border); padding: 26px 20px; text-align: center; color: var(--text-soft); font-size: .88rem; }

/* Figures */
figure.fig { margin: 18px 0; text-align: center; }
figure.fig svg { background: var(--surface); border-radius: 12px; border: 1px solid var(--border); }
figure.fig figcaption { font-size: .88rem; color: var(--text-soft); margin-top: 6px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* KaTeX : pas de débordement */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.katex { position: relative; }

/* ---------- Matrices, fractales (Maths expertes) ---------- */
.mat-eq { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.mat-eq .op { font-size: 1.5rem; font-weight: 700; color: var(--text-soft); }
table.mat { border-collapse: separate; border-spacing: 3px; margin: 4px auto; padding: 2px 6px; border-left: 2px solid var(--text); border-right: 2px solid var(--text); border-radius: 10px; }
table.mat td { min-width: 2.4em; text-align: center; font-family: var(--mono); padding: 4px 6px; border-radius: 6px; transition: background .15s; }
table.mat td.hl { background: color-mix(in srgb, var(--theme, var(--accent)) 24%, transparent); }
table.mat input[type="number"] { width: 3.6em; padding: 4px 2px; text-align: center; font-family: var(--mono); }
.mc td { cursor: pointer; font-weight: 700; }
canvas.fractal { width: 100%; display: block; border-radius: 12px; cursor: zoom-in; background: var(--surface-2); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .chapter-layout { grid-template-columns: 1fr; gap: 0; padding: 0 16px 60px; }
  .sidebar {
    position: fixed; top: 58px; left: 0; bottom: 0; width: 280px; max-height: none; z-index: 60;
    background: var(--bg); border-right: 1px solid var(--border); padding: 20px; transform: translateX(-100%); transition: transform .25s;
  }
  body.menu-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .menu-btn { display: grid; }
  .widget-cols, .two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .topbar-inner { padding: 10px 16px; }
  .container { padding: 0 16px; }
  .chapter-hero { padding: 22px 18px; }
  .chapter-hero .num { font-size: 5rem; }
  .widget-body { padding: 14px; }
  .box { padding: 14px 16px; }
  .exo { padding: 16px; }
  h2 { font-size: 1.5rem; }
  .brand span.txt { display: none; }
}

@media print {
  .topbar, .sidebar, .widget, .chapter-foot, .done-toggle, .exo-filter { display: none !important; }
  .chapter-layout { display: block; }
  details { border: none !important; }
  details > .inner { display: block !important; }
}
