/* ============ MPro École — styles ============ */
:root {
  --primaire: #1E40AF;
  --primaire-fonce: #1E3A8A;
  --primaire-clair: #DBEAFE;
  --accent: #F59E0B;
  --accent-clair: #FEF3C7;
  --succes: #16A34A;
  --succes-clair: #DCFCE7;
  --erreur: #DC2626;
  --erreur-clair: #FEE2E2;
  --fond: #F4F6FB;
  --surface: #FFFFFF;
  --surface-2: #EEF1F8;
  --texte: #0F172A;
  --texte-2: #475569;
  --texte-3: #94A3B8;
  --bord: #E2E8F0;
  --ombre: 0 1px 2px rgba(15,23,42,.06), 0 4px 14px rgba(15,23,42,.06);
  --rayon: 16px;
  --taille-texte: 16px;
  --haut: 56px;
  --bas: 64px;
  --sh: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --c-maths: #2563EB; --c-maths-clair: #DBEAFE;
  --c-francais: #E11D48; --c-francais-clair: #FFE4E6;
  --c-pc: #7C3AED; --c-pc-clair: #EDE9FE;
  --c-svt: #16A34A; --c-svt-clair: #DCFCE7;
  --c-anglais: #EA580C; --c-anglais-clair: #FFEDD5;
  color-scheme: light;
}
[data-theme="sombre"] {
  --fond: #0B1220;
  --surface: #131C2E;
  --surface-2: #1B2540;
  --texte: #E8EDF7;
  --texte-2: #A9B4C8;
  --texte-3: #6B7891;
  --bord: #24314D;
  --primaire: #60A5FA;
  --primaire-fonce: #1E3A8A;
  --primaire-clair: #1E2B4F;
  --accent-clair: #3A2C0B;
  --succes-clair: #0F2E1C;
  --erreur-clair: #3A1414;
  --ombre: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
  --c-maths-clair: #172554; --c-francais-clair: #3B0A18; --c-pc-clair: #2A1650;
  --c-svt-clair: #0E2E1A; --c-anglais-clair: #3A1A06;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
  font-size: var(--taille-texte);
  line-height: 1.55;
  background: var(--fond);
  color: var(--texte);
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--primaire); }
[hidden] { display: none !important; }
.ico { flex: none; display: block; }

/* ---------- Structure ---------- */
#app { max-width: 720px; margin: 0 auto; min-height: 100%; position: relative; }
#barre-haut {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  max-width: 720px; margin: 0 auto;
  height: calc(var(--haut) + var(--sh)); padding: var(--sh) 8px 0;
  display: flex; align-items: center; gap: 4px;
  background: var(--surface); border-bottom: 1px solid var(--bord);
}
#titre-zone { flex: 1; min-width: 0; padding: 0 8px; }
#titre-page { font-weight: 750; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sous-titre-page { font-size: 12px; color: var(--texte-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sous-titre-page:empty { display: none; }
.icone-btn { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--texte); }
.icone-btn:active { background: var(--surface-2); }
#vue {
  padding: calc(var(--haut) + var(--sh) + 12px) 16px calc(var(--bas) + var(--sb) + 28px);
  outline: none; min-height: 100vh;
}
body.sans-nav #vue { padding-bottom: calc(var(--sb) + 28px); }
body.sans-nav #nav-bas { display: none; }
body.sans-haut #barre-haut { display: none; }
body.sans-haut #vue { padding-top: calc(var(--sh) + 12px); }
#nav-bas {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  max-width: 720px; margin: 0 auto;
  height: calc(var(--bas) + var(--sb)); padding-bottom: var(--sb);
  display: flex; background: var(--surface); border-top: 1px solid var(--bord);
}
#nav-bas a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--texte-3); font-size: 11px; font-weight: 600;
}
#nav-bas a.actif { color: var(--primaire); }
#nav-bas a.actif .ico { transform: translateY(-1px); }

