/* Gaspard : plaques émaillées. Bleu émail, blanc, liseré en retrait ; listes à filets fins. */
:root {
  --fond: #f5f6f8;
  --surface: #ffffff;
  --encre: #0f1830;
  --doux: #525d78;
  --filet: #dde1e9;
  --filet-fort: #b4bccb;
  --email: #1c3fa6;
  --email-appui: #152f7e;
  --email-texte: #1c3fa6;
  --email-pale: #e7ecf9;
  --sur-email: #ffffff;
  --lisere: rgb(255 255 255 / .82);
  --alerte: #7c5200;
  --alerte-pale: #fbf0d6;
  --ok: #14664a;
  --voile: rgb(9 14 32 / .5);
  --rayon: 8px;
  --marge: 16px;
  --bas: env(safe-area-inset-bottom, 0px);
  --onglets: 64px;
  --sortie: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0b1020;
    --surface: #131a2e;
    --encre: #e9edf6;
    --doux: #a5afc6;
    --filet: #242d46;
    --filet-fort: #46537a;
    --email: #3558d6;
    --email-appui: #2a48b8;
    --email-texte: #a3b6ff;
    --email-pale: #18224a;
    --lisere: rgb(255 255 255 / .7);
    --alerte: #f1c56a;
    --alerte-pale: #2e2610;
    --ok: #74d3a9;
    --voile: rgb(0 0 0 / .62);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--fond);
  color: var(--encre);
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(var(--onglets) + var(--bas) + 24px);
  overflow-x: clip;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  accent-color: var(--email);
  caret-color: var(--email-texte);
}
body.hors-session { padding-bottom: var(--bas); }
::selection { background: var(--email); color: var(--sur-email); }
h1, h2, h3, p, ul, dl, dd { margin: 0; }
ul { padding: 0; list-style: none; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
a { color: var(--email-texte); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--email-texte); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.invisible {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.icone {
  width: 24px; height: 24px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.icone.plein { fill: currentColor; stroke-width: 1.5; }

/* ---------------------------------------------------------------- plaque */
.plaque {
  position: relative;
  background: var(--email);
  color: var(--sur-email);
  border-radius: var(--rayon);
  box-shadow: inset 0 0 0 4px var(--email), inset 0 0 0 5px var(--lisere);
}

/* ---------------------------------------------------------------- barre du haut */
.barre {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  min-height: calc(env(safe-area-inset-top, 0px) + 56px);
  padding: env(safe-area-inset-top, 0px) var(--marge) 0;
  background: var(--fond);
  border-bottom: 1px solid var(--filet);
}
.hors-session .barre { display: none; }
.sceau {
  display: grid; place-items: center; width: 34px; height: 34px;
  background: var(--email); color: var(--sur-email); border-radius: 7px;
  box-shadow: inset 0 0 0 2px var(--email), inset 0 0 0 3px var(--lisere);
}
.sceau .icone { width: 22px; height: 22px; }
.retour {
  display: grid; place-items: center; width: 44px; height: 44px; margin-left: -10px;
  border: 0; border-radius: var(--rayon); background: transparent;
}
.retour:active { background: var(--filet); }
.titres { min-width: 0; flex: 1; }
.titres h1 { font-size: 1.125rem; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
.titres h1, .sous-titre { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sous-titre { font-size: .8125rem; line-height: 1.3; color: var(--doux); }

main { max-width: 640px; margin: 0 auto; padding: 0 var(--marge); }
/* le texte vient d'e-mails : un mot interminable se coupe, il ne pousse jamais la page */
main :is(h2, h3, p, li, dd, dt, b) { overflow-wrap: anywhere; min-width: 0; }
main :is(section, article, .actions, .promesse) { grid-template-columns: minmax(0, 1fr); }
@keyframes arrivee { from { transform: translateY(12px); } }

/* ---------------------------------------------------------------- boutons */
.principal, .secondaire {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: var(--rayon);
  font-weight: 650; font-size: 1rem; border: 0;
  transition: background-color .15s, opacity .15s;
}
.principal {
  background: var(--email); color: var(--sur-email);
  box-shadow: inset 0 0 0 3px var(--email), inset 0 0 0 4px var(--lisere);
}
.principal:active { background: var(--email-appui); box-shadow: inset 0 0 0 3px var(--email-appui), inset 0 0 0 4px var(--lisere); }
.secondaire { background: transparent; box-shadow: inset 0 0 0 1px var(--filet-fort); }
.secondaire:active { background: var(--filet); }
.principal:disabled, .secondaire:disabled { opacity: .5; cursor: default; }
.principal.petit { min-height: 44px; padding: 0 16px; font-size: .9375rem; }
.principal.large { width: 100%; }

/* ---------------------------------------------------------------- connexion */
.connexion {
  min-height: 100dvh; max-width: 380px; margin: 0 auto;
  display: flex; flex-direction: column; justify-content: center; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 32px) 8px 48px;
}
.enseigne { display: grid; place-items: center; width: 88px; height: 88px; border-radius: 14px; margin-bottom: 12px; }
.enseigne .icone { width: 56px; height: 56px; }
.connexion h2 { font-size: 2rem; line-height: 1.1; font-weight: 800; letter-spacing: -.025em; }
.accroche { font-size: 1.125rem; line-height: 1.45; max-width: 30ch; margin-bottom: 20px; }
.note { font-size: .875rem; color: var(--doux); }
.note:empty { display: none; }

/* pages simples servies par le serveur (lien expiré, connexion réussie) */
body.simple { padding: 0 var(--marge); }
.simple main { max-width: 380px; padding: 22dvh 0 48px; display: grid; gap: 12px; }
.simple h1 { font-size: 1.75rem; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; }
.simple a {
  justify-self: start; display: inline-flex; align-items: center; min-height: 48px; padding: 0 20px; margin-top: 12px;
  background: var(--email); color: var(--sur-email); border-radius: var(--rayon); font-weight: 650; text-decoration: none;
  box-shadow: inset 0 0 0 3px var(--email), inset 0 0 0 4px var(--lisere);
}
.sans-script { padding: 48px var(--marge); }

/* ---------------------------------------------------------------- aujourd'hui */
.annonce-jour { padding: 28px 0 20px; }
.annonce-jour h2 { font-size: 1.875rem; line-height: 1.12; font-weight: 800; letter-spacing: -.025em; text-wrap: balance; }
.annonce-jour p { margin-top: 8px; color: var(--doux); max-width: 34ch; }

.bandeau {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; margin-bottom: 20px;
  background: var(--email-pale); border-radius: var(--rayon);
}
.bandeau .icone { color: var(--email-texte); }
.bandeau p { flex: 1; font-size: .875rem; line-height: 1.4; }

/* ---------------------------------------------------------------- lignes (un fil par ligne) */
.lignes { margin: 0 calc(-1 * var(--marge)); border-top: 1px solid var(--filet); }
.lignes li { border-bottom: 1px solid var(--filet); }
.ligne {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px var(--marge); min-height: 72px;
  color: inherit; text-decoration: none; background: var(--surface);
  transition: background-color .15s;
}
.ligne:active { background: var(--email-pale); }
.etat {
  flex: none; width: 10px; height: 10px; margin-top: 7px; border-radius: 2px; position: relative;
}
.etat.decider { background: var(--email-texte); }
.etat.attente { box-shadow: inset 0 0 0 1.5px var(--doux); }
.etat.clos { box-shadow: inset 0 0 0 1.5px var(--filet-fort); }
.etat.clos::after {
  content: ""; position: absolute; left: -2px; right: -2px; top: 4.25px; height: 1.5px;
  background: var(--doux); transform: rotate(-45deg);
}
.ligne-corps { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.ligne-tete { display: flex; align-items: baseline; gap: 12px; }
.ligne-titre { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.non-lu .ligne-titre { font-weight: 700; }
.quand { flex: none; font-size: .8125rem; color: var(--doux); white-space: nowrap; }
.ligne-infos { font-size: .875rem; color: var(--doux); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ligne-etat { font-size: .875rem; color: var(--doux); overflow-wrap: anywhere; }
.ligne-etat.decider { color: var(--email-texte); font-weight: 650; }
.vignette { flex: none; width: 56px; height: 56px; border-radius: 6px; object-fit: cover; background: var(--filet); }

/* ---------------------------------------------------------------- espaces : une plaque par porte */
.portes { padding-top: 36px; display: grid; gap: 12px; }
.portes h3, .groupe-titre {
  font-size: .8125rem; line-height: 1.4; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--doux);
}
.porte {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 16px;
  min-height: 84px; padding: 18px 30px; text-decoration: none;
  transition: background-color .15s;
}
.porte::before, .porte::after {
  content: ""; position: absolute; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%;
  background: var(--lisere);
}
.porte::before { left: 13px; }
.porte::after { right: 13px; }
a.porte:active { background: var(--email-appui); box-shadow: inset 0 0 0 4px var(--email-appui), inset 0 0 0 5px var(--lisere); }
.porte-nom { font-size: 1.1875rem; line-height: 1.2; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.porte-objet { grid-column: 1; font-size: .875rem; color: color-mix(in srgb, var(--sur-email) 86%, var(--email)); }
.porte-compte { grid-column: 2; grid-row: 1 / span 2; font-size: .875rem; font-weight: 650; text-align: right; }
.porte.a-venir {
  background: transparent; color: var(--encre);
  box-shadow: none; outline: 1.5px dashed var(--filet-fort); outline-offset: -1.5px;
}
.porte.a-venir::before, .porte.a-venir::after { background: var(--filet-fort); }
.porte.a-venir .porte-objet, .porte.a-venir .porte-compte { color: var(--doux); }
a.porte.a-venir:active { background: var(--filet); box-shadow: none; }
a.porte.a-venir:focus-visible { outline: 2px solid var(--email-texte); outline-offset: 2px; }

/* ---------------------------------------------------------------- un espace */
.groupe { padding-top: 24px; }
.groupe-titre { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.groupe-compte { font-weight: 500; letter-spacing: 0; }
.vide, .bientot { padding: 40px 0; display: grid; gap: 12px; justify-items: start; }
.vide h2, .bientot h2 { font-size: 1.375rem; line-height: 1.2; font-weight: 750; letter-spacing: -.015em; }
.vide p { color: var(--doux); max-width: 36ch; }
.bientot .plaque { width: 100%; margin-bottom: 16px; }
.promesse { display: grid; gap: 10px; max-width: 38ch; }
.promesse li { position: relative; padding-left: 20px; }
.promesse li::before {
  content: ""; position: absolute; left: 0; top: .55em; width: 8px; height: 8px; border-radius: 2px;
  box-shadow: inset 0 0 0 1.5px var(--doux);
}

/* ---------------------------------------------------------------- un fil */
.fiche { padding: 24px 0 8px; display: grid; gap: 16px; }
.fiche h2 { font-size: 1.5rem; line-height: 1.18; font-weight: 800; letter-spacing: -.02em; text-wrap: balance; overflow-wrap: anywhere; }
.photos {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  margin: 0 calc(-1 * var(--marge)); padding: 0 var(--marge); scrollbar-width: none;
}
.photos img {
  flex: none; width: 84%; max-width: 420px; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: var(--rayon); scroll-snap-align: center; background: var(--filet);
}
.photos img:only-child { width: 100%; max-width: none; }
.faits { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border-top: 1px solid var(--filet); }
.faits > div { padding: 10px 0; border-bottom: 1px solid var(--filet); min-width: 0; }
.faits > div:nth-child(odd) { padding-right: 12px; }
.faits > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
.faits dt { font-size: .8125rem; color: var(--doux); }
.faits dd { font-weight: 650; overflow-wrap: anywhere; }
.resume { max-width: 62ch; }
.verifier { padding: 12px 14px; background: var(--alerte-pale); border-radius: var(--rayon); color: var(--alerte); }
.verifier h3 { font-size: .8125rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.verifier ul { margin-top: 4px; display: grid; gap: 2px; color: var(--encre); }
.verifier li { overflow-wrap: anywhere; }
.lien-dehors {
  justify-self: start; display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  font-weight: 650; overflow-wrap: anywhere;
}
.lien-dehors .icone { width: 20px; height: 20px; }

.echanges { padding-top: 24px; }
.echange { padding: 16px 0; border-top: 1px solid var(--filet); display: grid; gap: 8px; min-width: 0; }
.echange-tete { display: flex; align-items: baseline; gap: 8px; font-size: .875rem; min-width: 0; }
.echange-tete b { min-width: 0; overflow-wrap: anywhere; }
.nature { color: var(--doux); }
.echange-tete .quand { margin-left: auto; }
.categorie { font-size: 1.0625rem; font-weight: 700; }
.a-toi { padding: 10px 12px; background: var(--email-pale); border-radius: var(--rayon); overflow-wrap: anywhere; }
.objet { font-size: .875rem; color: var(--doux); overflow-wrap: anywhere; }
.lettre {
  display: block; width: 100%; margin: 0;
  padding: 14px; border: 0; border-radius: var(--rayon);
  background: var(--surface); color: var(--encre);
  box-shadow: inset 0 0 0 1px var(--filet-fort);
  font: inherit; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere;
}
textarea.lettre { resize: none; min-height: 9lh; field-sizing: content; }
textarea.lettre:focus-visible { outline: 2px solid var(--email-texte); outline-offset: 0; border-radius: var(--rayon); }
.parti .lettre { background: transparent; box-shadow: inset 0 0 0 1px var(--filet); color: var(--doux); }
.actions { display: grid; gap: 10px; }
.destinataire { font-size: .875rem; color: var(--doux); overflow-wrap: anywhere; }
.destinataire b { color: var(--encre); font-weight: 650; }
.fait { display: flex; align-items: center; gap: 6px; font-size: .875rem; font-weight: 650; color: var(--ok); }
.fait .icone { width: 18px; height: 18px; stroke-width: 2.25; }

/* ---------------------------------------------------------------- réglages */
.reglage { padding-top: 24px; display: grid; gap: 12px; justify-items: start; }
.reglage .groupe-titre { margin-bottom: 0; }
.reglage p { max-width: 38ch; overflow-wrap: anywhere; }
.reglage .faits { width: 100%; }

/* ---------------------------------------------------------------- navigation basse */
.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: space-around;
  height: calc(var(--onglets) + var(--bas)); padding: 0 4px var(--bas);
  background: var(--fond); border-top: 1px solid var(--filet);
}
.onglet {
  flex: 1 1 0; min-width: 0; max-width: 120px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--doux); text-decoration: none; font-size: .75rem; font-weight: 600;
}
.onglet-icone {
  display: grid; place-items: center; width: 54px; height: 30px; border-radius: 7px;
  transition: background-color .2s var(--sortie), color .2s;
}
.onglet-nom { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.onglet[aria-current] { color: var(--encre); }
.onglet[aria-current] .onglet-icone {
  background: var(--email); color: var(--sur-email);
  box-shadow: inset 0 0 0 2px var(--email), inset 0 0 0 3px var(--lisere);
}
.onglet.a-venir:not([aria-current]) .onglet-icone { opacity: .6; }
.onglet:focus-visible { outline-offset: -4px; }

/* ---------------------------------------------------------------- feuille de confirmation */
.feuille {
  width: 100%; max-width: 480px; margin: auto auto 0; padding: 24px var(--marge) calc(var(--bas) + 16px);
  border: 0; border-radius: 16px 16px 0 0; background: var(--surface); color: var(--encre);
  box-shadow: 0 -8px 32px rgb(9 14 32 / .18);
}
.feuille[open] { display: grid; gap: 8px; animation: monte .26s var(--sortie); }
.feuille::backdrop { background: var(--voile); animation: voile .2s ease-out; }
.feuille h2 { font-size: 1.25rem; line-height: 1.25; font-weight: 750; }
.feuille-detail { color: var(--doux); overflow-wrap: anywhere; }
.feuille-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
@keyframes monte { from { transform: translateY(100%); } }
@keyframes voile { from { opacity: 0; } }

/* ---------------------------------------------------------------- message temporaire */
.toast {
  position: fixed; left: var(--marge); right: var(--marge); bottom: calc(var(--onglets) + var(--bas) + 12px);
  max-width: 480px; margin: 0 auto; z-index: 10;
  background: var(--encre); color: var(--fond); padding: 12px 16px; border-radius: var(--rayon);
  font-size: .9375rem; box-shadow: 0 8px 24px rgb(9 14 32 / .24);
  animation: arrivee .2s var(--sortie);
}
.hors-session .toast { bottom: calc(var(--bas) + 16px); }

/* ---------------------------------------------------------------- chargement */
.squelette { padding-top: 32px; display: grid; gap: 14px; }
.squelette-ligne { height: 56px; border-radius: var(--rayon); background: var(--filet); opacity: .6; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
