:root {
  color-scheme: light;
  --fond: #fff8ef;
  --carte: #ffffff;
  --texte: #2b2620;
  --doux: #7a6f63;
  --trait: #efe4d6;
  --ok: #1e9e5a;
  --ok-fond: #e3f6ec;
  --alerte: #e07a12;
  --alerte-fond: #fff0dc;
  --rouge: #d64545;
  --accent: #2f6fe4;          /* change selon l'espace (enfant / parent) */
  --accent-fond: #e7efff;
  --rayon: 22px;
  --ombre: 0 2px 0 rgba(43, 38, 32, .04), 0 8px 24px rgba(43, 38, 32, .06);
}
body.lucas    { --accent: #2f6fe4; --accent-fond: #e7efff; }
body.victoria { --accent: #b84ad6; --accent-fond: #f6e9fb; }
body.parent   { --accent: #3d4a5c; --accent-fond: #e9edf2; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--fond); color: var(--texte);
  font: 18px/1.4 ui-rounded, "SF Pro Rounded", -apple-system, system-ui, "Segoe UI", sans-serif;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 1100px; margin: 0 auto; }
h1 { font-size: 32px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 21px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }

/* ---------- en-tête ---------- */
.entete { display: flex; align-items: center; gap: 14px; margin: 4px 0 20px; flex-wrap: wrap; }
.entete .titre { flex: 1; min-width: 200px; }
.entete .sous { color: var(--doux); font-size: 16px; margin-top: 2px; }
.retour {
  width: 48px; height: 48px; border-radius: 16px; background: var(--carte); box-shadow: var(--ombre);
  font-size: 22px; display: grid; place-items: center; flex: none;
}
.pastille { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 14px; font-weight: 600; background: var(--accent-fond); color: var(--accent); }
.pastille.demo { background: var(--alerte-fond); color: var(--alerte); }

/* ---------- grille de cartes ---------- */
.grille { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.carte { background: var(--carte); border-radius: var(--rayon); padding: 20px; box-shadow: var(--ombre); }
.carte.large { grid-column: 1 / -1; }
.vide { color: var(--doux); font-size: 16px; padding: 6px 0; }

/* ---------- accueil ---------- */
.profils { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 8px; }
.profil {
  background: var(--carte); border-radius: 28px; box-shadow: var(--ombre); padding: 28px 22px;
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; min-height: 230px; justify-content: center;
  transition: transform .12s ease;
}
.profil:active { transform: scale(.97); }
.profil .avatar { width: 108px; height: 108px; border-radius: 50%; display: grid; place-items: center; font-size: 54px; }
.profil.lucas .avatar { background: #e7efff; }
.profil.victoria .avatar { background: #f6e9fb; }
.profil.parent .avatar { background: #e9edf2; }
.profil .nom { font-size: 26px; font-weight: 700; }
.profil .info { color: var(--doux); font-size: 16px; }
.pied { color: var(--doux); font-size: 14px; text-align: center; margin-top: 28px; }

/* ---------- écran du code ---------- */
.code { max-width: 420px; margin: 10vh auto 0; text-align: center; }
.code .logo { font-size: 64px; }
.code h1 { margin: 8px 0 6px; }
.code p { color: var(--doux); margin-bottom: 22px; }
.code input {
  width: 100%; font: inherit; font-size: 22px; text-align: center; padding: 16px; border-radius: 18px;
  border: 2px solid var(--trait); background: var(--carte); color: var(--texte);
}
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; font-weight: 700; padding: 15px 22px; border-radius: 18px; min-height: 52px;
}
.code .bouton { width: 100%; margin-top: 12px; }
.bouton.secondaire { background: var(--accent-fond); color: var(--accent); }
.erreur { color: var(--rouge); margin-top: 12px; min-height: 1.4em; font-size: 16px; }

/* ---------- onglets ---------- */
.onglets { display: flex; gap: 8px; background: var(--carte); padding: 6px; border-radius: 18px; box-shadow: var(--ombre); margin-bottom: 18px; overflow-x: auto; }
.onglets button { padding: 10px 16px; border-radius: 13px; font-weight: 600; white-space: nowrap; color: var(--doux); }
.onglets button[aria-selected="true"] { background: var(--accent); color: #fff; }

/* ---------- emploi du temps ---------- */
.journee { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cours { display: grid; grid-template-columns: 62px 40px 1fr; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 16px; background: var(--accent-fond); }
.cours .heure { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); font-size: 16px; }
.cours .emoji { font-size: 24px; text-align: center; }
.cours .matiere { font-weight: 600; }
.cours.pause { background: none; padding: 2px 12px; color: var(--doux); font-size: 15px; }
.cours.pause .heure { color: var(--doux); font-weight: 500; }
.cours.pause .emoji { font-size: 18px; }
.cours.maintenant { outline: 3px solid var(--accent); }
.cours.controle { background: var(--alerte-fond); }
.cours .badge { margin-left: 6px; font-size: 13px; font-weight: 700; color: var(--alerte); }

/* ---------- contrôles & notes ---------- */
.liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ligne { display: flex; align-items: center; gap: 12px; }
.ligne .corps { flex: 1; min-width: 0; }
.ligne .titre { font-weight: 600; }
.ligne .detail { color: var(--doux); font-size: 15px; }
.quand { flex: none; min-width: 74px; text-align: center; padding: 8px 10px; border-radius: 14px; background: var(--alerte-fond); color: var(--alerte); font-weight: 700; font-size: 15px; }
.quand.loin { background: var(--accent-fond); color: var(--accent); }
.note { flex: none; width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; font-weight: 800; font-size: 20px; background: var(--ok-fond); color: var(--ok); }
.note.faible { background: var(--alerte-fond); color: var(--alerte); }

/* ---------- checklist ---------- */
.progression { height: 10px; border-radius: 99px; background: var(--trait); overflow: hidden; margin: 2px 0 14px; }
.progression div { height: 100%; background: var(--ok); border-radius: 99px; transition: width .25s ease; }
.coche { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 12px; border-radius: 16px; background: #faf6f0; }
.coche .case { width: 34px; height: 34px; border-radius: 11px; border: 3px solid var(--trait); flex: none; display: grid; place-items: center; font-size: 20px; color: #fff; background: #fff; }
.coche[aria-checked="true"] .case { background: var(--ok); border-color: var(--ok); }
.coche[aria-checked="true"] .texte { color: var(--doux); text-decoration: line-through; }
.bravo { margin-top: 12px; padding: 12px; border-radius: 16px; background: var(--ok-fond); color: var(--ok); font-weight: 700; text-align: center; }

.bascule { display: inline-flex; background: #f3ece2; border-radius: 14px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.bascule button { padding: 8px 14px; border-radius: 11px; font-weight: 600; color: var(--doux); }
.bascule button[aria-pressed="true"] { background: var(--carte); color: var(--texte); box-shadow: var(--ombre); }

/* ---------- espace parent ---------- */
table { width: 100%; border-collapse: collapse; font-size: 16px; }
th { text-align: left; color: var(--doux); font-weight: 600; font-size: 14px; padding: 8px 6px; border-bottom: 2px solid var(--trait); }
td { padding: 10px 6px; border-bottom: 1px solid var(--trait); vertical-align: top; }
td.montant { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.table-defile { overflow-x: auto; }
.com { padding: 12px 0; border-bottom: 1px solid var(--trait); display: flex; gap: 12px; align-items: baseline; }
.com:last-child { border-bottom: 0; }
.com .point { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 6px; }
.com.lu .point { background: var(--trait); }
.com .titre { font-weight: 600; }
.com.lu .titre { font-weight: 400; }
.alerte { background: var(--alerte-fond); color: #8a4a06; padding: 12px 16px; border-radius: 16px; margin-bottom: 16px; font-size: 16px; }

@media (max-width: 520px) {
  body { font-size: 17px; }
  h1 { font-size: 26px; }
  .profil { min-height: 170px; padding: 20px; }
  .profil .avatar { width: 80px; height: 80px; font-size: 40px; }
  .cours { grid-template-columns: 54px 32px 1fr; }
}

/* ---------- exercices : carte d'accueil ---------- */
.carte.exos { grid-column: 1 / -1; }
.compteurs { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.compteur { flex: 1; min-width: 110px; background: var(--accent-fond); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; align-items: center; }
.gros { font-size: 26px; font-weight: 800; }
.tuiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.tuile {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 18px 12px; border-radius: 20px;
  background: #faf6f0; border: 3px solid transparent; transition: transform .12s ease; min-height: 140px; justify-content: center;
}
.tuile:active { transform: scale(.96); }
.tuile.urgente { border-color: var(--alerte); background: var(--alerte-fond); }
.emoji-tuile { font-size: 44px; line-height: 1.1; }
.nom-tuile { font-weight: 800; font-size: 19px; }

/* ---------- exercices : écrans ---------- */
.bouton.enorme { width: 100%; font-size: 21px; min-height: 64px; border-radius: 20px; margin-top: 14px; }
.centre { text-align: center; }
.texte-lecture p { font-size: 24px; line-height: 1.65; margin: 0 0 14px; }
body.lucas .texte-lecture p { font-size: 21px; }
.texte-lecture.cache { filter: blur(9px); user-select: none; pointer-events: none; }
.actions-lecture { margin-top: 8px; }
.resultat-lecture { text-align: center; background: var(--ok-fond); color: #145c36; border-radius: 18px; padding: 16px; }
.lecon-fiche .points { font-size: 20px; line-height: 1.5; padding-left: 26px; margin: 0 0 12px; }
.lecon-fiche .points li { margin-bottom: 8px; }
.exemple { background: var(--accent-fond); border-radius: 16px; padding: 14px; font-size: 19px; }
.pastille-controle { background: var(--alerte-fond); color: #8a4a06; border-radius: 14px; padding: 10px 14px; font-weight: 700; margin-bottom: 14px; }

.points-quiz { display: flex; gap: 6px; justify-content: center; margin: -6px 0 14px; flex-wrap: wrap; }
.points-quiz span { width: 16px; height: 16px; border-radius: 50%; background: var(--trait); transition: transform .2s; }
.points-quiz span.ici { background: var(--accent); transform: scale(1.3); }
.points-quiz span.bon { background: var(--ok); }
.points-quiz span.rate { background: var(--alerte); }
.gros-score { font-size: 20px; padding: 6px 14px; }
.quiz .numero { color: var(--doux); font-size: 15px; font-weight: 700; }
.quiz .question { font-size: 26px; font-weight: 800; margin: 6px 0 18px; line-height: 1.3; }
.choix-liste { display: grid; gap: 12px; }
.choix {
  width: 100%; padding: 18px; border-radius: 18px; font-size: 21px; font-weight: 700; background: #faf6f0; border: 3px solid var(--trait);
  text-align: center; transition: transform .1s;
}
.choix:active { transform: scale(.98); }
.choix.bon, .pave button.bon { background: var(--ok-fond); border-color: var(--ok); color: #145c36; }
.choix.rate { background: var(--alerte-fond); border-color: var(--alerte); color: #8a4a06; animation: secoue .35s; }
.choix:disabled { cursor: default; }
@keyframes secoue { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.retour-quiz { margin-top: 16px; padding: 14px; border-radius: 18px; text-align: center; animation: apparait .25s ease; }
.retour-quiz.bon { background: var(--ok-fond); color: #145c36; }
.retour-quiz.rate { background: var(--alerte-fond); color: #8a4a06; }
.retour-quiz p { margin-top: 6px; }
@keyframes apparait { from { transform: scale(.9); opacity: 0; } }

.zone-saisie { max-width: 380px; margin: 0 auto; }
.saisie { font-size: 40px; font-weight: 800; text-align: center; padding: 10px; border-radius: 18px; border: 3px solid var(--accent); margin-bottom: 12px; font-variant-numeric: tabular-nums; min-height: 72px; }
.saisie.vide-saisie { color: var(--trait); }
.pave { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pave button { font-size: 28px; font-weight: 800; min-height: 64px; border-radius: 16px; background: #faf6f0; border: 3px solid var(--trait); }
.pave button:active { transform: scale(.95); }
.pave .extra { background: var(--accent-fond); color: var(--accent); }
.pave .efface { background: #f3ece2; }
.pave .valider { grid-column: 1 / -1; background: var(--accent); color: #fff; border-color: var(--accent); }
.pave button:disabled { opacity: .6; }
.aide-texte { margin-top: 18px; background: #faf6f0; border-radius: 16px; padding: 10px 14px; }
.aide-texte summary { font-weight: 700; cursor: pointer; }
.aide-texte p { margin-top: 8px; }

.fin-quiz { text-align: center; padding: 10px 0; }
.trophee { font-size: 96px; animation: rebond .8s ease; }
@keyframes rebond { 0% { transform: scale(0); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
.fin-quiz h2 { justify-content: center; }
.score { font-size: 48px; font-weight: 900; color: var(--accent); }
.etoiles-gagnees { font-size: 24px; font-weight: 800; color: #c98a00; min-height: 1em; }
.boutons-fin { display: grid; gap: 4px; grid-template-columns: 1fr 1fr; }
.faible-txt { color: var(--alerte); font-weight: 700; }

.confettis { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
.confettis span { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation-name: tombe; animation-timing-function: linear; animation-fill-mode: forwards; }
@keyframes tombe { to { transform: translateY(110vh) rotate(720deg); } }
@media (prefers-reduced-motion: reduce) { .confettis { display: none; } .trophee, .choix.rate, .retour-quiz { animation: none; } }

/* ---------- alertes parents ---------- */
.alerte-ligne { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; border-left: 6px solid var(--trait); background: #faf6f0; }
.alerte-ligne.urgent { border-left-color: var(--rouge); background: #fdecec; }
.alerte-ligne.attention { border-left-color: var(--alerte); background: var(--alerte-fond); }
.alerte-ligne .titre { font-weight: 700; }
.emoji-alerte { font-size: 26px; flex: none; }
.bouton.petit { min-height: 40px; padding: 8px 14px; border-radius: 12px; flex: none; }

/* ---------- utilitaires ---------- */
.detail, .sous { color: var(--doux); font-size: 15px; }
.bloc { margin-top: 14px; }
.liste.serree { gap: 4px; margin-top: 4px; }
.marge { margin-bottom: 8px; }