/* ---------- Éléments ---------- */
.titre-section { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 2px 10px; }
.titre-section h2 { font-size: 17px; margin: 0; font-weight: 750; }
.titre-section a, .titre-section button { font-size: 14px; color: var(--primaire); font-weight: 600; text-decoration: none; }
.carte { background: var(--surface); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 16px; }
.carte + .carte { margin-top: 12px; }
.muet { color: var(--texte-2); }
.petit { font-size: 13px; }
.centre { text-align: center; }
.ligne { display: flex; align-items: center; gap: 10px; }
.espace { flex: 1; }
.vide-etat { text-align: center; color: var(--texte-2); padding: 36px 16px; }
.vide-etat .ico { margin: 0 auto 10px; color: var(--texte-3); }

.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 14px; font-weight: 700;
  background: var(--surface-2); color: var(--texte); text-decoration: none;
  transition: transform .1s;
}
.bouton:active { transform: scale(.97); }
.bouton.primaire { background: var(--primaire-fonce); color: #fff; }
[data-theme="sombre"] .bouton.primaire { background: #2563EB; }
.bouton.accent { background: var(--accent); color: #1F1300; }
.bouton.contour { background: transparent; border: 2px solid var(--bord); }
.bouton.plein { width: 100%; }
.bouton.petit { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.bouton:disabled { opacity: .45; pointer-events: none; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 38px; padding: 0 16px; border-radius: 999px; font-weight: 650; font-size: 14px;
  background: var(--surface); border: 1.5px solid var(--bord); color: var(--texte-2);
}
.chip.actif { background: var(--primaire-fonce); border-color: var(--primaire-fonce); color: #fff; }
[data-theme="sombre"] .chip.actif { background: #2563EB; border-color: #2563EB; }

.barre { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.barre > span { display: block; height: 100%; background: var(--primaire); border-radius: 99px; transition: width .4s; }
.etiquette { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--texte-2); }
.etiquette.ok { background: var(--succes-clair); color: var(--succes); }
.etiquette.bientot { background: var(--accent-clair); color: #B45309; }
[data-theme="sombre"] .etiquette.bientot { color: #FBBF24; }

/* Couleurs de matière */
.m-maths { --c: var(--c-maths); --c-clair: var(--c-maths-clair); }
.m-francais { --c: var(--c-francais); --c-clair: var(--c-francais-clair); }
.m-pc { --c: var(--c-pc); --c-clair: var(--c-pc-clair); }
.m-svt { --c: var(--c-svt); --c-clair: var(--c-svt-clair); }
.m-anglais { --c: var(--c-anglais); --c-clair: var(--c-anglais-clair); }
.pastille-matiere { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--c-clair); color: var(--c); flex: none; }

/* ---------- Accueil ---------- */
.hero {
  border-radius: 22px; padding: 20px; color: #fff;
  background: linear-gradient(135deg, #1E3A8A 0%, #4F46E5 100%);
  position: relative; overflow: hidden;
}
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255,255,255,.08); }
.hero h1 { margin: 0 0 4px; font-size: 22px; }
.hero p { margin: 0; opacity: .85; font-size: 14px; }
.hero .stats { display: flex; gap: 10px; margin-top: 16px; }
.hero .stat { flex: 1; background: rgba(255,255,255,.12); border-radius: 14px; padding: 10px; }
.hero .stat b { display: flex; align-items: center; gap: 5px; font-size: 20px; }
.hero .stat span { font-size: 12px; opacity: .85; }
.recherche-faux {
  margin-top: 14px; display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--surface); color: var(--texte-3); border-radius: 14px; padding: 13px 14px; box-shadow: var(--ombre); font-size: 15px; text-align: left;
}
.grille-matieres { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.carte-matiere { background: var(--surface); border-radius: var(--rayon); padding: 14px; box-shadow: var(--ombre); text-align: left; display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--texte); border-bottom: 4px solid var(--c); }
.carte-matiere b { font-size: 15px; }
.carte-matiere .petit { color: var(--texte-2); }
.continuer { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--texte); }
.continuer .espace { min-width: 0; }
.continuer b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Listes de leçons ---------- */
.chapitre-titre { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--texte-3); margin: 22px 4px 8px; }
.liste { background: var(--surface); border-radius: var(--rayon); box-shadow: var(--ombre); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px; width: 100%; text-align: left;
  text-decoration: none; color: var(--texte); border-bottom: 1px solid var(--bord); min-height: 64px;
}
.item:last-child { border-bottom: 0; }
.item:active { background: var(--surface-2); }
.item .espace { min-width: 0; }
.item b { display: block; font-weight: 650; line-height: 1.3; }
.item .petit { color: var(--texte-2); }
.item.verrou { opacity: .6; }
.num-lecon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; background: var(--c-clair, var(--surface-2)); color: var(--c, var(--texte-2)); flex: none; }
.num-lecon.fait { background: var(--succes); color: #fff; }

/* ---------- Recherche ---------- */
.champ-recherche { position: relative; }
.champ-recherche input {
  width: 100%; height: 52px; border-radius: 14px; border: 2px solid var(--bord); background: var(--surface);
  padding: 0 46px 0 46px; font-size: 16px; outline: none;
}
.champ-recherche input:focus { border-color: var(--primaire); }
.champ-recherche > .ico { position: absolute; left: 14px; top: 15px; color: var(--texte-3); }
.champ-recherche .effacer { position: absolute; right: 4px; top: 4px; }
mark { background: var(--accent-clair); color: inherit; border-radius: 3px; padding: 0 1px; }
.extrait { font-size: 13px; color: var(--texte-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Leçon ---------- */
.lecon-entete { border-radius: 22px; padding: 18px; background: var(--c-clair); margin-bottom: 14px; }
.lecon-entete .etiquettes { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.lecon-entete .etiquette { background: var(--surface); color: var(--c); }
.lecon-entete h1 { margin: 0; font-size: 23px; line-height: 1.25; }
.lecon-entete p { margin: 8px 0 0; color: var(--texte-2); font-size: 15px; }
.lecon-entete .actions { display: flex; gap: 8px; margin-top: 14px; }
.lecon-entete .bouton.primaire { background: var(--c); }
.progression-lecon { position: sticky; top: calc(var(--haut) + var(--sh)); z-index: 5; height: 4px; margin: 0 -16px 10px; background: var(--surface-2); }
.progression-lecon span { display: block; height: 100%; background: var(--c); width: 0; transition: width .2s; }

.bloc { background: var(--surface); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 16px; margin-bottom: 12px; border-left: 5px solid transparent; transition: box-shadow .3s, border-color .3s; scroll-margin-top: 90px; }
.bloc-tete { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.bloc-tete h3 { margin: 0; font-size: 16.5px; flex: 1; }
.bloc-type { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--c); }
.bloc p { margin: 0 0 10px; }
.bloc p:last-child { margin-bottom: 0; }
.bloc ul, .bloc ol { margin: 6px 0 10px; padding-left: 22px; }
.bloc li { margin: 4px 0; }
.bloc.intro { border-left-color: var(--c); }
.bloc.exemple { background: var(--surface); border-left-color: var(--accent); }
.bloc.exemple .bloc-type { color: #B45309; }
[data-theme="sombre"] .bloc.exemple .bloc-type { color: #FBBF24; }
.bloc.retenir { background: var(--c-clair); border-left-color: var(--c); }
.bloc.attention { background: var(--erreur-clair); border-left-color: var(--erreur); }
.bloc.attention .bloc-type { color: var(--erreur); }
.bloc.lecture-en-cours { box-shadow: 0 0 0 3px var(--c), var(--ombre); }
.btn-ecouter { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--c-clair); color: var(--c); flex: none; }
.bloc.retenir .btn-ecouter { background: var(--surface); }
.btn-ecouter.actif { background: var(--c); color: #fff; }
.formule { display: block; text-align: center; font-size: 1.15em; font-weight: 700; background: var(--surface-2); border-radius: 12px; padding: 12px; margin: 10px 0; overflow-x: auto; }
.bloc.retenir .formule { background: var(--surface); }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.1; margin: 0 2px; font-size: .95em; }
.frac > span:first-child { border-bottom: 1.6px solid currentColor; padding: 0 3px; }
.frac > span:last-child { padding: 0 3px; }
.tableau { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 15px; }
.tableau th, .tableau td { border: 1px solid var(--bord); padding: 7px 8px; text-align: left; }
.tableau th { background: var(--surface-2); }
.tableau-defile { overflow-x: auto; }
/* Notations mathématiques */
.lim { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.05; margin-right: 3px; }
.lim > span { font-size: .62em; font-weight: 600; white-space: nowrap; }
.integ { display: inline-flex; align-items: center; vertical-align: middle; }
.integ > .s { font-size: 1.55em; font-weight: 400; line-height: 1; }
.integ > .b { display: inline-flex; flex-direction: column; justify-content: space-between; font-size: .62em; line-height: 1.15; margin: 0 2px 0 1px; align-self: stretch; }
.conj { text-decoration: overline; }
.vec { position: relative; display: inline-block; padding-top: .3em; line-height: 1; }
.vec::before { content: ''; position: absolute; top: .05em; left: 1px; right: 1px; height: 1.5px; background: currentColor; }
.vec::after { content: ''; position: absolute; top: -.12em; right: 0; border: .2em solid transparent; border-left: .32em solid currentColor; border-right: 0; }
.nucl { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: right; font-size: .62em; line-height: 1.05; margin-right: 1px; }
.geno { white-space: nowrap; font-weight: 600; }
.citation { margin: 10px 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 10px 10px 0; font-style: italic; line-height: 1.6; }
.citation .source { display: block; margin-top: 6px; font-style: normal; font-size: .85em; color: var(--texte-2); }
.echiquier th, .echiquier td { text-align: center; white-space: nowrap; }
.echiquier td small { display: block; opacity: .75; font-size: .82em; }
.binom { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.05; font-size: .9em; padding: 0 5px; margin: 0 2px; border: solid currentColor; border-width: 0 1.5px; border-radius: 9px; }
.tab-var th, .tab-var td { text-align: center; padding: 6px 5px; white-space: nowrap; }
.tab-var th { width: 1%; }
.tab-var .tv-i { color: var(--texte-2); }
.tab-var .tv-fleche { font-size: 1.35em; color: var(--c); font-weight: 700; }
.figure { display: flex; justify-content: center; margin: 10px 0; }
.figure svg { max-width: 100%; height: auto; }
.en { font-style: italic; color: var(--c-anglais); font-weight: 600; }

/* Étapes à dévoiler */
.etape { display: flex; gap: 10px; padding: 10px 0; border-top: 1px dashed var(--bord); }
.etape:first-of-type { border-top: 0; }
.etape .n { width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--c); color: #fff; font-weight: 800; font-size: 13px; display: grid; place-items: center; margin-top: 1px; }
.etape.cachee { display: none; }
.btn-etape { margin-top: 8px; }

/* Quiz dans le cours + exercices */
.question { font-weight: 650; margin-bottom: 12px; }
.choix-liste { display: grid; gap: 8px; }
.choix {
  width: 100%; min-height: 50px; padding: 10px 14px; border-radius: 13px; text-align: left;
  border: 2px solid var(--bord); background: var(--surface); display: flex; align-items: center; gap: 10px; font-weight: 550;
}
.choix .lettre { width: 28px; height: 28px; border-radius: 8px; flex: none; display: grid; place-items: center; background: var(--surface-2); font-weight: 800; font-size: 13px; }
.choix.selection { border-color: var(--primaire); }
.choix.juste { border-color: var(--succes); background: var(--succes-clair); }
.choix.juste .lettre { background: var(--succes); color: #fff; }
.choix.faux { border-color: var(--erreur); background: var(--erreur-clair); }
.choix.faux .lettre { background: var(--erreur); color: #fff; }
.choix:disabled { cursor: default; }
.vf { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vf .choix { justify-content: center; }
.champ {
  width: 100%; height: 52px; border-radius: 13px; border: 2px solid var(--bord); background: var(--surface);
  padding: 0 14px; font-size: 17px; outline: none;
}
.champ:focus { border-color: var(--primaire); }
.champ.juste { border-color: var(--succes); background: var(--succes-clair); }
.champ.faux { border-color: var(--erreur); background: var(--erreur-clair); }
.trou {
  display: inline-block; min-width: 90px; width: auto; height: 36px; border: 0; border-bottom: 2.5px solid var(--primaire);
  background: var(--surface-2); border-radius: 8px 8px 0 0; padding: 0 8px; margin: 2px; font-size: 16px; text-align: center; outline: none;
}
.trou.juste { border-bottom-color: var(--succes); background: var(--succes-clair); }
.trou.faux { border-bottom-color: var(--erreur); background: var(--erreur-clair); }
.texte-trous { line-height: 2.3; }
.ordre-zone { min-height: 54px; border: 2px dashed var(--bord); border-radius: 13px; padding: 8px; display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.ordre-zone:empty::before { content: "Touche les éléments dans le bon ordre"; color: var(--texte-3); font-size: 14px; padding: 6px; }
.jeton { min-height: 40px; padding: 0 14px; border-radius: 11px; background: var(--surface-2); font-weight: 650; border: 2px solid transparent; }
.ordre-zone .jeton { background: var(--primaire-clair); }
.jeton.juste { border-color: var(--succes); } .jeton.faux { border-color: var(--erreur); }
.reponse-retour { margin-top: 12px; border-radius: 13px; padding: 12px 14px; font-size: 15px; }
.reponse-retour.ok { background: var(--succes-clair); }
.reponse-retour.ko { background: var(--erreur-clair); }
.reponse-retour b { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.reponse-retour.ok b { color: var(--succes); } .reponse-retour.ko b { color: var(--erreur); }
.actions-exo { display: flex; gap: 8px; margin-top: 14px; }
.actions-exo .bouton { flex: 1; }

/* Écran exercice */
.exo-tete { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.exo-tete .barre { flex: 1; }
.exo-compteur { font-weight: 800; font-size: 14px; color: var(--texte-2); }
.exo-carte { min-height: 260px; }
.resultat-final { text-align: center; padding: 28px 16px; }
.score-cercle { width: 130px; height: 130px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; font-size: 34px; font-weight: 900; background: conic-gradient(var(--c, var(--primaire)) calc(var(--p) * 1%), var(--surface-2) 0); position: relative; }
.score-cercle::before { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--surface); }
.score-cercle span { position: relative; }

/* ---------- Bouton flottant ---------- */
.fab-zone { position: fixed; right: max(16px, calc(50% - 360px + 16px)); bottom: calc(var(--sb) + 20px); z-index: 25; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
body:not(.sans-nav) .fab-zone { bottom: calc(var(--bas) + var(--sb) + 16px); }
.fab { width: 58px; height: 58px; border-radius: 18px; background: var(--c, var(--primaire-fonce)); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 20px rgba(0,0,0,.25); transition: transform .2s; }
.fab.ouvert { transform: rotate(45deg); }
.fab-menu { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.fab-option { display: flex; align-items: center; gap: 10px; background: var(--surface); color: var(--texte); border-radius: 14px; padding: 0 14px 0 10px; height: 48px; box-shadow: var(--ombre); font-weight: 650; animation: monte .18s ease-out; }
.fab-option .ico { color: var(--c, var(--primaire)); }
@keyframes monte { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Feuille du bas ---------- */
#feuille-fond { position: fixed; inset: 0; background: rgba(2,6,23,.5); z-index: 55; animation: fondu .2s; }
#feuille {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 56; max-width: 720px; margin: 0 auto;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 8px 16px calc(var(--sb) + 16px);
  max-height: 88vh; overflow-y: auto; animation: glisse .25s ease-out;
}
#feuille .poignee { width: 42px; height: 5px; border-radius: 9px; background: var(--bord); margin: 4px auto 12px; }
#feuille h2 { margin: 0 0 12px; font-size: 19px; }
@keyframes glisse { from { transform: translateY(100%); } }
@keyframes fondu { from { opacity: 0; } }
textarea.zone-note { width: 100%; min-height: 180px; border: 2px solid var(--bord); border-radius: 14px; padding: 12px; resize: vertical; background: var(--surface); outline: none; font-size: 16px; line-height: 1.5; }
textarea.zone-note:focus { border-color: var(--primaire); }
input.champ-titre { width: 100%; border: 0; border-bottom: 2px solid var(--bord); padding: 8px 2px; font-size: 18px; font-weight: 700; background: transparent; outline: none; margin-bottom: 12px; }
.lien-lecon { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; background: var(--surface-2); padding: 5px 10px; border-radius: 99px; color: var(--texte-2); margin-bottom: 10px; }

/* ---------- Cahier ---------- */
.onglets { display: flex; background: var(--surface-2); border-radius: 14px; padding: 4px; margin-bottom: 14px; }
.onglets button { flex: 1; min-height: 42px; border-radius: 11px; font-weight: 700; color: var(--texte-2); }
.onglets button.actif { background: var(--surface); color: var(--texte); box-shadow: var(--ombre); }
.grille-pages { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vignette { background: var(--surface); border-radius: 14px; box-shadow: var(--ombre); overflow: hidden; text-align: left; }
.vignette img, .vignette .vide { display: block; width: 100%; aspect-ratio: 3/4; object-fit: cover; background: #fff; }
.vignette .info { padding: 8px 10px; font-size: 13px; }
.vignette .info b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item .extrait { -webkit-line-clamp: 2; }

/* ---------- Page blanche / brouillon ---------- */
#brouillon { position: fixed; inset: 0; z-index: 50; background: #fff; display: flex; flex-direction: column; touch-action: none; color: #0F172A; }
#brouillon .bh { height: calc(52px + var(--sh)); padding: var(--sh) 6px 0; display: flex; align-items: center; gap: 4px; background: #F8FAFC; border-bottom: 1px solid #E2E8F0; }
#brouillon .bh input { flex: 1; min-width: 0; border: 0; background: transparent; font-weight: 700; font-size: 16px; outline: none; padding: 6px; color: #0F172A; }
#brouillon .bh .icone-btn, #brouillon .outils .icone-btn { color: #0F172A; }
#brouillon .bh .icone-btn:disabled { opacity: .3; }
#brouillon .toile-zone { flex: 1; position: relative; overflow: hidden; }
#brouillon canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#brouillon .outils { padding: 8px 8px calc(var(--sb) + 8px); background: #F8FAFC; border-top: 1px solid #E2E8F0; }
#brouillon .outils-ligne { display: flex; align-items: center; gap: 4px; justify-content: space-between; }
#brouillon .outil { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; color: #0F172A; }
#brouillon .outil.actif { background: #DBEAFE; color: #1E40AF; }
#brouillon .pastille-couleur { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1.5px #CBD5E1; }
#brouillon .pastille-couleur.actif { box-shadow: 0 0 0 2.5px #1E40AF; }
#brouillon .panneau { display: flex; gap: 10px; align-items: center; padding: 6px 4px 10px; overflow-x: auto; }
#brouillon .taille { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; }
#brouillon .taille.actif { background: #DBEAFE; }
#brouillon .taille i { display: block; border-radius: 50%; background: #0F172A; }
#brouillon .num-page { font-size: 13px; font-weight: 700; color: #475569; min-width: 44px; text-align: center; }

/* ---------- Lecteur voix ---------- */
#lecteur-voix {
  position: fixed; left: 12px; right: 12px; z-index: 30; max-width: 696px; margin: 0 auto;
  bottom: calc(var(--sb) + 12px); background: #0F172A; color: #fff; border-radius: 18px; padding: 8px 8px 8px 14px;
  display: flex; align-items: center; gap: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.3); animation: monte .2s;
}
body:not(.sans-nav) #lecteur-voix { bottom: calc(var(--bas) + var(--sb) + 10px); }
#lecteur-voix .txt { flex: 1; min-width: 0; font-size: 13px; }
#lecteur-voix .txt b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#lecteur-voix .icone-btn { color: #fff; }
#lecteur-voix .vitesse { font-weight: 800; font-size: 13px; width: 48px; height: 36px; border-radius: 10px; background: rgba(255,255,255,.12); }
body.voix-active .fab-zone { bottom: calc(var(--bas) + var(--sb) + 86px); }
body.voix-active.sans-nav .fab-zone { bottom: calc(var(--sb) + 86px); }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; top: calc(var(--sh) + 12px); transform: translate(-50%, -200%); visibility: hidden; z-index: 60; background: #0F172A; color: #fff; padding: 11px 18px; border-radius: 14px; font-weight: 600; font-size: 14px; transition: transform .3s, visibility .3s; max-width: 90vw; text-align: center; box-shadow: 0 10px 24px rgba(0,0,0,.25); }
#toast.visible { transform: translate(-50%, 0); visibility: visible; }

/* ---------- Examens ---------- */
.exam-carte { display: flex; gap: 12px; align-items: center; }
.exam-date { width: 58px; flex: none; text-align: center; border-radius: 14px; background: var(--c-clair); color: var(--c); padding: 6px 0; }
.exam-date b { display: block; font-size: 22px; line-height: 1.1; }
.exam-date span { font-size: 11px; font-weight: 800; text-transform: uppercase; }
.exam-ouvert { border: 2px solid var(--succes); }
.chrono { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-variant-numeric: tabular-nums; background: var(--surface-2); border-radius: 10px; padding: 6px 10px; }
.chrono.urgent { background: var(--erreur-clair); color: var(--erreur); }
.certif-apercu { width: 100%; border-radius: 12px; box-shadow: var(--ombre); display: block; background: #fff; }
.grille-certifs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.badge-certif { background: var(--surface); border-radius: 16px; padding: 14px 10px; text-align: center; box-shadow: var(--ombre); }
.badge-certif .medaille { width: 54px; height: 54px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.or { background: linear-gradient(135deg, #F59E0B, #B45309); }
.argent { background: linear-gradient(135deg, #94A3B8, #475569); }
.bronze { background: linear-gradient(135deg, #D97706, #7C2D12); }
.reussi { background: linear-gradient(135deg, #22C55E, #15803D); }
.regles { margin: 0; padding-left: 20px; } .regles li { margin: 6px 0; }

/* ---------- Profil / réglages ---------- */
.profil-tete { display: flex; align-items: center; gap: 14px; }
.avatar { width: 64px; height: 64px; border-radius: 20px; background: linear-gradient(135deg, #1E3A8A, #4F46E5); color: #fff; display: grid; place-items: center; font-size: 26px; font-weight: 800; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.reglage { display: flex; align-items: center; gap: 12px; padding: 14px; border-bottom: 1px solid var(--bord); }
.reglage:last-child { border-bottom: 0; }
.reglage .espace b { display: block; font-weight: 650; }
.reglage select { max-width: 52%; height: 40px; border-radius: 10px; border: 1.5px solid var(--bord); background: var(--surface); padding: 0 8px; }
.interrupteur { width: 52px; height: 30px; border-radius: 99px; background: var(--bord); position: relative; flex: none; transition: background .2s; }
.interrupteur::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.interrupteur.on { background: var(--succes); }
.interrupteur.on::after { transform: translateX(22px); }
input[type=range] { width: 100%; accent-color: var(--primaire); }
.stat-matiere { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.stat-matiere .espace .barre { margin-top: 6px; }

/* ---------- Bienvenue ---------- */
.bienvenue { min-height: calc(100vh - 40px); display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 10px 4px; }
.bienvenue .logo { width: 88px; height: 88px; border-radius: 26px; margin: 0 auto; display: block; box-shadow: 0 12px 30px rgba(30,58,138,.35); }
.bienvenue h1 { text-align: center; margin: 0; font-size: 28px; }
.bienvenue .lead { text-align: center; color: var(--texte-2); margin: 0; }
.atouts { display: grid; gap: 10px; }
.atout { display: flex; gap: 12px; align-items: center; background: var(--surface); border-radius: 14px; padding: 12px; box-shadow: var(--ombre); }
.atout .pastille-matiere { width: 40px; height: 40px; }
.grille-classes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grille-classes .chip { width: 100%; padding: 0; }
.separateur { display: flex; align-items: center; gap: 10px; color: var(--texte-3); font-size: 13px; }
.separateur::before, .separateur::after { content: ""; flex: 1; height: 1px; background: var(--bord); }
.bouton-google { background: var(--surface); border: 2px solid var(--bord); color: var(--texte); }

@media (min-width: 560px) {
  .grille-matieres { grid-template-columns: repeat(3, 1fr); }
  .grille-pages { grid-template-columns: repeat(3, 1fr); }
  .grille-certifs { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
a.carte, a.exam-carte, a.badge-certif { text-decoration: none; color: inherit; display: flex; }
a.carte.continuer, a.carte.exam-carte { display: flex; }
#brouillon .panneau .pastille-couleur { flex: none; }
.onglets button { display: flex; align-items: center; justify-content: center; gap: 6px; }

/* ============ Professeur mascotte ============ */
/* ---------- Mascotte ---------- */
.mascotte { position: relative; width: var(--taille, 100%); flex: none; }
.mascotte-svg { display: block; width: 100%; height: auto; overflow: visible; }
.mascotte .mascotte-svg { transform-origin: 50% 92%; animation: respire 3.6s ease-in-out infinite; }
.mascotte.saute .mascotte-svg { animation: mascotte-saute .6s cubic-bezier(.3,1.5,.5,1); }
.mascotte-svg .m-corps { transform-origin: 50px 60px; }
.mascotte-svg .m-oeil { transition: transform .07s; }
.mascotte-svg .m-oeil.ferme { transform: scaleY(.12); }
@keyframes respire { 50% { transform: translateY(1.5%) scale(1.012, .988); } }
@keyframes mascotte-saute { 0% { transform: none; } 30% { transform: translateY(-16%) scale(.96, 1.05); } 60% { transform: translateY(0) scale(1.06, .94); } 100% { transform: none; } }
.bulle-mascotte {
  position: absolute; left: 78%; bottom: 82%; z-index: 3; width: max-content; max-width: 210px;
  padding: 6px 10px; border-radius: 14px 14px 14px 4px; background: #fff; color: #1E1B2E;
  font-size: 12.5px; font-weight: 600; line-height: 1.3; text-align: left; box-shadow: 0 6px 18px rgba(0,0,0,.25);
  transform-origin: 0 100%; animation: bulle .25s cubic-bezier(.3,1.4,.6,1);
}
.bulle-mascotte b { display: block; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #7C3AED; }
@keyframes bulle { from { opacity: 0; transform: scale(.6); } }

/* Choix du professeur */
.prof-editeur { display: grid; gap: 16px; }
.prof-apercu { position: relative; display: flex; justify-content: center; padding: 26px 0 4px; min-height: 150px; }
.prof-apercu .bulle-mascotte { left: 58%; bottom: 84%; max-width: 150px; }
.prof-champ { display: grid; gap: 8px; }
.choix-formes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.choix-forme { aspect-ratio: 1; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); border: 2px solid transparent; }
.choix-forme.actif { border-color: var(--primaire); background: var(--primaire-clair); }
.choix-forme .mascotte-svg { width: 82%; }
.choix-couleurs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; justify-items: center; }
.choix-couleur { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--bord); }
.choix-couleur.actif { box-shadow: 0 0 0 3px var(--texte); }
.noms-proposes { margin-top: -8px; }
.choix-voix { display: grid; gap: 8px; }
.choix-voix-btn { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 14px; border-radius: 14px; text-align: left; background: var(--surface); border: 2px solid var(--bord); }
.choix-voix-btn .ico { color: var(--primaire); }
.choix-voix-btn b { display: block; }
.choix-voix-btn .petit { color: var(--texte-2); }
.choix-voix-btn.actif { border-color: var(--primaire); background: var(--primaire-clair); }

/* Le professeur dans l'appli */
.prof-accueil { display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 14px; padding: 10px 14px 10px 10px; text-align: left; color: var(--texte); text-decoration: none; }
.prof-accueil .espace { min-width: 0; }
.prof-accueil b { display: block; }
.prof-accueil > .ico { color: var(--primaire); }
.pa-mascotte { width: 58px; flex: none; }
.item-mascotte { width: 34px; display: grid; place-items: center; flex: none; }
.exo-mascotte { position: relative; width: 46px; flex: none; }
.exo-mascotte .bulle-mascotte { left: calc(100% + 6px); bottom: auto; top: 2px; border-radius: 4px 14px 14px 14px; transform-origin: 0 0; }
.exo-mascotte.grand { width: 96px; margin: -6px auto 10px; }
.exo-mascotte.grand .bulle-mascotte { top: -6px; }
