/* Messenger-style chat (loaded by messages.php after style.css) */
.msgs{min-height:calc(100vh - 120px)}
.msgs-main{position:relative;background:var(--card)}
.chat-head{background:var(--card);position:sticky;top:0;z-index:2}
.msgs-main .chat{flex:1;gap:0;padding:14px 12px 8px;max-height:calc(100vh - 260px);min-height:260px;background:var(--card);scroll-behavior:auto}
.chat-sep{align-self:center;color:var(--muted);font-size:12px;margin:14px 0 8px;text-align:center}
.chat-empty{margin:auto;text-align:center}
.mrow{display:flex;align-items:flex-end;gap:8px;margin-top:2px;max-width:100%}
.mrow.first{margin-top:8px}
.mrow.me{justify-content:flex-end}
.mav{width:28px;flex:none;visibility:hidden}.mrow.last .mav{visibility:visible}
.mav .av{width:28px;height:28px;font-size:11px;display:block}
.mrow .bub{max-width:min(72%,520px);padding:8px 12px;border-radius:18px;background:#e4e6eb;color:var(--text);align-self:auto;line-height:1.35;font-size:15px}
.mrow.me .bub{background:#ff4500;color:#fff}
.mrow.them.first:not(.last) .bub{border-bottom-left-radius:4px}.mrow.them:not(.first):not(.last) .bub{border-top-left-radius:4px;border-bottom-left-radius:4px}.mrow.them.last:not(.first) .bub{border-top-left-radius:4px}
.mrow.me.first:not(.last) .bub{border-bottom-right-radius:4px}.mrow.me:not(.first):not(.last) .bub{border-top-right-radius:4px;border-bottom-right-radius:4px}.mrow.me.last:not(.first) .bub{border-top-right-radius:4px}
.mrow .bub .bt{display:block;word-wrap:break-word;overflow-wrap:anywhere}
.mrow .bub-img{display:block;max-width:100%;max-height:300px;border-radius:12px;margin:0;background:#d0d3d8;min-width:80px;min-height:60px;object-fit:contain}
.mrow .bub-imgl{display:block}.mrow .bub-imgl+.bt{margin-top:6px}
.mrow .bub.img-only{padding:3px;background:transparent!important}
.mrow.me .bub.img-only .bub-img,.mrow.them .bub.img-only .bub-img{border-radius:16px}
.chat-seen{align-self:flex-end;color:var(--muted);font-size:11.5px;margin:3px 4px 0}
.chat-new{position:absolute;left:50%;transform:translateX(-50%);bottom:76px;background:#ff4500;color:#fff;border:0;border-radius:5px;padding:6px 14px;font-weight:700;font-size:13px;box-shadow:0 2px 8px rgba(0,0,0,.25);cursor:pointer;z-index:3}
.chat-prev{display:flex;gap:8px;overflow-x:auto;padding:8px 12px 0;border-top:1px solid var(--line);background:var(--card)}
.chat-prev[hidden]{display:none}
.chat-prev .pv{position:relative;flex:none}.chat-prev img{width:68px;height:68px;object-fit:contain;border-radius:10px;display:block;border:1px solid var(--line)}
.chat-prev .pv button{position:absolute;top:-6px;right:-6px;width:22px;height:22px;border-radius:50%;border:0;background:#333;color:#fff;font-size:15px;line-height:1;cursor:pointer;padding:0}
.msgs-main .chat-form{display:flex;align-items:flex-end;gap:8px;padding:10px 12px;border-top:1px solid var(--line);background:var(--card);margin-top:auto}
.chat-prev:not([hidden])+.chat-form{border-top:0}
.chat-form textarea{flex:1;resize:none;min-height:40px;max-height:140px;padding:9px 16px;border:0;border-radius:20px;background:#f0f2f5;font:inherit;color:inherit;line-height:1.35;outline:0;overflow-y:auto}
.chat-form textarea:focus{background:#e9ebee}
.chat-form .chat-attach{width:40px;height:40px;border-radius:5px;background:transparent;font-size:22px;position:relative}.chat-form .chat-attach:hover{background:#f0f2f5}.chat-form .chat-attach.has{outline:0;background:#e7f3ff}
.chat-send{width:40px;height:40px;border-radius:5px;border:0;background:transparent;color:#ff4500;display:grid;place-items:center;cursor:pointer;flex:none;padding:0}.chat-send:hover{background:#f0f2f5}.chat-send:disabled{opacity:.4;cursor:default}
.chat-form.busy textarea{opacity:.7}
.chat-lb{position:fixed;inset:0;background:rgba(0,0,0,.88);z-index:9999;display:grid;place-items:center;cursor:zoom-out}
.chat-lb img{max-width:96vw;max-height:92vh;border-radius:8px}
.chat-lb button{position:absolute;top:12px;right:16px;background:none;border:0;color:#fff;font-size:36px;cursor:pointer}
@media (max-width:760px){
  .msgs{min-height:calc(100vh - 100px);border-radius:0}
  .msgs-main .chat{max-height:calc(100vh - 230px)}
  .mrow .bub{max-width:80%}
}
