/* ── Direct & group messages (live chat) ── */
.mc-page { max-width: 980px; margin: 0 auto; height: calc(100dvh - 150px); min-height: 440px; display: flex; flex-direction: column; background: var(--bg2, var(--surface)); border: 1px solid var(--border); border-radius: var(--cs-radius, 14px); overflow: hidden; }
.mc-head { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border); background: var(--bg2, var(--surface)); flex-shrink: 0; }
.mc-back, .mc-iconbtn { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--text2) !important; background: none; border: 0; flex-shrink: 0; }
.mc-back:hover, .mc-iconbtn:hover { background: var(--bg3); }
.mc-head-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.6rem; color: var(--text) !important; text-decoration: none !important; }
.mc-head-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; flex-direction: column; line-height: 1.15; }
.mc-head-name small { font-weight: 500; color: var(--text3); font-size: 0.75rem; }
.mc-av { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; background: #4361ee; color: #fff; font-weight: 700; font-size: 0.85rem; text-decoration: none !important; }
.mc-av img { width: 100%; height: 100%; object-fit: cover; }
.mc-av-36 { width: 36px; height: 36px; }
.mc-av-group { background: #7c3aed; }

.mc-app { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mc-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 14px 8px; }
.mc-older { text-align: center; margin: 4px 0 10px; }
.mc-empty { text-align: center; color: var(--text3); padding: 3rem 1rem; }
.mc-empty i { font-size: 2.2rem; margin-bottom: 0.5rem; display: block; opacity: 0.6; }
.mc-day { text-align: center; margin: 14px 0 8px; }
.mc-day span { font-size: 0.72rem; font-weight: 700; color: var(--text3); background: var(--bg3); padding: 3px 10px; border-radius: 999px; }
.mc-system { text-align: center; font-size: 0.76rem; color: var(--text3); margin: 6px 0; }

.mc-msg { display: flex; align-items: flex-end; gap: 8px; margin-top: 10px; position: relative; }
.mc-msg.grouped { margin-top: 2px; }
.mc-msg.mine { flex-direction: row-reverse; }
.mc-msg .mc-av { width: 30px; height: 30px; font-size: 0.75rem; }
.mc-msg.grouped .mc-av { visibility: hidden; height: 1px; }
.mc-stack { max-width: min(78%, 560px); display: flex; flex-direction: column; min-width: 0; }
.mc-msg.mine .mc-stack { align-items: flex-end; }
.mc-name { font-size: 0.72rem; font-weight: 700; color: var(--text3); margin: 0 0 2px 10px; }
.mc-bubble { position: relative; padding: 7px 11px 5px; border-radius: 18px; background: var(--bg3); color: var(--text); overflow-wrap: anywhere; line-height: 1.38; font-size: 0.95rem; border: 1px solid var(--border); }
.mc-msg.mine .mc-bubble { background: #2563eb; color: #fff; border-color: transparent; }
.mc-msg.theirs:not(.grouped) .mc-bubble { border-bottom-left-radius: 6px; }
.mc-msg.mine:not(.grouped) .mc-bubble { border-bottom-right-radius: 6px; }
.mc-text { white-space: pre-wrap; display: inline; }
.mc-text a { color: inherit; text-decoration: underline; }
.mc-text code { background: rgba(0, 0, 0, 0.15); border-radius: 4px; padding: 0 4px; font-size: 0.85em; }
.mc-meta { font-size: 0.66rem; opacity: 0.7; margin-left: 8px; white-space: nowrap; float: right; margin-top: 6px; }
.mc-deleted { font-style: italic; opacity: 0.75; font-size: 0.88rem; }
.mc-msg.deleted .mc-bubble { background: transparent !important; color: var(--text3) !important; border: 1px dashed var(--border) !important; }
.mc-imgs { display: grid; gap: 3px; margin: 2px -6px 4px; border-radius: 12px; overflow: hidden; max-width: 320px; }
.mc-imgs-2, .mc-imgs-4 { grid-template-columns: 1fr 1fr; }
.mc-imgs-3 { grid-template-columns: 1fr 1fr; }
.mc-imgs-3 a:first-child { grid-column: 1 / -1; }
.mc-imgs img { width: 100%; height: 100%; max-height: 300px; object-fit: cover; display: block; }
.mc-imgs-1 img { max-height: 360px; object-fit: contain; background: rgba(0,0,0,0.15); }
.mc-reply { display: flex; align-items: center; gap: 5px; max-width: 100%; border: 0; background: none; color: var(--text3); font-size: 0.76rem; padding: 0 10px 3px; cursor: pointer; text-align: left; min-width: 0; }
.mc-reply span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-reply b { white-space: nowrap; flex-shrink: 0; }
.mc-reply:hover { color: var(--text); }
.mc-reacts { display: flex; gap: 4px; flex-wrap: wrap; margin-top: -6px; padding: 0 8px; position: relative; z-index: 1; }
.mc-react { border: 1px solid var(--border); background: var(--bg2, var(--surface)); color: var(--text); border-radius: 999px; padding: 1px 7px; font-size: 0.82rem; line-height: 1.5; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
.mc-react span { font-size: 0.72rem; font-weight: 700; color: var(--text2); }
.mc-react.mine { border-color: #2563eb; background: rgba(37, 99, 235, 0.14); }
.mc-react:disabled { cursor: default; }
.mc-flash .mc-bubble { animation: mcFlash 1.8s ease-out; }
@keyframes mcFlash { 0%, 30% { box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.8); } 100% { box-shadow: none; } }
.mc-unhide { display: none; }
.mc-msg.from-blocked .mc-unhide { display: inline-block; border: 0; background: none; color: inherit; font-size: 0.82rem; font-style: italic; padding: 0; cursor: pointer; text-decoration: underline; }
.mc-msg.from-blocked .mc-body, .mc-msg.from-blocked .mc-reacts { display: none; }

/* toolbar */
.mc-actions { display: none; align-self: center; gap: 2px; background: var(--bg2, var(--surface)); border: 1px solid var(--border); border-radius: 999px; padding: 2px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); flex-shrink: 0; }
.mc-actions button { width: 30px; height: 30px; border: 0; background: none; color: var(--text2); border-radius: 50%; font-size: 0.85rem; cursor: pointer; }
.mc-actions button:hover { background: var(--bg3); color: var(--text); }
.mc-actions .mc-danger:hover { color: #dc2626; }
.mc-msg.act .mc-actions { display: flex; }
@media (hover: hover) { .mc-msg:hover .mc-actions { display: flex; } }
.mc-msg.mc-system .mc-actions, .mc-msg.deleted .mc-actions { display: none !important; }

.mc-seen { text-align: right; font-size: 0.7rem; color: var(--text3); margin: 3px 4px 0; }
.mc-seen i { color: #2563eb; }
.mc-newpill { position: absolute; left: 50%; transform: translateX(-50%); bottom: 86px; border: 0; background: #2563eb; color: #fff; border-radius: 999px; padding: 5px 14px; font-size: 0.8rem; font-weight: 600; box-shadow: 0 4px 12px rgba(0,0,0,0.25); z-index: 5; }

/* composer */
.mc-composer-wrap { border-top: 1px solid var(--border); padding: 8px 10px; background: var(--bg2, var(--surface)); flex-shrink: 0; }
.mc-blocked { text-align: center; color: var(--text3); font-size: 0.85rem; padding: 6px; }
.mc-composer { margin: 0; }
.mc-row-input { display: flex; align-items: flex-end; gap: 6px; }
.mc-row-input textarea { flex: 1; resize: none; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 20px; padding: 9px 14px; line-height: 1.35; max-height: 160px; font-size: 16px; outline: none; }
.mc-row-input textarea:focus { border-color: #2563eb; }
.mc-tool { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #2563eb; font-size: 1.35rem; cursor: pointer; margin: 0; flex-shrink: 0; }
.mc-tool:hover { background: var(--bg3); }
.mc-row-input .cs-emoji-btn { width: 40px; height: 40px; border-radius: 50% !important; padding: 0 !important; background: none !important; color: var(--text2) !important; border: 0 !important; font-size: 1.25rem; box-shadow: none !important; }
.mc-row-input .cs-emoji-pop { right: -46px; }
.mc-send { width: 40px; height: 40px; border-radius: 50%; border: 0; background: #2563eb; color: #fff; flex-shrink: 0; font-size: 1rem; }
.mc-send:disabled { opacity: 0.6; }
.mc-replybar { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text2); background: var(--bg3); border-radius: 10px; padding: 6px 10px; margin-bottom: 6px; min-width: 0; }
.mc-replybar > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-x { border: 0; background: none; color: var(--text3); font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.mc-previews { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.mc-prev { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.mc-prev img { width: 100%; height: 100%; object-fit: cover; }
.mc-prev .mc-x { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,0.6); color: #fff; border-radius: 50%; width: 20px; height: 20px; font-size: 0.9rem; padding: 0; }
.mc-edit textarea { width: 100%; min-width: 220px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); padding: 6px 8px; font-size: 0.92rem; }
.mc-edit-btns { display: flex; gap: 6px; justify-content: flex-end; margin: 4px 0 2px; }

/* reaction picker */
.mc-reactpop { position: absolute; z-index: 30; background: var(--bg2, var(--surface)); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); padding: 5px; width: max-content; max-width: min(340px, calc(100% - 8px)); }
.mc-quick { display: flex; gap: 2px; align-items: center; }
.mc-quick button, .mc-egrid button { border: 0; background: none; font-size: 1.4rem; width: 38px; height: 38px; border-radius: 50%; cursor: pointer; line-height: 1; }
.mc-quick button:hover, .mc-egrid button:hover { background: var(--bg3); }
.mc-reactpop button.mine { background: rgba(37, 99, 235, 0.2); box-shadow: inset 0 0 0 1px #2563eb; }
.mc-more { font-size: 0.9rem !important; color: var(--text2); }
.mc-allemoji { max-height: 240px; overflow-y: auto; margin-top: 4px; border-top: 1px solid var(--border); padding-top: 4px; width: 320px; max-width: 100%; }
.mc-egroup { font-size: 0.68rem; font-weight: 800; text-transform: uppercase; color: var(--text3); margin: 6px 4px 2px; }
.mc-egrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); }

.mc-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 10px); background: #1f2937; color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 0.88rem; z-index: 3000; opacity: 0; transition: opacity 0.2s, transform 0.2s; max-width: calc(100vw - 32px); box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.mc-toast.ok { background: #16a34a; }
.mc-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* group: members side panel */
.mc-group-body { flex: 1; min-height: 0; display: flex; }
.mc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mc-side { width: 270px; flex-shrink: 0; border-left: 1px solid var(--border); padding: 12px; overflow-y: auto; display: none; }
@media (min-width: 900px) { .mc-side { display: block; } .mc-page-group:not(.show-side) .mc-side { display: block; } }
.mc-page-group.show-side .mc-side { display: block; }
@media (max-width: 899.98px) {
  .mc-page-group.show-side .mc-side { position: absolute; right: 0; top: 0; bottom: 0; background: var(--bg2, var(--surface)); z-index: 40; box-shadow: -8px 0 24px rgba(0,0,0,0.25); width: min(300px, 85%); }
  .mc-page-group { position: relative; }
}
@media (max-width: 767.98px) {
  .mc-page { height: calc(100dvh - 118px); border-radius: 0; margin: -1rem calc(-1 * var(--cs-gutter, 12px)) 0; border-left: 0; border-right: 0; }
  .mc-stack { max-width: 82%; }
}

/* Full-height chat: the page fits exactly between the header and the bottom of the screen
   (messages-chat.js sets --mc-h from the visible screen height, so it's right on every visit). */
body:has(.mc-page) footer, body:has(.mc-page) .site-footer { display: none !important; }
body:has(.mc-page) .app-main { padding-bottom: 0.75rem !important; }
.mc-page { height: var(--mc-h, calc(100dvh - 150px)); }
@media (max-width: 767.98px) {
  html:has(.mc-page), body:has(.mc-page) { overflow: hidden; }
  body:has(.mc-page) .app-main { padding: 0 !important; }
  body:has(.mc-page) #pwaInstallWrap { display: none !important; }
  .mc-page { height: var(--mc-h, calc(100dvh - 64px)); min-height: 0; margin: 0; max-width: none; width: 100%; border: 0; border-radius: 0; }
}

/* Phone keyboard up: the chat takes exactly the visible space above the keyboard (messages-chat.js). */
.mc-page.mc-kb { position: fixed; left: 0; right: 0; top: var(--mc-kb-top, 0); height: var(--mc-h) !important; min-height: 0 !important; margin: 0 !important; z-index: 1045; border-radius: 0; border: 0; }
