/* ==== Styles du site de révision : thème clair/sombre, mise en page, composants des fiches et des examens ==== */

/* ---------- Thème ---------- */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --surface-3: #e9e9e5;
  --ink: #1b1b1f;
  --ink-2: #4c4c55;
  --ink-3: #8b8b94;
  --line: #e4e4df;
  --line-2: #d4d4ce;
  --shadow: 0 1px 2px rgba(20, 20, 30, .04), 0 4px 16px rgba(20, 20, 30, .05);
  --shadow-lg: 0 2px 6px rgba(20, 20, 30, .05), 0 16px 40px rgba(20, 20, 30, .09);

  --c1: #2f6fed; --c2: #0f9f6e; --c3: #e08a00; --c4: #e0407b; --c5: #7c4ddb;
  --c1-soft: rgba(47, 111, 237, .10); --c2-soft: rgba(15, 159, 110, .10); --c3-soft: rgba(224, 138, 0, .11);
  --c4-soft: rgba(224, 64, 123, .10); --c5-soft: rgba(124, 77, 219, .10);

  --ok: #0f9f6e; --ok-soft: rgba(15, 159, 110, .12);
  --ko: #d93a3a; --ko-soft: rgba(217, 58, 58, .10);
  --warn: #d97f06;

  --accent: #2f6fed;
  --accent-soft: rgba(47, 111, 237, .10);
  --on-accent: #ffffff;

  --radius: 14px;
  --radius-sm: 9px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --header-h: 60px;
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e11; --surface: #17171b; --surface-2: #1e1e23; --surface-3: #27272d;
    --ink: #ececf0; --ink-2: #b4b4bd; --ink-3: #7c7c86; --line: #2a2a31; --line-2: #3a3a42;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 16px 40px rgba(0, 0, 0, .4);
    --c1: #6b9cff; --c2: #34c793; --c3: #f5a524; --c4: #f26b9e; --c5: #a585f5;
    --c1-soft: rgba(107, 156, 255, .14); --c2-soft: rgba(52, 199, 147, .13); --c3-soft: rgba(245, 165, 36, .13);
    --c4-soft: rgba(242, 107, 158, .13); --c5-soft: rgba(165, 133, 245, .14);
    --ok: #34c793; --ok-soft: rgba(52, 199, 147, .14); --ko: #f26363; --ko-soft: rgba(242, 99, 99, .13);
    --on-accent: #0e0e11;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e11; --surface: #17171b; --surface-2: #1e1e23; --surface-3: #27272d;
  --ink: #ececf0; --ink-2: #b4b4bd; --ink-3: #7c7c86; --line: #2a2a31; --line-2: #3a3a42;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 16px 40px rgba(0, 0, 0, .4);
  --c1: #6b9cff; --c2: #34c793; --c3: #f5a524; --c4: #f26b9e; --c5: #a585f5;
  --c1-soft: rgba(107, 156, 255, .14); --c2-soft: rgba(52, 199, 147, .13); --c3-soft: rgba(245, 165, 36, .13);
  --c4-soft: rgba(242, 107, 158, .13); --c5-soft: rgba(165, 133, 245, .14);
  --ok: #34c793; --ok-soft: rgba(52, 199, 147, .14); --ko: #f26363; --ko-soft: rgba(242, 99, 99, .13);
  --on-accent: #0e0e11;
  color-scheme: dark;
}

