/* Courriel — l'application. Dessin repris de la maquette acceptée (maquette/index.html) :
   trois volets (dossiers, liste, lecture) sur un ordinateur ; un seul volet à la fois sur un téléphone.
   Les trois couleurs de la jauge portent le sens : vert = tout va bien, ambre = épinglé, rouge = bloqué.
   Les polices (Bricolage Grotesque, Figtree) viennent de Google Fonts ; sans elles, la pile de repli garde tout lisible. */
:root {
  --fond: #f2f5ee; --surface: #ffffff; --surface-2: #f7f9f4; --encre: #1b2418; --doux: #5c6a55; --trait: #dde4d5;
  --vert: #47791f; --vert-fond: #e9f3dc; --ambre: #9a6400; --ambre-fond: #fdf1d3; --rouge: #b3261e; --rouge-fond: #fde9e6;
  --sur-vert: #ffffff; --ombre: 0 10px 30px rgba(27, 36, 24, .10);
  --titre: "Bricolage Grotesque", "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --texte: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #121810; --surface: #1a2217; --surface-2: #20291c; --encre: #e7eee1; --doux: #9eac96; --trait: #2d3a28;
    --vert: #8fcf52; --vert-fond: #24361a; --ambre: #f2b84b; --ambre-fond: #3a2e12; --rouge: #ff8a7d; --rouge-fond: #3d1c19;
    --sur-vert: #10160d; --ombre: 0 10px 30px rgba(0, 0, 0, .45); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #121810; --surface: #1a2217; --surface-2: #20291c; --encre: #e7eee1; --doux: #9eac96; --trait: #2d3a28;
  --vert: #8fcf52; --vert-fond: #24361a; --ambre: #f2b84b; --ambre-fond: #3a2e12; --rouge: #ff8a7d; --rouge-fond: #3d1c19;
  --sur-vert: #10160d; --ombre: 0 10px 30px rgba(0, 0, 0, .45); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--fond); color: var(--encre); font: 16px/1.45 var(--texte); -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
#racine { height: 100%; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
:focus-visible { outline: 3px solid var(--vert); outline-offset: 2px; border-radius: 6px; }
h1, h2, p, ul, ol { margin: 0; }

.app { height: 100%; display: flex; flex-direction: column; gap: 10px; max-width: 1320px; margin: 0 auto;
       padding-top: max(10px, env(safe-area-inset-top, 0px)); padding-bottom: max(10px, 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)); }

