/* ==========================================================================
   Messagerie — style « Logic » (home-style) en version méditerranéenne
   Encre marine, mer turquoise, murs blanchis à la chaux, terre cuite,
   ocre solaire, olivier et zellige.
   ========================================================================== */

:root {
    color-scheme: light;

    /* Palette de référence (home-style.css) */
    --ink: #103c4a;
    --muted: #526c77;
    --accent: #087b98;
    --accent-hover: #06647c;
    --line: #cfe0e5;
    --paper: #fafcfd;
    --ice: #f0f9fc;

    /* Touches méditerranéennes */
    --lime: #f7f3ec;          /* mur blanchi à la chaux */
    --line-warm: #e8dfcf;
    --sand: #efe5d3;
    --terracotta: #c0583a;
    --ochre: #d9962b;
    --olive: #6f7f3f;
    --majorelle: #2f55b5;
    --veil: 250 252 253;      /* voile clair posé sur l'illustration */

    /* Jetons d'interface */
    --bg: var(--ice);
    --sidebar: var(--lime);
    --surface: #ffffff;
    --surface-2: var(--paper);
    --surface-3: #e7f0f3;
    --hover: rgb(8 123 152 / 0.06);
    --border: var(--line);
    --border-strong: #b6cdd5;
    --ghost-border: #8aa8b4;
    --text: var(--ink);
    --text-2: var(--muted);
    --text-3: #7c939c;
    --accent-soft: #e3f2f6;
    --accent-soft-2: #c7e6ed;
    --accent-text: #ffffff;
    --accent-ink: #06647c;
    --danger: #ac383d;
    --danger-soft: #f9e8e7;
    --success: #187a5b;
    --success-soft: #e1f2eb;
    --warning: #7a5212;
    --warning-soft: #fbf1dc;
    --warning-line: #efdcb4;
    --star: var(--ochre);
    --compose-head: var(--ink);
    --shadow-sm: 0 1px 2px rgb(16 60 74 / 0.06);
    --shadow: 0 8px 28px rgb(16 60 74 / 0.12);
    --shadow-lg: 0 12px 40px rgb(16 60 74 / 0.18);
    --radius: 8px;
    --radius-sm: 6px;
    --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    --shell: 1240px;
    --sidebar-w: 256px;
    --list-w: 400px;
}

/* Nuit méditerranéenne */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --ink: #e6f0f2;
        --muted: #a6bec6;
        --accent: #3aaac7;
        --accent-hover: #62bdd5;
        --line: #23465a;
        --paper: #10303b;
        --ice: #0b2129;
        --lime: #0f2731;
        --line-warm: #1f4150;
        --sand: #2b3b3a;
        --terracotta: #e08566;
        --ochre: #e9b25a;
        --olive: #a7b86f;
        --majorelle: #8aa2f0;
        --veil: 11 33 41;
        --surface: #12303b;
        --surface-3: #1b4250;
        --hover: rgb(255 255 255 / 0.05);
        --border-strong: #31596c;
        --ghost-border: #3d6a7d;
        --text-3: #789aa4;
        --accent-soft: rgb(58 170 199 / 0.15);
        --accent-soft-2: rgb(58 170 199 / 0.28);
        --accent-text: #06232c;
        --accent-ink: #7fcde0;
        --danger: #ec7f7a;
        --danger-soft: rgb(236 127 122 / 0.13);
        --success: #5cc49c;
        --success-soft: rgb(92 196 156 / 0.13);
        --warning: #f0c26e;
        --warning-soft: rgb(233 178 90 / 0.1);
        --warning-line: rgb(233 178 90 / 0.25);
        --compose-head: #1b4250;
        --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
        --shadow: 0 8px 28px rgb(0 0 0 / 0.35);
        --shadow-lg: 0 12px 40px rgb(0 0 0 / 0.45);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --ink: #e6f0f2;
    --muted: #a6bec6;
    --accent: #3aaac7;
    --accent-hover: #62bdd5;
    --line: #23465a;
    --paper: #10303b;
    --ice: #0b2129;
    --lime: #0f2731;
    --line-warm: #1f4150;
    --sand: #2b3b3a;
    --terracotta: #e08566;
    --ochre: #e9b25a;
    --olive: #a7b86f;
    --majorelle: #8aa2f0;
    --veil: 11 33 41;
    --surface: #12303b;
    --surface-3: #1b4250;
    --hover: rgb(255 255 255 / 0.05);
    --border-strong: #31596c;
    --ghost-border: #3d6a7d;
    --text-3: #789aa4;
    --accent-soft: rgb(58 170 199 / 0.15);
    --accent-soft-2: rgb(58 170 199 / 0.28);
    --accent-text: #06232c;
    --accent-ink: #7fcde0;
    --danger: #ec7f7a;
    --danger-soft: rgb(236 127 122 / 0.13);
    --success: #5cc49c;
    --success-soft: rgb(92 196 156 / 0.13);
    --warning: #f0c26e;
    --warning-soft: rgb(233 178 90 / 0.1);
    --warning-line: rgb(233 178 90 / 0.25);
    --compose-head: #1b4250;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow: 0 8px 28px rgb(0 0 0 / 0.35);
    --shadow-lg: 0 12px 40px rgb(0 0 0 / 0.45);
}

*, *::before, *::after { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft-2); color: var(--ink); }

