/* Vue flux — mobile first, design de la maquette validée le 2026-08-21. */
* { box-sizing: border-box; }
:root {
  --ground: #F3F4F7; --surface: #FFFFFF; --ink: #1A1F27; --muted: #8A93A1;
  --soft: #5A6472; --rule: rgba(25,30,38,.10); --accent: #17696E;
  --accent-bg: rgba(23,105,110,.10); --warn: #B4761F;
  --tabbar: 3.4rem;
}
html, body { margin: 0; }
html { min-height: 100%; }
body {
  background: var(--ground); color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.45;
  max-width: 640px; margin: 0 auto;
  /* Pas de padding-bottom ici : Safari iOS l'ignore dans la hauteur de
     défilement. La réserve est un bloc réel (.tabbar-espace), inséré avec
     la barre — la dernière carte reste donc entièrement atteignable. */
}
.appbar {
  display: flex; align-items: center; gap: .6rem;
  padding: .9rem 1.1rem .6rem;
}
.appbar h1 { margin: 0; font-size: 1.45rem; letter-spacing: -.02em; flex: 1; }
.compteur { font-size: .78rem; font-weight: 600; color: var(--accent);
  background: var(--accent-bg); padding: .28rem .65rem; border-radius: 99px; }

.chips { display: flex; gap: .4rem; padding: .15rem .9rem .6rem; overflow-x: auto; }
.chip {
  font-size: .78rem; font-weight: 600; padding: .32rem .75rem; border-radius: 99px;
  background: var(--surface); border: 1px solid rgba(25,30,38,.14);
  color: var(--soft); white-space: nowrap; text-decoration: none;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.items { padding: 0 .7rem; }
.item {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 14px;
  padding: .65rem .8rem; margin-bottom: .5rem; position: relative;
}
.item .row1 { display: flex; align-items: center; gap: .5rem; }
.qui { font-weight: 650; font-size: .93rem; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quand { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.detail { font-size: .84rem; color: var(--soft); margin-top: .2rem;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pending { position: absolute; top: .7rem; right: .65rem;
  width: .5rem; height: .5rem; border-radius: 50%; background: var(--warn); }

.ch { width: 1.7rem; height: 1.7rem; border-radius: 9px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 800; }
.ch.mail { background: #E8EEFB; color: #3757B8; }
.ch.tel  { background: #E2F0EF; color: #17696E; }
.ch.sms  { background: #F0EAFB; color: #6B46C1; }
.ch.wa   { background: #E3F4E6; color: #1E8A45; }

.gestes { display: flex; align-items: center; gap: .45rem; margin-top: .55rem; flex-wrap: wrap; }
button.geste, a.geste {
  font: inherit; font-size: .78rem; font-weight: 650; padding: .34rem .75rem;
  border-radius: 99px; cursor: pointer; text-decoration: none;
  background: var(--accent-bg); color: var(--accent);
  border: 1px dashed rgba(23,105,110,.5);
}
button.geste.plain { background: var(--ground); color: var(--soft);
  border: 1px solid rgba(25,30,38,.14); }
.derive { font-size: .76rem; color: var(--accent); font-weight: 600; }

.vide { text-align: center; color: var(--muted); padding: 3rem 1rem; }

/* Feuille d'affectation */
.voile { position: fixed; inset: 0; background: rgba(16,20,26,.42); z-index: 30; }
.feuille {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  max-width: 640px; margin: 0 auto;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: .6rem 1rem calc(1.4rem + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -12px 40px rgba(10,14,20,.25);
  max-height: 82vh; overflow-y: auto;
}
.grab { width: 44px; height: 4px; border-radius: 2px;
  background: rgba(25,30,38,.18); margin: .2rem auto .8rem; }
.feuille h2 { margin: 0 0 .1rem; font-size: 1.02rem; }
.feuille .sous { font-size: .8rem; color: var(--muted); margin: 0 0 .8rem; }
.recherche { width: 100%; font: inherit; font-size: .9rem;
  background: var(--ground); border: 1px solid var(--rule); border-radius: 12px;
  padding: .55rem .8rem; margin-bottom: .6rem; }
/* Safari iOS refuse qu'un <button> soit un conteneur flex : le bouton est
   neutre, c'est le span intérieur .cible-in qui porte la mise en page. */
.cible { display: block; width: 100%; padding: 0; border: 0;
  border-bottom: 1px solid rgba(25,30,38,.07); background: none; font: inherit;
  text-align: left; cursor: pointer; color: var(--ink);
  -webkit-appearance: none; appearance: none; }
.cible-in { display: flex; align-items: center; gap: .65rem; width: 100%;
  padding: .55rem .2rem; }
.cible-texte { flex: 1; min-width: 0; }
.cible-texte b { display: block; color: var(--ink); font-size: .92rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 2rem; height: 2rem; border-radius: 50%; flex: none;
  background: #E2F0EF; color: var(--accent); font-weight: 700; font-size: .78rem;
  display: inline-flex; align-items: center; justify-content: center; }
.avatar.org { border-radius: 8px; background: #E8EEFB; color: #3757B8; }
.cible small { display: block; color: var(--muted); font-size: .74rem; }
.note-groupe { font-size: .78rem; color: var(--warn); margin: .4rem 0 .2rem; }

.confirmation { background: var(--accent-bg); color: var(--accent);
  border-radius: 12px; padding: .6rem .8rem; font-size: .85rem; font-weight: 600; }

.tabbar-espace {
  height: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 1rem);
  flex: none;
}
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  max-width: 640px; margin: 0 auto;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--rule);
  height: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px));
  padding: .45rem .4rem calc(.45rem + env(safe-area-inset-bottom, 0px));
  /* Opaque même en surimpression du contenu qui défile dessous. */
  backdrop-filter: saturate(180%) blur(8px);
}
.tab { flex: 1; text-align: center; font-size: .68rem; font-weight: 600;
  color: var(--muted); text-decoration: none; }
.tab.on { color: var(--accent); }
.tab .pic { display: flex; justify-content: center; height: 22px; margin-bottom: .15rem; }
.ico { display: block; flex: none; }

.htmx-request.item { opacity: .5; }

/* Fiches et listes (écrans 3-5) */
.retour { font-size: 1.3rem; text-decoration: none; color: var(--ink); padding: 0 .3rem; }
.fichehead { padding: .2rem 1.1rem .8rem; }
.fichehead h2 { margin: .5rem 0 .35rem; font-size: 1.3rem; letter-spacing: -.02em; }
.avatar { width: 2rem; height: 2rem; border-radius: 50%; flex: none;
  background: #E2F0EF; color: var(--accent); font-weight: 700; font-size: .78rem;
  display: inline-flex; align-items: center; justify-content: center; }
.avatar.org { border-radius: 8px; background: #E8EEFB; color: #3757B8; }
.avatar.big { width: 3.2rem; height: 3.2rem; font-size: 1.05rem; }
.orgchips { display: flex; gap: .4rem; flex-wrap: wrap; }
.orgchip { font-size: .74rem; font-weight: 600; padding: .26rem .6rem; border-radius: 99px;
  background: #E8EEFB; color: #3757B8; text-decoration: none; }
.bloc { background: var(--surface); border: 1px solid var(--rule); border-radius: 14px;
  padding: .7rem .85rem; margin-bottom: .55rem; }
.bloc h5 { margin: 0 0 .45rem; font-size: .72rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); }
.coord { display: flex; align-items: center; gap: .5rem; padding: .28rem 0; font-size: .87rem; }
.coord .ch { width: 1.4rem; height: 1.4rem; font-size: .62rem; }
.tag { font-size: .64rem; font-weight: 700; color: var(--accent);
  background: var(--accent-bg); padding: .1rem .4rem; border-radius: 4px; }
.tag.grey { color: var(--muted); background: var(--ground); }
.ligne { display: flex; align-items: center; gap: .65rem; text-decoration: none; color: inherit; }
.legende { font-size: .74rem; color: var(--muted); }
p.legende { text-align: center; padding: .6rem 0; }
.recherche { width: 100%; font: inherit; font-size: .92rem;
  background: var(--surface); border: 1px solid rgba(25,30,38,.18);
  border-radius: 12px; padding: .6rem .85rem; }

/* Vues détail */
.corps-mail { width: 100%; height: 62vh; border: 1px solid var(--rule); border-radius: 14px; background: #fff; }
.corps-texte { font: inherit; font-size: .9rem; white-space: pre-wrap; word-wrap: break-word; margin: 0; }
.corps-resume { font-size: .9rem; white-space: pre-wrap; }
.replique { padding: .45rem 0; border-bottom: 1px solid rgba(25,30,38,.06); }
.replique p { margin: .15rem 0 0; font-size: .89rem; }
.replique.moi p { color: var(--accent); }
button.chip { font: inherit; cursor: pointer; }
/* Toute la carte ouvre le détail ; les gestes restent au-dessus du lien. */
.ouvrir { position: absolute; inset: 0; z-index: 1; }
.gestes { position: relative; z-index: 2; }
.pending { z-index: 2; }

/* Édition des fiches */
.oter { font: inherit; font-size: .8rem; border: 0; background: none; color: var(--muted);
  cursor: pointer; padding: .15rem .4rem; border-radius: 6px; }
.oter:hover { color: #A33B2E; background: rgba(163,59,46,.08); }
.ajout { display: flex; gap: .45rem; margin-top: .55rem; }
.ajout input { flex: 1; font: inherit; font-size: .88rem; background: var(--ground);
  border: 1px solid var(--rule); border-radius: 10px; padding: .45rem .7rem; min-width: 0; }
.erreur-fiche { border-left: 3px solid #A33B2E; color: #A33B2E; font-size: .87rem; }

/* Lecture façon Gmail */
.lecture { padding: 0 1rem; }
.sujet-mail { margin: .3rem 0 .8rem; font-size: 1.22rem; line-height: 1.3; letter-spacing: -.01em; }
.entete-mail { display: flex; gap: .65rem; align-items: flex-start; margin-bottom: .7rem; }
.entete-infos { flex: 1; min-width: 0; }
.entete-infos .ligne1 { display: flex; align-items: baseline; gap: .5rem; }
.entete-infos .ligne1 b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.destinataires summary { list-style: none; cursor: pointer; font-size: .8rem; color: var(--muted); }
.destinataires summary::-webkit-details-marker { display: none; }
.detail-dest { font-size: .8rem; color: var(--soft); margin-top: .4rem; }
.detail-dest p { margin: .2rem 0; }
.pieces { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .7rem; }
.piece { font-size: .78rem; background: var(--surface); border: 1px solid var(--rule);
  border-radius: 8px; padding: .3rem .55rem; text-decoration: none; color: var(--ink); }
a.piece:active { background: var(--accent-bg); }
.corps-gmail { width: 100%; border: 0; background: #fff; border-radius: 10px; display: block; }
.corps-texte-gmail { font-size: .95rem; line-height: 1.6; white-space: pre-wrap;
  overflow-wrap: break-word; background: var(--surface); border-radius: 10px; padding: .9rem 1rem; }

/* Défilement infini : la sentinelle se charge quand elle apparaît. */
.suite { display: flex; justify-content: center; padding: 1rem 0 .4rem; }
.rondelle { width: 1.1rem; height: 1.1rem; border-radius: 50%;
  border: 2px solid var(--rule); border-top-color: var(--accent);
  animation: tourne .7s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .rondelle { animation: none; } }

/* Entité maison : d'où je parle */
.entite { display: inline-block; margin-top: .4rem; font-size: .68rem; font-weight: 700;
  letter-spacing: .02em; padding: .16rem .5rem; border-radius: 99px;
  color: var(--teinte); background: color-mix(in srgb, var(--teinte) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--teinte) 30%, transparent); }
@supports not (color: color-mix(in srgb, red 10%, transparent)) {
  .entite { color: var(--teinte); background: var(--ground); border: 1px solid var(--rule); }
}
.entite-ligne { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; font-size: .87rem; }
.entite-ligne .mono { flex: 1; }

/* Barre de recherche : toujours refermable (clavier iOS) */
.barre-recherche { display: flex; gap: .45rem; align-items: center; padding: 0 .9rem .6rem; margin: 0; }
.barre-recherche .recherche { flex: 1; min-width: 0; margin: 0; }
.fermer-recherche { font: inherit; font-size: 1rem; line-height: 1; cursor: pointer;
  border: 1px solid var(--rule); background: var(--surface); color: var(--muted);
  border-radius: 10px; padding: .5rem .7rem; -webkit-appearance: none; appearance: none; }
.fermer-recherche:active { background: var(--ground); }

/* Icônes d'action en tête de fiche */
.icone { font: inherit; font-size: 1.05rem; line-height: 1; cursor: pointer;
  border: 1px solid var(--rule); background: var(--surface); color: var(--accent);
  border-radius: 10px; padding: .4rem .6rem; -webkit-appearance: none; appearance: none; }
.icone:active { background: var(--accent-bg); }

/* Composeur façon Gmail : feuille presque plein écran, fermeture en haut à
   gauche, envoi en haut à droite, zone de rédaction enrichie. */
html, body { overflow-x: hidden; }  /* un mail large ne fait plus paniquer la page */
.feuille.pleine {
  top: max(1.6rem, env(safe-area-inset-top, 0px));
  bottom: 0; max-height: none;
  display: flex; flex-direction: column;
  padding: .5rem .9rem calc(.7rem + env(safe-area-inset-bottom, 0px));
}
.composeur { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.composeur-barre { display: flex; align-items: center; gap: .6rem; padding: .2rem 0 .6rem; }
.composeur-barre .envoyer { background: var(--accent); color: #fff; border-style: solid; }
.composeur-champ { font-size: .88rem; color: var(--soft); padding: .45rem 0;
  border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
.composeur-sujet { width: 100%; font: inherit; font-size: .95rem; font-weight: 600;
  border: 0; padding: .55rem 0; background: none; color: var(--ink); outline: none; }
.composeur-outils { display: flex; gap: .3rem; padding: .45rem 0; }
.composeur-outils button { font: inherit; font-size: .85rem; min-width: 2.1rem;
  padding: .3rem .5rem; border: 1px solid var(--rule); background: var(--surface);
  border-radius: 8px; cursor: pointer; color: var(--ink);
  -webkit-appearance: none; appearance: none; }
.composeur-outils button:active { background: var(--accent-bg); }
.composeur-editeur { flex: 1; min-height: 8rem; font: inherit; font-size: .95rem;
  line-height: 1.55; padding: .6rem 0; border: 0; outline: none; overflow-y: auto;
  background: none; color: var(--ink); width: 100%; }
.composeur-editeur:empty::before { content: attr(data-placeholder); color: var(--muted); }
