/* ============================================================
   Omnis Mail — feuille de style du webmail.

   Registre volontairement sobre : une messagerie professionnelle
   se juge à la densité d'information et au calme visuel, pas aux
   aplats de couleur. Les actions sur un message sont des icônes
   dans une barre d'outils, jamais des pavés de boutons.

   Palette : celle de l'écosystème (blanc + vert CREA), l'indigo
   en accent, le violet Sancti réservé à l'identité.
   ============================================================ */

:root {
  --bg-app:       #f6f8fc;
  --bg-primary:   #ffffff;
  --bg-secondary: #f1f3f6;
  --bg-tertiary:  #e6e9ee;
  --border:       #e3e6eb;
  --border-hov:   #cfd4dc;
  --t-primary:    #16181d;
  --t-secondary:  #454a54;
  --t-muted:      #6b7280;
  --t-dim:        #8b919c;
  --green:        #10a37f;
  --green-d:      #0a7a5e;
  --indigo:       #5c7cfa;
  --indigo-d:     #4c6ef5;
  --warn-bg:      #fff8e6;
  --warn-fg:      #7a5a00;
  --sancti:       #7c3aed;
  --amber:        #b76e00;
  --red:          #cc3f3f;
  --radius:       10px;
  --topbar-h:     62px;
  --shadow-pop:   0 12px 40px -12px rgba(16,24,40,.28), 0 2px 8px -2px rgba(16,24,40,.12);
}

* { box-sizing: border-box; }
/* `hidden` doit gagner : plusieurs blocs ci-dessous imposent un
   display (flex, grid), ce qui écraserait l'attribut sans cela. */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-app);
  color: var(--t-primary);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
}
.icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; display: block; flex-shrink: 0; }
.icon-sm { width: 15px; height: 15px; stroke-width: 2; }

.brand { display: flex; align-items: baseline; gap: 5px; font-size: 18px; color: var(--t-primary); text-decoration: none; white-space: nowrap; }
.brand .wm-omnis { font-weight: 800; letter-spacing: -.015em; }
.brand .wm-mail { font-weight: 500; color: var(--green); font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 11px 20px; border-radius: var(--radius); font-weight: 600; font-size: 14px;
  border: 1px solid transparent; cursor: pointer; transition: all .14s ease; text-decoration: none;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-d); }
.btn-primary:disabled { opacity: .55; cursor: progress; }
.btn-ghost { background: var(--bg-primary); border-color: var(--border); color: var(--t-primary); }
.btn-ghost:hover { border-color: var(--border-hov); background: var(--bg-secondary); }

.icon-btn {
  background: none; border: none; cursor: pointer; color: var(--t-muted);
  padding: 8px; border-radius: 50%; display: flex; transition: background .12s ease;
}
.icon-btn:hover { background: var(--bg-tertiary); color: var(--t-primary); }
.icon-btn:disabled { opacity: .4; cursor: default; }

/* ---------------- Connexion (Sancti ID) ---------------- */
.login {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(50% 42% at 50% 0%, rgba(124,58,237,.10), transparent 72%),
    radial-gradient(40% 40% at 88% 100%, rgba(16,163,127,.08), transparent 70%);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--bg-primary);
  border: 1px solid var(--border); border-radius: 18px; padding: 40px 34px;
  box-shadow: 0 28px 70px -34px rgba(16,24,40,.34);
  text-align: center;
}
.brand-lg { font-size: 28px; justify-content: center; margin-bottom: 10px; }
.brand-lg .wm-mail { font-size: 21px; }
.login-lead { color: var(--t-muted); margin: 0 0 28px; }
.btn-sancti {
  width: 100%; background: var(--sancti); color: #fff;
  box-shadow: 0 6px 22px -8px rgba(124,58,237,.7);
}
.btn-sancti:hover { background: #6d28d9; color: #fff; }
.sancti-mark { width: 20px; height: 20px; }
.login-note { color: var(--t-dim); font-size: 12.5px; margin: 16px 0 0; }
.login-sep {
  display: flex; align-items: center; gap: 12px; margin: 26px 0 18px;
  color: var(--t-dim); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
}
.login-sep::before, .login-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.login-local { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-local label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--t-secondary); font-weight: 500; }
.login-local input {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-primary); outline: none;
}
.login-local input:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(92,124,250,.15); }
.login-error { color: var(--red); font-size: 13px; margin: 0; }
.login-hint { color: var(--t-dim); font-size: 12px; text-align: center; margin: 0; }

