.chat-head{display:flex;align-items:center;gap:.6rem;margin-bottom:.8rem}
.chat-head h1{margin:0;font-size:1.25rem}.flip{transform:scaleX(-1)}
#chat-msgs{display:flex;flex-direction:column;gap:.7rem;padding:.2rem 0 1rem;margin-bottom:96px}
.cmsg{display:flex;gap:.6rem;align-items:flex-start}
.cbody{max-width:calc(100% - 3rem);background:var(--card);border:1px solid var(--line2);border-radius:16px 16px 16px 4px;padding:.5rem .8rem;min-width:0}
.cmsg.mine .cbody{background:linear-gradient(135deg,rgba(var(--acc-rgb),.28),rgba(var(--acc-rgb),.28));border-color:var(--line);border-radius:16px 16px 4px 16px}
.chead{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}.chead .post-name{font-size:.9rem}
.ctext{overflow-wrap:anywhere}.ctext a{color:var(--blue)}
.cmenu{margin-left:auto}.cmenu summary{width:28px;height:28px}
/* barre de saisie ancrée en bas, au-dessus de la barre de navigation */
.chat-dock{position:fixed;left:50%;transform:translateX(-50%);width:calc(100% - 24px);max-width:736px;z-index:35;
  bottom:calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px)}
