/* Nakria Mail — nouvelle direction artistique. Se charge après nakria-ui.css (couleurs, police, animations).
   Mail porte la teinte rose du module ; le violet reste l'accent d'action. */

:root {
  --mail: #FFD6E3; --mail-soft: #FFEAF1; --mail-d: #FF8FB1;
  --line-2: #D8C9AE;
  --danger: #D6336C;
  color-scheme: light;
}

html, body { height: 100%; }
body { font-size: 15px; line-height: 1.5; overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { text-decoration: none; }
h1, h2, .brand, .avatar, .btn, .section { font-synthesis: none; }

/* --- Boutons ------------------------------------------------------------- */
.btn { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); box-shadow: 0 3px 0 var(--line); padding: 9px 18px; font: 700 14px/1.2 var(--font-b); }
.btn:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--ink); box-shadow: 0 3px 0 var(--line), 0 12px 16px -8px rgba(34, 27, 58, .22); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.btn-primary { --rel: 4px; background: var(--acc); color: #fff; border-color: transparent; box-shadow: 0 4px 0 var(--acc-d); }
.btn-primary:hover:not(:disabled) { background: var(--acc); border-color: transparent; box-shadow: 0 4px 0 var(--acc-d), 0 14px 18px -8px rgba(108, 77, 255, .4); }
.btn-primary:active:not(:disabled) { box-shadow: 0 2px 0 var(--acc-d); }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 4px 2px; color: var(--soft); font-size: 13.5px; font-weight: 600; }
.link:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.link.danger:hover { color: var(--danger); }
.icon-btn { background: none; border: 0; font-size: 20px; line-height: 1; padding: 8px; color: var(--soft); border-radius: 50%; }
.icon-btn:hover { color: var(--ink); background: var(--mail-soft); }
.form-error { margin: 0; font-size: 14px; font-weight: 600; color: var(--danger); }
/* « Externe » : pastille sans point */
.chip::before { display: none; }
.chip { padding: 6px 11px; background: var(--lemon); border-color: transparent; color: var(--ink); }

/* --- Démarrage ------------------------------------------------------------ */
.boot { position: fixed; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; color: var(--soft); }
.boot p { text-align: center; padding: 0 24px; }
.boot-logo { animation: spin 6s linear infinite; filter: drop-shadow(0 8px 14px rgba(34, 27, 58, .16)); }

/* --- Structure ------------------------------------------------------------ */
.app { display: grid; grid-template-columns: 372px minmax(0, 1fr); height: 100%; height: 100dvh; }
.side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--card); }
.pane { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.side-top { padding: 16px 18px 0; }
.hub { display: inline-block; padding: 4px 0; font-size: 13.5px; font-weight: 600; color: var(--soft); }
.hub:hover { color: var(--ink); }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 18px 16px; }
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; font: 400 22px/1 var(--font-d); }
.brand img { width: 30px; height: 30px; }
.brand b { font-weight: 400; color: var(--soft); }
.side-head .btn { padding: 9px 16px; font-size: 13.5px; white-space: nowrap; flex: none; }

.search { padding: 0 18px 10px; }
.search input { width: 100%; padding: 11px 16px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--bg); font-size: 14px; transition: border-color .2s, background .2s; }
.search input::placeholder { color: var(--soft); }
.search input:focus { border-color: var(--acc); background: var(--card); outline: none; }

