:root {
  --accent: #37beff; --accent-dark: #1a9ad8; --nav: #2f3a3f; --nav-text: #cfd6da;
  --bg: #fff; --panel: #f4f4f4; --border: #dfe3e6; --text: #2c363a; --muted: #737d83;
  --hover: #e9eff2; --selected: #d6eefb; --danger: #d9534f; --star: #f5a623;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.reader .toolbar > .iconbtn { display: none; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: var(--accent-dark); }
h2 { font-size: 17px; margin: 0 0 14px; font-weight: 600; }
.muted { color: var(--muted); }
.grow { flex: 1; min-width: 0; }

/* Boutons et champs */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--border); border-radius: 4px; background: #fff; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .45; cursor: default; }
.tool { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; min-width: 56px; padding: 6px 8px; border: 0; background: none; border-radius: 4px; cursor: pointer; font-size: 11px; color: var(--text); }
.tool:hover { background: var(--hover); }
.tool:disabled { opacity: .35; cursor: default; background: none; }
.tool svg { width: 20px; height: 20px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }

/* Structure */
#app { display: flex; height: 100%; }
.taskbar { width: 78px; background: var(--nav); color: var(--nav-text); display: flex; flex-direction: column; align-items: stretch; padding: 8px 0; flex: none; }
.taskbar .logo { display: flex; justify-content: center; padding: 10px 0 16px; color: var(--accent); }
.taskbar .logo img { width: 38px; height: 38px; display: block; }
.taskbar button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 11px 4px; border: 0; background: none; color: inherit; cursor: pointer; font-size: 11px; }
.taskbar button svg { width: 22px; height: 22px; }
.taskbar button:hover { color: #fff; background: rgba(255,255,255,.06); }
.taskbar button.active { color: var(--accent); background: rgba(0,0,0,.2); }
.taskbar .spacer { flex: 1; }
.view { flex: 1; display: flex; min-width: 0; }
.col { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); }
.col-head { height: 58px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--border); flex: none; }
.col-head .title { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-body { flex: 1; overflow: auto; min-height: 0; }
.col-foot { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); flex: none; }
.sidebar { width: 230px; background: var(--panel); flex: none; }
.listcol { width: 400px; flex: none; }
.content { flex: 1; min-width: 0; border-right: 0; }
.iconbtn { display: inline-flex; padding: 6px; border: 0; background: none; border-radius: 4px; cursor: pointer; color: var(--muted); }
.iconbtn:hover { background: var(--hover); color: var(--text); }
.iconbtn:disabled { opacity: .35; cursor: default; }

/* Dossiers */
.account { font-size: 12px; color: var(--muted); padding: 10px 14px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-wrap { padding: 10px 12px; }
.compose-wrap .btn { width: 100%; justify-content: center; padding: 9px; }
.folders { list-style: none; margin: 0; padding: 0 0 10px; }
.folders li { display: flex; align-items: center; gap: 9px; padding: 8px 14px; cursor: pointer; border-left: 3px solid transparent; }
.folders li:hover { background: var(--hover); }
.folders li.active { background: #fff; border-left-color: var(--accent); color: var(--accent-dark); font-weight: 600; }
.folders li.unread .fname { font-weight: 700; }
.folders li.drop { background: var(--selected); outline: 2px dashed var(--accent); outline-offset: -2px; }
.folders .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--accent); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 7px; }

