/* app/css/style.css — Révision CAPET SII·IE
   Direction : Minimalism & Swiss Style, sombre par défaut, palette terre
   cuite et bois. Grille nette, hiérarchie typographique forte, une seule
   couleur d'accent.
   Aucune dépendance, aucune police à télécharger : San Francisco sur iPhone
   via -apple-system, dont le rendu optique à petite taille est inégalé. */

/* ─── Jetons ─────────────────────────────────────────────────────────────
   Sombre par défaut : la révision se fait le soir et dans les transports.
   Le thème clair est une surcharge explicite, pas l'inverse.              */
:root {
  /* Surfaces — trois niveaux seulement, pour que la hiérarchie reste lisible.
     Bruns chauds : le bois sombre d'un bureau le soir, pas le bleu d'un écran. */
  --bg: #171210;
  --surface: #231b17;
  --surface-haut: #2e2420;

  /* Encres — 4.5:1 minimum sur --surface pour le texte courant */
  --ink: #f4ece3;
  --ink-doux: #cdbcae;
  --ink-faible: #a89686;   /* 5.94:1 sur --surface — seuil texte 4.5 */

  --rule: #3b2f29;
  --rule-fort: #4a3b31;

  /* Accent unique : terre cuite. 6.7:1 sur --surface, lisible en texte. */
  --accent: #e0906a;
  --accent-sourd: #4a2a1e;
  --sur-accent: #1f120b;

  /* Sémantique de notation — jamais la couleur seule, toujours un libellé.
     Sauge, ocre, brique : la même famille chaude que l'accent. */
  --su: #a6c98b;
  --hesite: #e4b85e;
  --rate: #f0867d;
  --su-fond: #233121;
  --hesite-fond: #36290f;
  --rate-fond: #3c1f1d;

  /* Consommé par les SVG de schémas (voir scripts/build_svg.py) */
  --svg-bg: #231b17;

  /* Rythme 4/8 — une seule échelle, pas d'exception */
  --e1: 4px;  --e2: 8px;  --e3: 12px; --e4: 16px;
  --e5: 24px; --e6: 32px; --e7: 48px;

  --rayon: 14px;
  --rayon-sm: 10px;

  /* Hauteurs des barres fixes : partagées par le corps, les commandes
     collantes et le toast, pour que rien ne se recouvre */
  --h-haut: 61px;
  --h-bas: 52px;

  /* Une seule courbe, deux durées : entrée calme, sortie rapide */
  --t-rapide: 140ms;
  --t-normal: 220ms;
  --courbe: cubic-bezier(0.32, 0.72, 0, 1);

  color-scheme: dark;
}

:root[data-theme="clair"] {
  /* Papier crème et terre : chaud sans virer au jaune */
  --bg: #f4ede3;
  --surface: #fffaf3;
  --surface-haut: #efe5d8;

  --ink: #2a201b;
  --ink-doux: #5c4c42;
  --ink-faible: #75635a;   /* 5.48:1 sur --surface */

  --rule: #e1d4c5;
  --rule-fort: #d2c2b0;

  --accent: #a5472a;
  --accent-sourd: #f4dacc;
  --sur-accent: #fff8f2;

  --su: #4b7536;
  --hesite: #8f5c0c;
  --rate: #ad2e36;
  --su-fond: #e8f0df;
  --hesite-fond: #f7e9cf;
  --rate-fond: #f7dfdb;

  --svg-bg: #fffaf3;

  color-scheme: light;
}

/* ─── Base ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text",
        system-ui, "Segoe UI", sans-serif;
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(var(--h-bas) + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

/* Le focus clavier reste toujours visible — jamais d'outline:none nu */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--rayon-sm);
}

/* ─── En-tête ──────────────────────────────────────────────────────────── */
.barre-haut {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--e3);
  padding: var(--e2) var(--e4);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: env(safe-area-inset-top);
  z-index: 20;
}

.marque {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-doux);
}

#bascule-theme {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-doux);
  cursor: pointer;
  transition: background var(--t-rapide) var(--courbe),
              color var(--t-rapide) var(--courbe);
}
#bascule-theme:active { background: var(--surface-haut); color: var(--ink); }
#bascule-theme svg { width: 21px; height: 21px; }

/* ─── Conteneur ────────────────────────────────────────────────────────── */
/* Colonne flexible : les commandes (#commandes, margin-top:auto) descendent
   au bas de l'écran quand la carte est courte, et restent collées au-dessus
   de la navigation quand elle est longue. Le pouce les trouve toujours au
   même endroit. */
main {
  display: flex;
  flex-direction: column;
  padding: var(--e4) var(--e4) var(--e4);
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  min-height: calc(100dvh - var(--h-haut) - var(--h-bas)
                   - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
main > .carte { flex: 0 0 auto; }

/* ─── Repères du jour ──────────────────────────────────────────────────── */
.reperes {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--e1) 0;
  margin: 0 0 var(--e3);
  font-size: 13px;
  color: var(--ink-faible);
  font-variant-numeric: tabular-nums;
}
.reperes strong { color: var(--ink-doux); font-weight: 600; }
.repere + .repere::before { content: "·"; margin: 0 var(--e2); color: var(--rule-fort); }
.repere.proche strong { color: var(--hesite); }
a.repere { color: var(--accent); text-decoration: none; font-weight: 500; }

/* Filtre courant (thème ou révision libre) et sa sortie */
.filtre-theme {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--e3);
  margin: 0 0 var(--e3);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.filtre-theme span { flex: 1; min-width: 0; text-wrap: pretty; }
.filtre-theme a {
  flex: 0 0 auto;
  color: var(--ink-doux);
  text-decoration: none;
  font-weight: 500;
  padding: var(--e2) var(--e3);
  margin: calc(-1 * var(--e2)) calc(-1 * var(--e3)) calc(-1 * var(--e2)) 0;
  border-radius: 999px;
}
.filtre-theme a:active { background: var(--surface-haut); }

/* ─── Barre de progression de session ──────────────────────────────────── */
.jauge {
  height: 3px;
  background: var(--rule);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: var(--e3);
}
.jauge > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width var(--t-normal) var(--courbe);
}

