/* CybsinMail — thème sombre gris-bleu, gros caractères, coins arrondis */
:root {
  --bg: #121a28; --panel: #182235; --panel2: #1e2a40; --chip: #22304a; --line: #2a3852; --line2: #34466a;
  --text: #eef3fb; --muted: #b6c2d6; --accent: #6f9bff; --onAccent: #0b1220; --sel: #26395e;
  --danger: #ff9b93; --ok: #5fd3a0; --okBg: #173d31; --drive: #1f5c47;
  --radius: 20px;
}
* { box-sizing: border-box; }
html { font-size: 18px; }
html.t0 { font-size: 16px; } html.t1 { font-size: 18px; } html.t2 { font-size: 20px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Figtree, system-ui, -apple-system, 'Segoe UI', sans-serif; line-height: 1.4; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }
svg.i { width: 1.15em; height: 1.15em; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Boutons */
.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 2.6rem; padding: 0 1rem; border: none; border-radius: 14px; background: var(--chip); color: var(--text); font-weight: 600; white-space: nowrap; }
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--accent); color: var(--onAccent); font-weight: 700; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border: 2px solid var(--line); }
.btn.drive { background: var(--drive); color: #d9f5ea; }
.btn.big { min-height: 3rem; padding: 0 1.4rem; }
.btn[disabled] { opacity: .5; cursor: default; }
.iconbtn { width: 2.8rem; height: 2.8rem; padding: 0; border: 2px solid var(--line); border-radius: 16px; background: var(--panel2); display: inline-flex; align-items: center; justify-content: center; color: var(--text); }

/* Écrans de connexion */
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.card { width: 100%; max-width: 30rem; background: var(--panel); border-radius: 24px; padding: 2rem; display: flex; flex-direction: column; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .6rem; font-family: 'Bricolage Grotesque', Figtree, sans-serif; font-weight: 700; font-size: 1.35rem; }
.logo { width: 2.4rem; height: 2.4rem; border-radius: 13px; background: var(--accent); color: var(--onAccent); display: flex; align-items: center; justify-content: center; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--muted); }
.input { min-height: 3rem; padding: 0 1rem; border: 2px solid var(--line2); border-radius: 14px; background: var(--bg); color: var(--text); width: 100%; }
textarea.input { padding: .8rem 1rem; }
select.input { padding: 0 .8rem; }
.error { color: var(--danger); font-weight: 600; min-height: 1.4em; }
.hint { color: var(--muted); font-size: .9rem; }
.qr { background: #fff; border-radius: 16px; padding: 12px; align-self: center; }

/* Mise en page principale */
#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: .9rem; height: 4.2rem; padding: 0 1rem; flex-shrink: 0; }
.top .brand { width: 16.5rem; flex-shrink: 0; }
.search { flex: 1; display: flex; align-items: center; gap: .6rem; min-height: 2.8rem; padding: 0 1rem; border-radius: 16px; background: var(--panel2); border: 2px solid var(--line); color: var(--muted); }
.search input { flex: 1; border: none; outline: none; background: transparent; color: var(--text); min-width: 0; }
.sizer { display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 16px; background: var(--panel2); border: 2px solid var(--line); }
.sizer button { width: 2.5rem; height: 2.2rem; border: none; border-radius: 12px; background: transparent; font-weight: 700; }
.sizer span { min-width: 5.5rem; text-align: center; font-size: .85rem; font-weight: 600; color: var(--muted); }

.panes { flex: 1; min-height: 0; display: flex; gap: .7rem; padding: 0 .7rem .7rem; }
.pane { background: var(--panel); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.nav { width: 18rem; flex-shrink: 0; overflow-y: auto; padding: .5rem .45rem; }
.list { width: 40rem; flex-shrink: 1; min-width: 26rem; }
.reader { flex: 1; min-width: 0; }

/* Arborescence */
.acct { display: flex; align-items: center; gap: .55rem; width: 100%; min-height: 2.6rem; margin-top: .45rem; padding: 0 .6rem; border: none; border-radius: 12px; background: transparent; font-weight: 700; text-align: left; letter-spacing: .02em; }
.dot { width: .8rem; height: .8rem; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.fold { display: flex; align-items: center; gap: .55rem; width: 100%; min-height: 2.4rem; padding: 0 .6rem; border: none; border-radius: 12px; background: transparent; text-align: left; font-weight: 500; }
.fold:hover, .acct:hover { background: rgba(255,255,255,.04); }
.fold.on { background: var(--sel); font-weight: 700; }
.fold .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fold .chev { width: 1.1rem; display: inline-flex; color: var(--muted); }
.count { font-size: .85rem; font-weight: 700; color: var(--accent); }
.warn { font-size: .75rem; font-weight: 700; color: var(--danger); }
.navfoot { margin-top: 1rem; padding: .5rem; }

/* Liste */
.listhead { display: flex; align-items: center; gap: .7rem; padding: .9rem 1.1rem .6rem; }
.listhead h1 { margin: 0; flex: 1; font-family: 'Bricolage Grotesque', Figtree, sans-serif; font-weight: 700; font-size: 1.3rem; display: flex; align-items: center; gap: .5rem; min-width: 0; }
.listhead h1 span.t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cols { display: flex; gap: .8rem; padding: .45rem 1.1rem; border-top: 2px solid var(--line); border-bottom: 2px solid var(--line); font-size: .8rem; font-weight: 700; color: var(--muted); }
.cols .c1 { width: 2.3rem; } .cols .c2 { width: 11rem; } .cols .c3 { flex: 1; } .cols .c4 { width: 5.5rem; text-align: right; }
.rows { flex: 1; overflow-y: auto; padding: .3rem .45rem .6rem; }
.grp { padding: .7rem .7rem .2rem; font-size: .75rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.row { display: flex; align-items: center; gap: .8rem; width: 100%; min-height: 3.3rem; padding: .45rem .7rem; margin-bottom: 2px; border: none; border-radius: 14px; background: transparent; text-align: left; }
.row:hover { background: rgba(255,255,255,.04); }
.row.on { background: var(--sel); }
.av { position: relative; width: 2.3rem; height: 2.3rem; border-radius: 50%; flex-shrink: 0; color: var(--onAccent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; }
.av .u { position: absolute; top: -3px; left: -3px; width: .8rem; height: .8rem; border-radius: 50%; background: #fff; border: 3px solid var(--panel); }
.row .from { width: 11rem; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .subj { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .subj .p { color: var(--muted); }
.row .when { width: 5.5rem; flex-shrink: 0; text-align: right; font-size: .88rem; color: var(--muted); }
.row.unread .from, .row.unread .subj .s, .row.unread .when { font-weight: 700; color: var(--text); }
.row .clip { color: var(--muted); display: inline-flex; }
.more { margin: .6rem auto; display: flex; }
.empty { padding: 3rem 1.5rem; text-align: center; color: var(--muted); }

/* Lecture */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; padding: .8rem 1.1rem; border-bottom: 2px solid var(--line); }
.actions .sp { flex: 1; }
.readbody { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; padding: 1.2rem 1.6rem 1.6rem; gap: 1rem; }
.readbody h2 { margin: 0; font-family: 'Bricolage Grotesque', Figtree, sans-serif; font-weight: 700; font-size: 1.45rem; line-height: 1.25; }
.sender { display: flex; align-items: center; gap: .8rem; padding-bottom: 1rem; border-bottom: 2px solid var(--line); }
.sender .av { width: 3rem; height: 3rem; font-size: .95rem; }
.sender .who { flex: 1; min-width: 0; }
.sender .who b { font-size: 1.05rem; }
.sender .who div { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.sender .date { color: var(--muted); font-size: .88rem; text-align: right; }
.atts { display: flex; flex-wrap: wrap; gap: .6rem; }
.att { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem .55rem .8rem; border: 2px solid var(--line); border-radius: 16px; max-width: 100%; }
.att .ic { width: 2.2rem; height: 2.2rem; border-radius: 12px; background: var(--chip); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.att .nm { display: flex; flex-direction: column; min-width: 0; margin-right: .3rem; }
.att .nm b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 16rem; }
.att .nm span { font-size: .8rem; color: var(--muted); }
.mailframe { flex: 1; min-height: 24rem; width: 100%; border: none; border-radius: 16px; background: #fff; }

/* Rédaction */
.overlay { position: fixed; inset: 0; background: rgba(5,9,16,.72); display: flex; align-items: center; justify-content: center; padding: 1.2rem; z-index: 20; }
.dialog { width: 100%; max-width: 62rem; max-height: 100%; display: flex; flex-direction: column; background: var(--panel); border-radius: 24px; overflow: hidden; }
.dialog.small { max-width: 32rem; }
.dhead { display: flex; align-items: center; gap: .7rem; padding: 1rem 1.3rem; border-bottom: 2px solid var(--line); }
.dhead h2 { margin: 0; flex: 1; font-family: 'Bricolage Grotesque', Figtree, sans-serif; font-size: 1.3rem; }
.dbody { flex: 1; min-height: 0; overflow-y: auto; padding: 1rem 1.3rem; display: flex; flex-direction: column; gap: .7rem; }
.dfoot { display: flex; align-items: center; gap: .6rem; padding: .9rem 1.3rem; border-top: 2px solid var(--line); }
.dfoot .sp { flex: 1; }
.cline { display: flex; align-items: center; gap: .7rem; }
.cline > span { width: 4.2rem; flex-shrink: 0; font-weight: 600; color: var(--muted); }
.tools { display: flex; gap: .35rem; flex-wrap: wrap; }
.tools button { min-width: 2.6rem; height: 2.4rem; border: none; border-radius: 10px; background: var(--chip); font-weight: 700; }
.editor { min-height: 14rem; padding: 1rem; border: 2px solid var(--line2); border-radius: 16px; background: var(--bg); outline: none; line-height: 1.55; overflow-wrap: anywhere; }
.editor:empty::before { content: attr(data-ph); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .4rem; min-height: 2.2rem; padding: 0 .4rem 0 .8rem; border-radius: 12px; background: var(--chip); font-size: .9rem; }
.chip button { width: 1.8rem; height: 1.8rem; border: none; border-radius: 8px; background: transparent; color: var(--danger); }
.sigprev { display: flex; align-items: flex-start; gap: .8rem; }
.sigprev img { background: #fff; border-radius: 10px; padding: 6px; max-width: 100%; }
.check { display: flex; align-items: center; gap: .6rem; min-height: 2.6rem; }
.check input { width: 1.4rem; height: 1.4rem; }
.quoteinfo { color: var(--muted); font-size: .9rem; border-left: 3px solid var(--line2); padding-left: .8rem; }
.pick { display: flex; flex-direction: column; gap: 2px; }
.pick .fold { min-height: 2.8rem; }

/* Réglages */
.settings { flex: 1; min-height: 0; display: flex; gap: .7rem; padding: 0 .7rem .7rem; }
.stabs { width: 18rem; flex-shrink: 0; padding: .7rem .5rem; gap: 4px; }
.stab { display: flex; align-items: center; gap: .7rem; min-height: 2.9rem; padding: 0 .8rem; border: none; border-radius: 14px; background: transparent; text-align: left; font-weight: 500; }
.stab.on { background: var(--sel); font-weight: 700; }
.scontent { flex: 1; min-width: 0; overflow-y: auto; padding: 1.5rem 2rem; }
.scontent h2 { margin: 0 0 .3rem; font-family: 'Bricolage Grotesque', Figtree, sans-serif; font-size: 1.45rem; }
.scontent > p { margin: 0 0 1.3rem; color: var(--muted); }
.box { border: 2px solid var(--line); border-radius: 18px; padding: 1.1rem 1.2rem; margin-bottom: .9rem; max-width: 70rem; }
.boxrow { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.boxrow .grow { flex: 1; min-width: 12rem; }
.pill { display: inline-flex; align-items: center; gap: .4rem; min-height: 1.9rem; padding: 0 .8rem; border-radius: 1rem; font-size: .82rem; font-weight: 700; }
.pill.ok { background: var(--okBg); color: #a9f0d1; }
.pill.ko { background: #3d1f22; color: var(--danger); }
.sigs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; margin-top: 1rem; }
.sigs .img { background: #fff; border-radius: 14px; padding: 12px; min-height: 8rem; display: flex; align-items: flex-start; }
.sigs .img img { max-width: 100%; }
.rulegrid { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
.rulelist { flex: 1; min-width: 20rem; display: flex; flex-direction: column; gap: .6rem; }
.ruleform { width: 32rem; max-width: 100%; display: flex; flex-direction: column; gap: .9rem; padding: 1.2rem; border-radius: 20px; background: var(--panel2); }
.two { display: flex; gap: .6rem; }
.two > * { flex: 1; }
.toggle { width: 3rem; height: 1.75rem; border-radius: 1rem; border: none; position: relative; flex-shrink: 0; background: #3a4660; }
.toggle.on { background: #3f7a63; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: calc(1.75rem - 6px); height: calc(1.75rem - 6px); border-radius: 50%; background: #fff; transition: left .15s; }
.toggle.on::after { left: calc(100% - 1.75rem + 3px); }
.acctchips { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.acctchips button { display: inline-flex; align-items: center; gap: .5rem; min-height: 2.6rem; padding: 0 1rem; border: 2px solid var(--line); border-radius: 1.3rem; background: transparent; font-weight: 500; }
.acctchips button.on { border-color: var(--accent); background: var(--sel); font-weight: 700; }

.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: #0b1220; border: 2px solid var(--line2); padding: .8rem 1.2rem; border-radius: 16px; font-weight: 600; z-index: 40; max-width: 90vw; }
.toast.bad { border-color: var(--danger); color: var(--danger); }
.spin { display: inline-block; width: 1.2rem; height: 1.2rem; border: 3px solid var(--line2); border-top-color: var(--accent); border-radius: 50%; animation: s 0.8s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }
.mobonly { display: none !important; }

/* ---------- Écrans moyens ---------- */
@media (max-width: 1400px) {
  .list { width: 34rem; min-width: 22rem; }
  .row .from, .cols .c2 { width: 9rem; }
}
/* ---------- Téléphone : un seul panneau à la fois ---------- */
@media (max-width: 900px) {
  .mobonly { display: inline-flex !important; }
  .deskonly { display: none !important; }
  .top { height: auto; padding: calc(env(safe-area-inset-top) + .6rem) .8rem .6rem; flex-wrap: wrap; gap: .5rem; }
  .top .brand { width: auto; flex: 1; }
  .top .search { order: 3; flex-basis: 100%; }
  .panes, .settings { padding: 0; gap: 0; }
  .pane { border-radius: 0; }
  .nav, .list, .reader, .stabs, .scontent { width: 100%; min-width: 0; flex: 1; }
  #app[data-screen="nav"] .list, #app[data-screen="nav"] .reader,
  #app[data-screen="list"] .nav, #app[data-screen="list"] .reader,
  #app[data-screen="read"] .nav, #app[data-screen="read"] .list { display: none; }
  #app[data-screen="read"] .top, #app[data-screen="list"] .top .sizer { display: none; }
  .nav { padding: .4rem .6rem calc(env(safe-area-inset-bottom) + 1rem); }
  .fold { min-height: 3rem; }
  .cols { display: none; }
  .row { align-items: flex-start; flex-wrap: wrap; padding: .7rem; background: var(--panel2); margin-bottom: .4rem; border-radius: 16px; }
  .row .from { width: auto; flex: 1; }
  .row .when { width: auto; }
  .row .from { order: 1; } .row .when { order: 2; } .row .subj { order: 3; } .row .clip { display: none; }
  .row .subj { flex-basis: 100%; margin-top: -.85rem; padding-left: 3.1rem; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .sender { flex-wrap: wrap; } .sender .date { flex-basis: 100%; text-align: left; }
  .att { flex-wrap: wrap; width: 100%; } .att .nm { flex: 1 1 calc(100% - 3.5rem); } .att .btn { flex: 1; } .att .nm b { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .actions.desk { display: none; }
  .mobbar { display: flex !important; justify-content: space-around; padding: .5rem .3rem calc(env(safe-area-inset-bottom) + .5rem); background: var(--panel2); }
  .mobbar button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; border: none; background: transparent; font-size: .7rem; font-weight: 600; padding: .2rem 0; }
  .mobbar button svg.i { width: 1.6rem; height: 1.6rem; }
  .readbody { padding: 1rem; }
  .mobhead { display: flex !important; align-items: center; gap: .3rem; padding: calc(env(safe-area-inset-top) + .4rem) .4rem .3rem; }
  .mobhead button { border: none; background: transparent; color: var(--accent); font-weight: 700; display: inline-flex; align-items: center; min-height: 2.8rem; }
  .newfab { display: flex !important; margin: .4rem .8rem calc(env(safe-area-inset-bottom) + .6rem); }
  .overlay { padding: 0; }
  .dialog { border-radius: 0; height: 100%; max-height: none; }
  .dhead { padding-top: calc(env(safe-area-inset-top) + 1rem); }
  .dfoot { padding-bottom: calc(env(safe-area-inset-bottom) + .9rem); }
  .sigs { grid-template-columns: 1fr; }
  .stabs { flex: none; flex-direction: row !important; overflow-x: auto; }
  .stab { white-space: nowrap; }
  .scontent { padding: 1rem; }
}
.mobbar, .mobhead, .newfab { display: none !important; }
@media (max-width: 900px) { .mobbar, .mobhead, .newfab { display: flex !important; } }
