/* Palette Maths0 = palette du site principal (blanc / navy / orange clair),
   comme la bannière d'accueil — demande explicite de l'utilisateur, à la
   place d'une teinte distincte par chapitre. Une seule palette pour tous
   les chapitres : `[data-theme]` reste posé dans le HTML (cf.
   content/content.json > chapitres[].color) mais ne change plus rien ici,
   pour ne pas avoir à toucher le contenu si l'un ou l'autre revient. */
:root {
  --ivory: #ffffff;
  --ivory-soft: #f4f6f9;
  --card: #ffffff;
  --ink: #002b5c;
  --ink-soft: #5a6b7b;
  --border: #e2e8f0;
  --shadow: 0 6px 20px rgba(0, 43, 92, 0.08);
  --shadow-lg: 0 14px 36px rgba(0, 43, 92, 0.16);
  --radius: 14px;
  --green: #16a34a;
  --red: #dc2626;

  --theme: #002b5c;
  --theme-soft: #eaf3fb;
  --blue: #0073cf;
  --accent: #ff6a13;
  --accent-600: #e85d08;
  /* Orangé clair utilisé sur fond navy (bannière d'accueil du site,
     `.home-banner-note a`) — demande explicite de l'utilisateur pour le
     bandeau sombre de Maths0, distinct de l'orange vif des boutons. */
  --accent-light: #ffc78a;
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--ivory);
  color: var(--ink);
}
h2 {
  font-family: "Fraunces", Georgia, serif;
  color: var(--ink);
  font-weight: 700;
  margin: 0 0 6px;
}
.muted { color: var(--ink-soft); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 24px;
  background: var(--ink);
  color: #fff;
}
.back-link { color: #fff; opacity: 0.85; text-decoration: none; font-size: 0.9rem; font-weight: 600; flex: none; white-space: nowrap; }
.back-link:hover { opacity: 1; text-decoration: underline; }
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; flex: 1; min-width: 0; overflow: hidden; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: #fff; color: var(--ink); font-weight: 800; font-size: 0.85rem;
}
.brand-text { font-family: "Fraunces", Georgia, serif; font-weight: 700; font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text em { font-style: normal; opacity: 0.85; font-weight: 600; color: var(--accent-light); }
.topbar nav { display: flex; gap: 8px; flex: none; }
.nav-btn {
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.35); color: #fff;
  padding: 8px 16px; border-radius: 999px; cursor: pointer; font-size: 0.88rem; font-weight: 700; white-space: nowrap;
}
.nav-btn:hover { background: rgba(255,255,255,0.22); }

@media (max-width: 640px) {
  .topbar { padding: 12px 14px; gap: 8px; }
  .back-link span.back-label { display: none; }
  .brand-text { font-size: 1rem; }
  .nav-btn { padding: 7px 10px; font-size: 0.76rem; }
}
@media (max-width: 360px) {
  /* Sous 360px, même deux libellés courts ("Composer"/"Progression") ne
     tiennent plus à côté du monogramme + "← " : le monogramme porte seul
     la marque (cf. apps/web, même geste sur le header du site). */
  .brand-text { display: none; }
}

#app { max-width: 880px; margin: 0 auto; padding: 26px 16px 60px; }
.footer { text-align: center; padding: 18px; color: var(--ink-soft); font-size: 0.82rem; }

.section-title {
  margin-top: 28px; padding-bottom: 6px; font-size: 0.95rem; color: var(--ink);
  font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 2px solid var(--border);
}

/* ── Compositeur ─────────────────────────────────────────────────────── */
.chapter-block { margin-top: 14px; }
.chapter-head {
  display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--theme);
  padding: 8px 0;
}
.chapter-head--soon { color: var(--ink-soft); }
.chapter-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; background: var(--theme-soft); color: var(--theme);
  font-weight: 800; font-size: 0.8rem; flex: none;
}
.soon-badge { margin-left: auto; font-size: 0.75rem; font-weight: 700; color: var(--ink-soft); background: var(--ivory-soft); padding: 3px 10px; border-radius: 999px; }
.chapter-avg { margin-left: auto; font-weight: 800; color: var(--theme); }

.paragraphe-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 6px; }
.paragraphe-chip {
  border: 1.5px solid var(--border); background: var(--card); color: var(--ink);
  padding: 8px 14px; border-radius: 18px; font-size: 0.88rem; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: all .12s ease;
}
.paragraphe-chip:hover { border-color: var(--theme); }
.paragraphe-chip.is-selected { background: var(--theme); border-color: var(--theme); color: #fff; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  border: 1.5px solid var(--border); background: var(--card); color: var(--ink);
  padding: 7px 16px; border-radius: 999px; font-size: 0.88rem; font-weight: 700; cursor: pointer; font-family: inherit;
}
.chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