.progression-file {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--ink-faible);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  margin: 0 0 var(--e3);
}
.progression-file .reprise { color: var(--hesite); }

/* ─── Carte ────────────────────────────────────────────────────────────── */
.carte {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--rayon);
  padding: var(--e5) var(--e4);
  margin-bottom: var(--e3);
  animation: entree var(--t-normal) var(--courbe) both;
}

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

.recto { cursor: pointer; }

/* Après révélation, le recto se fait rappel : plus de cadre, question en
   corps courant, indices retirés. La carte de réponse devient le sujet. */
.recto.estompe {
  cursor: default;
  background: transparent;
  border-color: transparent;
  padding: 0 var(--e2) var(--e2);
  margin-bottom: var(--e2);
  animation: none;
}
.recto.estompe .vedette,
.recto.estompe .enonce-schema {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink-doux);
  letter-spacing: 0;
}
.recto.estompe .enonce { font-size: 15px; }
.recto.estompe .en-jeu,
.recto.estompe .indice,
.recto.estompe .freq,
.recto.estompe .cadre { display: none; }

.carte.verso { border-color: color-mix(in srgb, var(--accent) 45%, var(--rule)); }
/* Le défilement vers la réponse tient compte des commandes collantes */
#verso { scroll-margin-bottom: 140px; }
.verso .katex-display { font-size: 1.4em; margin: var(--e2) 0; }
.verso .regle { font-size: 18px; line-height: 1.5; }
.verso .formule-mixte { font-size: 18px; }

/* Le contexte situe la carte : code et titre du theme, en tete de recto.
   Sans lui, 45 labels partages posent exactement la meme question. */
.contexte {
  margin: 0 0 var(--e3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  text-wrap: pretty;
}

/* Le cadre d'application : regime, hypotheses. Vient des fiches. */
.cadre {
  margin: var(--e3) 0 0;
  font-size: 14px;
  color: var(--ink-doux);
  font-style: italic;
  text-wrap: pretty;
}

/* Les grandeurs en jeu : des symboles, pas une phrase. Alignes en ligne,
   separes visuellement, ils cadrent la reponse sans la livrer. */
.en-jeu {
  margin: var(--e4) 0 0;
  font-size: 14px;
  color: var(--ink-faible);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--e2);
}
.en-jeu .katex {
  font-size: 1em;
  color: var(--ink-doux);
  background: var(--surface-haut);
  padding: 2px var(--e2);
  border-radius: 6px;
}

/* La frequence au concours : discrete, en bas de carte */
.freq {
  margin: var(--e3) 0 0;
  font-size: 12px;
  color: var(--ink-faible);
  font-variant-numeric: tabular-nums;
}

/* L'indice d'unites cadre la reponse sans la donner */
.indice {
  margin: var(--e3) 0 0;
  padding-top: var(--e3);
  border-top: 1px solid var(--rule);
  font-size: 14px;
  color: var(--ink-faible);
}

/* Formule mixte : du texte francais entrecoupe de segments math.
   Alignee a gauche comme une phrase, pas centree comme une equation. */
.formule-mixte {
  margin: 0;
  font-size: 17px;
  line-height: 1.6;
  text-wrap: pretty;
}

/* La consigne oriente sans prendre la vedette */
.consigne {
  color: var(--ink-faible);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 var(--e3);
}

/* L'énoncé porte la question : c'est le seul élément en gros corps */
.vedette {
  font-size: 22px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}

/* L'enonce du piege est cite : on le detache comme une citation, pour
   qu'il soit clair que c'est le propos a critiquer, pas une affirmation. */
.enonce {
  margin: 0 0 var(--e4);
  padding: var(--e3);
  background: var(--surface-haut);
  border-radius: var(--rayon-sm);
  font-size: 16px;
  line-height: 1.5;
  text-wrap: pretty;
}
/* La seconde consigne (la question posee) ferme la carte, sans marge basse */
.carte .consigne:last-child { margin-bottom: 0; }

.titre-piege {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 var(--e2);
}

/* Le verso : la réponse est mise en valeur par un liseré, pas par une couleur de fond */
.regle {
  margin: 0;
  font-size: 17px;
  border-left: 3px solid var(--accent);
  padding-left: var(--e3);
}

.vedette + .regle { margin-top: var(--e3); }

.conditions {
  margin: var(--e3) 0 0;
  padding: var(--e3);
  background: var(--surface-haut);
  border-radius: var(--rayon-sm);
  font-size: 15px;
}
.conditions strong { color: var(--accent); }

.unites {
  margin: var(--e3) 0 0;
  color: var(--ink-doux);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.erreur-type {
  margin: var(--e3) 0 0;
  color: var(--ink-faible);
  font-size: 14px;
  font-style: italic;
}

.carte-svg {
  text-align: center;
  margin: var(--e4) 0;
  padding: var(--e4);
  background: var(--svg-bg);
  border-radius: var(--rayon-sm);
  border: 1px solid var(--rule);
}
.carte-svg img { max-width: 100%; height: auto; }
/* SVG inline : les traits suivent l'encre du thème courant (currentColor),
   pas le réglage du système. Largeur fluide, plafonnée à la taille naturelle
   par hydraterSchemas ; hauteur déduite du viewBox. */
.carte-svg svg {
  display: block;
  margin: 0 auto;
  width: 100%;
  height: auto;
  color: var(--ink);
  overflow: visible;
}

/* La question d'un schéma : sous l'image, en corps de lecture, pas en
   capitales de consigne — c'est un énoncé, souvent long. */
.enonce-schema {
  margin: 0;
  font-size: 17px;
  line-height: 1.45;
  font-weight: 500;
  text-wrap: pretty;
}

.latex-brut {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, monospace;
  font-size: 14px;
  word-break: break-word;
  color: var(--ink-doux);
}

/* KaTeX : empêcher une formule large de faire déborder la page */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: var(--e1) 0;
}
.katex { font-size: 1.05em; }

