/* Mes mails — dossiers à gauche, liste au centre, lecture à droite ; sur téléphone, un écran à la fois. */
:root {
  --bg: #f7f4ee; --panel: #fffdf9; --fg: #14202b; --muted: #6a7580; --line: #e4ddcf;
  --accent: #1e5c99; --accent-soft: #e1edf8; --on-accent: #fff; --unread: #d31b27; --ok: #1f7a4d;
  --warn: #a35a00; --warn-soft: #fbefd9;
  --font: system-ui, -apple-system, 'Segoe UI', Inter, sans-serif;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121921; --panel: #1a232d; --fg: #ece8df; --muted: #9aa7b3; --line: #2b3641;
    --accent: #6db0ea; --accent-soft: #1e3248; --on-accent: #0f1a24; --unread: #ff6b73; --ok: #5fcf98;
    --warn: #e9b25c; --warn-soft: #3a2d14;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 var(--font);
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chargement { text-align: center; color: var(--muted); margin-top: 30vh; }
[hidden] { display: none !important; }

/* ---------- Connexion ---------- */
.connexion { max-width: 340px; margin: 18vh auto 0; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.connexion h1 { margin: 0 0 6px; color: var(--accent); font-size: 26px; }
.connexion input { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }

/* ---------- Mise en page ---------- */
.app {
  display: grid; grid-template-columns: 230px minmax(300px, 400px) minmax(0, 1fr);
  gap: 10px; height: 100vh; height: 100dvh;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}
.col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

/* Barre de gauche */
.cote { overflow-y: auto; padding-bottom: 12px; }
.cote h1 { margin: 0; padding: 16px 16px 10px; font-size: 18px; color: var(--accent); }
.ecrire { margin: 0 12px 10px; padding: 10px 14px; border: 0; border-radius: 99px; background: var(--accent); color: var(--on-accent); font-weight: 600; }
.sec { padding: 12px 16px 4px; color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.lien-cote {
  display: flex; align-items: center; gap: 9px; width: calc(100% - 16px); margin: 0 8px; padding: 8px 10px;
  border: 0; border-radius: 9px; background: none; text-align: left;
}
.lien-cote:hover { background: var(--bg); }
.lien-cote[aria-current="true"] { background: var(--accent-soft); font-weight: 600; }
.lien-cote .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lien-cote small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.lien-cote small.nonlus { color: var(--unread); font-weight: 600; }
.lien-cote.sous { padding-left: 30px; font-size: 14px; }
.pastille { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.fleche { color: var(--muted); font-size: 11px; width: 14px; text-align: center; }
.alerte-compte { margin: 6px 12px; padding: 8px 10px; border-radius: 9px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }

/* Liste */
.outils { display: flex; gap: 8px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); }
.outils input[type=search] { flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--bg); }
.titre-vue { padding: 12px 14px 4px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.titre-vue small { color: var(--muted); font-weight: 400; }
.liste { overflow-y: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; }
.ligne {
  display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 10px 14px 10px 12px; min-width: 0; position: relative;
}
.ligne:hover { background: var(--bg); }
.ligne[aria-current="true"] { background: var(--accent-soft); }
.ligne.nonlu { box-shadow: inset 3px 0 0 var(--unread); }
.ligne .l1 { display: flex; gap: 8px; align-items: center; }
.ligne .de { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne .quand { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; flex: none; }
.ligne .sujet { padding-left: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.ligne.nonlu .de, .ligne.nonlu .sujet { font-weight: 650; }
.etoile { color: #e0a100; }
.vide { margin: auto; padding: 30px; text-align: center; color: var(--muted); max-width: 34ch; }
.plus { margin: 12px; padding: 9px; width: calc(100% - 24px); border: 1px solid var(--line); border-radius: 10px; background: none; color: var(--accent); }
.erreur-boite { margin: 8px 12px; padding: 8px 10px; border-radius: 9px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }

/* Lecture */
.barre { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--line); min-height: 52px; }
.btn {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--bg); white-space: nowrap;
  text-decoration: none; color: var(--fg); display: inline-flex; align-items: center; gap: 5px;
}
.btn:hover { border-color: var(--accent); }
.btn.principal { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.danger { color: var(--unread); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.icone { padding: 6px 10px; }
.retour { display: none; border: 0; background: none; color: var(--accent); padding: 6px 4px; }
.lecture { overflow-y: auto; flex: 1; min-height: 0; padding: 16px 20px 40px; }
.lecture h2 { margin: 0 0 10px; font-size: 20px; line-height: 1.3; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: 13px; margin-bottom: 14px; overflow-wrap: anywhere; display: flex; flex-direction: column; gap: 2px; }
.meta b { color: var(--fg); font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); color: var(--fg); width: max-content; }
.corps-cadre { width: 100%; border: 0; min-height: 120px; display: block; background: #fff; border-radius: 10px; }
.corps-texte { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 80ch; }
.pieces { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.piece { display: inline-flex; gap: 6px; align-items: center; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--fg); text-decoration: none; font-size: 13px; max-width: 100%; }
.piece span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.piece small { color: var(--muted); }

/* Feuilles (écrire, plus tard, réglages…) */
.voile { position: fixed; inset: 0; background: rgba(10, 16, 22, .45); z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; }
.feuille {
  background: var(--panel); border-radius: 18px; width: min(760px, 100%); max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.feuille.petite { width: min(420px, 100%); }
.feuille-tete { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.feuille-tete h3 { margin: 0; flex: 1; font-size: 16px; }
.fermer { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); padding: 4px 8px; }
.feuille-corps { padding: 14px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.feuille-pied { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); }
.feuille-pied .esp { flex: 1; }
.champ { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.champ label { width: 52px; color: var(--muted); font-size: 13px; flex: none; }
.champ input, .champ select { flex: 1; min-width: 0; border: 0; background: none; padding: 6px 0; }
.champ input:focus, .champ select:focus { outline: none; }
.lien-mini { border: 0; background: none; color: var(--accent); font-size: 13px; padding: 2px 4px; }
textarea.texte { min-height: 220px; resize: vertical; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); line-height: 1.5; }
.sig-apercu { border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13px; color: var(--muted); max-height: 140px; overflow: auto; }
.sig-apercu img { max-width: 100%; height: auto; }
.cite { border-left: 3px solid var(--line); padding-left: 10px; color: var(--muted); font-size: 13px; max-height: 160px; overflow: auto; white-space: pre-wrap; }
.liste-pj { display: flex; flex-wrap: wrap; gap: 6px; }
.choix { display: flex; flex-direction: column; gap: 6px; }
.choix button { text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); display: flex; justify-content: space-between; gap: 10px; }
.choix button small { color: var(--muted); }
.choix input[type=datetime-local] { padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.editeur-sig { min-height: 110px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #fff; color: #14202b; overflow: auto; }
.editeur-sig img { max-width: 100%; height: auto; }
.carte { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.carte .l { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.carte .discret, .discret { color: var(--muted); font-size: 13px; }
input.std, textarea.std, select.std { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom));
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; z-index: 40;
  max-width: 92vw; display: flex; gap: 14px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast button { border: 0; background: none; color: var(--accent-soft); font-weight: 700; padding: 0; }

/* ---------- Téléphone ---------- */
.menu { display: none; border: 0; background: none; font-size: 20px; padding: 4px 8px; color: var(--accent); }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0; }
  .col { border-radius: 0; border: 0; }
  .cote { position: fixed; inset: 0 25% 0 0; z-index: 15; transform: translateX(-105%); transition: transform .2s; border-right: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
  .app.menu-ouvert .cote { transform: none; box-shadow: 0 0 0 100vw rgba(10,16,22,.35); }
  .menu { display: inline-block; }
  .liste-col { padding-top: env(safe-area-inset-top); }
  .app.lecture-ouverte .liste-col { display: none; }
  .app:not(.lecture-ouverte) .lecture-col { display: none; }
  .lecture-col { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .retour { display: inline-block; }
  .lecture { padding: 14px 14px 40px; }
  .voile { padding: 0; align-items: flex-end; }
  .feuille { border-radius: 18px 18px 0 0; max-height: 94dvh; padding-bottom: env(safe-area-inset-bottom); }
  .barre .btn .lib { display: none; }
}
