/* =========================================================
   Examen civique — style inspiré de Duolingo
   ========================================================= */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #3c3c3c;
  --muted: #777777;
  --faint: #afafaf;
  --line: #e5e5e5;
  --hover: #f7f7f7;

  --green: #58cc02;  --green-dark: #58a700;  --green-soft: #d7ffb8;  --green-line: #a5ed6e;
  --blue: #1cb0f6;   --blue-dark: #1899d6;   --blue-soft: #ddf4ff;   --blue-line: #84d8ff;
  --red: #ff4b4b;    --red-dark: #ea2b2b;    --red-soft: #ffdfe0;    --red-line: #ffb2b2;
  --orange: #ff9600; --orange-dark: #e08600; --orange-soft: #fff0d9;
  --purple: #ce82ff; --purple-dark: #a568cc; --purple-soft: #f4e5ff;
  --gold: #ffc800;   --gold-dark: #e0a800;   --gold-soft: #fff6d1;

  --radius: 16px;
  --font: "Nunito", "Segoe UI Rounded", "Arial Rounded MT Bold", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
    --bg: #131f24;
    --surface: #131f24;
    --text: #f1f7fb;
    --muted: #9fb0ba;
    --faint: #52656d;
    --line: #37464f;
    --hover: #1b2a31;
    --green-soft: #1f3a1d;  --green-line: #3f7a1f;
    --blue-soft: #16364a;   --blue-line: #1f6c93;
    --red-soft: #3f2226;    --red-line: #8d3a3e;
    --orange-soft: #3b2b14;
    --purple-soft: #33254a;
    --gold-soft: #3a3214;
  }
}
:root[data-theme="dark"] {
    --bg: #131f24;
    --surface: #131f24;
    --text: #f1f7fb;
    --muted: #9fb0ba;
    --faint: #52656d;
    --line: #37464f;
    --hover: #1b2a31;
    --green-soft: #1f3a1d;  --green-line: #3f7a1f;
    --blue-soft: #16364a;   --blue-line: #1f6c93;
    --red-soft: #3f2226;    --red-line: #8d3a3e;
    --orange-soft: #3b2b14;
    --purple-soft: #33254a;
    --gold-soft: #3a3214;
  }


* { box-sizing: border-box; }
button, a, label, summary { -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 700 17px/1.45 var(--font);
  animation: page-in .35s ease-out;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 900; line-height: 1.2; }
h2 { font-size: 1.3rem; margin: 0 0 12px; }
.muted { color: var(--muted); font-weight: 700; }
.small { font-size: .88rem; color: var(--muted); }
code { background: var(--hover); padding: 1px 6px; border-radius: 6px; }

/* ---------- couleurs utilitaires ---------- */
.c-green  { --c: var(--green);  --c-dark: var(--green-dark);  --c-soft: var(--green-soft); }
.c-blue   { --c: var(--blue);   --c-dark: var(--blue-dark);   --c-soft: var(--blue-soft); }
.c-red    { --c: var(--red);    --c-dark: var(--red-dark);    --c-soft: var(--red-soft); }
.c-orange { --c: var(--orange); --c-dark: var(--orange-dark); --c-soft: var(--orange-soft); }
.c-purple { --c: var(--purple); --c-dark: var(--purple-dark); --c-soft: var(--purple-soft); }
.c-gold   { --c: var(--gold);   --c-dark: var(--gold-dark);   --c-soft: var(--gold-soft); }