/* ─── Commandes ────────────────────────────────────────────────────────── */
#commandes {
  margin-top: auto;
  padding-top: var(--e4);
  position: sticky;
  bottom: calc(var(--h-bas) + env(safe-area-inset-bottom));
  z-index: 10;
  display: grid;
  gap: var(--e2);
  /* Le contenu qui défile dessous s'efface dans le fond, sans bord dur */
  background: linear-gradient(to top, var(--bg) 0, var(--bg) calc(100% - var(--e4)), transparent);
}
#commandes:empty { display: none; }

.bouton-secondaire {
  width: 100%;
  min-height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule-fort);
  border-radius: var(--rayon-sm);
  background: var(--surface);
  color: var(--ink);
  font: 600 16px/1.1 inherit;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--t-rapide) var(--courbe),
              background var(--t-rapide) var(--courbe);
}
.bouton-secondaire:active { transform: scale(0.985); background: var(--surface-haut); }
.pile-boutons { display: grid; gap: var(--e2); }
label.bouton-secondaire:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.revelateur {
  width: 100%;
  min-height: 52px;
  display: grid;
  place-items: center;
  text-decoration: none;
  border: 0;
  border-radius: var(--rayon-sm);
  background: var(--accent);
  color: var(--sur-accent);
  font: 600 17px/1 inherit;
  font-family: inherit;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform var(--t-rapide) var(--courbe),
              filter var(--t-rapide) var(--courbe);
}
.revelateur:active { transform: scale(0.985); filter: brightness(0.92); }

.actions { display: flex; gap: var(--e2); }

.actions button {
  flex: 1;
  min-height: 52px;
  border-radius: var(--rayon-sm);
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  font: 600 15px/1.1 inherit;
  font-family: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  gap: 2px;
  transition: transform var(--t-rapide) var(--courbe),
              background var(--t-rapide) var(--courbe);
}
.actions button:active { transform: scale(0.97); }
.actions button .touche {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-faible);
  letter-spacing: 0.04em;
}

.b-su     { border-color: var(--su);     color: var(--su); }
.b-hesite { border-color: var(--hesite); color: var(--hesite); }
.b-rate   { border-color: var(--rate);   color: var(--rate); }
.b-su:active     { background: var(--su-fond); }
.b-hesite:active { background: var(--hesite-fond); }
.b-rate:active   { background: var(--rate-fond); }

/* ─── Toast : la dernière note, annulable ──────────────────────────────── */
.toast {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--e3);
  padding: var(--e2) var(--e2) var(--e2) var(--e4);
  background: var(--surface-haut);
  border: 1px solid var(--rule-fort);
  border-radius: var(--rayon-sm);
  font-size: 15px;
  color: var(--ink-doux);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--t-normal) var(--courbe), transform var(--t-normal) var(--courbe);
}
.toast.visible { opacity: 1; transform: none; }
.toast[data-note="su"] strong     { color: var(--su); }
.toast[data-note="hesite"] strong { color: var(--hesite); }
.toast[data-note="rate"] strong   { color: var(--rate); }
.toast button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 var(--e3);
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font: 600 15px/1 inherit;
  font-family: inherit;
  cursor: pointer;
}
.toast button:active { background: var(--accent-sourd); }

/* ─── Fin de session et statistiques ───────────────────────────────────── */
.bilan {
  list-style: none;
  margin: var(--e4) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--e2);
}
.bilan li {
  display: grid;
  gap: 2px;
  padding: var(--e3) var(--e2);
  border-radius: var(--rayon-sm);
  background: var(--surface-haut);
  text-align: center;
}
.bilan strong { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.bilan span { font-size: 12px; color: var(--ink-faible); }
.bilan .su     { background: var(--su-fond); }     .bilan .su strong     { color: var(--su); }
.bilan .hesite { background: var(--hesite-fond); } .bilan .hesite strong { color: var(--hesite); }
.bilan .rate   { background: var(--rate-fond); }   .bilan .rate strong   { color: var(--rate); }
.bilan + .texte-doux { margin-top: var(--e4); margin-bottom: 0; }

/* ─── Qualité de l'auto-évaluation ─────────────────────────────────────── */
/* Ce que « su » engageait : relation, unités, conditions. Discret, en fin
   de verso, juste avant les boutons de notation. */
.criteres {
  margin: var(--e3) 0 0;
  padding-top: var(--e3);
  border-top: 1px dashed var(--rule);
  font-size: 13px;
  color: var(--ink-faible);
  text-wrap: pretty;
}

/* Développement d'un point de vigilance, sous la règle */
.complement {
  margin: var(--e3) 0 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-doux);
  text-wrap: pretty;
}

/* Carte récalcitrante : le verso renvoie à la source */
.badge-difficile {
  margin: 0 0 var(--e3);
  padding: var(--e2) var(--e3);
  border-radius: var(--rayon-sm);
  background: var(--hesite-fond);
  color: var(--hesite);
  font-size: 14px;
  font-weight: 600;
}

.lien-difficiles {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--e2);
  margin: calc(-1 * var(--e3)) 0 var(--e4);
  padding: var(--e3);
  border-radius: var(--rayon-sm);
  background: var(--hesite-fond);
  color: var(--hesite);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}
.lien-difficiles svg { width: 18px; height: 18px; flex: 0 0 auto; }
.ligne-theme .meta em { font-style: normal; color: var(--hesite); }

/* ─── Alerte ───────────────────────────────────────────────────────────── */
.alerte-stockage {
  border-color: var(--rate);
  background: var(--rate-fond);
}
.alerte-stockage .consigne {
  color: var(--rate);
  text-transform: none;
  letter-spacing: 0;
  font-size: 15px;
  display: flex;
  align-items: flex-start;
  gap: var(--e2);
  margin: 0;
}
.alerte-stockage svg { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 1px; }

/* ─── Barre de navigation ──────────────────────────────────────────────── */
.barre-bas {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}

