/*
  Lesson pages. Built from the approved prototype (prototypes/rendu-formules.html):
  same tokens, card look, fonts and KaTeX fixes. See project-memory/guides/math-rendering.md.

  Block accent colours: only Propriété (teal) is approved. The other block colours are
  a PROPOSAL waiting for the founder's choice. Change them here, in one place.
*/

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1c1e21;
  --ink-soft: #5b616b;
  --line: #e4e1d8;
  --code-bg: #f1efe8;
  --reponse-bg: #f7f5ef;  /* answer column: a slight tint next to the white exercise */
  --scale: 1;

  --c-definition: #1d5fb8;  --c-definition-soft: #e7eef9;
  --c-propriete: #0f766e;   --c-propriete-soft: #e3f2ef;   /* approved */
  --c-theoreme: #6b3fb0;    --c-theoreme-soft: #efe9f8;
  --c-rappel: #4a5d70;      --c-rappel-soft: #e9eef2;
  --c-methode: #8a5a00;     --c-methode-soft: #f6eedc;
  --c-remarque: #5b616b;    --c-remarque-soft: #efeee9;
  --c-exemple: #b4531a;     --c-exemple-soft: #fbeee4;
  --c-exercice: #b1265a;    --c-exercice-soft: #f9e7ee;

  --ok: #1a7f37;
  --presque: #8a5a00;
  --ko: #b42318;

  --c-video: var(--c-theoreme);  --c-video-soft: var(--c-theoreme-soft);  /* series: an exercise with a video correction */

  --accent: var(--c-propriete);
  --accent-soft: var(--c-propriete-soft);
}

:root[data-theme="dark"] {
  --bg: #121416;
  --surface: #1b1e21;
  --ink: #e8e6e1;
  --ink-soft: #9aa1aa;
  --line: #2c3035;
  --code-bg: #15181a;
  --reponse-bg: #22262a;

  --c-definition: #7fb0f5;  --c-definition-soft: #18263a;
  --c-propriete: #4fd1c0;   --c-propriete-soft: #17312e;
  --c-theoreme: #b9a0f0;    --c-theoreme-soft: #261f3a;
  --c-rappel: #9fb3c8;      --c-rappel-soft: #1f262d;
  --c-methode: #e0c55a;     --c-methode-soft: #302a14;
  --c-remarque: #9aa1aa;    --c-remarque-soft: #24272b;
  --c-exemple: #f0a06a;     --c-exemple-soft: #36231a;
  --c-exercice: #f38bb0;    --c-exercice-soft: #3a1c28;

  --ok: #56d364;
  --presque: #e0c55a;
  --ko: #ff7b72;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121416;
    --surface: #1b1e21;
    --ink: #e8e6e1;
    --ink-soft: #9aa1aa;
    --line: #2c3035;
    --code-bg: #15181a;
    --reponse-bg: #22262a;

    --c-definition: #7fb0f5;  --c-definition-soft: #18263a;
    --c-propriete: #4fd1c0;   --c-propriete-soft: #17312e;
    --c-theoreme: #b9a0f0;    --c-theoreme-soft: #261f3a;
    --c-rappel: #9fb3c8;      --c-rappel-soft: #1f262d;
    --c-methode: #e0c55a;     --c-methode-soft: #302a14;
    --c-remarque: #9aa1aa;    --c-remarque-soft: #24272b;
    --c-exemple: #f0a06a;     --c-exemple-soft: #36231a;
    --c-exercice: #f38bb0;    --c-exercice-soft: #3a1c28;

    --ok: #56d364;
    --presque: #e0c55a;
    --ko: #ff7b72;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Top bar ---------- */
.barre {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 16px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.fil { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--ink-soft); min-width: 0; }
.fil a { color: var(--ink-soft); text-decoration: none; }
.fil a:hover { color: var(--ink); text-decoration: underline; }
.fil .sep { opacity: .6; }
.fil [aria-current] { color: var(--ink); font-weight: 500; }
/* On a phone the trail keeps only the way back, on one line: the page's own name is its title just
   below, and on a chapter's pages « Accueil » is one step up from the subject's page. */
@media (max-width: 560px) {
  .fil:has(> a:nth-of-type(2)) > [aria-current],
  .fil:has(> a:nth-of-type(2)) > .sep:nth-last-child(2) { display: none; }
  .fil:has(> a:nth-of-type(3)) > a:first-child,
  .fil:has(> a:nth-of-type(3)) > a:first-child + .sep { display: none; }
}

.outils { display: flex; gap: 6px; }
.outils button {
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
}
.outils button:hover { border-color: var(--ink-soft); }

button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Prose stays at a comfortable 760px; exercise cards may use the full width
   so the statement and the correction can sit side by side. */
main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 16px 56px;
}
main > *, .inductif > *, .etape > *, .avant > *, .fin-notion > * {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}
main > .inductif, main > .bloc--exercice, main > .bloc--defi, .inductif > .etape, .inductif > .fin-notion,
.etape > .a-toi, .fin-notion > .bloc--defi { max-width: 1120px; }

/* ---------- Page headers ---------- */
.eyebrow {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 6px;
}
.eyebrow .chapter { color: var(--ink-soft); font-weight: 500; letter-spacing: .04em; }

.entete h1 {
  font-size: calc(30px * var(--scale));
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.2;
  margin: 4px 0 12px;
}
.entete .eyebrow { color: var(--ink-soft); }
.entete .objectif, .entete .intro {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: calc(18px * var(--scale));
  line-height: 1.8;
  margin: 0;
}
.entete .intro p { margin: 0 0 .5em; }
.entete .objectif strong { font-family: "Inter", system-ui, sans-serif; font-size: .82em; font-weight: 600; }

.progression {
  height: 4px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
  margin: 10px 0 18px;
  max-width: 320px;
}
.progression span { display: block; height: 100%; background: var(--c-propriete); border-radius: 4px; }

h2.section {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 36px auto 12px;
}

/* ---------- Blocks (cards) ---------- */
.bloc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 28px 32px 30px;
  margin-top: 18px;
  margin-bottom: 18px;
  font-size: calc(19px * var(--scale));
}
.bloc--defi { --accent: var(--c-exercice); --accent-soft: var(--c-exercice-soft); }
.bloc--definition { --accent: var(--c-definition); --accent-soft: var(--c-definition-soft); }
.bloc--propriete  { --accent: var(--c-propriete);  --accent-soft: var(--c-propriete-soft); }
.bloc--theoreme   { --accent: var(--c-theoreme);   --accent-soft: var(--c-theoreme-soft); }
.bloc--rappel     { --accent: var(--c-rappel);     --accent-soft: var(--c-rappel-soft); }
.bloc--methode    { --accent: var(--c-methode);    --accent-soft: var(--c-methode-soft); }
.bloc--remarque   { --accent: var(--c-remarque);   --accent-soft: var(--c-remarque-soft); }
.bloc--exemple    { --accent: var(--c-exemple);    --accent-soft: var(--c-exemple-soft); }
.bloc--exercice   { --accent: var(--c-exercice);   --accent-soft: var(--c-exercice-soft); }

