:root {
  --fond: #f4f1ea;
  --carte: #fffdf8;
  --encre: #1f2a24;
  --doux: #5d6a62;
  --trait: #ddd6c8;
  --vert: #2f6b4f;
  --vert-clair: #e2efe7;
  --sur-vert: #ffffff;
  --alerte: #a8491a;
  --alerte-clair: #fbeadd;
  --rouge: #a3282d;
  --ombre: 0 1px 2px rgba(31, 42, 36, .06), 0 6px 18px rgba(31, 42, 36, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #161b18;
    --carte: #1f2622;
    --encre: #ecefe9;
    --doux: #a3ada6;
    --trait: #333d37;
    --vert: #6fc296;
    --vert-clair: #20352a;
    --sur-vert: #10201a;
    --alerte: #f0a36c;
    --alerte-clair: #3a2a1e;
    --rouge: #ef8a8e;
    --ombre: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.page {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
h1 { font-size: 30px; line-height: 1.15; margin: 0; letter-spacing: -.02em; text-wrap: balance; }
h2 { font-size: 21px; line-height: 1.2; margin: 0; }
p { margin: 0; }
.surtitre { color: var(--doux); font-size: 14px; text-transform: uppercase; letter-spacing: .08em; }
.note, .attente { color: var(--doux); font-size: 15px; }
.erreur { color: var(--rouge); font-size: 15px; min-height: 1.4em; }
.cache { display: none; }
.pile { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.sans-puce { list-style: none; padding: 0; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--vert); outline-offset: 2px; }

input[type="password"], input[type="text"] {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 1.5px solid var(--trait);
  border-radius: 14px;
  background: var(--carte);
}

.bouton {
  min-height: 54px;
  padding: 12px 20px;
  border: 0;
  border-radius: 14px;
  font-weight: 650;
  width: 100%;
}
.bouton.grand { min-height: 76px; font-size: 20px; }
.bouton.principal { background: var(--vert); color: var(--sur-vert); }
.bouton.secondaire { background: var(--vert-clair); color: var(--vert); }
.bouton.discret { background: transparent; border: 1.5px solid var(--trait); }
.bouton.danger { background: var(--rouge); color: var(--sur-vert); }
.bouton:active { transform: translateY(1px); }

.lien {
  background: none;
  border: 0;
  padding: 10px 0;
  color: var(--vert);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 15px;
}
.lien.retour { text-decoration: none; padding: 6px 0; }
.liens { display: flex; flex-wrap: wrap; gap: 4px 22px; justify-content: center; margin-top: 8px; }

.carte {
  background: var(--carte);
  border: 1px solid var(--trait);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--ombre);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.carte.accent { border-color: var(--vert); }

.choix {
  text-align: left;
  background: var(--carte);
  border: 2px solid var(--trait);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.choix span { color: var(--doux); font-size: 15px; }
.choix.actif { border-color: var(--vert); background: var(--vert-clair); }

/* En-tête de la liste, toujours visible */
.entete {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--fond);
  margin: calc(-20px - env(safe-area-inset-top)) -16px 0;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-bottom: 1px solid var(--trait);
}
.entete h1 { font-size: 24px; }
.entete-ligne { display: flex; justify-content: space-between; align-items: center; }
.compteur { font-variant-numeric: tabular-nums; font-weight: 700; }
.barre { height: 8px; border-radius: 99px; background: var(--trait); overflow: hidden; }
.barre span { display: block; height: 100%; background: var(--vert); border-radius: 99px; transition: width .25s; }

/* Tâches */
.taches { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tache {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--carte);
  border: 1px solid var(--trait);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--ombre);
}
.tache .corps { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.tache .titre { font-size: 18px; line-height: 1.25; }
.tache .detail { color: var(--doux); font-size: 15px; }
.coche {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 2px solid var(--vert);
  background: transparent;
  font-size: 24px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.tache.faite { background: var(--vert-clair); border-color: transparent; box-shadow: none; }
.tache.faite .coche { background: var(--vert); color: var(--sur-vert); font-weight: 700; }
.tache.faite .titre { color: var(--doux); }
.tache.bloquee { box-shadow: none; background: transparent; border-style: dashed; }
.tache.bloquee .coche { border-color: var(--trait); font-size: 18px; }
.tache.bloquee .titre, .tache.bloquee .detail, .tache.bloquee .sous { opacity: .55; }
.verrou { font-size: 14px; color: var(--doux); }
.fait-a { font-size: 13px; color: var(--doux); }
.tache.critique:not(.faite):not(.bloquee) { border: 2px solid var(--alerte); background: var(--alerte-clair); }
.tache.critique:not(.faite):not(.bloquee) .coche { border-color: var(--alerte); }
.badge {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--alerte);
}
.tache.faite .badge { display: none; }

.sous { list-style: none; margin: 4px 0 0; padding: 0; align-self: stretch; display: flex; flex-direction: column; gap: 6px; }
.sous-coche {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: transparent;
  border: 1px solid var(--trait);
  border-radius: 12px;
  padding: 8px 12px;
}
.sous-coche .case {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 2px solid var(--vert);
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
}
.sous-coche.ok .case { background: var(--vert); color: var(--sur-vert); }
.sous-coche.ok { color: var(--doux); }
.tache.bloquee .sous-coche .case { border-color: var(--trait); }

.preuve { width: 120px; height: 90px; object-fit: cover; border-radius: 10px; background: var(--trait); }
.preuve.grande { width: 100%; height: auto; max-height: 420px; }
figure { margin: 0; display: flex; flex-direction: column; gap: 4px; }
figcaption { font-size: 13px; color: var(--doux); }

.statut { text-align: center; font-size: 14px; color: var(--doux); }
.statut.ok::before { content: "● "; color: var(--vert); }
.statut.attente::before { content: "● "; color: var(--alerte); }

.fin { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 32px 0 8px; }
.fin-coche {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--vert);
  color: var(--sur-vert);
  font-size: 46px;
  display: grid;
  place-items: center;
}

/* Fenêtres (aide, confirmation) */
.fond {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(15, 20, 17, .55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.feuille {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--carte);
  border-radius: 22px 22px 0 0;
  padding: 22px 16px calc(22px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.actions { display: flex; flex-direction: column; gap: 10px; }
.photo-aide { width: 100%; border-radius: 12px; background: var(--trait); }
.photo-manquante {
  border: 1.5px dashed var(--trait);
  border-radius: 12px;
  padding: 22px 12px;
  text-align: center;
  color: var(--doux);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: 528px;
  margin: 0 auto;
  background: var(--encre);
  color: var(--fond);
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 15px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.visible { opacity: 1; transform: none; }

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