/* --- Sections : slider (même principe que la page du compte) -------------- */
.sections { --slide: cubic-bezier(.3, 1.25, .5, 1); position: relative; isolation: isolate; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0 18px 12px; padding: 5px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; }
.sections::before { content: ''; position: absolute; z-index: 0; top: 5px; bottom: 5px; left: 5px; width: calc((100% - 10px) / 3); border-radius: 999px; background: var(--ink); box-shadow: 0 8px 16px -8px rgba(34, 27, 58, .55); transition: transform .5s var(--slide); }
.sections:has(.section:nth-child(2).on)::before { transform: translateX(100%); }
.sections:has(.section:nth-child(3).on)::before { transform: translateX(200%); }
.section { position: relative; z-index: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 3px; background: none; border: 0; border-radius: 999px; padding: 10px 2px; color: var(--soft); font: 700 12px/1.1 var(--font-b); white-space: nowrap; transition: color .3s var(--ease); }
.section:hover { color: var(--ink); }
.section.on, .section.on:hover { color: #fff; }
.section:focus-visible { outline-offset: -3px; }
.badge { display: inline-block; min-width: 17px; padding: 1px 5px; margin-left: 0; border-radius: 999px; background: var(--acc); color: #fff; font: 700 11px/1.3 var(--font-b); text-align: center; flex: none; }
.badge.quiet { background: transparent; border: 1px solid var(--line-2); color: var(--soft); padding: 1px 5px; }
.section.on .badge.quiet { border-color: rgba(255, 255, 255, .5); color: #fff; }
/* Sans :has() (très vieux navigateurs) : la pastille active se colore directement */
@supports not selector(:has(*)) { .sections::before { display: none; } .section.on { background: var(--ink); } }

/* --- Liste des conversations ---------------------------------------------- */
.convs { list-style: none; margin: 0; padding: 6px 10px; overflow-y: auto; flex: 1; min-height: 0; }
.conv { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; column-gap: 12px; align-items: center; width: 100%; text-align: left; background: none; border: 0; border-radius: 18px; padding: 10px; transition: background .2s, transform .25s var(--ease); }
.conv:hover { background: var(--mail-soft); }
.conv[aria-current="true"] { background: var(--mail); }
.conv-name { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.conv-name > span:not(.tag) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.conv-time { font-size: 12px; color: var(--soft); white-space: nowrap; }
.conv-prev { grid-column: 2; margin: 1px 0 0; font-size: 13.5px; color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-dot { grid-column: 3; justify-self: end; }
.conv.unread .conv-name > span:not(.tag) { font-weight: 700; }
.conv.unread .conv-prev { color: var(--ink); font-weight: 500; }
.pill { min-width: 20px; padding: 2px 7px; border-radius: 999px; background: var(--acc); color: #fff; font: 700 12px/1.35 var(--font-b); text-align: center; }
.empty { margin: 0; padding: 28px 24px; color: var(--soft); font-size: 14.5px; line-height: 1.6; white-space: pre-line; text-wrap: pretty; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
.me-address { font-size: 12.5px; color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-links { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.side-links form { margin: 0; flex: none; }
.side-links a.link:hover { text-decoration: underline; }

/* Avatars : initiales sur les pastels de la charte */
.avatar { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font: 400 17px/1 var(--font-d); color: var(--ink); flex: none; }
.av0 { background: var(--sky); } .av1 { background: var(--mint); } .av2 { background: var(--lilac); }
.av3 { background: var(--peach); } .av4 { background: var(--lemon); } .av5 { background: var(--pink); }

/* --- Volet conversation --------------------------------------------------- */
.pane-empty { margin: auto; max-width: 400px; padding: 24px; text-align: center; color: var(--soft); }
.pane-empty img { margin: 0 auto; animation: bob 6s ease-in-out infinite; filter: drop-shadow(0 12px 18px rgba(34, 27, 58, .14)); }
.pane-empty h1 { margin: 22px 0 10px; font: 400 clamp(32px, 4vw, 44px)/1.05 var(--font-d); color: var(--ink); }
.pane-empty p { line-height: 1.65; font-size: 16px; }

.thread { display: flex; flex-direction: column; flex: 1; min-height: 0; position: relative; }
.thread-head { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--card); }
.thread-head .avatar { width: 40px; height: 40px; font-size: 15px; }
.th-id { min-width: 0; flex: 1; }
.th-id h2 { font: 400 22px/1.15 var(--font-d); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-id p { margin: 1px 0 0; font-size: 12.5px; color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-actions { display: flex; gap: 14px; }
.back { display: none; margin-left: -8px; }

.msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 20px 10px; display: flex; flex-direction: column; }
.msgs:focus { outline: none; }
.older { align-self: center; margin-bottom: 14px; }
.day { align-self: center; margin: 18px 0 10px; padding: 4px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--soft); }
.msg { display: flex; flex-direction: column; max-width: min(640px, 78%); margin-top: 3px; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.msg.first { margin-top: 12px; }
.bubble { padding: 10px 16px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); overflow-wrap: anywhere; }
.mine .bubble { background: var(--acc); color: #fff; border-color: transparent; border-bottom-right-radius: 7px; }
.theirs .bubble { border-bottom-left-radius: 7px; }
.subj { margin: 0 0 3px; font-size: 12.5px; font-weight: 600; opacity: .7; }
.text { margin: 0; white-space: pre-wrap; }
.mine .bubble a { text-decoration: underline; }
.meta { margin: 3px 6px 0; font-size: 12px; color: var(--soft); }
.meta .bad { color: var(--danger); font-weight: 600; }

.jump { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); padding: 9px 18px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); font-size: 13.5px; font-weight: 700; box-shadow: 0 10px 24px rgba(34, 27, 58, .14); }

.composer-wrap { padding: 10px 20px calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 8px; }
.composer { display: flex; align-items: flex-end; gap: 10px; }
.composer textarea { flex: 1; min-width: 0; min-height: 46px; resize: none; max-height: 190px; padding: 12px 18px; border-radius: 24px; border: 1.5px solid var(--line); background: var(--card); line-height: 1.45; transition: border-color .2s; }
.composer textarea:focus { outline: none; border-color: var(--acc); }
.composer textarea::placeholder { color: var(--soft); }
.composer .btn { padding: 12px 22px; }

/* --- Fenêtres (nouveau message, contact, dossier) ------------------------- */
.dialog { overflow: visible; width: min(440px, calc(100vw - 32px)); padding: 28px; border: 0; border-radius: 28px; background: var(--card); color: var(--ink); box-shadow: 0 30px 70px rgba(34, 27, 58, .3); }
.dialog[open] { animation: pop .45s var(--ease); }
.dialog::backdrop { background: rgba(34, 27, 58, .45); }
.dialog h2 { margin: 0 0 18px; font: 400 30px/1.1 var(--font-d); }
.dialog label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 600; color: var(--soft); }
.dialog input:not(.nk-date-text):not(.nk-search) { width: 100%; padding: 12px 16px; border-radius: var(--r2); border: 1.5px solid var(--line); background: var(--bg); font-size: 15.5px; transition: border-color .2s, box-shadow .2s, background .2s; }
.dialog input:not(.nk-date-text):not(.nk-search):hover { border-color: #D8C9AE; }
.dialog input:not(.nk-date-text):not(.nk-search):focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 4px rgba(108, 77, 255, .16); background: #fff; }
.hint { margin: 10px 0 0; font-size: 13px; color: var(--soft); line-height: 1.55; }
.hint b { font-weight: 700; color: var(--ink); }
.dialog .form-error { margin-top: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.dialog label.gap { margin-top: 14px; }

/* --- Dossiers, contacts, abonnements -------------------------------------- */
.chips { display: flex; gap: 6px; padding: 2px 18px 10px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px; border: 1.5px solid var(--line); background: none; color: var(--soft); font-size: 13px; font-weight: 600; line-height: 1.2; white-space: nowrap; transition: background .2s, border-color .2s, color .2s; }
.chip-btn:hover { color: var(--ink); border-color: var(--line-2); }
.chip-btn[aria-pressed="true"] { color: var(--ink); border-color: var(--ink); background: var(--mail-soft); }
.chip-btn .n { font-size: 11.5px; color: var(--acc); font-weight: 700; }
.chip-btn.add { border-style: dashed; }
.folder-tools { display: flex; gap: 14px; padding: 0 18px 8px; }
.intro { padding: 12px 18px 4px; }
.intro p { font-size: 13.5px; line-height: 1.55; color: var(--soft); }
.contacts-bar { padding: 4px 18px 10px; }
.contacts-bar .btn { padding: 8px 16px; font-size: 13.5px; }

.contacts-view { flex: 1; min-height: 0; overflow-y: auto; }
.contacts-view .convs { overflow: visible; padding-bottom: 0; }
.letter { padding: 14px 18px 4px; font: 400 15px/1 var(--font-d); color: var(--acc); }
.contact { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px; border-radius: 18px; transition: background .2s; }
.contact:hover { background: var(--mail-soft); }
.contact .open { display: grid; grid-template-columns: 44px minmax(0, 1fr); column-gap: 12px; align-items: center; text-align: left; background: none; border: 0; padding: 8px 10px; min-width: 0; }
.contact .who { min-width: 0; }
.contact .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact .who .sub { font-size: 12.5px; color: var(--soft); }
.contact .row-actions { display: flex; gap: 10px; padding-right: 10px; }
.blocked { padding: 14px 18px 20px; border-top: 1px solid var(--line); margin-top: 10px; }
.blocked h3 { margin: 0 0 8px; font: 400 16px/1.3 var(--font-d); color: var(--soft); }
.blocked-list { list-style: none; margin: 0; padding: 0; }
.blocked-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 13.5px; }
.blocked-list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--soft); }

/* Lignes de conversation : épingle et étiquettes */
.conv-name .pin { flex: none; width: 13px; height: 13px; align-self: center; fill: none; stroke: var(--acc); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tag { flex: none; align-self: center; white-space: nowrap; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 1.4; background: var(--lemon); color: var(--ink); }
.tag.warn { background: #FFD9E4; color: var(--danger); }

/* Menu « Plus » */
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; padding: 4px 2px; }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { color: var(--ink); }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; min-width: 240px; display: flex; flex-direction: column; gap: 2px; padding: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 18px 40px rgba(34, 27, 58, .18); animation: pop .3s var(--ease); transform-origin: top right; }
.menu-pop button { text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 12px; font-size: 14px; font-weight: 600; color: var(--ink); }
.menu-pop button:hover { background: var(--mail-soft); }
.menu-pop .danger { color: var(--danger); }
.menu-field { padding: 6px 10px 2px; font-size: 12.5px; font-weight: 600; color: var(--soft); }
.menu-pop .nk-select { margin: 0 8px 6px; }
.menu-pop .nk-btn { padding-top: 9px; padding-bottom: 9px; font-size: 14.5px; }
.menu-pop .nk-pop { z-index: 40; }

/* Bandeaux au-dessus de la conversation */
.banner { margin: 12px 20px 0; padding: 14px 18px; border-radius: 20px; border: 1px solid var(--line); background: var(--card); font-size: 14px; line-height: 1.55; }
.banner.warn { background: #FFF0F4; border-color: #FFC9DB; }
.banner h3 { margin: 0 0 4px; font: 400 18px/1.3 var(--font-d); }
.banner.warn h3 { color: var(--danger); }
.banner p { color: var(--soft); }
.banner details { margin-top: 6px; color: var(--soft); }
.banner summary { cursor: pointer; font-size: 13.5px; font-weight: 600; }
.banner ul { margin: 6px 0 0; padding-left: 18px; }
.banner .banner-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; }
.banner .banner-actions .btn { padding: 7px 15px; font-size: 13.5px; }
.banner .fine { margin-top: 8px; font-size: 12.5px; }
.composer-note { margin: 0; padding: 14px 20px calc(16px + env(safe-area-inset-bottom, 0px)); font-size: 13.5px; color: var(--soft); text-align: center; }

/* --- Mobile : une seule colonne ------------------------------------------- */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .pane { position: fixed; inset: 0; background: var(--bg); transform: translateX(100%); visibility: hidden; transition: transform .25s var(--ease), visibility 0s linear .25s; z-index: 5; }
  body.in-thread .pane { transform: none; visibility: visible; transition: transform .25s var(--ease); }
  .pane-empty { display: none; }
  .back { display: inline-block; }
  .thread-head { padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  .th-actions { gap: 10px; }
  .th-id h2 { font-size: 19px; }
  .msg { max-width: 88%; }
  .msgs { padding: 14px 12px 8px; }
  .composer-wrap { padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .composer .btn { padding: 12px 18px; }
  .side-top { padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
  .banner { margin: 10px 12px 0; }
  .contact .row-actions { flex-direction: column; gap: 0; align-items: flex-end; }
  .menu-pop { right: -4px; }
}
@media (prefers-reduced-motion: reduce) { .pane, .sections::before { transition: none !important; } }

/* Widgets du compte (définis dans nakria-ui.css) : taille compacte pour les fenêtres */
.nk-btn, .nk-date input.nk-date-text { padding-top: 11px; padding-bottom: 11px; font-size: 15.5px; }
.nk-date input.nk-date-text { width: 100%; font: 400 15.5px/1.3 var(--font-b); color: var(--ink); background: var(--bg); border: 1.5px solid var(--line); border-radius: var(--r2); padding-left: 15px; padding-right: 58px; }
.nk-date-btn { width: 36px; height: 36px; }
.nk-pop input.nk-search { width: 100%; }
/* One contextual suggestion for the received dated message currently in view. */
.mail-date-card { flex: none; display: flex; align-items: center; gap: 16px; margin: 12px 20px 0; padding: 16px 20px; background: var(--card, #fff); border: 1.5px solid var(--line, #e9dfcf); border-radius: 26px; }
.mail-date-card[hidden], .mail-date-card [hidden] { display: none; }
.mail-date-icon { flex: none; width: 54px; height: 54px; }
.mail-date-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mail-date-copy strong { font-size: 15px; line-height: 1.35; }
.mail-date-summary { font-size: 13px; color: var(--soft, #777); }
.mail-date-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.mail-date-arrow { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--acc); transition: background .15s ease; }
.mail-date-arrow:hover { background: #f0ebff; }
.mail-date-arrow:active { background: #e6ddff; }
.mail-date-arrow:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.mail-date-counter { flex: none; margin-left: 5px; color: var(--soft); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mail-date-row.has-choices .mail-date-summary { color: var(--ink); }
@media (max-width: 620px) {
  .mail-date-row { gap: 2px; flex-wrap: nowrap; }
  .mail-date-row.has-choices .mail-date-summary { flex: 0 1 auto; min-width: 0; font-size: 12px; }
  .mail-date-arrow { width: 30px; height: 34px; }
  .mail-date-counter { margin-left: 4px; font-size: 10px; }
}
.mail-date-add { flex: none; white-space: nowrap; border-radius: 24px; padding: 13px 18px; }
.msg.theirs:has(.bubble):focus-within { outline-offset: 4px; }
@media (max-width: 620px) {
  .mail-date-card { display: grid; grid-template-columns: 44px minmax(0, 1fr); margin: 8px 12px 0; padding: 14px; gap: 12px 10px; border-radius: 20px; }
  .mail-date-icon { width: 44px; height: 44px; align-self: start; margin-top: 3px; }
  .mail-date-copy { min-width: 0; gap: 3px; }
  .mail-date-add { grid-column: 1 / -1; width: 100%; margin: 0; padding: 12px 16px; min-height: 44px; font-size: 13px; text-align: center; }
  .mail-date-copy strong { font-size: 13px; line-height: 1.35; }
  .mail-date-summary { font-size: 12px; }
}

.mail-date-feedback { font-size: 12px; color: #39734d; }
.mail-date-feedback:empty { display: none; }
.mail-date-feedback.is-error { color: var(--danger); }
/* Violet marker from the Nakria action palette; keep message text fully selectable. */
.mail-date-highlight { color: inherit; font-weight: 600; background: linear-gradient(transparent 50%, rgba(108, 77, 255, .25) 50%, rgba(108, 77, 255, .25) 94%, transparent 94%); border-radius: 2px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