/* ---------- boutons 3D ---------- */
.btn {
  --b: var(--green); --b-dark: var(--green-dark); --b-text: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 24px;
  border: 0; border-radius: var(--radius);
  background: var(--b); color: var(--b-text);
  box-shadow: 0 4px 0 var(--b-dark);
  font: 800 15px/1 var(--font); letter-spacing: .8px; text-transform: uppercase;
  cursor: pointer; text-decoration: none !important;
  transition: transform .08s, box-shadow .08s, filter .15s;
  position: relative; top: 0;
}
@media (hover: hover) { .btn:hover { filter: brightness(1.06); } }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--b-dark); }
.btn-green { --b: var(--green); --b-dark: var(--green-dark); }
.btn-blue  { --b: var(--blue);  --b-dark: var(--blue-dark); }
.btn-red   { --b: var(--red);   --b-dark: var(--red-dark); }
.btn-gold  { --b: var(--gold);  --b-dark: var(--gold-dark); --b-text: #5c4300; }
.btn-ghost { --b: var(--surface); --b-dark: var(--line); --b-text: var(--blue); border: 2px solid var(--line); }
.btn-ghost:hover { background: var(--hover); filter: none; }
.btn[disabled], .btn.is-disabled {
  --b: var(--line); --b-dark: var(--line); --b-text: var(--faint);
  box-shadow: none; cursor: default; transform: none; filter: none;
}
.btn-block { width: 100%; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }
.icon-btn {
  background: none; border: 0; cursor: pointer; font: 900 26px/1 var(--font); color: var(--faint);
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; text-decoration: none !important;
}
.icon-btn:hover { background: var(--hover); color: var(--muted); }

/* ---------- barre du haut ---------- */
.topbar { border-bottom: 2px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 22px; }
.logo { font: 900 28px/1 var(--font); color: var(--green); letter-spacing: -.5px; text-decoration: none !important; display: flex; align-items: baseline; }
.logo .dot { width: 10px; height: 10px; border-radius: 50%; margin-left: 3px;
  background: linear-gradient(90deg, #1d4ed8 33%, #fff 33% 66%, #ef4444 66%); border: 1px solid var(--line); }
.topnav { display: flex; gap: 4px; }
.topnav a { color: var(--muted); font-weight: 800; text-transform: uppercase; font-size: 14px; letter-spacing: .6px;
  padding: 8px 12px; border-radius: 12px; border: 2px solid transparent; text-decoration: none; }
.topnav a:hover { background: var(--hover); }
.topnav a.active { color: var(--blue); background: var(--blue-soft); border-color: var(--blue-line); }
.nav-ico { display: none; }
.chips { margin-left: auto; display: flex; gap: 14px; }
.chip-stat { font-weight: 900; font-size: 16px; white-space: nowrap; }
.chip-stat.streak { color: var(--orange); }
.chip-stat.streak.off { filter: grayscale(1); color: var(--faint); }
.chip-stat.xp { color: var(--gold-dark); }
.chip-stat.level { color: var(--blue); }
@media (max-width: 640px) {
  .topbar-inner { gap: 8px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .logo { font-size: 24px; }
  .chips { gap: 9px; align-items: center; }
  .chip-stat { font-size: 14.5px; }
  /* Onglets en bas de l'écran, comme sur l'appli mobile. */
  .topnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; gap: 0;
    background: var(--surface); border-top: 2px solid var(--line);
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  }
  .topnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 11.5px; padding: 5px 0; }
  .nav-ico { display: block; font-size: 22px; line-height: 1.1; }
  .page { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (max-width: 400px) {
  .lvl-label { display: none; }
  .logo { font-size: 22px; }
  .chips { gap: 7px; }
  .chips .sound-toggle, .chips .music-toggle { width: 32px; height: 30px; font-size: 14px; }
}

/* ---------- pages ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.card {
  border: 2px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
  background: var(--surface);
}
.card h2 { display: flex; align-items: center; gap: 8px; }
.card.empty { text-align: center; max-width: 520px; margin: 40px auto; }
.big-emoji { font-size: 64px; line-height: 1; margin: 10px 0; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }

/* ---------- accueil ---------- */
.home { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 40px; align-items: start; }
@media (max-width: 900px) { .home { grid-template-columns: 1fr; gap: 10px; } }
.side { position: sticky; top: 90px; }
@media (max-width: 900px) { .side { position: static; } }

.unit-banner {
  background: var(--green); color: #fff; border-radius: var(--radius); padding: 18px 22px;
  box-shadow: 0 4px 0 var(--green-dark); display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 30px;
}
.unit-banner h1 { margin: 0 0 2px; font-size: 1.35rem; }
.unit-banner p { margin: 0; opacity: .92; font-size: .95rem; }
.unit-banner .btn { --b: #fff; --b-dark: rgba(0,0,0,.2); --b-text: var(--green-dark); flex: none; white-space: nowrap; }
@media (max-width: 560px) {
  .unit-banner { flex-direction: column; align-items: stretch; text-align: center; padding: 16px; }
  .unit-banner form, .unit-banner .btn { width: 100%; }
}
.unit-banner form { margin: 0; flex: none; }

.path { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 44px 0 30px; }
.node-wrap { display: flex; flex-direction: column; align-items: center; position: relative; }
.node-wrap:nth-child(5n+2) { translate: -70px 0; }
.node-wrap:nth-child(5n+3) { translate: -105px 0; }
.node-wrap:nth-child(5n+4) { translate: -70px 0; }
.node-wrap:nth-child(5n+6) { translate: 70px 0; }
@media (max-width: 520px) {
  .node-wrap:nth-child(5n+2), .node-wrap:nth-child(5n+4) { translate: -40px 0; }
  .node-wrap:nth-child(5n+3) { translate: -60px 0; }
  .node-wrap:nth-child(5n+6) { translate: 40px 0; }
}
.node-form { margin: 0; position: relative; width: 104px; height: 104px; display: grid; place-items: center; }
.ring { position: absolute; inset: 0; width: 104px; height: 104px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring-bg { stroke: var(--line); }
.ring-fg { stroke: var(--c); stroke-linecap: round; transition: stroke-dashoffset 1.2s cubic-bezier(.3, .9, .3, 1); }
.node {
  width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer; padding: 14px;
  background: var(--c); box-shadow: 0 7px 0 var(--c-dark);
  transition: transform .1s, box-shadow .1s; position: relative; top: -3px;
}
.node svg { width: 100%; height: 100%; display: block; }
@media (hover: hover) { .node:hover { transform: scale(1.06); } }
.node:active { transform: translateY(6px); box-shadow: 0 1px 0 var(--c-dark); }
.node.trophy { background: var(--gold); box-shadow: 0 7px 0 var(--gold-dark); }
.node-label { margin-top: 8px; text-align: center; font-weight: 900; font-size: 15px; max-width: 170px; }
.node-label small { display: block; font-weight: 800; color: var(--muted); font-size: 13px; }
.crowns { color: var(--gold-dark); letter-spacing: 1px; }
.start-bubble {
  position: absolute; top: -46px; left: 50%; transform: translateX(-50%);
  background: var(--surface); color: var(--green); border: 2px solid var(--line); border-radius: 12px;
  padding: 7px 12px; font-weight: 900; font-size: 14px; text-transform: uppercase; letter-spacing: .6px; white-space: nowrap;
  animation: bob 1.6s ease-in-out infinite; z-index: 2;
}
.start-bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -8px; width: 12px; height: 12px; background: var(--surface);
  border-right: 2px solid var(--line); border-bottom: 2px solid var(--line); transform: translateX(-50%) rotate(45deg);
}
.path .node-wrap { animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.path .node-wrap:nth-child(2) { animation-delay: .06s; }
.path .node-wrap:nth-child(3) { animation-delay: .12s; }
.path .node-wrap:nth-child(4) { animation-delay: .18s; }
.path .node-wrap:nth-child(5) { animation-delay: .24s; }
.path .node-wrap:nth-child(6) { animation-delay: .30s; }

/* panneau latéral */
.goal { display: flex; align-items: center; gap: 16px; }
.goal .ring-box { position: relative; width: 84px; height: 84px; flex: none; }
.goal .ring-box .ring { width: 84px; height: 84px; }
.goal .ring-box .ring circle { stroke-width: 9; }
.goal .ring-box span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 28px; }
.goal strong { display: block; font-size: 1.05rem; }
.levelbar, .bar { height: 16px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 8px 0 4px; }
.levelbar span, .bar span {
  display: block; height: 100%; border-radius: 99px; background: var(--c, var(--gold));
  position: relative; transition: width 1s cubic-bezier(.3, .9, .3, 1);
}
.levelbar span::after, .bar span::after, .progress span::after {
  content: ""; position: absolute; left: 8px; right: 8px; top: 4px; height: 4px; border-radius: 99px; background: rgba(255,255,255,.35);
}
.exam-card { border-color: var(--blue-line); }
.exam-card .facts { display: flex; gap: 10px; margin: 6px 0 12px; flex-wrap: wrap; }
.exam-card .facts span { background: var(--blue-soft); color: var(--blue-dark); border-radius: 10px; padding: 4px 10px; font-size: 14px; font-weight: 900; }
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) .exam-card .facts span { color: var(--blue); }
}
:root[data-theme="dark"] .exam-card .facts span { color: var(--blue); }

select, input[type="search"] {
  width: 100%; margin: 4px 0 10px; padding: 11px 12px; font: 700 15px var(--font); color: var(--text);
  border: 2px solid var(--line); border-radius: 12px; background: var(--hover);
}
select:focus, input[type="search"]:focus { outline: none; border-color: var(--blue-line); }
label.field { display: block; font-size: 14px; color: var(--muted); font-weight: 800; }
details.more > summary { cursor: pointer; color: var(--blue); font-weight: 800; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary { margin-bottom: 10px; }
.chart { width: 100%; height: 110px; display: block; }
.chart .threshold { stroke: var(--green); stroke-dasharray: 5 5; stroke-width: 2; }
.chart .line { fill: none; stroke: var(--blue); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round;
  stroke-dasharray: 1000; stroke-dashoffset: 1000; animation: draw 1.4s ease-out forwards .2s; }
.chart .pt { fill: var(--surface); stroke: var(--blue); stroke-width: 3; }
.chart .pt.pass { stroke: var(--green); fill: var(--green); }
.chart text { fill: var(--muted); font: 800 11px var(--font); }

.badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.badge { text-align: center; font-size: 11.5px; font-weight: 800; color: var(--muted); line-height: 1.2; }
.badge .medal {
  width: 58px; height: 58px; margin: 0 auto 5px; border-radius: 50%; display: grid; place-items: center; font-size: 28px;
  background: var(--gold-soft); border: 3px solid var(--gold); box-shadow: 0 3px 0 var(--gold-dark);
  position: relative; overflow: hidden;
}
.badge .medal::after {
  content: ""; position: absolute; top: -60%; left: -80%; width: 50%; height: 220%; transform: rotate(25deg);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent); animation: shine 3.5s ease-in-out infinite;
}
.badge.locked .medal { background: var(--hover); border-color: var(--line); box-shadow: 0 3px 0 var(--line); filter: grayscale(1); opacity: .45; }
.badge.locked .medal::after { display: none; }
.badge.locked { color: var(--faint); }

table.list { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.list td { padding: 9px 4px; border-bottom: 2px solid var(--line); }
table.list tr:last-child td { border-bottom: 0; }
td.num { text-align: right; white-space: nowrap; }
.ok-text { color: var(--green); }
.ko-text { color: var(--red); }
.subthemes td:first-child { color: var(--muted); }

/* ---------- leçon / examen ---------- */
body.lesson { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.lesson-form { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.lesson-top {
  width: 100%; max-width: 1040px; margin: 0 auto; padding: 22px 20px 10px;
  display: flex; align-items: center; gap: 16px;
}
.progress { flex: 1; height: 16px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress span {
  display: block; height: 100%; background: var(--green); border-radius: 99px; position: relative; min-width: 16px;
  transition: width .6s cubic-bezier(.3, .9, .3, 1);
}
.timer { font-weight: 900; font-size: 17px; color: var(--blue); font-variant-numeric: tabular-nums; white-space: nowrap; }
.timer.low { color: var(--red); animation: pulse 1s ease-in-out infinite; }
.combo { font-weight: 900; font-size: 18px; color: var(--faint); filter: grayscale(1); white-space: nowrap; transition: .3s; }
.combo.on { color: var(--orange); filter: none; animation: flame 1.2s ease-in-out infinite; }

.lesson-body { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 18px 20px 30px; }
.lesson-body.center { text-align: center; }
.q-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0 10px; }
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 900;
  text-transform: uppercase; letter-spacing: .4px; background: var(--c-soft); color: var(--c-dark);
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) .pill { color: var(--c); }
}
:root[data-theme="dark"] .pill { color: var(--c); }

.q-count { margin-left: auto; color: var(--faint); font-weight: 900; font-size: 14px; }
.q-title { font-size: 1.6rem; margin: 6px 0 26px; animation: slide-in .35s ease-out; }
@media (max-width: 600px) { .q-title { font-size: 1.3rem; } }

.choices { display: grid; gap: 12px; }
.choice {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer;
  border: 2px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 0 var(--line);
  font-size: 1.05rem; font-weight: 700; transition: background .15s, border-color .15s, transform .08s, box-shadow .08s;
  animation: slide-in .35s ease-out backwards; user-select: none;
}
.choice:nth-child(2) { animation-delay: .05s; }
.choice:nth-child(3) { animation-delay: .1s; }
.choice:nth-child(4) { animation-delay: .15s; }
@media (hover: hover) { .choice:hover { background: var(--hover); } }
.choice:active { transform: translateY(3px); box-shadow: 0 0 0 var(--line); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .key {
  flex: none; width: 32px; height: 32px; border-radius: 9px; border: 2px solid var(--line);
  display: grid; place-items: center; font-size: 15px; font-weight: 900; color: var(--faint);
}
.choice:has(input:checked) { border-color: var(--blue-line); background: var(--blue-soft); color: var(--blue-dark); box-shadow: 0 3px 0 var(--blue-line); }
.choice:has(input:checked) .key { border-color: var(--blue-line); color: var(--blue); }
.choice:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 3px; }
.choices .choice.good { border-color: var(--green-line); background: var(--green-soft); color: var(--green-dark); box-shadow: 0 3px 0 var(--green-line); animation: bounce .5s ease-out; }
.choices .choice.good .key { border-color: var(--green-line); color: var(--green-dark); }
.choices .choice.bad { border-color: var(--red-line); background: var(--red-soft); color: var(--red-dark); box-shadow: 0 3px 0 var(--red-line); animation: shake .45s ease-in-out; }
.choices .choice.bad .key { border-color: var(--red-line); color: var(--red-dark); }
.choices .choice.dim { opacity: .55; }
.choice:has(input:disabled) { cursor: default; }
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) .choice:has(input:checked), :root:not([data-theme="light"]) .choices .choice.good, :root:not([data-theme="light"]) .choices .choice.bad { color: var(--text); }
}
:root[data-theme="dark"] .choice:has(input:checked), :root[data-theme="dark"] .choices .choice.good, :root[data-theme="dark"] .choices .choice.bad { color: var(--text); }


.qgrid-drawer { margin-top: 26px; }
.qgrid-drawer summary { cursor: pointer; color: var(--blue); font-weight: 800; font-size: 14.5px; }
.qgrid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 7px; margin-top: 12px; }
.qgrid.inline { display: flex; flex-wrap: wrap; justify-content: center; }
.qgrid button, .qgrid a {
  min-width: 36px; height: 36px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface);
  color: var(--muted); font: 900 14px var(--font); cursor: pointer; display: grid; place-items: center; text-decoration: none;
  box-shadow: 0 2px 0 var(--line);
}
.qgrid .done { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue-dark); }
.qgrid .flag { border-color: var(--orange); box-shadow: 0 2px 0 var(--orange); }
.qgrid .current { background: var(--blue); border-color: var(--blue-dark); color: #fff; }
.legend { font-size: 13px; color: var(--muted); display: flex; gap: 14px; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 5px; vertical-align: -1px; border: 2px solid; }
.legend .done::before { background: var(--blue-soft); border-color: var(--blue-line); }
.legend .flag::before { border-color: var(--orange); }
@media (max-width: 600px) { .qgrid { grid-template-columns: repeat(8, 1fr); } }

.lesson-footer { border-top: 2px solid var(--line); background: var(--surface); position: sticky; bottom: 0; z-index: 5; }
.lesson-footer.ok { background: var(--green-soft); border-top-color: transparent; animation: rise .3s ease-out; }
.lesson-footer.ko { background: var(--red-soft); border-top-color: transparent; animation: rise .3s ease-out; }
.footer-inner {
  max-width: 1040px; margin: 0 auto; padding: 22px 20px; padding-bottom: calc(22px + env(safe-area-inset-bottom)); min-height: 100px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.footer-inner .btn { min-width: 150px; }
.flag-toggle { cursor: pointer; font-weight: 900; color: var(--muted); user-select: none; }
.flag-toggle input { display: none; }
.flag-toggle span { padding: 10px 14px; border-radius: 12px; border: 2px solid var(--line); display: inline-block; transition: .15s; }
.flag-toggle input:checked + span { color: var(--orange); border-color: var(--orange); background: var(--orange-soft); }
.feedback { display: flex; gap: 16px; align-items: flex-start; flex: 1; min-width: 0; }
.fb-icon {
  flex: none; width: 64px; height: 64px; border-radius: 50%; background: var(--surface);
  display: grid; place-items: center; font-size: 34px; font-weight: 900; animation: pop .45s cubic-bezier(.2, 1.6, .4, 1);
}
.ok .fb-icon { color: var(--green); }
.ko .fb-icon { color: var(--red); }
.fb-title { font-size: 1.45rem; font-weight: 900; display: block; }
.ok .fb-title, .ok .fb-combo { color: var(--green-dark); }
.ko .fb-title, .ko .fb-answer { color: var(--red-dark); }
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) .ok .fb-title, :root:not([data-theme="light"]) .ok .fb-combo { color: var(--green); }
:root:not([data-theme="light"]) .ko .fb-title, :root:not([data-theme="light"]) .ko .fb-answer { color: var(--red); }
}
:root[data-theme="dark"] .ok .fb-title, :root[data-theme="dark"] .ok .fb-combo { color: var(--green); }
:root[data-theme="dark"] .ko .fb-title, :root[data-theme="dark"] .ko .fb-answer { color: var(--red); }