/* Liste des messages */
.searchbar { position: relative; flex: 1; }
.searchbar svg { position: absolute; left: 8px; top: 8px; color: var(--muted); }
.searchbar input { padding-left: 32px; }
.listbar { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-bottom: 1px solid var(--border); font-size: 12px; flex: none; }
.listbar select { width: auto; padding: 3px 6px; font-size: 12px; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; gap: 8px; padding: 9px 12px 9px 8px; border-bottom: 1px solid #eef1f2; cursor: pointer; border-left: 3px solid transparent; }
.row:hover { background: #f7fafb; }
.row.open { background: var(--selected); border-left-color: var(--accent); }
.row.checked { background: #eaf6fd; }
.row.unseen .who, .row.unseen .subj { font-weight: 700; color: #111; }
.row .cell { display: flex; align-items: flex-start; }
.row .check { margin-top: 3px; }
.row .main { flex: 1; min-width: 0; }
.row .line { display: flex; gap: 8px; align-items: baseline; }
.row .who, .row .subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.row .subj { color: #4d5a60; }
.row .when { font-size: 12px; color: var(--muted); flex: none; }
.row .marks { display: flex; gap: 4px; color: var(--muted); flex: none; align-items: center; }
.row .marks svg { width: 14px; height: 14px; }
.star { color: #c5ccd0; cursor: pointer; background: none; border: 0; padding: 0; display: inline-flex; }
.star.on { color: var(--star); }
.star.on svg { fill: var(--star); }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 54px; height: 54px; stroke-width: 1.2; opacity: .5; display: block; margin: 0 auto 10px; }

/* Lecture */
.toolbar { height: 58px; display: flex; align-items: center; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--border); flex: none; overflow-x: auto; }
.toolbar .sep { width: 1px; height: 30px; background: var(--border); margin: 0 6px; flex: none; }
.msg-head { padding: 16px 22px 12px; border-bottom: 1px solid var(--border); }
.msg-head h1 { font-size: 20px; margin: 0 0 10px; font-weight: 600; word-break: break-word; }
.msg-meta { display: flex; gap: 12px; align-items: flex-start; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex: none; }
.msg-meta .who { font-weight: 600; }
.msg-meta .rcpt { font-size: 12px; color: var(--muted); word-break: break-word; }
.msg-meta .when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.notice { display: flex; align-items: center; gap: 10px; background: #fff8e1; border-bottom: 1px solid #f0e2b0; padding: 8px 22px; font-size: 13px; }
.notice .btn { padding: 3px 10px; font-size: 12px; }
.msg-body { padding: 0; }
.msg-body iframe { width: 100%; border: 0; display: block; min-height: 200px; }
.msg-body pre { margin: 0; padding: 18px 22px; white-space: pre-wrap; word-break: break-word; font: 14px/1.5 "Segoe UI", Roboto, Arial, sans-serif; }
.msg-body pre .quoted { color: #6b7c85; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 22px; border-top: 1px solid var(--border); }
.att { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--panel); text-decoration: none; color: var(--text); max-width: 280px; }
.att:hover { background: var(--hover); }
.att .aname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .asize { font-size: 11px; color: var(--muted); flex: none; }
.att button { border: 0; background: none; cursor: pointer; padding: 0; display: inline-flex; color: var(--muted); }

/* Rédaction */
.compose { padding: 14px 22px 22px; display: flex; flex-direction: column; min-height: 100%; }
.field { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); padding: 4px 0; position: relative; }
.field > label { width: 70px; font-size: 12px; color: var(--muted); flex: none; margin: 0; }
.field input { border: 0; padding: 7px 0; }
/* Champs sans bordure : le focus est signalé par un soulignement. Le contour
   transparent le rend visible en mode de contrastes forcés, où les ombres
   disparaissent. */
.field input:focus { outline: 0; }
.field input:focus-visible { outline: 2px solid transparent; box-shadow: 0 2px 0 var(--accent-dark); }
.field .link { white-space: nowrap; flex: none; font-size: 12px; color: var(--accent-dark); cursor: pointer; background: none; border: 0; }
.compose textarea { flex: 1; min-height: 260px; margin-top: 12px; border: 1px solid var(--border); resize: vertical; font-family: Consolas, "DejaVu Sans Mono", monospace; font-size: 13px; line-height: 1.5; }
.suggest { position: absolute; left: 80px; top: 100%; z-index: 20; background: #fff; border: 1px solid var(--border); box-shadow: 0 4px 14px rgba(0,0,0,.14); border-radius: 4px; min-width: 300px; max-height: 220px; overflow: auto; }
.suggest div { padding: 7px 11px; cursor: pointer; }
.suggest div.sel, .suggest div:hover { background: var(--selected); }

/* Contacts, préférences */
.items { list-style: none; margin: 0; padding: 0; }
.items li { padding: 10px 14px; border-bottom: 1px solid #eef1f2; cursor: pointer; border-left: 3px solid transparent; }
.items li:hover { background: #f7fafb; }
.items li.active { background: var(--selected); border-left-color: var(--accent); }
.items .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form { padding: 20px 26px; max-width: 620px; }
.form .actions { display: flex; gap: 8px; margin-top: 18px; }
.form textarea { min-height: 110px; resize: vertical; }
table.folders-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
table.folders-table td { padding: 7px 6px; border-bottom: 1px solid #eef1f2; }
table.folders-table td.num { text-align: right; color: var(--muted); font-size: 12px; white-space: nowrap; }
table.folders-table td.act { text-align: right; white-space: nowrap; }
.inline { display: flex; gap: 8px; align-items: center; }

/* Menus, notifications */
.menu { position: fixed; z-index: 50; background: #fff; border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 6px 20px rgba(0,0,0,.18); padding: 4px 0; min-width: 190px; max-height: 60vh; overflow: auto; }
.menu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 14px; border: 0; background: none; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--hover); }
.menu .msep { height: 1px; background: var(--border); margin: 4px 0; }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; }
.toast { background: #2f3a3f; color: #fff; padding: 9px 18px; border-radius: 4px; box-shadow: 0 4px 14px rgba(0,0,0,.25); max-width: 80vw; }
.toast.error { background: var(--danger); }
.loading { padding: 30px; text-align: center; color: var(--muted); }

/* Connexion */
.login-page { background: var(--nav); display: flex; align-items: center; justify-content: center; }
.login-box { background: #fff; width: 360px; max-width: calc(100vw - 32px); border-radius: 6px; padding: 30px 32px 22px; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.login-logo { display: block; margin: -6px auto 0; width: 132px; height: auto; }
.login-slogan { text-align: center; color: var(--muted); font-style: italic; margin: 0 0 18px; }
.login-box h1 { text-align: center; font-size: 26px; font-weight: 700; letter-spacing: .01em; margin: 6px 0 2px; }
.login-box .btn { width: 100%; justify-content: center; margin-top: 20px; padding: 10px; }
.login-error { background: #fdecea; color: #a12622; border: 1px solid #f5c6c2; border-radius: 4px; padding: 8px 12px; margin: 0; }
.login-foot { text-align: center; font-size: 12px; color: var(--muted); margin: 18px 0 0; }

@media (max-width: 1100px) { .sidebar { width: 190px; } .listcol { width: 320px; } }
@media (max-width: 760px) {
  .taskbar { width: 54px; } .taskbar button span { display: none; }
  .sidebar { display: none; } .listcol { width: auto; flex: 1; }
  .reader .toolbar > .iconbtn { display: inline-flex; }
  .view.reading .listcol { display: none; } .view:not(.reading) .content.reader { display: none; }
}

/* Sélection multiple : pas de sélection de texte au Maj + clic. */
.row { user-select: none; }

/* Focus clavier des éléments de liste (dossiers, messages, contacts, onglets,
   identités) et du volet de lecture. Contour rentré : ces éléments touchent le
   bord de conteneurs qui rognent ce qui dépasse. */
.folders li:focus-visible, .row:focus-visible, .items li:focus-visible, .reader .col-body:focus-visible {
  outline: 2px solid var(--accent-dark); outline-offset: -2px; }

/* État SPF / DKIM / DMARC */
.auths { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.auth { font-size: 11px; padding: 1px 7px; border-radius: 10px; border: 1px solid; white-space: nowrap; cursor: help; }
.auth.ok { color: #1e7e34; border-color: #a9dbb5; background: #eaf7ed; }
.auth.warn { color: #946200; border-color: #f0d58c; background: #fff8e1; }
.auth.bad { color: #b02a25; border-color: #efb1ae; background: #fdecea; }
.auth.unk { color: var(--muted); border-color: var(--border); background: var(--panel); }

/* Rédaction : choix du format, identité, éditeur HTML */
.toolbar select.fmt { width: auto; padding: 4px 8px; align-self: center; }
.field select { border: 0; padding: 7px 0; background: transparent; flex: 1; min-width: 0; }
.field select:focus { outline: 0; }
.field select:focus-visible { outline: 2px solid transparent; box-shadow: 0 2px 0 var(--accent-dark); }
.rich { flex: 1; display: flex; flex-direction: column; margin-top: 12px; border: 1px solid var(--border); min-height: 260px; }
.ebar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 6px; background: var(--panel); border-bottom: 1px solid var(--border); }
.ebar .sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.ebtn { border: 1px solid transparent; background: none; border-radius: 3px; padding: 3px 8px; cursor: pointer; font-size: 13px; min-width: 28px; }
.ebtn:hover { background: var(--hover); border-color: var(--border); }
.editor { flex: 1; padding: 12px 14px; overflow-wrap: anywhere; line-height: 1.5; min-height: 220px; }
.editor:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.editor blockquote { margin: 6px 0 6px 6px; padding-left: 10px; border-left: 2px solid #c5ccd0; color: #5c6a70; }
.editor a { color: var(--accent-dark); }
.editor .gaufre-sig, .editor .wm-sig { color: var(--muted); }

/* Formulaires */
.form .hint { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.form .checkline { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.form .checkline input { width: auto; }
.items.boxed { border: 1px solid var(--border); border-radius: 4px; max-height: 220px; overflow: auto; }
.tag { display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 400; padding: 0 6px; border-radius: 8px; background: var(--selected); color: var(--accent-dark); }

/* Boîte de dialogue (confirmation, saisie) */
.modal { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: #fff; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.3); padding: 20px 22px 16px; width: 100%; max-width: 420px; }
.dialog p { margin: 0 0 14px; line-height: 1.5; }
.dialog input { width: 100%; margin-bottom: 14px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; }
