/* ===== Mise en page générale ===== */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: #e3e5e8;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  color: #1d1d1f;
}

/* ===== En-tête fixe ===== */
#barre {
  position: fixed; top: var(--topbar, 62px); left: 0; right: 0; z-index: 10;   /* sous l'en-tête commun (../commun) */
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 8px 16px;
  background: #161b22; color: #fff;   /* couleurs de l'en-tête commun */
  border-bottom: 1px solid rgba(56,189,248,.22);
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
#barre .groupe { display: flex; align-items: center; gap: 6px; }
#barre .groupe.large select { max-width: 260px; }
#barre .lbl { font-size: 12px; opacity: .7; }
#barre select {
  height: 34px; padding: 0 8px; border: 0; border-radius: 6px;
  background: #212936; color: #fff; font-size: 14px; cursor: pointer;
}
#barre select option { color: #000; background: #fff; }
#barre select option:disabled { color: #aaa; }

button.ico {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; min-width: 34px; padding: 0 8px;
  border: 0; border-radius: 6px; cursor: pointer;
  background: #212936; color: #fff; font-size: 14px;
}
button.ico:hover:not(:disabled) { background: #2a3444; }
button.ico:disabled { opacity: .35; cursor: default; }
button.ico svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
button.mat.actif, button.mat.actif:hover:not(:disabled) { background: #f0b429; color: #24324a; }
#btnP svg path { fill: currentColor; stroke: none; }
#compteur { min-width: 70px; text-align: center; font-size: 14px; }

#zone { padding: 76px 12px 40px; }

/* ===== Feuille A4 ===== */
.feuille {
  width: 210mm; min-height: 297mm;
  margin: 0 auto 24px;
  padding: 16mm 18mm 18mm;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
  font-family: Cambria, Georgia, "Times New Roman", serif;
  font-size: 12pt; line-height: 1.55;
  position: relative;
}
.feuille .haut {
  display: flex; justify-content: space-between; gap: 12px;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 9pt; color: #666;
  border-bottom: 1px solid #ccc; padding-bottom: 4px; margin-bottom: 14px;
}
.feuille h2 {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 0 0 2px; font-size: 16pt; color: #24324a;
}
.feuille h2 .etoiles { font-size: 13pt; letter-spacing: 1px; color: #e09b00; }
.feuille h2 .etoiles .vide { color: #ddd; }
.feuille .titre { margin: 0 0 12px; font-style: italic; color: #444; font-weight: normal; font-size: 12pt; }
.feuille .synthese h2 { color: #8a1c1c; }

.feuille .enonce p { margin: 0 0 8px; }

.feuille figure.schema { margin: 12px auto; text-align: center; }
.feuille figure.schema svg { max-width: 100%; height: auto; }
.feuille figure.schema figcaption { font-size: 10pt; color: #555; font-style: italic; }

.feuille .donnees {
  margin: 10px 0; padding: 6px 12px;
  border-left: 3px solid #24324a; background: #f5f7fa;
}
.feuille .donnees b { font-family: "Segoe UI", Roboto, Arial, sans-serif; font-size: 10.5pt; }
.feuille .donnees ul { margin: 4px 0 0; padding-left: 20px; }

.feuille .questions { list-style: none; margin: 12px 0 0; padding: 0; }
.feuille .questions li { display: flex; gap: 8px; margin: 0 0 7px; }
.feuille .questions li .num { flex: 0 0 auto; font-weight: bold; min-width: 26px; }
.feuille .questions li.sous { padding-left: 26px; }

.feuille .pied {
  position: absolute; bottom: 8mm; left: 18mm; right: 18mm;
  display: flex; justify-content: space-between;
  font-family: "Segoe UI", Roboto, Arial, sans-serif; font-size: 8.5pt; color: #888;
  border-top: 1px solid #e3e3e3; padding-top: 3px;
}

.vide-msg { text-align: center; color: #888; padding-top: 80px; font-family: "Segoe UI", Arial, sans-serif; }

/* Feuille courante en mode chapitre */
.feuille.courante { outline: 3px solid #f0b429; outline-offset: 2px; }

/* ===== Écrans étroits ===== */
@media (max-width: 860px) {
  #barre .lbl { display: none; }
  button.mat span { display: none; }
  #barre .groupe.large select { max-width: 150px; }
  #zone { padding-top: 130px; }
  .feuille { width: 100%; min-height: 0; padding: 18px; }
}

/* ===== Impression ===== */
@page {
  size: A4; margin: 10mm 0 14mm;
  @bottom-left { content: "mimba-educ.com"; font: 8.5pt Arial, sans-serif; color: #888; margin-left: 18mm; }
  @bottom-right { content: counter(page); font: 8.5pt Arial, sans-serif; color: #888; margin-right: 18mm; }
}
@media print {
  #barre { display: none; }
  body { background: #fff; }
  #zone { padding: 0; }
  .feuille { margin: 0; box-shadow: none; outline: none !important; page-break-after: always; min-height: 0; padding-top: 4mm; padding-bottom: 0; }
  .feuille .pied { display: none; }
  .feuille:last-child { page-break-after: auto; }
}

/* ===== Mode prof / menu impression ===== */
#btnProf.actif { background: #2e7d4f; }
.menu-imp { position: relative; }
#menuImp {
  position: absolute; right: 0; top: 40px; z-index: 20;
  background: #fff; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  padding: 6px; display: flex; flex-direction: column; min-width: 230px;
}
#menuImp.cache { display: none; }
#menuImp button {
  border: 0; background: none; text-align: left; padding: 9px 12px; border-radius: 6px;
  font-size: 14px; cursor: pointer; color: #24324a;
}
#menuImp button:hover { background: #eef2f8; }

/* ===== Tableaux ===== */
.feuille table.tab { border-collapse: collapse; margin: 10px auto; font-size: 11pt; }
.feuille table.tab td, .feuille table.tab th { border: 1px solid #555; padding: 4px 10px; text-align: center; min-width: 60px; }
.feuille table.tab th { background: #eef1f5; font-weight: bold; }
.feuille table.tab td.vide { background: #fff; }

/* ===== Questions et corrections ===== */
.feuille .questions li { flex-wrap: wrap; }
.feuille .questions li .qtxt { flex: 1 1 0; }
.feuille .questions li .corr { flex: 0 0 100%; padding-left: 34px; }
.feuille .questions li.sous .corr { padding-left: 34px; }
.bt-corr {
  font-family: "Segoe UI", Roboto, Arial, sans-serif; font-size: 9.5pt;
  border: 1px solid #c7cfdb; background: #f6f8fb; color: #24324a;
  border-radius: 14px; padding: 2px 10px; margin: 4px 6px 2px 0; cursor: pointer;
}
.bt-corr:hover { background: #e9eef6; }
.bloc-rep {
  margin: 6px 0; padding: 8px 12px 8px 14px;
  border: 2px solid #2f6fd6; border-radius: 6px; background: #fff;
}
.bloc-rais {
  margin: 6px 0; padding: 8px 12px;
  border: 1.5px dashed #9aa3ad; border-radius: 6px; background: #f4f5f7;
  font-size: 10.5pt; color: #333;
}
.bloc-titre {
  font-family: "Segoe UI", Roboto, Arial, sans-serif; font-size: 9.5pt; font-weight: bold;
  margin-bottom: 4px;
}
.bloc-rep .bloc-titre { color: #2f6fd6; }
.bloc-rais .bloc-titre { color: #555; }
.bloc-rais .bloc-titre i { font-weight: normal; }
.etiq {
  display: inline-block; font-family: "Segoe UI", Arial, sans-serif; font-size: 9pt;
  padding: 1px 8px; border-radius: 10px; background: #e3e8f0; color: #24324a; margin-bottom: 4px;
}
.bloc-rais .etape { margin: 2px 0; }
.bloc-rais .etape b { color: #24324a; }
.bloc-rais .erreur { margin-top: 6px; color: #8a1c1c; }
.ref { color: #2f6fd6; text-decoration: underline dotted; cursor: pointer; }
.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%,60% { background: #fff3c4; } 100% { background: transparent; } }
.cache { display: none; }

.feuille .retenir {
  margin-top: 14px; padding: 8px 12px; border-left: 4px solid #e09b00; background: #fff8e6;
}
.feuille .retenir .bloc-titre { color: #a06b00; }

/* Animations */
figure.anim { margin: 8px auto; text-align: center; }
figure.anim svg { max-width: 100%; height: auto; }
.anim-ctrl { display: flex; justify-content: center; gap: 6px; margin-top: 4px; }
.anim-ctrl button {
  border: 1px solid #c7cfdb; background: #fff; border-radius: 50%; width: 30px; height: 30px;
  cursor: pointer; font-size: 13px; color: #24324a;
}

/* Feuille « Corrigé » : seulement à l'impression */
.feuille.corrige-imp { display: none; }
.feuille.corrige-imp h2 { color: #2e7d4f; }
.feuille.corrige-imp .cq { margin: 0 0 10px; }
.feuille.corrige-imp .cq > b { display: inline-block; min-width: 34px; }

@media print {
  .bt-corr, .anim-ctrl, #menuImp { display: none !important; }
  .feuille .corr { display: none !important; }
  .feuille .retenir { display: none; }
  body.imp-court .feuille.corrige-imp, body.imp-detail .feuille.corrige-imp { display: block; }
  body.imp-court .feuille.corrige-imp .bloc-rais { display: none; }
  body.imp-detail .feuille.corrige-imp .retenir { display: block; }
  .bloc-rep, .bloc-rais { break-inside: avoid; }
}
.repli { display: none; }
.repli.ouvert, body.prof .repli { display: block; }
body.prof .bt-corr { display: none; }

/* --- Narration et construction pas à pas --- */
.bloc-titre .outils { float: right; display: inline-flex; gap: 6px; }
.bt-voix { font: 12px Arial, sans-serif; border: 1px solid #b9c7dd; background: #f3f7fd; color: #1f4fa8;
  border-radius: 12px; padding: 2px 9px; cursor: pointer; }
.bt-voix:hover { background: #e2ecfa; }
.bt-voix.mini { padding: 0 6px; font-size: 11px; vertical-align: middle; }
.bt-voix.parle { background: #1f4fa8; color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.lignes .lg { margin: 5px 0; line-height: 1.55; }
.lg.masque, .etape.masque { visibility: hidden; }
.lg.apparait, .etape.apparait { animation: entree .5s ease-out; }
.etape.actuelle { background: #fff6d6; border-radius: 4px; }
@keyframes entree { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@media print { .bt-voix, .outils { display: none !important; } }

/* Tableaux : quadrillage complet, lignes d'en-tête en gras */
.feuille table.tab { border: 2px solid #24324a; }
.feuille table.tab td, .feuille table.tab th { border: 1px solid #24324a; }
.feuille table.tab.avancement th { background: #e9eef6; }
.feuille table.tab.avancement tr:nth-child(1) th { background: #dfe8f5; }

/* ---------- Rappel de cours ---------- */
.feuille.cours h4 { display:flex; justify-content:space-between; align-items:center; margin:22px 0 8px; padding:6px 10px;
  background:#24324a; color:#fff; border-radius:6px; font-size:13pt; }
.feuille.cours h4 .bt-voix { background:#fff; }
.c-tt { font-weight:bold; margin-bottom:6px; }
.c-essentiel { border:2px solid #e2a400; background:#fff8e1; border-radius:8px; padding:10px 14px; margin:10px 0; }
.c-essentiel li { margin:4px 0; }
.c-p { margin:8px 0; line-height:1.55; }
.c-liste li { margin:4px 0; line-height:1.5; }
.c-st { margin:14px 0 6px; font-size:12.5pt; color:#1f4fa8; border-bottom:1px dashed #b8c8e6; padding-bottom:2px; }
.c-def { margin:6px 0; padding:6px 10px; border-left:4px solid #1f4fa8; background:#f3f7fd; border-radius:0 6px 6px 0; }
.c-formule { margin:12px auto; max-width:92%; border:2px solid #1f4fa8; border-radius:8px; padding:6px 12px; background:#fff; text-align:center; }
.c-fnom { font-weight:bold; color:#1f4fa8; text-align:left; font-size:11pt; }
.c-f { font-size:13pt; overflow-x:auto; }
.c-fnote { font-size:10.5pt; color:#444; text-align:left; }
.c-demo { margin:10px 0; border:1px dashed #7a8aa5; border-radius:8px; padding:6px 12px; background:#fafbfd; }
.c-demo summary { cursor:pointer; font-weight:bold; color:#24324a; }
.c-demo .lg { margin:5px 0 5px 10px; }
.c-methode { border:2px solid #2e7d32; background:#eef8ef; border-radius:8px; padding:10px 14px; margin:10px 0; }
.c-methode li { margin:4px 0; }
.c-erreurs { border:2px solid #c0392b; background:#fdeeee; border-radius:8px; padding:10px 14px; margin:10px 0; }
.c-erreurs li { margin:4px 0; }
.c-exemple { border:2px solid #6a3fa0; border-radius:8px; padding:10px 14px; margin:10px 0; }
.feuille.cours .actuelle { background:#fff3b0; border-radius:4px; transition:background .3s; }
@media print {
  .c-demo { display:block; } .c-demo > * { display:block; }
  .feuille.cours h4 { background:none; color:#000; border-bottom:2px solid #000; border-radius:0; }
  .feuille.cours .bloc-rep, .feuille.cours .bloc-rais { display:block !important; }
}
.c-leg { text-align:center; font-size:10.5pt; color:#444; font-style:italic; margin:-4px auto 12px; max-width:90%; }
.feuille.cours figure.anim { margin-bottom:4px; }
.bt-voix.tout { font-size:11pt; margin-left:14px; padding:4px 12px; border-radius:16px; vertical-align:middle; }
.feuille.cours figure.actuelle, .feuille.cours .c-b.actuelle { background:transparent; outline:3px solid #f5c518; outline-offset:4px; border-radius:6px; }
@media print { .bt-voix.tout { display:none; } }

/* Voix de « À retenir » : ligne lue surlignée */
.feuille .retenir li.actuelle { background:#fff3b0; border-radius:4px; transition:background .3s; }
.feuille .enonce .bt-enonce { float:right; margin:0 0 4px 10px; }