.fb-answer { margin: 2px 0 4px; font-size: 1.05rem; }
.fb-combo { margin: 2px 0; }
.fb-expl { margin: 4px 0; font-size: .95rem; font-weight: 700; color: var(--text); }
.fb-source { margin: 4px 0 0; font-size: .82rem; color: var(--muted); }
@media (max-width: 700px) {
  .footer-inner { flex-direction: column; align-items: stretch; padding: 16px; min-height: 0; }
  .footer-inner .btn { width: 100%; }
  .is-exam .footer-inner { flex-direction: row; flex-wrap: wrap; }
  .is-exam .footer-inner .btn { width: auto; flex: 1; min-width: 110px; }
  .fb-icon { width: 44px; height: 44px; font-size: 24px; }
  .fb-title { font-size: 1.2rem; }
  .fb-expl { font-size: .88rem; }
  .lesson-top { gap: 10px; padding: 14px 14px 6px; padding-top: calc(14px + env(safe-area-inset-top)); }
  .lesson-top .sound-toggle, .lesson-top .music-toggle { width: 32px; height: 32px; border: 0; font-size: 16px; }
  .lesson-top .icon-btn { width: 32px; font-size: 24px; }
  .timer { font-size: 15px; }
  .lesson-body { padding: 10px 16px 24px; }
  .choice { padding: 12px 14px; font-size: 1rem; gap: 12px; }
  .tiles { gap: 10px; }
  .tile { width: calc(50% - 5px); max-width: 160px; }
  .result-hero h1 { font-size: 1.6rem; }
}