.bloc-titre {
  font-family: "Inter", system-ui, sans-serif;
  font-size: calc(22px * var(--scale));
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.35;
  margin: 0 0 14px;
}

.enonce, .solution, .aide-corps, .results, .q-texte {
  font-family: "Source Serif 4", Georgia, serif;
  line-height: 2;
}
.enonce p, .solution p, .aide-corps p, .results p { margin: 0 0 .2em; }
.complement { margin-top: 10px; }

/* A short formula and the punctuation right after it: no line break between them. */
.nowrap { white-space: nowrap; }

.liste { margin: .1em 0 .35em; padding-left: 1.25em; }
.liste li { margin: 0 0 .15em; padding-left: .15em; }
.liste li::marker { color: var(--accent); }

p.conclusion {
  margin: .45em 0;
  padding: .3em .9em;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 8px 8px 0;
}

/* Display formulas, aligned left (fleqn), scroll on small screens */
.formule, .formulas { min-width: 0; }
.formulas.indented { padding-left: 20px; }

.katex { font-size: 1.12em; }
.katex-display { margin: .35em 0; }
.katex-display.fleqn > .katex { padding-left: 0; }
.formule .katex-display, .formulas .katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

/* Numbered results (from the prototype) */
.results {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.results > li {
  display: grid;
  grid-template-columns: 30px 1fr;
  column-gap: 14px;
  align-items: center;
}
.num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  display: grid;
  place-items: center;
  align-self: center;
}
.results > li > div { min-width: 0; } /* lets long formulas scroll instead of widening the grid */
.results li.has-condition .num, .results li.has-text .num { align-self: start; margin-top: 8px; }
.condition { margin: 4px 0 0; }
.results .texte p { margin: 0; }

/* Tables */
.tableau { overflow-x: auto; margin: .5em 0 .7em; }
.tableau table { border-collapse: collapse; min-width: 100%; font-size: .9em; line-height: 1.6; }
.tableau th, .tableau td { border: 1px solid var(--line); padding: 8px 12px; text-align: center; vertical-align: middle; }
.tableau thead th {
  background: var(--accent-soft);
  font-family: "Inter", system-ui, sans-serif;
  font-size: .8em;
  font-weight: 600;
}
.tableau tbody th { font-weight: 400; background: var(--code-bg); }