html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 650; line-height: 1.15; letter-spacing: -0.03em; text-wrap: balance; }
kbd {
    font: 600 11px/1 var(--font);
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink);
}
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.spacer { flex: 1; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.icon { width: 18px; height: 18px; flex: none; stroke-width: 1.8; }
.icon.xs { width: 14px; height: 14px; }

/* Libellé avec filet (section-label) */
.eyebrow {
    display: flex;
    align-items: center;
    gap: 20px;
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
}
.eyebrow::after { content: ""; width: 120px; height: 1px; background: var(--line); }

/* ---------- Boutons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 40px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--ghost-border);
    background: rgb(var(--veil) / 0.62);
    color: var(--ink);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.btn:hover:not(:disabled) { background: var(--surface); border-color: var(--accent); }
.btn:disabled { opacity: 0.6; }
.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
}
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); transform: translateY(-2px); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.danger:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-2px); }
.btn.block { width: 100%; }
.btn.lg { min-height: 48px; padding: 13px 23px; font-size: 14px; }
.btn .icon { width: 17px; height: 17px; }

.btn-spinner { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }
.btn.loading .btn-spinner { display: inline-block; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    flex: none;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-2);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--accent); }
.icon-btn:disabled { opacity: 0.4; }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm .icon { width: 17px; height: 17px; }
.icon-btn.xs { width: 24px; height: 24px; border-radius: 5px; }
.icon-btn.xs .icon { width: 15px; height: 15px; }
.icon-btn.danger:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); }
.icon-btn.on { color: var(--accent); }

.link-btn {
    border: 0;
    background: none;
    padding: 2px 4px;
    color: var(--accent);
    font-weight: 500;
    border-radius: 4px;
    text-decoration: underline;
    text-underline-offset: 4px;
}
.link-btn:hover { color: var(--accent-hover); }

/* Bouton du tiroir de dossiers et bouton « retour » : affichés selon la mise en page */
.nav-toggle, .back-btn { display: none !important; }

/* ---------- Champs ---------- */

.input {
    display: block;
    width: 100%;
    min-height: 46px;
    padding: 11px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    background: var(--paper);
    color: var(--ink);
    line-height: 1.5;
    transition: border-color 0.15s, background 0.15s;
}
textarea.input { resize: vertical; }
select.input { padding-top: 0; padding-bottom: 0; }
.input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.field-label { display: grid; gap: 9px; font-size: 14px; font-weight: 500; color: var(--ink); margin-bottom: 18px; }
.field-label .input { font-weight: 400; font-size: 15px; }
.hint { margin: -8px 0 18px; font-size: 13px; color: var(--text-2); }
.check-row { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check-row .icon { width: 16px; height: 16px; vertical-align: -3px; color: var(--accent); }
.check-row.disabled { opacity: 0.5; cursor: default; }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

/* ---------- Avatars : couleurs du bassin méditerranéen ---------- */

.avatar {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 50%;
    background: var(--av-bg, #dcf0f5);
    color: var(--av-fg, #0a6a83);
    font-size: 13px;
    font-weight: 650;
    letter-spacing: 0.02em;
    user-select: none;
}
.av-0 { --av-bg: #dcf0f5; --av-fg: #0a6a83; }   /* mer */
.av-1 { --av-bg: #f7e2d7; --av-fg: #a2482a; }   /* terre cuite */
.av-2 { --av-bg: #e7ecd9; --av-fg: #56662c; }   /* olivier */
.av-3 { --av-bg: #f8ebcf; --av-fg: #855a10; }   /* safran */
.av-4 { --av-bg: #e1e6f8; --av-fg: #2c46a3; }   /* Majorelle */
.av-5 { --av-bg: #ece4f4; --av-fg: #694b8b; }   /* lavande */
.av-6 { --av-bg: #d8ece9; --av-fg: #1c6b63; }   /* lagune */
.av-7 { --av-bg: #f6dee7; --av-fg: #9b2f5c; }   /* bougainvillier */
:root[data-theme="dark"] .avatar { background: color-mix(in srgb, var(--av-fg, #0a6a83) 38%, var(--surface)); color: color-mix(in srgb, var(--av-fg, #0a6a83) 28%, #ffffff); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .avatar { background: color-mix(in srgb, var(--av-fg, #0a6a83) 38%, var(--surface)); color: color-mix(in srgb, var(--av-fg, #0a6a83) 28%, #ffffff); }
}
.avatar.sm { width: 30px; height: 30px; font-size: 11.5px; }
.avatar.lg { width: 46px; height: 46px; font-size: 15px; }

/* ---------- Marque : arche et enveloppe ---------- */

.brand { display: flex; align-items: center; gap: 12px; font-weight: 650; font-size: 17px; letter-spacing: -0.03em; color: var(--ink); }
.brand-mark {
    position: relative;
    display: grid;
    place-items: center;
    width: 30px;
    height: 36px;
    padding-top: 4px;
    border-radius: 15px 15px 4px 4px;
    background: var(--accent);
    color: #fff;
}
.brand-mark::after {
    content: "";
    position: absolute;
    top: 5px;
    right: 5px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ochre);
}
.brand-mark .icon { width: 16px; height: 16px; }
.brand-lg { font-size: 20px; }
.brand-lg .brand-mark { width: 38px; height: 46px; border-radius: 19px 19px 5px 5px; }
.brand-lg .brand-mark .icon { width: 20px; height: 20px; }
.brand-lg .brand-mark::after { top: 7px; right: 7px; width: 7px; height: 7px; }

/* ---------- Écran de chargement ---------- */

.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--paper); z-index: 100; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--accent-soft-2); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
.boot-error { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 24px; color: var(--text-2); }
.boot-error .icon { width: 36px; height: 36px; color: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Connexion : composition pleine largeur ---------- */

.login {
    position: relative;
    height: 100%;
    overflow: auto;
    display: grid;
    align-items: center;
    background: #eef5f4;
}
.login > picture {
    position: absolute;
    inset: 0;
}
.login-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 72% center;
}
.login::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, rgb(var(--veil) / 0.92), rgb(var(--veil) / 0.7) 36%, rgb(var(--veil) / 0) 64%);
}
.login-inner {
    position: relative;
    z-index: 1;
    width: min(var(--shell), calc(100% - 96px));
    margin: auto;
    padding: 56px 0;
}
.login-panel { max-width: 450px; }
.login-panel .eyebrow { margin: 34px 0 16px; }
.login-title { font-size: clamp(32px, 3.3vw, 46px); font-weight: 700; letter-spacing: -0.048em; line-height: 1.1; color: var(--ink); }
.login-title span { font-weight: 650; color: var(--accent); }
.login-card {
    margin-top: 30px;
    padding: 28px 28px 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgb(var(--veil) / 0.86);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}
.password-wrap { position: relative; display: block; }
.password-wrap .input { padding-right: 48px; }
.password-wrap .icon-btn { position: absolute; right: 8px; top: 8px; }
.form-error {
    margin: -6px 0 16px;
    padding: 12px 14px;
    border-left: 4px solid var(--danger);
    border-radius: 5px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 14px;
}
.login-foot { display: flex; align-items: center; gap: 8px; margin: 18px 0 0; color: var(--text-2); font-size: 13px; }
.login-foot .icon { width: 15px; height: 15px; color: var(--accent); }

/* ---------- Structure de l'application ---------- */

.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) var(--list-w) minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
}

/* Barre latérale : chaux, zellige et terre cuite */
.sidebar {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--sidebar);
    border-right: 1px solid var(--line-warm);
    isolation: isolate;
}
.sidebar::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 260px;
    z-index: -1;
    pointer-events: none;
    background: url("../img/zellige.svg") repeat;
    opacity: 0.22;
    -webkit-mask-image: linear-gradient(to top, #000 10%, transparent);
    mask-image: linear-gradient(to top, #000 10%, transparent);
}
.sidebar-head { padding: 20px 20px 16px; }
.compose-btn { margin: 0 16px 14px; min-height: 46px; font-size: 14px; }
.folders { flex: 1; overflow-y: auto; padding: 4px 12px 16px; }
.folder-group { display: grid; gap: 2px; }
.folder-row {
    position: relative;
    display: flex;
    align-items: center;
    border-radius: var(--radius-sm);
    padding-left: calc(var(--depth, 0) * 14px);
    transition: background 0.15s;
}
.folder-row:hover { background: rgb(255 255 255 / 0.6); }
:root[data-theme="dark"] .folder-row:hover { background: var(--hover); }
.folder-row.active { background: var(--surface); box-shadow: inset 3px 0 0 var(--accent), var(--shadow-sm); }
.folder-row.drop-target { background: var(--accent-soft-2); box-shadow: inset 0 0 0 2px var(--accent); }
.folder {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 40px;
    padding: 0 10px 0 13px;
    color: var(--ink);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
}
.folder:hover { color: var(--accent); }
.folder-row.active .folder { color: var(--accent); font-weight: 600; }
.folder-row.disabled .folder { opacity: 0.55; cursor: default; }
.folder .icon { width: 18px; height: 18px; color: var(--text-2); }
.folder-row.active .folder .icon, .folder:hover .icon { color: var(--accent); }
.folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
    min-width: 22px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 11.5px;
    font-weight: 700;
    text-align: center;
}
.badge.muted { background: var(--sand); color: var(--terracotta); }
.folder-more { position: absolute; right: 6px; opacity: 0; background: var(--sidebar); }
.folder-row.active .folder-more { background: var(--surface); }
.folder-row:hover .folder-more, .folder-more:focus-visible { opacity: 1; }
.folder-row:hover .badge { visibility: hidden; }
.folder-row:not(:has(.folder-more)):hover .badge { visibility: visible; }
.folder-section {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 22px 2px 8px 13px;
}
.folder-section span {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
}
.folder-section span::after { content: ""; flex: 1; height: 1px; background: var(--line-warm); }
.folder-empty { margin: 4px 13px; color: var(--text-2); font-size: 13px; }
.folders-loading { display: grid; gap: 14px; padding: 12px; }
.sidebar-foot {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 12px 14px 16px;
    border-top: 1px solid var(--line-warm);
}
.account-email { flex: 1; min-width: 0; font-size: 13px; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: 4px; }

.scrim { display: none; }

/* Liste des messages */
.list-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    background: var(--surface);
    border-right: 1px solid var(--line);
}
.list-head { display: flex; align-items: center; gap: 4px; padding: 18px 12px 10px 20px; }
.folder-title { flex: 1; min-width: 0; font-size: 24px; font-weight: 650; letter-spacing: -0.04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#refresh-btn.spinning .icon { animation: spin 0.8s linear infinite; }
.search { position: relative; margin: 2px 16px 10px; }
.search > .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 17px; height: 17px; pointer-events: none; }
.search input {
    width: 100%;
    height: 42px;
    padding: 0 14px 0 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--paper);
    transition: border-color 0.15s, background 0.15s;
}
.search input::placeholder { color: var(--text-3); }
.search input:focus { outline: none; background: var(--surface); border-color: var(--accent); }

.list-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    padding: 4px 10px 4px 20px;
    border-bottom: 1px solid var(--line);
}
.select-all { display: grid; place-items: center; width: 22px; height: 30px; cursor: pointer; }
.filters { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.chip {
    min-height: 30px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip:hover { color: var(--accent); border-color: var(--accent); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.bulk { display: none; align-items: center; gap: 1px; flex: 1; min-width: 0; }
.bulk-count { font-size: 13px; font-weight: 600; color: var(--accent); margin-right: auto; padding-left: 2px; white-space: nowrap; }
.list-toolbar.has-selection .filters { display: none; }
.list-toolbar.has-selection .bulk { display: flex; }

.message-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; transition: opacity 0.2s; }
.message-list.is-loading { opacity: 0.6; }

.list-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    min-height: 44px;
    padding: 4px 10px 4px 20px;
    border-top: 1px solid var(--line);
    background: var(--paper);
}
.pager-info { flex: 1; font-size: 12.5px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }

.row {
    position: relative;
    display: flex;
    gap: 13px;
    padding: 13px 16px 13px 20px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}
.row:hover { background: var(--ice); }
.row.active, .row.selected { background: var(--accent-soft); }
.row.active::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.row.unread::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 50%;
    width: 6px;
    height: 6px;
    margin-top: -3px;
    border-radius: 50%;
    background: var(--accent);
}
.row-avatar { position: relative; padding: 0; border: 0; background: none; border-radius: 50%; height: 38px; }
.row-check {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.15s, transform 0.15s;
}
.row-check .icon { width: 18px; height: 18px; stroke-width: 3; }
.row.selected .row-check { opacity: 1; transform: none; }
.row-avatar:hover .row-check, .message-list.selecting .row-avatar .row-check { opacity: 1; transform: none; }
.row-avatar:hover .row-check, .message-list.selecting .row:not(.selected) .row-check { background: var(--surface); color: var(--text-3); box-shadow: inset 0 0 0 2px var(--border-strong); }
.row.selected .row-avatar:hover .row-check { background: var(--accent); color: #fff; box-shadow: none; }
.row-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row-top, .row-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: 14.5px; font-weight: 500; }
.row-date { flex: none; font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.row-subject { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 14px; }
.row.unread .row-from { font-weight: 650; }
.row.unread .row-subject { color: var(--ink); font-weight: 600; }
.row.unread .row-date { color: var(--accent); font-weight: 600; }
.row-icons { display: flex; align-items: center; gap: 5px; flex: none; color: var(--text-3); }
.row-ico .icon { width: 14px; height: 14px; display: block; }
.draft-tag { font-style: normal; color: var(--terracotta); font-weight: 600; }
.star-btn { border: 0; background: none; padding: 2px; color: var(--text-3); display: inline-grid; border-radius: 5px; opacity: 0.6; transition: color 0.15s, opacity 0.15s, transform 0.15s; }
.star-btn .icon { width: 16px; height: 16px; }
.row:hover .star-btn, .star-btn:focus-visible { opacity: 1; }
.star-btn:hover { color: var(--star); transform: scale(1.12); }
.star-btn.on { color: var(--star); opacity: 1; }
.star-btn.on .icon { fill: currentColor; }
.icon-btn.star-btn { opacity: 1; padding: 0; color: var(--text-2); }
.icon-btn.star-btn.on { color: var(--star); }

.app.dragging-mail .folder-row[data-drop=""] { opacity: 0.5; }

/* États vides et squelettes */
.empty, .reader-empty {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 10px;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-2);
    min-height: 60%;
}
.empty p, .reader-empty p { margin: 0; }
.empty-icon { width: 40px; height: 40px; color: var(--accent); stroke-width: 1.5; opacity: 0.7; }
.reader-empty { height: 100%; gap: 8px; }
.reader-empty-art {
    width: 170px;
    height: 210px;
    margin-bottom: 18px;
    border-radius: 85px 85px 8px 8px;
    background: url("../img/arche.webp") center / cover no-repeat, var(--ice);
    box-shadow: 0 0 0 8px var(--lime), 0 0 0 9px var(--line-warm), var(--shadow);
}
.reader-empty-title { font-size: 22px; font-weight: 650; letter-spacing: -0.035em; color: var(--ink); }
.reader-empty .small { margin-top: 14px; }
.reader-empty kbd { margin: 0 1px; }

.skeleton-line, .skeleton-block, .skeleton-card {
    display: block;
    border-radius: 5px;
    background: linear-gradient(90deg, var(--surface-3) 0%, var(--paper) 50%, var(--surface-3) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.2s ease-in-out infinite;
}
.skeleton-line { height: 12px; width: 70%; margin: 4px 0; }
.skeleton-line.lg { height: 24px; margin-bottom: 20px; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w90 { width: 90%; }
.skeleton-block { border-radius: 50%; color: transparent; }
.skeleton-card { height: 280px; border-radius: var(--radius); }
.row.skeleton { cursor: default; }
.row.skeleton:hover { background: none; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Lecteur ---------- */

.reader-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.reader-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 60px;
    padding: 10px 18px;
    background: rgb(var(--veil) / 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}
.tb-group { display: flex; align-items: center; gap: 2px; }
.tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 8px; flex: none; }
.reader-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.reader-article { max-width: 980px; margin: 0 auto; padding: 32px 36px 48px; }
.reader-subject { font-size: clamp(22px, 2vw, 30px); font-weight: 650; letter-spacing: -0.04em; line-height: 1.2; margin-bottom: 22px; overflow-wrap: anywhere; }
.reader-meta { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 14px; margin-bottom: 20px; }
.meta-main { flex: 1; min-width: min(260px, calc(100% - 60px)); display: grid; gap: 3px; }
.meta-from { font-size: 15px; overflow-wrap: break-word; }
.meta-line { font-size: 13.5px; color: var(--text-2); overflow-wrap: break-word; }
.meta-date { flex: none; margin-left: auto; font-size: 13px; color: var(--text-2); padding-top: 2px; text-align: right; }
.addr { border: 0; background: none; padding: 0; color: inherit; font: inherit; border-radius: 3px; text-align: left; }
.addr:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.addr.strong { font-weight: 650; color: var(--ink); }

.banner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid var(--warning-line);
    border-left: 4px solid var(--ochre);
    border-radius: 5px;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 13.5px;
}
.banner .icon { width: 18px; height: 18px; color: var(--ochre); }
.banner > span { flex: 1; min-width: 200px; }
.banner .link-btn { color: inherit; font-weight: 600; }

.attachments { margin-bottom: 18px; }
.att-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--ink); margin-bottom: 10px; }
.att-head .icon { width: 15px; height: 15px; color: var(--accent); }
.att-list { display: flex; flex-wrap: wrap; gap: 10px; }
.att {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 8px 10px;
    min-width: 0;
    max-width: 300px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    transition: transform 0.25s ease, border-color 0.25s ease;
}
.att:hover { transform: translateY(-3px); border-color: var(--accent); }
.att-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); flex: none; }
.att-icon .icon { width: 18px; height: 18px; }
.att-info { display: grid; min-width: 0; }
.att-name { font-size: 13.5px; font-weight: 600; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-name:hover { color: var(--accent); }
.att-size { font-size: 12px; color: var(--text-2); }

.mail-body {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.mail-frame { display: block; width: 100%; height: 120px; border: 0; background: #fff; }
.reader-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

/* ---------- Menus ---------- */

.menu {
    position: fixed;
    z-index: 80;
    min-width: 220px;
    max-width: 320px;
    max-height: min(420px, 70vh);
    overflow-y: auto;
    padding: 6px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    animation: pop 0.14s ease-out;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: 5px;
    background: none;
    color: var(--ink);
    text-align: left;
    font-size: 14px;
}
.menu-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .icon { width: 16px; height: 16px; color: var(--text-2); }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--ice); color: var(--accent); outline: none; }
.menu-item:hover:not(:disabled) .icon, .menu-item:focus-visible .icon { color: var(--accent); }
.menu-item:disabled { opacity: 0.45; }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-sep { height: 1px; margin: 5px 6px; background: var(--line); }
.menu-header { display: flex; align-items: center; gap: 12px; padding: 8px 12px 6px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.menu-header::after { content: ""; flex: 1; height: 1px; background: var(--line); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }

/* ---------- Boîtes de dialogue ---------- */

.dialog {
    width: min(460px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgb(16 60 74 / 0.35); backdrop-filter: blur(3px); }
.dialog[open] { animation: pop 0.16s ease-out; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 18px 8px 26px; }
.dialog-head h2 { font-size: 21px; letter-spacing: -0.035em; }
.dialog-body { padding: 12px 26px 4px; }
.dialog-text { margin: 0 0 8px; color: var(--muted); line-height: 1.65; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 26px 24px; }
.settings-dialog { width: min(760px, calc(100vw - 32px)); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 32px; }
.settings-grid h3 { display: flex; align-items: center; gap: 16px; font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--ink); margin: 6px 0 18px; }
.settings-grid h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Éditeur de signature : fond « papier », tel que le verront les destinataires */
.sig-editor {
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    overflow: hidden;
    transition: border-color 0.15s;
}
.sig-editor:focus-within { border-color: var(--accent); }
.sig-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1px;
    padding: 4px 6px;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
}
.sig-toolbar .tb-sep { height: 18px; margin: 0 4px; }
.sig-content {
    min-height: 140px;
    max-height: 280px;
    overflow-y: auto;
    padding: 12px 14px;
    background: #fff;
    color: #103c4a;
    color-scheme: light;
    font: 14px/1.5 Arial, Helvetica, sans-serif;
    font-weight: 400;
    overflow-wrap: break-word;
    outline: none;
    contain: layout paint;
}
.sig-content:empty::before { content: attr(data-placeholder); color: #7c939c; pointer-events: none; }
.sig-content img { max-width: 100%; height: auto; cursor: pointer; }
.sig-content img.sig-selected { outline: 2px solid #087b98; outline-offset: 2px; }
.sig-content a { color: #087b98; }
.sig-hint { margin: 8px 0 0; }
@media (pointer: coarse) { .sig-content { font-size: 16px; } }

/* ---------- Notifications ---------- */

.toasts {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 90;
    display: grid;
    gap: 10px;
    width: max-content;
    max-width: min(520px, calc(100vw - 32px));
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px 10px 18px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
    font-size: 14px;
    pointer-events: auto;
    animation: toast-in 0.22s ease-out;
}
.toast.leaving { opacity: 0; transform: translateY(6px); transition: 0.2s; }
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-msg { flex: 1; }
.toast-action { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 4px 8px; border-radius: 5px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Rédaction ---------- */

.compose {
    position: fixed;
    right: 24px;
    bottom: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    width: 620px;
    height: min(680px, calc(100dvh - 48px));
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: var(--shadow-lg);
    animation: compose-in 0.2s ease-out;
}
@keyframes compose-in { from { transform: translateY(24px); opacity: 0; } }
.compose.maximized { right: 50%; bottom: 50%; transform: translate(50%, 50%); width: min(1000px, calc(100vw - 64px)); height: calc(100dvh - 64px); border-radius: var(--radius); border-bottom: 1px solid var(--line); animation: none; }
.compose.minimized { height: auto; width: 340px; }
.compose.minimized .compose-body, .compose.minimized .compose-foot { display: none; }
.compose-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 8px 9px 18px;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--compose-head);
    color: #fff;
    cursor: default;
}
.compose.minimized .compose-head { cursor: pointer; }
.compose-title { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-head-actions { display: flex; gap: 2px; }
.compose-head .icon-btn { color: rgb(255 255 255 / 0.78); }
.compose-head .icon-btn:hover:not(:disabled) { background: rgb(255 255 255 / 0.12); color: #fff; }
.compose-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.compose-fields { padding: 0 18px; }
.cfield {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    border-bottom: 1px solid var(--line);
}
.cfield-label { width: 44px; flex: none; color: var(--text-2); font-size: 13.5px; }
.cfield-extra { display: flex; gap: 2px; align-self: flex-start; padding-top: 12px; }
.cfield-extra .link-btn { color: var(--text-2); font-size: 13.5px; text-decoration: none; }
.cfield-extra .link-btn:hover { color: var(--accent); }
.subject-input { flex: 1; min-width: 0; border: 0; background: none; height: 44px; font-weight: 600; color: var(--ink); }
.subject-input:focus { outline: none; }

.chips { position: relative; flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 7px 0; cursor: text; }
.chip-input { flex: 1; min-width: 120px; border: 0; background: none; height: 30px; padding: 0 2px; color: var(--ink); }
.chip-input:focus { outline: none; }
.chips .chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    min-height: 30px;
    height: 30px;
    padding: 0 3px 0 10px;
    border-radius: var(--radius-sm);
    background: var(--ice);
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 500;
    max-width: 100%;
    cursor: pointer;
}
.chips .chip:hover { border-color: var(--accent); }
.chips .chip.invalid { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-x { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--text-3); flex: none; }
.chip-x:hover { background: var(--hover); color: var(--danger); }
.chip-x .icon { width: 13px; height: 13px; }

.suggest {
    position: absolute;
    left: 0;
    top: calc(100% + 4px);
    z-index: 5;
    min-width: 300px;
    max-width: 100%;
    padding: 5px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.suggest-item { display: grid; padding: 8px 12px; border-radius: 5px; cursor: pointer; }
.suggest-item.active, .suggest-item:hover { background: var(--accent-soft); }
.suggest-name { font-weight: 600; font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-addr { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.editor-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1px;
    padding: 6px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
}
.editor-toolbar .tb-sep { height: 18px; margin: 0 5px; }
/* Fond « papier » : ce que voit le destinataire, lisible quel que soit le thème */
.editor-wrap { flex: 1; min-height: 120px; overflow-y: auto; background: #fff; color: #103c4a; color-scheme: light; }
.editor {
    min-height: 100%;
    padding: 16px 20px 26px;
    font: 14px/1.6 Arial, Helvetica, sans-serif;
    overflow-wrap: break-word;
    /* Empêche le contenu cité de déborder sur l'interface */
    contain: layout paint;
    transform: translateZ(0);
}
.editor:focus { outline: none; }
.editor img { max-width: 100%; height: auto; }
.editor blockquote { margin: 0 0 0 0.8ex; padding-left: 1ex; border-left: 2px solid #cfe0e5; }
.editor a { color: #087b98; }

.compose-attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 18px; border-top: 1px solid var(--line); max-height: 110px; overflow-y: auto; }
.att-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 260px;
    height: 32px;
    padding: 0 4px 0 10px;
    border-radius: var(--radius-sm);
    background: var(--ice);
    border: 1px solid var(--line);
    font-size: 13px;
}
.att-chip > .icon { width: 14px; height: 14px; color: var(--accent); }
.att-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: var(--ink); }
.att-chip-size { color: var(--text-2); white-space: nowrap; }

.compose-foot { display: flex; align-items: center; gap: 6px; padding: 12px 14px 14px 18px; border-top: 1px solid var(--line); }
.send-btn { padding: 9px 22px; }
.compose-status { font-size: 12.5px; color: var(--text-2); margin-left: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compose.busy .editor-wrap { opacity: 0.6; }
.drop-zone {
    position: absolute;
    inset: 50px 12px 12px;
    display: none;
    place-items: center;
    align-content: center;
    gap: 10px;
    border: 2px dashed var(--accent);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 88%, var(--accent));
    color: var(--accent);
    font-weight: 600;
    pointer-events: none;
}
.drop-zone .icon { width: 28px; height: 28px; }
.compose.dragging .drop-zone { display: grid; }

/* ---------- Adaptation aux écrans et appareils ----------
   ≥ 1280 px   PC, Galaxy Tab 12,4″ en paysage ............ 3 panneaux
   1100–1279   petits portables ............................ 3 panneaux, barre latérale réduite
   680–1099    Galaxy Z Fold5 déplié, tablettes en portrait,
               Tab 8,7″ et iPhone 16 Pro Max en paysage .... 2 panneaux + tiroir de dossiers
   < 680       iPhone 16 Pro Max, Z Fold5 plié,
               Tab 8,7″ en portrait ........................ 1 panneau
   Les barres d'outils s'adaptent à la largeur de leur panneau (container queries). */

.list-pane { container: list / inline-size; }
.reader-pane { container: reader / inline-size; }

/* Zones sûres : encoche, Dynamic Island et barre d'accueil de l'iPhone */
.app { padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
.list-foot { padding-bottom: max(4px, env(safe-area-inset-bottom)); }
.sidebar-foot { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.reader-article { padding-bottom: calc(48px + env(safe-area-inset-bottom)); }
.toasts { bottom: calc(24px + env(safe-area-inset-bottom)); }
.login-inner { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }

@media (min-width: 1600px) {
    :root { --sidebar-w: 268px; --list-w: 440px; }
}

/* Barre latérale réduite à des icônes */
@media (max-width: 1279px) {
    :root { --sidebar-w: 74px; --list-w: 340px; }
    .sidebar-head .brand span:last-child, .compose-btn span, .folder-name, .folder-section span, .folder-empty, .account-email, .folder-more { display: none; }
    .sidebar-head { padding: 18px 0 14px; display: grid; place-items: center; }
    .compose-btn { margin: 0 13px 14px; padding: 0; }
    .folders { padding: 4px 9px; }
    .folder-row { padding-left: 0; }
    .folder { justify-content: center; padding: 0; height: 44px; }
    .badge { position: absolute; top: 2px; right: 3px; min-width: 18px; padding: 0 5px; font-size: 10px; }
    .folder-section { justify-content: center; margin: 14px 0 6px; }
    .sidebar-foot { flex-direction: column; padding: 12px 0 max(12px, env(safe-area-inset-bottom)); }
    .reader-article { padding: 26px 26px calc(36px + env(safe-area-inset-bottom)); }
}

/* Deux panneaux : liste + lecture, dossiers dans un tiroir */
@media (max-width: 1099px) {
    :root { --sidebar-w: 288px; --list-w: clamp(300px, 40vw, 380px); }
    .app { grid-template-columns: var(--list-w) minmax(0, 1fr); }
    .nav-toggle { display: inline-flex !important; }
    .hide-compact { display: none !important; }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 50;
        width: calc(var(--sidebar-w) + env(safe-area-inset-left));
        padding: env(safe-area-inset-top) 0 0 env(safe-area-inset-left);
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: var(--shadow-lg);
    }
    .app.nav-open .sidebar { transform: none; }
    .sidebar-head .brand span:last-child, .compose-btn span, .folder-name, .folder-empty, .account-email { display: initial; }
    .folder-section span { display: flex; }
    .sidebar-head { padding: 20px 20px 16px; display: block; }
    .compose-btn { margin: 0 16px 14px; padding: 9px 18px; }
    .folders { padding: 4px 12px 16px; }
    .folder-row { padding-left: calc(var(--depth, 0) * 14px); }
    .folder { justify-content: flex-start; padding: 0 10px 0 13px; height: 46px; font-size: 15px; }
    .folder-more { display: inline-flex; }
    .folder-row .badge, .folder-row:hover .badge { position: static; visibility: visible; min-width: 22px; padding: 1px 7px; font-size: 11.5px; }
    .folder-section { justify-content: space-between; margin: 22px 2px 8px 13px; }
    .sidebar-foot { flex-direction: row; padding: 14px 12px max(14px, env(safe-area-inset-bottom)) 16px; }
    .scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgb(16 60 74 / 0.35); opacity: 0; pointer-events: none; transition: opacity 0.22s; }
    .app.nav-open .scrim { opacity: 1; pointer-events: auto; }

    .list-head { padding: 12px 8px 8px 8px; }
    .folder-title { font-size: 22px; }
    .reader-toolbar { padding: 8px 12px; }
    .reader-article { padding: 22px 22px calc(32px + env(safe-area-inset-bottom)); }
    .login-inner { width: calc(100% - 64px); }

    /* Rédaction : feuille centrée sur tablette et Fold déplié */
    .compose, .compose.maximized {
        top: max(24px, env(safe-area-inset-top));
        bottom: max(24px, env(safe-area-inset-bottom));
        left: 50%;
        right: auto;
        width: min(780px, calc(100vw - 48px));
        height: auto;
        transform: translateX(-50%);
        border-radius: var(--radius);
        border-bottom: 1px solid var(--line);
    }
    .compose.minimized { top: auto; bottom: 0; width: min(420px, calc(100vw - 48px)); border-radius: var(--radius) var(--radius) 0 0; }
}

/* Un panneau : la lecture s'ouvre par-dessus la liste */
@media (max-width: 679px) {
    .app { grid-template-columns: minmax(0, 1fr); }
    .back-btn { display: inline-flex !important; }
    .list-pane { border-right: 0; }
    .reader-pane {
        position: fixed;
        inset: 0;
        z-index: 30;
        padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
        transform: translateX(100%);
        transition: transform 0.22s ease, visibility 0.22s;
        visibility: hidden;
    }
    .app.reading .reader-pane { transform: none; visibility: visible; }
    .reader-toolbar { padding: 6px 8px; gap: 0; min-height: 56px; }
    .reader-article { padding: 20px 16px calc(32px + env(safe-area-inset-bottom)); }
    .reader-subject { font-size: 22px; }
    .meta-date { width: 100%; text-align: left; padding-left: 60px; margin-top: -2px; }

    .compose, .compose.maximized {
        inset: 0;
        width: auto;
        height: auto;
        transform: none;
        border-radius: 0;
        border: 0;
        padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
    }
    .compose-head { border-radius: 0; padding-top: calc(9px + env(safe-area-inset-top)); }
    .compose-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
    .compose.minimized { inset: auto 0 0 0; }
    .settings-grid { grid-template-columns: 1fr; }
    .toasts { bottom: calc(16px + env(safe-area-inset-bottom)); }
}

@media (max-width: 540px) {
    .login { align-items: start; }
    .login-backdrop { object-position: 76% center; }
    .login::after { background: linear-gradient(180deg, rgb(var(--veil) / 0.97), rgb(var(--veil) / 0.88) 62%, rgb(var(--veil) / 0.25)); }
    .login-inner { width: calc(100% - 40px); padding: calc(36px + env(safe-area-inset-top)) 0 calc(120px + env(safe-area-inset-bottom)); }
    .login-panel .eyebrow { margin: 26px 0 12px; }
    .login-title { font-size: clamp(28px, 8vw, 36px); letter-spacing: -0.045em; }
    .login-card { margin-top: 24px; padding: 22px 18px 18px; }
    .eyebrow::after { width: 80px; }
    .row { padding: 12px 12px 12px 18px; gap: 11px; }
}

/* Écrans très étroits : Galaxy Z Fold5 plié (≈ 344 px) */
@media (max-width: 400px) {
    .list-head { padding-left: 4px; }
    .list-toolbar { padding-left: 14px; gap: 6px; }
    .chip { padding: 0 10px; }
    .row { padding: 12px 10px 12px 16px; gap: 10px; }
    .row .avatar { width: 34px; height: 34px; font-size: 12px; }
    .row-avatar { height: 34px; }
    .compose-fields { padding: 0 12px; }
    .cfield-label { width: 34px; }
    .editor { padding: 14px 14px 24px; }
    .editor-toolbar { padding: 4px 8px; }
}

/* Téléphones : barre de mise en forme sur une seule ligne, défilable */
@media (max-width: 679px) {
    .editor-toolbar, .sig-toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .editor-toolbar > *, .sig-toolbar > * { flex: none; }
    .login-card { padding: 20px 14px 16px; }
    .reader-article { padding: 18px 14px calc(28px + env(safe-area-inset-bottom)); }
    .meta-date { padding-left: 0; }
    .dialog-head { padding: 18px 12px 6px 18px; }
    .dialog-body { padding: 10px 18px 4px; }
    .dialog-foot { padding: 12px 18px 18px; }
}

/* Écrans peu hauts : téléphones en paysage */
@media (max-height: 520px) and (max-width: 1099px) {
    .compose, .compose.maximized { inset: 0; width: auto; height: auto; transform: none; border-radius: 0; border: 0; padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left); }
    .compose-head { border-radius: 0; }
    .list-head { padding-top: 6px; padding-bottom: 4px; }
    .folder-title { font-size: 19px; }
    .search { margin-bottom: 6px; }
    .search input { height: 38px; }
    .list-toolbar { min-height: 42px; }
    .sidebar-head { padding: 12px 20px 10px; }
    .compose-btn { min-height: 40px; margin-bottom: 8px; }
    .folder { height: 40px; }
    .reader-toolbar { min-height: 48px; padding-top: 4px; padding-bottom: 4px; }
    .reader-empty-art { display: none; }
}

/* Barres d'outils selon la largeur réelle du panneau */
@container reader (max-width: 560px) {
    .reader-toolbar .tb-sep, .reader-toolbar [data-act=spam], .reader-toolbar [data-act=unread] { display: none; }
    .reader-toolbar { gap: 0; }
}
@container reader (max-width: 400px) {
    .reader-toolbar [data-act=reply-all], .reader-toolbar [data-act=forward] { display: none; }
}
@container list (max-width: 380px) {
    .bulk-word { display: none; }
    .bulk { gap: 0; }
}
@container list (max-width: 340px) {
    .list-head { gap: 0; }
    .list-head .icon-btn { width: 36px; height: 36px; }
    .folder-title { font-size: 19px; }
}

/* Écrans tactiles : cibles plus grandes, pas de zoom automatique sur iPhone */
@media (pointer: coarse) {
    .icon-btn { width: 42px; height: 42px; }
    .icon-btn.sm { width: 38px; height: 38px; }
    .icon-btn.xs { width: 34px; height: 34px; }
    .input, select.input, textarea.input, .search input, .chip-input, .subject-input { font-size: 16px; }
    .editor { font-size: 16px; }
    .btn { min-height: 44px; }
    .chip { min-height: 36px; }
    .chips .chip { height: 34px; }
    .chip-x { width: 30px; height: 30px; }
    .folder { height: 46px; }
    .folder-more { position: static; opacity: 1; background: none; }
    .folder-row:hover .badge { visibility: visible; }
    .row { padding-top: 14px; padding-bottom: 14px; }
    .star-btn { opacity: 0.8; padding: 6px; margin: -6px -4px -6px 0; }
    .row-ico .icon { width: 15px; height: 15px; }
    .menu-item { padding: 12px 14px; font-size: 15px; }
    .suggest-item { padding: 11px 12px; }
    .att { padding: 10px 10px 10px 12px; }
    .shortcuts-hint { display: none; }
    .list-toolbar, .reader-toolbar, .editor-toolbar { scrollbar-width: none; }
}
@media (pointer: coarse) and (max-width: 400px) {
    .icon-btn { width: 38px; height: 38px; }
}

/* Pas d'effet de survol « collant » après un appui tactile */
@media (hover: none) {
    .btn.primary:hover:not(:disabled), .btn.danger:hover:not(:disabled), .att:hover { transform: none; }
    .row:not(.active):not(.selected):hover { background: transparent; }
    .star-btn:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
