/* Routines : téléphone et tablette d'abord. Boutons et champs d'au moins 44 px. */
:root {
  --c: #5b4bdb;
  --fond: #f6f4ff;
  --carte: #ffffff;
  --texte: #1f1d2b;
  --doux: #6b6880;
  --ligne: #e4e1f0;
  --vert: #2f9e44;
  --rouge: #c92a2a;
  --jaune: #f9c74f;
  --rayon: 18px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: #f6f4ff; }
body { min-height: 100vh; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fond);
  color: var(--texte);
  font-size: 17px;
  line-height: 1.4;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--c); }
h1 { font-size: 1.6rem; margin: .4em 0 .6em; }
h2 { font-size: 1.15rem; margin: 0 0 .7em; }
h2 small, .titre small { color: var(--doux); font-weight: 500; font-size: .85em; }
.note { color: var(--doux); }
.centre { text-align: center; }
.vide { text-align: center; color: var(--doux); font-size: 1.15rem; padding: 2em 0; }

main.etroit { max-width: 440px; margin: 0 auto; padding: 24px 18px 40px; }
main.large { max-width: 760px; margin: 0 auto; padding: 14px 14px 110px; }
.page-parent main.large { padding-bottom: 40px; }
.logo { font-size: 56px; text-align: center; margin-top: 12px; }
.page-connexion h1, main.etroit > h1 { text-align: center; }

/* ---------- formulaires et boutons ---------- */
.pile { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .95rem; }
input, select {
  font: inherit; min-height: 48px; padding: 10px 12px; border: 2px solid var(--ligne); border-radius: 12px;
  background: #fff; color: var(--texte); width: 100%; min-width: 0;
}
input:focus, select:focus { outline: none; border-color: var(--c); }
input.code { font-size: 1.6rem; letter-spacing: .3em; text-align: center; }
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 16px; border-radius: 14px; border: 2px solid var(--ligne);
  background: #fff; color: var(--texte); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.bouton:active { transform: scale(.97); }