.roadmap {
  margin-top: 24px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.roadmap-title { font-weight: 800; font-size: 0.85rem; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-soft); margin-bottom: 8px; }
.roadmap-body { display: flex; flex-wrap: wrap; gap: 6px; }
.roadmap-pill { background: var(--theme-soft); color: var(--theme); font-weight: 700; font-size: 0.82rem; padding: 5px 12px; border-radius: 999px; }

.primary-btn {
  background: var(--accent); color: #fff; border: none; padding: 12px 22px; border-radius: 999px;
  font-size: 1rem; font-weight: 700; cursor: pointer; font-family: inherit; transition: background .15s;
}
.primary-btn:hover { background: var(--accent-600); }
.primary-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.link-btn { background: none; border: none; color: var(--blue); text-decoration: underline; cursor: pointer; font-size: 0.9rem; padding: 0; font-weight: 600; font-family: inherit; flex: none; }

/* ── Rappel de cours ─────────────────────────────────────────────────── */
.rappel-card {
  background: var(--theme-soft); border: 1px solid var(--theme); border-radius: var(--radius);
  padding: 22px; margin-top: 14px;
}
.rappel-tag { font-weight: 800; font-size: 0.82rem; text-transform: uppercase; letter-spacing: .3px; color: var(--theme); margin-bottom: 10px; }
.rappel-body p { margin: 0 0 10px; line-height: 1.65; }
.rappel-body ol { margin: 0 0 10px; padding-left: 22px; line-height: 1.65; }
.rappel-body strong { color: var(--theme); }
.rappel-table { width: 100%; border-collapse: collapse; margin: 4px 0 14px; background: var(--card); border-radius: 10px; overflow: hidden; }
.rappel-table th, .rappel-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 0.92rem; text-align: center; }
.rappel-table th:first-child, .rappel-table td:first-child { text-align: left; }
.rappel-table th { background: var(--theme); color: #fff; font-weight: 700; }
.rappel-table tr:last-child td { border-bottom: none; }
/* Schémas des rappels (rangées) : livres / personnes, blocs, emplacements ▼.
   Tout en <span> (le schéma vit dans un <p>) — cf. schema() dans gen_content.py. */
.sch {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 10px 12px; margin: 4px 0 2px;
}
.sch-row { display: flex; align-items: flex-end; justify-content: center; flex-wrap: wrap; gap: 4px; padding: 0 8px 3px; }
.sch-etagere { border-bottom: 6px solid #a16207; border-radius: 0 0 3px 3px; }
.sch-slot { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; }
.sch-sub { font-size: 0.75rem; font-weight: 700; color: var(--ink-soft); line-height: 1.1; min-height: 1.1em; }
.sch-livre, .sch-perso {
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 0.78rem; line-height: 1;
}
.sch-livre { width: 26px; height: 42px; border-radius: 4px 4px 2px 2px; box-shadow: inset -4px 0 0 rgba(0, 0, 0, .18); }
.sch-perso { width: 30px; height: 30px; border-radius: 50%; }
.sch-livre sub, .sch-perso sub { font-size: 0.6rem; }
.sch-bleu { background: #2563eb; }
.sch-rouge { background: #dc2626; }
.sch-vert { background: #16a34a; }
.sch-rose { background: #db2777; }
.sch-ardoise { background: #475569; }
.sch-bloc { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; }
.sch-bloc-in { display: inline-flex; gap: 3px; padding: 3px; border: 2px dashed var(--accent); border-radius: 8px; background: #fff4ec; }
.sch-lab { font-size: 0.75rem; font-weight: 800; color: var(--accent-600); line-height: 1.1; white-space: nowrap; }
.sch-op { align-self: center; font-weight: 800; color: var(--ink-soft); padding: 0 2px; }
.sch-trou { align-self: flex-end; color: var(--accent); font-size: 0.85rem; padding: 0 1px 4px; }
.sch-cap { font-size: 0.88rem; text-align: center; line-height: 1.5; }
.sch-case {
  display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 32px;
  padding: 0 6px; border-radius: 6px; color: #fff; font-weight: 800; font-size: 0.82rem; white-space: nowrap;
}
.sch-jaune { background: #eab308; color: #1f2937; }
.sch-noir { background: #1f2937; }
.sch-gris { background: #e2e8f0; color: #334155; }
.sch-orange { background: var(--accent); }
.sch-blanc { background: #fff; color: #1f2937; box-shadow: inset 0 0 0 1.5px #94a3b8; }
.sch-boule { display: inline-block; width: 22px; height: 22px; border-radius: 50%; box-shadow: inset -3px -3px 0 rgba(0, 0, 0, .15); align-self: center; }
.sch-urne-w { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.sch-urne {
  display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 4px; max-width: 150px;
  padding: 12px 10px 10px; border: 3px solid var(--ink-soft); border-top: none; border-radius: 0 0 28px 28px;
}
.sch-lignes { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.sch-panneaux { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: 100%; }
.sch-panneau {
  display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1 1 180px; max-width: 260px;
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--ivory-soft);
}
.sch-ptitre { font-weight: 800; font-size: 0.82rem; color: var(--theme); text-align: center; }
.sch-pform { font-size: 0.85rem; text-align: center; }
.sch-grille { display: inline-grid; gap: 2px; }
.sch-c {
  display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 3px;
  border-radius: 4px; background: var(--ivory-soft); font-size: 0.78rem; font-weight: 700;
}
.sch-ch { background: transparent; color: var(--ink-soft); }
.sch-hl { background: var(--accent); color: #fff; }
.sch-carte { background: #fff; box-shadow: inset 0 0 0 1px var(--border); }
.sch-noire { color: #1f2937; }
.sch-rougec { color: #dc2626; }
.sch-fig { background: #ffe3d1; }
.sch-as { background: #dbeafe; }
.sch-podium { display: flex; align-items: flex-end; gap: 4px; }
.sch-marche {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 4px; width: 78px;
  border-radius: 6px 6px 0 0; color: #fff; padding-top: 6px;
}
.sch-marche b { font-size: 1.3rem; }
.sch-marche .sch-sub { color: #fff; }
.sch-marche.m1 { height: 96px; background: #d4a017; }
.sch-marche.m2 { height: 72px; background: #94a3b8; }
.sch-marche.m3 { height: 56px; background: #b45309; }
.sch-svg { display: block; width: 100%; height: auto; }
@media (max-width: 420px) {
  .sch-livre { width: 22px; height: 36px; }
  .sch-perso { width: 26px; height: 26px; }
}

/* ── Question ─────────────────────────────────────────────────────────── */
.top-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.top-actions-left { display: flex; align-items: center; gap: 14px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--card); color: var(--theme); cursor: pointer; padding: 0; flex: none;
}
.icon-btn:hover { border-color: var(--theme); }

/* ── Calculatrice ─────────────────────────────────────────────────────── */
.calc-overlay {
  position: fixed; inset: 0; background: rgba(0, 43, 92, 0.45); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.calc-card {
  width: min(320px, 100%); background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 16px; max-height: calc(100vh - 32px); overflow-y: auto;
}
.calc-head { display: flex; align-items: center; justify-content: space-between; font-weight: 800; color: var(--ink); margin-bottom: 10px; }
.calc-close { background: none; border: none; color: var(--ink-soft); cursor: pointer; padding: 4px; display: flex; }
.calc-display {
  background: var(--ivory-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; text-align: right; font-size: 1.6rem; font-weight: 700; color: var(--ink);
  margin-bottom: 10px; overflow-x: auto; white-space: nowrap;
}
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.calc-grid button {
  min-height: 46px; border-radius: 10px; border: 1px solid var(--border); background: var(--ivory-soft);
  color: var(--ink); font-size: 1.05rem; font-weight: 700; cursor: pointer; font-family: inherit;
}
.calc-grid button:active { background: var(--theme-soft); }
.calc-grid button[data-op],
.calc-grid button[data-act="sqrt"],
.calc-grid button[data-act="pow"] { background: var(--theme-soft); color: var(--theme); }
.calc-zero { grid-column: span 2; }
.calc-eq { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }
.calc-combi { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.calc-combi-title { font-weight: 800; font-size: 0.82rem; text-transform: uppercase; letter-spacing: .3px; color: var(--ink-soft); margin-bottom: 8px; }
.calc-combi-row { display: flex; gap: 10px; margin-bottom: 10px; }
.calc-combi-row label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: var(--ink-soft); font-weight: 700; }
.calc-combi-row input {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 1rem;
  font-family: inherit; color: var(--ink); width: 100%;
}
.calc-combi-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.calc-combi-btns button {
  flex: 1; min-height: 40px; border-radius: 999px; border: 1.5px solid var(--theme); background: #fff;
  color: var(--theme); font-weight: 700; cursor: pointer; font-family: inherit;
}
.calc-combi-result { margin-top: 10px; font-weight: 700; color: var(--ink); min-height: 1.2em; word-break: break-word; }

@media (max-width: 360px) {
  .calc-card { padding: 12px; }
  .calc-grid button { min-height: 42px; font-size: 0.98rem; }
}
.progress-bar { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; margin-bottom: 16px; }
.progress-bar-fill { height: 100%; background: var(--theme); transition: width .2s; }

.quiz-card { background: var(--card); border: 1px solid var(--border); border-top: 4px solid var(--theme); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.quiz-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
/* Petit rappel visuel de la marque sur chaque question, en haut à droite —
   demande de l'utilisateur. Le vrai logo du site (`LOGO_KHOUBAIB` dans
   app.js, copie du SVG d'apps/web/components/Header.tsx), pas le monogramme
   « M0 » du topbar de cette appli. Posé comme DERNIER élément de
   `.quiz-card-head` : `justify-content: space-between` le pousse tout à
   droite et décale « Revoir le rappel » vers le centre, sans chevauchement. */
.quiz-card-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px; flex: none; overflow: hidden;
}
.quiz-card-logo svg { width: 100%; height: 100%; display: block; }
.badge { display: inline-block; background: var(--theme-soft); color: var(--theme); border-radius: 999px; padding: 4px 12px; font-size: 0.8rem; font-weight: 700; }

.prompt { font-size: 1.15rem; margin-bottom: 16px; line-height: 1.6; font-weight: 600; }
.katex { color: inherit; }

.choices { display: grid; gap: 10px; }
.choice-btn {
  text-align: left; border: 1.5px solid var(--border); background: var(--ivory-soft); color: var(--ink);
  padding: 12px 16px; border-radius: 12px; font-size: 1rem; font-family: inherit; cursor: pointer; transition: all .12s;
}
.choice-btn:hover:not(:disabled) { border-color: var(--theme); }
.choice-btn:disabled { cursor: default; }
.choice-btn.choice-correct { background: #e3f3e6; border-color: var(--green); color: var(--green); font-weight: 700; }
.choice-btn.choice-wrong { background: #fbe7e5; border-color: var(--red); color: var(--red); }

.feedback { margin-top: 16px; padding: 12px 16px; border-radius: 12px; font-size: 0.98rem; font-weight: 600; }
.feedback.correct { background: #e3f3e6; color: var(--green); }
.feedback.incorrect { background: #fbe7e5; color: var(--red); }
.feedback-expl { margin-top: 6px; font-weight: 500; font-size: 0.9rem; opacity: 0.9; }

.result-summary { text-align: center; }
.result-score { font-size: 2.4rem; font-weight: 800; color: var(--theme); margin: 8px 0; }
.result-table { width: 100%; border-collapse: collapse; margin-top: 16px; text-align: left; }
.result-table th, .result-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.result-table th { color: var(--ink-soft); font-weight: 700; }

@media (max-width: 640px) {
  #app { padding: 18px 12px 44px; }
  .quiz-card, .rappel-card { padding: 16px; }
  .prompt { font-size: 1.05rem; }
}

/* Blocs de code Python (chapitre 4) : <code class="code-block"> dans un
   énoncé (<p class="prompt">) ou un rappel — display:block plutôt qu'un
   <pre>, qui n'a pas le droit d'être enfant d'un <p>. Défilement horizontal
   DANS le bloc, jamais de la page, à 375 px. */
.prompt code, .rappel-body code, .choice-btn code, #feedback code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.92em;
  background: var(--ivory-soft); border-radius: 6px; padding: 1px 5px;
}
code.code-block {
  display: block; white-space: pre; overflow-x: auto; margin: 10px 0; padding: 10px 12px;
  border: 1px solid var(--border); line-height: 1.5; text-align: left; font-weight: 400;
}
.rappel-body code.code-block { white-space: normal; }

/* ── Accueil (2026-10-19) : bandeau + chapitres en accordéon ───────────────
   Page élargie (`body.is-home`, posé par renderBuilder et retiré au lancement
   d'un quiz) : les cartes de question gardent leur largeur de lecture. */
body.is-home #app { max-width: 1120px; padding-bottom: 120px; }

.dn-hero {
  position: relative; overflow: hidden; display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px;
  align-items: center; padding: 40px 44px; border-radius: 22px; color: #fff;
  background:
    radial-gradient(circle at 85% 20%, rgba(255, 106, 19, 0.28), transparent 45%),
    linear-gradient(135deg, #002b5c 0%, #013a78 60%, #0a4d94 100%);
  box-shadow: var(--shadow-lg);
}
.dn-hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .08;
  background-image: radial-gradient(#fff 1px, transparent 1px); background-size: 18px 18px;
}
.dn-hero-text { position: relative; z-index: 1; }
.dn-hero-kicker {
  display: inline-block; font-size: 0.78rem; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  color: var(--accent-light); background: rgba(255,255,255,0.1); padding: 5px 12px; border-radius: 999px;
}
.dn-hero h1 { font-family: "Fraunces", Georgia, serif; font-size: 3rem; line-height: 1.05; margin: 14px 0 12px; }
.dn-hero p { margin: 0; max-width: 560px; line-height: 1.6; opacity: .9; }
.dn-hero-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.dn-hero-stats span {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); border-radius: 12px;
  padding: 8px 14px; font-size: 0.88rem;
}
.dn-hero-stats strong { font-size: 1.15rem; color: var(--accent-light); margin-right: 4px; }
.dn-hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; align-items: center; }
.dn-ghost-btn {
  color: #fff; text-decoration: none; font-weight: 700; padding: 11px 20px; border-radius: 999px;
  border: 1.5px solid rgba(255,255,255,0.5);
}
.dn-ghost-btn:hover { background: rgba(255,255,255,0.12); }
.dn-hero-art { position: relative; z-index: 1; height: 220px; }
.dn-f {
  position: absolute; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.22); border-radius: 18px;
  font-size: 1.6rem; color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.18);
  animation: dn-float 6s ease-in-out infinite;
}
.dn-f1 { width: 110px; height: 90px; top: 8px; left: 12%; font-size: 2.2rem; color: var(--accent-light); }
.dn-f2 { width: 120px; height: 110px; top: 40px; right: 4%; animation-delay: -2s; }
.dn-f3 { width: 96px; height: 80px; bottom: 6px; left: 2%; animation-delay: -4s; }
.dn-f4 { width: 86px; height: 72px; bottom: 18px; left: 46%; animation-delay: -1s; color: var(--accent-light); }
@keyframes dn-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { .dn-f, .ch-body { animation: none; } }

.dn-head { margin-top: 40px; margin-bottom: 14px; scroll-margin-top: 16px; }
.dn-head h2 { font-size: 1.7rem; }
.dn-head p { margin: 4px 0 0; max-width: 720px; line-height: 1.55; }

.ch-list { display: grid; gap: 14px; }
.ch-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow);
  overflow: hidden; transition: box-shadow .15s, border-color .15s;
}
.ch-card:hover { box-shadow: var(--shadow-lg); }
.ch-card.is-open, .ch-card.has-selection { border-color: rgba(0, 43, 92, 0.35); }
.ch-card.has-selection { box-shadow: inset 4px 0 0 var(--accent), var(--shadow); }
.ch-head {
  width: 100%; display: flex; align-items: center; gap: 16px; padding: 20px 22px;
  background: none; border: none; text-align: left; cursor: pointer; font-family: inherit; color: var(--ink);
}
.ch-card--soon .ch-head { cursor: default; opacity: .65; }
.ch-num {
  flex: none; width: 48px; height: 48px; border-radius: 14px; display: inline-flex; align-items: center;
  justify-content: center; font-family: "Fraunces", Georgia, serif; font-size: 1.4rem; font-weight: 700;
  background: var(--theme-soft); color: var(--ink); transition: background .15s, color .15s;
}
.ch-card.is-open .ch-num { background: var(--ink); color: #fff; }
.ch-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ch-title { font-size: 1.12rem; font-weight: 700; line-height: 1.3; }
.ch-meta { font-size: 0.86rem; color: var(--ink-soft); }
.ch-count {
  flex: none; font-size: 0.78rem; font-weight: 800; color: #fff; background: var(--accent);
  padding: 4px 11px; border-radius: 999px; white-space: nowrap;
}
.ch-count[hidden] { display: none; }
.ch-chevron {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; background: var(--ivory-soft); color: var(--ink); transition: transform .2s, background .15s;
}
.ch-head:hover .ch-chevron { background: var(--theme-soft); }
.ch-card.is-open .ch-chevron { transform: rotate(180deg); }
.ch-head:focus-visible, .par-row:focus-visible { outline: 3px solid rgba(255, 106, 19, .5); outline-offset: -3px; }

.ch-body { border-top: 1px solid var(--border); padding: 14px 22px 20px; animation: dn-open .2s ease; }
@keyframes dn-open { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.par-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.par-row {
  width: 100%; height: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--card); cursor: pointer;
  font-family: inherit; color: var(--ink); text-align: left; transition: all .12s;
}
.par-row:hover { border-color: var(--ink); background: var(--ivory-soft); }
.par-box {
  flex: none; width: 22px; height: 22px; border-radius: 7px; border: 2px solid #c3cedb;
  display: inline-flex; align-items: center; justify-content: center; color: transparent; transition: all .12s;
}
.par-box svg { vertical-align: 0 !important; }
.par-num { flex: none; font-size: 0.8rem; font-weight: 800; color: var(--ink-soft); min-width: 26px; }
.par-title { flex: 1; min-width: 0; font-size: 0.94rem; font-weight: 600; line-height: 1.35; }
.par-ex { flex: none; font-size: 0.76rem; font-weight: 700; color: var(--ink-soft); background: var(--ivory-soft); padding: 3px 8px; border-radius: 999px; }
.par-row.is-selected { border-color: var(--accent); background: #fff4ec; }
.par-row.is-selected .par-box { background: var(--accent); border-color: var(--accent); color: #fff; }
.par-row.is-selected .par-ex { background: #fff; }
.ch-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.primary-btn--sm { padding: 10px 18px; font-size: 0.92rem; }

.dn-settings {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px;
  background: var(--ivory-soft); border: 1px solid var(--border); border-radius: 18px; padding: 20px 22px;
}
.dn-setting-label { font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-soft); }

.dn-launchbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100; padding: 12px 16px;
  transform: translateY(110%); transition: transform .25s ease; pointer-events: none;
}
.dn-launchbar.is-visible { transform: none; pointer-events: auto; }
.dn-launchbar-inner {
  max-width: 1120px; margin: 0 auto; display: flex; align-items: center; gap: 16px;
  background: var(--ink); color: #fff; border-radius: 18px; padding: 12px 14px 12px 22px;
  box-shadow: 0 16px 40px rgba(0, 43, 92, 0.35);
}
.dn-launchbar-text { flex: 1; min-width: 0; font-size: 0.95rem; }
.dn-launchbar-text strong { color: var(--accent-light); }
.dn-launchbar .link-btn { color: #fff; opacity: .8; }

@media (max-width: 860px) {
  .dn-hero { grid-template-columns: 1fr; padding: 30px 24px; }
  .dn-hero-art { display: none; }
  .dn-hero h1 { font-size: 2.4rem; }
  .par-list { grid-template-columns: 1fr; }
  .dn-settings { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .dn-hero { padding: 24px 18px; border-radius: 18px; }
  .dn-hero h1 { font-size: 2rem; }
  .dn-hero-actions .primary-btn, .dn-ghost-btn { width: 100%; text-align: center; }
  .ch-head { padding: 16px 14px; gap: 12px; }
  .ch-num { width: 40px; height: 40px; font-size: 1.15rem; border-radius: 12px; }
  .ch-title { font-size: 1rem; }
  .ch-count { display: none; }
  .ch-body { padding: 10px 12px 16px; }
  .ch-actions .primary-btn { width: 100%; }
  .dn-launchbar { padding: 8px; }
  .dn-launchbar-inner { padding: 10px 10px 10px 14px; gap: 10px; }
  .dn-launchbar-text { font-size: 0.82rem; }
  .dn-launchbar .link-btn { display: none; }
  .dn-launchbar .primary-btn { padding: 10px 14px; font-size: 0.9rem; }
}

/* Page CHAPITRE (2026-10-19) : fil d'Ariane vers Terminale Maths et
   intertitres de groupe (Le cours / Par situation / Pour aller plus loin). */
.dn-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 600; margin-bottom: 14px; opacity: .9; }
.dn-crumbs a { color: var(--accent-light); text-decoration: none; }
.dn-crumbs a:hover { text-decoration: underline; }
.dn-groupe { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 26px 0 4px; padding-bottom: 8px; border-bottom: 2px solid var(--border); }
.dn-groupe:first-child { margin-top: 0; }
.dn-groupe-label { font-family: "Fraunces", Georgia, serif; font-size: 1.3rem; font-weight: 700; color: var(--ink); }
.dn-groupe-sub { font-size: 0.88rem; color: var(--ink-soft); }

/* ── Ma progression : jauges + meilleures / moins bonnes notes ───────── */
.gauge-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-top: 16px; align-items: start; }
.gauge-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; text-align: center;
}
.gauge-title { font-weight: 800; color: var(--theme); font-size: 0.95rem; min-height: 2.4em; }
.gauge { width: 100%; max-width: 200px; display: block; margin: 4px auto 0; }
.gauge-zone { fill: none; stroke-width: 16; stroke-linecap: round; }
.gauge-zone.low, .is-low { --c: var(--red); }
.gauge-zone.mid, .is-mid { --c: #f59e0b; }
.gauge-zone.good, .is-good { --c: var(--green); }
.gauge-zone { stroke: var(--c); }
.gauge-needle line { stroke: var(--ink); stroke-width: 5; stroke-linecap: round; }
.gauge-needle { transform-origin: 100px 100px; transform: rotate(0deg); transition: transform 1.1s cubic-bezier(.3, 1.4, .5, 1); }
.gauges-on .gauge-needle { transform: rotate(var(--angle)); }
.gauge-hub { fill: var(--ink); }
.gauge-value { font-weight: 800; font-size: 1.15rem; color: var(--c); margin-top: 2px; }
.gauge-sub { font-size: 0.85rem; margin-top: 4px; }
.pill { display: inline-block; font-weight: 800; color: #fff; background: var(--c); padding: 1px 8px; border-radius: 999px; }
.gauge-general { display: flex; align-items: center; gap: 20px; margin-top: 16px; text-align: left; }
.gauge-general .gauge { flex: 0 0 220px; max-width: 220px; margin: 0; }
.gauge-general .gauge-title { min-height: 0; font-size: 1.15rem; }
.gauge-general .gauge-value { font-size: 1.6rem; }
@media (max-width: 520px) { .gauge-general { flex-direction: column; text-align: center; gap: 4px; } }
.gauge-details { margin-top: 10px; text-align: left; font-size: 0.8rem; }
.gauge-details summary { cursor: pointer; font-weight: 700; color: var(--theme); text-align: center; }
.gauge-details ul { list-style: none; margin: 0; padding: 0; }
.gauge-chap { margin-top: 8px; }
.gauge-chap-title { font-weight: 800; color: var(--ink); padding-bottom: 2px; }
.gauge-row { display: flex; align-items: center; gap: 6px; padding: 3px 0 3px 8px; border-top: 1px solid var(--border); }
.gauge-row-title { flex: 1; min-width: 0; color: var(--ink); }
.gauge-row.is-todo .gauge-row-title { color: var(--ink-soft); }
.gauge-row .pill { font-size: 0.72rem; padding: 0 6px; }
.pill-vide { color: var(--ink-soft); min-width: 2.2em; text-align: center; }

.tests-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.tests-col { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; }
.tests-col ul { list-style: none; margin: 0; padding: 0; }
.tests-head { font-weight: 800; font-size: 0.82rem; text-transform: uppercase; letter-spacing: .4px; color: var(--c); margin-bottom: 6px; }
.tests-head.good { --c: var(--green); }
.tests-head.low { --c: var(--red); }
.test-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); }
.test-row:first-child { border-top: none; }
.test-note { flex: none; width: 54px; text-align: center; font-weight: 800; color: #fff; background: var(--c); border-radius: 10px; padding: 6px 0; }
.test-info { font-size: 0.88rem; line-height: 1.35; }

.dn-hello { font-family: "Fraunces", Georgia, serif; font-size: 1.35rem; font-weight: 600; margin: 0 0 10px !important; opacity: 1 !important; color: #fff; }
.sch-carte { min-width: 0; padding: 0 3px; font-size: 0.72rem; letter-spacing: -0.3px; }
@media (max-width: 420px) {
  .sch-c { min-width: 22px; height: 24px; }
  .sch-carte { font-size: 0.62rem; padding: 0 1px; }
  .sch-case { min-width: 26px; height: 30px; padding: 0 4px; font-size: 0.76rem; }
}
.sch-row > .sch-slot { margin: 0 2px; }
@media (max-width: 420px) {
  .sch-row { gap: 2px; padding: 0 2px 3px; }
  .sch-row > .sch-slot { margin: 0 1px; }
  .sch { padding: 12px 6px 10px; }
}

/* Illustration d'un énoncé (Fiche D : boulangerie, tables, sondage, cadenas,
   hélicoptère) — SVG en tête de .prompt, centré, sur sa propre ligne. */
.ex-illus { display: block; width: 168px; max-width: 60%; margin: 0 auto 12px; padding: 8px 10px;
  background: #fff8ef; border: 1px solid #f2dcc2; border-radius: 14px; }
.ex-illus svg { display: block; width: 100%; height: auto; }
@media (max-width: 420px) { .ex-illus { width: 140px; } }

/* ── Algèbre 3 / Analyse 3 : encadrés des rappels (Méthode, Étape, Attention…) ── */
.rappel-body p.rbox { margin: 12px 0; padding: 10px 14px; border-radius: 10px; border-left: 4px solid; line-height: 1.6; }
.rbox-methode { background: #fff7ed; border-color: #d4a017; }
.rbox-methode strong:first-child { color: #92400e; }
.rbox-etape { background: #eef5fc; border-color: #0073cf; }
.rbox-etape strong:first-child { color: #0059a3; }
.rbox-attention { background: #fdecec; border-color: var(--red); }
.rbox-attention strong:first-child { color: var(--red); }
.rbox-retenir { background: #ecfdf3; border-color: var(--green); }
.rbox-retenir strong:first-child { color: #15803d; }
.rbox-demo { background: #f4f6f9; border-color: #94a3b8; }
.rbox-exemple { background: #f5f3ff; border-color: #7c3aed; }
.rbox-exemple strong:first-child { color: #6d28d9; }

/* ── Correction pas à pas : une étape par ligne, dévoilées une à une ── */
.feedback-expl.steps { opacity: 1; margin-top: 10px; background: #fff; color: var(--ink); border-radius: 10px; padding: 10px 12px; }
.step-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.step { display: flex; gap: 10px; align-items: baseline; line-height: 1.55; animation: step-in .25s ease; }
.step[hidden] { display: none; }
.step-num { flex: none; font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .3px; color: #fff; background: var(--blue); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.step-text { min-width: 0; overflow-wrap: anywhere; }
.step-ctrl { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.step-next { background: var(--ink); color: #fff; border: none; border-radius: 999px; padding: 7px 14px; font-weight: 700; font-size: 0.85rem; cursor: pointer; }
.step-next:hover { background: #0b3f7a; }
@keyframes step-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

/* Matrices de permutation (deux lignes) : défilement horizontal interne
   plutôt qu'un débordement de carte à 375 px. */
.prompt .katex-display, .rappel-body .katex-display, .choice-btn .katex-display { overflow-x: auto; overflow-y: hidden; }
.choice-btn .katex, .prompt .katex { max-width: 100%; }

/* Schémas SVG des rappels (permutation fléchée, cycle en rond). */
.a3-sch { display: block; margin: 8px auto; text-align: center; }
.a3-sch svg { max-width: 100%; height: auto; }
.a3-sch .cap { display: block; font-size: 0.82rem; color: var(--ink-soft); margin-top: 2px; }

/* ── Réponses tapées (questions « saisie », propres à Complexes) ── */
.saisie { margin-top: 14px; display: grid; gap: 10px; }
.saisie-aide { margin: 0; font-size: 0.86rem; color: var(--ink-soft); line-height: 1.5; }
.saisie-aide code { background: var(--ivory-soft); border: 1px solid var(--border); border-radius: 6px; padding: 0 5px; font-size: 0.85em; color: var(--ink); }
.saisie-champ { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 10px; }
.saisie-label { font-weight: 700; white-space: nowrap; }
.saisie-input {
  width: 100%; min-width: 0; font: inherit; font-size: 1.05rem; padding: 10px 12px;
  border: 2px solid var(--border); border-radius: 10px; background: #fff; color: var(--ink);
}
.saisie-input:focus { outline: none; border-color: var(--theme); box-shadow: 0 0 0 3px var(--theme-soft); }
.saisie-input.is-invalid { border-color: var(--accent); }
.saisie-input.is-correct { border-color: var(--green); background: #e3f3e6; color: var(--green); font-weight: 600; }
.saisie-input.is-wrong { border-color: var(--red); background: #fbe7e5; color: var(--red); }
.saisie-input:disabled { opacity: 1; }
.saisie-apercu { grid-column: 2; min-height: 1.4em; font-size: 0.98rem; color: var(--ink); overflow-x: auto; overflow-y: hidden; max-width: 100%; }
.saisie-apercu-err { font-size: 0.82rem; color: var(--accent-600); }
.saisie-touches { display: flex; flex-wrap: wrap; gap: 6px; }
.saisie-touche {
  min-width: 44px; min-height: 38px; padding: 6px 10px; font: inherit; font-weight: 700;
  border: 1px solid var(--border); border-radius: 9px; background: var(--ivory-soft); color: var(--ink); cursor: pointer;
}
.saisie-touche:hover:not(:disabled) { border-color: var(--theme); }
.saisie-touche:disabled { opacity: 0.5; cursor: default; }
.saisie-erreur { min-height: 0; font-size: 0.9rem; font-weight: 600; color: var(--accent-600); }
.saisie-erreur:empty { display: none; }
#validerBtn { justify-self: start; }
.feedback-attendu { margin-top: 8px; font-weight: 600; color: var(--ink); }
@media (max-width: 420px) {
  .saisie-champ { grid-template-columns: minmax(0, 1fr); }
  .saisie-apercu { grid-column: 1; }
}
/* Formules du bandeau : jamais coupées sur deux lignes (« i² = −1 »). */
.dn-hero-art .dn-f { white-space: nowrap; }