/* ── Bandeau du haut ── */
.haut { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.marque { display: flex; align-items: center; gap: 10px; min-width: 0; margin-right: auto; }
.marque .logo { display: flex; flex: none; }
.jauge { width: 38px; height: 38px; flex: none; }
.marque b, .marque h1 { font: 700 1.2rem/1.1 var(--titre); letter-spacing: -.01em; }
.marque small { display: block; color: var(--doux); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ecrire { border: 0; background: var(--vert); color: var(--sur-vert); font-weight: 700; padding: 10px 18px; border-radius: 12px; }
.outils { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bande { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--ambre-fond); color: var(--encre); border-radius: 10px; padding: 6px 12px; font-size: .9rem; font-weight: 600; }

/* ── Les trois volets ── */
.volets { flex: 1; min-height: 0; display: grid; grid-template-columns: 230px minmax(280px, 380px) minmax(0, 1fr); gap: 10px; }
.volet { background: var(--surface); border: 1px solid var(--trait); border-radius: 16px; min-height: 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.volet h2 { font: 700 1rem/1.2 var(--titre); padding: 14px 16px 8px; }
.defile { overflow-y: auto; min-height: 0; flex: 1; -webkit-overflow-scrolling: touch; }

.dossiers button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; text-align: left; padding: 10px 16px; font-weight: 500; }
.dossiers button[aria-current="true"] { background: var(--vert-fond); font-weight: 700; }
.dossiers .nom-dossier { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dossiers .option-pro .nom-dossier { white-space: normal; overflow: visible; text-overflow: clip; }
.dossiers .n { margin-left: auto; font-variant-numeric: tabular-nums; font-size: .82rem; color: var(--doux); }
.dossiers .ico { width: 20px; text-align: center; flex: none; }
.dossiers .sep { margin: 8px 16px 2px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--doux); }
.dossiers .groupe { margin: 12px 16px 2px; font: 700 .9rem/1.2 var(--titre); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dossiers .bloq[aria-current="true"] { background: var(--rouge-fond); }
.pro { font-size: .68rem; font-weight: 700; letter-spacing: .06em; color: var(--ambre); border: 1px solid currentColor; border-radius: 999px; padding: 1px 7px; margin-left: 6px; flex: none; }
.pied-dossiers { border-top: 1px solid var(--trait); padding: 10px 16px; display: grid; gap: 6px; justify-items: start; }
.lien { border: 0; background: none; padding: 4px 0; color: var(--vert); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; font-size: .92rem; }
.installer { display: grid; gap: 6px; justify-items: start; }

.entete-liste { display: flex; align-items: center; gap: 8px; padding: 8px 12px 6px 0; }
.entete-liste h2 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-top: 6px; padding-bottom: 6px; }
.cherche { margin: 0 12px 8px; }
.cherche input { width: 100%; font: inherit; color: var(--encre); background: var(--surface-2); border: 1px solid var(--trait); border-radius: 10px; padding: 9px 12px; }
.titre-groupe { padding: 8px 16px 4px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ambre); font-weight: 700; }
.titre-groupe.doux { color: var(--doux); }
.ligne { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 4px 10px; align-items: start; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--trait); background: none; padding: 12px 12px 12px 10px; }
.ligne[aria-current="true"] { background: var(--surface-2); }
.ligne:focus-visible { outline-offset: -3px; }
.ligne .point { width: 9px; height: 9px; border-radius: 50%; background: var(--vert); margin-top: 7px; visibility: hidden; }
.ligne.non-lu .point { visibility: visible; }
.ligne.non-lu .de, .ligne.non-lu .objet { font-weight: 700; }
.ligne .de { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne .quand { font-size: .8rem; color: var(--doux); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ligne .objet { grid-column: 2 / 4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne .extrait { grid-column: 2 / 4; color: var(--doux); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne .etiq { grid-column: 2 / 4; justify-self: start; }
.etiq { font-size: .78rem; font-weight: 700; border-radius: 6px; padding: 1px 8px; }
.etiq.epingle { background: var(--ambre-fond); color: var(--ambre); }
.etiq.bloque { background: var(--rouge-fond); color: var(--rouge); }
.vide { padding: 28px 18px; color: var(--doux); display: grid; gap: 12px; justify-items: start; }
.plus { display: block; margin: 12px auto 16px; }

.lecture .barre { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--trait); }
.action { border: 1px solid var(--trait); background: var(--surface-2); border-radius: 10px; padding: 8px 12px; font-weight: 600; font-size: .92rem; }
.action.vert { background: var(--vert); border-color: var(--vert); color: var(--sur-vert); }
.action.ambre { background: var(--ambre-fond); border-color: transparent; color: var(--ambre); }
.action.rouge { color: var(--rouge); }
.action.plein-rouge { background: var(--rouge); border-color: var(--rouge); color: var(--surface); }
.action.second { background: none; font-weight: 500; }
.action.rond { padding: 6px 11px; font-size: 1.05rem; line-height: 1.2; }
.action.grand { padding: 12px 18px; font-size: 1rem; }
.retour { display: none; }
.courriel { padding: 18px 20px 28px; max-width: 78ch; display: grid; gap: 14px; }
.courriel h1 { font: 700 1.45rem/1.2 var(--titre); text-wrap: balance; overflow-wrap: anywhere; }
.courriel h2 { font: 700 .95rem/1.2 var(--titre); padding: 0; }
.courriel .qui { color: var(--doux); font-size: .92rem; overflow-wrap: anywhere; }
.courriel .qui b { color: var(--encre); }
.texte-brut { white-space: pre-wrap; overflow-wrap: anywhere; }
.cadre { display: block; width: 100%; height: 62vh; min-height: 320px; border: 1px solid var(--trait); border-radius: 12px; background: #ffffff; }
.note-images { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--doux); font-size: .9rem; }
.alerte { background: var(--rouge-fond); border-radius: 12px; padding: 12px 14px; }
.alerte b { color: var(--rouge); }
.alerte ul { margin: 6px 0 0; padding-left: 20px; }
.liens, .pieces { display: grid; gap: 8px; justify-items: start; border-top: 1px solid var(--trait); padding-top: 14px; }
.lien-courriel, .piece { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; max-width: 100%; text-align: left; border: 1px solid var(--trait); background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.nom-lien, .nom-piece { font-weight: 600; overflow-wrap: anywhere; }
.vers, .taille, .discret-texte { color: var(--doux); font-size: .88rem; overflow-wrap: anywhere; }
.adresse-lien { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88rem; overflow-wrap: anywhere; background: var(--surface-2); border: 1px solid var(--trait); border-radius: 10px; padding: 8px 10px; }
.accueil { padding: 28px 22px; color: var(--doux); max-width: 56ch; display: grid; gap: 10px; }
.accueil h1 { font: 700 1.3rem/1.2 var(--titre); color: var(--encre); }
.accueil ul { padding-left: 20px; }
.accueil li { margin-bottom: 6px; }

/* ── Fenêtres (les nôtres : jamais celles du navigateur) ── */
.voile { position: fixed; inset: 0; background: rgba(10, 16, 8, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.fenetre { background: var(--surface); border-radius: 18px; box-shadow: var(--ombre); width: min(560px, 100%); max-height: 100%; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.fenetre.large { width: min(680px, 100%); }
.fenetre h2 { font: 700 1.2rem/1.2 var(--titre); }
.fenetre .pied { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.fenetre ul, .fenetre ol { padding-left: 20px; }
.fenetre li { margin-bottom: 8px; }
.pile { display: grid; gap: 10px; }
.choix { display: grid; gap: 8px; }
.choix .action { display: flex; gap: 10px; align-items: center; text-align: left; }
.champ { font-weight: 600; font-size: .9rem; display: grid; gap: 4px; }
.champ input, .champ textarea { font: inherit; font-weight: 400; color: var(--encre); background: var(--surface-2); border: 1px solid var(--trait); border-radius: 10px; padding: 9px 12px; width: 100%; }
.champ textarea { min-height: 180px; resize: vertical; }
.case { display: flex; align-items: center; gap: 8px; font-size: .95rem; }
.case input { width: 18px; height: 18px; accent-color: var(--vert); }
.erreur { color: var(--rouge); font-weight: 600; background: var(--rouge-fond); border-radius: 10px; padding: 8px 12px; }
.annonce { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--encre); color: var(--fond); padding: 10px 16px; border-radius: 12px; box-shadow: var(--ombre); z-index: 30; max-width: calc(100% - 32px); font-weight: 600; }
.annonce-erreur { background: var(--rouge); color: var(--surface); }

/* ── Écran de connexion, écran d'attente ── */
.porte { min-height: 100%; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top, 0px)) 16px 24px; }
.carte { background: var(--surface); border: 1px solid var(--trait); border-radius: 18px; box-shadow: var(--ombre); width: min(420px, 100%); padding: 24px; display: grid; gap: 14px; }
.carte .marque { margin: 0 0 4px; }
.carte .marque h1 { font-size: 1.35rem; }
.sous-carte { display: grid; gap: 6px; justify-items: start; border-top: 1px solid var(--trait); padding-top: 12px; }
.attente { color: var(--doux); }
#racine > .attente { padding: 28px 18px; }

/* ── Téléphone : un volet à la fois ── */
@media (max-width: 899px) {
  .volets { grid-template-columns: minmax(0, 1fr); }
  .volet.dossiers-v { display: none; }
  .app[data-vue="dossiers"] .volet.dossiers-v { display: flex; }
  .app[data-vue="dossiers"] .volet.liste-v, .app[data-vue="dossiers"] .volet.lecture { display: none; }
  .app[data-vue="liste"] .volet.lecture { display: none; }
  .app[data-vue="lecture"] .volet.liste-v { display: none; }
  .retour, .menu { display: inline-block; }
  .marque small { display: none; }
  .cadre { height: 70vh; }
  .lecture .barre { gap: 6px; padding: 10px 12px; }
  .lecture .barre .action { padding: 7px 10px; font-size: .86rem; }
  .courriel { padding: 16px 16px 24px; }
}
@media (min-width: 900px) { .menu { display: none; } }
@media (prefers-reduced-motion: no-preference) {
  .annonce { animation: monte .25s ease-out; }
  @keyframes monte { from { opacity: 0; transform: translate(-50%, 8px); } }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