/* Worked solution of an example */
.solution {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.sous-titre {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 4px;
}

/* Figures (inline SVG) */
.figure { margin: 14px 0 6px; }
.figure svg { display: block; width: 100%; max-width: 560px; height: auto; margin: 0 auto; overflow: visible; }
.figure .ax { stroke: var(--ink-soft); stroke-width: 1.2; fill: none; }
.figure .arrow { fill: var(--ink-soft); }
.figure .grid { stroke: var(--line); stroke-width: 1; }
.figure .curve { stroke: var(--accent); stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.figure .curve2 { stroke: var(--c-exemple); stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.figure .guide { stroke: var(--ink-soft); stroke-width: 1.1; stroke-dasharray: 4 4; fill: none; }
.figure .level { stroke: var(--c-exercice); stroke-width: 1.6; stroke-dasharray: 6 4; fill: none; }
.figure .pt { fill: var(--accent); }
.figure .pt2 { fill: var(--c-exemple); }
.figure .hole { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.figure text { font-family: "Source Serif 4", Georgia, serif; font-size: 16px; fill: var(--ink); }
.figure text.i { font-style: italic; }
.figure text.soft { fill: var(--ink-soft); }
.figure text.cap { font-family: "Inter", system-ui, sans-serif; font-size: 13px; fill: var(--ink-soft); }
.figure text.acc { fill: var(--accent); }
.figure text.acc2 { fill: var(--c-exemple); }
.figure text.lvl { fill: var(--c-exercice); }

/* ---------- Exercises ---------- */
.mobilise {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: -4px 0 14px;
  font-size: 13px;
  color: var(--ink-soft);
}
.puce {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}
.puce:hover { border-color: var(--ink-soft); }
.puce-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}
.puce .katex { font-size: 1em; }

.questions {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}
.question {
  display: grid;
  grid-template-columns: 30px 1fr;
  column-gap: 14px;
  padding: 16px 0 0;
}
.question + .question { margin-top: 16px; border-top: 1px solid var(--line); }
.questions.single .question { grid-template-columns: 1fr; padding-top: 4px; }
.question > .num { align-self: start; margin-top: 8px; }
.q-corps { min-width: 0; }

/* Exercise on the left, help and correction on the right, in a slightly different tint.
   Stacked (exercise first) on narrow screens. */
.q-exercice { min-width: 0; }
.q-reponse {
  min-width: 0;
  margin-top: 12px;
  padding: 12px 16px 14px;
  background: var(--reponse-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.q-reponse-titre {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.q-reponse .aides { margin-top: 6px; }
.q-reponse .aide-corps { background: var(--surface); }
@media (min-width: 900px) {
  .q-corps {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    column-gap: 24px;
    align-items: start;
  }
  .q-reponse { margin-top: 2px; }
}

.aides { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; font-size: .92em; }
.aide { flex: 0 0 auto; min-width: 0; }
.aide[open] { flex-basis: 100%; }
.aide > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
}
.aide > summary::-webkit-details-marker { display: none; }
.aide > summary::before { content: "+"; font-weight: 600; color: var(--accent); width: .7em; text-align: center; }
.aide[open] > summary::before { content: "−"; }
.aide > summary:hover { border-color: var(--ink-soft); }
.aide[open] > summary { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.aide-corps {
  margin-top: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--code-bg);
  border: 1px solid var(--line);
}

.controle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 14px;
}
.controle label { color: var(--ink-soft); font-weight: 500; }
.controle label .katex { color: var(--ink); }
.controle input {
  font: 500 15px ui-monospace, SFMono-Regular, Consolas, monospace;
  width: 9em;
  padding: 6px 10px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.controle button {
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
.verdict { flex-basis: 100%; margin: 0; font-weight: 500; }
.verdict:empty { display: none; }
.verdict.ok { color: var(--ok); }
.verdict.presque { color: var(--presque); }
.verdict.ko { color: var(--ko); }

/* ---------- Chapter and level pages ---------- */
/* Chapter page: the lesson and the exercises, two equal doors (side by side on a phone too) */
.portes { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 28px; }
.porte {
  --accent: var(--c-propriete);
  --accent-soft: var(--c-propriete-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 34px 16px 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
}
.porte--exercices { --accent: var(--c-exercice); --accent-soft: var(--c-exercice-soft); }
a.porte:hover { border-color: var(--accent); }
.porte-icone { width: 56px; height: 56px; display: grid; place-items: center; margin-bottom: 14px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); }
.porte-icone .icone { width: 28px; height: 28px; }
.porte-titre { font-size: calc(21px * var(--scale)); font-weight: 600; letter-spacing: -.01em; }
.porte-meta { margin-top: 4px; font-size: 14px; color: var(--ink-soft); }
.porte--bientot { background: none; border-style: dashed; color: var(--ink-soft); }
.porte--bientot .porte-icone { background: none; color: var(--ink-soft); }
.retour-chapitre { margin-top: 32px; font-size: 14px; }
.retour-chapitre a { color: var(--ink-soft); text-decoration: none; }
.retour-chapitre a:hover { color: var(--ink); text-decoration: underline; }
@media (max-width: 560px) {
  .portes { gap: 12px; margin-top: 18px; }
  .porte { padding: 24px 8px 22px; }
}

.liste-notions, .liste-chapitres { list-style: none; margin: 0 auto; padding: 0; display: grid; gap: 10px; }
.carte {
  display: grid;
  grid-template-columns: 36px 1fr;
  column-gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink);
}
.carte:hover { border-color: var(--ink-soft); }
.carte .num { width: 30px; height: 30px; font-size: 14px; align-self: start; --accent: var(--c-propriete); --accent-soft: var(--c-propriete-soft); }
.carte-titre { display: block; font-weight: 600; font-size: 16px; margin-top: 3px; }
.carte-texte { display: block; font-family: "Source Serif 4", Georgia, serif; font-size: 16px; line-height: 1.6; color: var(--ink-soft); margin-top: 2px; }
.carte-meta { display: block; font-size: 12px; color: var(--ink-soft); margin-top: 6px; }
.carte .katex { font-size: 1em; }

.bientot { color: var(--ink-soft); font-size: 14px; margin: 14px auto 0; }

/* ---------- Navigation: year → filière → subject (contenu/navigation.yaml) ---------- */
/* Home page: the three years of the lycée in order, on a rail. A dot per year, filled when the
   year has lessons. Each year lists its filières; two of them sit side by side on a wide screen. */
.annees { list-style: none; margin: 32px auto 0; padding: 0; }
.annee { position: relative; padding: 0 0 34px 36px; }
.annee:last-child { padding-bottom: 0; }
.annee::before { content: ""; position: absolute; left: 7px; top: 24px; bottom: -4px; width: 2px; background: var(--line); }
.annee:last-child::before { display: none; }
.annee::after {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.annee--bientot::after { background: var(--bg); border: 2px solid var(--line); box-shadow: none; }
.annee-titre { margin: 0 0 12px; font-size: calc(22px * var(--scale)); font-weight: 650; letter-spacing: -.015em; line-height: 1.25; }
.annee-quand { display: block; margin-top: 2px; font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--ink-soft); }
.annee--bientot .annee-titre { color: var(--ink-soft); }
.annee-vide { margin: 0; font-size: 14px; color: var(--ink-soft); }
.voies { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.voie {
  display: block;
  height: 100%;
  padding: 15px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink);
}
a.voie:hover { border-color: var(--accent); }
.voie-nom { display: block; font-size: calc(17px * var(--scale)); font-weight: 600; line-height: 1.3; }
.voie-sous { font-weight: 400; color: var(--ink-soft); white-space: nowrap; }
.voie-meta { display: block; margin-top: 4px; font-size: 13px; color: var(--ink-soft); }
.voie--bientot { background: none; border-style: dashed; color: var(--ink-soft); }

/* « Reprendre »: the last page studied (lecon.js shows it when there is one). */
.reprendre {
  display: grid;
  gap: 2px;
  margin-top: 24px;
  padding: 13px 18px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--ink);
  text-decoration: none;
}
.reprendre[hidden] { display: none; }
.reprendre:hover .reprendre-titre { text-decoration: underline; }
.reprendre-mot { font-size: 13px; font-weight: 600; color: var(--accent); }
.reprendre-titre { font-size: calc(16px * var(--scale)); font-weight: 600; line-height: 1.35; }
.reprendre-lieu { font-size: 13px; color: var(--ink-soft); }

/* A filière's page: its subjects, as doors (as a chapter's Cours | Exercices). */
.portes--matieres { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.porte--physique { --accent: var(--c-definition); --accent-soft: var(--c-definition-soft); }
.porte--svt { --accent: var(--ok); --accent-soft: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
/* On a phone the subjects become rows: icon, name, number of chapters. */
@media (max-width: 560px) {
  .portes--matieres { grid-template-columns: 1fr; gap: 10px; }
  .portes--matieres .porte {
    display: grid;
    grid-template-columns: 44px 1fr;
    column-gap: 14px;
    align-items: center;
    padding: 14px 16px;
    text-align: left;
  }
  .portes--matieres .porte-icone { grid-row: span 2; width: 44px; height: 44px; margin: 0; border-radius: 12px; }
  .portes--matieres .porte-icone .icone { width: 22px; height: 22px; }
  .portes--matieres .porte-titre { align-self: end; font-size: calc(18px * var(--scale)); }
  .portes--matieres .porte-meta { align-self: start; margin-top: 0; }
}

/* What only one track has (a chapter, a notion, a card), in that track's pages */
.badge-filiere {
  display: inline-block;
  flex: none;
  padding: 0 7px;
  border-radius: 999px;
  font-family: Inter, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 1.7;
  text-transform: uppercase;
  color: var(--c-definition);
  background: var(--c-definition-soft);
  vertical-align: 2px;
}
.carte-titre .badge-filiere { margin-left: 8px; }

/* ---------- Previous / next ---------- */
.suite { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 36px; }
.suite a {
  display: block;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}
.suite a:hover { border-color: var(--ink-soft); }
.suite a > span { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 2px; }
.suite a strong { font-weight: 600; font-size: 15px; }
.suite .suiv { grid-column: 2; text-align: right; }
.suite .katex { font-size: 1em; }

.pied {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 40px;
  font-size: 13px;
  color: var(--ink-soft);
}
.pied kbd {
  font: 12px ui-monospace, SFMono-Regular, Consolas, monospace;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

/* =================================================================== inductive notions */

.inductif { margin-top: 22px; }

.etape, .etape-carte, .a-toi, .explication, .a-retenir, .autre-explication, .fin-notion, .prerequis-carte { scroll-margin-top: 72px; }

.mini-titre {
  margin: 0 0 4px;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.consigne { font-size: 14px; color: var(--ink-soft); margin: -4px 0 12px; line-height: 1.6; }

/* Buttons */
.bouton-principal, .bouton-secondaire, .bouton-discret, .plus-pres {
  font: inherit;
  font-family: "Inter", system-ui, sans-serif;
  cursor: pointer;
  border-radius: 10px;
}
.bouton-principal {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--c-propriete);
  border: 1px solid var(--c-propriete);
  padding: 10px 18px;
}
:root[data-theme="dark"] .bouton-principal { color: #0d1f1d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bouton-principal { color: #0d1f1d; } }
.bouton-principal:hover { filter: brightness(1.08); }
.bouton-secondaire {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 10px 16px;
}
.bouton-secondaire:hover { border-color: var(--ink-soft); }
.bouton-discret {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  background: none;
  border: 1px dashed var(--line);
  padding: 6px 12px;
}
.bouton-discret:hover { color: var(--ink); border-color: var(--ink-soft); }

/* Intro and prerequisites */
.carte-intro {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 26px;
  font-size: calc(18px * var(--scale));
}
.carte-intro .eyebrow { color: var(--c-propriete); }
.carte-intro .mini-titre { margin-top: 12px; }

.graphe-prerequis { margin: 0 0 14px; }
.graphe-prerequis svg { display: block; width: 100%; max-width: 420px; height: auto; margin: 0 auto; }
.graphe-prerequis .noeud rect { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.graphe-prerequis a:hover .noeud rect { stroke: var(--ink-soft); }
.graphe-prerequis .noeud-titre { font: 600 14px "Inter", system-ui, sans-serif; fill: var(--ink); }
.graphe-prerequis .noeud-sous { font: 500 11px "Inter", system-ui, sans-serif; fill: var(--ink-soft); }
.graphe-prerequis .noeud--courant rect { fill: var(--c-propriete-soft); stroke: var(--c-propriete); stroke-width: 2; }
.graphe-prerequis .noeud--courant .noeud-sous { fill: var(--c-propriete); }
.graphe-prerequis .noeud.acquis rect { stroke: var(--ok); stroke-width: 2; }
.graphe-prerequis .noeud.acquis .noeud-sous { fill: var(--ok); }
.graphe-prerequis .noeud.a-revoir rect { stroke: var(--presque); stroke-width: 2; stroke-dasharray: 5 3; }
.graphe-prerequis .lien { stroke: var(--ink-soft); stroke-width: 1.4; }
.graphe-prerequis .lien-fleche { fill: var(--ink-soft); }

.prerequis-liste { display: grid; gap: 10px; }
.prerequis-carte {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px 16px;
  font-size: calc(17px * var(--scale));
}
.prerequis-carte.acquis { border-color: var(--ok); }
.prerequis-carte.a-revoir { border-color: var(--presque); }
.prerequis-tete { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.prerequis-tete h3 { margin: 0; font-size: 16px; font-weight: 600; }
.prerequis-ou { font-size: 12px; color: var(--ink-soft); }
.prerequis-etat { margin-left: auto; font-size: 13px; font-weight: 600; }
.prerequis-carte.acquis .prerequis-etat { color: var(--ok); }
.prerequis-carte.a-revoir .prerequis-etat { color: var(--presque); }
.prerequis-besoin { font-family: "Source Serif 4", Georgia, serif; line-height: 1.8; margin: 4px 0 8px; }
.prerequis-besoin p { margin: 0; }
.prerequis-verif { margin-top: 6px; }
.prerequis-revoir { margin: 10px 0 0; font-size: 14px; }
.prerequis-revoir a { color: var(--c-propriete); font-weight: 500; }
.prerequis-carte .aide { margin-top: 10px; }

.demarrer { text-align: center; margin-top: 22px; margin-bottom: 8px; }

/* Multiple choice */
.qcm-texte { margin-bottom: 8px; }
.qcm-choix { display: flex; flex-wrap: wrap; gap: 8px; }
.choix {
  font: inherit;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: .95em;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 7px 14px;
  cursor: pointer;
  text-align: left;
}
.choix:hover:not(:disabled) { border-color: var(--ink-soft); }
.choix:disabled { cursor: default; }
.choix .katex { font-size: 1.05em; }
.choix--faux { border-color: var(--ko); color: var(--ko); text-decoration: line-through; text-decoration-thickness: 1px; }
.choix--juste { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); color: var(--ink); font-weight: 600; }
.choix--solution { border-color: var(--ok); border-style: dashed; }
.retour {
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  font-family: "Source Serif 4", Georgia, serif;
  line-height: 1.8;
}
.retour p { margin: 0; }
.retour--juste { background: color-mix(in srgb, var(--ok) 10%, var(--surface)); border-left: 3px solid var(--ok); }
.retour--faux { background: color-mix(in srgb, var(--ko) 8%, var(--surface)); border-left: 3px solid var(--ko); }

/* Steps */
.etape { margin-top: 28px; }
.etape-carte {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--c-propriete);
  border-radius: 12px;
  padding: 22px 30px 26px;
  font-size: calc(19px * var(--scale));
}
.etape-tete { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 16px; margin-bottom: 10px; }
.etape-tete .eyebrow { color: var(--c-propriete); }
.etape-titre { margin: 0; font-size: calc(22px * var(--scale)); font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.annonce {
  font-family: "Inter", system-ui, sans-serif;
  font-size: .78em;
  line-height: 1.6;
  color: var(--ink-soft);
  background: var(--c-propriete-soft);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
}
.annonce p { margin: 0; }
.annonce strong { color: var(--ink); }
.question-etape {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.question-etape > .bouton-discret { margin-top: 12px; }
.explication { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
.a-retenir {
  margin-top: 18px;
  padding: 16px 20px;
  border-radius: 10px;
  border-left: 4px solid var(--c-definition);
  background: var(--c-definition-soft);
}
.a-retenir .eyebrow { color: var(--c-definition); }
.a-retenir h3 { margin: 0 0 6px; font-size: calc(18px * var(--scale)); font-weight: 600; }
.autre-explication {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: 10px;
  background: var(--reponse-bg);
  border: 1px solid var(--line);
}
.point-etape {
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: 10px;
  border: 1.5px solid var(--c-propriete);
  text-align: center;
}
.point-etape p { margin: 0 0 10px; font-weight: 600; font-size: 17px; }
.point-boutons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.etape-fin { text-align: center; margin-top: 18px; }
.a-toi > .bloc { margin-top: 18px; }

/* Explorer: graph + "come closer" tables */
.explorer { margin: 14px 0 4px; }
.explorer-graphe { display: block; width: 100%; max-width: 520px; height: auto; margin: 0 auto; overflow: hidden; }
.explorer .grid { stroke: var(--line); stroke-width: 1; }
.explorer .ax { stroke: var(--ink-soft); stroke-width: 1.3; }
.explorer .arrow { fill: var(--ink-soft); }
.explorer .guide { stroke: var(--ink-soft); stroke-width: 1.1; stroke-dasharray: 4 4; }
.explorer .curve { stroke: var(--c-propriete); stroke-width: 2.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.explorer .pt { fill: var(--c-propriete); }
.explorer .hole { fill: var(--surface); stroke: var(--c-propriete); stroke-width: 2.2; }
.explorer .lbl { font: 14px "Inter", system-ui, sans-serif; fill: var(--ink-soft); }
.explorer .lbl--x0 { fill: var(--ink); font-weight: 700; }
.explorer .droite { fill: none; stroke-width: 1.8; }
.explorer .droite--tangente { stroke: var(--c-definition); stroke-dasharray: 7 5; }
.explorer .droite--asymptote { stroke: var(--c-methode); stroke-dasharray: 9 5; }
.explorer .droite--guide { stroke: var(--ink-soft); stroke-dasharray: 3 4; }
.explorer .droite--courbe2 { stroke: var(--c-exemple); stroke-width: 2.4; }
.explorer .droite-lbl { font: italic 15px "Source Serif 4", Georgia, serif; fill: var(--ink-soft); }
.explorer .pt--repere { fill: var(--ink); }
.explorer .pt-lbl { font: italic 600 16px "Source Serif 4", Georgia, serif; fill: var(--ink); }
.explorer .secante { stroke: var(--c-exercice); stroke-width: 1.8; }
.explorer--infini .approche, .explorer--aucune .approche, .explorer--un-cote .approche { grid-template-columns: 1fr; max-width: 420px; margin-left: auto; margin-right: auto; }
.explorer .marqueur circle { fill: var(--c-exercice); stroke: var(--surface); stroke-width: 2; }
.explorer .marqueur .proj { stroke: var(--c-exercice); stroke-width: 1.3; stroke-dasharray: 3 3; }
.approche { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.cote {
  min-width: 0;
  background: var(--reponse-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px 12px;
  font-size: 15px;
}
.cote-titre { margin: 0 0 6px; font-family: "Inter", system-ui, sans-serif; font-size: 13px; color: var(--ink-soft); }
.cote-titre strong { color: var(--ink); }
.cote table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cote th, .cote td { padding: 4px 6px; text-align: right; border-bottom: 1px solid var(--line); font-family: "Inter", system-ui, sans-serif; }
.cote th { font-weight: 500; color: var(--ink-soft); }
.cote th .katex { font-size: 1em; }
.cote tr.recent td { color: var(--c-exercice); font-weight: 700; }
.plus-pres {
  width: 100%;
  margin-top: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--c-propriete);
  background: var(--surface);
  border: 1.5px solid var(--c-propriete);
  padding: 8px 10px;
}
.plus-pres:disabled { color: var(--ink-soft); border-color: var(--line); cursor: default; }

/* End of the notion */
.fin-notion { margin-top: 28px; }
.bilan {
  margin-top: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--c-definition);
  border-radius: 12px;
  padding: 20px 26px;
  font-size: calc(18px * var(--scale));
}
.bilan .eyebrow { color: var(--c-definition); }
.bilan-liste { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 14px; }
.bilan-liste > li, .prerequis-liste > *, .approche > * { min-width: 0; } /* long formulas scroll instead of widening the grid */
.bilan-liste h3 { margin: 0 0 2px; font-size: 16px; font-weight: 600; }

/* Videos by Moroccan teachers (contenu/chaines.yaml + contenu/<niveau>/videos/): a small YouTube-like window that shows one part
   at a time (‹ › to change), and the player that opens below it. Colours drawn over a thumbnail
   are fixed, not themed, because they sit on a photo. */
.etape-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.etape-tete-texte { min-width: 0; }
.etape-tete--video { align-items: flex-start; }
.etape-tete--video .etape-tete-texte { flex: 1 1 320px; }
.etape-tete--video .etape-actions { margin-top: 14px; }
.etape-tete--video > .videos { flex: 0 0 272px; }

.videos { width: 100%; max-width: 320px; font-family: "Inter", system-ui, sans-serif; }
.videos-titre {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--c-definition);
}
.video-liste { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.js .video-item:not(.courant) { display: none; }
.video-vignette {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 10px;
  background: #000;
  box-shadow: 0 1px 3px rgb(0 0 0 / .18);
}
.video-vignette img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.video-vignette:hover img { transform: scale(1.04); }
.video-vignette:focus-visible { outline: 3px solid var(--c-definition); outline-offset: 2px; }
.video-play { position: absolute; inset: 0; display: grid; place-items: center; }
.video-play svg { width: 48px; height: 48px; filter: drop-shadow(0 1px 4px rgb(0 0 0 / .4)); }
.video-play circle { fill: rgb(0 0 0 / .55); transition: fill .2s; }
.video-vignette:hover .video-play circle { fill: rgb(0 0 0 / .8); }
.video-role, .video-duree {
  position: absolute;
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
  color: #fff;
  background: rgb(0 0 0 / .75);
}
.video-role { top: 8px; left: 8px; }
.video-role--cours { background: #1d5fb8; }
.video-role--exercices { background: #b1265a; }
.video-duree { right: 8px; bottom: 8px; font-variant-numeric: tabular-nums; }
.video-item.en-lecture .video-vignette { outline: 3px solid var(--c-definition); outline-offset: 2px; }
/* Who explains the point and at which minute: the line a student reads first. */
.video-texte { min-width: 0; }
.video-qui { margin: 8px 0 0; font-size: 15px; line-height: 1.4; color: var(--ink); overflow-wrap: anywhere; }
.video-prof { font-weight: 600; }
.video-instant { font-weight: 600; color: var(--c-definition); font-variant-numeric: tabular-nums; white-space: nowrap; }
.video-label {
  margin: 3px 0 0;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--ink);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.video-meta {
  margin: 3px 0 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.video-meta cite { font-style: normal; }
.video-nav { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.video-fleche {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0 0 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 600 19px/1 "Inter", system-ui, sans-serif;
  cursor: pointer;
}
.video-fleche:hover { border-color: var(--c-definition); color: var(--c-definition); }
.video-compteur { min-width: 3.4em; font-size: 13px; color: var(--ink-soft); text-align: center; font-variant-numeric: tabular-nums; }

.videos-notion, .videos-chapitre { margin-top: 18px; }
.video-lecteur { margin: 6px 0 18px; }
.video-lecteur iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 10px; background: #000; }
.video-lecteur--short iframe { aspect-ratio: 9 / 16; max-width: 320px; margin: 0 auto; }
.video-lecteur-titre { margin: 0 0 6px; font: 13.5px/1.4 "Inter", system-ui, sans-serif; color: var(--ink); }
.video-lecteur-titre strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.video-lecteur-pied { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 6px 0 0; font: 13px "Inter", system-ui, sans-serif; }
.video-lecteur-pied a { margin-left: auto; }
.video-lecteur-pied a, .video-fermer { color: var(--c-definition); }
.video-fermer { padding: 0; border: 0; background: none; font: inherit; text-decoration: underline; cursor: pointer; }

/* In a card (direct notions): the window lies flat under the card's title, in the answer tint:
   thumbnail on the left, then who explains this exact point, at which minute, in which video. */
.fiche-video { padding: 12px 24px 14px; border-top: 1px solid var(--line); background: var(--reponse-bg); }
.fiche-video .videos { max-width: none; }
.fiche-video .video-item { grid-template-columns: 184px minmax(0, 1fr); gap: 4px 16px; align-items: start; }
.js .fiche-video .video-item.courant, html:not(.js) .fiche-video .video-item { display: grid; }
.fiche-video .video-qui { margin-top: 0; }
.fiche-video .video-lecteur { margin: 12px 0 0; }
@media (max-width: 560px) {
  .fiche-video { padding: 12px 16px 14px; }
  .fiche-video .video-item { grid-template-columns: 120px minmax(0, 1fr); gap: 4px 12px; }
  .fiche-video .video-play svg { width: 34px; height: 34px; }
  .fiche-video .video-role { top: 5px; left: 5px; padding: 2px 5px; font-size: 10.5px; }
  .fiche-video .video-duree { right: 5px; bottom: 5px; padding: 2px 5px; font-size: 10.5px; }
}

/* Control page (dist/<niveau>/revue-videos.html): for us, not for students. */
.revue h3.revue-notion { margin: 28px 0 0; font: 600 18px/1.35 "Inter", system-ui, sans-serif; }
.revue h4 { margin: 16px 0 4px; font: 600 14px/1.4 "Inter", system-ui, sans-serif; }
.revue h4 code { margin-left: 6px; font: 400 12px ui-monospace, Consolas, monospace; color: var(--ink-soft); overflow-wrap: anywhere; }
.revue-liste { margin: 0; padding-left: 20px; font: 14px/1.5 "Inter", system-ui, sans-serif; }
.revue-liste li { margin: 0 0 10px; }
.revue-liste a { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--c-definition); }
.revue-preuve, .revue-meta { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); overflow-wrap: anywhere; }
.revue-preuve q { color: var(--ink); }
.revue-vide { margin: 0; font: 13px "Inter", system-ui, sans-serif; color: var(--ink-soft); }

/* Chapter page: the thumbnail of each notion's first video part */
.carte--video { grid-template-columns: 36px 1fr 144px; }
.carte-vignette {
  position: relative;
  align-self: start;
  width: 144px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
}
.carte-vignette img { display: block; width: 100%; height: 100%; object-fit: cover; }
.carte-vignette-nb {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: rgb(0 0 0 / .78);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  .etape-tete--video > .videos { flex-basis: 100%; max-width: none; }
  .carte--video { grid-template-columns: 36px 1fr; }
  .carte-vignette { grid-column: 2; width: 150px; margin-top: 10px; }
}

/* Step-by-step reveal (only when JavaScript runs; without it everything is visible) */
.revoir-etape { display: none; }
.js .etape.verrouillee, .js .fin-notion.verrouillee { display: none; }
.js .etape[data-stage="0"] .revele-1,
.js .etape[data-stage="0"] .revele-2,
.js .etape[data-stage="1"] .revele-2 { display: none; }
.js .etape:not([data-stage="1"]) .point-etape { display: none; }
.js .etape:not([data-aide]) .autre-explication { display: none; }
.js .etape[data-stage="3"] .etape-fin { display: none; }
.js .etape:not([data-stage="0"]) .passer { display: none; }
.js .etape[data-passe] .revoir-etape { display: inline-block; }
.js .etape[data-passe] .etape-corps,
.js .etape[data-passe] .a-toi,
.js .etape[data-passe] .autre-explication { display: none; }
.js .avant[data-demarre] .demarrer { display: none; }
.js .etape:not([data-stage="0"]) .question-etape > .bouton-discret { display: none; }
.encore-bloque { display: none; margin: 10px 0 0; font-size: 14px; color: var(--ink-soft); }
.encore-bloque a { color: var(--c-propriete); }
.js .etape[data-aide] [data-action="pas-encore"] { display: none; }
.js .etape[data-aide] .encore-bloque { display: block; }
html:not(.js) .inductif [data-action], html:not(.js) .plus-pres { display: none; }

@media (max-width: 560px) {
  .etape-carte { padding: 18px 16px 20px; font-size: calc(17px * var(--scale)); }
  .carte-intro { padding: 18px 16px; }
  .cote { padding: 8px 8px 10px; font-size: 14px; }
  .cote th, .cote td { padding: 4px 3px; }
  .a-retenir { padding: 14px 14px; }
}

@media (max-width: 560px) {
  main { padding-top: 20px; }
  .bloc { padding: 22px 18px 24px; font-size: calc(17px * var(--scale)); }
  .formulas.indented { padding-left: 0; }
  .question { grid-template-columns: 26px 1fr; column-gap: 10px; }
  .results > li { column-gap: 10px; }
  .entete h1 { font-size: calc(25px * var(--scale)); }
  .suite { grid-template-columns: 1fr; }
  .suite .suiv { grid-column: 1; }
  .outils button { padding: 5px 8px; }
}

/* ---------- Direct notions (short version): cards of rule → example → exercise ---------- */
main > .direct { max-width: 960px; }
.direct > * { max-width: none; }
.fiche-sommaire { margin-top: 18px; font-size: 14px; }
.fiche-sommaire ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.fiche-sommaire a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  font-weight: 500;
}
.fiche-sommaire a:hover { border-color: var(--ink-soft); }
.fiche-sommaire .num { width: 22px; height: 22px; font-size: 12px; flex: none; }
.fiche-sommaire a.fait { border-color: var(--ok); }
.fiche-sommaire a.fait .num { background: var(--ok); color: var(--surface); }
.fiche-sommaire .katex { font-size: 1em; }
.fiche-compteur { margin: 8px 0 0; font-size: 13px; color: var(--ink-soft); }
.fiche-compteur:empty { display: none; }
.fiche {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 22px;
  font-size: calc(18px * var(--scale));
  scroll-margin-top: 64px;
  overflow: hidden;
}
.fiche-tete { display: flex; align-items: center; gap: 12px; padding: 16px 24px 12px; }
.fiche-tete h2 { flex: 1; margin: 0; font-size: calc(21px * var(--scale)); font-weight: 600; letter-spacing: -.01em; line-height: 1.35; }
.fiche-tete .num { flex: none; --accent: var(--c-propriete); --accent-soft: var(--c-propriete-soft); }
.fiche-etat { display: none; flex: none; font-size: 12px; font-weight: 600; color: var(--ok); }
.fiche.fait { border-color: var(--ok); }
.fiche.fait .fiche-etat { display: inline; }
.fiche-partie { padding: 12px 24px 14px; border-left: 4px solid var(--accent); border-top: 1px solid var(--line); min-width: 0; }
.fiche-partie .eyebrow { margin-bottom: 2px; }
.fiche-partie .enonce { line-height: 1.85; }
.fiche-partie--definition { --accent: var(--c-definition); --accent-soft: var(--c-definition-soft); }
.fiche-partie--regle { --accent: var(--c-propriete); --accent-soft: var(--c-propriete-soft); }
.fiche-partie--methode { --accent: var(--c-methode); --accent-soft: var(--c-methode-soft); }
.fiche-partie--exemple { --accent: var(--c-exemple); --accent-soft: var(--c-exemple-soft); }
.fiche-partie--exercice { --accent: var(--c-exercice); --accent-soft: var(--c-exercice-soft); padding-bottom: 20px; }
.fiche-partie--exercice .questions { margin-top: 0; }
@media (max-width: 560px) {
  .fiche { font-size: calc(17px * var(--scale)); }
  .fiche-tete { padding: 14px 16px 10px; }
  .fiche-partie { padding: 10px 14px 12px; }
}

/* ---------- Exercise series (dist/<niveau>/<chapitre>/exercices.html) ----------
   A box holds one statement and nothing else. Corrections open in their own panel (.exo-volet),
   next to the box on a wide screen, under it otherwise. Three displays of the same exercises
   (.serie[data-vue]): "un" (one at a time, with the strip of numbers), "grille", "liste". */
main > .entete--serie { max-width: 860px; }
.entete--serie .intro p { margin: 0; color: var(--ink-soft); }
main > .serie { max-width: 1120px; margin-top: 20px; scroll-margin-top: 64px; }
.serie > * { max-width: 860px; margin-left: auto; margin-right: auto; }
/* The tick and the notion menu are drawn by the browser: in the page's theme */
.serie { color-scheme: light; }
:root[data-theme="dark"] .serie { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .serie { color-scheme: dark; } }
.js .serie-groupe { max-width: none; }
.js .serie-groupe > h2 { display: none; }
.serie .katex { font-size: 1.08em; }
.serie-groupe, .exo { scroll-margin-top: 64px; }
html:not(.js) :is(.serie-outils, .serie-palette, .serie-pages, .serie-suite, .exo-fait, .exo-actions, .exo-volet-fermer, .exo-ouvrir) { display: none; }

/* The bar: categories, then the filter, the counter and the display, then the strip of numbers */
.serie-categories { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--code-bg); }
.serie-categories a {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
}
.serie-categories a:hover { color: var(--ink); }
.serie-categories a[aria-current] { color: var(--ink); background: var(--surface); box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 20%, transparent); font-weight: 600; }
.serie-nb { font-size: 12.5px; font-weight: 500; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.serie-outils { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 14px; font-size: 13px; }
.serie-notion select {
  max-width: 260px;
  padding: 6px 8px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.serie-compteur { margin: 0; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.serie-vues { display: inline-flex; gap: 2px; margin-left: auto; }
.serie-vues button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
}
.serie-vues button:hover { color: var(--ink); }
.serie-vues button[aria-pressed="true"] { color: var(--ink); background: color-mix(in srgb, var(--ink) 9%, transparent); }
.icone { flex: none; width: 1em; height: 1em; }
.serie-vues .icone { width: 15px; height: 15px; }

.serie-palette { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.serie:not([data-vue="un"]) .serie-palette { display: none; }
.pastille {
  flex: none;
  width: 34px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: color-mix(in srgb, var(--ink-soft) 13%, var(--bg));
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.pastille--video { background: var(--c-video-soft); color: var(--c-video); }
.pastille:hover { border-color: currentColor; }
.pastille.fait { background: color-mix(in srgb, var(--ok) 18%, var(--surface)); color: var(--ok); }
.pastille[aria-current] { background: var(--ink); color: var(--bg); font-weight: 600; }
.pastille[aria-current].fait { background: var(--ok); color: var(--surface); }

/* The box */
.exo { max-width: 860px; margin: 22px auto 0; }
.exo[hidden], .serie-groupe[hidden], .pastille[hidden], .serie-suite[hidden] { display: none; }
.exo-boite {
  position: relative;
  min-width: 0;
  padding: 24px 30px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid color-mix(in srgb, var(--ink-soft) 45%, var(--line));
  border-radius: 12px;
  font-size: calc(19px * var(--scale));
}
.exo--video .exo-boite { border-color: color-mix(in srgb, var(--c-video) 32%, var(--line)); border-left-color: var(--c-video); }
.exo { --accent: var(--ink-soft); --accent-soft: var(--code-bg); }
.exo--video { --accent: var(--c-video); --accent-soft: var(--c-video-soft); }
.exo-tete { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.exo-num {
  flex: none;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.exo-titre { flex: 1; min-width: 0; margin: 3px 0 0; font: 500 calc(16px * var(--scale))/1.5 "Inter", system-ui, sans-serif; color: var(--ink-soft); }
.exo-fait {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font: 500 13px/1.6 "Inter", system-ui, sans-serif;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
.exo-fait input { width: 16px; height: 16px; margin: 0; accent-color: var(--ok); cursor: pointer; }
.exo-fait:hover, .exo.fait .exo-fait { color: var(--ink); }
.exo.fait .exo-num { background: color-mix(in srgb, var(--ok) 16%, var(--surface)); color: var(--ok); }
.exo-questions { list-style: none; margin: 8px 0 0; padding: 0; }
.exo-q, .exo-resultats > li { display: flex; align-items: baseline; gap: .5em; }
.exo-q > .enonce, .exo-resultats > li > div { flex: 1; min-width: 0; }
.exo-q + .exo-q { margin-top: 6px; }
.exo-q--sous { padding-left: 1.7em; }
.exo-n { flex: none; min-width: 1.6em; font: 600 .82em "Inter", system-ui, sans-serif; color: var(--accent); font-variant-numeric: tabular-nums; }
.exo-pied { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 16px; margin-top: 18px; font: 12.5px/1.6 "Inter", system-ui, sans-serif; color: var(--ink-soft); }
.exo-pied p { margin: 0; }
.exo-source strong { font-weight: 500; }
.exo-note { display: inline-flex; align-items: center; gap: 5px; color: var(--c-video); }
.exo-note .icone { width: 11px; height: 11px; }
.exo-ouvrir { position: absolute; inset: 0; border-radius: 12px; }
.serie[data-vue="un"] .exo-ouvrir { display: none; }

/* Under the box: what the student may open */
.exo-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.js .serie:not([data-vue="un"]) :is(.exo-actions, .exo-volet, .exo-fait, .exo-source) { display: none; }
.exo-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font: 500 13.5px "Inter", system-ui, sans-serif;
  color: var(--ink);
  cursor: pointer;
}
.exo-action:hover { border-color: var(--ink-soft); }
.exo-action[aria-expanded="true"] { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.exo-action--video .icone { color: var(--c-video); }
.exo-action--video[aria-expanded="true"] { border-color: var(--c-video); background: var(--c-video); color: var(--surface); }
.exo-action--video[aria-expanded="true"] .icone { color: inherit; }

/* The panel: always outside the box, in the answer tint */
.exo-volet {
  min-width: 0;
  margin-top: 14px;
  padding: 16px 20px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--reponse-bg);
  font-size: calc(17px * var(--scale));
  scroll-margin: 64px 0 16px;
}
.js .exo-volet:not(.ouvert) { display: none; }
.exo-volet-tete { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.exo-volet-tete h4 { margin: 0; font: 600 14px/1.5 "Inter", system-ui, sans-serif; }
.exo-volet--video h4 { color: var(--c-video); }
.exo-volet-fermer { flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 999px; background: none; font: 14px "Inter", system-ui, sans-serif; color: var(--ink-soft); cursor: pointer; }
.exo-volet-fermer:hover { background: var(--line); color: var(--ink); }
.exo-volet-aide { margin: 0 0 8px; font-size: 13px; color: var(--ink-soft); }
.exo-fiches { margin: 0; }
.exo-fiches .puce { max-width: 100%; background: var(--surface); }
.exo-texte { font-family: "Source Serif 4", Georgia, serif; line-height: 1.95; }
.exo-texte p { margin: 0 0 .2em; }
.exo-resultats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.exo-texte .exo-methode { font: 13px/1.6 "Inter", system-ui, sans-serif; color: var(--ink-soft); }
.exo-livre-ref { margin: 12px 0 0; font: 12.5px/1.5 "Inter", system-ui, sans-serif; color: var(--ink-soft); }
/* Wide screen: statement on the left, panel on the right. The one that is read against the other
   stays in view: the video next to a long statement, the statement next to a long correction. */
@media (min-width: 1000px) {
  .exo[data-ouvert] { max-width: none; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 20px; align-items: start; }
  .exo[data-ouvert] > .exo-volet { margin-top: 0; }
  .exo[data-ouvert="video"] > .exo-volet, .exo[data-ouvert]:not([data-ouvert="video"]) > .exo-principal {
    position: sticky;
    top: 64px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }
}

/* The video panel: the card's video window, with a large thumbnail that the player replaces */
.exo-volet .videos { max-width: none; }
.exo-volet .video-role, .exo-volet .video-lecteur-titre { display: none; }
.exo-volet .video-item.en-lecture .video-vignette { display: none; }
.exo-volet .video-instant { color: var(--c-video); }
/* The whole title (YouTube: 100 characters at most): clamped short, an Arabic title is cut mid-run. */
.exo-volet .video-meta { -webkit-line-clamp: 4; }
.exo-volet .video-lecteur { margin: 0 0 4px; }
.video-sauts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 0; font: 13px "Inter", system-ui, sans-serif; }
.video-sauts-titre { color: var(--ink-soft); font-weight: 500; margin-right: 2px; }
.video-saut {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  white-space: nowrap;
}
.video-saut small { font-size: 11.5px; font-weight: 500; color: var(--ink-soft); }
.video-saut:hover, .video-saut.actif { border-color: var(--c-video); color: var(--c-video); }

/* Previous / next exercise, and the pages of the grid */
.serie-suite { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; }
.serie:not([data-vue="un"]) .serie-suite { display: none; }
.serie-suite button, .serie-pages button {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font: 500 14px "Inter", system-ui, sans-serif;
  color: var(--ink);
  cursor: pointer;
}
.serie-suite button:hover:enabled, .serie-pages button:hover { border-color: var(--ink-soft); }
.serie-suite button:disabled { opacity: .4; cursor: default; }
.serie-pages { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 20px; }
.serie-pages:empty { display: none; }
.serie-pages button { min-width: 38px; padding: 7px 10px; font-variant-numeric: tabular-nums; }
.serie-pages button[aria-current] { border-color: var(--ink); background: var(--ink); color: var(--bg); }

/* Grid: the statements side by side; a click opens one */
.serie[data-vue="grille"] .serie-groupe { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; margin-top: 20px; }
.serie[data-vue="grille"] .serie-groupe[hidden] { display: none; }
.serie[data-vue="grille"] .exo { width: 100%; margin: 0; }
.serie[data-vue="grille"] .exo-principal { height: 100%; }
.serie[data-vue="grille"] .exo-boite { height: 100%; display: flex; flex-direction: column; padding: 14px 18px 12px; font-size: calc(16px * var(--scale)); }
.serie[data-vue="grille"] .exo-tete { margin-bottom: 6px; }
.serie[data-vue="grille"] .exo-titre { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.serie[data-vue="grille"] .exo-enonce { max-height: 11em; overflow: hidden; }
.serie[data-vue="grille"] .exo-enonce .enonce { line-height: 1.8; }
.serie[data-vue="grille"] .exo-enonce.deborde { -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.serie[data-vue="grille"] .exo-enonce :is(p, .enonce, .katex-display) { overflow: hidden; }
.serie[data-vue="grille"] .exo-pied { position: absolute; top: 18px; right: 18px; margin: 0; }
.serie[data-vue="grille"] .exo-note-plus { display: none; }
.serie[data-vue="grille"] .exo-note-mot { text-transform: capitalize; }
.serie[data-vue="grille"] .exo-boite:hover { border-color: var(--accent); }

/* List: one line per exercise, in two columns on a wide screen */
.serie[data-vue="liste"] .serie-groupe { columns: 2 380px; column-gap: 16px; margin-top: 20px; }
.serie[data-vue="liste"] .exo { max-width: none; margin: 0; break-inside: avoid; border-bottom: 1px solid var(--line); }
.serie[data-vue="liste"] .exo-boite { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border: 0; border-radius: 8px; background: none; font-size: 15px; }
.serie[data-vue="liste"] .exo-boite:hover { background: var(--surface); }
.serie[data-vue="liste"] .exo-tete { flex: 1; min-width: 0; align-items: center; margin: 0; }
.serie[data-vue="liste"] .exo-titre { margin: 0; font-size: calc(14px * var(--scale)); line-height: 1.45; color: var(--ink); }
.serie[data-vue="liste"] .exo-num { min-width: 34px; height: 26px; font-size: 13px; }
.serie[data-vue="liste"] .exo-enonce { display: none; }
.serie[data-vue="liste"] .exo-pied { margin: 0; }
.serie[data-vue="liste"] .exo-note-texte { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 560px) {
  main > .serie, .serie-groupe, .exo { scroll-margin-top: 88px; } /* the top bar takes two lines */
  .exo-volet { scroll-margin-top: 88px; }
  main > .serie { margin-top: 14px; }
  .serie-categories a { padding: 8px 7px; font-size: 13px; }
  .serie-categories:has(a:nth-child(4)) { display: grid; grid-template-columns: 1fr 1fr; }
  .serie-nb { display: none; }
  /* The notion menu and the three displays (icons) on one line, the counter under them */
  .serie-outils { gap: 6px 8px; margin-top: 10px; }
  .serie-notion { flex: 1 1 0; min-width: 0; }
  .serie-notion select { width: 100%; max-width: none; }
  .serie-compteur { order: 1; flex-basis: 100%; font-size: 12.5px; }
  .serie-vues button { padding: 9px 10px; }
  .serie-vues .icone { width: 17px; height: 17px; }
  .serie-vues button > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .serie-palette { margin-top: 8px; }
  /* The strip of numbers stays on one line that slides */
  .serie-palette { flex-wrap: nowrap; overflow-x: auto; margin-left: -16px; margin-right: -16px; padding: 2px 16px 6px; scrollbar-width: none; }
  .serie-palette::-webkit-scrollbar { display: none; }
  .pastille { width: 38px; height: 36px; }
  .exo { margin-top: 14px; }
  .exo-boite { padding: 16px 16px 12px; font-size: calc(17px * var(--scale)); }
  .exo-volet { padding: 12px 14px 14px; font-size: calc(16px * var(--scale)); }
  .exo-q--sous { padding-left: 1em; }
  .exo-action { flex: 1 1 auto; justify-content: center; }
  .serie-suite button { flex: 1; }
  .serie[data-vue="liste"] .serie-groupe { columns: 1; }
}

/* Control page of the series (dist/<niveau>/revue-exercices.html) */
.revue h3 code { margin-left: 6px; font: 400 12px ui-monospace, Consolas, monospace; color: var(--ink-soft); overflow-wrap: anywhere; }
.revue-exo { margin-top: 26px; padding-top: 4px; border-top: 1px solid var(--line); }
.revue-exo h3.revue-notion { margin-top: 14px; }
.revue-exo .revue-meta code { font: 12px ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.revue-enonce { margin: 8px 0; font-size: 17px; }

/* Série : les énoncés sont recopiés tels quels, donc parfois longs. Une formule trop large défile
   dans sa ligne ; la page, elle, ne défile jamais de côté. */
.exo .katex-display, .revue-exo .katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.exo-enonce p, .exo-texte p, .exo-q > .enonce, .exo-resultats > li > div, .revue-exo p { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
