/* Mon Sinistre — une colonne calme, une action principale par écran. Rouge réservé au danger et aux délais dépassés. */
:root {
  --fond: #F3F6F9; --carte: #FFFFFF; --encre: #17212B; --doux: #556270; --trait: #D5DDE5;
  --primaire: #1F5FBF; --sur-primaire: #FFFFFF; --primaire-fond: #E6EEFA;
  --ok: #23785A; --ok-fond: #E2F3EB;
  --alerte: #8A5A0B; --alerte-fond: #FBF1D9;
  --danger: #B3261E; --danger-fond: #FBE7E5; --sur-danger: #FFFFFF;
  --ombre: 0 1px 2px rgba(23, 33, 43, .06), 0 4px 14px rgba(23, 33, 43, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0E151C; --carte: #17212B; --encre: #E9EEF3; --doux: #9FADBA; --trait: #2B3946;
    --primaire: #7FB2F7; --sur-primaire: #0A1B33; --primaire-fond: #1B2E48;
    --ok: #63C9A1; --ok-fond: #14372B;
    --alerte: #E8B95A; --alerte-fond: #3A2D10;
    --danger: #F2928A; --danger-fond: #44201D; --sur-danger: #2B0B09;
    --ombre: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--encre);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent; overflow-wrap: break-word;
}
h1, h2, p, ul, ol { margin: 0; }
h1 { font-size: 1.55rem; line-height: 1.2; font-weight: 750; text-wrap: balance; }
h2 { font-size: 1.1rem; line-height: 1.3; font-weight: 700; }
ul, ol { padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
a { color: var(--primaire); }
[hidden] { display: none !important; }
.doux { color: var(--doux); font-size: .94rem; }
.grand { font-size: 1.12rem; }
.chiffre { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cache-visuel { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }

/* Barre du haut */
.barre {
  position: sticky; top: 0; z-index: 5; background: var(--fond); border-bottom: 1px solid var(--trait);
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.barre-contenu { max-width: 560px; margin: 0 auto; min-height: 54px; display: flex; align-items: center; gap: 8px; }
.barre-titre { flex: 1; min-width: 0; font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barre a { text-decoration: none; font-weight: 600; padding: 12px 4px; white-space: nowrap; }

main {
  max-width: 592px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px;
  padding-top: 20px; padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
main:focus { outline: none; }

/* Cartes */
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: 18px; padding: 18px; box-shadow: var(--ombre); display: flex; flex-direction: column; gap: 10px; }
.carte.ton-ok { background: var(--ok-fond); border-color: transparent; }
.carte.ton-alerte { background: var(--alerte-fond); border-color: transparent; }
.carte.ton-danger { background: var(--danger-fond); border-color: transparent; }
.intertitre { margin-top: 8px; }
.pile { display: flex; flex-direction: column; gap: 12px; }
.hero { align-items: flex-start; padding: 24px 20px; gap: 14px; }

/* Boutons */
.bouton {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 54px; padding: 12px 18px;
  border-radius: 14px; border: 1.5px solid var(--trait); background: var(--carte); color: var(--encre);
  font: inherit; font-weight: 650; text-align: center; text-decoration: none; cursor: pointer;
}
.bouton.principal { background: var(--primaire); border-color: var(--primaire); color: var(--sur-primaire); min-height: 58px; font-size: 1.08rem; }
.bouton.urgence { background: var(--danger); border-color: var(--danger); color: var(--sur-danger); }
.bouton.supprimer { color: var(--danger); border-color: transparent; background: transparent; }
.bouton.lien { border-color: transparent; background: transparent; color: var(--primaire); min-height: 44px; }
.bouton:disabled { opacity: .5; cursor: not-allowed; }
button.texte { font: inherit; background: none; border: 0; padding: 0; color: var(--primaire); text-decoration: underline; cursor: pointer; }
.rangee { display: flex; flex-wrap: wrap; gap: 10px; }
.rangee > * { flex: 1 1 150px; }
:focus-visible, label.bouton:focus-within { outline: 3px solid var(--primaire); outline-offset: 2px; }

/* Pastilles d'état */
.pastille { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .82rem; font-weight: 650; background: var(--primaire-fond); color: var(--primaire); white-space: nowrap; }
.pastille.ok { background: var(--ok-fond); color: var(--ok); }
.pastille.alerte { background: var(--alerte-fond); color: var(--alerte); }
.pastille.danger { background: var(--danger-fond); color: var(--danger); }
.texte-ok { color: var(--ok); font-weight: 650; }
.texte-alerte { color: var(--alerte); font-weight: 650; }
.texte-danger { color: var(--danger); font-weight: 650; }

/* Accueil : dossiers */
.dossier { display: flex; flex-direction: row; align-items: flex-start; gap: 14px; text-decoration: none; color: inherit; }
.dossier img { width: 56px; height: 56px; flex: none; }
.dossier-texte { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.ligne-titre { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Choix du type */
.tuiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tuile { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 10px; border-radius: 18px; border: 1.5px solid var(--trait); background: var(--carte); color: var(--encre); font: inherit; font-weight: 650; text-align: center; cursor: pointer; box-shadow: var(--ombre); }
.tuile img { width: 76px; height: 76px; }

/* Progression */
.progression { height: 10px; border-radius: 99px; background: var(--trait); overflow: hidden; }
.progression span { display: block; height: 100%; background: var(--ok); border-radius: 99px; }

/* Listes */
.liste { display: flex; flex-direction: column; background: var(--carte); border: 1px solid var(--trait); border-radius: 18px; overflow: hidden; }
.liste > li + li { border-top: 1px solid var(--trait); }
.rang { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 56px; background: none; border: 0; font: inherit; color: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.rang > .corps { flex: 1; min-width: 0; }
.coche { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--trait); display: grid; place-items: center; font-size: .85rem; font-weight: 800; color: transparent; }
.rang.fait .coche { background: var(--ok); border-color: var(--ok); color: var(--carte); }
.rang.fait .corps strong { font-weight: 500; color: var(--doux); }
.fleche { flex: none; color: var(--doux); font-size: 1.3rem; }

/* Photos */
.grille-photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 480px) { .grille-photos { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.vignette { padding: 0; border: 1px solid var(--trait); border-radius: 14px; overflow: hidden; background: var(--carte); color: inherit; font: inherit; text-align: left; cursor: pointer; display: flex; flex-direction: column; }
.vignette img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--trait); }
.vignette span { padding: 8px 10px; font-size: .88rem; color: var(--doux); min-height: 2.6em; }
.apercu { width: 100%; max-height: 46vh; object-fit: contain; border-radius: 12px; background: var(--fond); }

/* Formulaires */
.champ { display: flex; flex-direction: column; gap: 6px; }
.champ > span { font-weight: 650; font-size: .95rem; }
.champ small { color: var(--doux); font-size: .86rem; }
input, select, textarea { font: inherit; color: var(--encre); background: var(--fond); border: 1.5px solid var(--trait); border-radius: 12px; padding: 12px; width: 100%; min-height: 50px; }
.carte input, .carte select, .carte textarea, dialog input, dialog select, dialog textarea { background: var(--fond); }
textarea { resize: vertical; line-height: 1.45; }
.deux-colonnes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.segments { display: flex; border: 1.5px solid var(--trait); border-radius: 14px; overflow: hidden; background: var(--carte); }
.segments button { flex: 1; min-height: 48px; border: 0; background: none; font: inherit; font-weight: 650; color: var(--doux); cursor: pointer; }
.segments button[aria-pressed="true"] { background: var(--primaire-fond); color: var(--primaire); }
.ligne-montant { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.chiffre.total { font-size: 1.8rem; line-height: 1.15; }
.puces { list-style: disc; padding-left: 1.2em; display: flex; flex-direction: column; gap: 4px; }

/* Assistant IA */
.bandeau-demo { background: var(--alerte-fond); color: var(--alerte); border-radius: 12px; padding: 10px 14px; font-weight: 600; font-size: .94rem; }
.reponse { white-space: pre-wrap; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.puce { border: 1.5px solid var(--trait); background: var(--carte); color: var(--encre); border-radius: 18px; padding: 8px 14px; min-height: 40px; font: inherit; font-size: .92rem; text-align: left; cursor: pointer; }
.choix { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; }
.choix legend { font-weight: 650; font-size: .95rem; padding: 0; margin-bottom: 4px; }
.case { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; cursor: pointer; }
.case input { width: 24px; height: 24px; min-height: 0; padding: 0; flex: none; margin: 2px 0 0; accent-color: var(--primaire); }
.case > span { min-width: 0; }

/* Chronologie */
.chrono { display: flex; flex-direction: column; gap: 0; border-left: 2px solid var(--trait); margin-left: 8px; }
.chrono li { position: relative; padding: 0 0 16px 18px; }
.chrono li::before { content: ""; position: absolute; left: -7px; top: 8px; width: 12px; height: 12px; border-radius: 50%; background: var(--primaire); border: 2px solid var(--fond); }
.chrono button { width: 100%; text-align: left; background: var(--carte); border: 1px solid var(--trait); border-radius: 14px; padding: 12px 14px; font: inherit; color: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }

/* Urgence */
.numeros { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.numeros a { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 64px; border-radius: 14px; background: var(--danger); color: var(--sur-danger); text-decoration: none; font-weight: 750; font-size: 1.3rem; line-height: 1.1; }
.numeros a small { font-size: .8rem; font-weight: 600; }
.numeros.discrets a { background: var(--carte); color: var(--danger); border: 1.5px solid var(--trait); min-height: 54px; font-size: 1.1rem; }

/* Feuille (fenêtre de saisie) */
dialog.feuille { width: min(560px, 100%); max-width: 100%; max-height: 92vh; margin: auto auto 0; padding: 0; border: 0; border-radius: 22px 22px 0 0; background: var(--carte); color: var(--encre); overflow: auto; }
@media (min-width: 620px) { dialog.feuille { margin: auto; border-radius: 22px; } }
dialog.feuille::backdrop { background: rgba(10, 16, 22, .55); }
.feuille-contenu { display: flex; flex-direction: column; gap: 14px; padding: 22px 18px calc(18px + env(safe-area-inset-bottom, 0px)); }

/* Message bref en bas d'écran */
.annonce { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 30; max-width: calc(100% - 32px); background: var(--encre); color: var(--fond); padding: 12px 18px; border-radius: 14px; font-weight: 600; text-align: center; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); }

@media (prefers-reduced-motion: no-preference) {
  .progression span { transition: width .3s ease; }
}
