/* full screen chat */
body.msgr-open { overflow: hidden; }
.msgr { position: fixed; inset: 0; z-index: 28; background: var(--bg); color: var(--fg); display: grid; grid-template-columns: 300px minmax(0, 1fr) 76px; font: 14px "WP Emoji", system-ui, sans-serif; }
.msgr[hidden] { display: none; }
.msgr button { font: inherit; color: inherit; cursor: pointer; }
.m-grow { flex: 1; min-width: 0; display: block; }
.m-grow b, .m-grow small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-grow small { color: var(--muted); font-size: 12px; margin-top: 1px; }

/* avatars with a status dot */
.m-av { position: relative; width: 38px; height: 38px; border-radius: 50%; background: var(--edge); display: grid; place-items: center; font-weight: 700; flex: none; }
.m-av img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.m-av::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--bg); background: #6b6b76; display: none; }
.m-av[data-status]::after { display: block; }
.m-av[data-status="online"]::after { background: #3ddc84; }
.m-av[data-status="away"]::after { background: #ffcf5e; }
.m-av[data-status="busy"]::after { background: #e0443e; }
.m-av.ghost { background: transparent; visibility: hidden; }
.m-dot { min-width: 18px; height: 18px; border-radius: 9px; background: #e0443e; color: #fff; font-size: 11px; line-height: 18px; text-align: center; padding: 0 5px; box-sizing: border-box; flex: none; }

/* left: me + all friends */
.m-left { display: flex; flex-direction: column; min-height: 0; background: var(--card); border-right: 1px solid var(--line); }
.m-top { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.m-top h2 { margin: 0; font-size: 16px; }
.m-close { border: 1px solid var(--edge); background: var(--card3); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 700; }
.m-me { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.m-me .m-grow b { margin-bottom: 4px; }
.m-me select, .m-me input, .m-search { background: var(--field); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: 13px "WP Emoji", system-ui, sans-serif; max-width: none; text-align: left; box-sizing: border-box; width: 100%; }
.m-me input { grid-column: 1 / -1; }
.m-search { flex: none; width: calc(100% - 24px); margin: 10px 12px 4px; }
.m-me select, .m-me input { flex: none; }
.m-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; scrollbar-width: thin; }
.m-row { box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; border-radius: 10px; padding: 8px; text-align: left; }
.m-row:hover { background: var(--card3); }
.m-row.on { background: var(--card3); box-shadow: inset 3px 0 0 var(--accent); }
.m-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 20px 12px; margin: 0; }

/* middle: the conversation */
.m-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.m-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--card2); }
.m-head .m-av { width: 42px; height: 42px; }
.m-back { display: none; border: 0; background: transparent; font-size: 26px; line-height: 1; padding: 0 6px 0 0; }
.msgr .m-btn { border: 0; border-radius: 999px; background: var(--accent); color: #111; font-weight: 800; font-size: 12px; padding: 7px 14px; }
.m-bio { margin: 0; padding: 8px 18px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); }
.m-msgs { flex: 1; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.m-day { align-self: center; color: var(--muted); font-size: 11px; margin: 10px 0 6px; }
.m-msg { display: flex; gap: 10px; align-items: flex-start; margin-top: 10px; }
.m-msg.cont { margin-top: 0; }
.m-msg .m-av { width: 34px; height: 34px; }
.m-msg .m-av::after { display: none; }
.m-bubble { min-width: 0; max-width: min(560px, 85%); overflow-wrap: anywhere; font-size: var(--chat-size); line-height: 1.4; }
.m-meta { display: flex; align-items: baseline; gap: 8px; }
.m-meta small { color: var(--muted); font-size: 11px; }
.m-msg.mine .m-meta b { color: var(--accent); }
.m-blank { flex: 1; display: grid; place-items: center; color: var(--muted); }
.m-form { padding: 12px 18px 16px; border-top: 1px solid var(--line); display: block; }
.m-form input { width: 100%; max-width: none; box-sizing: border-box; text-align: left; padding: 11px 14px; border-radius: 12px; }

/* right: recent chats */
.m-right { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 0; background: var(--card); border-left: 1px solid var(--line); overflow-y: auto; scrollbar-width: none; }
.m-right small { color: var(--muted); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }
.m-rec { position: relative; border: 0; background: transparent; padding: 3px; border-radius: 50%; }
.m-rec.on { box-shadow: 0 0 0 2px var(--accent); }
.m-rec .m-av { width: 44px; height: 44px; }
.m-rec .m-dot { position: absolute; top: -3px; right: -3px; }

@media (max-width: 760px) {
  .msgr { grid-template-columns: minmax(0, 1fr); }
  .m-right { display: none; }
  .msgr .m-main { display: none; }
  .msgr.chatting .m-left { display: none; }
  .msgr.chatting .m-main { display: flex; }
  .m-back { display: block; }
}

/* tabs on the left: chats / friends */
.m-tabs { display: flex; gap: 6px; padding: 10px 12px 0; }
.m-tab { flex: 1; position: relative; border: 1px solid var(--line); background: var(--card2); border-radius: 999px; padding: 7px 10px; font-weight: 700; font-size: 12px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
.m-tab.on { background: var(--accent); color: #111; border-color: transparent; }
.m-find { display: flex; gap: 8px; padding: 10px 12px 4px; }
.m-find .m-search { margin: 0; flex: 1; width: auto; }
.m-people h3 { margin: 12px 8px 4px; font-size: 11px; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.m-row.static { cursor: default; }
.m-row.static:hover { background: transparent; }
.m-row.static small { color: var(--muted); font-size: 12px; }
.msgr .m-btn.quiet { background: var(--card3); color: var(--fg); border: 1px solid var(--edge); }
.m-people .m-btn { flex: none; padding: 5px 10px; }

/* pictures */
.m-img { display: block; max-width: min(260px, 100%); max-height: 220px; border-radius: 10px; margin: 4px 0; cursor: zoom-in; object-fit: contain; background: var(--card2); }
.m-gone { color: var(--muted); font-size: 12px; }
.m-light { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.85); display: grid; place-items: center; cursor: zoom-out; padding: 20px; }
.m-light img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.m-inrow { display: flex; gap: 8px; align-items: center; }
.m-inrow input { flex: 1; width: auto; }
.m-attach { flex: none; border: 1px solid var(--line); background: var(--card2); border-radius: 12px; width: 44px; height: 44px; font-size: 18px; }
.m-pend { position: relative; display: inline-block; margin-bottom: 8px; }
.m-pend img { display: block; max-height: 90px; max-width: 160px; border-radius: 8px; border: 1px solid var(--edge); }
.m-x { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--edge); background: var(--card3); font-size: 14px; line-height: 1; padding: 0; }
.m-note { min-height: 0; margin: 0 0 6px; font-size: 12px; color: #ff8a8a; }
.m-note:empty { display: none; }

.m-inrow textarea { flex: 1; width: auto; box-sizing: border-box; resize: none; font: inherit; line-height: 20px; padding: 11px 14px; border-radius: 12px; text-align: left; }
.m-inrow { align-items: flex-end; }
.m-form .send-btn { height: 44px; }