.chat-dock .flash{margin-bottom:.4rem}
.chat-form{display:flex;gap:.5rem;padding:.5rem;background:rgba(23,22,21,.96);border:1px solid var(--line2);border-radius:999px;backdrop-filter:blur(10px)}
.chat-form input{border-radius:999px;flex:1;min-width:0}
body.kb .bottom-nav{display:none}
.room{display:flex;align-items:center;gap:.8rem;color:var(--text);text-decoration:none}.room:hover{text-decoration:none;border-color:var(--pink)}
.room>.grow{display:flex;flex-direction:column;min-width:0}
.room-meta{display:flex;flex-direction:column;align-items:flex-end;gap:.3rem}
.unread{background:var(--pink);color:#fff;border-radius:999px;min-width:24px;padding:.05rem .45rem;text-align:center;font-size:.75rem;font-weight:700}
/* chat en direct + panneau des connectés */
.chat-head{justify-content:space-between}
.chat-main{min-width:0}
.online{display:none}
.online h2{font-size:1rem;margin:0 0 .6rem}
.online ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:.3rem}
.online li a{display:flex;align-items:center;gap:.5rem;color:var(--text);text-decoration:none;padding:.3rem .4rem;border-radius:10px}
.online li a:hover{background:rgba(255,255,255,.05)}
.on-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.dot-on{width:9px;height:9px;border-radius:50%;background:#2fe0a0;margin-left:auto;flex:none}
.online-open .online{display:block;position:fixed;right:0;top:0;bottom:0;width:min(78vw,280px);z-index:60;background:var(--bg2);border-left:1px solid var(--line2);padding:calc(64px + env(safe-area-inset-top)) .9rem 1rem;overflow-y:auto}
.dm-list{margin-bottom:96px}
@media(min-width:900px){
  .chatpage.online-open{display:grid;grid-template-columns:minmax(0,1fr) 240px;gap:1rem;align-items:start}
  .online-open .online{position:static;width:auto;padding:0;border:0;background:none;z-index:auto}
  .chat-dock{position:sticky;left:auto;transform:none;width:auto;max-width:none;bottom:12px}
}
.online-close{float:right;width:36px;height:36px}@media(min-width:900px){.online-close{display:none}}

/* messages privés : mes messages à droite, ceux de l'autre à gauche */
.dm-head{justify-content:flex-start}
.dm-list .cmsg{display:flex;width:100%}
.dm-list .cbody{max-width:80%}
.dm-list .cmsg.mine{justify-content:flex-end}
.dm-list .cmsg.mine .cbody{text-align:left}
.dm-list .cbody small{display:block;margin-top:.15rem;opacity:.8}
.dm-list .cmsg.mine small{text-align:right}

/* nouveau message : liste des abonnements */
.msg-title{display:flex;align-items:center;justify-content:space-between;margin:.25rem 0 1rem}
.msg-title .page-title{margin:0}
.msg-plus{width:46px;height:46px;border-radius:50%;display:grid;place-items:center;background:linear-gradient(90deg,var(--pink),var(--acc));color:#fff;box-shadow:none;text-decoration:none}
.msg-plus:hover{text-decoration:none;filter:brightness(1.08)}
.nm-sheet{display:none;position:fixed;inset:0;z-index:120;background:rgba(9,8,7,.72);align-items:flex-end}
.nm-sheet:target{display:flex}
.nm-in{width:100%;max-width:560px;margin:0 auto;max-height:80%;display:flex;flex-direction:column;background:var(--card);border-radius:20px 20px 0 0;border-top:1px solid var(--line);padding:1rem;padding-bottom:calc(1rem + env(safe-area-inset-bottom))}
.nm-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:.6rem}
.nm-list{overflow-y:auto;display:flex;flex-direction:column;gap:.2rem;margin-top:.6rem}
.nm-item{display:flex;align-items:center;gap:.7rem;padding:.55rem;border-radius:12px;color:var(--text);text-decoration:none}
.nm-item:hover{background:rgba(255,255,255,.06);text-decoration:none}
.nm-item[hidden]{display:none}
@media(min-width:700px){.nm-sheet{align-items:center}.nm-in{border-radius:20px}}

/* chat en direct : mes messages à droite (avatar à droite), ceux des autres à gauche */
#chat-msgs .cmsg.mine{flex-direction:row-reverse}
#chat-msgs .cmsg.mine .cbody{text-align:left}
/* DM : mes messages à droite (row-reverse + flex-end les renvoyait à gauche) */
#chat-msgs.dm-list .cmsg{flex-direction:row;width:100%}
#chat-msgs.dm-list .cmsg.mine{justify-content:flex-end}
#chat-msgs.dm-list .cmsg:not(.mine){justify-content:flex-start}

/* ===== Chat en direct & messages privés : écran complet, seule la conversation défile ===== */
html:has(body.fullscreen),body.fullscreen{overflow:hidden;overscroll-behavior:none}
body.fullscreen .shell{height:var(--vvh,100dvh);display:flex;flex-direction:column;overflow:hidden;padding-bottom:calc(var(--nav-h) + env(safe-area-inset-bottom))}
body.fullscreen.kb .shell{padding-bottom:0}
body.fullscreen .topwrap{flex:none}
body.fullscreen .chatbar{display:none}
body.fullscreen main.content{flex:1;min-height:0;display:flex;flex-direction:column;padding-top:.4rem;padding-bottom:.5rem;overflow:hidden}
body.fullscreen main.content>*{animation:none}
body.fullscreen .chatpage,body.fullscreen .chat-main{flex:1;min-height:0;display:flex;flex-direction:column}
body.fullscreen .chatpage.online-open{display:grid;grid-template-columns:minmax(0,1fr);align-items:stretch}
body.fullscreen .chat-head{flex:none;margin-bottom:.4rem}
body.fullscreen #chat-msgs{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;margin-bottom:0;padding:.4rem .1rem .8rem;scroll-behavior:auto}
body.fullscreen .dm-list{margin-bottom:0}
body.fullscreen .chat-dock{position:static!important;transform:none!important;left:auto!important;bottom:auto!important;width:auto;max-width:none;flex:none;padding-top:.4rem}
body.fullscreen .chat-main>.center{flex:none}
@media(min-width:900px){body.fullscreen .chatpage.online-open{grid-template-columns:minmax(0,1fr) 240px}body.fullscreen .online-open .online{overflow-y:auto}}
@media(min-width:1024px){body.fullscreen .shell{padding-bottom:0}}

/* ===== Messages privés : avatars à côté des bulles, images, outils d'envoi ===== */
.dm-list .cmsg{align-items:flex-end;gap:.5rem}
.dm-list .dm-av{flex:none;line-height:0}
.dm-list .cmsg .cbody{max-width:min(78%,420px)}
.dm-list .dm-img{margin:.1rem 0 .3rem;border-radius:12px}
.dm-list .dm-img img{max-height:260px;border-radius:12px}
.dm-list .cbody .ctext{overflow-wrap:anywhere}
.dm-form{align-items:center}
.dm-tool{width:42px;height:42px;flex:none;display:grid;place-items:center;border-radius:50%;background:none;border:0;color:var(--muted);cursor:pointer;transition:background .15s,color .15s}
.dm-tool:hover{background:rgba(255,255,255,.08);color:var(--pink)}
.dm-tool .ico{width:22px;height:22px}
.dm-send{width:44px;height:44px;flex:none;display:grid;place-items:center;border-radius:50%;border:0;background:linear-gradient(100deg,var(--acc),var(--acc));color:#fff;cursor:pointer;box-shadow:none}
.dm-send[disabled]{opacity:.6}
.dm-send .ico{width:20px;height:20px}
.dm-att{display:flex;align-items:center;gap:.6rem;margin-bottom:.4rem;padding:.4rem .6rem;border-radius:14px;background:rgba(23,22,21,.96);border:1px solid var(--line2)}
.dm-att[hidden],.dm-emo[hidden]{display:none}
.dm-att img{width:44px;height:44px;border-radius:10px;object-fit:cover}
.dm-att span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.85rem;color:var(--muted)}
.dm-att button{background:none;border:0;color:var(--muted);font-size:1.4rem;cursor:pointer;line-height:1}
.dm-emo{display:grid;grid-template-columns:repeat(8,1fr);gap:0;max-height:132px;overflow-y:auto;overscroll-behavior:contain;margin-bottom:.4rem;padding:.3rem;border-radius:16px;background:rgba(23,22,21,.98);border:1px solid var(--line2)}
.dm-emo button{background:none;border:0;font-size:1.2rem;line-height:1;padding:.3rem 0;border-radius:10px;cursor:pointer}
.dm-emo button:hover{background:rgba(255,255,255,.1)}

/* clavier iOS : l'écran complet est fixé sur la zone réellement visible (plus de saut quand le clavier s'ouvre, ex. « Répondre ») */
@media (max-width:1099px){
  body.fullscreen .shell{position:fixed;top:0;left:0;right:0;margin:0 auto;width:100%;transform:translateY(var(--vvt,0px));will-change:transform}
}

/* clavier ouvert (mobile) : mode immersif façon appli — seuls la conversation et la barre d'écriture restent */
@media (max-width:1099px){
  body.fullscreen.kb .bottom-nav,
  body.fullscreen.kb .topwrap,
  body.fullscreen.kb main.content>.flash,
  body.fullscreen.kb .content>.flash,
  body.fullscreen.kb .chat-head:not(.dm-head),
  body.fullscreen.kb .chat-main>.center,
  body.fullscreen.kb .online{display:none!important}
  body.fullscreen.kb .dm-head{margin-bottom:.2rem;padding:.2rem 0}
  body.fullscreen.kb .dm-head .muted{display:none}
  body.fullscreen.kb main.content{padding-top:max(.4rem,env(safe-area-inset-top));padding-bottom:.35rem}
  body.fullscreen.kb .chat-dock{padding-top:.3rem}
  body.fullscreen.kb #chat-msgs{padding-top:.2rem}
}
/* les messages de confirmation s'effacent seuls sur les pages plein écran */
body.fullscreen .content>.flash{transition:opacity .4s,margin .4s,max-height .4s;max-height:120px;overflow:hidden}
body.fullscreen .content>.flash.gone{opacity:0;max-height:0;margin:0;padding-top:0;padding-bottom:0;border-width:0}

/* ---- Modération : messages système, état du salon, actions staff ---- */
.cmsg.csys{justify-content:center;margin:.35rem 0}
.cmsg.csys span{display:inline-block;max-width:92%;padding:.35rem .8rem;border-radius:999px;background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.1);color:#dad9d8;font-size:.8rem;text-align:center;line-height:1.35}
.chat-state{margin:0 0 .45rem;padding:.5rem .8rem;border-radius:14px;background:rgba(var(--acc-rgb),.16);border:1px solid rgba(var(--acc-rgb),.35);color:#eeedec;font-size:.82rem;line-height:1.35}
.chat-state[hidden]{display:none}
.chat-state b{color:#fff}
.chat-form input:disabled{opacity:.55}
.cmenu .mod-item{color:#dbdad9}
.cmenu form.js-mod{margin:0}

/* ---- Accusés de lecture (✔✔ gris = envoyé, ✔✔ blanc = lu), seulement sur mes messages ---- */
.rcpt{display:inline-flex;vertical-align:-2px;margin-left:.3rem;width:20px;height:13px;color:rgba(255,255,255,.3);transition:color .25s}
.rcpt svg{width:100%;height:100%;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
.rcpt.rd{color:#fff;filter:drop-shadow(0 0 4px rgba(255,255,255,.55))}
.rcpt.rd svg{stroke-width:2.2}
.cbody small:has(.rcpt){opacity:1}
/* heure + accusé de lecture en bas à droite de la bulle (comme en message privé) */
.cfoot{display:flex;align-items:flex-end;justify-content:space-between;gap:.5rem;margin-top:.25rem}
.cfoot .rx{flex:1 1 auto;min-width:0;margin:0}
.cfoot .rx:empty{display:none}
.cfoot .ctime{margin-left:auto;flex:none;font-size:.72rem;line-height:1;white-space:nowrap;display:inline-flex;align-items:center;opacity:.85}
.cfoot .ctime .rcpt{margin-left:.25rem}
.dm-head{margin-bottom:.2rem}.dm-head .post-name{font-size:.82rem;font-weight:800}.cmsg.mine .dm-head .post-name{color:#dbdad9}