/* ---------------- Structure ---------------- */
.app { height: 100%; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); flex-shrink: 0; position: relative;
  display: flex; align-items: center; gap: 8px; padding: 0 14px;
  background: var(--bg-app);
}
.topbar .brand { margin-right: 18px; }

.search { flex: 1; max-width: 720px; position: relative; display: flex; align-items: center; }
.search > .icon { position: absolute; left: 14px; color: var(--t-muted); }
.search input {
  width: 100%; padding: 11px 40px 11px 42px; border-radius: 8px;
  border: 1px solid transparent; background: var(--bg-secondary); outline: none;
}
.search input::placeholder { color: var(--t-muted); }
.search input:focus {
  background: var(--bg-primary); border-color: var(--border);
  box-shadow: var(--shadow-pop);
}
.search-clear { position: absolute; right: 6px; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.kind-switch { display: flex; background: var(--bg-secondary); border-radius: 999px; padding: 3px; margin-right: 6px; }
.kind-switch button {
  border: none; background: none; cursor: pointer; padding: 5px 15px;
  border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--t-muted);
}
.kind-switch button.active { background: var(--bg-primary); color: var(--t-primary); box-shadow: 0 1px 3px rgba(16,24,40,.14); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--indigo-d); color: #fff; font-weight: 700; font-size: 13.5px;
  display: grid; place-items: center; letter-spacing: .02em;
}
.avatar:hover { box-shadow: 0 0 0 4px rgba(92,124,250,.18); }
.avatar-lg { width: 46px; height: 46px; font-size: 17px; }

/* ---------------- Popovers ---------------- */
.popover {
  position: absolute; top: calc(var(--topbar-h) - 6px); right: 12px; z-index: 70;
  background: var(--bg-primary); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-pop); padding: 14px;
}
.apps-popover { width: 312px; }
.apps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.app-tile {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 12px 6px; border-radius: 12px; text-decoration: none; color: var(--t-secondary);
  font-size: 11.5px; font-weight: 600; text-align: center; line-height: 1.25;
}
.app-tile:hover { background: var(--bg-secondary); color: var(--t-primary); }
.app-tile .tile-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 15px; letter-spacing: -.02em;
}
.app-tile[aria-current="page"] { background: var(--bg-secondary); }
.popover-foot { margin: 12px 4px 2px; font-size: 11.5px; color: var(--t-dim); text-align: center; }

.profile-popover { width: 288px; }
.profile-head { display: flex; align-items: center; gap: 12px; padding: 4px 4px 14px; border-bottom: 1px solid var(--border); }
.profile-head strong { display: block; font-size: 14px; }
.profile-head span { display: block; font-size: 12.5px; color: var(--t-muted); word-break: break-all; }
.profile-quota { font-size: 12px; color: var(--t-muted); padding: 12px 4px; border-bottom: 1px solid var(--border); }
.popover-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border: none; background: none; cursor: pointer; text-align: left;
  border-radius: 8px; color: var(--t-secondary); font-size: 13.5px; text-decoration: none;
}
.popover-item:hover { background: var(--bg-secondary); color: var(--t-primary); }

/* ---------------- Colonnes ----------------
   Deux zones seulement : les dossiers, puis LA page.
   La liste et la lecture ne coexistent jamais — on lit un
   message en pleine largeur, pas dans un volet coincé à côté
   de la liste. Une seule surface blanche, un seul cadre.      */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 244px 1fr; }
.app.nav-collapsed .layout { grid-template-columns: 74px 1fr; }

