/* ==========================================================================
   WEB-MATH v2 — Feuille de style principale
   Système : variables → base → en-tête → mise en page → navigation latérale
   → page chapitre (onglets, sommaire) → contenu → encadrés → exercices
   → corrections → pages niveau & accueil → recherche → impression
   ========================================================================== */

:root {
  --lc: #1565C0;            /* couleur du niveau (surchargée par page) */
  --lc-soft: #E3F2FD;
  --ink: #1b2430;
  --ink-2: #4a5566;
  --ink-3: #6b7685;
  --line: #e3e8ef;
  --line-2: #cfd7e2;
  --bg: #f6f8fb;
  --paper: #ffffff;
  --ok: #1e8e4e;
  --ok-soft: #e6f6ec;
  --warn: #c2410c;
  --warn-soft: #fff1e8;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --info: #1d4ed8;
  --info-soft: #eaf1ff;
  --tip: #a16207;
  --tip-soft: #fff8e1;
  --violet: #6d28d9;
  --violet-soft: #f3edff;
  --teal: #0f766e;
  --teal-soft: #e6f7f5;
  --r: 12px;
  --r-sm: 8px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 10px 30px rgba(16,24,40,.12);
  --hd-h: 60px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs: 17px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--hd-h) + 70px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: var(--fs); line-height: 1.7;
  color: var(--ink); background: var(--bg);
}
body.lv-6eme, body.lv-5eme { --fs: 18px; }
a { color: var(--lc); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--lc) 55%, white); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- En-tête ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50; height: var(--hd-h);
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.site-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--lc); }
.hd-inner { height: 100%; max-width: 1440px; margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 0 16px; }
.menu-btn {
  display: none; border: 1px solid var(--line-2); background: var(--paper); border-radius: var(--r-sm);
  width: 42px; height: 42px; align-items: center; justify-content: center; font-size: 20px; color: var(--ink);
}
.logo { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 800; font-size: 18px; white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo-icon { font-size: 22px; }
.logo-txt em { font-style: normal; color: var(--ink-3); font-weight: 600; }
.lv-nav { display: flex; gap: 6px; margin-left: 8px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.lv-nav::-webkit-scrollbar { display: none; }
.lvpill {
  --c: var(--lc); padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 700;
  color: var(--c); background: color-mix(in srgb, var(--c) 10%, white); white-space: nowrap;
  border: 1.5px solid transparent;
}
.lvpill:hover { text-decoration: none; border-color: color-mix(in srgb, var(--c) 40%, white); }
.lvpill.active { background: var(--c); color: #fff; }
.lv-select { display: none; }
.srch-btn {
  margin-left: auto; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-2);
  background: var(--bg); color: var(--ink-2); border-radius: 999px; padding: 7px 14px; font-size: 14px;
}
.srch-btn:hover { border-color: var(--lc); color: var(--ink); }
.srch-kbd { font: 12px/1 var(--font); background: var(--paper); border: 1px solid var(--line-2); border-radius: 5px; padding: 3px 6px; color: var(--ink-3); }

/* ---------- Mise en page ---------- */
.page-wrap { max-width: 1440px; margin: 0 auto; display: grid; grid-template-columns: 1fr; }
.page-wrap.has-sidebar { grid-template-columns: 290px minmax(0, 1fr); }
.main { min-width: 0; padding: 24px 32px 64px; }
.content { max-width: 860px; margin: 0 auto; }
.breadcrumb { max-width: 860px; margin: 0 auto 14px; font-size: 14px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.breadcrumb a { color: var(--ink-3); }
.breadcrumb .sep { color: var(--line-2); }

/* ---------- Navigation latérale (chapitres) ---------- */
.sidebar {
  position: sticky; top: var(--hd-h); height: calc(100vh - var(--hd-h)); overflow-y: auto;
  background: var(--paper); border-right: 1px solid var(--line); padding-bottom: 24px;
  scrollbar-width: thin;
}
.sidebar-hd { padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.sidebar-hd a { color: var(--ink); }
.sidebar-label { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 800; color: var(--lc); }
.sidebar-cycle { display: block; color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.lv-badge, .lv-badge-lg { font-size: 11px; font-weight: 800; letter-spacing: .04em; padding: 2px 7px; border-radius: 6px; background: var(--lc); color: #fff; }
.lv-badge-lg { font-size: 13px; vertical-align: middle; background: rgba(255,255,255,.22); }
.nav-group { padding: 14px 10px 4px; }
.nav-group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--ink-3); padding: 0 10px 6px; }
.sidebar-list { list-style: none; margin: 0; padding: 0; }
.sidebar-item a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 15px; line-height: 1.35;
}
.sidebar-item a:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.sidebar-item.active a { background: var(--lc-soft); color: var(--lc); font-weight: 700; }
.nav-num {
  flex: 0 0 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; color: var(--lc); background: color-mix(in srgb, var(--lc) 10%, white);
  position: relative;
}
.nav-num.done { background: var(--ok); color: #fff; }
.nav-prog { margin-left: auto; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.nav-overlay { display: none; }

/* ---------- Page chapitre ---------- */
.ch-head { margin-bottom: 18px; }
.ch-kicker { font-size: 14px; font-weight: 700; color: var(--lc); text-transform: uppercase; letter-spacing: .05em; }
.ch-title { font-size: clamp(26px, 3.4vw, 36px); line-height: 1.2; margin: 4px 0 10px; }
.ch-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--ink-3); font-size: 14px; align-items: center; }
.prog-bar { flex: 1 1 160px; max-width: 260px; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.prog-bar > span { display: block; height: 100%; width: 0; background: var(--ok); border-radius: inherit; transition: width .3s; }

.ch-tabs {
  position: sticky; top: var(--hd-h); z-index: 20; display: flex; gap: 4px; padding: 8px 0;
  background: var(--bg); border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; scrollbar-width: none;
}
.ch-tabs::-webkit-scrollbar { display: none; }
.ch-tab {
  border: 0; background: transparent; color: var(--ink-2); font-weight: 700; font-size: 15px;
  padding: 9px 16px; border-radius: 999px; white-space: nowrap; display: flex; align-items: center; gap: 7px;
}
.ch-tab:hover { background: var(--paper); color: var(--ink); }
.ch-tab[aria-selected="true"] { background: var(--lc); color: #fff; box-shadow: var(--shadow); }
.ch-tab .count { font-size: 12px; background: rgba(0,0,0,.08); padding: 1px 7px; border-radius: 99px; }
.ch-tab[aria-selected="true"] .count { background: rgba(255,255,255,.25); }
.ch-panel[hidden] { display: none; }

.ch-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; }
.page-toc { display: none; }
@media (min-width: 1320px) {
  .ch-layout.with-toc { grid-template-columns: minmax(0, 1fr) 220px; max-width: 1110px; }
  .ch-layout.with-toc .page-toc { display: block; }
}
.page-toc { position: sticky; top: calc(var(--hd-h) + 72px); align-self: start; font-size: 14px; }
.page-toc-title { font-weight: 800; color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.page-toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.page-toc a { display: block; padding: 5px 0 5px 12px; margin-left: -2px; border-left: 2px solid transparent; color: var(--ink-3); line-height: 1.35; }
.page-toc a:hover { color: var(--ink); text-decoration: none; }
.page-toc a.current { color: var(--lc); border-left-color: var(--lc); font-weight: 700; }

.ch-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 48px; }
.ch-nav a { display: block; padding: 14px 18px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); }
.ch-nav a:hover { border-color: var(--lc); text-decoration: none; }
.ch-nav small { display: block; color: var(--ink-3); font-size: 13px; }
.ch-nav .next { text-align: right; grid-column: 2; }
.panel-cta { margin-top: 36px; padding: 18px 20px; border-radius: var(--r); background: var(--lc-soft); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 10px 18px;
  background: var(--lc); color: #fff; font-weight: 700; font-size: 15px;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn.ghost { background: var(--paper); color: var(--ink); border: 1px solid var(--line-2); }

/* ---------- Contenu rédigé ---------- */
.content h1 { font-size: 30px; line-height: 1.25; }
.prose h2 { font-size: 24px; line-height: 1.3; margin: 40px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--lc-soft); }
.prose h3 {
  font-size: 21px; line-height: 1.35; margin: 36px 0 12px; display: flex; gap: 10px; align-items: baseline;
}
.prose h3 .h-num { flex: 0 0 auto; color: #fff; background: var(--lc); border-radius: 8px; font-size: 15px; padding: 1px 9px; }
.prose h4 { font-size: 18px; margin: 26px 0 8px; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 1.4em; }
.prose li { margin: 4px 0; }
.prose strong { color: var(--ink); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.prose table { border-collapse: collapse; width: 100%; margin: 16px 0 22px; background: var(--paper); border-radius: var(--r-sm); overflow: hidden; font-size: 16px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; vertical-align: top; }
.prose th { background: var(--lc-soft); color: var(--ink); font-weight: 700; }
.prose tr:nth-child(even) td { background: #fafbfd; }
.prose blockquote { margin: 18px 0; padding: 12px 16px; border-left: 4px solid var(--line-2); background: var(--paper); border-radius: 0 var(--r-sm) var(--r-sm) 0; color: var(--ink-2); }
.prose blockquote > :last-child { margin-bottom: 0; }
.prose code { background: #eef2f7; border-radius: 5px; padding: 1px 6px; font-size: .92em; }
.prose pre code { background: none; padding: 0; border-radius: 0; font-size: inherit; }
.headerlink { display: none; }

/* Formules : jamais de flèches de défilement parasites */
.math-display { display: block; overflow-x: auto; overflow-y: hidden; margin: 14px 0; padding: 2px 0; scrollbar-width: thin; }
.katex-display { margin: .4rem 0 !important; overflow-x: auto; overflow-y: hidden; }
.katex { font-size: 1.08em; }
/* Fractions en ligne : un peu d'air pour qu'elles ne touchent pas la ligne voisine */
.katex .base { margin: 3px 0; }
.prose li + li { margin-top: 4px; }
body.lv-6eme .katex, body.lv-5eme .katex { font-size: 1.12em; }

/* Figures */
figure { margin: 22px 0; padding: 16px 16px 10px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); text-align: center; }
figure svg { height: auto; max-width: 100%; }
figure.fig-custom svg { font-family: var(--font); }
figure.fig-custom figcaption { font-style: normal; color: var(--ink-2); font-size: 14px; }
figcaption { font-size: 13px; color: var(--ink-3); margin-top: 8px; font-style: italic; }
figure.no-caption figcaption { display: none; }

/* ---------- Encadrés pédagogiques ---------- */
.callout {
  --cc: var(--info); --cs: var(--info-soft);
  margin: 20px 0; padding: 14px 18px 14px 16px; border-radius: var(--r); background: var(--cs);
  border: 1px solid color-mix(in srgb, var(--cc) 22%, white); border-left: 5px solid var(--cc); color: var(--ink);
}
.callout > :last-child { margin-bottom: 0; }
.callout-title { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--cc); margin-bottom: 6px; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; }
.callout-title .katex { text-transform: none; letter-spacing: 0; }
.callout.retenir    { --cc: var(--info);   --cs: var(--info-soft); }
.callout.definition { --cc: var(--lc);     --cs: var(--lc-soft); }
.callout.propriete  { --cc: var(--teal);   --cs: var(--teal-soft); }
.callout.methode    { --cc: var(--ok);     --cs: var(--ok-soft); }
.callout.exemple    { --cc: var(--ink-2);  --cs: #f2f4f8; }
.callout.astuce     { --cc: var(--tip);    --cs: var(--tip-soft); }
.callout.attention  { --cc: var(--danger); --cs: var(--danger-soft); }
.callout.plusloin   { --cc: var(--violet); --cs: var(--violet-soft); }
.callout.bientot    { --cc: var(--teal);   --cs: var(--teal-soft); border-style: dashed; border-left-style: solid; }
details.callout > summary { list-style: none; cursor: pointer; }
details.callout > summary::-webkit-details-marker { display: none; }
details.callout > summary .callout-title { margin: 0; }
details.callout > summary .callout-title::after { content: "Afficher ▾"; margin-left: auto; font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--ink-3); }
details.callout[open] > summary .callout-title::after { content: "Masquer ▴"; }
details.callout[open] > summary { margin-bottom: 8px; }

/* ---------- Fiche mémo ---------- */
.memo-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.memo-head p { margin: 0; color: var(--ink-3); }

/* ---------- Exercices ---------- */
.exo-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-bottom: 20px;
}
.exo-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--line-2); background: var(--paper); color: var(--ink-2); border-radius: 999px;
  padding: 6px 13px; font-size: 14px; font-weight: 700;
}
.chip:hover { border-color: var(--lc); }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.l1[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); }
.chip.l2[aria-pressed="true"] { background: #b45309; border-color: #b45309; }
.chip.l3[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); }
.exo-score { font-size: 14px; color: var(--ink-3); font-weight: 600; }

.lvl-heading { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 800; margin: 30px 0 14px; color: var(--ink); }
.lvl-heading .dot { width: 12px; height: 12px; border-radius: 50%; }
.lvl-heading.l1 .dot { background: var(--ok); }
.lvl-heading.l2 .dot { background: #d97706; }
.lvl-heading.l3 .dot { background: var(--danger); }
.lvl-heading small { font-weight: 600; color: var(--ink-3); font-size: 14px; }

.exercise-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); margin: 0 0 16px;
  box-shadow: var(--shadow); overflow: hidden; scroll-margin-top: calc(var(--hd-h) + 70px);
}
.exercise-card.done { border-color: color-mix(in srgb, var(--ok) 45%, white); }
.exercise-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); background: #fbfcfe;
}
.exo-num { font-weight: 800; color: var(--lc); }
.exo-sep { color: var(--line-2); }
.exo-title { font-weight: 600; color: var(--ink-2); }
.lvl-tag { margin-left: auto; font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.lvl-tag.l1 { background: var(--ok-soft); color: var(--ok); }
.lvl-tag.l2 { background: #fff4e0; color: #b45309; }
.lvl-tag.l3 { background: var(--danger-soft); color: var(--danger); }
.exercise-body { padding: 14px 18px 4px; }
.exercise-body > :last-child { margin-bottom: 12px; }
.exercise-body p { margin: 0 0 10px; }
.exercise-body p.subq { margin: 0 0 4px; padding-left: 6px; }
.annexe-toc { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 18px; margin: 0 0 18px; }
.annexe-toc ol { margin: 0; padding-left: 20px; columns: 2 260px; column-gap: 28px; }
.annexe-toc li { break-inside: avoid; padding: 2px 0; }
.annexe-toc .count { font-size: 12px; color: var(--ink-3); }
.prose h2.annexe-topic { scroll-margin-top: calc(var(--hd-h) + 16px); }
.exercise-body p.subq + p:not(.subq) { margin-top: 10px; }
.exercise-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 0 16px 14px; }
.done-btn {
  border: 1.5px solid var(--line-2); background: var(--paper); color: var(--ink-2); border-radius: 999px;
  padding: 6px 13px; font-size: 14px; font-weight: 700;
}
.done-btn:hover { border-color: var(--ok); color: var(--ok); }
.done-btn[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }

/* Badges ★ (annales / annexes) */
.badge { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.badge-1 { background: var(--ok-soft); color: var(--ok); }
.badge-2 { background: #fff4e0; color: #b45309; }
.badge-3 { background: var(--danger-soft); color: var(--danger); }

/* ---------- Corrections ---------- */
.correction-details { flex: 1 1 100%; border-radius: var(--r-sm); border: 1px solid color-mix(in srgb, var(--ok) 30%, white); background: var(--paper); margin: 0 0 4px; }
.exercise-card .correction-details { margin: 0; }
.correction-summary {
  list-style: none; display: flex; align-items: center; gap: 10px; padding: 9px 14px; cursor: pointer;
  font-weight: 700; color: var(--ok); font-size: 15px; border-radius: var(--r-sm);
}
.correction-summary::-webkit-details-marker { display: none; }
.correction-summary:hover { background: var(--ok-soft); }
.corr-chevron { margin-left: auto; transition: transform .2s; font-size: 18px; }
.correction-details[open] .corr-chevron { transform: rotate(90deg); }
.correction-details[open] .correction-summary { border-bottom: 1px solid var(--line); border-radius: var(--r-sm) var(--r-sm) 0 0; background: var(--ok-soft); }
.correction-body { padding: 14px 18px 8px; font-size: .97em; }
.correction-body p { margin: 0 0 10px; }
.correction-body p.step-heading { margin-top: 16px; padding-top: 10px; border-top: 1px dashed var(--line); }
.correction-body p.step-heading:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.correction-body p.step-heading strong { color: var(--lc); }
.correction-toggle-bar { text-align: right; margin: 10px 0; }
.btn-toggle-all { border: 1px solid var(--line-2); background: var(--paper); border-radius: 999px; padding: 6px 14px; font-weight: 700; color: var(--ink-2); }
.pts-tag { font-size: 13px; font-weight: 800; color: var(--lc); background: var(--lc-soft); border-radius: 6px; padding: 1px 7px; }

/* Anciennes pages (annexes / animations) */
.section-heading { font-size: 22px; padding: 12px 18px; border-radius: var(--r); color: #fff; background: var(--lc); margin: 32px 0 18px; border: 0; }
.niveau-heading { font-size: 18px; }

/* ---------- Pages niveau ---------- */
.lv-banner { border-radius: 18px; padding: 30px 28px; color: #fff; background: var(--lc); margin-bottom: 24px; position: relative; overflow: hidden; }
.lv-banner::after { content: "∑ π √ ∞"; position: absolute; right: 24px; bottom: -10px; font-size: 88px; opacity: .12; font-weight: 800; letter-spacing: 12px; pointer-events: none; }
.lv-banner h1 { margin: 0 0 6px; font-size: clamp(26px, 4vw, 38px); }
.lv-banner p { margin: 0; opacity: .92; font-size: 17px; }
.lv-banner small { display: block; margin-top: 10px; opacity: .8; }
.lv-banner .prog-bar { background: rgba(255,255,255,.25); margin-top: 16px; max-width: 320px; }
.lv-banner .prog-bar > span { background: #fff; }
.lv-banner .prog-txt { font-size: 14px; opacity: .9; margin-top: 6px; }
.lv-section { margin: 30px 0; }
.lv-section h2 { font-size: 20px; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
.lv-section h2 .count { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.mod-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.mod-card {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); box-shadow: var(--shadow);
}
.mod-card:hover { text-decoration: none; border-color: var(--lc); transform: translateY(-1px); }
.mc-num { flex: 0 0 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; color: var(--lc); background: var(--lc-soft); }
.mc-body { flex: 1; min-width: 0; }
.mc-title { font-weight: 700; line-height: 1.3; }
.mc-meta { font-size: 13px; color: var(--ink-3); margin-top: 3px; }
.mc-prog { height: 5px; border-radius: 99px; background: var(--line); margin-top: 8px; overflow: hidden; }
.mc-prog > span { display: block; height: 100%; width: 0; background: var(--ok); }
.mc-arrow { color: var(--ink-3); font-size: 22px; }
.annale-card .mc-num { background: #fff4e0; color: #b45309; }
.extra-card .mc-num { background: var(--violet-soft); color: var(--violet); }

/* ---------- Accueil ---------- */
.home-page .main { padding-top: 32px; }
.home-page .content { max-width: 1100px; }
.hero { text-align: center; padding: 34px 16px 18px; }
.hero h1 { font-size: clamp(30px, 5vw, 48px); line-height: 1.15; margin: 0 0 12px; }
.hero h1 span { color: var(--info); }
.hero-sub { font-size: 19px; color: var(--ink-2); margin: 0 auto 8px; max-width: 640px; }
.hero-sub2 { font-size: 14px; color: var(--ink-3); margin: 0; }
.resume-box { max-width: 640px; margin: 18px auto 0; display: none; }
.resume-box.show { display: block; }
.resume-box a { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 12px 18px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line-2); color: var(--ink); font-weight: 600; }
.resume-box a:hover { border-color: var(--info); text-decoration: none; }
.home-section { margin: 34px 0; }
.home-section h2 { font-size: 22px; text-align: center; margin: 0 0 16px; }
.cycle-row { margin-bottom: 18px; }
.cycle-title { font-size: 13px; font-weight: 800; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 8px 4px; }
.lv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.lv-card {
  display: block; padding: 18px 18px 16px; border-radius: 16px; background: var(--paper); border: 1px solid var(--line);
  border-top: 5px solid var(--lc); color: var(--ink); box-shadow: var(--shadow); position: relative;
}
.lv-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.lvc-hd { display: flex; align-items: center; gap: 8px; }
.lvc-label { font-size: 26px; font-weight: 800; color: var(--lc); }
.lvc-desc { font-size: 15px; color: var(--ink-2); margin: 6px 0 10px; line-height: 1.45; }
.lvc-stats { font-size: 13px; color: var(--ink-3); }
.lvc-prog { height: 5px; border-radius: 99px; background: var(--line); margin-top: 10px; overflow: hidden; }
.lvc-prog > span { display: block; height: 100%; width: 0; background: var(--ok); }
.how-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.how-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.how-icon { font-size: 26px; }
.how-card h3 { margin: 8px 0 4px; font-size: 17px; }
.how-card p { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.5; }

/* ---------- Pied de page ---------- */
.site-footer { text-align: center; color: var(--ink-3); font-size: 14px; padding: 26px 16px 34px; border-top: 1px solid var(--line); background: var(--paper); }

/* ---------- Recherche ---------- */
.srch-modal { display: none; position: fixed; inset: 0; z-index: 100; }
.srch-modal.open { display: block; }
.srch-overlay { position: absolute; inset: 0; background: rgba(15,23,42,.45); }
.srch-panel { position: relative; max-width: 640px; margin: 10vh auto 0; background: var(--paper); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; width: calc(100% - 32px); }
.srch-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.srch-input { flex: 1; border: 0; outline: 0; font: inherit; font-size: 17px; padding: 6px 0; background: transparent; }
.srch-close { border: 0; background: var(--bg); border-radius: 8px; width: 32px; height: 32px; }
.srch-results { max-height: 55vh; overflow-y: auto; }
.srch-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 11px 16px; border-bottom: 1px solid var(--line); color: var(--ink); }
.srch-item:hover { background: var(--bg); text-decoration: none; }
.srch-badge { color: #fff; font-size: 12px; font-weight: 800; border-radius: 6px; padding: 1px 7px; }
.srch-title { font-weight: 700; }
.srch-sub { flex-basis: 100%; font-size: 14px; color: var(--ink-3); }
.srch-empty { padding: 16px; color: var(--ink-3); margin: 0; }
.srch-footer { padding: 9px 16px; font-size: 13px; color: var(--ink-3); background: var(--bg); }
.srch-footer kbd { border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; background: var(--paper); }

/* ---------- Code ---------- */
.highlight { border-radius: var(--r-sm); margin: 14px 0; overflow-x: auto; }
.highlight pre { margin: 0; padding: 14px 16px; font-size: 15px; line-height: 1.55; }

/* ---------- Mobile / tablette ---------- */
@media (max-width: 1080px) {
  .page-wrap.has-sidebar { grid-template-columns: 1fr; }
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed; z-index: 60; top: 0; left: 0; bottom: 0; height: 100vh; width: min(320px, 86vw);
    transform: translateX(-105%); transition: transform .25s ease; box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-overlay { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(15,23,42,.4); }
  body.nav-open { overflow: hidden; }
}
@media (max-width: 760px) {
  :root { --hd-h: 56px; }
  .main { padding: 16px 16px 48px; }
  .lv-nav { display: none; }
  .lv-select {
    display: block; border: 1px solid var(--line-2); border-radius: 999px; background: var(--paper); color: var(--ink);
    font: 600 14px var(--font); padding: 7px 10px;
  }
  .logo-txt em { display: none; }
  .srch-btn { padding: 8px 11px; }
  .srch-btn-txt, .srch-kbd { display: none; }
  .ch-tab { padding: 8px 13px; font-size: 14px; }
  .prose h3 { font-size: 19px; }
  .ch-nav { grid-template-columns: 1fr; }
  .ch-nav .next { grid-column: 1; }
  .exercise-body, .correction-body { padding-left: 14px; padding-right: 14px; }
  .lvl-tag { margin-left: 0; }
  .lv-banner::after { display: none; }
}

/* ---------- Grand public : accueil, examens, pages d'information ---------- */
.hero-brand { display: inline-block; font-weight: 800; font-size: 15px; letter-spacing: .02em; color: var(--info); background: #eaf1ff; border-radius: 999px; padding: 5px 14px; margin-bottom: 14px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 20px 0 14px; }
.resume-box a { flex-wrap: wrap; text-align: center; }
.home-section { scroll-margin-top: calc(var(--hd-h) + 12px); }
.lv-section { scroll-margin-top: calc(var(--hd-h) + 12px); }
.exam-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.exam-card { display: block; background: var(--paper); border: 1px solid var(--line); border-top: 4px solid var(--lc); border-radius: var(--r); padding: 20px; color: var(--ink); transition: transform .15s ease, box-shadow .15s ease; }
.exam-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.exam-card h3 { margin: 8px 0 4px; font-size: 19px; }
.exam-card p { margin: 0 0 10px; color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.exam-go { font-weight: 700; color: var(--lc); }
.parents { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; }
.parents h2 { margin-top: 0; }
.parents p { max-width: 720px; margin: 0 auto; color: var(--ink-2); line-height: 1.6; text-align: center; }
.info-page h2 { margin-top: 28px; }
.nf-code { font-size: clamp(64px, 14vw, 110px); font-weight: 800; line-height: 1; color: var(--line-2); }
.nf-levels { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.site-footer p { margin: 6px 0 0; }
.ft-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin-bottom: 10px; }
.ft-links a { color: var(--ink-2); font-weight: 600; }
.ft-copy { color: var(--ink-2); }
.ft-note { font-size: 13px; }
.contact-form { display: grid; gap: 6px; max-width: 560px; margin-top: 18px; }
.contact-form label { font-weight: 700; margin-top: 10px; }
.contact-form .opt { font-weight: 400; color: var(--ink-3); }
.contact-form input[type=text], .contact-form input[type=email], .contact-form textarea { width: 100%; box-sizing: border-box; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font: inherit; background: var(--paper); color: var(--ink); }
.contact-form input:focus, .contact-form textarea:focus { outline: 2px solid var(--lc); outline-offset: 1px; }
.contact-form .btn { justify-self: start; margin-top: 12px; }
.form-note { font-size: 14px; color: var(--ink-3); }
.form-ok { background: var(--ok-soft); color: var(--ok); border-radius: 10px; padding: 12px 14px; font-weight: 700; }
@media (max-width: 760px) {
  .hd-inner { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .logo { flex-shrink: 0; }
  .menu-btn ~ .logo .logo-txt { display: none; }
  .lv-select { flex: 1 1 auto; min-width: 0; width: 0; }
  .srch-btn { flex-shrink: 0; margin-left: 0; }
  .ch-tabs { gap: 4px; }
  .ch-tab { flex: 1 1 auto; justify-content: center; padding: 8px 8px; white-space: nowrap; }
  .ch-tab .count { display: none; }
  .hero-cta .btn { flex: 1 1 100%; text-align: center; justify-content: center; }
}

/* ---------- Impression ---------- */
@media print {
  :root { --fs: 12pt; }
  body { background: #fff; }
  .site-header, .sidebar, .nav-overlay, .ch-tabs, .page-toc, .ch-nav, .exo-toolbar, .exercise-actions .done-btn,
  .panel-cta, .breadcrumb, .site-footer, .srch-modal, .print-hide { display: none !important; }
  .page-wrap.has-sidebar { display: block; }
  .main { padding: 0; }
  .exercise-card, .callout, figure { break-inside: avoid; box-shadow: none; }
  .correction-details:not([open]) { display: none; }
  a { color: inherit; }
}

/* Le copyright reste visible sur les fiches imprimées */
@media print {
  .site-footer { display: block !important; border: 0; background: none; padding: 8px 0 0; }
  .ft-links, .ft-note { display: none !important; }
}

/* ─── Outils : calculateur de notes, défi automatismes, laboratoires ─────────── */
.outil-intro { font-size: 18px; color: var(--ink-2); }
.prose .calc-form, .prose .lab { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin: 16px 0 26px; }
.calc-colonnes { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 8px 24px; }
.calc-bloc h3 { display: block; font-size: 16px; margin: 0 0 8px; padding: 0; border: 0; color: var(--ink); }
.calc-bloc small { display: block; font-weight: 400; color: var(--ink-3); }
.calc-ligne { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 15px; }
.calc-ligne em { font-style: normal; color: var(--ink-3); font-size: 13px; white-space: nowrap; }
.calc-ligne input, .calc-ligne select { flex: 0 0 auto; border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 8px; font: inherit; background: var(--paper); color: var(--ink); }
.calc-ligne input { width: 72px; text-align: center; }
.calc-ligne input:focus, .calc-ligne select:focus { outline: 2px solid var(--lc); outline-offset: 1px; }
.calc-ligne input.calc-err { border-color: var(--danger); background: var(--danger-soft); }
.calc-option { flex: 1; display: flex; align-items: center; gap: 8px; }
.calc-resultat { margin-top: 16px; padding: 14px 16px; background: var(--info-soft); border-radius: var(--r-sm); }
.calc-resultat p { margin: 0 0 8px; }
.calc-resultat p:last-child { margin-bottom: 0; }
.calc-grand { font-size: 18px; }
.calc-alerte { color: var(--danger); font-size: 15px; }
.prose table.calc-table { display: table; margin: 8px 0 0; font-size: 15px; }
.calc-pill { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: 13px; font-weight: 700; }
.calc-pill.ok { background: var(--ok-soft); color: var(--ok); }
.calc-pill.non { background: var(--danger-soft); color: var(--danger); }
.calc-actions { margin-top: 10px; }

.defi { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; margin: 16px 0 26px; min-height: 220px; }
.prose h2.defi-titre { font-size: 20px; margin: 0 0 12px; padding: 0; border: 0; }
.prose h2.defi-titre:not(:first-child) { margin-top: 24px; }
.defi-classes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.defi-classe { display: block; text-align: left; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--paper); color: var(--ink); font: inherit; cursor: pointer; }
.defi-classe:hover { border-color: var(--lc); background: var(--lc-soft); }
.defi-classe strong { display: block; font-size: 18px; }
.defi-classe small { color: var(--ink-3); font-size: 12.5px; }
.defi-haut { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 14px; font-weight: 700; color: var(--ink-2); }
.defi-barre { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0 18px; }
.defi-barre span { display: block; height: 100%; background: var(--lc); }
.defi-question { font-size: 20px; line-height: 1.5; margin: 0 0 16px; }
.defi-form { display: flex; gap: 10px; flex-wrap: wrap; }
.defi-saisie { flex: 1 1 160px; min-width: 0; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font: inherit; background: var(--paper); color: var(--ink); }
.defi-saisie:focus { outline: 2px solid var(--lc); outline-offset: 1px; }
.defi-form .btn { border: 0; cursor: pointer; font: inherit; font-weight: 700; }
.defi-aide { font-size: 13.5px; color: var(--ink-3); margin: 8px 0 0; }
.defi-aide-err { color: var(--danger); font-size: 15px; margin: 8px 0 0; }
.defi-choix { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.defi-option { min-height: 46px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--paper); color: var(--ink); font: inherit; cursor: pointer; }
.defi-option:not(:disabled):hover { border-color: var(--lc); background: var(--lc-soft); }
.defi-option:disabled { cursor: default; color: var(--ink); }
.defi-option.bon { border-color: var(--ok); background: var(--ok-soft); }
.defi-option.faux { border-color: var(--danger); background: var(--danger-soft); }
.defi-correction { margin: 14px 0 12px; padding: 12px 14px; border-radius: var(--r-sm); }
.defi-correction.ok { background: var(--ok-soft); }
.defi-correction.non { background: var(--danger-soft); }
.defi-correction p { margin: 6px 0 0; }
.defi-suivant { border: 0; cursor: pointer; font: inherit; font-weight: 700; }
.defi-fin { text-align: center; }
.defi-note { font-size: 56px; font-weight: 800; line-height: 1.1; color: var(--lc); }
.defi-note small { font-size: 24px; color: var(--ink-3); }
.defi-temps-fin { font-weight: 700; margin: 4px 0 8px; }
.defi-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.defi-actions .btn { cursor: pointer; font: inherit; font-weight: 700; }
.defi-actions .btn:not(.ghost) { border: 0; }
.defi-partage { font-size: 14px; color: var(--ink-2); margin: 10px 0 0; overflow-wrap: anywhere; }
.defi-revoir { border-top: 1px solid var(--line); padding: 10px 0; }
.defi-revoir p { margin: 0 0 6px; }

.lab-corps { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; align-items: start; }
.lab-dessin svg { display: block; width: 100%; height: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); }
.lab-grille { stroke: #e6ebf2; stroke-width: 1; }
.lab-axe { stroke: var(--ink-2); stroke-width: 1.5; }
.lab-graduation { font-size: 11px; fill: var(--ink-3); }
.lab-courbe { stroke: var(--info); stroke-width: 3; }
.lab-sommet { fill: var(--danger); }
.lab-racine { fill: var(--ok); }
.lab-curseur { display: grid; grid-template-columns: 54px 1fr; align-items: center; gap: 8px; margin-bottom: 6px; font-weight: 700; }
.lab-curseur input { width: 100%; accent-color: var(--lc); }
.lab-formule { font-size: 20px; font-weight: 700; }
.lab-infos p { margin: 0 0 8px; font-size: 15.5px; }
.lab-boutons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.lab-boutons .btn { cursor: pointer; font: inherit; font-weight: 700; padding: 8px 14px; }
.lab-boutons .btn:not(.ghost) { border: 0; }
.lab-barres { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.lab-colonne { text-align: center; min-width: 0; }
.lab-pct { display: block; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.lab-rail { position: relative; height: 180px; background: var(--bg); border-radius: 6px; overflow: hidden; margin: 2px 0; }
.lab-rail::after { content: ""; position: absolute; left: 0; right: 0; bottom: 33.333%; border-top: 2px dashed var(--danger); }
.lab-remplie { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--info); opacity: .8; }
.lab-triangle { fill: var(--info-soft); stroke: var(--info); stroke-width: 2.5; stroke-linejoin: round; }
.lab-droit { stroke: var(--danger); stroke-width: 2; }
.lab-etiquette { font-size: 16px; font-weight: 700; fill: var(--ink); }
.lab-poignee { fill: var(--info); stroke: #fff; stroke-width: 3; cursor: grab; touch-action: none; }
.lab-poignee:active { cursor: grabbing; }
.lab-poignee:focus { outline: none; stroke: var(--ink); }
.lab-succes { background: var(--ok-soft); padding: 8px 12px; border-radius: var(--r-sm); }