.barre-bas a {
  flex: 1;
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 52px;
  padding: var(--e2) 2px;
  text-decoration: none;
  color: var(--ink-faible);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color var(--t-rapide) var(--courbe);
}
.barre-bas a svg { width: 23px; height: 23px; }
.barre-bas a.actif { color: var(--accent); }
.barre-bas a:active { color: var(--ink-doux); }

/* ─── Liste des priorités ──────────────────────────────────────────────── */
.carte-liste { padding-bottom: var(--e2); }

.liste-themes {
  list-style: none;
  margin: 0 calc(-1 * var(--e2));
  padding: 0;
}
.liste-themes li + li .ligne-theme { border-top: 1px solid var(--rule); }

/* Chaque ligne est un lien plein : la zone de toucher est la ligne entière */
.ligne-theme {
  display: grid;
  grid-template-columns: 8px 1fr auto 16px;
  align-items: center;
  gap: var(--e3);
  min-height: 60px;
  padding: var(--e3) var(--e2);
  color: inherit;
  text-decoration: none;
  border-radius: var(--rayon-sm);
  transition: background var(--t-rapide) var(--courbe);
}
.ligne-theme:active { background: var(--surface-haut); }
.ligne-theme .corps { min-width: 0; display: grid; gap: 2px; }
.ligne-theme .theme {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  text-wrap: pretty;
}
.ligne-theme .meta {
  font-size: 12px;
  color: var(--ink-faible);
  font-variant-numeric: tabular-nums;
}
.ligne-theme .meta strong { color: var(--hesite); font-weight: 600; }
.ligne-theme .maitrise {
  display: grid;
  justify-items: end;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.ligne-theme .pct { font-size: 15px; font-weight: 600; white-space: nowrap; }
.ligne-theme .pct.neutre { color: var(--ink-faible); font-weight: 500; }
.barre-maitrise {
  display: block;
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: var(--rule);
  overflow: hidden;
}
.barre-maitrise > i { display: block; height: 100%; background: var(--su); border-radius: inherit; }
.ligne-theme .chevron { width: 16px; height: 16px; color: var(--ink-faible); }

.sous-titre {
  margin: var(--e2) 0 var(--e5);
  color: var(--ink-doux);
  font-size: 15px;
  line-height: 1.45;
}

/* Visible des lecteurs d'écran, invisible à l'œil — pour les intitulés
   que la mise en page rend redondants mais que la structure exige. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* La pastille double la couleur d'un libellé : jamais la couleur seule */
.pastille {
  display: block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--rule-fort);
}
.pastille.n-rate   { background: var(--rate); }
.pastille.n-hesite { background: var(--hesite); }
.pastille.n-su     { background: var(--su); }
.pastille.n-neutre { background: var(--rule-fort); }

/* Texte courant secondaire : casse normale, jamais en capitales */
.texte-doux {
  margin: 0 0 var(--e3);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink-doux);
  text-wrap: pretty;
}
.texte-doux:last-child { margin-bottom: 0; }
.carte .vedette + .texte-doux { margin-top: var(--e2); }

/* ─── Catégories ───────────────────────────────────────────────────────── */
/* Contrôle segmenté : un seul type de carte à la fois */
.segments {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 3px;
  margin-top: var(--e4);
  background: var(--surface-haut);
  border-radius: var(--rayon-sm);
}
.segment {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-doux);
  font: 600 13px/1 inherit;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--t-rapide) var(--courbe), color var(--t-rapide) var(--courbe);
}
.segment.actif { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(40, 24, 16, 0.25); }

/* Génie : un en-tête de section, lui-même point de départ d'une session */
.genie { margin-top: var(--e5); }
.tete-genie {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--e3);
  padding: 0 var(--e1) var(--e3);
  color: inherit;
  text-decoration: none;
}
.tete-genie .corps { display: grid; gap: 2px; min-width: 0; }
.tete-genie .consigne { margin: 0; color: var(--accent); }
.tete-genie .meta { font-size: 13px; color: var(--ink-faible); line-height: 1.35; text-wrap: pretty; }
.tete-genie .chiffres { color: var(--ink-doux); font-variant-numeric: tabular-nums; }
.tete-genie .chiffres strong { color: var(--hesite); font-weight: 600; }
.tete-genie .action {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 36px;
  padding: 0 var(--e2) 0 var(--e3);
  border: 1px solid var(--rule-fort);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}
.tete-genie:active .action { background: var(--surface-haut); }
.tete-genie .action svg { width: 16px; height: 16px; }

.categorie { padding-top: var(--e3); padding-bottom: var(--e3); }
.tete-categorie {
  display: grid;
  grid-template-columns: 1fr 18px;
  align-items: center;
  gap: var(--e3);
  min-height: 48px;
  color: inherit;
  text-decoration: none;
}
.tete-categorie:active .vedette-cat { color: var(--accent); }
.tete-categorie .corps { display: grid; gap: 2px; min-width: 0; }
.vedette-cat {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.tete-categorie .meta { font-size: 13px; color: var(--ink-faible); font-variant-numeric: tabular-nums; }
.tete-categorie .meta strong { color: var(--hesite); font-weight: 600; }
.tete-categorie .chevron { width: 18px; height: 18px; color: var(--ink-faible); }

/* Thèmes de la catégorie : des puces cliquables, le code en évidence */
.chips { display: flex; flex-wrap: wrap; gap: var(--e2); margin-top: var(--e3); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 36px;
  padding: 6px var(--e3) 6px var(--e2);
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface-haut);
  color: var(--ink-doux);
  font-size: 13px;
  line-height: 1.25;
  text-decoration: none;
  text-wrap: pretty;
}
.chip:active { border-color: var(--accent); color: var(--ink); }
.chip-code { font-weight: 700; color: var(--accent); letter-spacing: 0.02em; }
.chip b {
  margin-left: 2px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--hesite-fond);
  color: var(--hesite);
  font-size: 12px;
}