.xp-float {
  position: fixed; z-index: 50; pointer-events: none; font: 900 22px var(--font); color: var(--gold-dark);
  text-shadow: 0 2px 0 #fff; animation: float-up 1.2s ease-out forwards;
}

/* ---------- résultats ---------- */
.result-hero { text-align: center; padding: 10px 0 6px; }
.result-hero h1 { font-size: 2rem; margin: 6px 0 4px; }
.result-hero.pass h1 { color: var(--gold-dark); }
.result-hero.fail h1 { color: var(--blue); }
.result-hero p { color: var(--muted); margin: 0 0 20px; }
.tiles { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin: 16px 0 22px; }
.tile {
  width: 150px; border: 2px solid var(--c); border-radius: var(--radius); overflow: hidden; background: var(--c);
  animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both;
}
.tile:nth-child(2) { animation-delay: .12s; }
.tile:nth-child(3) { animation-delay: .24s; }
.tile:nth-child(4) { animation-delay: .36s; }
.tile > span { display: block; color: #fff; font-weight: 900; font-size: 12.5px; text-transform: uppercase; letter-spacing: .6px; padding: 5px 4px 4px; text-align: center; }
.tile strong { display: block; background: var(--surface); color: var(--c); border-radius: 12px 12px 0 0; padding: 12px 6px; font-size: 1.45rem; text-align: center; }
.new-badges { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; }
.new-badges .badge { width: 120px; animation: pop .6s cubic-bezier(.2, 1.6, .4, 1) both .5s; font-size: 13px; color: var(--text); }
.new-badges .badge .medal { width: 76px; height: 76px; font-size: 38px; }
.new-badges .badge small { display: block; color: var(--muted); font-weight: 700; margin-top: 2px; }
.center-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 26px; }
.theme-bars td:first-child { width: 45%; }
.theme-bars td.barcell { width: 40%; }
.theme-bars .bar { margin: 0; height: 14px; }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 28px 0 12px; }
.section-title h2 { margin: 0; }
.toggle-link { font-size: 14px; font-weight: 800; }

