/* Fil Santé — mobile d'abord, gros caractères, contraste élevé, clair et sombre. */

:root {
  --fond: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --texte: #16211f;
  --texte-doux: #55625f;
  --bordure: #d5ddda;
  --accent: #0f766e;
  --accent-fort: #0b5e58;
  --accent-texte: #ffffff;
  --accent-doux: #d9efec;
  --danger: #b42318;
  --danger-doux: #fde8e6;
  --succes: #12703a;
  --niveau-faible: #2e7d4f;
  --niveau-moyen: #a15c00;
  --niveau-fort: #b42318;
  --rayon: 14px;
  --ombre: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f1514;
    --surface: #18201f;
    --surface-2: #212b29;
    --texte: #e8efed;
    --texte-doux: #a3b2ae;
    --bordure: #33403d;
    --accent: #2bb3a6;
    --accent-fort: #4fd1c5;
    --accent-texte: #06201d;
    --accent-doux: #173a37;
    --danger: #ff8a7d;
    --danger-doux: #3a1d1a;
    --succes: #6fd29a;
    --niveau-faible: #6fd29a;
    --niveau-moyen: #f3b562;
    --niveau-fort: #ff8a7d;
    --ombre: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 18px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 0.5rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--accent); }

.ecran {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.chargement, .vide, .note { color: var(--texte-doux); }
.chargement { padding: 24px 16px; text-align: center; }
.sous-titre { color: var(--texte-doux); margin: 4px 0 0; font-size: 0.95rem; }
.aide { color: var(--texte-doux); font-size: 0.9rem; margin-top: -0.25rem; }

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-principal { background: var(--accent); color: var(--accent-texte); }
.btn-principal:active { background: var(--accent-fort); }
.btn-secondaire { background: var(--surface); color: var(--accent); border-color: var(--bordure); }
.btn-danger { background: var(--danger-doux); color: var(--danger); }
.btn-lien {
  background: none; border: 0; color: var(--accent); width: auto; min-height: 44px;
  padding: 8px 4px; font-weight: 600;
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Champs ---------- */

label { display: block; font-weight: 600; font-size: 0.95rem; margin: 0 0 6px; }

input, select, textarea {
  width: 100%;
  font: inherit;
  font-size: 18px; /* 16 px minimum : sinon iOS zoome sur le champ */
  color: var(--texte);
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 52px;
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--texte-doux) 50%), linear-gradient(135deg, var(--texte-doux) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}
textarea { min-height: 160px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--texte-doux); opacity: 0.8; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent-doux); }

.champ { margin-bottom: 14px; }
.champ:last-child { margin-bottom: 0; }
.avec-unite { position: relative; }
.avec-unite input { padding-right: 64px; }
.unite { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--texte-doux); font-size: 0.95rem; pointer-events: none; }

.grille { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grille .champ { margin: 0; }
.pleine-largeur { grid-column: 1 / -1; }

.erreur {
  background: var(--danger-doux);
  color: var(--danger);
  border-radius: 10px;
  padding: 12px 14px;
  font-weight: 500;
}

/* ---------- Connexion ---------- */

.ecran-connexion { padding-top: 32px; }
.marque { text-align: center; margin-bottom: 24px; }
.marque img { border-radius: 16px; margin-bottom: 12px; }

.carte {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 20px 16px;
}
form.carte { display: grid; gap: 12px; }
form.carte label { margin-bottom: -6px; }

.champ-code { font-size: 28px; letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }
.etapes { margin: 0; padding-left: 1.3rem; display: grid; gap: 6px; font-size: 0.95rem; }
.cle { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 12px; }
.cle-libelle { color: var(--texte-doux); font-size: 0.9rem; }
.cle code { font-size: 1rem; word-break: break-all; font-weight: 600; }
.cle .btn { grid-column: 1 / -1; min-height: 44px; }
.qr-details summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.qr { background: #fff; border-radius: 10px; padding: 12px; max-width: 240px; margin: 8px auto 0; }
.qr svg { display: block; width: 100%; height: auto; }

/* ---------- Accueil ---------- */

.entete { padding: 8px 0 16px; }
.actions-principales { display: grid; gap: 12px; margin-bottom: 28px; }

.btn-noter {
  display: flex; align-items: center; gap: 16px;
  min-height: 96px; padding: 18px 20px;
  background: var(--accent); color: var(--accent-texte);
  border-radius: 18px; text-decoration: none;
  box-shadow: var(--ombre);
}
.btn-noter:active { background: var(--accent-fort); }
.btn-noter strong { display: block; font-size: 1.25rem; }
.btn-noter small { display: block; opacity: 0.9; font-size: 0.9rem; }
.btn-noter-icone {
  flex: none; width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.18); font-size: 2rem; line-height: 1;
}

.btn-voix {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 64px; padding: 12px 20px;
  background: var(--surface); color: var(--texte-doux);
  border: 1px dashed var(--bordure); border-radius: 18px;
  font: inherit; text-align: left;
}
.btn-voix small { display: block; font-size: 0.85rem; }
.icone { display: inline-grid; place-items: center; }

.liste-entrees { display: grid; gap: 12px; }
.carte-entree { display: block; text-decoration: none; color: inherit; }
.carte-entree:active { background: var(--surface-2); }
.carte-entree-date { font-weight: 700; margin-bottom: 4px; }
.carte-entree-texte { color: var(--texte-doux); margin-bottom: 8px; font-size: 0.95rem; }
.carte-entree-texte:last-child { margin-bottom: 0; }

.pastilles { display: flex; flex-wrap: wrap; gap: 6px; }
.pastille {
  font-size: 0.8rem; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--texte-doux);
}
.pastille[data-niveau="faible"] { color: var(--niveau-faible); }
.pastille[data-niveau="moyen"] { color: var(--niveau-moyen); }
.pastille[data-niveau="fort"] { color: var(--niveau-fort); }