/* ─── Extraits d'épreuves ──────────────────────────────────────────────── */
.etiquette-sujet {
  display: inline-block;
  margin: 0 0 var(--e3);
  padding: 3px var(--e2);
  border-radius: 999px;
  background: var(--accent-sourd);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.systeme {
  margin: var(--e1) 0 0;
  font-size: 14px;
  color: var(--ink-doux);
  font-style: italic;
}
.donnees {
  margin: var(--e3) 0 0;
  padding: var(--e2) var(--e3) var(--e2) var(--e5);
  background: var(--surface-haut);
  border-radius: var(--rayon-sm);
  font-size: 14px;
  line-height: 1.5;
}
.donnees li { margin: 2px 0; text-wrap: pretty; }
.schema-exo svg { max-width: 100%; }
.schema-exo { position: relative; }
.schema-exo::after {
  content: "";
  position: absolute;
  right: 8px; bottom: 8px;
  width: 14px; height: 14px;
  border: 1.5px solid var(--ink-faible);
  border-radius: 3px;
  opacity: 0.7;
  mask: linear-gradient(135deg, #000 0 35%, transparent 35% 65%, #000 65%);
  -webkit-mask: linear-gradient(135deg, #000 0 35%, transparent 35% 65%, #000 65%);
}
/* Après révélation, le recto d'un exercice garde ses données et son schéma :
   le corrigé y renvoie sans cesse. */
.recto.estompe .donnees { display: block; font-size: 13px; }
.recto.estompe .etiquette-sujet { display: none; }
.recto.estompe .systeme { display: none; }
.reponse-exo p {
  margin: 0 0 var(--e3);
  font-size: 16px;
  line-height: 1.55;
  text-wrap: pretty;
}
.reponse-exo p:last-child { margin-bottom: 0; }
.reponse-exo .katex-display { font-size: 1em; }
.verso .reponse-exo .katex-display { font-size: 1.05em; }
.attendus {
  margin: 0;
  padding: var(--e2) var(--e3) var(--e2) var(--e5);
  background: var(--surface-haut);
  border-radius: var(--rayon-sm);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-doux);
}
.attendus li { margin: 2px 0; }
.verso .consigne { margin-top: var(--e3); }
.verso .consigne:first-child { margin-top: 0; }
.avertissement {
  margin: var(--e3) 0 0;
  padding: var(--e2) var(--e3);
  border-left: 3px solid var(--hesite);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-doux);
  text-wrap: pretty;
}
.avertissement:empty { display: none; }

/* Liste des extraits, par session */
.tete-session {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--e3);
  padding: 0 var(--e2) var(--e2);
  color: inherit;
  text-decoration: none;
}
.tete-session .corps { display: grid; gap: 2px; min-width: 0; }
.tete-session .meta { font-size: 13px; color: var(--ink-faible); font-variant-numeric: tabular-nums; }
.tete-session .action {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 36px;
  padding: 0 var(--e2) 0 var(--e3);
  border: 1px solid var(--rule-fort);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.tete-session .action svg { width: 16px; height: 16px; }
.ligne-sujet {
  display: grid;
  grid-template-columns: 1fr auto 16px;
  align-items: center;
  gap: var(--e3);
  min-height: 56px;
  padding: var(--e3) var(--e2);
  color: inherit;
  text-decoration: none;
  border-radius: var(--rayon-sm);
}
.ligne-sujet:active { background: var(--surface-haut); }
.ligne-sujet .corps { min-width: 0; display: grid; gap: 2px; }
.ligne-sujet .theme { font-size: 15px; font-weight: 500; line-height: 1.3; text-wrap: pretty; }
.ligne-sujet .meta { font-size: 12px; color: var(--ink-faible); text-wrap: pretty; }
.ligne-sujet .chevron { width: 16px; height: 16px; color: var(--ink-faible); }
.etat {
  padding: 2px var(--e2);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-haut);
  color: var(--ink-faible);
}
.etat.su { background: var(--su-fond); color: var(--su); }
.etat.hesite { background: var(--hesite-fond); color: var(--hesite); }
.etat.rate { background: var(--rate-fond); color: var(--rate); }

/* Schéma en plein écran : fond opaque, le pincement natif fait le zoom */
.plein-ecran {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + var(--e3)) var(--e4) calc(env(safe-area-inset-bottom) + var(--e4));
  touch-action: pinch-zoom;
  overscroll-behavior: contain;
  overflow: hidden;
}
.plein-ecran .fermer {
  justify-self: end;
  width: 44px; height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-haut);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.plein-ecran .fermer svg { width: 22px; height: 22px; }
.plein-ecran .cadre {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: var(--e3);
  background: var(--svg-bg);
  border: 1px solid var(--rule);
  border-radius: var(--rayon);
  color: var(--ink);
}
.plein-ecran .cadre svg { width: 100%; height: auto; max-height: 100%; overflow: visible; }
/* Une figure du texte, agrandie, s'ajuste à l'écran entier sans être rognée */
.plein-ecran .cadre img { display: block; width: 100%; height: auto; max-height: 100%; object-fit: contain; }
.plein-ecran .aide { margin: var(--e3) 0 0; text-align: center; font-size: 13px; color: var(--ink-faible); }

/* ─── Réglages ─────────────────────────────────────────────────────────── */
section.carte h2.consigne { margin-bottom: var(--e2); }
.stats { margin-top: var(--e3); }

.champ {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0 var(--e3);
  background: var(--surface-haut);
  color: var(--ink);
  border: 1px solid var(--rule-fort);
  border-radius: var(--rayon-sm);
  font: 400 17px/1.3 inherit;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.champ:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[type="date"].champ::-webkit-date-and-time-value { text-align: left; }

#zone {
  display: block;
  width: 100%;
  margin-top: var(--e3);
  padding: var(--e3);
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--rayon-sm);
  font: 400 13px/1.45 ui-monospace, "SF Mono", SFMono-Regular, monospace;
  resize: vertical;
}

.message {
  margin: var(--e3) 0 0;
  min-height: 1.4em;
  font-size: 14px;
  line-height: 1.4;
  color: var(--accent);
}
.message:empty { margin: 0; min-height: 0; }
.message.erreur { color: var(--rate); }