.qcard { border: 2px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; border-left-width: 8px; }
.qcard.ok { border-left-color: var(--green); }
.qcard.ko { border-left-color: var(--red); }
.qcard .q { font-weight: 900; margin: 6px 0 10px; font-size: 1.05rem; }
.qcard ul { list-style: none; padding: 0; margin: 0 0 10px; }
.qcard li { padding: 7px 12px; border-radius: 12px; margin: 4px 0; border: 2px solid transparent; font-size: .97rem; }
.qcard li.good { background: var(--green-soft); border-color: var(--green-line); }
.qcard li.bad { background: var(--red-soft); border-color: var(--red-line); text-decoration: line-through; }
.qcard li em { font-style: normal; font-size: 12px; color: var(--muted); margin-left: 6px; text-decoration: none; display: inline-block; }
.qcard .expl { margin: 0; font-weight: 700; font-size: .95rem; }
.qcard .meta-line { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-top: 8px; }
.qcard form { margin: 0; display: inline; }

/* ---------- révision ---------- */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 10px; align-items: end; }
.filters .btn { min-height: 46px; margin-bottom: 10px; }
@media (max-width: 800px) { .filters { grid-template-columns: 1fr 1fr; } .filters .search { grid-column: 1 / -1; } }
.rev .answer { margin-top: 8px; }
.rev summary { cursor: pointer; color: var(--blue); font-weight: 900; font-size: 14px; text-transform: uppercase; letter-spacing: .5px; list-style: none; }
.rev summary::-webkit-details-marker { display: none; }
.rev details[open] summary { display: none; }
.rev .answer-box { background: var(--green-soft); border: 2px solid var(--green-line); border-radius: 12px; padding: 10px 14px; animation: slide-in .25s ease-out; }
.rev .answer-box strong { color: var(--green-dark); display: block; }
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) .rev .answer-box strong { color: var(--green); }
}
:root[data-theme="dark"] .rev .answer-box strong { color: var(--green); }

