:root {
  --fond: #f4f5f7;
  --carte: #ffffff;
  --texte: #16181d;
  --doux: #626873;
  --trait: #e3e5ea;
  --islam: #0d7a5c;
  --islam-clair: #e3f3ed;
  --sante: #c2410c;
  --sante-clair: #fbeae2;
  --famille: #1d5fc4;
  --famille-clair: #e4edfa;
  --cerveau: #6d3fd1;
  --cerveau-clair: #eee8fb;
  --ok: #0d7a5c;
  --retard: #b45309;
  --rate: #b91c1c;
  --rayon: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fond); color: var(--texte); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 calc(76px + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; color: inherit; }
main { max-width: 560px; margin: 0 auto; padding: 12px 16px 24px; }

/* En-tête */
.entete { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0 12px; }
.entete h1 { font-size: 26px; margin: 0; letter-spacing: -0.02em; }
.entete .sous { color: var(--doux); font-size: 14px; }
.nav-jour { display: flex; align-items: center; gap: 4px; }
.rond {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--trait); background: var(--carte);
  display: grid; place-items: center; cursor: pointer; font-size: 18px; padding: 0;
}

/* Cartes */
.carte { background: var(--carte); border-radius: var(--rayon); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.carte h2 { font-size: 17px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.carte h2 .pastille { width: 10px; height: 10px; border-radius: 50%; }
.carte h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--doux); margin: 16px 0 8px; }
.carte h3:first-of-type { margin-top: 4px; }
.islam .pastille { background: var(--islam); }
.sante .pastille { background: var(--sante); }
.famille .pastille { background: var(--famille); }
.cerveau .pastille { background: var(--cerveau); }

.ligne { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--trait); }
.ligne:first-of-type { border-top: 0; }
.ligne .lib { flex: 1; min-width: 0; }
.ligne .lib small { display: block; color: var(--doux); font-size: 13px; }
.vide { color: var(--doux); font-size: 14px; padding: 6px 0; }

/* Score */
.score { display: flex; align-items: center; gap: 12px; }
.score .barre { flex: 1; height: 10px; background: var(--trait); border-radius: 99px; overflow: hidden; }
.score .barre i { display: block; height: 100%; background: var(--islam); border-radius: 99px; transition: width .3s; }
.score b { font-size: 15px; white-space: nowrap; }
.prochaine { font-size: 15px; margin-top: 10px; color: var(--doux); }
.prochaine b { color: var(--islam); }

/* Prières */
.prieres { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.priere {
  border: 1.5px solid var(--trait); background: var(--carte); border-radius: 12px; padding: 8px 2px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 72px;
}
.priere .nom { font-size: 13px; font-weight: 600; }
.priere .h { font-size: 12px; color: var(--doux); }
.priere .etat { font-size: 11px; font-weight: 600; min-height: 14px; }
.priere.h { border-color: var(--ok); background: var(--islam-clair); }
.priere.h .etat { color: var(--ok); }
.priere.r { border-color: var(--retard); background: #fdf3e3; }
.priere.r .etat { color: var(--retard); }
.priere.m { border-color: var(--rate); background: #fdecec; }
.priere.m .etat { color: var(--rate); }
.priere.prochaine-p { box-shadow: 0 0 0 3px var(--islam-clair); }
.aide { font-size: 12px; color: var(--doux); margin-top: 6px; }

/* Compteurs */
.compteur { display: flex; align-items: center; gap: 6px; }
.compteur button {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--trait); background: var(--fond);
  font-size: 20px; line-height: 1; cursor: pointer;
}
.compteur .val { min-width: 54px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.compteur .val small { font-weight: 400; color: var(--doux); }
.atteint .val { color: var(--ok); }

/* Puces */
.puces { display: flex; flex-wrap: wrap; gap: 6px; }
.puce {
  border: 1.5px solid var(--trait); background: var(--carte); border-radius: 99px; padding: 6px 12px; font-size: 14px; cursor: pointer;
}
.puce.on { background: var(--texte); border-color: var(--texte); color: #fff; }
.sante .puce.on { background: var(--sante); border-color: var(--sante); }
.cerveau .puce.on { background: var(--cerveau); border-color: var(--cerveau); }
.islam .puce.on { background: var(--islam); border-color: var(--islam); }

/* Boutons et champs */
.btn {
  border: 0; border-radius: 10px; padding: 8px 14px; background: var(--texte); color: #fff; font-weight: 600; cursor: pointer; font-size: 14px;
}
.btn.leger { background: var(--fond); color: var(--texte); border: 1px solid var(--trait); }
.btn.danger { background: #fdecec; color: var(--rate); }
.btn.islam { background: var(--islam); }
.btn.famille { background: var(--famille); }
.btn.cerveau { background: var(--cerveau); }
.btn.sante { background: var(--sante); }
.btn.large { width: 100%; padding: 12px; font-size: 16px; }
input[type=text], input[type=number], input[type=password], input[type=date], input[type=time], select {
  width: 100%; border: 1px solid var(--trait); border-radius: 10px; padding: 10px 12px; background: var(--carte); font-size: 16px;
}
.champ { margin-bottom: 10px; }
.champ label { display: block; font-size: 13px; color: var(--doux); margin-bottom: 4px; }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ajout { display: flex; gap: 8px; margin-top: 8px; }
.ajout input { flex: 1; }
.petit-input { width: 90px !important; text-align: right; }
.lien { background: none; border: 0; color: var(--famille); padding: 0; cursor: pointer; font-size: 14px; }
.suppr { background: none; border: 0; color: var(--doux); cursor: pointer; font-size: 18px; padding: 4px 8px; }

/* Graphiques */
.graphe { width: 100%; height: auto; display: block; }
.legende { display: flex; justify-content: space-between; font-size: 12px; color: var(--doux); margin-top: 4px; }
.chiffres { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chiffre { background: var(--fond); border-radius: 12px; padding: 10px; text-align: center; }
.chiffre b { display: block; font-size: 22px; letter-spacing: -0.02em; }
.chiffre span { font-size: 12px; color: var(--doux); }
.grille { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.grille i { aspect-ratio: 1; border-radius: 4px; background: var(--trait); }
.progression { height: 6px; background: var(--trait); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.progression i { display: block; height: 100%; background: var(--cerveau); }

/* Sourates */
.sourate { cursor: pointer; }
.sourate .num { color: var(--doux); font-size: 13px; width: 30px; display: inline-block; }
.statut { font-size: 12px; font-weight: 600; border-radius: 99px; padding: 3px 10px; white-space: nowrap; }
.statut.en_cours { background: #fdf3e3; color: var(--retard); }
.statut.apprise { background: var(--islam-clair); color: var(--ok); }
.statut.non { color: var(--doux); }

/* Barre du bas */
nav.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--trait); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 10;
}
nav.onglets a {
  flex: 1; max-width: 112px; text-align: center; padding: 8px 0 10px; text-decoration: none; color: var(--doux); font-size: 11px; font-weight: 600;
}
nav.onglets a span { display: block; font-size: 22px; line-height: 1.2; filter: grayscale(1); opacity: .55; }
nav.onglets a.actif { color: var(--texte); }
nav.onglets a.actif span { filter: none; opacity: 1; }

/* Connexion */
.connexion { max-width: 360px; margin: 18vh auto 0; padding: 0 16px; text-align: center; }
.connexion h1 { font-size: 32px; margin-bottom: 4px; }
.connexion p { color: var(--doux); margin-top: 0; }
.erreur { color: var(--rate); font-size: 14px; min-height: 20px; margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--texte); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 20; max-width: 90vw;
}
