/* VibesHosting Mail — trois panneaux (dossiers · liste · lecture), clair et sombre, accent vert */
:root {
  --bg: #f4f6f5; --side: #eceff0; --panel: #ffffff; --panel-2: #f3f5f4; --hover: #f0f3f2; --line: #e3e7e5; --line-2: #d2d8d5;
  --text: #121614; --muted: #66706b; --faint: #98a19c; --accent: #1fa463; --accent-2: #17864f; --accent-soft: #e3f6ec; --accent-ink: #ffffff;
  --sel: #e6f5ec; --unread: #121614; --danger: #d64545; --star: #f0a020; --shadow: 0 18px 50px rgba(16, 24, 20, .14);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; --mono: ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0c0d0e; --side: #101213; --panel: #141617; --panel-2: #1a1d1e; --hover: #1a1e1d; --line: #222628; --line-2: #2e3335;
  --text: #ebeeec; --muted: #939b97; --faint: #69716d; --accent: #34c27a; --accent-2: #5be3a0; --accent-soft: rgba(52,194,122,.14); --accent-ink: #06140c;
  --sel: rgba(52,194,122,.12); --unread: #ffffff; --danger: #ef6b6b; --star: #f2b33d; --shadow: 0 18px 50px rgba(0,0,0,.5); color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0c0d0e; --side: #101213; --panel: #141617; --panel-2: #1a1d1e; --hover: #1a1e1d; --line: #222628; --line-2: #2e3335;
  --text: #ebeeec; --muted: #939b97; --faint: #69716d; --accent: #34c27a; --accent-2: #5be3a0; --accent-soft: rgba(52,194,122,.14); --accent-ink: #06140c;
  --sel: rgba(52,194,122,.12); --unread: #ffffff; --danger: #ef6b6b; --star: #f2b33d; --shadow: 0 18px 50px rgba(0,0,0,.5); color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body, #app { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent-2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: rgba(52,194,122,.3); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border: 1px solid transparent; border-radius: 10px; background: none; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background-color .15s, transform .12s, border-color .15s, filter .15s; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-main { background: var(--accent); color: var(--accent-ink); }
.btn-main:hover:not(:disabled) { filter: brightness(1.06); }
.btn-line { border-color: var(--line-2); }
.btn-line:hover:not(:disabled) { border-color: var(--accent); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: none; color: var(--muted); cursor: pointer; transition: background-color .15s, color .15s; flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--accent); }
.icon-btn.star.on { color: var(--star); }
.i { width: 19px; height: 19px; display: block; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Connexion ---------- */
body:has(.login) { overflow: auto; }
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; overflow: auto;
  background: radial-gradient(1000px 520px at 12% 0%, var(--accent-soft), transparent 60%), radial-gradient(800px 500px at 100% 100%, var(--accent-soft), transparent 60%), var(--bg); }
