/* Inbox — interface façon messagerie Instagram. Conçue pour le téléphone d'abord. */
:root {
  --fond: #fff; --texte: #000; --doux: #737373; --trait: #dbdbdb; --champ: #efefef;
  --bulle: #efefef; --bulle-txt: #000; --lien: #00376b; --bleu: #0095f6; --rouge: #ed4956;
  --moi: linear-gradient(180deg, #b833f5 0%, #6b4ef6 45%, #3797f0 100%);
  --app-h: 100dvh;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --fond: #000; --texte: #f5f5f5; --doux: #a8a8a8; --trait: #262626; --champ: #262626;
          --bulle: #262626; --bulle-txt: #f5f5f5; --lien: #e0f1ff; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--fond); }
body { color: var(--texte); font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button, label, [role=button] { touch-action: manipulation; cursor: pointer; }
button { background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }

.app { height: var(--app-h); display: flex; overflow: hidden; }
.pane { display: flex; flex-direction: column; min-width: 0; height: 100%; }
.list { width: 100%; }
.chat { width: 100%; }
.app[data-view=list] .chat, .app[data-view=chat] .list { display: none; }

.top { display: flex; align-items: center; gap: 4px; min-height: 56px; padding: env(safe-area-inset-top) 8px 0 16px; flex: none; }
.top h1 { font-size: 24px; font-weight: 700; letter-spacing: -.3px; margin: 0; flex: 1; }
.ic { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; flex: none; }
.ic:active { opacity: .5; }
.etat { font-size: 12px; color: var(--doux); padding-right: 4px; }

.recherche { margin: 4px 16px 8px; display: flex; align-items: center; gap: 8px; background: var(--champ); border-radius: 12px; padding: 0 12px; color: var(--doux); flex: none; }
.recherche input { flex: 1; min-width: 0; height: 40px; border: 0; background: none; outline: 0; font-size: 16px; color: var(--texte); -webkit-appearance: none; appearance: none; }
.recherche input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* Rangée des réseaux, façon rangée de stories */
.reseaux { display: flex; gap: 14px; overflow-x: auto; padding: 4px 16px 12px; flex: none; scrollbar-width: none; }
.reseaux::-webkit-scrollbar { display: none; }
.res { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 64px; flex: none; font-size: 12px; color: var(--doux); }
.res .cercle { position: relative; width: 60px; height: 60px; border-radius: 50%; padding: 3px; background: var(--trait); display: block; }
.res .cercle i { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; border: 2.5px solid var(--fond); font-style: normal; font-weight: 700; font-size: 17px; color: #fff; background: #8e8e8e; }
.res.actif { color: var(--texte); font-weight: 600; }
.res.actif .cercle { background: linear-gradient(45deg, #feda75, #fa7e1e 25%, #d62976 50%, #962fbf 75%, #4f5bd5); }
.res span.nom { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pastille { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--rouge); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--fond); }

/* Couleurs de réseau : pastille d'avatar, cercle de filtre, bulles envoyées */
.n-instagram { --net: linear-gradient(45deg, #feda75, #fa7e1e 25%, #d62976 50%, #962fbf 75%, #4f5bd5); }
.n-whatsapp { --net: #25d366; } .n-linkedin { --net: #0a66c2; } .n-twitter { --net: #111; }
.n-facebook { --net: linear-gradient(45deg, #0a7cff, #a334fa 60%, #ff5c87); } .n-telegram { --net: #2aabee; }
.n-signal { --net: #3a76f0; } .n-discord { --net: #5865f2; } .n-imessage { --net: #34c759; }
.n-gmessages { --net: #1a73e8; } .n-slack { --net: #611f69; } .n-autre { --net: #8e8e8e; } .n-tous { --net: #262626; }
.res .cercle i { background: var(--net, #8e8e8e); }
@media (prefers-color-scheme: dark) { .n-twitter { --net: #3a3a3a; } .n-tous { --net: #3a3a3a; } }

.liste { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-bottom: env(safe-area-inset-bottom); }
.ligne { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 16px; text-align: left; min-height: 72px; }
.ligne:active, .ligne.ouverte { background: var(--champ); }
.ligne .txt { flex: 1; min-width: 0; }
.ligne .nom { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ligne .apercu { font-size: 14px; color: var(--doux); display: flex; gap: 4px; }
.ligne .apercu b { font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ligne .apercu time { flex: none; }
.ligne.nonlu .nom { font-weight: 700; }
.ligne.nonlu .apercu { color: var(--texte); font-weight: 600; }
.ligne.nonlu .apercu b { font-weight: 600; }
.ligne .point { width: 9px; height: 9px; border-radius: 50%; background: var(--bleu); flex: none; visibility: hidden; }
.ligne.nonlu .point { visibility: visible; }
.rien { padding: 48px 32px; text-align: center; color: var(--doux); }

.av { position: relative; width: var(--s, 56px); height: var(--s, 56px); border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: calc(var(--s, 56px) * .4); user-select: none; }
.av img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: var(--champ); }
.av .net { position: absolute; right: -2px; bottom: -2px; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 11px; background: var(--net, #8e8e8e); border: 2px solid var(--fond); font-size: 9.5px; font-weight: 800; letter-spacing: -.2px; display: grid; place-items: center; color: #fff; }

/* Conversation */
.vide { flex: 1; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.vide .rond { width: 96px; height: 96px; border: 2px solid var(--texte); border-radius: 50%; display: grid; place-items: center; margin-bottom: 8px; }
.vide .t { font-size: 20px; margin: 0; } .vide .s { color: var(--doux); margin: 0; }
.conv { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.conv .top { padding-left: 4px; border-bottom: 1px solid var(--trait); padding-bottom: 6px; }
.tete { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.tete .qui { min-width: 0; }
.tete .nom, .tete .sous { display: block; }
.tete .nom { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tete .sous { font-size: 12px; color: var(--doux); }
.msgs { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 12px 12px 4px; display: flex; flex-direction: column; gap: 2px; }
.heure { align-self: center; font-size: 12px; color: var(--doux); padding: 14px 0 8px; }
.debut { align-self: center; text-align: center; padding: 24px 0 8px; color: var(--doux); font-size: 13px; }
.debut .av { margin: 0 auto 10px; } .debut .nom { color: var(--texte); font-size: 18px; font-weight: 600; }
.m { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.m.moi { justify-content: flex-end; }
.m .av { margin-bottom: 2px; } .m .av.fant { visibility: hidden; }
.m .col { display: flex; flex-direction: column; max-width: min(76%, 520px); min-width: 0; }
.m.moi .col { align-items: flex-end; } .m.eux .col { align-items: flex-start; }
.auteur { font-size: 12px; color: var(--doux); margin: 8px 0 2px 14px; }
.bulle { padding: 8px 14px; border-radius: 22px; background: var(--bulle); color: var(--bulle-txt); font-size: 15px; line-height: 1.32; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; position: relative; user-select: text; -webkit-user-select: text; }
.m.moi .bulle { background: var(--moi); background-attachment: fixed; color: #fff; }
.conv.n-whatsapp .m.moi .bulle { background: #1faa59; } .conv.n-linkedin .m.moi .bulle { background: #0a66c2; }
.conv.n-twitter .m.moi .bulle { background: #1d9bf0; } .conv.n-telegram .m.moi .bulle { background: #2aabee; }
.conv.n-signal .m.moi .bulle { background: #3a76f0; } .conv.n-imessage .m.moi .bulle { background: #34c759; }
.conv.n-facebook .m.moi .bulle { background: linear-gradient(180deg, #a334fa, #0a7cff); background-attachment: fixed; }
.bulle a { color: inherit; text-decoration: underline; }
.m.eux.suite-h .bulle { border-top-left-radius: 6px; } .m.eux.suite-b .bulle { border-bottom-left-radius: 6px; }
.m.moi.suite-h .bulle { border-top-right-radius: 6px; } .m.moi.suite-b .bulle { border-bottom-right-radius: 6px; }
.bulle.emoji { background: none !important; padding: 2px 4px; font-size: 44px; line-height: 1.1; }
.bulle.media { padding: 0; background: var(--champ) !important; overflow: hidden; }
.bulle.media img, .bulle.media video { display: block; max-width: 100%; width: var(--w, 240px); max-height: 380px; object-fit: cover; }
.bulle.media .legende { padding: 8px 14px; color: var(--bulle-txt); }
.bulle.fichier { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.bulle.erreur { background: none !important; border: 1px solid var(--trait); color: var(--doux) !important; font-style: italic; font-size: 13px; }
.bulle audio { display: block; max-width: 240px; height: 40px; }
.cite { font-size: 13px; color: var(--doux); border-left: 3px solid var(--trait); padding: 2px 10px; margin: 6px 4px 3px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reacs { display: flex; gap: 2px; margin: -6px 8px 4px; background: var(--champ); border: 2px solid var(--fond); border-radius: 12px; padding: 1px 6px; font-size: 13px; z-index: 1; }
.suivi { font-size: 12px; color: var(--doux); margin: 3px 6px 0; }
.suivi.ko { color: var(--rouge); }
.m.attente .bulle { opacity: .6; }
.tape { padding: 0 20px 6px; font-size: 13px; color: var(--doux); flex: none; }

.compo { display: flex; align-items: flex-end; gap: 4px; margin: 6px 12px calc(8px + env(safe-area-inset-bottom)); padding: 0 6px 0 2px; border: 1px solid var(--trait); border-radius: 24px; flex: none; background: var(--fond); }
.compo textarea { flex: 1; min-width: 0; border: 0; outline: 0; background: none; resize: none; font-size: 16px; line-height: 1.3; padding: 11px 4px; max-height: 120px; }
.compo .envoi { color: var(--bleu); font-weight: 600; height: 44px; padding: 0 10px; flex: none; }
.compo .envoi:disabled { opacity: .4; }
.compo.envoi-fichier { opacity: .6; pointer-events: none; }

/* Mise en route */
.porte { position: fixed; inset: 0; background: var(--fond); z-index: 30; display: grid; place-items: center; padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom)); overflow-y: auto; }
.porte form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.porte .logo, .accueil .logo { width: 72px; height: 72px; border-radius: 20px; background: linear-gradient(45deg, #feda75, #fa7e1e 25%, #d62976 50%, #962fbf 75%, #4f5bd5); margin: 0 auto 8px; }
.porte h2 { font-size: 22px; margin: 0; text-align: center; }
.porte p { margin: 0; color: var(--doux); text-align: center; font-size: 14px; }
.porte input { height: 48px; border-radius: 10px; border: 1px solid var(--trait); background: var(--champ); padding: 0 14px; font-size: 16px; outline: 0; width: 100%; }
.porte button.cta, .feuille button.cta { height: 48px; border-radius: 10px; background: var(--bleu); color: #fff; font-weight: 600; font-size: 15px; }
.porte button.cta:disabled { opacity: .5; }
.porte .err { color: var(--rouge); font-size: 14px; min-height: 20px; text-align: center; }
.porte .lien { color: var(--bleu); font-size: 14px; height: 44px; }
.accueil { position: fixed; inset: 0; background: var(--fond); z-index: 20; display: grid; place-items: center; transition: opacity .25s; }
.accueil.parti { opacity: 0; pointer-events: none; }

/* Feuille du bas */
.feuille { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .5); display: flex; align-items: flex-end; justify-content: center; }
.feuille .carte { width: 100%; max-width: 520px; background: var(--fond); border-radius: 18px 18px 0 0; padding: 8px 20px calc(20px + env(safe-area-inset-bottom)); max-height: 88dvh; overflow-y: auto; }
.feuille .poignee { width: 40px; height: 4px; border-radius: 2px; background: var(--trait); margin: 4px auto 14px; }
.feuille h3 { margin: 0 0 12px; font-size: 18px; }
.feuille .rang { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; border-top: 1px solid var(--trait); width: 100%; text-align: left; font-size: 15px; }
.feuille .rang small { color: var(--doux); display: block; font-size: 13px; }
.feuille .rang.danger { color: var(--rouge); }
.feuille .cta { width: 100%; margin-top: 14px; }

.visio { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .94); display: grid; place-items: center; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.visio img { max-width: 100%; max-height: 100%; object-fit: contain; }
.bandeau { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 60; background: #262626; color: #fff; border-radius: 12px; padding: 6px 6px 6px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; max-width: 480px; margin: 0 auto; }
.bandeau button { color: #fff; background: var(--bleu); border-radius: 8px; height: 40px; padding: 0 14px; font-weight: 600; flex: none; }

/* Ordinateur : deux colonnes */
@media (min-width: 900px) {
  .app[data-view] .list, .app[data-view] .chat { display: flex; }
  .list { width: 400px; flex: none; border-right: 1px solid var(--trait); }
  .chat { flex: 1; }
  .retour { display: none; }
  .conv .top { padding-left: 16px; }
  .vide { display: flex; }
  .app[data-view=chat] .vide { display: none; }
  .ligne:hover { background: var(--champ); }
  .feuille { align-items: center; } .feuille .carte { border-radius: 18px; }
  .msgs { padding: 16px 24px 4px; } .compo { margin: 8px 24px 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
