/* ═══════════════════════════════════════════════════════════════════════════
   ElectroCAD — Messagerie admin v11 « EMX » (2026-07-15)
   Namespace .emx / emx-* — totalement indépendant d'admin-email-v10.css.
   Thème sombre par défaut, override [data-theme="light"] (palette ivoire site).
   Responsive : ≥1200 (3 volets) · 900–1199 (rail icônes) · <900 (1 vue).
   ═══════════════════════════════════════════════════════════════════════════ */

.emx {
    /* tokens locaux */
    --x-bg: #0C0C0E;
    --x-bg2: #131316;
    --x-panel: #17171B;
    --x-panel2: #1D1D22;
    --x-line: rgba(255, 255, 255, 0.07);
    --x-line2: rgba(255, 255, 255, 0.13);
    --x-text: #EDEDEF;
    --x-text2: #A1A1AA;
    --x-text3: #6E6E78;
    --x-red: #DC2626;
    --x-red-h: #EF4444;
    --x-red-soft: rgba(220, 38, 38, 0.12);
    --x-red-line: rgba(220, 38, 38, 0.4);
    --x-hover: rgba(255, 255, 255, 0.045);
    --x-active: rgba(220, 38, 38, 0.10);
    --x-green: #16A34A;
    --x-amber: #F59E0B;
    --x-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
    --x-radius: 14px;

    display: grid;
    grid-template-columns: 246px 400px 1fr;
    height: calc(100vh - 210px);
    min-height: 540px;
    background: var(--x-bg);
    border: 1px solid var(--x-line);
    border-radius: var(--x-radius);
    overflow: hidden;
    color: var(--x-text);
    position: relative;
    font-size: 0.92rem;
}
[data-theme="light"] .emx {
    --x-bg: #FAF7EE;
    --x-bg2: #F5F1E8;
    --x-panel: #FFFEF8;
    --x-panel2: #FFFFFF;
    --x-line: rgba(20, 18, 12, 0.09);
    --x-line2: rgba(20, 18, 12, 0.18);
    --x-text: #1A1A1F;
    --x-text2: #6F6E6A;
    --x-text3: #918D84;
    --x-red-soft: rgba(220, 38, 38, 0.09);
    --x-hover: rgba(20, 18, 12, 0.045);
    --x-active: rgba(220, 38, 38, 0.08);
    --x-shadow: 0 18px 50px rgba(60, 50, 30, 0.18);
}

.emx *, .emx *::before, .emx *::after { box-sizing: border-box; }
.emx button { font-family: inherit; }

/* Le conteneur admin peut être plus étroit que le viewport → paliers sur la largeur RÉELLE,
   posés en classes .emx-cw-* par un ResizeObserver (PAS de container-type : le containment
   ferait du wrapper le référentiel du position:fixed → plein écran cassé). */

/* Pas de sélection de texte parasite au clic dans la navigation / liste / barres d'outils
   (le corps du message et les champs de saisie restent sélectionnables) */
.emx-nav, .emx-list, .emx-read-bar, .emx-qr, .emx-pager {
    user-select: none;
    -webkit-user-select: none;
}
.emx input, .emx textarea, .emx [contenteditable="true"] {
    user-select: text;
    -webkit-user-select: text;
}

/* ─── Boutons génériques ─────────────────────────────────────────────── */
.emx-btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 14px; border-radius: 9px;
    border: 1px solid var(--x-line2); background: transparent;
    color: var(--x-text); font-size: 0.85rem; font-weight: 500;
    cursor: pointer; transition: background .14s, border-color .14s, transform .08s;
    white-space: nowrap;
}
.emx-btn:hover { background: var(--x-hover); }
.emx-btn:active { transform: scale(.97); }
.emx-btn-pri { background: var(--x-red); border-color: var(--x-red); color: #fff; }
.emx-btn-pri:hover { background: var(--x-red-h); border-color: var(--x-red-h); }
.emx-btn-gh { border-color: transparent; color: var(--x-text2); }
.emx-btn[disabled] { opacity: .5; cursor: default; }
.emx-ic-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; min-width: 38px; border-radius: 9px;
    border: none; background: transparent; color: var(--x-text2);
    font-size: 0.95rem; cursor: pointer; transition: background .14s, color .14s;
}
.emx-ic-btn:hover { background: var(--x-hover); color: var(--x-text); }
.emx-ic-btn[disabled] { opacity: .35; cursor: default; }
.emx-ic-btn[disabled]:hover { background: transparent; }
.emx-danger { color: #F87171 !important; }
.emx-danger:hover { background: rgba(220, 38, 38, 0.12) !important; }
[data-theme="light"] .emx-danger { color: #B91C1C !important; }

/* ─── Colonne 1 : navigation dossiers ────────────────────────────────── */
.emx-nav {
    display: flex; flex-direction: column;
    background: var(--x-bg2);
    border-right: 1px solid var(--x-line);
    padding: 16px 12px;
    gap: 2px;
    overflow-y: auto;
}
.emx-brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 14px; }
.emx-brand-ic {
    width: 38px; height: 38px; border-radius: 11px; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--x-red) 0%, #991B1B 100%);
    color: #fff; font-size: 1rem;
    box-shadow: 0 6px 18px rgba(220, 38, 38, 0.35);
}
.emx-brand-tx { display: flex; flex-direction: column; min-width: 0; }
.emx-brand-tx strong { font-size: 0.95rem; letter-spacing: -0.01em; }
.emx-brand-tx span { font-size: 0.72rem; color: var(--x-text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.emx-cta {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 11px 12px; margin-bottom: 14px;
    border: none; border-radius: 10px;
    background: var(--x-red); color: #fff;
    font-size: 0.88rem; font-weight: 600; cursor: pointer;
    transition: background .14s, transform .08s;
    box-shadow: 0 8px 22px rgba(220, 38, 38, 0.28);
}
.emx-cta:hover { background: var(--x-red-h); }
.emx-cta:active { transform: scale(.98); }

.emx-nav-sec {
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.09em;
    text-transform: uppercase; color: var(--x-text3);
    padding: 6px 8px 6px;
}
.emx-folders { display: flex; flex-direction: column; gap: 1px; }
.emx-nav-item {
    display: flex; align-items: center; gap: 11px;
    width: 100%; padding: 9px 10px; border: none; border-radius: 9px;
    background: transparent; color: var(--x-text2);
    font-size: 0.87rem; cursor: pointer; text-align: left;
    transition: background .13s, color .13s;
    position: relative;
}
.emx-nav-item i { width: 18px; text-align: center; font-size: 0.88rem; flex: 0 0 auto; }
.emx-nav-item span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emx-nav-item:hover { background: var(--x-hover); color: var(--x-text); }
.emx-nav-item.active { background: var(--x-active); color: var(--x-text); font-weight: 600; }
.emx-nav-item.active::before {
    content: ''; position: absolute; left: -12px; top: 20%; bottom: 20%;
    width: 3px; border-radius: 0 3px 3px 0; background: var(--x-red);
}
.emx-nav-item.active i { color: var(--x-red); }
.emx-badge {
    background: var(--x-red); color: #fff; font-size: 0.68rem; font-weight: 700;
    min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
}
.emx-badge-mut { background: var(--x-line2); color: var(--x-text2); }
.emx-nav-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--x-line); display: flex; flex-direction: column; gap: 1px; }
.emx-nav-scrim { display: none; }