/* La zone sensible ne crie pas : un cadre discret, un bouton texte rouge.
   Le poids visuel d'une action doit suivre sa fréquence, pas sa gravité. */
.carte-danger { border-style: dashed; }
.bouton-danger {
  width: 100%;
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: var(--rayon-sm);
  background: transparent;
  color: var(--rate);
  font: 600 15px/1.1 inherit;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--t-rapide) var(--courbe),
              border-color var(--t-rapide) var(--courbe);
}
.bouton-danger:active, .bouton-danger.arme { background: var(--rate-fond); border-color: var(--rate); }

/* ─── Mouvement réduit ─────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─── Écrans étroits ───────────────────────────────────────────────────── */
@media (max-width: 380px) {
  body { font-size: 16px; }
  .vedette { font-size: 20px; }
  main { padding-left: var(--e3); padding-right: var(--e3); }
  .actions button { font-size: 14px; }
}

/* ─── Lecture des épreuves officielles ─────────────────────────────────── */
.entete-epreuve { padding-bottom: var(--e4); }
.sommaire-epreuve { margin-top: var(--e4); }
.sommaire-epreuve summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 var(--e3);
  border: 1px solid var(--rule-fort);
  border-radius: var(--rayon-sm);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-doux);
  cursor: pointer;
  list-style: none;
}
.sommaire-epreuve summary::-webkit-details-marker { display: none; }
.sommaire-epreuve summary::after { content: "▾"; margin-left: auto; color: var(--ink-faible); }
.sommaire-epreuve[open] summary::after { content: "▴"; }
.sommaire-epreuve ol {
  list-style: none;
  margin: var(--e2) 0 0;
  padding: var(--e2) 0 0;
  max-height: 55vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--rule);
}
.sommaire-epreuve li a {
  display: block;
  padding: 8px var(--e2);
  border-radius: 8px;
  color: var(--ink-doux);
  font-size: 14px;
  line-height: 1.35;
  text-decoration: none;
  text-wrap: pretty;
}
.sommaire-epreuve li a:active { background: var(--surface-haut); color: var(--ink); }
.sommaire-epreuve li.niv1 a { font-weight: 600; color: var(--ink); }
.sommaire-epreuve li.niv2 a { padding-left: var(--e4); }
.sommaire-epreuve li.niv3 a { padding-left: calc(var(--e4) * 1.5); font-size: 13px; }

.texte-epreuve {
  margin-top: var(--e4);
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  color: var(--ink);
}
.texte-epreuve h1, .texte-epreuve h2, .texte-epreuve h3, .texte-epreuve h4 {
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
  scroll-margin-top: var(--e4);
}
.texte-epreuve h1 { font-size: 22px; margin: var(--e6) 0 var(--e3); }
.texte-epreuve h2 { font-size: 19px; margin: var(--e6) 0 var(--e2); }
.texte-epreuve h3 { font-size: 17px; margin: var(--e5) 0 var(--e2); }
.texte-epreuve h4 { font-size: 16px; margin: var(--e4) 0 var(--e2); color: var(--ink-doux); }
.texte-epreuve p, .texte-epreuve li { text-wrap: pretty; }
.texte-epreuve p { margin: 0 0 var(--e3); }
.texte-epreuve ul, .texte-epreuve ol { padding-left: var(--e5); margin: 0 0 var(--e3); }
.texte-epreuve li { margin: 2px 0; }
.texte-epreuve blockquote {
  margin: var(--e3) 0;
  padding: var(--e2) var(--e3);
  border-left: 3px solid var(--accent);
  background: var(--surface-haut);
  border-radius: 0 var(--rayon-sm) var(--rayon-sm) 0;
  color: var(--ink-doux);
}
.texte-epreuve img {
  display: block;
  width: 100%;
  height: auto;
  margin: var(--e4) auto;
  border-radius: var(--rayon-sm);
  background: var(--svg-bg);
  cursor: zoom-in;
}
.texte-epreuve .figure-manquante {
  margin: var(--e3) 0;
  padding: var(--e3);
  border: 1px dashed var(--rule-fort);
  border-radius: var(--rayon-sm);
  font-size: 13px;
  font-style: italic;
  color: var(--ink-faible);
}
.texte-epreuve .table-scroll {
  margin: var(--e3) 0;
  /* Le contenu large d'un tableau ne doit ni élargir la page ni s'étendre
     hors de son cadre (Chromium le compte sinon dans la fenêtre du téléphone). */
  contain: paint;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--rayon-sm);
  border: 1px solid var(--rule);
}
.texte-epreuve table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 14px; }
.texte-epreuve th, .texte-epreuve td { padding: 6px 8px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.texte-epreuve th { background: var(--surface-haut); font-weight: 600; }
.texte-epreuve strong { font-weight: 600; }
.texte-epreuve .maths-bloc { margin: var(--e3) 0; overflow-x: auto; overflow-y: hidden; }
.texte-epreuve .katex { font-size: 1.05em; }
/* Une formule en ligne ne se coupe pas : si elle est trop large pour
   l'écran, elle défile dans son propre cadre plutôt que d'élargir la page. */
.texte-epreuve .maths {
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  vertical-align: -0.2em;
  -webkit-overflow-scrolling: touch;
}

.pagination-epreuve {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--e2);
  margin: var(--e6) 0 var(--e4);
}
.pagination-epreuve .bouton-secondaire { min-height: 52px; font-size: 14px; text-align: center; padding: var(--e2); }
.pagination-epreuve > a:nth-child(2) { grid-column: 1 / -1; order: 3; }
.pagination-epreuve > span { display: none; }

/* Le texte intégral reste lisible sans débordement horizontal sur l'iPhone */
@media (max-width: 380px) {
  .texte-epreuve { font-size: 15px; }
}

/* ─── Cours ────────────────────────────────────────────────────────────── */
/* Accès depuis l'écran Catégories : bouton général, lien par catégorie,
   puce double par thème (réviser | lire le cours). Cibles de 44 px. */