/* Couleur propre à chaque matière (posée sur <body data-subject>) */
[data-subject="maths"]   { --accent: var(--c1); --accent-soft: var(--c1-soft); }
[data-subject="eco"]     { --accent: var(--c2); --accent-soft: var(--c2-soft); }
[data-subject="gestion"] { --accent: var(--c3); --accent-soft: var(--c3-soft); }
[data-subject="stats"]   { --accent: var(--c4); --accent-soft: var(--c4-soft); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.62 var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  min-height: 100vh; min-height: 100dvh;
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.25; letter-spacing: -.015em; margin: 0; }
p { margin: 0 0 .8em; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- En-tête ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: calc(var(--header-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 650; font-size: 17px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 750;
  background: linear-gradient(135deg, #2f6fed, #7c4ddb 55%, #e0407b);
}
.topnav { display: flex; gap: 2px; margin-left: 18px; }
.topnav a {
  color: var(--ink-2); font-size: 14.5px; font-weight: 520; padding: 7px 12px; border-radius: 999px;
}
.topnav a:hover { text-decoration: none; background: var(--surface-2); color: var(--ink); }
.topnav a.active { color: var(--ink); background: var(--surface-3); }
.topbar-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 999px; border: 0; background: transparent; color: var(--ink-2);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.read-progress { position: absolute; left: 0; bottom: -1px; height: 2px; background: var(--accent); width: 0; transition: width .1s linear; }

/* Barre d'onglets du bas (mobile) */
.tabbar { display: none; }
@media (max-width: 760px) {
  .topnav { display: none; }
  .tabbar {
    display: flex; position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--line);
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--ink-3); font-size: 11px; font-weight: 560;
  }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a svg { width: 23px; height: 23px; }
  .tabbar a.active { color: var(--accent); }
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
}

/* ---------- Mise en page ---------- */
.main { padding: 8px max(16px, env(safe-area-inset-left)) 64px; }
.wrap { max-width: 1080px; margin: 0 auto; }
.wrap-narrow { max-width: 760px; margin: 0 auto; }
.view { animation: viewIn .35s cubic-bezier(.2, .7, .2, 1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head { padding: 28px 0 22px; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.page-head h1 { font-size: clamp(28px, 4.5vw, 40px); font-weight: 720; letter-spacing: -.025em; }
.page-head .sub { color: var(--ink-2); font-size: 17px; margin-top: 8px; max-width: 640px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; color: var(--ink-3); margin-bottom: 14px; }
.crumbs a { color: var(--ink-2); }
.crumbs span.sep { opacity: .5; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 36px 0 14px; }
.section-title h2 { font-size: 20px; font-weight: 680; }
.section-title .more { font-size: 14px; color: var(--ink-3); }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
a.card { display: block; color: inherit; transition: transform .18s ease, box-shadow .18s ease, border-color .18s; }
a.card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--line-2); }

/* Carte matière */
.subject-card { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 14px; min-height: 190px; }
.subject-card .s-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.subject-card .s-icon svg { width: 24px; height: 24px; }
.subject-card h3 { font-size: 19px; font-weight: 680; }
.subject-card .meta { font-size: 13.5px; color: var(--ink-3); }
.subject-card .bottom { margin-top: auto; display: flex; align-items: center; gap: 12px; }
.subject-card::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%;
  background: var(--accent-soft); opacity: .6; pointer-events: none;
}

/* Barres et anneaux de progression */
.bar { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .8s cubic-bezier(.2, .7, .2, 1); }
.pct { font-size: 13px; font-weight: 650; color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }
.ring { --p: 0; --size: 64px; width: var(--size); height: var(--size); position: relative; flex: none; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring .track { stroke: var(--surface-3); }
.ring .val { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.2, .7, .2, 1); }
.ring .label { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }

/* Bloc de bienvenue */
.hero { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; padding: 26px; }
.hero h1 { font-size: clamp(26px, 4vw, 36px); font-weight: 730; letter-spacing: -.025em; }
.hero p { color: var(--ink-2); margin: 8px 0 0; }
.hero .ring { --size: 104px; }
.hero .ring .label { font-size: 22px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 18px; }
.hero-stats div { font-size: 13px; color: var(--ink-3); }
.hero-stats b { display: block; font-size: 22px; color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
@media (max-width: 560px) { .hero { grid-template-columns: 1fr; } .hero .ring { display: none; } }

/* Listes (fiches, examens) */
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; color: inherit; border-top: 1px solid var(--line); transition: background .15s; }
.list-item:first-child { border-top: 0; }
a.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; font-size: 15.5px; }
.list-item .li-sub { font-size: 13.5px; color: var(--ink-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.list-item .li-right { display: flex; align-items: center; gap: 10px; flex: none; color: var(--ink-3); font-size: 13px; }
.list-item .chev { width: 16px; height: 16px; color: var(--ink-3); flex: none; }
.chapter-title { font-size: 13px; font-weight: 650; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin: 28px 2px 10px; }

.status-dot { width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center; border: 2px solid var(--line-2); color: transparent; }
.status-dot svg { width: 14px; height: 14px; }
.status-dot.st-vu { border-color: var(--accent); background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); background-size: 100% 100%; border-width: 2px; opacity: .8; }
.status-dot.st-vu { background: conic-gradient(var(--accent) 0 25%, transparent 25% 100%); }
.status-dot.st-revoir { border-color: var(--warn); background: conic-gradient(var(--warn) 0 50%, transparent 50% 100%); }
.status-dot.st-maitrise { border-color: var(--ok); background: var(--ok); color: #fff; }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.ko { background: var(--ko-soft); color: var(--ko); }
.tag.warn { background: var(--c3-soft); color: var(--warn); }
.score-pill { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; padding: 3px 9px; border-radius: 99px; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 15px; padding: 10px 18px; border-radius: 999px; cursor: pointer;
  transition: background .15s, transform .1s, border-color .15s, opacity .15s;
  -webkit-tap-highlight-color: transparent; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { font-size: 13.5px; padding: 7px 13px; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: var(--on-accent); }
.btn.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn svg { width: 17px; height: 17px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Segmented control (filtres) */
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 560; color: var(--ink-2); cursor: pointer; }
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

/* ---------- Page fiche ---------- */
.fiche-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 48px; max-width: 1120px; margin: 0 auto; }
@media (min-width: 1140px) { .fiche-layout { grid-template-columns: minmax(0, 760px) 240px; justify-content: center; } }
.toc { display: none; }
@media (min-width: 1140px) {
  .toc { display: block; position: sticky; top: calc(var(--header-h) + 28px); align-self: start; max-height: calc(100vh - var(--header-h) - 56px); overflow: auto; padding-top: 24px; }
}
.toc-title { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 10px; }
.toc a { display: block; font-size: 13.5px; color: var(--ink-3); padding: 5px 0 5px 12px; border-left: 2px solid var(--line); line-height: 1.35; }
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 560; }

.fiche-head { padding: 26px 0 8px; }
.fiche-head h1 { font-size: clamp(28px, 4.6vw, 40px); font-weight: 740; letter-spacing: -.028em; }
.fiche-head .meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.fiche-end { margin: 48px 0 0; padding: 22px; text-align: center; }
.fiche-end h3 { font-size: 18px; margin-bottom: 6px; }
.fiche-end p { color: var(--ink-2); font-size: 15px; }
.fiche-end .btn-row { justify-content: center; margin-top: 14px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.pager a { padding: 14px 16px; }
.pager .lbl { font-size: 12.5px; color: var(--ink-3); }
.pager .ttl { font-weight: 600; font-size: 15px; color: var(--ink); }
.pager .next { text-align: right; grid-column: 2; }

/* ---------- Contenu riche (fiches + examens) ---------- */
.prose { font-size: 16.5px; line-height: 1.7; }
.prose > * + * { margin-top: 0; }
.prose h2 { font-size: 25px; font-weight: 720; margin: 52px 0 16px; padding-top: 6px; letter-spacing: -.022em; }
.prose h3 { font-size: 19px; font-weight: 680; margin: 32px 0 10px; }
.prose h4 { font-size: 16.5px; font-weight: 680; margin: 22px 0 8px; }
.prose p, .prose ul, .prose ol { margin: 0 0 14px; }
.prose ul, .prose ol { padding-left: 1.35em; }
.prose li { margin: 4px 0; }
.prose li::marker { color: var(--ink-3); }
.prose strong, .prose b { font-weight: 650; }
.prose em { font-style: italic; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0; }
.prose code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
.prose blockquote { margin: 18px 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--line-2); color: var(--ink-2); font-style: italic; }
.prose .lead { font-size: 19px; line-height: 1.6; color: var(--ink-2); margin: 6px 0 22px; }
.prose mark { background: var(--c3-soft); color: inherit; padding: 0 3px; border-radius: 4px; }
.prose .katex { font-size: 1.07em; }
.prose .katex-display { margin: 14px 0; padding: 4px 2px; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }

/* Encadrés */
.box {
  --b: var(--ink-3); --bs: var(--surface-2);
  position: relative; margin: 20px 0; padding: 16px 18px 14px; border-radius: var(--radius-sm);
  background: var(--bs); border: 1px solid color-mix(in srgb, var(--b) 18%, transparent);
}
.box::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--b); }
.box > :last-child { margin-bottom: 0; }
.box-title { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .055em; color: var(--b); margin-bottom: 8px; display: block; line-height: 1.5; }
.box-title::before { content: ""; width: 15px; height: 15px; display: inline-block; vertical-align: -2px; margin-right: 7px; background: currentColor; -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
.box.def       { --b: var(--c1); --bs: var(--c1-soft); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 19.5V5a2 2 0 0 1 2-2h12v16H6a2 2 0 0 0-2 2zm0 0A2 2 0 0 0 6 22h12'/%3E%3C/svg%3E"); }
.box.thm       { --b: var(--c5); --bs: var(--c5-soft); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2l3 6.5 7 1-5 5 1.2 7L12 18l-6.2 3.5L7 14.5l-5-5 7-1z'/%3E%3C/svg%3E"); }
.box.formule   { --b: var(--c1); --bs: var(--surface); border: 1.5px solid color-mix(in srgb, var(--c1) 45%, transparent); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 4H6l7 8-7 8h12'/%3E%3C/svg%3E"); }
.box.methode   { --b: var(--c2); --bs: var(--c2-soft); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6h11M9 12h11M9 18h11M4 6h.01M4 12h.01M4 18h.01'/%3E%3C/svg%3E"); }
.box.exemple   { --b: var(--ink-3); --bs: var(--surface-2); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E"); }
.box.piege     { --b: var(--ko); --bs: var(--ko-soft); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9L1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0zM12 9v4M12 17h.01'/%3E%3C/svg%3E"); }
.box.astuce    { --b: var(--c3); --bs: var(--c3-soft); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6M10 22h4M12 2a7 7 0 0 0-4 12.7V17h8v-2.3A7 7 0 0 0 12 2z'/%3E%3C/svg%3E"); }
.box.intuition { --b: var(--c5); --bs: var(--c5-soft); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8S1 12 1 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E"); }
.box.eco       { --b: var(--c2); --bs: var(--c2-soft); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 17l6-6 4 4 8-8M14 7h7v7'/%3E%3C/svg%3E"); }
.box.exam      { --b: var(--c4); --bs: var(--c4-soft); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 10L12 5 2 10l10 5 10-5zM6 12v5c3 2 9 2 12 0v-5'/%3E%3C/svg%3E"); }
.box.objectifs { --b: var(--accent); --bs: var(--surface); border: 1px solid var(--line); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Ccircle cx='12' cy='12' r='6'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3C/svg%3E"); }
.box.resume    { --b: var(--accent); --bs: var(--accent-soft); padding: 20px 22px 18px; --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E"); }
.box.auteur    { --b: var(--c5); --bs: var(--surface); border: 1px solid var(--line); --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21a8 8 0 0 1 16 0'/%3E%3C/svg%3E"); }
.box.objectifs ul, .box.resume ul { margin-bottom: 0; }

/* Tableaux */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 18px 0; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.tbl-wrap > .tbl { margin: 0; border: 0; border-radius: 0; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; margin: 18px 0; font-size: 15px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.tbl th, .tbl td { padding: 9px 12px; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
.tbl tr:first-child th, .tbl tr:first-child td, .tbl thead + tbody tr:first-child td { border-top: 0; }
.tbl thead th, .tbl tr:first-child th { background: var(--surface-2); font-weight: 650; font-size: 13.5px; color: var(--ink-2); border-top: 0; }
.tbl thead + tbody tr:first-child td, .tbl thead + tbody tr:first-child th { border-top: 1px solid var(--line); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tfoot td, .tbl tr.total td, .tbl tr.total th { font-weight: 650; background: var(--surface-2); }
.tbl .hl { background: var(--accent-soft); }
@media (max-width: 600px) { .tbl { font-size: 14px; } .tbl th, .tbl td { padding: 7px 8px; } }

/* Tableau de variations */
.tv { border-collapse: collapse; margin: 20px auto; font-size: 15px; background: var(--surface); border: 1.5px solid var(--ink-2); min-width: min(100%, 420px); }
.tv th, .tv td { border: 1px solid var(--line-2); padding: 8px 12px; text-align: center; min-width: 46px; }
.tv th { border-right: 1.5px solid var(--ink-2); background: var(--surface-2); font-weight: 600; }
.tv tr { border-bottom: 1.5px solid var(--ink-2); }
.tv td { border-left-color: transparent; border-right-color: transparent; }
.tv tr.var td { height: 76px; position: relative; }
.tv td.hi { vertical-align: top; }
.tv td.lo { vertical-align: bottom; }
.tv td.up, .tv td.down { font-size: 22px; vertical-align: middle; font-weight: 700; }
.tv td.up { color: var(--ok); }
.tv td.down { color: var(--ko); }
.tv td.zero { font-weight: 700; color: var(--accent); }
.tv td.bar { border-left: 4px double var(--ink-2); border-right: 0; padding: 0; min-width: 6px; }
.tv-wrap, .prose > .tv { overflow-x: auto; }
.prose .tv { display: table; }
@media (max-width: 600px) { .tv { font-size: 13.5px; } .tv th, .tv td { padding: 6px 7px; min-width: 32px; } }

/* Schémas SVG */
.schema { margin: 26px 0; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-align: center; }
.schema svg { display: block; width: 100%; height: auto; margin: 0 auto; max-height: 520px; overflow: visible; }
.schema figcaption { font-size: 14px; color: var(--ink-3); margin-top: 12px; line-height: 1.5; }
@media (max-width: 600px) { .schema { padding: 12px 8px; margin-left: -4px; margin-right: -4px; } }

/* Halo couleur du fond autour des textes : reste lisible même si une courbe passe dessous */
.schema svg text, .widget svg text { paint-order: stroke; stroke: var(--surface); stroke-width: 3.5px; stroke-linejoin: round; }
svg .s-axis { stroke: var(--ink-2); stroke-width: 1.5; fill: none; }
svg .s-grid { stroke: var(--line); stroke-width: 1; fill: none; }
svg .s-ink  { stroke: var(--ink); stroke-width: 1.8; fill: none; }
svg .s-c1 { stroke: var(--c1); stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
svg .s-c2 { stroke: var(--c2); stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
svg .s-c3 { stroke: var(--c3); stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
svg .s-c4 { stroke: var(--c4); stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
svg .s-c5 { stroke: var(--c5); stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
svg .s-f1 { fill: var(--c1); fill-opacity: .16; stroke: none; }
svg .s-f2 { fill: var(--c2); fill-opacity: .16; stroke: none; }
svg .s-f3 { fill: var(--c3); fill-opacity: .18; stroke: none; }
svg .s-f4 { fill: var(--c4); fill-opacity: .16; stroke: none; }
svg .s-f5 { fill: var(--c5); fill-opacity: .16; stroke: none; }
svg .s-d1 { fill: var(--c1); } svg .s-d2 { fill: var(--c2); } svg .s-d3 { fill: var(--c3); } svg .s-d4 { fill: var(--c4); } svg .s-d5 { fill: var(--c5); }
svg .s-dash { stroke-dasharray: 5 4; }
svg .s-thin { stroke-width: 1.2; }
svg .s-thick { stroke-width: 3.6; }
svg .s-arrow { fill: var(--ink-2); stroke: none; }
svg .s-txt { fill: var(--ink); font-size: 13px; font-family: var(--font); }
svg .s-txt-sm { fill: var(--ink-2); font-size: 11px; font-family: var(--font); }
svg .s-txt-b { fill: var(--ink); font-size: 13px; font-weight: 700; font-family: var(--font); }
svg .s-txt-mute { fill: var(--ink-3); font-size: 12px; font-family: var(--font); }
svg .s-t1 { fill: var(--c1); } svg .s-t2 { fill: var(--c2); } svg .s-t3 { fill: var(--c3); } svg .s-t4 { fill: var(--c4); } svg .s-t5 { fill: var(--c5); }
svg text.s-t1, svg text.s-t2, svg text.s-t3, svg text.s-t4, svg text.s-t5 { font-size: 13px; font-weight: 600; font-family: var(--font); }
svg .s-box { fill: var(--surface-2); stroke: var(--line-2); stroke-width: 1.2; }
svg .s-box1 { fill: var(--c1-soft); stroke: var(--c1); stroke-width: 1.3; }
svg .s-box2 { fill: var(--c2-soft); stroke: var(--c2); stroke-width: 1.3; }
svg .s-box3 { fill: var(--c3-soft); stroke: var(--c3); stroke-width: 1.3; }
svg .s-box4 { fill: var(--c4-soft); stroke: var(--c4); stroke-width: 1.3; }
svg .s-box5 { fill: var(--c5-soft); stroke: var(--c5); stroke-width: 1.3; }

/* Animations des schémas (déclenchées par .in-view, posé en JS à l'entrée à l'écran) */
.anim-ready .s-pop { opacity: 0; transform: scale(.85); transform-box: fill-box; transform-origin: center; transition: opacity .5s ease, transform .6s cubic-bezier(.2, .8, .2, 1.2); transition-delay: var(--d, 0ms); }
.anim-ready.in-view .s-pop { opacity: 1; transform: none; }
.anim-ready .s-draw { transition: stroke-dashoffset 1.5s cubic-bezier(.4, 0, .2, 1); transition-delay: var(--d, 0ms); }
@media (prefers-reduced-motion: reduce) {
  .anim-ready .s-pop { opacity: 1; transform: none; transition: none; }
  .view { animation: none; }
}

/* Widgets interactifs */
.widget { margin: 26px 0; padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.widget-title { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .055em; color: var(--accent); margin-bottom: 12px; display: block; line-height: 1.5; }
.widget-title::before { content: ""; display: inline-block; vertical-align: 1px; margin-right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); animation: pulse 2.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
.widget svg { display: block; width: 100%; height: auto; max-height: 460px; touch-action: pan-y; }
.widget-controls { display: flex; flex-wrap: wrap; gap: 12px 22px; align-items: center; margin-top: 14px; font-size: 14.5px; }
.widget-controls label { display: flex; align-items: center; gap: 10px; flex: 1 1 200px; color: var(--ink-2); font-weight: 520; }
.widget-controls output, .widget output { font-family: var(--mono); font-size: 14px; background: var(--surface-2); padding: 4px 10px; border-radius: 8px; color: var(--ink); font-variant-numeric: tabular-nums; }
.widget-controls button, .widget button { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-size: 14px; font-weight: 560; cursor: pointer; }
.widget-controls button:hover, .widget button:hover { background: var(--surface-2); }
/* Les titres sont en majuscules mais pas les formules (f(x) ne doit pas devenir F(X)) */
.box-title .katex, .widget-title .katex, .eyebrow .katex, .chapter-title .katex { text-transform: none; letter-spacing: 0; }
.widget output { display: inline-block; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.widget-hint { font-size: 14px; color: var(--ink-3); margin: 12px 0 0; }
.widget select { font: inherit; font-size: 14px; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); }
input[type="range"] { -webkit-appearance: none; appearance: none; flex: 1; min-width: 110px; height: 22px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 5px; border-radius: 99px; background: var(--surface-3); }
input[type="range"]::-moz-range-track { height: 5px; border-radius: 99px; background: var(--surface-3); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); margin-top: -7.5px; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.widget input[type="number"], .widget input[type="text"] { font: inherit; font-size: 14px; width: 80px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); }

/* Méthode pas à pas */
.stepper { margin: 22px 0; counter-reset: st; }
.stepper .step { position: relative; padding: 2px 0 16px 44px; }
.stepper .step::before {
  counter-increment: st; content: counter(st); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 14px;
}
.stepper .step::after { content: ""; position: absolute; left: 13.5px; top: 32px; bottom: 4px; width: 1.5px; background: var(--line-2); }
.stepper .step:last-of-type::after { display: none; }
.stepper .step > :last-child { margin-bottom: 0; }
.stepper.js .step.hidden { display: none; }
.stepper.js .step.shown { animation: stepIn .4s cubic-bezier(.2, .7, .2, 1); }
@keyframes stepIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.stepper-ctrl { display: flex; gap: 8px; align-items: center; padding-left: 44px; }
.stepper-ctrl .count { font-size: 13px; color: var(--ink-3); margin-left: 4px; }

/* Exercices et corrections dépliables */
.exo-item { margin: 18px 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.exo-item > :last-child { margin-bottom: 0; }
details.solution, details.qr { margin-top: 12px; border-radius: var(--radius-sm); }
details.solution > summary, details.qr > summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 14.5px; color: var(--accent); padding: 7px 14px; border-radius: 999px; background: var(--accent-soft);
  -webkit-user-select: none; user-select: none;
}
details.solution > summary::-webkit-details-marker, details.qr > summary::-webkit-details-marker { display: none; }
details.solution > summary::before, details.qr > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .2s; margin-right: 2px; }
details[open].solution > summary::before, details[open].qr > summary::before { transform: rotate(45deg); }
details.solution[open] > summary { margin-bottom: 12px; }
details.solution > :not(summary) { animation: stepIn .3s ease; }
details.solution { padding: 0; }
details.solution[open] { padding: 0 0 4px; }
details.qr { border: 1px solid var(--line); padding: 10px 14px; background: var(--surface); }
details.qr > summary { background: none; padding: 2px 0; color: var(--ink); }

/* Cartes Q/R à retourner */
.flashcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 12px; margin: 18px 0; }
.flashcards .card-fc { perspective: 1000px; min-height: 150px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.flashcards .fc-inner { position: relative; width: 100%; height: 100%; min-height: 150px; transition: transform .55s cubic-bezier(.3, .7, .2, 1); transform-style: preserve-3d; -webkit-transform-style: preserve-3d; display: grid; }
.flashcards .card-fc.flipped .fc-inner { transform: rotateY(180deg); }
.flashcards .front, .flashcards .back {
  grid-area: 1 / 1; padding: 16px; border-radius: var(--radius-sm); display: flex; flex-direction: column; justify-content: center;
  -webkit-backface-visibility: hidden; backface-visibility: hidden; font-size: 15px; line-height: 1.5; border: 1px solid var(--line);
}
.flashcards .front { background: var(--surface); font-weight: 600; box-shadow: var(--shadow); }
.flashcards .front::after { content: "Toucher pour voir la réponse"; font-size: 11.5px; font-weight: 500; color: var(--ink-3); margin-top: 10px; }
.flashcards .back { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); transform: rotateY(180deg); color: var(--ink); }
.flashcards .card-fc.known .front { border-color: var(--ok); }
.fc-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; font-size: 13.5px; color: var(--ink-3); }

/* Quiz */
.quiz { margin: 22px 0; display: flex; flex-direction: column; gap: 14px; }
.quiz .q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.quiz .q-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 4px; }
.quiz .q-num { flex: none; font-size: 12.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 99px; }
.quiz .q-text { font-weight: 600; margin: 0 0 10px; }
.quiz .q-multi { font-size: 12.5px; color: var(--ink-3); margin: -4px 0 10px; }
.quiz ol.choices { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.quiz ol.choices li {
  position: relative; margin: 0; padding: 11px 14px 11px 46px; border: 1.5px solid var(--line); border-radius: 11px; cursor: pointer;
  transition: border-color .15s, background .15s; -webkit-tap-highlight-color: transparent; line-height: 1.45;
}
.quiz ol.choices li::before {
  content: attr(data-k); position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; border-radius: 7px;
  border: 1.5px solid var(--line-2); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--ink-3);
}
.quiz ol.choices li:hover { border-color: var(--line-2); background: var(--surface-2); }
.quiz ol.choices li.sel { border-color: var(--accent); background: var(--accent-soft); }
.quiz ol.choices li.sel::before { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.quiz .q.done ol.choices li { cursor: default; }
.quiz .q.done ol.choices li.right { border-color: var(--ok); background: var(--ok-soft); }
.quiz .q.done ol.choices li.right::before { background: var(--ok); border-color: var(--ok); color: #fff; content: "✓"; }
.quiz .q.done ol.choices li.wrong { border-color: var(--ko); background: var(--ko-soft); }
.quiz .q.done ol.choices li.wrong::before { background: var(--ko); border-color: var(--ko); color: #fff; content: "✕"; }
.quiz .q.done ol.choices li.missed { border-style: dashed; border-color: var(--ok); }
.quiz .q.done ol.choices li.missed::after { content: "oubliée"; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 11.5px; font-weight: 650; color: var(--ok); }
.quiz .q-expl { display: none; margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); font-size: 15px; }
.quiz .q.done .q-expl { display: block; animation: stepIn .35s ease; }
.quiz .q-expl > :last-child { margin-bottom: 0; }
.quiz .q-foot { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.quiz .q-verdict { font-weight: 650; font-size: 14px; }
.quiz .q-verdict.ok { color: var(--ok); } .quiz .q-verdict.part { color: var(--warn); } .quiz .q-verdict.ko { color: var(--ko); }
.quiz-score { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 18px; border-radius: var(--radius); background: var(--accent-soft); margin-top: 6px; }
.quiz-score .big { font-size: 30px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* ---------- Examens ---------- */
.exam-bar {
  position: sticky; top: calc(var(--header-h) + env(safe-area-inset-top)); z-index: 30; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; margin: 0 0 20px; border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.timer { font-family: var(--mono); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.timer.low { color: var(--warn); } .timer.over { color: var(--ko); }
.timer-bar { flex: 1 1 40px; min-width: 30px; }
.exam-bar { flex-wrap: nowrap; }
.exam-bar .btn-row { margin-left: auto; flex-wrap: nowrap; gap: 6px; }
@media (max-width: 480px) { .timer-bar { display: none; } .timer { font-size: 20px; } }
.exam-intro-card { padding: 24px; }
.exam-intro-card .facts { display: flex; flex-wrap: wrap; gap: 14px 28px; margin: 0 0 6px; }
.exam-intro-card .facts div { font-size: 13px; color: var(--ink-3); }
.exam-intro-card .facts b { display: block; color: var(--ink); font-size: 20px; font-weight: 700; }
.exam-sujet .exo, .exam-corrige .corr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin: 0 0 18px; box-shadow: var(--shadow); }
.exam-sujet .exo h3, .exam-corrige .corr h3 { margin-top: 0; font-size: 19px; display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; }
.exo h3 .pts, .corr h3 .pts { font-size: 13px; font-weight: 650; color: var(--accent); background: var(--accent-soft); padding: 2px 9px; border-radius: 99px; }
.exam-corrige-head { margin: 34px 0 16px; }
.crit { position: relative; margin: 14px 0; padding: 14px 16px 12px; border-radius: 11px; border: 1.5px solid var(--line); background: var(--surface); transition: border-color .2s, background .2s; }
.crit > :last-child { margin-bottom: 0; }
.crit-ctrl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.crit-ctrl .pts-lbl { font-size: 13px; font-weight: 650; color: var(--ink-2); margin-right: auto; }
.crit-ctrl button { border: 1.5px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.crit-ctrl button.on.full { background: var(--ok); border-color: var(--ok); color: #fff; }
.crit-ctrl button.on.half { background: var(--warn); border-color: var(--warn); color: #fff; }
.crit-ctrl button.on.none { background: var(--ko); border-color: var(--ko); color: #fff; }
.crit.g-full { border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.crit.g-half { border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.crit.g-none { border-color: color-mix(in srgb, var(--ko) 45%, transparent); }
.self-score { position: sticky; bottom: 12px; z-index: 20; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); margin-top: 18px; }
@media (max-width: 760px) { .self-score { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px); } }
.self-score .big { font-size: 24px; font-weight: 750; font-variant-numeric: tabular-nums; }
.self-score { flex-wrap: nowrap; }
.self-score .msg { flex: 1; min-width: 0; font-size: 13.5px; color: var(--ink-2); line-height: 1.35; }
@media (max-width: 600px) {
  .self-score { gap: 10px; padding: 10px 12px; }
  .self-score .big { font-size: 20px; }
  .exam-sujet .exo, .exam-corrige .corr { padding: 16px 14px; }
  .crit { padding: 12px 12px 10px; }
  .exo-item { padding: 14px; }
}

/* Historique / progression */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 12px; }
.kpi { padding: 16px; }
.kpi .v { font-size: 26px; font-weight: 730; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 13px; color: var(--ink-3); }
.chart { width: 100%; height: auto; display: block; }
.chart .bar-r { fill: var(--accent); }
.chart .lbl { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .val { fill: var(--ink-2); font-size: 11px; font-weight: 650; font-family: var(--font); }
.chart .gl { stroke: var(--line); }
.heat { display: grid; grid-template-rows: repeat(7, 14px); grid-auto-flow: column; grid-auto-columns: 14px; gap: 4px; overflow-x: auto; }
.heat i { width: 14px; height: 14px; border-radius: 4px; background: var(--surface-3); }
.heat i.l1 { background: color-mix(in srgb, var(--ok) 35%, var(--surface-3)); }
.heat i.l2 { background: color-mix(in srgb, var(--ok) 65%, var(--surface-3)); }
.heat i.l3 { background: var(--ok); }

.empty { text-align: center; padding: 36px 18px; color: var(--ink-3); }
.empty h3 { color: var(--ink); margin-bottom: 6px; font-size: 17px; }

/* Recherche */
.search { position: relative; }
.search input {
  width: 100%; font: inherit; font-size: 16px; padding: 12px 16px 12px 44px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow); -webkit-appearance: none; appearance: none;
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ink-3); }
.search-results { margin-top: 10px; }

/* Notification flottante */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; z-index: 60;
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-size: 14.5px; font-weight: 560;
  box-shadow: var(--shadow-lg); transition: opacity .25s, transform .25s; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 760px) { .toast { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px); } }

/* Chargement */
.loading { display: grid; place-items: center; padding: 80px 0; color: var(--ink-3); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Impression : fiches propres sur papier */
@media print {
  .topbar, .tabbar, .toc, .fiche-end, .pager, .exam-bar, .self-score, .stepper-ctrl, .fc-toolbar, .crit-ctrl, .widget-controls { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
  .stepper.js .step.hidden { display: block; }
  details.solution > :not(summary) { display: block; }
  .flashcards .back { transform: none; position: static; }
  .card, .schema, .widget, .box, .quiz .q { box-shadow: none; break-inside: avoid; }
  .anim-ready .s-pop { opacity: 1; transform: none; }
}

/* Masqué sur petit écran */
@media (max-width: 600px) { .hide-sm { display: none; } }