.login-card { width: min(100%, 400px); padding: 34px 30px 28px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: var(--shadow); animation: rise .45s cubic-bezier(.2,.8,.2,1); }
.login-card .logo { width: 56px; height: 56px; border-radius: 16px; display: block; }
.login-card h1 { margin: 18px 0 4px; font-size: 24px; letter-spacing: -.02em; }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.field { display: grid; gap: 6px; margin-bottom: 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
.input { width: 100%; height: 46px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel-2); transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.check { display: flex; align-items: center; gap: 8px; margin: 2px 0 18px; color: var(--muted); font-size: 13.5px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.login-card .btn-main { width: 100%; height: 46px; border-radius: 12px; font-size: 15px; }
.login-msg { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: 13.5px; text-align: center; }
.login-foot { margin-top: 18px; text-align: center; color: var(--faint); font-size: 12.5px; }

/* ---------- Application ---------- */
.mail { display: grid; grid-template-columns: 236px minmax(300px, 400px) minmax(0, 1fr); height: 100%; }
.side { display: flex; flex-direction: column; min-height: 0; padding: 16px 12px 12px; background: var(--side); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; font-weight: 750; letter-spacing: -.01em; }
.brand img { width: 30px; height: 30px; border-radius: 9px; }
.brand small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 600; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-btn { width: 100%; height: 44px; margin-bottom: 14px; border-radius: 13px; font-size: 14.5px; box-shadow: 0 6px 18px -8px rgba(31,164,99,.7); }
.folders { flex: 1; overflow-y: auto; display: grid; align-content: start; gap: 2px; }
.folder { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 12px; border: 0; border-radius: 10px; background: none; color: var(--muted); text-align: left; cursor: pointer; font-weight: 550; transition: background-color .15s, color .15s; }
.folder:hover { background: var(--hover); color: var(--text); }
.folder.on { background: var(--accent-soft); color: var(--text); }
.folder.on .i { color: var(--accent); }
.folder span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder b { min-width: 22px; padding: 1px 7px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 11.5px; text-align: center; }
.folder-sep { margin: 12px 12px 4px; color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; display: flex; justify-content: space-between; align-items: center; }
.folder-sep button { border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 16px; line-height: 1; }
.side-foot { display: grid; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.quota { font-size: 12px; color: var(--muted); }
.quota .bar { height: 5px; margin-top: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.quota .bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .5s; }
.side-actions { display: flex; gap: 4px; }

.list-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.list-head { display: grid; gap: 10px; padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.list-title { display: flex; align-items: center; gap: 8px; }
.list-title h2 { flex: 1; margin: 0; font-size: 19px; letter-spacing: -.02em; }
.list-title .count { color: var(--muted); font-size: 13px; font-weight: 500; }
.search { position: relative; }
.search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 17px; height: 17px; }
.search input { width: 100%; height: 38px; padding: 0 12px 0 36px; border: 1px solid transparent; border-radius: 11px; background: var(--panel-2); }
.search input:focus { outline: none; border-color: var(--accent); background: var(--panel); }
.chips { display: flex; gap: 6px; }
.chip { height: 28px; padding: 0 12px; border: 1px solid var(--line); border-radius: 99px; background: none; color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.items { flex: 1; overflow-y: auto; }
.item { position: relative; display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background-color .12s; animation: fade .25s ease both; }
.item:hover { background: var(--hover); }
.item.on { background: var(--sel); }
.item.on::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; letter-spacing: .02em; flex: none; }
.item-top { display: flex; align-items: baseline; gap: 8px; }
.item-from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-weight: 550; }
.item-date { color: var(--faint); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.item-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--faint); font-size: 13px; }
.item.unread .item-from, .item.unread .item-subject { color: var(--unread); font-weight: 700; }
.item.unread::after { content: ""; position: absolute; right: 14px; bottom: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.item-icons { display: inline-flex; gap: 4px; color: var(--faint); }
.item-icons .i { width: 14px; height: 14px; }
.item-icons .star { color: var(--star); fill: var(--star); }
.list-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.empty-list { display: grid; place-items: center; gap: 8px; padding: 60px 20px; color: var(--faint); text-align: center; }
.empty-list .i { width: 40px; height: 40px; stroke-width: 1.4; }
.skeleton { height: 64px; margin: 10px 14px; border-radius: 12px; background: linear-gradient(90deg, var(--panel-2), var(--hover), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }

.read-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); }
.read-bar { display: flex; align-items: center; gap: 2px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.read-bar .grow { flex: 1; }
.read-body { flex: 1; overflow-y: auto; padding: 24px 28px 34px; animation: fade .25s ease; }
.read-subject { margin: 0 0 18px; font-size: 22px; line-height: 1.3; letter-spacing: -.02em; font-weight: 750; overflow-wrap: anywhere; }
.read-head { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: start; margin-bottom: 18px; }
.read-head .avatar { width: 44px; height: 44px; font-size: 16px; }
.read-from b { font-weight: 700; }
.read-from span { color: var(--muted); font-size: 13px; }
.read-to { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.read-date { color: var(--faint); font-size: 12.5px; white-space: nowrap; }
.notice { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; padding: 10px 14px; border-radius: 12px; background: var(--panel-2); color: var(--muted); font-size: 13px; }
.frame { width: 100%; min-height: 120px; border: 0; border-radius: 12px; background: #fff; display: block; }
.frame.frame-simple { min-height: 0; border-radius: 0; background: transparent; }
:root:not([data-theme="dark"]) .frame.frame-simple { background: transparent; }
.plain { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.65; margin: 0; font-family: var(--font); }
.atts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.att { display: flex; align-items: center; gap: 10px; max-width: 260px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s; }
.att:hover { border-color: var(--accent); transform: translateY(-1px); }
.att .ext { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-2); font-size: 10.5px; font-weight: 800; text-transform: uppercase; flex: none; }
.att b { display: block; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att small { color: var(--muted); font-size: 12px; }
.reply-bar { display: flex; gap: 8px; margin-top: 24px; }
.placeholder { flex: 1; display: grid; place-items: center; color: var(--faint); text-align: center; padding: 30px; }
.placeholder .big { width: 92px; height: 92px; border-radius: 28px; display: grid; place-items: center; margin: 0 auto 16px; background: var(--accent-soft); color: var(--accent); }
.placeholder .big .i { width: 44px; height: 44px; stroke-width: 1.5; }
.placeholder b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* ---------- Rédaction ---------- */
.composer { position: fixed; right: 24px; bottom: 0; z-index: 30; width: min(640px, calc(100% - 32px)); height: min(640px, calc(100% - 40px)); display: flex; flex-direction: column; border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; background: var(--panel); box-shadow: var(--shadow); animation: up .25s cubic-bezier(.2,.8,.2,1); }
.composer.max { right: 50%; bottom: 50%; transform: translate(50%, 50%); width: min(980px, calc(100% - 40px)); height: calc(100% - 60px); border-radius: 16px; border-bottom: 1px solid var(--line); animation: none; }
.composer.min { height: 48px; overflow: hidden; }
.comp-head { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 18px; border-bottom: 1px solid var(--line); cursor: default; }
.comp-head b { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comp-row { display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.comp-row label { color: var(--faint); font-size: 13px; min-width: 36px; }
.comp-row input { flex: 1; height: 42px; border: 0; background: none; outline: none; min-width: 0; }
.comp-row .link { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.tools { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.tools .icon-btn { width: 32px; height: 32px; border-radius: 8px; }
.tools .sep { width: 1px; margin: 6px 4px; background: var(--line); }
.editor { flex: 1; overflow-y: auto; padding: 16px 18px; outline: none; font-size: 14.5px; line-height: 1.6; overflow-wrap: anywhere; }
.editor:empty::before { content: attr(data-ph); color: var(--faint); }
.editor blockquote { margin: 10px 0; padding-left: 12px; border-left: 3px solid var(--line-2); color: var(--muted); }
.comp-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 10px; }
.comp-file { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px 0 12px; border: 1px solid var(--line); border-radius: 99px; font-size: 12.5px; max-width: 240px; }
.comp-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comp-file button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; width: 22px; }
.comp-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.comp-foot .grow { flex: 1; }
.comp-msg { color: var(--danger); font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 60; max-width: calc(100% - 32px); padding: 11px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 600; box-shadow: var(--shadow); transform: translate(-50%, 160%); opacity: 0; transition: transform .22s cubic-bezier(.2,.8,.2,1), opacity .22s; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.menu { position: fixed; z-index: 50; min-width: 200px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); animation: fade .15s ease; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.menu button:hover { background: var(--hover); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.back-btn { display: none; }
/* Tablette : dossiers repliés en icônes */
@media (max-width: 1180px) {
  .mail { grid-template-columns: 72px minmax(280px, 360px) minmax(0, 1fr); }
  .side { padding: 14px 10px; align-items: center; }
  .brand span, .folder span, .folder-sep, .quota, .compose-btn span { display: none; }
  .brand { padding: 2px 0 14px; }
  .compose-btn { width: 48px; height: 48px; padding: 0; border-radius: 14px; }
  .folder { justify-content: center; padding: 10px; position: relative; }
  .folder b { position: absolute; top: 2px; right: 2px; min-width: 18px; padding: 0 5px; font-size: 10.5px; }
  .side-actions { flex-direction: column; }
}
/* Téléphone : un panneau à la fois */
@media (max-width: 760px) {
  .mail { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .side { grid-row: 2; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); border-right: 0; border-top: 1px solid var(--line); align-items: center; }
  .brand, .side-foot .quota { display: none; }
  .folders { display: flex; flex: 1; overflow-x: auto; gap: 2px; }
  .folder { width: auto; flex: none; }
  .compose-btn { position: fixed; right: 16px; bottom: 76px; z-index: 20; width: 56px; height: 56px; margin: 0; border-radius: 18px; }
  .side-foot { border: 0; padding: 0; }
  .side-actions { flex-direction: row; }
  .list-pane, .read-pane { grid-row: 1; border-right: 0; }
  .mail.reading .list-pane, .mail:not(.reading) .read-pane { display: none; }
  .back-btn { display: inline-grid; }
  .read-body { padding: 18px 16px 28px; }
  .composer, .composer.max { inset: 0; right: 0; bottom: 0; transform: none; width: 100%; height: 100%; border-radius: 0; }
}

/* Plusieurs comptes */
.acc-switch { width: 100%; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 12px; padding: 6px 8px; margin: -4px 0 12px; transition: background-color .15s; }
.acc-switch:hover { background: var(--hover); }
.acc-switch .avatar { width: 32px; height: 32px; font-size: 12.5px; flex: none; }
.acc-switch span { flex: 1; min-width: 0; }
.acc-switch .chev { width: 16px; height: 16px; color: var(--faint); flex: none; }
.acc-menu { min-width: 280px; max-width: calc(100vw - 16px); }
.acc-menu .menu-title { margin: 4px 10px 6px; color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.acc-menu .avatar { width: 28px; height: 28px; font-size: 11.5px; }
.acc-menu button.on { background: var(--accent-soft); }
.acc-mail { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-n { min-width: 22px; padding: 1px 7px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 11.5px; text-align: center; }
.acc-on { color: var(--accent); font-size: 12px; font-weight: 600; }
.acc-menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.acc-menu .i { width: 17px; height: 17px; color: var(--muted); }
.login-overlay { position: fixed; inset: 0; z-index: 70; min-height: 100%; background: rgba(0,0,0,.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.login-overlay .login-card { position: relative; }
.login-close { position: absolute; top: 14px; right: 14px; }
@media (max-width: 1180px) { .acc-switch span, .acc-switch .chev { display: none; } .acc-switch { width: auto; padding: 4px; margin: 0 0 12px; } }
@media (max-width: 760px) { .acc-switch { margin: 0; } }

/* Raccourcis clavier dans le panneau de lecture vide */
.kbd-hints { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; font-size: 12px; color: var(--muted); }
.kbd-hints span { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.kbd-hints kbd { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--accent); }

.pw-wrap { position: relative; display: block; width: 100%; }
.pw-wrap > .input { width: 100%; padding-right: 76px; }
.pw-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); font: 600 12px/1 system-ui, sans-serif; padding: 5px 7px; border-radius: 6px; cursor: pointer; }
.pw-eye:hover { color: var(--text); background: var(--panel-2, rgba(255,255,255,.06)); }