.sidebar { padding: 4px 10px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; }
.compose-btn {
  display: flex; align-items: center; gap: 12px; align-self: flex-start;
  padding: 14px 22px; border: 1px solid var(--border); border-radius: 16px;
  background: var(--bg-primary); cursor: pointer; font-weight: 600; font-size: 14px;
  box-shadow: 0 1px 3px rgba(16,24,40,.1); transition: box-shadow .14s ease;
  color: var(--t-primary); margin: 4px 0 4px 2px;
}
.compose-btn:hover { box-shadow: 0 4px 14px -4px rgba(16,24,40,.2); }
.compose-btn .icon { color: var(--green); }
.app.nav-collapsed .compose-btn span,
.app.nav-collapsed .side-section h4,
.app.nav-collapsed .side-note,
.app.nav-collapsed .side-action span,
.app.nav-collapsed .folders .label,
.app.nav-collapsed .categories .label { display: none; }
.app.nav-collapsed .compose-btn { padding: 14px; border-radius: 50%; }

.folders, .categories { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.folders li button, .categories li button {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 7px 14px; border: none; background: none; cursor: pointer;
  border-radius: 0 999px 999px 0; color: var(--t-secondary); text-align: left; font-size: 13.5px;
}
.folders li button:hover, .categories li button:hover { background: var(--bg-tertiary); }
.folders li button.active, .categories li button.active {
  background: rgba(16,163,127,.14); color: var(--green-d); font-weight: 700;
}
.folders .label, .categories .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 12px; font-weight: 700; color: var(--t-muted); }
.folders li button.active .badge, .categories li button.active .badge { color: var(--green-d); }

.side-section h4 {
  margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--t-dim); padding-left: 14px;
}
.side-action {
  margin-top: 10px; width: 100%; display: flex; align-items: center; gap: 14px;
  background: none; border: none; border-radius: 0 999px 999px 0;
  padding: 8px 14px; cursor: pointer; color: var(--indigo-d); font-size: 13.5px; font-weight: 600;
}
.side-action:hover { background: rgba(92,124,250,.1); }
.side-note { font-size: 11.5px; color: var(--t-dim); margin: 8px 14px 0; line-height: 1.4; }

/* ---------------- La page ----------------
   Liste et lecture partagent exactement le même cadre : quel que
   soit ce qu'on regarde, c'est la même feuille blanche. */
.list-pane, .read-pane, .agenda-pane {
  background: var(--bg-primary); min-height: 0;
  /* `min-width: 0` sinon la colonne 1fr refuse de descendre sous
     la largeur intrinsèque de son contenu et la page déborde. */
  min-width: 0;
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 16px 16px 0 0;
}
.list-pane { display: flex; flex-direction: column; }
.app.reading .list-pane, .app.agenda .list-pane { display: none; }
.read-pane { display: none; overflow-y: auto; }
.app.reading:not(.agenda) .read-pane { display: block; }
.agenda-pane { display: none; flex-direction: column; overflow-y: auto; }
.app.agenda .agenda-pane { display: flex; }
.app.agenda .read-pane { display: none; }

/* ---------------- Domaines ---------------- */

.domaines-pane { display: none; flex-direction: column; overflow-y: auto; padding: 26px 30px 40px; gap: 18px; }
.app.domaines .domaines-pane { display: flex; }
.app.domaines .list-pane, .app.domaines .read-pane, .app.domaines .agenda-pane { display: none; }

.domaines-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.domaines-head h2 { margin: 0 0 4px; font-size: 1.25rem; }
.domaines-lead { margin: 0; max-width: 46ch; color: var(--t-muted); font-size: 13.5px; }
.domaine-ajout { display: flex; gap: 8px; }
.domaine-ajout input {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; background: var(--bg-primary); min-width: 220px;
}

/* Dire ce qui n'est pas réel, et le dire fort. Une adresse qu'on
   croit vivante et qui ne reçoit rien est pire que pas d'adresse. */
.avertissement {
  margin: 0; padding: 11px 14px; border-radius: var(--radius);
  background: #fff6e5; border: 1px solid #f0c67a; color: #6b4a10; font-size: 13px;
}