/* ─── Colonne 2 : liste ──────────────────────────────────────────────── */
.emx-list {
    display: flex; flex-direction: column;
    border-right: 1px solid var(--x-line);
    background: var(--x-bg);
    min-width: 0;
    overflow: hidden;
}
.emx-list-head {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 12px 8px;
}
.emx-list-title-w { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.emx-list-title { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.015em; white-space: nowrap; }
.emx-list-count { font-size: 0.75rem; color: var(--x-text3); white-space: nowrap; }
.emx-search {
    flex: 1; display: flex; align-items: center; gap: 8px;
    min-width: 90px; padding: 0 10px; height: 38px;
    background: var(--x-bg2); border: 1px solid var(--x-line);
    border-radius: 10px; transition: border-color .15s;
}
.emx-search:focus-within { border-color: var(--x-red-line); }
.emx-search i { color: var(--x-text3); font-size: 0.8rem; flex: 0 0 auto; }
.emx-search input {
    flex: 1; min-width: 0; border: none; background: transparent; outline: none;
    color: var(--x-text); font-size: 0.85rem; font-family: inherit;
}
.emx-search input::placeholder { color: var(--x-text3); }
.emx-search-x {
    display: flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border: none; border-radius: 6px;
    background: var(--x-line2); color: var(--x-text2); cursor: pointer; font-size: 0.7rem;
}

.emx-filters { display: flex; gap: 4px; padding: 0 12px 10px; overflow-x: auto; scrollbar-width: none; }
.emx-filters::-webkit-scrollbar { display: none; }
.emx-filter {
    padding: 6px 12px; border-radius: 999px; border: 1px solid var(--x-line);
    background: transparent; color: var(--x-text2); font-size: 0.78rem; font-weight: 500;
    cursor: pointer; white-space: nowrap; transition: all .13s;
    display: inline-flex; align-items: center; gap: 5px;
}
.emx-filter i { font-size: 0.68rem; }
.emx-filter:hover { background: var(--x-hover); color: var(--x-text); }
.emx-filter.active { background: var(--x-red-soft); border-color: var(--x-red-line); color: var(--x-red-h); font-weight: 600; }
[data-theme="light"] .emx-filter.active { color: #B91C1C; }

.emx-bulk {
    display: flex; align-items: center; gap: 4px;
    margin: 0 12px 10px; padding: 4px 6px;
    background: var(--x-red-soft); border: 1px solid var(--x-red-line);
    border-radius: 10px;
    animation: emx-pop .16s ease;
}
@keyframes emx-pop { from { opacity: 0; transform: translateY(-4px); } }
.emx-bulk-n { font-size: 0.8rem; font-weight: 600; flex: 1; }
.emx-bulk-actions { display: flex; gap: 2px; }
.emx-bulk .emx-ic-btn { width: 34px; height: 34px; min-width: 34px; }

/* items */
.emx-items { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 8px; }
.emx-group {
    position: sticky; top: 0; z-index: 2;
    padding: 7px 16px 5px;
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
    color: var(--x-text3);
    background: linear-gradient(var(--x-bg) 78%, transparent);
    backdrop-filter: blur(3px);
}
.emx-item {
    position: relative; overflow: hidden;
    border-bottom: 1px solid var(--x-line);
    cursor: pointer;
    outline: none;
}
.emx-item:focus-visible .emx-item-main { background: var(--x-hover); box-shadow: inset 0 0 0 2px var(--x-red-line); }
.emx-item-main {
    position: relative; z-index: 1;
    display: flex; gap: 10px; align-items: flex-start;
    padding: 11px 12px 11px 14px;
    background: var(--x-bg);
    transition: background .12s;
}
.emx-item:hover .emx-item-main { background: var(--x-hover); }
.emx-item.selected .emx-item-main { background: var(--x-active); }
.emx-item.selected { box-shadow: inset 3px 0 0 var(--x-red); }
.emx-item.checked .emx-item-main { background: var(--x-red-soft); }

/* rail non lu */
.emx-item.unread .emx-item-main::before {
    content: ''; position: absolute; left: 5px; top: 50%;
    width: 7px; height: 7px; margin-top: -4px; border-radius: 50%;
    background: var(--x-red);
}
.emx-item.unread .emx-item-from,
.emx-item.unread .emx-item-subj { font-weight: 700; color: var(--x-text); }
.emx-item.unread .emx-item-date { color: var(--x-red-h); font-weight: 600; }
[data-theme="light"] .emx-item.unread .emx-item-date { color: #B91C1C; }

/* avatar + checkbox superposés */
.emx-av-w { position: relative; flex: 0 0 auto; width: 40px; height: 40px; }
.emx-av {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 0.82rem; font-weight: 700; letter-spacing: 0.02em;
    user-select: none;
}
.emx-av-lg { width: 46px; height: 46px; font-size: 0.95rem; }
.emx-av-sm { width: 28px; height: 28px; font-size: 0.65rem; }
.emx-check {
    position: absolute; inset: 0; border-radius: 50%;
    display: none; align-items: center; justify-content: center;
    background: var(--x-panel2); border: 2px solid var(--x-line2);
    cursor: pointer;
}
.emx-check input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.emx-check span {
    width: 16px; height: 16px; border-radius: 4px;
    border: 2px solid var(--x-text3);
    display: block; position: relative; transition: all .12s;
}
.emx-check input:checked + span { background: var(--x-red); border-color: var(--x-red); }
.emx-check input:checked + span::after {
    content: ''; position: absolute; left: 3.5px; top: 0.5px;
    width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
@media (hover: hover) {
    .emx-item:hover .emx-check { display: flex; }
}
.emx-items.selecting .emx-check { display: flex; }

.emx-item-body { flex: 1; min-width: 0; }
.emx-item-l1 { display: flex; align-items: baseline; gap: 8px; }
.emx-item-from {
    flex: 1; min-width: 0; font-size: 0.88rem; font-weight: 500; color: var(--x-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.emx-item-date { font-size: 0.72rem; color: var(--x-text3); white-space: nowrap; }
.emx-item-l2 { display: flex; align-items: center; gap: 6px; margin-top: 1px; }
.emx-item-subj {
    flex: 1; min-width: 0; font-size: 0.83rem; color: var(--x-text2);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.emx-item-tags { display: inline-flex; gap: 6px; color: var(--x-text3); font-size: 0.72rem; flex: 0 0 auto; }
.emx-star-on { color: var(--x-amber) !important; }
.emx-item-l3 {
    margin-top: 2px; font-size: 0.78rem; color: var(--x-text3);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* actions au survol (desktop) */
.emx-hover-acts {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    display: none; gap: 2px; z-index: 2;
    background: var(--x-panel2); border: 1px solid var(--x-line2);
    border-radius: 10px; padding: 3px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.emx-ha {
    width: 32px; height: 32px; border: none; border-radius: 7px;
    background: transparent; color: var(--x-text2); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 0.82rem;
    transition: background .12s, color .12s;
}
.emx-ha:hover { background: var(--x-hover); color: var(--x-text); }
@media (hover: hover) and (min-width: 900px) {
    .emx-item:hover .emx-hover-acts { display: flex; }
    .emx-item:hover .emx-item-date { visibility: hidden; }
}

/* fonds de swipe mobile */
.emx-sw {
    position: absolute; top: 0; bottom: 0; width: 50%;
    display: flex; align-items: center; color: #fff; font-size: 1.15rem;
    opacity: 0; transition: opacity .1s;
}
.emx-sw-r { left: 0; justify-content: flex-start; padding-left: 22px; background: var(--x-green); }
.emx-sw-l { right: 0; justify-content: flex-end; padding-right: 22px; background: var(--x-red); }
.emx-item.sw-right .emx-sw-r { opacity: 1; }
.emx-item.sw-left .emx-sw-l { opacity: 1; }

/* squelettes / vides */
.emx-skel { display: flex; gap: 10px; padding: 13px 14px; border-bottom: 1px solid var(--x-line); }
.emx-skel-av { width: 40px; height: 40px; border-radius: 50%; background: var(--x-line); animation: emx-sh 1.2s infinite; }
.emx-skel-l { flex: 1; display: flex; flex-direction: column; gap: 7px; padding-top: 3px; }
.emx-skel-b { height: 10px; border-radius: 5px; background: var(--x-line); animation: emx-sh 1.2s infinite; }
@keyframes emx-sh { 50% { opacity: 0.45; } }
.emx-void {
    padding: 48px 20px; text-align: center; color: var(--x-text3);
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.emx-void i { font-size: 2.1rem; opacity: 0.5; }
.emx-void p { margin: 0; font-size: 0.88rem; }

.emx-pager {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 8px; border-top: 1px solid var(--x-line);
    font-size: 0.78rem; color: var(--x-text3);
}

/* ─── Colonne 3 : lecture ────────────────────────────────────────────── */
.emx-read { background: var(--x-panel); min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
.emx-empty {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; color: var(--x-text3); padding: 30px;
}
.emx-empty-ic {
    width: 76px; height: 76px; border-radius: 24px;
    display: flex; align-items: center; justify-content: center;
    background: var(--x-bg2); border: 1px solid var(--x-line);
    font-size: 1.8rem; color: var(--x-text3);
}
.emx-empty p { margin: 0; font-size: 0.92rem; }
.emx-empty-kbd { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; font-size: 0.75rem; margin-top: 6px; }
.emx-empty-kbd kbd, .emx-kbd kbd {
    display: inline-block; padding: 1px 6px; border-radius: 5px;
    background: var(--x-bg2, #1a1a1e); border: 1px solid var(--x-line2, #333);
    font-family: ui-monospace, monospace; font-size: 0.72rem;
}
.emx-read-loading { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; color: var(--x-text3); }

.emx-read-in { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.emx-read-bar {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; border-bottom: 1px solid var(--x-line);
    background: var(--x-panel);
    flex-wrap: wrap;
}
.emx-read-acts { display: flex; gap: 6px; }
.emx-read-tools { display: flex; gap: 2px; margin-left: auto; align-items: center; }
.emx-read-nav { display: inline-flex; gap: 2px; margin-left: 6px; padding-left: 8px; border-left: 1px solid var(--x-line); }

.emx-read-scroll { flex: 1; overflow-y: auto; padding: 18px 22px 26px; }
.emx-read-subj { margin: 0 0 14px; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.015em; line-height: 1.3; overflow-wrap: anywhere; }
.emx-read-meta { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
/* min-width : si la place manque, la date passe à la ligne au lieu d'écraser l'expéditeur
   (sinon le nom se retrouve à ~0px de large → une lettre par ligne) */
.emx-read-who { flex: 1; min-width: min(230px, 100%); }
.emx-read-from { font-size: 0.92rem; overflow-wrap: anywhere; }
.emx-read-addr { color: var(--x-text3); font-size: 0.8rem; }
.emx-read-dst {
    display: block; max-width: 100%; margin-top: 2px;
    border: none; background: none; padding: 0;
    color: var(--x-text3); font-size: 0.78rem; cursor: pointer; text-align: left;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.emx-read-dst i { font-size: 0.6rem; }
.emx-read-dst-full { margin-top: 4px; font-size: 0.8rem; color: var(--x-text2); }
.emx-read-dst-full span { color: var(--x-text3); }
.emx-read-date { font-size: 0.78rem; color: var(--x-text3); padding-top: 4px; }

.emx-atts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.emx-att {
    display: inline-flex; align-items: center; gap: 9px;
    padding: 8px 12px; max-width: 260px;
    background: var(--x-bg2); border: 1px solid var(--x-line);
    border-radius: 10px; cursor: pointer; color: var(--x-text);
    transition: border-color .13s, background .13s;
}
.emx-att:hover { border-color: var(--x-red-line); background: var(--x-red-soft); }
.emx-att > i:first-child { font-size: 1.15rem; color: var(--x-red-h); }
[data-theme="light"] .emx-att > i:first-child { color: #B91C1C; }
.emx-att-n { font-size: 0.8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.emx-att-s { font-size: 0.7rem; color: var(--x-text3); }
.emx-att-dl { font-size: 0.7rem; opacity: 0.5; }

.emx-read-body { border-radius: 10px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18); }

.emx-qr { padding: 10px 14px; border-top: 1px solid var(--x-line); background: var(--x-panel); }
.emx-qr-hint {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 11px 14px; border-radius: 999px;
    border: 1px solid var(--x-line2); background: var(--x-bg2);
    color: var(--x-text3); font-size: 0.85rem; cursor: text; text-align: left;
    transition: border-color .13s;
}
.emx-qr-hint:hover { border-color: var(--x-red-line); color: var(--x-text2); }

/* ─── Composer ───────────────────────────────────────────────────────── */
.emx-comp { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.emx-comp-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-bottom: 1px solid var(--x-line);
}
.emx-comp-title { font-weight: 700; font-size: 0.98rem; display: inline-flex; gap: 9px; align-items: center; }
.emx-comp-title i { color: var(--x-red); }
.emx-comp-save { flex: 1; text-align: right; font-size: 0.74rem; color: var(--x-text3); padding-right: 6px; }
.emx-comp-save.saved { color: var(--x-green); }
.emx-comp-send { margin-left: auto; }
.emx-comp-save + .emx-comp-send { margin-left: 0; }

.emx-comp-scroll { flex: 1; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.emx-comp-ctx {
    padding: 10px 14px; border-radius: 10px;
    background: var(--x-bg2); border: 1px solid var(--x-line);
    font-size: 0.85rem; color: var(--x-text2);
}
.emx-comp-ctx i { margin-right: 6px; color: var(--x-red); }
.emx-comp-ctx-s { margin-top: 3px; font-weight: 600; color: var(--x-text); font-size: 0.88rem; overflow-wrap: anywhere; }

.emx-field { display: flex; align-items: flex-start; gap: 10px; }
.emx-field > label {
    flex: 0 0 34px; padding-top: 11px;
    font-size: 0.78rem; font-weight: 600; color: var(--x-text3);
}
.emx-chips {
    flex: 1; display: flex; flex-wrap: wrap; gap: 5px; align-items: center;
    min-height: 42px; padding: 5px 8px;
    background: var(--x-bg2); border: 1px solid var(--x-line); border-radius: 9px;
    cursor: text; transition: border-color .14s;
}
.emx-chips:focus-within { border-color: var(--x-red-line); }
.emx-chips input {
    flex: 1; min-width: 120px; border: none; background: transparent; outline: none;
    color: var(--x-text); font-size: 0.87rem; font-family: inherit; padding: 5px 4px;
}
.emx-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 6px 4px 10px; border-radius: 999px;
    background: var(--x-panel2); border: 1px solid var(--x-line2);
    font-size: 0.8rem; max-width: 100%;
}
.emx-chip > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 210px; }
.emx-chip button {
    width: 18px; height: 18px; border: none; border-radius: 50%;
    background: var(--x-line2); color: var(--x-text2);
    font-size: 0.78rem; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.emx-chip button:hover { background: var(--x-red); color: #fff; }
.emx-ccbcc {
    align-self: center; border: none; background: none;
    color: var(--x-text3); font-size: 0.78rem; cursor: pointer; padding: 6px;
    white-space: nowrap;
}
.emx-ccbcc:hover { color: var(--x-red-h); }
.emx-subj {
    flex: 1; height: 42px; padding: 0 12px;
    background: var(--x-bg2); border: 1px solid var(--x-line); border-radius: 9px;
    color: var(--x-text); font-size: 0.92rem; font-weight: 600; font-family: inherit;
    outline: none; transition: border-color .14s; min-width: 0;
}
.emx-subj:focus { border-color: var(--x-red-line); }
.emx-subj::placeholder { font-weight: 400; color: var(--x-text3); }

/* barre d'outils */
.emx-tb {
    display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
    padding: 5px 7px;
    background: var(--x-bg2); border: 1px solid var(--x-line);
    border-radius: 9px 9px 0 0; border-bottom: none;
    position: sticky; top: 0; z-index: 3;
}
.emx-tb-b {
    width: 32px; height: 32px; border: none; border-radius: 7px;
    background: transparent; color: var(--x-text2); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 0.8rem;
}
.emx-tb-b:hover { background: var(--x-hover); color: var(--x-text); }
.emx-tb-sep { width: 1px; height: 18px; background: var(--x-line2); margin: 0 4px; flex: 0 0 auto; }
.emx-tb-sel {
    height: 30px; padding: 0 6px; border-radius: 7px;
    background: transparent; border: 1px solid var(--x-line2);
    color: var(--x-text2); font-size: 0.75rem; font-family: inherit;
    width: 84px; flex: 0 0 auto; cursor: pointer;
}
.emx-tb-sel option { background: var(--x-panel2); color: var(--x-text); }
.emx-tb-c {
    width: 30px; height: 30px; padding: 3px; border: 1px solid var(--x-line2);
    border-radius: 7px; background: transparent; cursor: pointer;
}

/* Éditeur toujours blanc : WYSIWYG fidèle au rendu email (et signature lisible) */
.emx-body {
    min-height: 240px; flex: 1;
    padding: 14px 16px;
    background: #ffffff; border: 1px solid var(--x-line);
    border-radius: 0 0 9px 9px;
    color: #1a1a1a; font-size: 0.92rem; line-height: 1.65;
    outline: none; overflow-y: auto; overflow-wrap: anywhere;
    caret-color: #1a1a1a;
}
.emx-body:focus { border-color: var(--x-red-line); }
.emx-body.dnd { border-color: var(--x-red); box-shadow: inset 0 0 0 2px var(--x-red-soft); }
.emx-body img { max-width: 100%; height: auto; }
.emx-body a { color: #B91C1C; }
.emx-sig-body { min-height: 160px; flex: 0 0 auto; border-radius: 0 0 9px 9px; }

.emx-comp-att { display: flex; flex-wrap: wrap; gap: 6px; }
.emx-attchip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 8px 6px 10px; border-radius: 9px;
    background: var(--x-bg2); border: 1px solid var(--x-line);
    font-size: 0.78rem;
}
.emx-attchip > i { color: var(--x-red-h); }
[data-theme="light"] .emx-attchip > i { color: #B91C1C; }
.emx-attchip-n { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.emx-attchip-s { color: var(--x-text3); font-size: 0.7rem; }
.emx-attchip button {
    width: 18px; height: 18px; border: none; border-radius: 50%;
    background: var(--x-line2); color: var(--x-text2); cursor: pointer;
    font-size: 0.8rem; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.emx-attchip button:hover { background: var(--x-red); color: #fff; }
.emx-comp-note { font-size: 0.76rem; color: var(--x-text3); }
.emx-comp-note i { margin-right: 5px; }

.emx-comp-foot {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 14px; border-top: 1px solid var(--x-line);
    background: var(--x-panel);
}
.emx-comp-from { margin-left: auto; font-size: 0.72rem; color: var(--x-text3); white-space: nowrap; }

/* autocomplete destinataires */
.emx-suggest {
    position: absolute; z-index: 60; min-width: 260px; max-width: 340px;
    background: var(--x-panel2); border: 1px solid var(--x-line2);
    border-radius: 11px; box-shadow: var(--x-shadow);
    overflow: hidden; padding: 4px;
}
.emx-sg {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 7px 9px; border: none; border-radius: 8px;
    background: transparent; cursor: pointer; text-align: left;
    color: var(--x-text);
}
.emx-sg:hover, .emx-sg.active { background: var(--x-red-soft); }
.emx-sg-t { display: flex; flex-direction: column; min-width: 0; font-size: 0.82rem; }
.emx-sg-t strong { font-weight: 600; }
.emx-sg-t span { color: var(--x-text3); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* mini-modal lien */
.emx-linkbox {
    position: fixed; inset: 0; z-index: 12000;
    background: rgba(0, 0, 0, 0.55);
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.emx-linkbox-in {
    width: 380px; max-width: 100%;
    background: var(--x-panel2, #1D1D22); border: 1px solid var(--x-line2, #333);
    border-radius: 13px; padding: 16px; box-shadow: var(--x-shadow, 0 18px 60px rgba(0,0,0,.5));
    display: flex; flex-direction: column; gap: 10px;
}
[data-theme="light"] .emx-linkbox-in { background: #FFFEF8; border-color: rgba(20,18,12,.18); }
.emx-linkbox-in label { font-size: 0.8rem; font-weight: 600; color: var(--x-text2, #aaa); }
.emx-linkbox-in input {
    height: 40px; padding: 0 12px; border-radius: 9px;
    border: 1px solid var(--x-line2, #333); background: var(--x-bg2, #131316);
    color: var(--x-text, #eee); font-size: 0.88rem; outline: none; font-family: inherit;
}
[data-theme="light"] .emx-linkbox-in input { background: #F5F1E8; color: #1A1A1F; }
.emx-linkbox-b { display: flex; justify-content: flex-end; gap: 8px; }

/* ─── Menus contextuels ──────────────────────────────────────────────── */
.emx-menu {
    position: fixed; z-index: 11000; min-width: 210px;
    background: var(--x-panel2, #1D1D22); border: 1px solid var(--x-line2, #333);
    border-radius: 12px; padding: 5px; box-shadow: var(--x-shadow, 0 18px 60px rgba(0,0,0,.5));
    animation: emx-pop .13s ease;
}
[data-theme="light"] .emx-menu { background: #FFFEF8; border-color: rgba(20,18,12,.18); }
.emx-menu-it {
    display: flex; align-items: center; gap: 11px; width: 100%;
    padding: 9px 12px; border: none; border-radius: 8px;
    background: transparent; color: var(--x-text, #eee);
    font-size: 0.85rem; cursor: pointer; text-align: left; font-family: inherit;
}
[data-theme="light"] .emx-menu-it { color: #1A1A1F; }
.emx-menu-it i { width: 17px; text-align: center; font-size: 0.8rem; color: var(--x-text2, #aaa); }
.emx-menu-it:hover { background: var(--x-hover, rgba(255,255,255,.05)); }
.emx-menu-it.emx-danger i { color: inherit; }
.emx-menu-div { height: 1px; background: var(--x-line, rgba(255,255,255,.08)); margin: 4px 8px; }

/* ─── Aperçu pièce jointe ────────────────────────────────────────────── */
.emx-preview {
    position: fixed; inset: 0; z-index: 12000;
    background: rgba(0, 0, 0, 0.88);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.emx-preview-bar {
    position: absolute; top: 0; left: 0; right: 0; z-index: 1;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 18px; background: rgba(0, 0, 0, 0.55); color: #fff;
}
.emx-preview-bar span { font-size: 0.88rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emx-preview-bar > div { display: flex; gap: 8px; align-items: center; }
.emx-preview-bar .emx-ic-btn { color: #fff; }
.emx-preview img { max-width: 92vw; max-height: 84vh; object-fit: contain; border-radius: 6px; margin-top: 44px; }
.emx-preview iframe { width: 92vw; height: 84vh; border: none; border-radius: 6px; margin-top: 44px; background: #fff; }

/* ─── Aide raccourcis ────────────────────────────────────────────────── */
.emx-kbd {
    position: fixed; right: 18px; bottom: 18px; z-index: 12000;
    width: 290px; padding: 14px 16px;
    background: var(--x-panel2, #1D1D22); border: 1px solid var(--x-line2, #333);
    border-radius: 14px; box-shadow: var(--x-shadow, 0 18px 60px rgba(0,0,0,.5));
    color: var(--x-text, #eee); font-size: 0.8rem;
    opacity: 0; transform: translateY(8px); transition: all .2s ease;
}
[data-theme="light"] .emx-kbd { background: #FFFEF8; color: #1A1A1F; border-color: rgba(20,18,12,.18); }
.emx-kbd.on { opacity: 1; transform: none; }
.emx-kbd h4 { margin: 0 0 9px; font-size: 0.85rem; }
.emx-kbd > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 2.5px 0; }
.emx-kbd > div > span:last-child { color: var(--x-text2, #aaa); }

/* ─── FAB mobile ─────────────────────────────────────────────────────── */
.emx-fab {
    display: none;
    position: absolute; right: 18px; bottom: 20px; z-index: 30;
    width: 56px; height: 56px; border-radius: 18px; border: none;
    background: var(--x-red); color: #fff; font-size: 1.15rem; cursor: pointer;
    box-shadow: 0 12px 30px rgba(220, 38, 38, 0.45);
    transition: transform .1s;
}
.emx-fab:active { transform: scale(.94); }

/* helpers visibilité */
.emx-only-m { display: none !important; }

/* ═══ Palier tablette : 900–1199 px — rail d'icônes ══════════════════ */
@media (max-width: 1199px) and (min-width: 900px) {
    .emx { grid-template-columns: 64px 340px 1fr; }
    .emx-nav { padding: 14px 8px; align-items: center; }
    .emx-brand-tx, .emx-nav-sec, .emx-nav-item span, .emx-cta span { display: none; }
    .emx-cta { width: 44px; height: 44px; padding: 0; justify-content: center; margin-bottom: 10px; }
    .emx-nav-item { justify-content: center; padding: 11px 0; width: 44px; }
    .emx-nav-item.active::before { left: -8px; }
    .emx-badge {
        position: absolute; top: 3px; right: 1px;
        min-width: 16px; height: 15px; font-size: 0.6rem; padding: 0 4px;
    }
    .emx-nav-foot { align-items: center; }
    .emx-read-acts .emx-btn span { display: none; }
    .emx-read-acts .emx-btn { padding: 8px 11px; }
}

/* ═══ Palier mobile : < 900 px — une vue à la fois ═══════════════════ */
@media (max-width: 899px) {
    .emx {
        display: block;
        height: calc(100vh - 150px);
        min-height: 480px;
        border-radius: 12px;
    }
    .emx-only-m { display: inline-flex !important; }
    .emx-only-d { display: none !important; }

    /* liste = vue par défaut */
    .emx-list { position: absolute; inset: 0; border-right: none; z-index: 1; }
    .emx-list-head { flex-wrap: wrap; padding: 10px 10px 8px; }
    .emx-search { order: 5; flex-basis: 100%; margin-top: 8px; height: 42px; }
    .emx-list-title { font-size: 1.1rem; }

    /* dossiers = drawer au-dessus */
    .emx-nav {
        position: absolute; top: 0; bottom: 0; left: 0; z-index: 40;
        width: min(310px, 86%);
        border-right: 1px solid var(--x-line2);
        box-shadow: var(--x-shadow);
        transform: translateX(-102%);
        transition: transform .22s cubic-bezier(.2, .8, .25, 1);
        background: var(--x-panel);
    }
    .emx[data-mode="nav"] .emx-nav { transform: none; }
    .emx-nav-scrim {
        position: absolute; inset: 0; z-index: 35;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0; pointer-events: none; transition: opacity .2s;
    }
    .emx[data-mode="nav"] .emx-nav-scrim { display: block; opacity: 1; pointer-events: auto; }
    .emx-nav-item { padding: 13px 12px; font-size: 0.95rem; }
    .emx-cta { padding: 14px 12px; font-size: 0.95rem; }

    /* lecture / composer = plein écran par-dessus */
    .emx-read {
        position: absolute; inset: 0; z-index: 20;
        transform: translateX(103%);
        transition: transform .22s cubic-bezier(.2, .8, .25, 1);
        will-change: transform;
    }
    .emx[data-mode="read"] .emx-read,
    .emx[data-mode="compose"] .emx-read { transform: none; }

    .emx-read-scroll { padding: 14px 14px 20px; }
    .emx-read-subj { font-size: 1.1rem; }
    .emx-read-bar { padding: 8px 8px; gap: 5px; }
    .emx-read-acts .emx-btn { padding: 9px 12px; font-size: 0.82rem; }
    .emx-read-nav { display: none; }
    .emx-read-meta { flex-wrap: wrap; gap: 10px; }
    /* la date passe SOUS l'expéditeur pour ne pas l'écraser */
    .emx-read-date { flex-basis: 100%; order: 3; padding: 0 0 0 56px; margin-top: -6px; font-size: 0.72rem; }
    .emx-read-addr { overflow-wrap: anywhere; }

    /* items : cibles tactiles plus hautes */
    .emx-item-main { padding: 13px 12px; }
    .emx-hover-acts { display: none !important; }
    .emx-check { display: none; }
    .emx-items.selecting .emx-check { display: flex; }

    /* FAB visible en liste uniquement */
    .emx[data-mode="list"] .emx-fab { display: flex; align-items: center; justify-content: center; }

    /* composer mobile */
    .emx-comp-scroll { padding: 12px 12px; }
    .emx-field { flex-wrap: wrap; }
    .emx-field > label { flex-basis: 30px; padding-top: 12px; }
    .emx-chips { min-height: 44px; }
    .emx-chips input { min-width: 90px; font-size: 0.92rem; }
    .emx-subj { height: 44px; font-size: 0.95rem; }
    .emx-body { min-height: 200px; font-size: 0.95rem; }
    .emx-comp-bar .emx-comp-save { display: none; }
    .emx-comp-foot { flex-wrap: wrap; }
    .emx-comp-from { display: none; }
    .emx-kbd { display: none; }
    .emx-suggest { left: 8px !important; right: 8px; max-width: none; }
}

/* très petits écrans */
@media (max-width: 380px) {
    .emx-item-l3 { display: none; }
    .emx-read-acts .emx-btn span { display: none; }
}

/* ─── Scrollbars discrètes ───────────────────────────────────────────── */
.emx-items::-webkit-scrollbar,
.emx-read-scroll::-webkit-scrollbar,
.emx-comp-scroll::-webkit-scrollbar,
.emx-nav::-webkit-scrollbar,
.emx-body::-webkit-scrollbar { width: 8px; }
.emx-items::-webkit-scrollbar-thumb,
.emx-read-scroll::-webkit-scrollbar-thumb,
.emx-comp-scroll::-webkit-scrollbar-thumb,
.emx-nav::-webkit-scrollbar-thumb,
.emx-body::-webkit-scrollbar-thumb { background: var(--x-line2); border-radius: 4px; }
.emx-items::-webkit-scrollbar-track,
.emx-read-scroll::-webkit-scrollbar-track { background: transparent; }

/* réduction de mouvement */
@media (prefers-reduced-motion: reduce) {
    .emx-nav, .emx-read, .emx-item-main, .emx-kbd { transition: none !important; }
}

/* ═══ Paliers CONTENEUR (≥1200 viewport mais conteneur admin étroit) ═════
   Le volet de lecture était écrasé quand la page admin est plus étroite que
   le viewport (paddings/layout) : les colonnes fixes 246+400 mangeaient tout. */
@media (min-width: 1200px) {
    .emx.emx-cw-md { grid-template-columns: 216px minmax(280px, 340px) minmax(0, 1fr); }
    .emx.emx-cw-sm {
        grid-template-columns: 64px minmax(250px, 300px) minmax(0, 1fr);
        .emx-nav { padding: 14px 8px; align-items: center; }
        .emx-brand-tx, .emx-nav-sec, .emx-nav-item span, .emx-cta span { display: none; }
        .emx-cta { width: 44px; height: 44px; padding: 0; justify-content: center; margin-bottom: 10px; }
        .emx-nav-item { justify-content: center; padding: 11px 0; width: 44px; }
        .emx-nav-item.active::before { left: -8px; }
        .emx-badge {
            position: absolute; top: 3px; right: 1px;
            min-width: 16px; height: 15px; font-size: 0.6rem; padding: 0 4px;
        }
        .emx-nav-foot { align-items: center; }
        .emx-read-acts .emx-btn span { display: none; }
        .emx-read-acts .emx-btn { padding: 8px 11px; }
    }
}

/* ═══ Lecture PLEIN ÉCRAN (double-clic sur un email / bouton agrandir) ═══ */
.emx-max-scrim { display: none; }
.emx.emx-max .emx-max-scrim {
    display: block;
    position: fixed; inset: 0; z-index: 4990;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    cursor: pointer;
}
.emx.emx-max .emx-read {
    position: fixed;
    inset: 3vh max(18px, calc((100vw - 1280px) / 2));
    z-index: 5000;
    transform: none;
    border: 1px solid var(--x-line2);
    border-radius: var(--x-radius);
    box-shadow: var(--x-shadow);
}
.emx-max-on { display: none; }
.emx.emx-max .emx-max-on { display: inline; }
.emx.emx-max .emx-max-off { display: none; }
@media (max-width: 899px) {
    .emx.emx-max .emx-read { inset: 0; border-radius: 0; border: none; }
}

/* ═══ MESSAGERIE en plein écran (bouton agrandir de la barre du haut) ════
   emx-float = variante non persistée posée pendant la lecture plein écran.
   Dans les deux cas le JS déplace l'app dans <body> (portal). */
.emx.emx-app-max, .emx.emx-float {
    position: fixed; inset: 0; z-index: 4980;
    /* !important : admin-v12.css force `.emx { height: calc(100vh - 232px) !important }`
       (place pour la bottom bar A12) — en plein écran on doit le surclasser */
    height: 100vh !important; height: 100dvh !important;
    max-height: none !important;
    min-height: 0 !important;
    border: none; border-radius: 0;
}
html.emx-lock, html.emx-lock body { overflow: hidden !important; }
.emx-appmax-on { display: none; }
.emx.emx-app-max .emx-appmax-on { display: inline; }
.emx.emx-app-max .emx-appmax-off { display: none; }


/* ===========================================================================
   01.08.2026 — Éditeur : listes VISIBLES + barre flottante de sélection
   « on voit pas les points des listes » : .emx-body n'avait aucune règle
   ul/ol/li, les puces héritaient donc du reset global (list-style:none).
   =========================================================================== */
.emx-body ul,
.emx-body ol,
.emx-read ul,
.emx-read ol {
    margin: 0.5em 0;
    padding-left: 1.7em;
}
.emx-body ul, .emx-read ul { list-style: disc outside; }
.emx-body ol, .emx-read ol { list-style: decimal outside; }
.emx-body ul ul, .emx-read ul ul { list-style: circle outside; }
.emx-body ul ul ul, .emx-read ul ul ul { list-style: square outside; }
.emx-body li, .emx-read li { display: list-item; margin: 0.15em 0; }
.emx-body blockquote {
    margin: 0.6em 0; padding: 0.2em 0 0.2em 0.9em;
    border-left: 3px solid var(--x-line2, #d8d5cc); color: #444;
}

/* Barre flottante (apparaît au-dessus de la sélection, motif Outlook) */
.emx-fmtbar {
    position: fixed;
    z-index: 100000;
    display: none;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border-radius: 10px;
    background: #1b1b1f;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 28px -8px rgba(0, 0, 0, 0.55), 0 2px 8px -2px rgba(0, 0, 0, 0.4);
}
.emx-fmtbar.is-open { display: flex; }
.emx-fmtbar button {
    appearance: none;
    border: 0;
    background: transparent;
    color: #EDEBE7;
    width: 34px;
    height: 34px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 0.92rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.emx-fmtbar button:hover { background: rgba(255, 255, 255, 0.12); }
.emx-fmtbar button:active { background: rgba(220, 38, 38, 0.35); }
.emx-fmtbar-sep {
    width: 1px; height: 20px; margin: 0 3px;
    background: rgba(255, 255, 255, 0.16);
}
/* doigt : cibles plus larges */
@media (hover: none) and (pointer: coarse) {
    .emx-fmtbar button { width: 40px; height: 40px; font-size: 1rem; }
}


/* ===========================================================================
   01.08.2026 — Aperçu PDF rendu par PDF.js (Chrome Android n'affiche pas les
   PDF dans une <iframe> : page grise + icône « document cassé »).
   =========================================================================== */
.emx-pdf-host {
    flex: 1;
    width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background: #52525b;
    padding: 10px 0 24px;
}
.emx-pdf-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.emx-pdf-page {
    display: block;
    max-width: 100%;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    border-radius: 2px;
}
.emx-pdf-load {
    padding: 28px 16px;
    text-align: center;
    color: #EDEBE7;
    font-size: 0.9rem;
}