.bouton-cours { display: flex; align-items: center; justify-content: center; gap: var(--e2); }
.bouton-cours svg { width: 20px; height: 20px; color: var(--accent); }

.chip-groupe {
  display: inline-flex;
  align-items: stretch;
  max-width: 100%;
  min-height: 44px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface-haut);
}
/* Les deux moitiés débordent d'un pixel sur la bordure du groupe : cibles de 44 px. */
.chip-groupe > * { margin-block: -1px; }
.chip-groupe .chip { border: 0; border-radius: 999px 0 0 999px; background: none; min-height: 44px; min-width: 0; }
.chip-cours {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 44px;
  padding: 0 var(--e3) 0 var(--e2);
  border-left: 1px solid var(--rule-fort);
  border-radius: 0 999px 999px 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.chip-cours svg { width: 17px; height: 17px; }
.chip-cours:active { background: var(--accent-sourd); }

.lien-cours {
  display: flex;
  align-items: center;
  gap: var(--e2);
  min-height: 44px;
  margin-top: var(--e3);
  padding: 0 var(--e3);
  border: 1px dashed var(--rule-fort);
  border-radius: var(--rayon-sm);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}
.lien-cours svg { width: 20px; height: 20px; color: var(--accent); flex: 0 0 auto; }
.lien-cours .meta { margin-left: auto; font-size: 13px; font-weight: 500; color: var(--ink-faible); }
.lien-cours:active { background: var(--surface-haut); }

/* Liste des chapitres */
.ligne-chapitre { grid-template-columns: 28px 1fr auto; }
.ligne-chapitre .numero {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.ligne-chapitre.a-paraitre { cursor: default; }
.ligne-chapitre.a-paraitre .theme { color: var(--ink-faible); }
.ligne-chapitre.a-paraitre .numero { color: var(--ink-faible); }

/* Lecteur : corps de texte, sans cadre de carte, pour donner toute la
   largeur (361 px sur l'iPhone 17) aux schémas et aux formules. */
.entete-cours .texte-doux { margin-top: var(--e2); font-size: 14px; }
.entete-cours .sommaire-epreuve li a { min-height: 44px; display: flex; align-items: center; padding-top: 4px; padding-bottom: 4px; }
.texte-cours {
  margin-top: var(--e4);
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: break-word;
  color: var(--ink);
}
.texte-cours h2, .texte-cours h3 {
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
  scroll-margin-top: calc(var(--h-haut) + var(--e2));
}
.texte-cours h2 {
  font-size: 21px;
  margin: var(--e7) 0 var(--e3);
  padding-top: var(--e3);
  border-top: 2px solid var(--accent);
}
.texte-cours > h2:first-child { margin-top: 0; }
.texte-cours h3 { font-size: 17px; margin: var(--e5) 0 var(--e2); color: var(--ink); }
.texte-cours h4 { font-size: 16px; margin: var(--e4) 0 var(--e2); color: var(--ink-doux); }
.texte-cours p, .texte-cours li { text-wrap: pretty; }
.texte-cours p { margin: 0 0 var(--e3); }
.texte-cours ul, .texte-cours ol { padding-left: var(--e5); margin: 0 0 var(--e3); }
.texte-cours li { margin: var(--e1) 0; }
.texte-cours strong { font-weight: 600; }
.texte-cours a { color: var(--accent); text-underline-offset: 2px; }
.texte-cours code { font-family: ui-monospace, "SF Mono", monospace; font-size: 14px; }
/* Programme d'automate ou pseudo-code : bloc à défilement propre, jamais celui de la page */
.texte-cours pre { margin: 0 0 var(--e3); padding: var(--e2) var(--e3); background: var(--surface-haut); border-radius: var(--rayon-sm); overflow-x: auto; line-height: 1.45; }
.texte-cours pre code { font-size: 13.5px; white-space: pre; }
.texte-cours .chapeau { font-size: 17px; color: var(--ink-doux); }

/* Formules : une formule affichée ne dépasse jamais la colonne ; si elle
   le faisait, elle défilerait dans son cadre plutôt que d'élargir la page. */
.texte-cours .maths-bloc { margin: var(--e3) 0; overflow-x: auto; overflow-y: hidden; }
.texte-cours .katex { font-size: 1.05em; }
/* En ligne, pas de cadre défilant (les débordements de 2 px de KaTeX en
   feraient une zone qui glisse sous le doigt) : KaTeX coupe la ligne après
   les signes = et +, et verifier_cours.mjs contrôle qu'aucun bloc insécable
   ne dépasse la colonne. Les formules courtes sont rendues insécables par
   souderFormules (cours.js), avec la ponctuation qui les touche. */
.texte-cours .insecable { white-space: nowrap; }

/* Schémas : SVG inline écrit à la main, viewBox de 360 au plus, affiché à
   toute la largeur. Les traits suivent l'encre du thème (currentColor). */
.texte-cours figure.schema {
  margin: var(--e4) 0;
  padding: var(--e2) var(--e1) var(--e3);
  background: var(--svg-bg);
  border: 1px solid var(--rule);
  border-radius: var(--rayon-sm);
  cursor: zoom-in;
}
.texte-cours figure.schema > svg { display: block; width: 100%; height: auto; color: var(--ink); overflow: visible; }
/* Dans une liste (auto-test), le schéma reprend toute la largeur du texte :
   sinon son texte passerait sous 12 px. */
.texte-cours li > figure.schema { margin-left: calc(-1 * var(--e5)); }
.texte-cours figure.schema figcaption {
  margin: var(--e2) var(--e2) 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-doux);
  text-wrap: pretty;
  cursor: auto;
}
.texte-cours figure.schema figcaption b { color: var(--ink); font-weight: 600; }

/* Encadrés : à retenir, hypothèses, démonstrations */
.texte-cours .encadre {
  margin: var(--e4) 0;
  padding: var(--e3);
  border: 1px solid var(--rule-fort);
  border-left: 3px solid var(--accent);
  border-radius: var(--rayon-sm);
  background: var(--surface);
}
.texte-cours .encadre > :last-child { margin-bottom: 0; }
.texte-cours .encadre .titre-encadre {
  margin: 0 0 var(--e2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.texte-cours details.demo {
  margin: var(--e3) 0;
  border: 1px solid var(--rule);
  border-radius: var(--rayon-sm);
  background: var(--surface);
}
.texte-cours details.demo > summary,
.texte-cours .autotest details > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 var(--e3);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
}
.texte-cours details > summary::-webkit-details-marker { display: none; }
.texte-cours details.demo > summary::after,
.texte-cours .autotest details > summary::after { content: "▾"; margin-left: auto; color: var(--ink-faible); }
.texte-cours details[open].demo > summary::after,
.texte-cours .autotest details[open] > summary::after { content: "▴"; }
.texte-cours details.demo > :not(summary) { margin-left: var(--e3); margin-right: var(--e3); }
.texte-cours details.demo[open] { padding-bottom: var(--e1); }

/* Formules clés : une fiche par formule, l'id de sa carte en lien */
.texte-cours .formules { list-style: none; padding: 0; margin: var(--e3) 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--e2); }
.texte-cours .formules > li {
  margin: 0;
  padding: var(--e2) var(--e3) var(--e3);
  border: 1px solid var(--rule-fort);
  border-radius: var(--rayon-sm);
  background: var(--surface);
}
.texte-cours .formules .f-tete {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--e2);
  font-size: 15px;
  font-weight: 600;
}
/* Plusieurs cartes pour une fiche : identifiants groupés, alignés à droite. */
.texte-cours .f-tete .f-ids { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--e2); margin-left: auto; }
.texte-cours .formules .maths-bloc { margin: var(--e1) 0; }
.texte-cours .formules .f-note { margin: 0; font-size: 14px; line-height: 1.45; color: var(--ink-doux); }
.texte-cours a.id-carte {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--e2);
  margin: calc(-1 * var(--e2)) calc(-1 * var(--e2)) calc(-1 * var(--e2)) 0;
  font: 600 12px/1 ui-monospace, "SF Mono", monospace;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.texte-cours a.id-carte:active { background: var(--accent-sourd); border-radius: 8px; }