.domaines-liste { display: flex; flex-direction: column; gap: 14px; }
.domaine {
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg-primary); overflow: hidden;
}
.domaine-entete { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.domaine-nom { font-weight: 600; font-size: 15px; }
.domaine-etat { font-size: 12.5px; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.domaine-etat.ok { background: #e6f6ef; color: #10704f; }
.domaine-etat.attente { background: #fdf0e3; color: #8a5a12; }
.domaine-actions { margin-left: auto; display: flex; gap: 8px; }

.domaine-corps { border-top: 1px solid var(--border); padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.domaine-corps h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--t-muted); }

.dns { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.dns th { text-align: left; color: var(--t-muted); font-weight: 600; padding: 5px 8px 5px 0; }
.dns td { padding: 6px 8px 6px 0; border-top: 1px solid var(--border); vertical-align: top; }
.dns .valeur { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; word-break: break-all; }
.dns .pourquoi { color: var(--t-muted); }

.controles { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
.controle { display: flex; gap: 8px; align-items: baseline; }
.controle .pastille { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 5px; }
.controle.ok .pastille { background: #10a37f; }
.controle.ko .pastille { background: var(--red); }
.controle .detail { color: var(--t-muted); }

.boites { display: flex; flex-direction: column; gap: 6px; }
.boite { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.boite-ajout { display: flex; gap: 8px; align-items: center; }
.boite-ajout input {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 11px; background: var(--bg-primary); width: 160px;
}
.boite-ajout .suffixe { color: var(--t-muted); font-size: 13px; }

/* ---------------- Choisir son adresse ---------------- */

.adresse-choix {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(16, 24, 40, .55);
}
.adresse-carte {
  width: min(30rem, 100%); background: var(--bg-primary);
  border-radius: 16px; padding: 30px 30px 26px;
  box-shadow: 0 24px 60px -18px rgba(16,24,40,.5);
}
.adresse-carte h2 { margin: 18px 0 8px; font-size: 1.3rem; }
.adresse-lead { margin: 0 0 20px; color: var(--t-muted); font-size: 13.5px; line-height: 1.6; }
.adresse-saisie {
  display: flex; align-items: center; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.adresse-saisie input { flex: 1; border: none; outline: none; padding: 11px 13px; background: none; font-size: 15px; }
.adresse-domaine { padding: 0 13px; color: var(--t-muted); font-size: 15px; white-space: nowrap; }
.adresse-etat { margin: 8px 0 0; min-height: 1.3em; font-size: 12.5px; }
.adresse-etat.ok { color: #10704f; }
.adresse-etat.ko { color: var(--red); }
.adresse-idees { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0 18px; }
.adresse-idees button {
  border: 1px solid var(--border); background: var(--bg-secondary); cursor: pointer;
  border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 12.5px;
}
.adresse-idees button:hover { border-color: #10a37f; color: #10a37f; }
#adresse-valider { width: 100%; justify-content: center; }

/* --- Agenda --- */
.agenda-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 20px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--bg-primary); z-index: 4;
}
.agenda-head { flex-wrap: wrap; }
.agenda-head strong { font-size: 16px; min-width: 150px; text-align: center; text-transform: capitalize; }
.agenda-head .btn { padding: 7px 14px; font-size: 13px; }
/* `minmax(0, 1fr)` : sans le 0, chaque colonne refuse de descendre
   sous la largeur de son plus long libellé et la page déborde. */
.agenda-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  border-top: 1px solid var(--border);
}
.agenda-grid .dow {
  padding: 8px; text-align: center; font-size: 11px; font-weight: 700; color: var(--t-dim);
  text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border);
}
.agenda-cell {
  min-height: 96px; min-width: 0; overflow: hidden;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
}
.agenda-cell:nth-child(7n) { border-right: none; }
.agenda-cell:hover { background: var(--bg-secondary); }
.agenda-cell.outside { background: var(--bg-secondary); color: var(--t-dim); }
.agenda-cell.selected { box-shadow: inset 0 0 0 2px var(--indigo); }
.agenda-cell .num { font-size: 12px; font-weight: 600; color: var(--t-muted); }
.agenda-cell.today .num {
  background: var(--green); color: #fff; border-radius: 50%;
  width: 22px; height: 22px; display: grid; place-items: center;
}
.agenda-chip {
  font-size: 11px; padding: 2px 6px; border-radius: 4px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  background: rgba(92,124,250,.14); color: var(--indigo-d);
}
.agenda-chip.source-crea { background: rgba(183,110,0,.15); color: var(--amber); }
.agenda-chip.source-invitation { background: rgba(16,163,127,.15); color: var(--green-d); }
.agenda-day { padding: 18px 22px 60px; }
.agenda-day h3 { margin: 0 0 12px; font-size: 15px; text-transform: capitalize; }
.agenda-item {
  display: flex; gap: 14px; padding: 11px 0; border-top: 1px solid var(--border);
}
.agenda-item .when { width: 120px; flex-shrink: 0; color: var(--t-muted); font-size: 13px; }
.agenda-item .what strong { display: block; font-weight: 600; }
.agenda-item .what span { color: var(--t-dim); font-size: 12.5px; }

/* --- Carte d'invitation dans un message --- */
.invite-card {
  border: 1px solid rgba(16,163,127,.35); border-radius: 12px; padding: 16px 18px;
  margin: 0 0 20px; background: rgba(16,163,127,.05);
}
.invite-card h3 { margin: 0 0 4px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.invite-when { color: var(--t-secondary); font-size: 13.5px; margin: 0 0 2px; text-transform: capitalize; }
.invite-meta { color: var(--t-dim); font-size: 12.5px; margin: 0; }
.invite-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.invite-actions button {
  padding: 8px 18px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-primary); cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--t-secondary);
}
.invite-actions button:hover { border-color: var(--border-hov); }
.invite-actions button.chosen { background: var(--green); border-color: var(--green); color: #fff; }
.invite-status { margin: 12px 0 0; font-size: 12.5px; color: var(--t-muted); }

.list-head {
  flex-shrink: 0; padding: 14px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: baseline; gap: 10px; font-weight: 700;
}
.list-count { font-weight: 500; color: var(--t-dim); font-size: 12.5px; }
.threads { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }

/* Une ligne = un message, comme dans un vrai client de courrier.
   Expéditeur, objet, aperçu, date : tout sur la même ligne. */
.threads li {
  display: flex; align-items: center; gap: 18px; overflow: hidden;
  padding: 0 24px; min-height: 42px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.threads li:hover { background: var(--bg-secondary); }
.threads li.unread { background: var(--bg-primary); }
.threads li.unread .th-from, .threads li.unread .th-subject { font-weight: 700; color: var(--t-primary); }
.th-from {
  width: 210px; flex-shrink: 0; font-size: 13.5px; color: var(--t-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.th-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.th-subject { font-size: 13.5px; color: var(--t-primary); white-space: nowrap; flex-shrink: 0; max-width: 52%; overflow: hidden; text-overflow: ellipsis; }
.th-preview { flex: 1; min-width: 0; font-size: 13px; color: var(--t-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-preview::before { content: '— '; }
.th-date { width: 86px; flex-shrink: 0; text-align: right; font-size: 12px; color: var(--t-dim); white-space: nowrap; }
.th-tags { display: flex; gap: 6px; flex-shrink: 0; }
.tag {
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-tertiary); color: var(--t-muted);
}
.tag.cat { background: rgba(92,124,250,.13); color: var(--indigo-d); }
.tag.prio-haute { background: rgba(204,63,63,.11); color: var(--red); }
.tag.prio-basse { background: var(--bg-tertiary); color: var(--t-dim); }
.tag.star { background: rgba(183,110,0,.13); color: var(--amber); }
.empty { text-align: center; color: var(--t-dim); padding: 40px 20px; }

/* ---------------- Lecture ---------------- */
.read-placeholder { display: none; }
.read { padding: 0 0 60px; }

/* Barre d'outils : des icônes, comme dans un vrai client de mail. */
.read-toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 2px; padding: 8px 16px;
  border-bottom: 1px solid var(--border); background: var(--bg-primary);
  overflow-x: auto; scrollbar-width: none;
}
.read-toolbar::-webkit-scrollbar { display: none; }
.read-toolbar .sep { width: 1px; height: 22px; background: var(--border); margin: 0 8px; }
.read-toolbar .spacer { flex: 1; }
.crea-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px;
  border-radius: 999px; border: 1px solid rgba(92,124,250,.35);
  background: rgba(92,124,250,.08); color: var(--indigo-d);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.crea-btn:hover { background: rgba(92,124,250,.16); }
.crea-btn:disabled { opacity: .55; cursor: progress; }

.read-body { padding: 26px 40px 0; max-width: 1000px; }
.read h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.012em; font-weight: 600; }
.read-meta { color: var(--t-dim); font-size: 12.5px; margin-bottom: 22px; }

.msg { border-top: 1px solid var(--border); padding: 20px 0; }
.msg:first-of-type { border-top: none; padding-top: 4px; }
.msg-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.msg-avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg-tertiary); color: var(--t-secondary); font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.msg-ident { min-width: 0; }
.msg-from { font-weight: 600; }
.msg-addr { color: var(--t-dim); font-size: 12.5px; margin-left: 6px; }
.msg-to { display: block; color: var(--t-dim); font-size: 12px; }
.msg-date { margin-left: auto; color: var(--t-dim); font-size: 12.5px; white-space: nowrap; }
.msg-body { white-space: pre-wrap; word-break: break-word; color: var(--t-secondary); }
.attachments { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.attachment {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--t-secondary);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 13px; background: var(--bg-secondary);
}
.reply-bar { display: flex; gap: 10px; margin-top: 24px; }
.reply-bar button {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 20px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg-primary);
  cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--t-secondary);
}
.reply-bar button:hover { background: var(--bg-secondary); border-color: var(--border-hov); }

/* Panneau IA */
.ai-panel {
  border: 1px solid rgba(92,124,250,.28); border-radius: 12px; padding: 15px 17px; margin: 18px 0 4px;
  background: linear-gradient(135deg, rgba(16,163,127,.045), rgba(92,124,250,.06));
}
.ai-panel h3 { margin: 0 0 8px; font-size: 12.5px; display: flex; align-items: center; gap: 8px; color: var(--indigo-d); }
.ai-panel .ai-body { white-space: pre-wrap; color: var(--t-secondary); font-size: 13.5px; }
.ai-source {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 999px; margin-left: auto;
}
.ai-source[data-source="crea"] { background: rgba(16,163,127,.15); color: var(--green-d); }
.ai-source[data-source="heuristique"] { background: rgba(183,110,0,.15); color: var(--amber); }
.ai-degraded { font-size: 11.5px; color: var(--amber); margin: 8px 0 0; }
.ai-list { margin: 8px 0 0; padding-left: 18px; color: var(--t-secondary); font-size: 13.5px; }

/* ---------------- Rédaction ---------------- */
.composer {
  position: fixed; right: 24px; bottom: 0; width: min(620px, calc(100vw - 48px));
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: 14px 14px 0 0; box-shadow: 0 -10px 44px -14px rgba(16,24,40,.34);
  z-index: 60; display: flex; flex-direction: column; overflow: hidden;
}
.composer header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; background: var(--bg-secondary); border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 13.5px;
}
.composer form { display: flex; flex-direction: column; }
.composer input, .composer textarea {
  border: none; border-bottom: 1px solid var(--border); padding: 11px 16px;
  outline: none; background: none; resize: none;
}
.composer textarea { border-bottom: none; font-family: inherit; }
/* La ligne « À » porte le dépliant Cc/Cci : un bouton discret, à
   droite, qui ne prend pas de hauteur tant qu'on ne s'en sert pas. */
.composer-de {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--t-muted);
}
.composer-de select {
  flex: 1; border: none; background: none; font: inherit;
  font-size: 13.5px; color: var(--t-primary); outline: none; cursor: pointer;
}
/* Un avertissement, pas une alarme : l'adresse écartée mérite une
   phrase lisible au-dessus de la rédaction, pas un bandeau rouge qui
   ferait croire à une panne. */
.composer-avertissement {
  margin: 0; padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--warn-bg, #fff8e6);
  color: var(--warn-fg, #7a5a00);
  font-size: 12.5px; line-height: 1.45;
}
/* Les fichiers joints. Une ligne par fichier, le nom tronqué plutôt
   que la mise en page cassée — un nom de trente caractères ne doit
   pas repousser le poids hors de l'écran. */
.pieces { list-style: none; margin: 0; padding: 6px 16px 10px; display: grid; gap: 5px; }
.piece {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg-secondary); font-size: 12.5px;
}
.piece-nom {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--t-primary);
}
.piece-poids { color: var(--t-muted); font-variant-numeric: tabular-nums; }
.piece-retirer {
  border: none; background: none; cursor: pointer; padding: 0 2px;
  color: var(--t-muted); font-size: 17px; line-height: 1;
}
.piece-retirer:hover { color: var(--t-primary); }
.piece-total { color: var(--t-muted); font-size: 11.5px; padding-left: 2px; }

/* Pendant un glisser-déposer : de quoi voir que le fichier tombera
   bien ici, sans déplacer quoi que ce soit — un cadre qui apparaît
   et pousse le texte fait sauter la rédaction sous le curseur. */
.composer-form.depot-actif,
#composer-form.depot-actif { outline: 2px dashed var(--indigo); outline-offset: -6px; }

.composer-to { display: flex; align-items: center; border-bottom: 1px solid var(--border); }
.composer-to input { flex: 1; border-bottom: none; }
.link-btn {
  border: none; background: none; cursor: pointer; padding: 0 16px;
  color: var(--t-muted); font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.link-btn:hover { color: var(--t-primary); }
.composer-ai { display: flex; gap: 8px; padding: 10px 16px; background: var(--bg-secondary); border-top: 1px solid var(--border); }
.composer-ai input {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; background: var(--bg-primary);
}
.composer footer { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.composer-status { font-size: 12.5px; color: var(--t-muted); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--t-primary); color: #fff; padding: 11px 20px; border-radius: 8px;
  font-size: 13px; z-index: 80; box-shadow: 0 10px 34px -10px rgba(0,0,0,.55);
}
.toast[data-tone="error"] { background: var(--red); }

/* ---------------- Écrans étroits ---------------- */
@media (max-width: 900px) {
  /* Sous 900 px l'objet et l'aperçu ne tiennent plus sur la même
     ligne que l'expéditeur : on repasse en deux lignes. */
  .threads li { flex-wrap: wrap; padding: 9px 18px; gap: 4px 12px; }
  .th-from { width: auto; flex: 1; }
  .th-main { flex-basis: 100%; }
  .th-subject { max-width: none; }
  .read-body { padding: 20px 20px 0; }
  .read-toolbar { padding: 8px 10px; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .app.nav-open .sidebar {
    display: flex; position: absolute; inset: var(--topbar-h) auto 0 0; width: 262px;
    z-index: 40; background: var(--bg-app); box-shadow: var(--shadow-pop);
  }
  .kind-switch { display: none; }
  .brand { display: none; }
}

/* --- Mises à jour de l'application de bureau ------------------
   Dans le pop-over du profil, sous le quota : c'est là qu'on va
   quand on cherche « quelque chose sur mon application ». */
.maj {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  display: grid; gap: 8px;
}
.maj-tete { display: flex; align-items: baseline; gap: 8px; }
.maj-titre { font-size: 12.5px; font-weight: 650; color: var(--t-primary); }
.maj-version {
  font-size: 11.5px; color: var(--t-dim); margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.maj-etat { margin: 0; font-size: 12.5px; color: var(--t-muted); line-height: 1.45; }
.maj-etat.erreur { color: var(--red); }
.maj-actions { display: flex; gap: 8px; }
.maj-actions .btn { padding: 5px 12px; font-size: 12.5px; }
.maj-auto {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--t-secondary); cursor: pointer;
}
.maj-auto input { accent-color: var(--green); }