.status { font-size: 12px; font-weight: 900; padding: 2px 9px; border-radius: 99px; text-transform: uppercase; letter-spacing: .4px; }
.status.nouvelle { background: var(--hover); color: var(--muted); }
.status.ratee { background: var(--red-soft); color: var(--red-dark); }
.status.a_revoir { background: var(--orange-soft); color: var(--orange-dark); }
.status.acquise { background: var(--green-soft); color: var(--green-dark); }
.status.signalee { background: var(--purple-soft); color: var(--purple-dark); }
.pager { display: flex; gap: 10px; justify-content: center; margin: 20px 0; }

/* ---------- son / chargement ---------- */
.sound-toggle, .music-toggle {
  background: none; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--text);
  width: 40px; height: 36px; font-size: 17px; line-height: 1; display: grid; place-items: center; flex: none;
  position: relative;
}
.sound-toggle:hover, .music-toggle:hover { background: var(--hover); }
.music-toggle.off { opacity: .45; }
.music-toggle.off::after {
  content: ""; position: absolute; left: 7px; right: 7px; top: 50%; height: 2px; background: var(--red); transform: rotate(-35deg);
}
.chips .sound-toggle, .chips .music-toggle { height: 32px; width: 36px; font-size: 15px; }
body.busy { cursor: progress; }
body.busy .btn, body.busy .choice { pointer-events: none; }