/* Dans le fil du texte, l'identifiant reste en ligne : il n'écarte pas
   l'interligne et ne rejette pas la ponctuation qui le suit. */
.texte-cours p a.id-carte,
.texte-cours .etapes a.id-carte {
  display: inline;
  min-height: 0;
  padding: 0;
  margin: 0;
}

/* Pièges : l'erreur, puis la règle */
.texte-cours .pieges { list-style: none; padding: 0; display: grid; gap: var(--e2); }
.texte-cours .pieges > li {
  margin: 0;
  padding: var(--e2) var(--e3) var(--e3);
  border: 1px solid var(--rule-fort);
  border-radius: var(--rayon-sm);
  background: var(--surface);
}
.texte-cours .pieges .f-tete { display: flex; align-items: center; justify-content: space-between; gap: var(--e2); font-weight: 600; }
.texte-cours .pieges .erreur { margin: var(--e1) 0 var(--e2); color: var(--ink-doux); }
.texte-cours .pieges .erreur::before { content: "L'erreur · "; font-weight: 700; color: var(--rate); }
.texte-cours .pieges .regle { margin: 0; font-size: 16px; line-height: 1.6; }
.texte-cours .pieges .regle::before { content: "La règle · "; font-weight: 700; color: var(--su); }
.texte-cours .pieges .regle + .regle { margin-top: var(--e1); }
.texte-cours .pieges .regle + .regle::before { content: none; }

/* Méthode concours : étapes numérotées, renvois aux épreuves */
.texte-cours ol.etapes { padding-left: var(--e5); }
.texte-cours ol.etapes > li::marker { color: var(--accent); font-weight: 700; }
.texte-cours .sujet {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-doux);
  padding-left: var(--e3);
  border-left: 2px solid var(--rule-fort);
}
/* Liste de lectures d'un sujet : les puces restent à droite du filet. */
.texte-cours ul.sujet { padding-left: calc(var(--e3) + 1.2em); }

/* Exemple chiffré : données, puis résolution question par question */
.texte-cours .donnees-ex { padding: var(--e3) var(--e3) var(--e3) var(--e5); background: var(--surface-haut); border-radius: var(--rayon-sm); }

/* Auto-test : la réponse reste repliée tant qu'on ne l'a pas cherchée */
.texte-cours ol.autotest { padding-left: var(--e5); }
.texte-cours ol.autotest > li { margin: 0 0 var(--e4); }
.texte-cours ol.autotest > li::marker { color: var(--accent); font-weight: 700; }
.texte-cours .autotest details {
  margin-top: var(--e2);
  border: 1px solid var(--rule);
  border-radius: var(--rayon-sm);
  background: var(--surface);
}
.texte-cours .autotest details > :not(summary) { margin-left: var(--e3); margin-right: var(--e3); }
.texte-cours .autotest details[open] { padding-bottom: var(--e1); }

/* Tableaux : trois colonnes au plus, ou défilement dans leur seul cadre */
.texte-cours .table-scroll {
  margin: var(--e3) 0;
  contain: paint;
  overflow-x: auto;
  border-radius: var(--rayon-sm);
  border: 1px solid var(--rule);
}
.texte-cours table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.45; }
.texte-cours th, .texte-cours td { padding: 6px 8px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.texte-cours tr:last-child td { border-bottom: 0; }
.texte-cours th { background: var(--surface-haut); font-weight: 600; }

.texte-cours .reviser-theme { margin: var(--e4) 0 var(--e2); }
.texte-cours a.revelateur { color: var(--sur-accent); text-decoration: none; }
/* Règle de piège en deux paragraphes : une seule étiquette. */
.texte-cours .pieges .regle + .regle { padding-top: var(--e1); }
.texte-cours .pieges .regle + .regle::before { content: none; }