.pied { margin-top: 32px; text-align: center; }

/* ---------- Formulaire d'entrée ---------- */

.entete-formulaire .retour { margin-left: -4px; margin-bottom: 4px; }

.bandeau {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--accent-doux); border-radius: 10px; padding: 6px 6px 6px 14px;
  margin-bottom: 16px; font-size: 0.95rem;
}

.bloc {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 16px;
  margin-bottom: 14px;
}

.bloc-repliable { padding: 0; }
.bloc-repliable > summary {
  list-style: none;
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 0 16px;
  font-weight: 700; font-size: 1.05rem; cursor: pointer;
}
.bloc-repliable > summary::-webkit-details-marker { display: none; }
.bloc-repliable > summary::after { content: "+"; margin-left: auto; font-size: 1.4rem; color: var(--texte-doux); font-weight: 400; }
.bloc-repliable[open] > summary::after { content: "–"; }
.bloc-repliable > :not(summary) { padding: 0 16px 16px; }
.compteur {
  background: var(--accent-doux); color: var(--accent-fort);
  border-radius: 999px; min-width: 26px; padding: 0 8px; font-size: 0.85rem; text-align: center;
}

/* Échelle 0 à 10 */
.echelle { border: 0; margin: 0 0 18px; padding: 0; min-width: 0; }
.echelle:last-child { margin-bottom: 0; }
.echelle legend { display: flex; justify-content: space-between; align-items: baseline; width: 100%; font-weight: 700; padding: 0; margin-bottom: 8px; }
.echelle-valeur { font-weight: 700; color: var(--accent-fort); font-variant-numeric: tabular-nums; }
.echelle-valeur.est-vide { color: var(--texte-doux); font-weight: 400; font-size: 0.9rem; }
.echelle-boutons { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.echelle-choix {
  min-height: 48px; border-radius: 10px;
  border: 1px solid var(--bordure); background: var(--surface-2); color: var(--texte);
  font: inherit; font-weight: 600; font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent; cursor: pointer;
}
.echelle-choix[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.echelle-mauvais .echelle-choix[aria-pressed="true"][data-valeur="7"],
.echelle-mauvais .echelle-choix[aria-pressed="true"][data-valeur="8"],
.echelle-mauvais .echelle-choix[aria-pressed="true"][data-valeur="9"],
.echelle-mauvais .echelle-choix[aria-pressed="true"][data-valeur="10"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.echelle-bornes { display: flex; justify-content: space-between; color: var(--texte-doux); font-size: 0.8rem; margin-top: 6px; }

.lignes { display: grid; gap: 12px; margin-bottom: 12px; }
.ligne { position: relative; background: var(--surface-2); border-radius: 12px; padding: 14px 48px 14px 14px; }
.ligne input, .ligne select { background-color: var(--surface); }
.btn-retirer {
  position: absolute; top: 6px; right: 6px;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; color: var(--texte-doux);
  font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.btn-ajouter { min-height: 48px; }

.barre-actions {
  position: sticky;
  bottom: 0;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--fond) 30%);
  margin-top: 8px;
}
.zone-suppression { margin-top: 24px; }

/* ---------- Messages ---------- */

.toast {
  position: fixed; left: 16px; right: 16px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: 480px; margin: 0 auto;
  padding: 14px 18px; border-radius: 12px;
  background: var(--texte); color: var(--fond);
  font-weight: 600; text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  z-index: 10;
}
.toast-erreur { background: var(--danger); color: #fff; }

@media (min-width: 560px) {
  .echelle-boutons { grid-template-columns: repeat(11, 1fr); }
}

@media (prefers-reduced-motion: no-preference) {
  .echelle-choix, .btn { transition: background-color 0.15s ease; }
}