#audio-hint {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); translate: -50% 0; z-index: 60;
  max-width: calc(100vw - 24px); white-space: normal; text-align: center;
  background: var(--text); color: var(--bg); font-weight: 800; font-size: 14px; padding: 10px 16px; border-radius: 99px;
  box-shadow: 0 4px 14px rgba(0,0,0,.2); pointer-events: none; animation: slide-in .4s ease-out .8s both;
}
@media (max-width: 640px) { body:not(.lesson) #audio-hint { bottom: calc(92px + env(safe-area-inset-bottom)); } }
body.lesson #audio-hint { bottom: calc(120px + env(safe-area-inset-bottom)); }

/* ---------- confettis ---------- */
.confetti { position: fixed; top: -12px; width: 10px; height: 14px; z-index: 100; pointer-events: none; border-radius: 3px; animation: fall linear forwards; }

/* ---------- animations ---------- */
@keyframes page-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes slide-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
@keyframes bounce { 0% { transform: scale(1); } 40% { transform: scale(1.04); } 70% { transform: scale(.98); } 100% { transform: scale(1); } }
@keyframes bob { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -6px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes flame { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.12) rotate(-4deg); } }
@keyframes float-up { 0% { transform: translate(-50%, 0) scale(.6); opacity: 0; } 20% { opacity: 1; transform: translate(-50%, -10px) scale(1.15); } 100% { transform: translate(-50%, -80px) scale(1); opacity: 0; } }
@keyframes shine { 0%, 70% { left: -80%; } 100% { left: 140%; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}


/* =========================================================
   Lisibilité : teintes foncées pour le TEXTE coloré
   (les couleurs vives restent pour les fonds et les boutons)
   ========================================================= */
:root {
  --green-text: #3a8700; --blue-text: #0f78b0; --red-text: #d12f2f;
  --orange-text: #b35c00; --purple-text: #8a45c2; --gold-text: #946c00;
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
    --green-text: #79d83a; --blue-text: #5cc8fa; --red-text: #ff7a7a;
    --orange-text: #ffab40; --purple-text: #d9a0ff; --gold-text: #ffd54d;
  }
}
:root[data-theme="dark"] {
    --green-text: #79d83a; --blue-text: #5cc8fa; --red-text: #ff7a7a;
    --orange-text: #ffab40; --purple-text: #d9a0ff; --gold-text: #ffd54d;
  }

.c-green  { --c-text: var(--green-text); }
.c-blue   { --c-text: var(--blue-text); }
.c-red    { --c-text: var(--red-text); }
.c-orange { --c-text: var(--orange-text); }
.c-purple { --c-text: var(--purple-text); }
.c-gold   { --c-text: var(--gold-text); }