.bouton.principal { background: var(--c); border-color: var(--c); color: #fff; }
.bouton.danger { color: var(--rouge); border-color: #f3c4c4; }
.bouton.petit { min-height: 44px; padding: 8px 12px; font-size: .95rem; }
.lien { background: none; border: 0; color: var(--doux); text-decoration: underline; font: inherit; min-height: 44px; cursor: pointer; }
.discret { text-align: center; margin-top: 18px; }
.boutons { display: flex; flex-wrap: wrap; gap: 8px; }
fieldset { border: 2px solid var(--ligne); border-radius: var(--rayon); padding: 12px; margin: 0; }
legend { font-weight: 700; padding: 0 6px; }
details { margin-top: 14px; }
summary { cursor: pointer; font-weight: 700; color: var(--c); min-height: 44px; display: flex; align-items: center; }
.avis-dev { background: #fff3bf; border-radius: 12px; padding: 10px 12px; text-align: center; }

/* ---------- message du haut ---------- */
.flash {
  position: sticky; top: 0; z-index: 20; background: var(--texte); color: #fff; padding: 12px 16px; text-align: center;
  font-weight: 600; transition: opacity .5s, transform .5s;
}
.flash.parti { opacity: 0; transform: translateY(-100%); pointer-events: none; }

/* ---------- choix de l'enfant ---------- */
.choix-enfants { display: grid; gap: 14px; margin-bottom: 22px; }
.choix-enfant {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 22px; text-decoration: none;
  background: var(--c); color: #fff; box-shadow: 0 6px 0 rgba(0, 0, 0, .15); min-height: 92px;
}
.choix-enfant:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0, 0, 0, .15); }
.choix-enfant .avatar { font-size: 48px; }
.choix-enfant .prenom { font-size: 1.6rem; font-weight: 800; flex: 1; }
.choix-enfant .solde { font-size: 1.2rem; font-weight: 800; background: rgba(255, 255, 255, .25); padding: 6px 12px; border-radius: 99px; }
.parent-lien { width: 100%; }

/* ---------- pages de l'enfant ---------- */
.page-enfant { background: var(--fond); background: linear-gradient(180deg, color-mix(in srgb, var(--c) 18%, #fff) 0, var(--fond) 260px); }
.entete-enfant { display: flex; align-items: center; gap: 12px; max-width: 760px; margin: 0 auto; padding: 14px 16px 6px; }
.entete-enfant .avatar {
  font-size: 44px; width: 68px; height: 68px; display: flex; align-items: center; justify-content: center;
  background: var(--c); border-radius: 50%; box-shadow: 0 4px 0 rgba(0, 0, 0, .15); flex: none;
}
.entete-enfant .prenom { font-size: 1.5rem; font-weight: 800; }
.compteurs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.pastille { background: #fff; border-radius: 99px; padding: 3px 10px; font-weight: 800; font-size: 1.05rem; box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.pastille.attente { color: var(--doux); }

.moments { display: flex; gap: 8px; max-width: 760px; margin: 8px auto 0; padding: 0 14px; }
.moments a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 64px;
  border-radius: 16px; background: #fff; color: var(--texte); text-decoration: none; font-weight: 700; font-size: .95rem;
  border: 3px solid transparent;
}
.moments a .em { font-size: 24px; }
.moments a.actif { border-color: var(--c); color: var(--c); }

.taches { display: grid; gap: 12px; margin-top: 6px; }
@media (min-width: 640px) {
  .taches { grid-template-columns: 1fr 1fr; gap: 16px; }
  .tache { min-height: 120px; }
  .tache .em { font-size: 54px; width: 64px; }
  .tache .libelle { font-size: 1.4rem; }
}
.taches form { margin: 0; }
.tache {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; min-height: 84px; padding: 12px 16px;
  border-radius: 20px; border: 3px solid var(--ligne); background: #fff; font: inherit; color: var(--texte); cursor: pointer;
  box-shadow: 0 5px 0 var(--ligne); -webkit-tap-highlight-color: transparent; transition: transform .08s;
}
.tache:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ligne); }
.tache .em { font-size: 40px; flex: none; width: 52px; text-align: center; }
.tache .libelle { flex: 1; font-size: 1.25rem; font-weight: 700; }
.tache .etat { font-weight: 800; color: var(--doux); white-space: nowrap; }
.tache.attente { border-color: var(--c); background: #efedff; background: color-mix(in srgb, var(--c) 12%, #fff); box-shadow: 0 5px 0 #c9c3f5; box-shadow: 0 5px 0 color-mix(in srgb, var(--c) 45%, #fff); }
.tache.attente .etat {
  color: #fff; background: var(--c); width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 1.3rem;
}
.tache.attente .libelle { text-decoration: line-through; text-decoration-thickness: 3px; text-decoration-color: #a99ff0; text-decoration-color: color-mix(in srgb, var(--c) 60%, transparent); }
.tache.valide { border-color: #b2f2bb; background: #ebfbee; box-shadow: none; cursor: default; opacity: .9; }
.tache.valide .etat { color: var(--vert); }
.tache.valide .libelle { color: var(--doux); }
.legende { color: var(--doux); text-align: center; font-size: .9rem; margin-top: 18px; }

.nav-enfant {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 4px; background: #fff;
  border-top: 1px solid var(--ligne); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 10;
}
.nav-enfant a {
  flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; min-height: 56px; justify-content: center;
  color: var(--doux); text-decoration: none; font-weight: 700; font-size: .85rem; border-radius: 12px;
}
.nav-enfant a span { font-size: 24px; }
.nav-enfant a.actif { color: var(--c); background: #efedff; background: color-mix(in srgb, var(--c) 10%, #fff); }

/* bravo */
.bravo { position: relative; overflow: hidden; background: var(--c); color: #fff; border-radius: 22px; padding: 22px 16px; text-align: center;
  margin: 8px 0 14px; animation: saute .6s ease-out; }
.bravo-texte { position: relative; font-size: 1.5rem; font-weight: 800; }
.bravo-texte small { font-size: .95rem; font-weight: 600; opacity: .9; }
.confettis i {
  position: absolute; top: -10px; left: calc(var(--i) * 4.2%); width: 9px; height: 14px; border-radius: 2px;
  background: hsl(calc(var(--i) * 47), 90%, 62%); animation: tombe 2.4s ease-in calc(var(--i) * 0.07s) 2 both;
}
@keyframes tombe { to { transform: translateY(160px) rotate(540deg); opacity: 0; } }
@keyframes saute { 0% { transform: scale(.6); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .bravo, .confettis i { animation: none; } .confettis { display: none; } }

/* boutique */
.recompenses { display: grid; gap: 12px; }
@media (min-width: 640px) { .recompenses { grid-template-columns: 1fr 1fr; } }
.recompense {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 6px 12px; background: #fff; border-radius: 20px;
  padding: 14px 16px; border: 3px solid var(--ligne); margin: 0;
}
.recompense .em { font-size: 40px; grid-row: span 2; text-align: center; }
.recompense .libelle { font-weight: 800; font-size: 1.15rem; }
.recompense .prix { font-weight: 800; white-space: nowrap; }
.recompense .bouton, .recompense .barre { grid-column: 2 / 4; }
.recompense.manque { opacity: .85; }
.barre { height: 14px; background: var(--ligne); border-radius: 99px; overflow: hidden; }
.barre i { display: block; height: 100%; background: var(--c); border-radius: 99px; }
.encore { grid-column: 2 / 4; color: var(--doux); font-weight: 700; font-size: .95rem; }
.demandes { background: #fff; border-radius: 20px; padding: 14px 16px; margin-bottom: 14px; border: 3px dashed var(--c); }
.demande { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.demande .em { font-size: 30px; }
.demande .libelle { flex: 1; font-weight: 700; }
.demande .prix { font-weight: 800; }

/* ---------- mode parent ---------- */
.entete-parent { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--texte); color: #fff; padding: 10px 14px; }
.entete-parent .titre { font-weight: 800; }
.entete-parent .titre small { color: #c9c6d9; }
.entete-parent .bouton { background: transparent; color: #fff; border-color: #55526a; }
.onglets { display: flex; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--ligne); }
.onglets a {
  flex: 1 0 auto; text-align: center; padding: 0 9px; min-height: 50px; display: flex; align-items: center; justify-content: center;
  color: var(--doux); text-decoration: none; font-weight: 700; border-bottom: 3px solid transparent; white-space: nowrap;
}
.onglets a.actif { color: var(--texte); border-bottom-color: #5b4bdb; }
.carte { background: var(--carte); border-radius: var(--rayon); padding: 16px; margin: 14px 0; border-left: 6px solid var(--c); box-shadow: 0 1px 3px rgba(0, 0, 0, .06); }
.carte.choisi { box-shadow: 0 0 0 3px var(--c); }
.ligne { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--ligne); }
.ligne:first-of-type { border-top: 0; }
.ligne .quoi { flex: 1 1 200px; font-size: 1.05rem; }
.ligne .quoi small { display: block; color: var(--doux); font-size: .85rem; }
.ligne .boutons { flex: 1 1 auto; justify-content: flex-end; flex-wrap: nowrap; }
.ligne .boutons .bouton { flex: 1 1 0; padding: 8px 6px; font-size: .92rem; min-width: 0; }
@media (min-width: 560px) { .ligne .boutons .bouton { flex: 0 0 auto; padding: 8px 14px; } }
.boutons.tout { border-top: 1px solid var(--ligne); padding-top: 12px; margin-top: 4px; }
.historique .pts { font-weight: 800; min-width: 44px; text-align: right; font-size: 1.1rem; }
.pts.plus { color: var(--vert); }
.pts.moins { color: var(--rouge); }
.soldes { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 4px; }
.solde-enfant { display: flex; align-items: center; gap: 8px; background: var(--c); color: #fff; border-radius: 16px; padding: 10px 14px; text-decoration: none; min-height: 60px; }
.solde-enfant .avatar { font-size: 28px; }
.solde-enfant .prenom { flex: 1; font-weight: 800; }
.solde-enfant .solde { font-weight: 800; }
.rapides { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fiche { border-left: 6px solid var(--c); padding: 10px 0 14px 12px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 10px; }
.champs { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 560px) { .champs { grid-template-columns: 2fr 1fr 1fr; } }
.tache-edit { border-top: 1px solid var(--ligne); padding: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.tache-edit:first-of-type { border-top: 0; }
.champs-ligne { display: grid; grid-template-columns: 72px 1fr; gap: 8px; margin: 0; }
.champs-ligne select[name="points"], .champs-ligne .cout { grid-column: 1; }
.champs-ligne .bouton { grid-column: 2; justify-self: start; }
@media (min-width: 560px) {
  .champs-ligne { grid-template-columns: 72px 1fr 92px auto; }
  .champs-ligne select[name="points"], .champs-ligne .cout, .champs-ligne .bouton { grid-column: auto; }
}
.champs-ligne.nouvelle { border-top: 2px dashed var(--ligne); padding-top: 12px; margin-top: 6px; }
.tache-edit { position: relative; }
.tache-edit .champs-ligne { grid-template-columns: 72px 72px 1fr; }
.tache-edit .champs-ligne input[name="libelle"] { grid-column: 2 / 4; }
.tache-edit .champs-ligne .bouton { grid-column: 2; justify-self: stretch; }
.tache-edit .actions { display: flex; gap: 8px; justify-content: flex-end; position: absolute; right: 0; bottom: 10px; }
@media (min-width: 560px) {
  .tache-edit { flex-direction: row; align-items: center; }
  .tache-edit .champs-ligne { flex: 1; grid-template-columns: 72px 1fr 92px auto; }
  .tache-edit .champs-ligne input[name="libelle"], .tache-edit .champs-ligne .bouton { grid-column: auto; }
  .tache-edit .actions { position: static; }
}
.tache-edit .actions form { margin: 0; }