.logo { color: var(--green-text); }
.chip-stat.streak { color: var(--orange-text); }
.chip-stat.xp { color: var(--gold-text); }
.chip-stat.level, .topnav a.active { color: var(--blue-text); }
.pill, .pill { color: var(--c-text); }
.q-count, .choice .key, .qgrid button, .qgrid a { color: var(--muted); }
.ok-text { color: var(--green-text); }
.ko-text { color: var(--red-text); }
.crowns { color: var(--gold-text); }
.flag-toggle input:checked + span { color: var(--orange-text); }
.result-hero.pass h1 { color: var(--gold-text); }
.result-hero.fail h1 { color: var(--blue-text); }
.tile { background: var(--c-dark); border-color: var(--c-dark); }
.tile.c-gold > span { color: #4d3800; }
.tile strong { color: var(--c-text); }
.exam-card .facts span { color: var(--blue-text); }
.status.ratee { color: var(--red-text); }
.status.a_revoir { color: var(--orange-text); }
.status.acquise { color: var(--green-text); }
.status.signalee { color: var(--purple-text); }
.ok .fb-title, .ok .fb-combo, .choices .choice.good, .choices .choice.good .key, .rev .answer-box strong { color: var(--green-text); }
.ko .fb-title, .ko .fb-answer, .choices .choice.bad, .choices .choice.bad .key { color: var(--red-text); }
.choice:has(input:checked), .choice:has(input:checked) .key { color: var(--blue-text); }
.qgrid .done { color: var(--blue-text); }
.xp-float { color: var(--gold-text); }
.timer { color: var(--blue-text); }
.timer.low { color: var(--red-text); }
.combo.on { color: var(--orange-text); }
.start-bubble { color: var(--green-text); }
.unit-banner .btn { --b-text: #3a8700; }

/* ---------- comptes : connexion, profil, administration ---------- */
.auth { max-width: 440px; margin: 0 auto; padding: 48px 20px; padding-top: calc(48px + env(safe-area-inset-top)); }
.auth-brand { text-align: center; margin-bottom: 22px; }
.logo.big { font-size: 46px; justify-content: center; }
.logo.big .dot { width: 16px; height: 16px; }
.auth-brand p { color: var(--muted); margin: 8px 0 0; }
.auth-tabs { display: flex; gap: 6px; background: var(--hover); padding: 5px; border-radius: 14px; margin-bottom: 16px; }
.auth-tabs a { flex: 1; text-align: center; padding: 10px; border-radius: 10px; color: var(--muted); font-weight: 900; text-decoration: none; }
.auth-tabs a.active { background: var(--surface); color: var(--blue-text); box-shadow: 0 2px 0 var(--line); }
input[type="text"], input[type="password"], textarea {
  width: 100%; margin: 4px 0 12px; padding: 12px; font: 700 16px var(--font); color: var(--text);
  border: 2px solid var(--line); border-radius: 12px; background: var(--hover);
}
textarea { resize: vertical; }
input[type="text"]:focus, input[type="password"]:focus, textarea:focus { outline: none; border-color: var(--blue-line); background: var(--surface); }
.form-error, .form-ok { padding: 10px 14px; border-radius: 12px; font-weight: 800; margin: 0 0 14px; }
.form-error { background: var(--red-soft); color: var(--red-text); }
.form-ok { background: var(--green-soft); color: var(--green-text); }
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.profile-head h1 { margin: 0; }
.avatar {
  width: 72px; height: 72px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 34px; font-weight: 900;
  display: grid; place-items: center; box-shadow: 0 4px 0 var(--blue-dark); flex: none;
}
.avatar.small { width: 44px; height: 44px; font-size: 20px; box-shadow: 0 3px 0 var(--blue-dark); }
a.avatar-link { text-decoration: none !important; }
.chips .avatar.small { width: 34px; height: 34px; font-size: 16px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.inline-form form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 0; }
.inline-form .field { flex: 1; min-width: 180px; }
.inline-form .field input { margin-bottom: 0; }
.inline-form .btn { min-height: 46px; }
.check { font-weight: 800; font-size: 14px; color: var(--muted); display: flex; gap: 6px; align-items: center; min-height: 46px; }
.user-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.user-name { flex: 1; min-width: 180px; }
.user-stats { display: flex; gap: 12px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.user-actions { display: grid; gap: 14px; }
.user-card details.more { margin-top: 12px; }
.admin-tabs { max-width: 420px; }
.qcard.inactive { opacity: .6; }
.qedit .field.good input { border-color: var(--green-line); }
.qedit .field.bad input { border-color: var(--red-line); }

/* Lisibilité (suite de l'audit) */
a, details.more > summary, .qgrid-drawer summary, .toggle-link, .rev summary { color: var(--blue-text); }
.unit-banner { background: #46a302; box-shadow: 0 4px 0 #3a8700; }
.unit-banner[style*="--blue"] { background: #1582bd !important; box-shadow: 0 4px 0 #0f6a9b !important; }
.qgrid .current { background: var(--blue-dark); border-color: #0f6a9b; color: #fff; }
.combo { color: var(--muted); }
.badge.locked { color: var(--muted); }
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) .unit-banner { background: #3a8700; box-shadow: 0 4px 0 #2c6800; }
}
:root[data-theme="dark"] .unit-banner { background: #3a8700; box-shadow: 0 4px 0 #2c6800; }


.topnav .nav-profile { display: none; }
@media (max-width: 640px) {
  .topnav .nav-profile { display: flex; }
  .chips .avatar-link { display: none; }
}

.avatar { background: #1582bd; box-shadow: 0 4px 0 #0f6a9b; }
.avatar.small { box-shadow: 0 3px 0 #0f6a9b; }
.badge-group { font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 14px 0 8px; }
.badge small { display: block; font-weight: 700; font-size: 10.5px; margin-top: 2px; color: var(--muted); }

.check.remember { min-height: 0; margin: 2px 0 14px; font-size: 14.5px; cursor: pointer; }
.check.remember input { width: 18px; height: 18px; accent-color: var(--green); }

.pending-box { text-align: center; }
.pending-box p { color: var(--muted); }
.pending-card { border-color: var(--orange); background: var(--orange-soft); }
.pending-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 0; border-top: 2px solid var(--line); }
.pending-row:first-of-type { border-top: 0; }
.pending-row form { margin: 0; }
.nav-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px; border-radius: 99px;
  background: var(--red); color: #fff; font-size: 12px; font-weight: 900; vertical-align: 1px; }
@media (max-width: 640px) { .topnav a { position: relative; } .nav-badge { position: absolute; top: 0; left: 55%; margin: 0; } }
.theme-toggle {
  background: none; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--text);
  width: 40px; height: 36px; font-size: 17px; line-height: 1; display: grid; place-items: center; flex: none;
}
.theme-toggle:hover { background: var(--hover); }
.chips .theme-toggle { height: 32px; width: 36px; font-size: 15px; }
.theme-toggle.corner { position: fixed; top: calc(14px + env(safe-area-inset-top)); right: 14px; z-index: 10; }
@media (max-width: 600px) { .lesson-top .theme-toggle { width: 32px; height: 32px; border: 0; font-size: 16px; } }
@media (max-width: 400px) { .chips .theme-toggle { width: 32px; height: 30px; font-size: 14px; } }
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { html:not([data-theme="light"]) { color-scheme: dark; } }
body { transition: background-color .25s, color .25s; }
