/* ─── FAB Button ─────────────────────────────────────────────── */
.mchat-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10020;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #2b3990;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 14px rgba(0,0,0,.25);
    transition: background .2s, transform .25s cubic-bezier(.4,0,.2,1), opacity .25s;
}
.mchat-fab:hover {
    background: #1e2a6e;
    transform: scale(1.06);
}
.mchat-fab--hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}
.mchat-fab__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74c3c;
    color: #fff;
    border-radius: 10px;
    min-width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

/* ─── Panel ──────────────────────────────────────────────────── */
.mchat-panel {
    position: fixed;
    bottom: 0;
    right: 20px;
    z-index: 10020;
    width: 340px;
    height: 520px;
    background: #fff;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 6px 30px rgba(0,0,0,.20);
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(.96);
    transition: opacity .2s ease-out, transform .2s ease-out;
    pointer-events: none;
}
.mchat-panel--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.mchat-panel--closing {
    opacity: 0;
    transform: translateY(10px) scale(.97);
    pointer-events: none;
}

/* ─── Header ─────────────────────────────────────────────────── */
.mchat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: #2b3990;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}
.mchat-header > span:first-of-type,
.mchat-header__name,
.mchat-header__info {
    flex: 1;
    min-width: 0;
}
.mchat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    opacity: .7;
    transition: opacity .15s, transform .15s;
    margin-left: auto;
}
.mchat-close:hover {
    opacity: 1;
    transform: scale(1.15);
}
.mchat-back {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: .85;
    transition: opacity .15s;
}
.mchat-back:hover { opacity: 1; }
.mchat-header__name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.mchat-header__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.mchat-header__info .mchat-header__name {
    line-height: 1.2;
}
.mchat-header__status {
    font-size: 11px;
    font-weight: 400;
    opacity: .8;
    display: flex;
    align-items: center;
    gap: 4px;
    line-height: 1;
    min-height: 12px;
}
.mchat-header__status--online {
    color: #69f0ae;
}
.mchat-header__status--offline {
    opacity: .55;
}
.mchat-online-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #69f0ae;
    display: block;
    flex-shrink: 0;
}
.mchat-header__name .mchat-icon-wrap {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.mchat-header__name .mchat-icon {
    flex-shrink: 0;
    vertical-align: middle;
}

/* ─── Search ─────────────────────────────────────────────────── */
.mchat-search {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.mchat-search__input {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 18px;
    padding: 7px 14px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
    transition: border-color .15s;
}
.mchat-search__input:focus { border-color: #2b3990; }

/* ─── Contact List ───────────────────────────────────────────── */
.mchat-list {
    flex: 1;
    overflow-y: auto;
    padding: 2px 0;
}
.mchat-section {
    padding: 8px 14px 4px;
    font-size: 11px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.mchat-contact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    cursor: pointer;
    transition: background .15s, transform .1s;
    border-left: 3px solid transparent;
}
.mchat-contact:hover {
    background: #f0f2f8;
    border-left-color: #2b3990;
}
.mchat-contact:active {
    transform: scale(.98);
}
.mchat-contact--inactive {
    opacity: .45;
}
.mchat-contact__left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.mchat-dot {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.mchat-dot::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
}
.mchat-dot--on::before {
    background: #2ecc71;
    box-shadow: 0 0 0 0 rgba(46,204,113,.5);
    animation: mchat-pulse 2s infinite;
}
@keyframes mchat-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(46,204,113,.5); }
    70%  { box-shadow: 0 0 0 6px rgba(46,204,113,0); }
    100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); }
}
.mchat-contact__name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 190px;
}
.mchat-contact__preview {
    font-size: 11px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 190px;
    margin-top: 1px;
}
.mchat-contact__preview img {
    height: 1em;
    width: 1em;
    vertical-align: -0.1em;
    display: inline;
}
.mchat-badge {
    background: #e74c3c;
    color: #fff;
    border-radius: 10px;
    min-width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    flex-shrink: 0;
}
.mchat-contact__right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.mchat-contact__pin {
    font-size: 12px;
    opacity: .5;
    line-height: 1;
}
.mchat-empty, .mchat-loading {
    padding: 24px 14px;
    text-align: center;
    color: #999;
}

/* ─── Chat Messages ──────────────────────────────────────────── */
.mchat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    background: #f4f5f7;
    display: flex;
    flex-direction: column;
    gap: 4px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
}
.mchat-msg {
    max-width: 80%;
    padding: 7px 11px 5px;
    border-radius: 14px;
    word-break: break-word;
    line-height: 1.4;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform .15s ease, background-color .15s;
}
.mchat-msg *,
.mchat-msg__text,
.mchat-msg__time {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.mchat-msg--longpress {
    transform: scale(0.975);
    filter: brightness(.96);
}
.mchat-msg--own {
    align-self: flex-end;
    background: #2b3990;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.mchat-msg--other {
    align-self: flex-start;
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,.07);
}
.mchat-msg--sending { opacity: .55; }
.mchat-msg--error {
    opacity: .7;
    border-left: 2px solid #e53935;
}
.mchat-msg__text { font-size: 13px; }
.mchat-msg__time {
    font-size: 10px;
    opacity: .65;
    margin-top: 3px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    line-height: 1;
    white-space: nowrap;
}

/* ─── Footer ─────────────────────────────────────────────────── */
.mchat-footer {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-top: 1px solid #e5e5e5;
    background: #fff;
    gap: 4px;
    flex-shrink: 0;
}
.mchat-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}
.mchat-input {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 18px;
    padding: 7px 36px 7px 14px;
    font-size: 13px;
    outline: none;
    transition: border-color .15s;
    box-sizing: border-box;
    min-height: 34px;
    max-height: 80px;
    overflow-y: auto;
    line-height: 1.4;
    word-break: break-word;
    white-space: pre-wrap;
}
.mchat-input:empty:before {
    content: attr(data-placeholder);
    color: #aaa;
    pointer-events: none;
}
.mchat-input:focus { border-color: #2b3990; }
.mchat-input img.emoji {
    width: 18px;
    height: 18px;
    vertical-align: -3px;
    margin: 0 1px;
}
.mchat-emoji-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    opacity: .6;
    transition: opacity .15s, transform .15s;
}
.mchat-emoji-btn:hover { opacity: 1; transform: translateY(-50%) scale(1.15); }
.mchat-attach-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color .15s, background .15s;
    flex-shrink: 0;
}
.mchat-attach-btn:hover { color: #2b3990; background: #f0f2f8; }
.mchat-send {
    background: none;
    border: none;
    color: #2b3990;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.mchat-send:hover { color: #1e2a6e; }
.mchat-send svg { width: 24px; height: 24px; }

/* ─── File Preview ───────────────────────────────────────────── */
.mchat-file-preview {
    padding: 6px 10px;
    border-top: 1px solid #eee;
    background: #fafafa;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 120px;
    overflow-y: auto;
    flex-shrink: 0;
}
.mchat-fp-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #e8eaf6;
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 11px;
    max-width: 220px;
}
.mchat-fp-icon { font-size: 13px; flex-shrink: 0; }
.mchat-fp-thumb { flex-shrink: 0; width: 40px; height: 40px; border-radius: 6px; overflow: hidden; }
.mchat-fp-img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 6px; }
.mchat-fp-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mchat-fp-name small { color: #888; }
.mchat-fp-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    color: #666;
    padding: 0 2px;
}
.mchat-fp-remove:hover { color: #e74c3c; }

/* ─── Files in messages ──────────────────────────────────────── */
.mchat-files {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mchat-file-img {
    display: block;
    border-radius: 8px;
    overflow: hidden;
    max-width: 200px;
}
.mchat-file-img img {
    display: block;
    max-width: 100%;
    border-radius: 8px;
}
.mchat-file-link {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: inherit;
    text-decoration: none;
    padding: 4px 8px;
    background: rgba(0,0,0,.06);
    border-radius: 8px;
    transition: background .15s;
}
.mchat-msg--own .mchat-file-link {
    background: rgba(255,255,255,.15);
    color: #fff;
}
.mchat-file-link:hover { background: rgba(0,0,0,.1); }
.mchat-msg--own .mchat-file-link:hover { background: rgba(255,255,255,.25); }
.mchat-file-icon { font-size: 14px; }
.mchat-file-size { opacity: .6; font-size: 10px; }

/* Group header for CRM document source */
.mchat-files-group-title {
    font-size: 11px;
    font-weight: 600;
    color: #5a6a7a;
    padding: 4px 6px 2px;
    margin-top: 4px;
    border-left: 2px solid #3390ec;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 2px;
}
.mchat-files-group-title:first-child { margin-top: 0; }
.mchat-msg--own .mchat-files-group-title {
    color: rgba(255,255,255,.8);
    border-left-color: rgba(255,255,255,.5);
}

/* ─── Emoji Picker ───────────────────────────────────────────── */
.mchat-emoji-picker {
    position: absolute;
    bottom: 52px;
    left: 0;
    right: 0;
    height: 280px;
    background: #fff;
    border-top: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    z-index: 10;
}
.mchat-ep-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
    padding: 4px 6px 0;
    gap: 2px;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    cursor: grab;
}
.mchat-ep-tabs::-webkit-scrollbar { display: none; }
.mchat-ep-tabs.mchat-dragging { cursor: grabbing; }
.mchat-ep-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 6px;
    opacity: .5;
    transition: opacity .15s;
}
.mchat-ep-tab:hover { opacity: .8; }
.mchat-ep-tab--active { opacity: 1; border-bottom-color: #2b3990; }
.mchat-ep-grid {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-content: flex-start;
}
.mchat-ep-emoji {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    border-radius: 6px;
    transition: background .1s, transform .1s;
    user-select: none;
}
.mchat-ep-emoji:hover {
    background: #f0f2f8;
    transform: scale(1.2);
}
.mchat-ep-tab--add {
    opacity: .4;
    font-size: 14px;
    font-weight: 700;
    color: #2b3990;
}
.mchat-ep-tab--add:hover { opacity: .8; }
.mchat-ep-cat-label {
    width: 100%;
    padding: 6px 4px 2px;
    font-size: 11px;
    font-weight: 600;
    color: #888;
    letter-spacing: .3px;
}
.mchat-ep-cat-label:first-child { padding-top: 2px; }
.mchat-ep-pack-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 4px 6px;
    font-size: 11px;
    font-weight: 600;
    color: #666;
}
.mchat-ep-pack-rm {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 10px;
    color: #d32f2f;
    opacity: .7;
    transition: opacity .15s;
}
.mchat-ep-pack-rm:hover { opacity: 1; }
.mchat-ep-add-form {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    top: 32px;
    background: #fff;
    z-index: 5;
    overflow-y: auto;
}
.mchat-ep-add-inner {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.mchat-ep-add-title {
    font-weight: 600;
    font-size: 13px;
    color: #333;
}
.mchat-ep-add-name {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 12px;
    outline: none;
}
.mchat-ep-add-name:focus { border-color: #2b3990; }
.mchat-ep-add-emojis {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 16px;
    outline: none;
    resize: none;
    line-height: 1.5;
}
.mchat-ep-add-emojis:focus { border-color: #2b3990; }
.mchat-ep-add-actions {
    display: flex;
    gap: 8px;
}
.mchat-ep-add-save {
    flex: 1;
    background: #2b3990;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.mchat-ep-add-save:hover { background: #1e2a6e; }
.mchat-ep-add-cancel {
    flex: 1;
    background: #f5f5f5;
    color: #666;
    border: none;
    border-radius: 8px;
    padding: 8px;
    font-size: 12px;
    cursor: pointer;
    transition: background .15s;
}
.mchat-ep-add-cancel:hover { background: #e0e0e0; }

/* ─── Master Picker Tabs (Emoji / Stickers) ──────────────────── */
.mchat-picker-master {
    display: flex;
    border-bottom: 1px solid #e5e5e5;
    flex-shrink: 0;
}
.mchat-pm-tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 12px;
    padding: 6px 4px;
    color: #888;
    transition: color .15s, border-color .15s;
}
.mchat-pm-tab:hover { color: #333; }
.mchat-pm-tab--active {
    color: #2b3990;
    border-bottom-color: #2b3990;
    font-weight: 600;
}
.mchat-picker-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ─── Sticker Picker ─────────────────────────────────────────── */
.mchat-stk-search {
    display: flex;
    padding: 6px;
    gap: 4px;
    flex-shrink: 0;
}
.mchat-stk-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 14px;
    padding: 5px 12px;
    font-size: 12px;
    outline: none;
    box-sizing: border-box;
}
.mchat-stk-input:focus { border-color: #2b3990; }
.mchat-stk-search-btn,
.mchat-stk-add-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    opacity: .7;
    flex-shrink: 0;
}
.mchat-stk-search-btn:hover,
.mchat-stk-add-btn:hover { opacity: 1; }
.mchat-stk-add-btn { font-size: 18px; font-weight: 700; color: #2b3990; }
.mchat-stk-packs {
    display: flex;
    flex-wrap: nowrap;
    gap: 3px;
    padding: 0 6px 4px;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    cursor: grab;
}
.mchat-stk-packs::-webkit-scrollbar { display: none; }
.mchat-stk-packs.mchat-dragging { cursor: grabbing; }
.mchat-stk-pack-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f2f8;
    border: none;
    cursor: pointer;
    font-size: 10px;
    padding: 2px;
    border-radius: 6px;
    color: #999;
    white-space: nowrap;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    transition: background .15s, transform .1s;
}
.mchat-stk-pack-btn:hover { background: #e0e3f0; transform: scale(1.1); }
.mchat-stk-pack-cover {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 4px;
    flex-shrink: 0;
}
.mchat-stk-pack-name {
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    user-select: none;
}
.mchat-stk-pack-btn--custom { position: relative; background: #e8f5e9; }
.mchat-stk-pack-btn--custom:hover { background: #c8e6c9; }
.mchat-stk-pack-rm {
    position: absolute;
    top: -4px;
    right: -4px;
    font-weight: 700;
    font-size: 10px;
    line-height: 1;
    width: 14px;
    height: 14px;
    background: #e74c3c;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    cursor: pointer;
    transition: opacity .15s;
}
.mchat-stk-pack-btn:hover .mchat-stk-pack-rm { opacity: 1; }
/* Touch: hide hover-X entirely, use long-press instead */
@media (pointer: coarse) {
    .mchat-stk-pack-rm { display: none !important; }
}
.mchat-stk-grid {
    flex: 1;
    overflow-y: auto;
    padding: 4px 6px;
}
.mchat-stk-title {
    font-size: 11px;
    font-weight: 600;
    color: #999;
    padding: 2px 0 4px;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.mchat-stk-items {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-content: flex-start;
}
.mchat-stk-item {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 8px;
    transition: background .1s, transform .1s;
    overflow: hidden;
}
.mchat-stk-item:hover {
    background: #f0f2f8;
    transform: scale(1.08);
}
.mchat-stk-thumb {
    max-width: 60px;
    max-height: 60px;
    object-fit: contain;
}
.mchat-stk-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.mchat-stk-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: #2b3990;
    border-radius: 50%;
    animation: mchat-spin .7s linear infinite;
}
@keyframes mchat-spin {
    to { transform: rotate(360deg); }
}
.mchat-stk-lottie {
    width: 60px;
    height: 60px;
    pointer-events: none;
}
.mchat-stk-lottie svg {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* ─── Sticker in message ─────────────────────────────────────── */
.mchat-msg--sticker {
    background: transparent !important;
    box-shadow: none !important;
    padding: 2px !important;
}
.mchat-msg--sticker .mchat-msg__time {
    color: #666;
    opacity: 1;
}
.mchat-msg--sticker .mchat-reactions {
    justify-content: flex-start;
}
.mchat-msg--sticker.mchat-msg--own .mchat-reactions {
    justify-content: flex-end;
}
.mchat-msg--sticker .mchat-reaction {
    background: #e4e4e4;
    border-color: #bbb;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.mchat-msg--sticker .mchat-reaction:hover {
    background: #d6d6d6;
}
.mchat-msg--sticker .mchat-reaction--own {
    background: rgba(43,57,144,.2);
    border-color: rgba(43,57,144,.4);
    box-shadow: 0 1px 3px rgba(43,57,144,.15);
}
.mchat-msg--sticker .mchat-reaction__count {
    color: #222;
}
/* Override .mchat-msg--own transparent styles when sticker */
.mchat-msg--sticker.mchat-msg--own .mchat-reaction {
    background: #e4e4e4;
    border-color: #bbb;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.mchat-msg--sticker.mchat-msg--own .mchat-reaction:hover {
    background: #d6d6d6;
}
.mchat-msg--sticker.mchat-msg--own .mchat-reaction--own {
    background: rgba(43,57,144,.2);
    border-color: rgba(43,57,144,.4);
}
.mchat-msg--sticker.mchat-msg--own .mchat-reaction__count {
    color: #222;
}
.mchat-msg__sticker {
    max-width: 150px;
}
.mchat-sticker-img {
    display: block;
    max-width: 150px;
    max-height: 150px;
    object-fit: contain;
}
.mchat-sticker-lottie {
    width: 150px;
    height: 150px;
}
.mchat-sticker-lottie svg {
    display: block;
    width: 100% !important;
    height: 100% !important;
}
.mchat-sticker-video {
    width: 150px;
    height: 150px;
}
.mchat-sticker-video-el {
    display: block;
    width: 150px;
    height: 150px;
    object-fit: contain;
    border: none;
    background: transparent;
}
.mchat-stk-video {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border: none;
    background: transparent;
}

/* ─── Delete Message Modal ────────────────────────────────────── */
.mchat-delete-modal {
    position: absolute;
    inset: 0;
    z-index: 20;
}
.mchat-dm-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.35);
}
.mchat-dm-dialog {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 14px;
    padding: 18px 20px;
    min-width: 220px;
    box-shadow: 0 8px 30px rgba(0,0,0,.2);
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: mchat-modal-in .15s ease-out;
}
@keyframes mchat-modal-in {
    from { opacity: 0; transform: translate(-50%, -50%) scale(.92); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.mchat-dm-title {
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    padding-bottom: 6px;
    color: #333;
}
.mchat-dm-btn {
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 9px 14px;
    border-radius: 10px;
    transition: background .15s, color .15s;
    font-weight: 500;
}
.mchat-dm-btn--danger {
    background: #fdecea;
    color: #d32f2f;
}
.mchat-dm-btn--danger:hover {
    background: #d32f2f;
    color: #fff;
}
.mchat-dm-btn--cancel {
    background: #f5f5f5;
    color: #666;
}
.mchat-dm-btn--cancel:hover {
    background: #e0e0e0;
    color: #333;
}
.mchat-dm-btn--confirm {
    background: #e3f2fd;
    color: #1976d2;
}
.mchat-dm-btn--confirm:hover {
    background: #1976d2;
    color: #fff;
}

/* ─── Sticker Pack Preview Modal ─────────────────────────── */
.mchat-pack-preview {
    width: auto;
    max-width: calc(100% - 20px);
    max-height: calc(100% - 40px);
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.mchat-pack-preview__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 6px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.mchat-pack-preview__title {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mchat-pack-preview__close {
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 16px;
    padding: 2px;
    line-height: 1;
    flex-shrink: 0;
}
.mchat-pack-preview__close:hover { color: #e74c3c; }
.mchat-pack-preview__grid {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    align-content: flex-start;
    min-height: 0;
}
.mchat-pack-preview__item {
    width: 56px;
    height: 56px;
}
.mchat-pack-preview__footer {
    padding: 6px 12px;
    border-top: 1px solid #eee;
    text-align: center;
    flex-shrink: 0;
}
.mchat-pack-preview__info {
    font-size: 12px;
    color: #4caf50;
    font-weight: 500;
}
.mchat-pack-preview__add {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    padding: 6px 12px;
}

/* ─── Deleted message placeholder ─────────────────────────── */
.mchat-msg--deleted {
    opacity: .65;
}
.mchat-msg__deleted {
    font-size: 12px;
    font-style: italic;
    color: #999;
    padding: 4px 8px;
}

/* ─── Twemoji in messages ────────────────────────────────────── */
.mchat-msg__text img.emoji,
.mchat-channel-msg__text img.emoji,
.mchat-channel-msg__bubble img.emoji {
    width: 20px;
    height: 20px;
    vertical-align: -4px;
    margin: 0 1px;
}
.mchat-ep-emoji img.emoji {
    width: 22px;
    height: 22px;
    pointer-events: none;
}
.mchat-ep-tab img.emoji {
    width: 16px;
    height: 16px;
}
.mchat-pm-tab img.emoji {
    width: 14px;
    height: 14px;
    vertical-align: -2px;
}

/* ─── Online widget chat button ──────────────────────────────── */
.makpp-chat-open {
    background: none;
    border: none;
    cursor: pointer;
    color: #2b3990;
    padding: 2px;
    display: inline-flex;
    align-items: center;
    opacity: .7;
    transition: opacity .15s, color .15s;
}
.makpp-chat-open:hover { opacity: 1; color: #e74c3c; }

/* ─── Scrollbar ──────────────────────────────────────────────── */
.mchat-messages::-webkit-scrollbar,
.mchat-list::-webkit-scrollbar { width: 5px; }
.mchat-messages::-webkit-scrollbar-track,
.mchat-list::-webkit-scrollbar-track { background: transparent; }
.mchat-messages::-webkit-scrollbar-thumb,
.mchat-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* ─── Lightbox Gallery ───────────────────────────────────────── */
.mchat-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .2s ease-out;
}
.mchat-lightbox.mchat-lb--open { opacity: 1; }
.mchat-lb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.88);
}
.mchat-lb-close {
    position: absolute;
    top: 16px; right: 20px;
    z-index: 2;
    background: none;
    border: none;
    color: #fff;
    font-size: 36px;
    cursor: pointer;
    line-height: 1;
    opacity: .8;
    transition: opacity .15s;
}
.mchat-lb-close:hover { opacity: 1; }
.mchat-lb-prev, .mchat-lb-next {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    z-index: 2;
    background: rgba(255,255,255,.12);
    border: none;
    color: #fff;
    font-size: 40px;
    width: 48px; height: 64px;
    cursor: pointer;
    border-radius: 8px;
    transition: background .15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mchat-lb-prev { left: 12px; }
.mchat-lb-next { right: 12px; }
.mchat-lb-prev:hover, .mchat-lb-next:hover { background: rgba(255,255,255,.25); }
.mchat-lb-content {
    position: relative;
    z-index: 1;
    max-width: 92vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mchat-lb-img {
    max-width: 92vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 4px;
    user-select: none;
}
.mchat-lb-video {
    max-width: 92vw;
    max-height: 88vh;
    border-radius: 4px;
    outline: none;
}
.mchat-lb-counter {
    position: absolute;
    bottom: 18px;
    left: 50%; transform: translateX(-50%);
    z-index: 2;
    color: rgba(255,255,255,.7);
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ─── Video file thumb in messages ───────────────────────────── */
.mchat-file-video {
    position: relative;
}
.mchat-file-video-thumb {
    display: block;
    max-width: 100%;
    border-radius: 8px;
    max-height: 180px;
}
.mchat-file-play {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 32px;
    text-shadow: 0 2px 8px rgba(0,0,0,.5);
    pointer-events: none;
}

/* ─── CRM File Picker ────────────────────────────────────────── */
.mchat-crm-picker,
.mchat-lead-picker,
.mchat-lead-links-picker {
    position: absolute;
    inset: 0;
    z-index: 22;
    background: #fff;
    display: flex;
    flex-direction: column;
    animation: mchat-slide-up .15s ease-out;
}
@keyframes mchat-slide-up {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}
.mchat-crm-header {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: #2b3990;
    color: #fff;
    flex-shrink: 0;
}
.mchat-crm-title {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
}
.mchat-crm-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}
.mchat-crm-back {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: .85;
    transition: opacity .15s;
    margin-right: 4px;
}
.mchat-crm-back:hover { opacity: 1; }
.mchat-crm-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.mchat-crm-tab {
    flex: 1;
    border: none;
    background: #f5f5f5;
    padding: 8px 0;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: #666;
    transition: background .15s, color .15s;
}
.mchat-crm-tab--active {
    background: #fff;
    color: #2b3990;
    box-shadow: inset 0 -2px 0 #2b3990;
}
.mchat-crm-search {
    padding: 8px 10px;
    flex-shrink: 0;
}
.mchat-lead-dialog-search {
    background: #fff;
    border-bottom: 1px solid #eceff3;
}
.mchat-lead-status-strip {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 7px 10px 8px;
    background: #fff;
    border-bottom: 1px solid #eceff3;
    flex-shrink: 0;
    scrollbar-width: none;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
}
.mchat-lead-status-strip::-webkit-scrollbar {
    display: none;
}
.mchat-lead-status-chip {
    appearance: none;
    border: 1px solid #dbe3f0;
    border-radius: 999px;
    background: #f8fafc;
    color: #475569;
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    min-height: 28px;
    padding: 0 10px;
    white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
}
.mchat-lead-status-chip:hover {
    background: #eef2ff;
    border-color: #c8d6fb;
    color: #2b3990;
}
.mchat-lead-status-chip:active {
    transform: scale(.98);
}
.mchat-lead-status-chip--active {
    background: #2b3990;
    border-color: #2b3990;
    color: #fff;
}
.mchat-lead-status-chip--special {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412;
}
.mchat-lead-status-chip--special:hover {
    background: #ffedd5;
    border-color: #fdba74;
    color: #7c2d12;
}
.mchat-lead-status-chip--special.mchat-lead-status-chip--active {
    background: #d97706;
    border-color: #d97706;
    color: #fff;
}
.mchat-crm-search-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 12px;
    outline: none;
    transition: border-color .15s;
}
.mchat-crm-search-input:focus {
    border-color: #2b3990;
}
.mchat-crm-old-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    user-select: none;
}
.mchat-crm-old-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #2b3990;
    margin: 0;
    cursor: pointer;
}
.mchat-crm-results {
    flex: 1;
    overflow-y: auto;
    padding: 4px 10px 8px;
}
.mchat-crm-item {
    margin-bottom: 10px;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
}
.mchat-crm-item-header {
    padding: 8px 10px;
    background: #f8f9fa;
    font-size: 12px;
    border-bottom: 1px solid #eee;
}
.mchat-crm-item-id {
    color: #999;
    font-weight: 400;
}
.mchat-crm-group {
    padding: 4px 0;
}
.mchat-crm-group-label {
    padding: 3px 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: #999;
    letter-spacing: .5px;
}
.mchat-crm-file {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: background .1s;
}
.mchat-crm-file:hover {
    background: #f0f2ff;
}
.mchat-crm-cb {
    flex-shrink: 0;
    accent-color: #2b3990;
}
.mchat-crm-file-icon {
    font-size: 14px;
    flex-shrink: 0;
}
.mchat-crm-file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mchat-crm-file-size {
    color: #999;
    font-size: 10px;
    flex-shrink: 0;
}
.mchat-crm-footer-bar {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    gap: 8px;
}
.mchat-crm-sel-count {
    flex: 1;
    font-size: 12px;
    color: #666;
}
.mchat-crm-send-btn {
    background: #2b3990;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 7px 18px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.mchat-crm-send-btn:hover { background: #1e2a6e; }
.mchat-crm-send-btn:disabled { opacity: .5; cursor: not-allowed; }
.mchat-crm-send-btn--ghost {
    background: #eef2ff;
    color: #2b3990;
}
.mchat-crm-send-btn--ghost:hover {
    background: #dfe6ff;
}

/* CRM picker scrollbar */
.mchat-crm-results::-webkit-scrollbar { width: 5px; }
.mchat-crm-results::-webkit-scrollbar-track { background: transparent; }
.mchat-crm-results::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

.mchat-lead-footer-note {
    flex: 1;
    font-size: 12px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mchat-lead-item {
    width: 100%;
    border: 1px solid #e6e9f4;
    border-radius: 10px;
    background: #fff;
    padding: 10px 12px;
    margin-bottom: 10px;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, transform .1s;
}
.mchat-lead-item:hover {
    border-color: #c7cff1;
    box-shadow: 0 6px 18px rgba(43,57,144,.08);
}
.mchat-lead-item:active {
    transform: scale(.995);
}
.mchat-lead-item--selected {
    border-color: #2b3990;
    box-shadow: 0 0 0 2px rgba(43,57,144,.12);
}
.mchat-lead-item__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
.mchat-lead-item__top strong {
    font-size: 13px;
    color: #1f2937;
}
.mchat-lead-item__id {
    font-size: 11px;
    color: #64748b;
    flex-shrink: 0;
}
.mchat-lead-item__meta,
.mchat-lead-item__footer {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    font-size: 11px;
    color: #64748b;
}
.mchat-lead-item__summary {
    margin: 7px 0;
    font-size: 12px;
    line-height: 1.45;
    color: #475569;
}
.mchat-lead-repeat {
    color: #b45309;
    font-weight: 600;
}

.mchat-relations-wrap {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.mchat-relations-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    gap: 8px;
}
.mchat-relations-stat {
    appearance: none;
    width: 100%;
    border: 1px solid #e2e8f5;
    padding: 10px 8px;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
    text-align: center;
    font: inherit;
    cursor: default;
    transition: transform .12s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.mchat-relations-stat--link {
    cursor: pointer;
}
.mchat-relations-stat--link:hover {
    border-color: #c8d6fb;
    box-shadow: 0 10px 24px rgba(43, 57, 144, .08);
    transform: translateY(-1px);
}
.mchat-relations-stat--link:active {
    transform: translateY(0) scale(.99);
}
.mchat-relations-stat--disabled {
    opacity: .72;
}
.mchat-relations-lead-card[data-rel-target],
.mchat-relations-section[data-rel-target],
.mchat-relations-subsection[data-rel-target] {
    scroll-margin-top: 8px;
}
.mchat-relations-target--flash {
    animation: mchat-relations-target-flash 1.05s ease;
}
@keyframes mchat-relations-target-flash {
    0% {
        transform: translateY(8px);
        box-shadow: 0 0 0 0 rgba(43, 57, 144, 0), 0 8px 24px rgba(15, 23, 42, .04);
    }
    35% {
        transform: translateY(0);
        box-shadow: 0 0 0 2px rgba(43, 57, 144, .18), 0 14px 28px rgba(43, 57, 144, .10);
    }
    100% {
        transform: translateY(0);
        box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
    }
}
.mchat-relations-stat__value {
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    color: #1f2937;
}
.mchat-relations-stat__label {
    margin-top: 4px;
    font-size: 11px;
    color: #64748b;
}
.mchat-relations-lead-card,
.mchat-relations-section,
.mchat-relations-contract {
    border: 1px solid #e6e9f4;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}
.mchat-relations-lead-card {
    padding: 12px;
}
.mchat-relations-lead-card--current {
    background: linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
    border-color: #cdd8fb;
}
.mchat-relations-lead-card--original {
    background: linear-gradient(180deg, #ffffff 0%, #fff9ef 100%);
    border-color: #f1d8ad;
}
.mchat-relations-lead-card__label,
.mchat-relations-section__title,
.mchat-relations-subsection__title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #64748b;
}
.mchat-relations-lead-card__title,
.mchat-relations-contract__title,
.mchat-relations-item__title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    color: #1f2937;
}
.mchat-relations-lead-card__title {
    margin-top: 6px;
}
.mchat-relations-section,
.mchat-relations-contract {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.mchat-relations-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid #edf1f7;
    background: #fbfcff;
}
.mchat-relations-item--compact {
    padding: 9px 10px;
    gap: 6px;
}
.mchat-relations-item__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}
.mchat-relations-item__badges,
.mchat-relations-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.mchat-relations-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: #374151;
    font-size: 10px;
    font-weight: 700;
}
.mchat-relations-badge--original {
    background: #fff3d6;
    color: #9a6700;
}
.mchat-relations-badge--current {
    background: #dcfce7;
    color: #166534;
}
.mchat-relations-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.mchat-relations-meta span {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 11px;
    line-height: 1.3;
}
.mchat-relations-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: #2b3990;
    color: #fff;
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
    transition: background .15s, transform .1s;
}
.mchat-relations-link:hover {
    background: #1e2a6e;
}
.mchat-relations-link:active {
    transform: scale(.98);
}
.mchat-relations-link--ghost {
    background: #eef2ff;
    color: #2b3990;
}
.mchat-relations-link--ghost:hover {
    background: #dfe6ff;
}
.mchat-relations-link--accent {
    background: #d7f4e8;
    color: #116149;
}
.mchat-relations-link--accent:hover {
    background: #bfead8;
}
.mchat-relations-subsection {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #edf2f7;
}
.mchat-relations-item__desc {
    font-size: 12px;
    line-height: 1.45;
    color: #475569;
}
.mchat-relations-payment-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.mchat-relations-payment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e8edf5;
}
.mchat-relations-payment-item__title {
    font-size: 12px;
    font-weight: 700;
    color: #1f2937;
}
.mchat-relations-payment-item__meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}
.mchat-relations-payment-item__meta span {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 11px;
}
.mchat-relations-track-chip {
    appearance: none;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 100%;
    min-height: 28px;
    padding: 4px 8px;
    border: 1px solid #d8e0ec;
    border-radius: 999px;
    background: #f8fafc;
    color: #334155;
    cursor: pointer;
    font: inherit;
    text-align: left;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.mchat-relations-track-chip:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}
.mchat-relations-track-chip:active {
    transform: scale(.98);
}
.mchat-track-logo {
    display: block;
    flex: 0 0 auto;
    object-fit: contain;
    opacity: .72;
}
.mchat-track-logo--cdek {
    width: 46px;
    height: 15px;
}
.mchat-track-logo--pochta {
    width: 34px;
    height: 24px;
}
.mchat-track-number {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    color: #334155;
}
.mchat-relations-track-chip--empty {
    border-color: #f1d4a4;
    background: #fff8ea;
    color: #9a6700;
    cursor: default;
}
.mchat-relations-track-chip--empty span {
    color: #9a6700;
}
.mchat-relations-lead-card__label,
.mchat-relations-lead-card__title,
.mchat-relations-section__title,
.mchat-relations-subsection__title,
.mchat-relations-contract__title,
.mchat-relations-item__title,
.mchat-relations-item__desc,
.mchat-relations-meta span,
.mchat-relations-payment-item__title,
.mchat-relations-payment-item__meta span,
.mchat-relations-track-chip {
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.mchat-relations-lead-card__label:active,
.mchat-relations-lead-card__title:active,
.mchat-relations-section__title:active,
.mchat-relations-subsection__title:active,
.mchat-relations-contract__title:active,
.mchat-relations-item__title:active,
.mchat-relations-item__desc:active,
.mchat-relations-meta span:active,
.mchat-relations-payment-item__title:active,
.mchat-relations-payment-item__meta span:active,
.mchat-relations-track-chip:active {
    opacity: .82;
}
.mchat-relations-track-chip--empty {
    cursor: default;
}
.mchat-relations-track-chip--empty:active {
    opacity: 1;
    transform: none;
}

/* ─── CRM button in footer ───────────────────────────────────── */
.mchat-crm-btn,
.mchat-lead-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: color .15s, background .15s;
    flex-shrink: 0;
}
.mchat-crm-btn:hover,
.mchat-lead-btn:hover {
    color: #2b3990;
    background: rgba(43,57,144,.08);
}

/* ─── Three-dot menu ─────────────────────────────────────────── */
.mchat-header-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 2px;
}
.mchat-lead-mode-toggle {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.24);
    border-radius: 8px;
    background: rgba(255,255,255,.1);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: .9;
    transition: background .15s ease, border-color .15s ease, transform .1s ease, opacity .15s ease;
}
.mchat-lead-mode-toggle:hover {
    background: rgba(255,255,255,.18);
    border-color: rgba(255,255,255,.38);
    opacity: 1;
}
.mchat-lead-mode-toggle:active {
    transform: scale(.96);
}
.mchat-lead-mode-toggle--operations {
    background: rgba(251,191,36,.22);
    border-color: rgba(251,191,36,.48);
}
.mchat-lead-mode-toggle svg {
    display: block;
    flex: 0 0 auto;
}
.mchat-search-msg-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    display: flex;
    opacity: .7;
    transition: opacity .15s;
}
.mchat-search-msg-btn:hover { opacity: 1; }
.mchat-dots-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1;
    opacity: .8;
    transition: opacity .15s;
    letter-spacing: 2px;
}
.mchat-dots-btn:hover { opacity: 1; }
.mchat-dots-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,.18);
    min-width: 180px;
    z-index: 30;
    overflow: hidden;
    animation: mchat-dd-in .12s ease-out;
    transform-origin: top right;
}
@keyframes mchat-dd-in {
    from { opacity: 0; transform: scale(.9); }
    to   { opacity: 1; transform: scale(1); }
}
.mchat-dd-item {
    display: block;
    width: 100%;
    border: none;
    background: none;
    text-align: left;
    padding: 10px 14px;
    font-size: 13px;
    cursor: pointer;
    color: #333;
    transition: background .1s;
}
.mchat-dd-item:hover { background: #f0f2f8; }

/* ─── Task Modal (create task from chat) ─────────────────────── */
.mchat-task-modal {
    position: absolute;
    inset: 0;
    z-index: 25;
}
.mchat-task-dialog {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 14px;
    padding: 18px 20px;
    width: 290px;
    max-width: 92%;
    box-shadow: 0 8px 30px rgba(0,0,0,.2);
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: mchat-task-in .15s ease-out;
}
@keyframes mchat-task-in {
    from { opacity: 0; transform: translate(-50%, -50%) scale(.95); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.mchat-task-title {
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    color: #333;
    padding-bottom: 4px;
}
.mchat-task-input {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
    width: 100%;
}
.mchat-task-input:focus { border-color: #2b3990; }
.mchat-task-textarea {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    resize: none;
    box-sizing: border-box;
    width: 100%;
}
.mchat-task-textarea:focus { border-color: #2b3990; }
.mchat-task-select {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    background: #fff;
    box-sizing: border-box;
    width: 100%;
}
.mchat-task-select:focus { border-color: #2b3990; }
.mchat-task-row {
    display: flex;
    gap: 8px;
}
.mchat-task-select--half,
.mchat-task-input--half {
    flex: 1;
    min-width: 0;
}
.mchat-task-actions {
    display: flex;
    gap: 8px;
    padding-top: 4px;
}
.mchat-task-btn {
    flex: 1;
    border: none;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.mchat-task-btn--save {
    background: #2b3990;
    color: #fff;
}
.mchat-task-btn--save:hover { background: #1e2a6e; }
.mchat-task-btn--save:disabled { opacity: .5; cursor: not-allowed; }
.mchat-task-btn--cancel {
    background: #f5f5f5;
    color: #666;
}
.mchat-task-btn--cancel:hover { background: #e0e0e0; }

/* ─── Task message card ──────────────────────────────────────── */
.mchat-msg--special {
    max-width: 85%;
}
.mchat-msg--lead {
    padding: 10px 12px 6px;
}
/* ─── Task card ──────────────────────────────────────────────── */
.mchat-msg-task {
    display: flex;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
    min-width: 200px;
}
.mchat-msg--own .mchat-msg-task {
    background: rgba(255,255,255,.12);
    box-shadow: none;
}
.mchat-msg-task__stripe {
    width: 4px;
    flex-shrink: 0;
    border-radius: 4px 0 0 4px;
}
.mchat-task-prio--low .mchat-msg-task__stripe { background: #a0aec0; }
.mchat-task-prio--normal .mchat-msg-task__stripe { background: #4a90d9; }
.mchat-task-prio--high .mchat-msg-task__stripe { background: #ed8936; }
.mchat-task-prio--urgent .mchat-msg-task__stripe { background: #e53e3e; }
.mchat-msg-task__content {
    flex: 1;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mchat-msg-task__header {
    display: flex;
    align-items: center;
    gap: 4px;
}
.mchat-msg-task__icon {
    display: inline-flex;
    color: #718096;
}
.mchat-msg--own .mchat-msg-task__icon { color: rgba(255,255,255,.6); }
.mchat-msg-task__label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: #718096;
    flex: 1;
}
.mchat-msg--own .mchat-msg-task__label { color: rgba(255,255,255,.6); }
.mchat-msg-task__prio-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 8px;
    letter-spacing: .2px;
}
.mchat-task-prio--low .mchat-msg-task__prio-badge { background: #edf2f7; color: #718096; }
.mchat-task-prio--normal .mchat-msg-task__prio-badge { background: #ebf4ff; color: #2b6cb0; }
.mchat-task-prio--high .mchat-msg-task__prio-badge { background: #fefcbf; color: #c05621; }
.mchat-task-prio--urgent .mchat-msg-task__prio-badge { background: #fff5f5; color: #c53030; }
.mchat-msg--own .mchat-msg-task__prio-badge { background: rgba(255,255,255,.18); color: #fff; }
.mchat-msg-task__title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    color: #1a202c;
}
.mchat-msg--own .mchat-msg-task__title { color: #fff; }
.mchat-msg-task__desc {
    font-size: 12px;
    color: #4a5568;
    line-height: 1.35;
}
.mchat-msg--own .mchat-msg-task__desc { color: rgba(255,255,255,.75); }
.mchat-msg-task__footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
    color: #718096;
    margin-top: 2px;
    align-items: center;
}
.mchat-msg--own .mchat-msg-task__footer { color: rgba(255,255,255,.55); }
.mchat-msg-task__assignee,
.mchat-msg-task__date {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

/* ─── Lead message card ──────────────────────────────────────── */
.mchat-msg-lead {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    max-width: 360px;
    padding: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    word-break: normal;
    overflow-wrap: normal;
}
.mchat-msg--own .mchat-msg-lead {
    background: transparent;
    box-shadow: none;
}
.mchat-msg-lead--has-menu .mchat-msg-lead__header {
    padding-right: 34px;
}
.mchat-msg-lead__card-menu {
    position: absolute;
    top: -3px;
    right: -4px;
    z-index: 6;
}
.mchat-msg-lead__menu-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(43,57,144,.08);
    color: #475569;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, transform .1s ease;
}
.mchat-msg-lead__menu-btn:hover,
.mchat-msg-lead__menu-btn[aria-expanded="true"] {
    background: rgba(43,57,144,.16);
    color: #2b3990;
}
.mchat-msg-lead__menu-btn:active {
    transform: scale(.96);
}
.mchat-msg-lead__menu-btn svg {
    width: 18px;
    height: 18px;
}
.mchat-msg-lead__menu {
    position: absolute;
    top: 32px;
    right: 0;
    min-width: 178px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 28px rgba(15,23,42,.18);
    overflow: hidden;
    z-index: 7;
    animation: mchat-dd-in .12s ease-out;
    transform-origin: top right;
}
.mchat-msg-lead__menu[hidden] {
    display: none;
}
.mchat-msg-lead__menu-item {
    appearance: none;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: #1f2937;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    transition: background .12s ease, color .12s ease;
}
.mchat-msg-lead__menu-item:hover {
    background: #f1f5f9;
    color: #2b3990;
}
.mchat-msg-lead__menu-item svg {
    flex: 0 0 auto;
    margin-right: 0 !important;
}
.mchat-msg--own .mchat-msg-lead__menu-btn {
    background: rgba(255,255,255,.14);
    color: rgba(255,255,255,.88);
}
.mchat-msg--own .mchat-msg-lead__menu-btn:hover,
.mchat-msg--own .mchat-msg-lead__menu-btn[aria-expanded="true"] {
    background: rgba(255,255,255,.24);
    color: #fff;
}
.mchat-msg-lead__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px 10px;
    flex-wrap: wrap;
}
.mchat-msg-lead__badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    max-width: 100%;
}
.mchat-msg-lead__badge-divider {
    width: 1px;
    height: 20px;
    background: #dbe3f0;
    border-radius: 999px;
    flex: 0 0 auto;
}
.mchat-msg-lead__track {
    appearance: none;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 100%;
    min-height: 30px;
    padding: 4px 8px;
    border: 1px solid #d8e0ec;
    border-radius: 9px;
    background: #f8fafc;
    color: #334155;
    cursor: pointer;
    font: inherit;
    text-align: left;
    transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.mchat-msg-lead__track:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}
.mchat-msg-lead__track:active {
    transform: scale(.98);
}
.mchat-msg-lead__track svg {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
}
.mchat-msg-lead__track .mchat-track-number {
    color: #334155;
}
.mchat-msg--own .mchat-msg-lead__track {
    border-color: rgba(255,255,255,.2);
    background: rgba(255,255,255,.1);
    color: rgba(255,255,255,.84);
}
.mchat-msg--own .mchat-msg-lead__track:hover {
    background: rgba(255,255,255,.16);
}
.mchat-msg--own .mchat-msg-lead__track .mchat-track-number {
    color: rgba(255,255,255,.9);
}
.mchat-msg-lead__envelope {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 4px 9px;
    border-radius: 9px;
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}
.mchat-msg-lead__envelope svg {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
}
.mchat-msg--own .mchat-msg-lead__envelope {
    background: rgba(251,191,36,.16);
    border-color: rgba(251,191,36,.28);
    color: #fde68a;
}
.mchat-msg-lead__debt {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 28px;
    padding: 4px 8px;
    border-radius: 9px;
    border: 1px solid transparent;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}
.mchat-msg-lead__debt svg {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
}
.mchat-msg-lead__debt--ok {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #047857;
}
.mchat-msg-lead__debt--bad {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}
.mchat-msg--own .mchat-msg-lead__badge-divider {
    background: rgba(255,255,255,.22);
}
.mchat-msg--own .mchat-msg-lead__debt--ok {
    background: rgba(34,197,94,.16);
    border-color: rgba(134,239,172,.32);
    color: #bbf7d0;
}
.mchat-msg--own .mchat-msg-lead__debt--bad {
    background: rgba(239,68,68,.16);
    border-color: rgba(252,165,165,.32);
    color: #fecaca;
}
.mchat-msg-lead__title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1 1 210px;
}
.mchat-msg-lead__icon {
    display: inline-flex;
    color: #2b3990;
    flex-shrink: 0;
}
.mchat-msg--own .mchat-msg-lead__icon {
    color: rgba(255,255,255,.8);
}
.mchat-msg-lead__title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    color: #1f2937;
    overflow-wrap: anywhere;
    word-break: normal;
    min-width: 0;
}
.mchat-msg--own .mchat-msg-lead__title,
.mchat-msg--own .mchat-msg-lead__client {
    color: #fff;
}
.mchat-msg-lead__status {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: #2b3990;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.25;
    white-space: normal;
    max-width: 100%;
}
.mchat-msg--own .mchat-msg-lead__status {
    background: rgba(255,255,255,.16);
    color: #fff;
}
.mchat-msg-lead__client {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    overflow-wrap: anywhere;
    word-break: normal;
}
.mchat-msg-lead__phone,
.mchat-msg-lead__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    font-size: 12px;
    color: #64748b;
}
.mchat-msg-lead__phone {
    align-items: center;
    gap: 6px;
    width: auto;
    max-width: 100%;
    padding: 0;
    border-radius: 0;
    background: transparent;
    font-weight: 600;
}
.mchat-msg--own .mchat-msg-lead__phone,
.mchat-msg--own .mchat-msg-lead__meta,
.mchat-msg--own .mchat-msg-lead__summary,
.mchat-msg--own .mchat-msg-lead__repeat {
    color: rgba(255,255,255,.78);
}
.mchat-msg-lead__meta {
    flex-direction: column;
    align-items: flex-start;
}
.mchat-msg-lead__meta span {
    display: block;
    padding: 0;
    border-radius: 0;
    background: transparent;
}
.mchat-msg-lead__title,
.mchat-msg-lead__client,
.mchat-msg-lead__phone,
.mchat-msg-lead__meta span,
.mchat-msg-lead__summary,
.mchat-msg-lead__repeat {
    cursor: pointer;
}
.mchat-msg-lead__title:active,
.mchat-msg-lead__client:active,
.mchat-msg-lead__phone:active,
.mchat-msg-lead__meta span:active,
.mchat-msg-lead__summary:active,
.mchat-msg-lead__repeat:active {
    opacity: .82;
}
.mchat-msg-lead__summary {
    font-size: 12px;
    line-height: 1.45;
    color: #475569;
    overflow-wrap: anywhere;
    word-break: normal;
}
.mchat-msg-lead__summary-label {
    font-weight: 800;
    color: #334155;
}
.mchat-msg--own .mchat-msg-lead__summary-label {
    color: #fff;
}
.mchat-msg-lead__repeat {
    font-size: 11px;
    font-weight: 700;
    color: #b45309;
    display: inline-flex;
    align-items: center;
    width: auto;
    max-width: 100%;
    padding: 0;
    border-radius: 0;
    background: transparent;
}
.mchat-msg-lead__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 4px;
    align-items: center;
}
.mchat-msg-lead__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 999px;
    width: 32px;
    height: 32px;
    padding: 0;
    background: #eef2ff;
    color: #2b3990;
    line-height: 0;
    cursor: pointer;
    transition: background .15s, color .15s, transform .1s;
}
.mchat-msg-lead__action svg {
    display: block;
    width: 16px;
    height: 16px;
}
.mchat-msg-lead__action:hover {
    background: #dfe6ff;
}
.mchat-msg-lead__action:active {
    transform: scale(.98);
}
.mchat-msg-lead__action--wa,
.mchat-msg-lead__action--tg {
    background: rgba(43,57,144,.1);
}
.mchat-msg-lead__action--relations {
    color: #0f766e;
    background: rgba(15,118,110,.14);
}
.mchat-msg-lead__action--wa {
    color: #1f9d57;
    background: rgba(37,211,102,.14);
}
.mchat-msg-lead__action--tg {
    color: #1d8ec6;
    background: rgba(34,158,217,.14);
}
.mchat-msg--own .mchat-msg-lead__action {
    background: rgba(255,255,255,.16);
    color: #fff;
}
.mchat-msg--own .mchat-msg-lead__action:hover {
    background: rgba(255,255,255,.22);
}
.mchat-msg--own .mchat-msg-lead__action--relations {
    color: #8ce9dc;
    background: rgba(15,118,110,.22);
}
.mchat-msg--own .mchat-msg-lead__action--relations:hover {
    background: rgba(15,118,110,.3);
}
.mchat-msg--own .mchat-msg-lead__action--wa {
    color: #87eba9;
    background: rgba(37,211,102,.22);
}
.mchat-msg--own .mchat-msg-lead__action--wa:hover {
    background: rgba(37,211,102,.3);
}
.mchat-msg--own .mchat-msg-lead__action--tg {
    color: #8fd7ff;
    background: rgba(34,158,217,.22);
}
.mchat-msg--own .mchat-msg-lead__action--tg:hover {
    background: rgba(34,158,217,.3);
}

@media (max-width: 520px) {
    .mchat-msg-lead {
        min-width: 0;
        max-width: 100%;
    }
    .mchat-msg-lead__header {
        gap: 8px;
    }
    .mchat-msg-lead__status {
        width: 100%;
    }
    .mchat-relations-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ─── Emoji pack message card ────────────────────────────────── */
.mchat-msg-emojipack {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mchat-msg-emojipack__head {
    font-size: 11px;
    font-weight: 600;
    opacity: .7;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.mchat-msg-emojipack__name {
    font-size: 14px;
    font-weight: 600;
}
.mchat-msg-emojipack__preview {
    font-size: 20px;
    line-height: 1.3;
}
.mchat-msg-emojipack__preview img.emoji {
    width: 22px;
    height: 22px;
    vertical-align: -4px;
}
.mchat-msg-emojipack__add {
    background: rgba(0,0,0,.08);
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: #333;
    transition: background .15s;
    align-self: flex-start;
    margin-top: 2px;
}
.mchat-msg-emojipack__add:hover { background: rgba(0,0,0,.14); }
.mchat-msg-emojipack__add:disabled { opacity: .5; cursor: default; }
.mchat-msg--own .mchat-msg-emojipack__add {
    background: rgba(255,255,255,.2);
    color: #fff;
}

/* ─── Share button in emoji pack header ──────────────────────── */
.mchat-ep-pack-actions {
    display: flex;
    gap: 8px;
}
.mchat-ep-pack-share {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 10px;
    color: #2b3990;
    opacity: .7;
    transition: opacity .15s;
}
.mchat-ep-pack-share:hover { opacity: 1; }

/* ─── Toast notification ─────────────────────────────────────── */
.mchat-toast {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #333;
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    z-index: 100001;
    opacity: 0;
    transition: opacity .25s, transform .25s;
    pointer-events: none;
    white-space: nowrap;
}
.mchat-toast--show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ─── Context Menu ────────────────────────────────────────────── */
.mchat-ctx-menu {
    position: absolute;
    z-index: 10010;
    min-width: 200px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0,0,0,.18);
    padding: 6px 0;
    animation: mchat-ctx-in .12s ease-out;
}
@keyframes mchat-ctx-in {
    from { opacity: 0; transform: scale(.92); }
    to   { opacity: 1; transform: scale(1); }
}
.mchat-ctx-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 16px;
    border: none;
    background: none;
    font-size: 13px;
    color: #222;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}
.mchat-ctx-item:hover {
    background: #f0f0f0;
}
.mchat-ctx-item:active {
    background: #e8e8e8;
}
.mchat-ctx-item--danger {
    color: #e53935;
}
.mchat-ctx-item--danger:hover {
    background: #fce4ec;
}
.mchat-ctx-item--danger:active {
    background: #f8d0d5;
}
/* Bottom-sheet overlay for mobile context menu */
.mchat-ctx-overlay {
    display: none;
}
.mchat-ctx-menu--sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    min-width: 0;
    max-height: 70vh;
    overflow-y: auto;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -4px 30px rgba(0,0,0,.22);
    z-index: 10030;
    animation: mchat-ctx-sheet-in .2s ease-out;
    padding-bottom: env(safe-area-inset-bottom, 8px);
}
.mchat-ctx-menu--sheet .mchat-ctx-item {
    padding: 14px 20px;
    font-size: 15px;
}
@keyframes mchat-ctx-sheet-in {
    from { opacity: 0; transform: translateY(100%); }
    to   { opacity: 1; transform: translateY(0); }
}
.mchat-ctx-overlay--visible {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 10029;
    background: rgba(0,0,0,.35);
    animation: mchat-ctx-fade .15s ease-out;
}
@keyframes mchat-ctx-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ─── Reply Bar (above footer) ────────────────────────────────── */
.mchat-reply-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f0f4ff;
    border-left: 3px solid #4a90d9;
    margin: 0;
    animation: mchat-reply-in .15s ease-out;
}
@keyframes mchat-reply-in {
    from { opacity: 0; max-height: 0; }
    to   { opacity: 1; max-height: 60px; }
}
.mchat-reply-bar__content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.mchat-reply-bar__name {
    font-size: 12px;
    font-weight: 600;
    color: #4a90d9;
}
.mchat-reply-bar__text {
    font-size: 12px;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mchat-reply-bar__close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mchat-reply-bar__close:hover {
    background: #e0e0e0;
    color: #333;
}

/* ─── Reply Quote in Message ──────────────────────────────────── */
.mchat-msg__reply {
    display: flex;
    flex-direction: column;
    padding: 4px 8px;
    margin-bottom: 4px;
    background: rgba(0,0,0,.05);
    border-left: 2px solid #4a90d9;
    border-radius: 4px;
    cursor: pointer;
    max-width: 100%;
    overflow: hidden;
}
.mchat-msg__reply:hover {
    background: rgba(0,0,0,.08);
}
.mchat-msg__reply-name {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #4a90d9;
    line-height: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mchat-msg__reply-text {
    display: block;
    font-size: 12px;
    color: #555;
    line-height: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Own messages: lighter reply block */
.mchat-msg--own .mchat-msg__reply {
    background: rgba(255,255,255,.15);
    border-left-color: rgba(255,255,255,.6);
}
.mchat-msg--own .mchat-msg__reply-name {
    color: rgba(255,255,255,.9);
}
.mchat-msg--own .mchat-msg__reply-text {
    color: rgba(255,255,255,.7);
}

/* ─── Forwarded Header ────────────────────────────────────────── */
.mchat-msg__fwd {
    font-size: 11px;
    color: #4a90d9;
    font-style: italic;
    margin-bottom: 4px;
}
.mchat-msg--own .mchat-msg__fwd {
    color: rgba(255,255,255,.7);
}

/* ─── Multi-Select Mode ───────────────────────────────────────── */
.mchat-select-mode .mchat-messages {
    user-select: none !important;
}
.mchat-select-mode .mchat-msg {
    cursor: pointer;
    user-select: none;
    transition: background-color .12s;
}
/* Checkbox circle — always at the left edge of chat area */
.mchat-select-mode .mchat-msg::before {
    content: '';
    position: absolute;
    left: -30px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #b0bec5;
    background: #fff;
    box-sizing: border-box;
    transition: all .15s;
    z-index: 2;
    top: 50%;
    transform: translateY(-50%);
}
.mchat-select-mode .mchat-msg--other,
.mchat-select-mode .mchat-msg--own {
    position: relative;
    margin-left: 30px;
}
/* Selected checkbox — filled blue with checkmark */
.mchat-select-mode .mchat-msg--selected::before {
    content: '';
    background: #3a82d0;
    border-color: #3a82d0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: 14px;
    background-position: center;
    background-repeat: no-repeat;
}
/* Selected message highlight — contrast backgrounds */
.mchat-msg--selected.mchat-msg--other {
    background: #d0e3f5 !important;
    box-shadow: 0 1px 3px rgba(58,130,208,.18) !important;
}
.mchat-msg--selected.mchat-msg--own {
    background: #1e2d7a !important;
}
.mchat-msg--selected.mchat-msg--sticker {
    background: rgba(58,130,208,.15) !important;
    box-shadow: none !important;
    border-radius: 14px !important;
}
/* Hide input area in select mode */
.mchat-select-mode .mchat-footer,
.mchat-select-mode .mchat-file-preview,
.mchat-select-mode .mchat-emoji-picker,
.mchat-select-mode .mchat-reply-bar {
    display: none !important;
}

/* ─── Select Action Bar ──────────────────────────────────────── */
.mchat-select-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-top: 1px solid #e5e5e5;
    background: #fff;
    flex-shrink: 0;
}
.mchat-select-bar__cancel {
    border: none;
    background: none;
    cursor: pointer;
    color: #888;
    padding: 4px;
    display: flex;
    align-items: center;
}
.mchat-select-bar__cancel:hover { color: #333; }
.mchat-select-bar__count {
    font-size: 14px;
    font-weight: 600;
    color: #3a82d0;
    min-width: 20px;
    text-align: center;
}
.mchat-select-bar__fwd {
    border: none;
    background: #3a82d0;
    color: #fff;
    padding: 7px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background .15s;
}
.mchat-select-bar__fwd:hover { background: #2d6cb3; }
.mchat-select-bar__fwd:disabled { opacity: .5; cursor: not-allowed; }
.mchat-select-bar__del {
    margin-left: auto;
    border: none;
    background: #e53935;
    color: #fff;
    padding: 7px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background .15s;
}
.mchat-select-bar__del svg { width: 16px; height: 16px; }
.mchat-select-bar__del:hover { background: #c62828; }
.mchat-select-bar__del:disabled { opacity: .5; cursor: not-allowed; }

/* ─── Highlight Animation (scroll-to-reply / pinned) ──────────── */
.mchat-msg--highlight {
    animation: mchat-highlight 2s ease-out;
}
@keyframes mchat-highlight {
    0%   { box-shadow: 0 0 0 3px rgba(74, 144, 217, .7); }
    60%  { box-shadow: 0 0 0 3px rgba(74, 144, 217, .3); }
    100% { box-shadow: none; }
}

/* ─── Forward Dialog ──────────────────────────────────────────── */
.mchat-fwd-dialog {
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}
.mchat-fwd-tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin: 0 -16px;
    padding: 0 16px;
}
.mchat-fwd-tab {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    position: relative;
    transition: color .15s;
}
.mchat-fwd-tab:hover {
    color: #444;
}
.mchat-fwd-tab--active {
    color: #4a90d9;
}
.mchat-fwd-tab--active::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: -2px;
    height: 2px;
    background: #4a90d9;
    border-radius: 2px 2px 0 0;
}
.mchat-fwd-list {
    flex: 1;
    overflow-y: auto;
    max-height: 320px;
    padding: 4px 0;
}
.mchat-fwd-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 16px;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
}
.mchat-fwd-item:hover {
    background: #f0f0f0;
}
.mchat-fwd-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    flex-shrink: 0;
}
.mchat-fwd-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
}

/* ─── Panel Tabs (Диалоги / Каналы) ──────────────────────────── */
.mchat-panel-tabs {
    display: flex;
    border-bottom: 2px solid #e8e8e8;
    padding: 0 12px;
    flex-shrink: 0;
}
.mchat-panel-tab {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    position: relative;
    transition: color .15s;
    text-align: center;
}
.mchat-panel-tab:hover { color: #444; }
.mchat-panel-tab--active { color: #4a90d9; }
.mchat-panel-tab--active::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: -2px;
    height: 2px;
    background: #4a90d9;
    border-radius: 2px 2px 0 0;
}

/* ─── TG Custom Emoji ─────────────────────────────────── */
.mchat-ep-tab-cover {
    width: 20px;
    height: 20px;
    object-fit: contain;
    pointer-events: none;
    border-radius: 3px;
}
.mchat-ep-tab-letter {
    font-size: 10px;
    line-height: 20px;
    color: #aaa;
}
.mchat-tge-items {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-content: flex-start;
}
.mchat-tge-item {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
    transition: background .1s, transform .1s;
    overflow: hidden;
}
.mchat-tge-item:hover {
    background: #f0f2f8;
    transform: scale(1.15);
}
.mchat-tge-thumb {
    width: 30px;
    height: 30px;
    object-fit: contain;
    pointer-events: none;
}
.mchat-tge-lottie {
    width: 30px;
    height: 30px;
    pointer-events: none;
}
.mchat-tge-lottie canvas {
    width: 30px !important;
    height: 30px !important;
}
/* Inline TG emoji in contenteditable and messages */
img.mchat-tgemoji {
    width: 20px;
    height: 20px;
    vertical-align: -4px;
    margin: 0 1px;
    display: inline;
    pointer-events: none;
}
.mchat-input img.mchat-tgemoji {
    pointer-events: auto;
    cursor: default;
}
img.mchat-tgemoji--pending {
    width: 20px;
    height: 20px;
    background: #e0e0e0;
    border-radius: 3px;
}
.mchat-tgemoji-anim {
    width: 20px;
    height: 20px;
    vertical-align: -4px;
    margin: 0 1px;
    display: inline-block;
    overflow: hidden;
    pointer-events: none;
}
video.mchat-tgemoji-anim {
    object-fit: contain;
}
.mchat-contact__preview .mchat-tgemoji-anim {
    width: 1em;
    height: 1em;
    vertical-align: -0.1em;
}

/* ─── Channel Icon ────────────────────────────────────────────── */
.mchat-channel-icon {
    font-size: 18px;
    width: 32px;
    flex-shrink: 0;
    text-align: center;
    line-height: 32px;
}

/* ─── Channel Messages (read-only view) ───────────────────────────── */
.mchat-channel-msg {
    padding: 4px 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    border-bottom: none;
    background: transparent;
}
.mchat-channel-msg__bubble {
    position: relative;
    display: inline-block;
    background: #fff;
    border-radius: 12px;
    padding: 8px 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,.12);
    max-width: 82%;
    word-break: break-word;
}
.mchat-channel-msg__bubble .mchat-reaction-picker {
    left: 0;
}
.mchat-channel-msg__text {
    font-size: 13px;
    color: #333;
    line-height: 1.45;
}
.mchat-channel-msg__time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}

/* ─── Channel Document Card ────────────────────────────────────────── */
.mchat-channel-doc {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-top: 6px;
    background: #f4f6f8;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: background .15s;
    cursor: pointer;
}
.mchat-channel-doc:hover {
    background: #e8ecf0;
    text-decoration: none;
    color: inherit;
}
.mchat-channel-doc__icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #e3e8ed;
    border-radius: 8px;
}
.mchat-channel-doc__icon svg {
    width: 22px;
    height: 22px;
}
.mchat-channel-doc__info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}
.mchat-channel-doc__name {
    font-size: 13px;
    font-weight: 500;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mchat-channel-doc__meta {
    font-size: 11px;
    color: #888;
}
.mchat-channel-doc__dl {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e3e8ed;
    transition: background .15s;
}
.mchat-channel-doc:hover .mchat-channel-doc__dl {
    background: #d0d6dc;
}

/* ─── Channel Footer ───────────────────────────────────────────────── */
.mchat-channel-footer {
    padding: 12px 16px;
    text-align: center;
    border-top: 1px solid #e8e8e8;
    flex-shrink: 0;
}
.mchat-channel-footer__text {
    font-size: 12px;
    color: #999;
    font-style: italic;
}

/* ─── Scroll-to-bottom button ──────────────────────────────────────── */
.mchat-scroll-bottom {
    position: absolute;
    right: 20px;
    bottom: 80px;
    width: 40px;
    height: 40px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    color: #666;
    transition: background .2s;
}
.mchat-scroll-bottom:hover { background: #f0f0f0; }
.mchat-scroll-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #2196F3;
    color: #fff;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
}

/* ─── Message status ticks ─────────────────────────────────────────── */
.mchat-msg__status { display: inline-flex; align-items: center; }
.mchat-msg__status svg { height: 11px; width: auto; display: block; }

/* ─── Telegram Markdown styles ──────────────────────────────────────── */
.mchat-channel-msg__bubble code,
.mchat-msg code {
    font-family: "Courier New", Courier, monospace;
    background: #f0f0f0;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 12px;
    color: #c7254e;
}
.mchat-code-copy {
    cursor: pointer;
    transition: background .15s;
}
.mchat-code-copy:hover {
    background: rgba(0,0,0,.08);
}
.mchat-code-copy--active {
    background: #d7e5f3 !important;
    color: #2b3990 !important;
}

/* Toast notification */
.mchat-toast {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(0,0,0,.75);
    color: #fff;
    font-size: 13px;
    padding: 6px 16px;
    border-radius: 8px;
    z-index: 100;
    opacity: 0;
    transition: opacity .2s, transform .2s;
    pointer-events: none;
    white-space: nowrap;
}
.mchat-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Loading older messages indicator */
.mchat-loading-older {
    text-align: center;
    padding: 8px;
    font-size: 12px;
    color: #999;
}
.mchat-channel-msg__bubble pre,
.mchat-msg pre {
    background: #f6f8fa;
    border-radius: 6px;
    padding: 10px 12px;
    overflow-x: auto;
    margin: 6px 0 2px;
    font-size: 12px;
}
.mchat-channel-msg__bubble pre code,
.mchat-msg pre code {
    background: none;
    padding: 0;
    color: #333;
}
.mchat-spoiler {
    background: #333;
    color: transparent;
    border-radius: 4px;
    padding: 0 2px;
    cursor: pointer;
    transition: color .15s, background .15s;
    user-select: none;
}
.mchat-spoiler--shown {
    background: #e8e8e8;
    color: inherit;
}

/* ─── Избранное (bookmark) ────────────────────────────────────── */
.mchat-contact--self .mchat-contact__bookmark {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5b9bd5;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}
.mchat-contact--self .mchat-contact__bookmark svg {
    width: 18px;
    height: 18px;
}
.mchat-contact--tool .mchat-contact__toolicon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e8f4fd;
    color: #2b6cb0;
    flex-shrink: 0;
}
.mchat-contact--tool .mchat-contact__toolicon svg {
    width: 14px;
    height: 14px;
    margin-right: 0 !important;
}
.mchat-contact--tool .mchat-contact__name {
    color: #1d3e68;
}
.mchat-header__bookmark {
    display: inline-flex;
    align-items: center;
    color: #5b9bd5;
    margin-right: 4px;
}
.mchat-fwd-avatar--self {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5b9bd5;
    background: #e8f0fa;
}
.mchat-fwd-avatar--group {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, #2b3990, #4a90d9);
}

/* ─── Pin banner ──────────────────────────────────────────────── */
.mchat-pin-banner {
    display: flex;
    align-items: center;
    background: #e8f4fd;
    border-bottom: 1px solid #c8dff0;
    padding: 6px 12px;
    gap: 8px;
    min-height: 40px;
    flex-shrink: 0;
}
.mchat-pin-banner__content {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    cursor: pointer;
    color: #2b6cb0;
}
.mchat-pin-banner__content:hover {
    color: #1a4a7a;
}
.mchat-pin-banner__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.mchat-pin-banner__label {
    font-size: 11px;
    font-weight: 600;
    color: #2b6cb0;
    line-height: 1.2;
}
.mchat-pin-banner__preview {
    font-size: 12px;
    color: #4a5568;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.mchat-pin-banner__close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: #718096;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.mchat-pin-banner__close:hover {
    background: rgba(0,0,0,.08);
    color: #c53030;
}
.mchat-pin-banner__counter {
    font-weight: 400;
    color: #718096;
    font-size: 10px;
    margin-left: 4px;
}

/* ─── Voice / Mic Button ───────────────────────────────────────────── */
.mchat-voice-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #718096;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.mchat-voice-btn:hover { color: #2b3990; }
.mchat-voice-btn svg { width: 24px; height: 24px; }

/* ─── Recording Bar (footer overlay) ──────────────────────────────── */
.mchat-footer--recording .mchat-input-wrap,
.mchat-footer--recording .mchat-send,
.mchat-footer--recording .mchat-voice-btn,
.mchat-footer--recording .mchat-attach-btn,
.mchat-footer--recording .mchat-lead-btn,
.mchat-footer--recording .mchat-crm-btn,
.mchat-footer--recording .mchat-emoji-btn {
    display: none !important;
}
.mchat-rec-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 0 4px;
}
.mchat-rec-cancel,
.mchat-rec-send {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}
.mchat-rec-cancel svg { width: 20px; height: 20px; color: #e53e3e; }
.mchat-rec-send svg { width: 24px; height: 24px; color: #2b3990; }
.mchat-rec-cancel:hover svg { color: #c53030; }
.mchat-rec-send:hover svg { color: #1e2a6e; }
.mchat-rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e53e3e;
    animation: mchat-blink 1s infinite;
    flex-shrink: 0;
}
@keyframes mchat-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
.mchat-rec-timer {
    font-size: 14px;
    color: #2d3748;
    font-variant-numeric: tabular-nums;
    min-width: 36px;
    flex: 1;
}

/* ─── Voice Player (in message) ──────────────────────────────────── */
.mchat-voice-player {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 180px;
    max-width: 260px;
    padding: 4px 0;
}
.mchat-voice-player__btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    color: #3182ce;
    flex-shrink: 0;
}
.mchat-voice-player__btn svg { width: 28px; height: 28px; }
.mchat-voice-player__btn:hover { color: #2b6cb0; }
.mchat-voice-player__track {
    flex: 1;
    height: 4px;
    background: rgba(0,0,0,.12);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}
.mchat-voice-player__progress {
    height: 100%;
    background: #3182ce;
    border-radius: 2px;
    width: 0;
    transition: width .1s linear;
}
.mchat-voice-player__dur {
    font-size: 12px;
    color: #718096;
    min-width: 30px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ─── Video Note (кружок) — in message ───────────────────────────── */
.mchat-video-note {
    position: relative;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    background: #000;
}
.mchat-video-note__video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}
.mchat-video-note__play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,.45);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity .2s;
}
.mchat-video-note__play svg { width: 22px; height: 22px; color: #fff; }
.mchat-video-note--playing .mchat-video-note__play { opacity: 0; }
.mchat-video-note--playing:hover .mchat-video-note__play { opacity: 1; }

/* ─── Video Note Recording Overlay ───────────────────────────────── */
.mchat-vidnote-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    gap: 16px;
}
.mchat-vidnote-circle {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid #e53e3e;
    animation: mchat-blink-border 1s infinite;
}
@keyframes mchat-blink-border {
    0%, 100% { border-color: #e53e3e; }
    50% { border-color: transparent; }
}
.mchat-vidnote-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.mchat-vidnote-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}
.mchat-vidnote-cancel,
.mchat-vidnote-send {
    background: rgba(255,255,255,.15);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
}
.mchat-vidnote-cancel:hover,
.mchat-vidnote-send:hover { background: rgba(255,255,255,.25); }
.mchat-vidnote-cancel svg,
.mchat-vidnote-send svg { width: 22px; height: 22px; }
.mchat-vidnote-timer {
    font-size: 18px;
    color: #fff;
    font-variant-numeric: tabular-nums;
    min-width: 44px;
    text-align: center;
}

/* ─── Group Chats ────────────────────────────────────────────────── */

/* Create group button */
.mchat-group-create-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    color: #2b3990;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid #eee;
    transition: background .15s;
}
.mchat-group-create-btn:hover { background: #f0f2f8; }
.mchat-group-create-icon { display: flex; align-items: center; }
.mchat-group-create-icon svg { width: 22px; height: 22px; }

/* Group icon in list */
.mchat-dot--group::before {
    background: #2b3990;
}

/* Group contact item */
.mchat-contact--group { cursor: pointer; }
.mchat-contact--group .mchat-contact__left { display: flex; align-items: center; gap: 10px; }
.mchat-contact--group .mchat-contact__info { min-width: 0; flex: 1; }
.mchat-contact--group .mchat-contact__name { font-weight: 500; }

/* Group icon in header */
.mchat-header__info--group { display: flex; flex-direction: column; gap: 1px; }
.mchat-icon-wrap { display: inline-flex; align-items: center; margin-right: 6px; vertical-align: middle; }
.mchat-icon-wrap svg { width: 18px; height: 18px; }

/* Sender name label in group messages */
.mchat-msg-sender {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 12px 0;
    margin-top: 6px;
    line-height: 1.3;
}

/* Group Modal Overlay */
.mchat-group-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
    animation: mchat-fadeIn .15s;
}
.mchat-group-modal {
    background: #fff;
    border-radius: 14px;
    width: 92%;
    max-width: 340px;
    max-height: 80%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.mchat-group-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #eee;
    font-weight: 600;
    font-size: 15px;
    color: #333;
}
.mchat-group-modal__close {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 0;
    display: flex;
}
.mchat-group-modal__close svg { width: 18px; height: 18px; }
.mchat-group-modal__close:hover { color: #333; }
.mchat-group-modal__body { padding: 12px 16px; overflow-y: auto; flex: 1; }
.mchat-group-modal__name {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    color: #333;
    font-size: 14px;
    outline: none;
    margin-bottom: 10px;
}
.mchat-group-modal__name:focus { border-color: #2b3990; }
.mchat-group-modal__name::placeholder { color: #999; }
.mchat-group-modal__search-wrap { margin-bottom: 10px; }
.mchat-group-modal__search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    color: #333;
    font-size: 13px;
    outline: none;
}
.mchat-group-modal__search:focus { border-color: #2b3990; }
.mchat-group-modal__search::placeholder { color: #999; }
.mchat-group-modal__users {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 240px;
    overflow-y: auto;
}
.mchat-group-modal__user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    transition: background .12s;
}
.mchat-group-modal__user:hover { background: #f0f2f8; }
.mchat-group-modal__user--selected { background: #e8ecf8; color: #333; }
.mchat-group-modal__user input[type=checkbox] {
    width: 16px;
    height: 16px;
    accent-color: #2b3990;
    cursor: pointer;
    flex-shrink: 0;
}
.mchat-group-modal__footer {
    padding: 12px 16px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
}
.mchat-group-modal__submit {
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    background: #2b3990;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, opacity .15s;
}
.mchat-group-modal__submit:hover { background: #1e2a6e; }
.mchat-group-modal__submit:disabled { opacity: .45; cursor: default; }

/* Group Info Panel */
.mchat-group-info-panel {
    position: absolute;
    inset: 0;
    background: #fff;
    z-index: 800;
    overflow-y: auto;
    animation: mchat-slideUp .2s;
}
@keyframes mchat-slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.mchat-group-info {
    padding: 16px;
}
.mchat-group-info__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.mchat-group-info__title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}
.mchat-group-info__close {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 0;
    display: flex;
}
.mchat-group-info__close svg { width: 18px; height: 18px; }
.mchat-group-info__close:hover { color: #333; }
.mchat-group-info__rename {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.mchat-group-info__name-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    color: #333;
    font-size: 14px;
    outline: none;
}
.mchat-group-info__name-input:focus { border-color: #2b3990; }
.mchat-group-info__rename-btn {
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    background: #2b3990;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.mchat-group-info__rename-btn:hover { background: #1e2a6e; }
.mchat-group-info__section {
    font-size: 11px;
    font-weight: 600;
    color: #999;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.mchat-group-info__add-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 8px;
    cursor: pointer;
    color: #2b3990;
    font-size: 14px;
    font-weight: 500;
    transition: background .15s;
}
.mchat-group-info__add-btn:hover { background: #f0f2f8; }
.mchat-group-info__member {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background .12s;
}
.mchat-group-info__member:hover { background: #f5f5f5; }
.mchat-group-info__member-name {
    flex: 1;
    font-size: 14px;
    color: #333;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mchat-group-info__admin {
    font-size: 11px;
    color: #e08e0b;
    background: #fef6e6;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    flex-shrink: 0;
}
.mchat-group-info__kick {
    background: none;
    border: none;
    color: #d32f2f;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}
.mchat-group-info__kick:hover { background: #fdecea; }
.mchat-group-info__leave {
    background: none;
    border: 1px solid #f5c6c6;
    color: #d32f2f;
    cursor: pointer;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    flex-shrink: 0;
}
.mchat-group-info__leave:hover { background: #fdecea; }
.mchat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
    flex-shrink: 0;
}
.mchat-dot--on { background: #22c55e; }

/* Group scrollbars */
.mchat-group-modal__body::-webkit-scrollbar,
.mchat-group-modal__users::-webkit-scrollbar,
.mchat-group-info-panel::-webkit-scrollbar { width: 5px; }
.mchat-group-modal__body::-webkit-scrollbar-track,
.mchat-group-modal__users::-webkit-scrollbar-track,
.mchat-group-info-panel::-webkit-scrollbar-track { background: transparent; }
.mchat-group-modal__body::-webkit-scrollbar-thumb,
.mchat-group-modal__users::-webkit-scrollbar-thumb,
.mchat-group-info-panel::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* ─── 1. Swipe-to-Reply ─────────────────────────────────────────── */
.mchat-msg {
    position: relative;
    will-change: transform;
}
.mchat-msg--swiping {
    transition: none !important;
}
.mchat-swipe-reply-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(43,57,144,.12);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .15s;
    pointer-events: none;
}
.mchat-msg--own .mchat-swipe-reply-icon { right: 100%; margin-right: 6px; }
.mchat-msg--other .mchat-swipe-reply-icon { left: 100%; margin-left: 6px; }
.mchat-swipe-reply-icon--visible { opacity: 1; }
.mchat-swipe-reply-icon svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: #2b3990;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ─── 2. Reactions ───────────────────────────────────────────────── */
.mchat-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
    font-size: 13px;
}
.mchat-reaction {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border-radius: 12px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid #bbb;
    background: #e4e4e4;
    box-shadow: 0 1px 2px rgba(0,0,0,.08);
    transition: background .15s, border-color .15s;
    line-height: 1.3;
}
.mchat-reaction img.emoji {
    width: 16px !important;
    height: 16px !important;
    max-width: 16px !important;
    max-height: 16px !important;
    vertical-align: -2px;
}
.mchat-reaction:hover { background: #d6d6d6; }
.mchat-reaction--own {
    background: rgba(43,57,144,.15);
    border-color: rgba(43,57,144,.35);
}
.mchat-reaction__count {
    font-size: 12px;
    color: #222;
    font-weight: 700;
}

/* Reactions inside own (blue) messages — need white-based contrast */
.mchat-msg--own .mchat-reaction {
    background: rgba(255,255,255,.25);
    border-color: rgba(255,255,255,.35);
}
.mchat-msg--own .mchat-reaction:hover {
    background: rgba(255,255,255,.35);
}
.mchat-msg--own .mchat-reaction--own {
    background: rgba(255,255,255,.35);
    border-color: rgba(255,255,255,.5);
}
.mchat-msg--own .mchat-reaction__count {
    color: #fff;
}
.mchat-reaction-picker {
    position: absolute;
    bottom: 100%;
    display: flex;
    gap: 2px;
    padding: 4px 6px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,.15);
    z-index: 20;
    margin-bottom: 4px;
}
.mchat-reaction-picker--floating {
    position: fixed;
    bottom: auto;
    margin-bottom: 0;
    z-index: 10080;
}
.mchat-msg--own .mchat-reaction-picker { right: 0; }
.mchat-msg--other .mchat-reaction-picker { left: 0; }
.mchat-reaction-picker__item {
    font-size: 22px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 8px;
    transition: background .12s, transform .12s;
    line-height: 1;
}
.mchat-reaction-picker__item img.emoji {
    width: 28px !important;
    height: 28px !important;
    max-width: 28px !important;
    max-height: 28px !important;
}
.mchat-reaction-picker__item:hover {
    background: #f0f0f0;
    transform: scale(1.2);
}

/* ─── 3. Typing Indicator ────────────────────────────────────────── */
.mchat-typing {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 0 14px 6px;
    font-size: 12px;
    color: #888;
    min-height: 22px;
}
.mchat-typing--visible { display: flex; }
.mchat-typing__dots {
    display: flex;
    gap: 3px;
}
.mchat-typing__dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #aaa;
    animation: mchatTypingBounce .6s infinite ease-in-out;
}
.mchat-typing__dot:nth-child(2) { animation-delay: .15s; }
.mchat-typing__dot:nth-child(3) { animation-delay: .3s; }
@keyframes mchatTypingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ─── 4. Edit Message ────────────────────────────────────────────── */
.mchat-edit-bar {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    background: #f0f2f8;
    border-top: 1px solid #dde;
    gap: 8px;
    font-size: 12px;
}
.mchat-edit-bar__icon {
    color: #2b3990;
    flex-shrink: 0;
}
.mchat-edit-bar__icon svg { width: 16px; height: 16px; }
.mchat-edit-bar__content {
    flex: 1;
    min-width: 0;
}
.mchat-edit-bar__label {
    color: #2b3990;
    font-weight: 600;
    font-size: 11px;
}
.mchat-edit-bar__text {
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mchat-edit-bar__close {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    padding: 2px;
    display: flex;
}
.mchat-edit-bar__close:hover { color: #333; }
.mchat-msg--edited .mchat-msg__time::before {
    content: 'ред.';
    font-size: 9px;
    opacity: .6;
    margin-right: 3px;
}

/* ─── 5. Dark Theme ──────────────────────────────────────────────── */
.mchat-panel--dark {
    background: #1a1a2e;
    color: #e0e0e0;
}
.mchat-panel--dark .mchat-header { background: #16213e; }
.mchat-panel--dark .mchat-messages { background: #0f0f23; }
.mchat-panel--dark .mchat-msg--own { background: #1a3a6b; color: #e8e8e8; }
.mchat-panel--dark .mchat-msg--other { background: #2a2a3e; color: #ddd; box-shadow: none; }
.mchat-panel--dark .mchat-footer { background: #1a1a2e; border-color: #333; }
.mchat-panel--dark .mchat-input {
    background: #2a2a3e;
    border-color: #444;
    color: #e0e0e0;
}
.mchat-panel--dark .mchat-input:focus { border-color: #5570bb; }
.mchat-panel--dark .mchat-contact { border-color: #333; }
.mchat-panel--dark .mchat-contact:hover { background: #2a2a3e; border-color: #5570bb; }
.mchat-panel--dark .mchat-contact__name { color: #e0e0e0; }
.mchat-panel--dark .mchat-contact__preview { color: #888; }
.mchat-panel--dark .mchat-search-input {
    background: #2a2a3e;
    border-color: #444;
    color: #e0e0e0;
}
.mchat-panel--dark .mchat-search-input:focus { border-color: #5570bb; }
.mchat-panel--dark .mchat-lead-dialog-search {
    background: #16213e;
    border-color: #333;
}
.mchat-panel--dark .mchat-lead-status-strip {
    background: #16213e;
    border-color: #333;
}
.mchat-panel--dark .mchat-lead-status-chip {
    background: #23253d;
    border-color: #3b4261;
    color: #d7def2;
}
.mchat-panel--dark .mchat-lead-status-chip:hover {
    background: #2c3454;
    border-color: #506192;
    color: #fff;
}
.mchat-panel--dark .mchat-lead-status-chip--active {
    background: #6d84d8;
    border-color: #6d84d8;
    color: #fff;
}
.mchat-panel--dark .mchat-lead-status-chip--special {
    background: rgba(251,191,36,.12);
    border-color: rgba(251,191,36,.28);
    color: #fcd58b;
}
.mchat-panel--dark .mchat-lead-status-chip--special:hover {
    background: rgba(251,191,36,.18);
    border-color: rgba(251,191,36,.38);
    color: #fde68a;
}
.mchat-panel--dark .mchat-lead-status-chip--special.mchat-lead-status-chip--active {
    background: #b45309;
    border-color: #b45309;
    color: #fff;
}
.mchat-panel--dark .mchat-crm-search-input {
    background: #23253d;
    border-color: #3b4261;
    color: #e5e7eb;
}
.mchat-panel--dark .mchat-crm-search-input::placeholder {
    color: #97a0bb;
}
.mchat-panel--dark .mchat-crm-search-input:focus {
    border-color: #6d84d8;
}
.mchat-panel--dark .mchat-ctx-menu { background: #2a2a3e; border-color: #444; }
.mchat-panel--dark .mchat-ctx-item { color: #ddd; }
.mchat-panel--dark .mchat-ctx-item:hover { background: #363650; }
.mchat-panel--dark .mchat-ctx-item--danger { color: #ef5350; }
.mchat-panel--dark .mchat-ctx-item--danger:hover { background: #3d2020; }
.mchat-panel--dark .mchat-reply-bar { background: #2a2a3e; border-color: #444; }
.mchat-panel--dark .mchat-reply-bar__name { color: #8899cc; }
.mchat-panel--dark .mchat-reply-bar__text { color: #aaa; }
.mchat-panel--dark .mchat-edit-bar { background: #2a2a3e; border-color: #444; }
.mchat-panel--dark .mchat-msg__reply { background: rgba(255,255,255,.06); border-color: #5570bb; }
.mchat-panel--dark .mchat-msg__time { color: #888; }
.mchat-panel--dark .mchat-pin-banner { background: #1e1e38; color: #bbb; border-color: #333; }
.mchat-panel--dark .mchat-file-item { border-color: #444; }
.mchat-panel--dark .mchat-file-item:hover { background: #2a2a3e; }
.mchat-panel--dark .mchat-typing { color: #777; }
.mchat-panel--dark .mchat-typing__dot { background: #777; }
.mchat-panel--dark .mchat-reaction { background: #2a2a3e; border-color: #555; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.mchat-panel--dark .mchat-reaction:hover { background: #363650; }
.mchat-panel--dark .mchat-reaction--own { background: rgba(85,112,187,.25); border-color: rgba(85,112,187,.5); }
.mchat-panel--dark .mchat-reaction__count { color: #ddd; }
/* Dark theme: override sticker + own reaction styles */
.mchat-panel--dark .mchat-msg--sticker .mchat-reaction,
.mchat-panel--dark .mchat-msg--sticker.mchat-msg--own .mchat-reaction { background: #2a2a3e; border-color: #555; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.mchat-panel--dark .mchat-msg--sticker .mchat-reaction:hover,
.mchat-panel--dark .mchat-msg--sticker.mchat-msg--own .mchat-reaction:hover { background: #363650; }
.mchat-panel--dark .mchat-msg--sticker .mchat-reaction--own,
.mchat-panel--dark .mchat-msg--sticker.mchat-msg--own .mchat-reaction--own { background: rgba(85,112,187,.25); border-color: rgba(85,112,187,.5); }
.mchat-panel--dark .mchat-msg--sticker .mchat-reaction__count,
.mchat-panel--dark .mchat-msg--sticker.mchat-msg--own .mchat-reaction__count { color: #ddd; }
.mchat-panel--dark .mchat-msg--deleted .mchat-msg__deleted { color: #777; }
.mchat-panel--dark .mchat-unread-divider span { background: #1a1a2e; color: #777; }
.mchat-panel--dark .mchat-unread-divider { border-color: #444; }
.mchat-panel--dark .mchat-voice-player__btn { color: #5570bb; }
.mchat-panel--dark .mchat-voice-player__track { background: rgba(255,255,255,.1); }
.mchat-panel--dark .mchat-voice-player__progress { background: #5570bb; }
.mchat-panel--dark .mchat-voice-player__dur { color: #888; }
.mchat-panel--dark .mchat-dm-dialog { background: #2a2a3e; color: #ddd; }
.mchat-panel--dark .mchat-dm-overlay { background: rgba(0,0,0,.5); }
.mchat-panel--dark .mchat-select-bar { background: #16213e; }
.mchat-panel--dark .mchat-msg--selected { background: rgba(85,112,187,.15) !important; }
.mchat-panel--dark .mchat-search-msg-bar { background: #16213e; border-color: #333; }
.mchat-panel--dark .mchat-search-msg-input {
    background: #2a2a3e;
    border-color: #444;
    color: #e0e0e0;
}
.mchat-panel--dark .mchat-search-msg-result { border-color: #333; }
.mchat-panel--dark .mchat-search-msg-result:hover { background: #2a2a3e; }
.mchat-panel--dark .mchat-link-preview { background: #2a2a3e; border-color: #444; }
.mchat-panel--dark .mchat-link-preview__title { color: #ddd; }
.mchat-panel--dark .mchat-link-preview__desc { color: #999; }
.mchat-panel--dark .mchat-link-preview__domain { color: #777; }
.mchat-panel--dark .mchat-msg--lead.mchat-msg--other {
    background: #25273c;
    border: 1px solid rgba(142, 162, 255, .08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
}
.mchat-panel--dark .mchat-msg-lead__icon {
    color: #90a7ff;
}
.mchat-panel--dark .mchat-msg-lead__title {
    color: #eef2ff;
}
.mchat-panel--dark .mchat-msg-lead__status {
    background: rgba(123, 144, 255, .16);
    color: #c9d4ff;
}
.mchat-panel--dark .mchat-msg-lead__client {
    color: #f3f4f6;
}
.mchat-panel--dark .mchat-msg-lead__phone,
.mchat-panel--dark .mchat-msg-lead__meta {
    color: #a8b3c8;
}
.mchat-panel--dark .mchat-msg-lead__summary {
    color: #c3cada;
}
.mchat-panel--dark .mchat-msg-lead__summary-label {
    color: #eef2ff;
}
.mchat-panel--dark .mchat-msg-lead__track {
    border-color: rgba(148,163,184,.24);
    background: rgba(148,163,184,.1);
    color: #cbd5e1;
}
.mchat-panel--dark .mchat-msg-lead__track:hover {
    background: rgba(148,163,184,.16);
    border-color: rgba(203,213,225,.32);
}
.mchat-panel--dark .mchat-msg-lead__track .mchat-track-number {
    color: #dbe3ef;
}
.mchat-panel--dark .mchat-msg-lead__envelope {
    background: rgba(251,191,36,.12);
    border-color: rgba(251,191,36,.28);
    color: #fde68a;
}
.mchat-panel--dark .mchat-msg-lead__badge-divider {
    background: rgba(148,163,184,.28);
}
.mchat-panel--dark .mchat-msg-lead__debt--ok {
    background: rgba(34,197,94,.12);
    border-color: rgba(134,239,172,.28);
    color: #bbf7d0;
}
.mchat-panel--dark .mchat-msg-lead__debt--bad {
    background: rgba(239,68,68,.13);
    border-color: rgba(252,165,165,.3);
    color: #fecaca;
}
.mchat-panel--dark .mchat-msg-lead__repeat {
    color: #f6c86e;
}
.mchat-panel--dark .mchat-msg-lead__action {
    background: #1b2340;
    color: #aebfff;
}
.mchat-panel--dark .mchat-msg-lead__action:hover {
    background: #25305a;
}
.mchat-panel--dark .mchat-msg-lead__action--relations {
    color: #7ce3d8;
    background: rgba(22, 163, 148, .16);
}
.mchat-panel--dark .mchat-msg-lead__action--wa {
    color: #69db93;
    background: rgba(34, 197, 94, .16);
}
.mchat-panel--dark .mchat-msg-lead__action--tg {
    color: #76c9ff;
    background: rgba(56, 189, 248, .16);
}
.mchat-panel--dark .mchat-tabs-header button { color: #888; border-color: transparent; }
.mchat-panel--dark .mchat-tabs-header button.active { color: #8899cc; border-color: #5570bb; }
.mchat-panel--dark .mchat-dark-toggle svg { fill: #ccc; }
.mchat-panel--dark .mchat-emoji-picker { background: #2a2a3e; border-color: #444; }
.mchat-panel--dark .mchat-emoji-tab { background: #1a1a2e; }
.mchat-panel--dark .mchat-emoji-tab:hover { background: #363650; }

/* Dark mode button in header */
.mchat-dark-toggle {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 4px;
    color: #fff;
    opacity: .7;
    transition: opacity .15s;
}
.mchat-dark-toggle:hover { opacity: 1; }
.mchat-dark-toggle svg { width: 16px; height: 16px; fill: currentColor; }

/* ─── 6. Message Search ──────────────────────────────────────────── */
.mchat-search-msg-bar {
    display: none;
    padding: 6px 10px;
    background: #f8f8f8;
    border-bottom: 1px solid #e5e5e5;
    gap: 6px;
    align-items: center;
}
.mchat-search-msg-bar--open { display: flex; }
.mchat-search-msg-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 16px;
    padding: 5px 12px;
    font-size: 12px;
    outline: none;
    background: #fff;
}
.mchat-search-msg-input:focus { border-color: #2b3990; }
.mchat-search-msg-nav {
    display: flex;
    gap: 2px;
}
.mchat-search-msg-nav button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px;
    color: #666;
    display: flex;
}
.mchat-search-msg-nav button:hover { color: #2b3990; }
.mchat-search-msg-count {
    font-size: 11px;
    color: #888;
    white-space: nowrap;
}
.mchat-search-msg-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px;
    color: #888;
    display: flex;
}
.mchat-search-msg-close:hover { color: #333; }
.mchat-msg--search-highlight {
    background: rgba(255,235,59,.35) !important;
    transition: background .3s;
}
.mchat-channel-msg--search-highlight .mchat-channel-msg__bubble {
    background: rgba(255,235,59,.35) !important;
    transition: background .3s;
}

/* ─── 7. Unread Divider ──────────────────────────────────────────── */
.mchat-unread-divider {
    display: flex;
    align-items: center;
    margin: 8px 0;
    border-top: 1px solid #3182ce;
    position: relative;
}
.mchat-unread-divider span {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background: #f0f1f5;
    color: #3182ce;
    font-size: 11px;
    font-weight: 600;
    padding: 0 10px;
    white-space: nowrap;
}

/* ─── 8. Waveform ────────────────────────────────────────────────── */
.mchat-voice-player__waveform {
    flex: 1;
    height: 28px;
    display: flex;
    align-items: center;
    gap: 1px;
    cursor: pointer;
    position: relative;
}
.mchat-voice-player__waveform canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ─── 10. Link Preview ───────────────────────────────────────────── */
.mchat-link-preview {
    display: block;
    margin-top: 6px;
    padding: 8px 10px;
    border-left: 3px solid #2b3990;
    border-radius: 0 8px 8px 0;
    background: #f5f6fa;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    transition: background .15s;
}
.mchat-link-preview:hover { background: #ecedf5; }
.mchat-link-preview__img {
    width: 100%;
    max-height: 140px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 6px;
}
.mchat-link-preview__title {
    font-size: 13px;
    font-weight: 600;
    color: #222;
    line-height: 1.3;
    margin-bottom: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.mchat-link-preview__desc {
    font-size: 12px;
    color: #666;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 2px;
}
.mchat-link-preview__domain {
    font-size: 11px;
    color: #999;
}

/* ─── Date Separators ────────────────────────────────────────────── */
.mchat-date-sep {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px 0 4px;
    font-size: 11px;
    color: #888;
    letter-spacing: .3px;
}
.mchat-date-sep__label {
    background: #eef0f4;
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: 500;
}
.mchat-panel--dark .mchat-date-sep__label {
    background: #2a2a3e;
    color: #888;
}

/* ─── Big Emoji ──────────────────────────────────────────────────── */
.mchat-msg--emoji-only {
    background: transparent !important;
    box-shadow: none !important;
    padding: 2px 4px !important;
}
.mchat-msg--emoji-only .mchat-msg__text {
    font-size: 42px;
    line-height: 1.15;
}
.mchat-msg--emoji-2 .mchat-msg__text { font-size: 36px; }
.mchat-msg--emoji-3 .mchat-msg__text { font-size: 30px; }
.mchat-msg--emoji-only .mchat-msg__text img.twemoji {
    width: 42px !important;
    height: 42px !important;
}
.mchat-msg--emoji-2 .mchat-msg__text img.twemoji {
    width: 36px !important;
    height: 36px !important;
}
.mchat-msg--emoji-3 .mchat-msg__text img.twemoji {
    width: 30px !important;
    height: 30px !important;
}

/* ─── Message Appear Animation ───────────────────────────────────── */
.mchat-msg--appear {
    animation: mchatMsgAppear .25s ease-out both;
}
@keyframes mchatMsgAppear {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ─── Scroll-to-bottom badge ─────────────────────────────────────── */
.mchat-scroll-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #e74c3c;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

/* ─── @Mention Autocomplete ────────────────────────────────────── */
.mchat-mention-popup {
    position: absolute;
    bottom: 100%;
    left: 8px;
    right: 8px;
    max-height: 180px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 -4px 16px rgba(0,0,0,.12);
    z-index: 22;
    display: none;
}
.mchat-mention-popup.open { display: block; }
.mchat-mention-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background .15s;
    font-size: 13px;
}
.mchat-mention-item:first-child { border-radius: 10px 10px 0 0; }
.mchat-mention-item:last-child { border-radius: 0 0 10px 10px; }
.mchat-mention-item:hover,
.mchat-mention-item.active {
    background: #e8f0fe;
}
.mchat-mention-item__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: #e0e0e0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}
.mchat-mention-item__name { font-weight: 500; }
.mchat-mention-tag {
    color: #3b82f6;
    font-weight: 500;
    cursor: pointer;
}
.mchat-mention-tag:hover { text-decoration: underline; }

/* ─── Emoji Autocomplete ──────────────────────────────────────── */
.mchat-emoji-ac {
    position: absolute;
    bottom: 100%;
    left: 8px;
    right: 8px;
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 -4px 16px rgba(0,0,0,.12);
    z-index: 22;
    display: none;
}
.mchat-emoji-ac.open { display: block; }
.mchat-emoji-ac-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    cursor: pointer;
    transition: background .15s;
    font-size: 13px;
}
.mchat-emoji-ac-item:first-child { border-radius: 10px 10px 0 0; }
.mchat-emoji-ac-item:last-child { border-radius: 0 0 10px 10px; }
.mchat-emoji-ac-item:hover,
.mchat-emoji-ac-item.active {
    background: #e8f0fe;
}
.mchat-emoji-ac-item__char { font-size: 22px; line-height: 1; }
.mchat-emoji-ac-item__name { color: #666; }

/* ─── Drag & Drop overlay ─────────────────────────────────────── */
.mchat-dnd-overlay {
    position: absolute;
    inset: 0;
    background: rgba(59,130,246,.12);
    border: 3px dashed #3b82f6;
    border-radius: 12px;
    z-index: 40;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.mchat-dnd-overlay.active { display: flex; }
.mchat-dnd-overlay__label {
    background: #3b82f6;
    color: #fff;
    padding: 12px 28px;
    border-radius: 20px;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(59,130,246,.3);
}

/* ─── Chat Wallpaper ──────────────────────────────────────────── */
.mchat-messages[data-wallpaper] {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.mchat-wallpaper-picker {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
    z-index: 60;
    padding: 16px;
    width: 280px;
    display: none;
}
.mchat-wallpaper-picker.open { display: block; }
.mchat-wallpaper-picker__title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
}
.mchat-wallpaper-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}
.mchat-wallpaper-opt {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    background-size: cover;
    background-position: center;
    transition: border-color .2s, transform .15s;
}
.mchat-wallpaper-opt:hover { transform: scale(1.05); }
.mchat-wallpaper-opt.active { border-color: #3b82f6; }
.mchat-wallpaper-opt--none {
    background: #f4f5f7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #999;
}
.mchat-wallpaper-close {
    display: block;
    width: 100%;
    padding: 8px;
    border: none;
    background: #f0f0f0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background .15s;
}
.mchat-wallpaper-close:hover { background: #e0e0e0; }

/* ─── Delete Animation ────────────────────────────────────────── */
@keyframes mchatMsgDeleteFade {
    0%   { opacity: 1; max-height: 200px; transform: scale(1); }
    60%  { opacity: 0; max-height: 200px; transform: scale(0.95); }
    100% { opacity: 0; max-height: 0; padding: 0; margin: 0; overflow: hidden; }
}
.mchat-msg--deleting {
    animation: mchatMsgDeleteFade .4s ease-out forwards;
    pointer-events: none;
}

/* ─── Dark mode additions ─────────────────────────────────────── */
.mchat-panel--dark .mchat-mention-popup { background: #2a2a3e; border-color: #444; }
.mchat-panel--dark .mchat-mention-item:hover,
.mchat-panel--dark .mchat-mention-item.active { background: #363650; }
.mchat-panel--dark .mchat-mention-item__name { color: #ddd; }
.mchat-panel--dark .mchat-mention-tag { color: #8899cc; }
.mchat-panel--dark .mchat-emoji-ac { background: #2a2a3e; border-color: #444; }
.mchat-panel--dark .mchat-emoji-ac-item:hover,
.mchat-panel--dark .mchat-emoji-ac-item.active { background: #363650; }
.mchat-panel--dark .mchat-emoji-ac-item__name { color: #888; }
.mchat-panel--dark .mchat-dnd-overlay { background: rgba(85,112,187,.15); border-color: #5570bb; }
.mchat-panel--dark .mchat-dnd-overlay__label { background: #5570bb; }
.mchat-panel--dark .mchat-wallpaper-picker { background: #2a2a3e; color: #ddd; }
.mchat-panel--dark .mchat-wallpaper-opt--none { background: #0f0f23; color: #777; }
.mchat-panel--dark .mchat-wallpaper-close { background: #363650; color: #ddd; }
.mchat-panel--dark .mchat-wallpaper-close:hover { background: #444; }

/* ─── Mute Icon ───────────────────────────────────────────────── */
.mchat-contact__mute {
    color: #999;
    font-size: 14px;
    margin-right: 4px;
    flex-shrink: 0;
}

/* ─── Archive Tab ─────────────────────────────────────────────── */
.mchat-archive-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 13px;
    font-weight: 500;
    color: #3b82f6;
    transition: background .15s;
}
.mchat-archive-header:hover { background: #f0f4ff; }
.mchat-archive-header__count {
    background: #e0e0e0;
    color: #666;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
}

/* ─── Media Gallery ───────────────────────────────────────────── */
.mchat-media-panel {
    position: absolute;
    inset: 0;
    background: #fff;
    z-index: 30;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.mchat-media-panel__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
}
.mchat-media-panel__close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
}
.mchat-media-panel__close:hover { background: #f0f0f0; }
.mchat-media-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.mchat-media-tab {
    flex: 1;
    padding: 8px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: none;
    color: #666;
    border-bottom: 2px solid transparent;
    transition: color .2s, border-color .2s;
}
.mchat-media-tab.active { color: #3b82f6; border-bottom-color: #3b82f6; }
.mchat-media-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.mchat-media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}
.mchat-media-grid__item {
    aspect-ratio: 1 / 1;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}
.mchat-media-grid__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.mchat-media-grid__item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.mchat-media-grid__item--video::after {
    content: '▶';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,.5);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}
.mchat-media-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background .15s;
}
.mchat-media-file:hover { background: #f5f5f5; }
.mchat-media-file__icon { font-size: 22px; flex-shrink: 0; }
.mchat-media-file__info { flex: 1; min-width: 0; }
.mchat-media-file__name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mchat-media-file__meta { font-size: 11px; color: #999; }
.mchat-media-link {
    display: block;
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    color: #3b82f6;
    font-size: 13px;
    word-break: break-all;
    transition: background .15s;
    text-decoration: none;
}
.mchat-media-link:hover { background: #f0f4ff; }
.mchat-media-link__date { font-size: 11px; color: #999; display: block; margin-top: 2px; }

/* ─── Poll ────────────────────────────────────────────────────── */
.mchat-poll {
    padding: 4px 0;
    min-width: 220px;
    max-width: 280px;
}
.mchat-poll__icon { font-size: 14px; margin-right: 4px; }
.mchat-poll__question {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    line-height: 1.3;
}
.mchat-poll__option {
    position: relative;
    padding: 6px 10px;
    margin-bottom: 4px;
    border-radius: 8px;
    border: 1px solid #ddd;
    cursor: pointer;
    font-size: 13px;
    transition: background .15s, border-color .15s;
    overflow: hidden;
}
.mchat-poll__option:hover { border-color: #3b82f6; }
.mchat-poll__option--voted {
    border-color: #3b82f6;
    background: rgba(59,130,246,.08);
}
.mchat-poll__option-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: rgba(59,130,246,.12);
    border-radius: 8px;
    transition: width .4s ease;
}
.mchat-poll__option-text {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mchat-poll__option-pct {
    font-weight: 600;
    font-size: 12px;
    color: #3b82f6;
    min-width: 32px;
    text-align: right;
}
.mchat-poll__total {
    font-size: 11px;
    color: #999;
    margin-top: 6px;
}
.mchat-poll__close-btn {
    font-size: 11px;
    color: #e74c3c;
    cursor: pointer;
    background: none;
    border: none;
    padding: 2px 0;
    margin-top: 4px;
}
.mchat-poll__close-btn:hover { text-decoration: underline; }
.mchat-poll__badge { font-size: 11px; color: #999; font-style: italic; }

/* ─── Poll Creation Modal ─────────────────────────────────────── */
.mchat-poll-modal {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mchat-poll-modal__dialog {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    width: 300px;
    max-height: 80%;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.mchat-poll-modal__title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 14px;
    text-align: center;
}
.mchat-poll-modal input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 8px;
    box-sizing: border-box;
}
.mchat-poll-modal input[type="text"]:focus { border-color: #3b82f6; outline: none; }
.mchat-poll-modal__add-option {
    font-size: 12px;
    color: #3b82f6;
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px 0;
    margin-bottom: 10px;
}
.mchat-poll-modal__add-option:hover { text-decoration: underline; }
.mchat-poll-modal__checks {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
    font-size: 13px;
}
.mchat-poll-modal__checks label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.mchat-poll-modal__actions {
    display: flex;
    gap: 8px;
}
.mchat-poll-modal__actions button {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s;
}
.mchat-poll-modal__cancel { background: #f0f0f0; }
.mchat-poll-modal__cancel:hover { background: #e0e0e0; }
.mchat-poll-modal__submit { background: #3b82f6; color: #fff; }
.mchat-poll-modal__submit:hover { background: #2563eb; }

/* ─── Send Context Menu (RMB / long-press) ────────────────────── */
.mchat-send-ctx {
    position: absolute;
    bottom: 56px;
    right: 10px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,.15);
    z-index: 30;
    overflow: hidden;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .15s, transform .15s;
}
.mchat-send-ctx--visible { opacity: 1; transform: translateY(0); }
.mchat-send-ctx__item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    text-align: left;
}
.mchat-send-ctx__item:hover { background: #f0f4ff; }
.mchat-send-ctx__item + .mchat-send-ctx__item { border-top: 1px solid #eee; }

/* ─── Scheduled Messages ──────────────────────────────────────── */
.mchat-schedule-modal {
    position: absolute;
    bottom: 60px;
    right: 12px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,.15);
    padding: 14px;
    z-index: 25;
    width: 240px;
}
.mchat-schedule-modal__title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
}
.mchat-schedule-modal input[type="datetime-local"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 10px;
    box-sizing: border-box;
}
.mchat-schedule-modal__actions {
    display: flex;
    gap: 8px;
}
.mchat-schedule-modal__actions button {
    flex: 1;
    padding: 7px;
    border-radius: 8px;
    border: none;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}
.mchat-schedule-modal__cancel { background: #f0f0f0; }
.mchat-schedule-modal__send { background: #3b82f6; color: #fff; }
.mchat-schedule-modal__send:hover { background: #2563eb; }
.mchat-scheduled-badge {
    font-size: 10px;
    color: #999;
    display: flex;
    align-items: center;
    gap: 3px;
}
.mchat-scheduled-list { max-height: 260px; overflow-y: auto; }
.mchat-scheduled-item {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}
.mchat-scheduled-item__text {
    font-size: 13px;
    margin-bottom: 4px;
    word-break: break-word;
}
.mchat-scheduled-item__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #888;
}
.mchat-scheduled-item__del {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: #e74c3c;
    font-size: 14px;
    padding: 2px 4px;
}
.mchat-scheduled-item__del:hover { color: #c0392b; }

/* ─── Dark mode: new features ─────────────────────────────────── */
.mchat-panel--dark .mchat-archive-header { color: #8899cc; border-color: #333; }
.mchat-panel--dark .mchat-archive-header:hover { background: #2a2a3e; }
.mchat-panel--dark .mchat-archive-header__count { background: #363650; color: #aaa; }
.mchat-panel--dark .mchat-media-panel { background: #1a1a2e; }
.mchat-panel--dark .mchat-media-panel__header { border-color: #333; color: #ddd; }
.mchat-panel--dark .mchat-media-panel__close:hover { background: #363650; }
.mchat-panel--dark .mchat-media-tabs { border-color: #333; }
.mchat-panel--dark .mchat-media-tab { color: #888; }
.mchat-panel--dark .mchat-media-tab.active { color: #8899cc; border-color: #5570bb; }
.mchat-panel--dark .mchat-media-file { border-color: #333; }
.mchat-panel--dark .mchat-media-file:hover { background: #2a2a3e; }
.mchat-panel--dark .mchat-media-file__name { color: #ddd; }
.mchat-panel--dark .mchat-media-link { color: #8899cc; border-color: #333; }
.mchat-panel--dark .mchat-media-link:hover { background: #2a2a3e; }
.mchat-panel--dark .mchat-poll__option { border-color: #444; color: #ddd; }
.mchat-panel--dark .mchat-poll__option:hover { border-color: #5570bb; }
.mchat-panel--dark .mchat-poll__option--voted { border-color: #5570bb; background: rgba(85,112,187,.1); }
.mchat-panel--dark .mchat-poll__option-bar { background: rgba(85,112,187,.15); }
.mchat-panel--dark .mchat-poll__option-pct { color: #8899cc; }
.mchat-panel--dark .mchat-poll-modal__dialog { background: #2a2a3e; color: #ddd; }
.mchat-panel--dark .mchat-poll-modal input[type="text"] { background: #1a1a2e; border-color: #444; color: #ddd; }
.mchat-panel--dark .mchat-poll-modal__cancel { background: #363650; color: #ddd; }
.mchat-panel--dark .mchat-poll-modal__submit { background: #5570bb; }
.mchat-panel--dark .mchat-schedule-modal { background: #2a2a3e; color: #ddd; }
.mchat-panel--dark .mchat-schedule-modal input { background: #1a1a2e; border-color: #444; color: #ddd; }
.mchat-panel--dark .mchat-schedule-modal__cancel { background: #363650; color: #ddd; }
.mchat-panel--dark .mchat-send-ctx { background: #2a2a3e; box-shadow: 0 4px 20px rgba(0,0,0,.4); }
.mchat-panel--dark .mchat-send-ctx__item { color: #ddd; }
.mchat-panel--dark .mchat-send-ctx__item:hover { background: #363650; }
.mchat-panel--dark .mchat-send-ctx__item + .mchat-send-ctx__item { border-color: #444; }
.mchat-panel--dark .mchat-scheduled-item { border-color: #444; }
.mchat-panel--dark .mchat-scheduled-item__text { color: #ddd; }

/* ─── Mobile: fullscreen panel + app-like UX ───────────────────── */
@media (max-width: 600px) and (pointer: coarse) {
    .mchat-panel {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0;
        padding-top: env(safe-area-inset-top, 0);
    }
    .mchat-fab {
        bottom: 16px;
        right: 16px;
    }
    .mchat-header {
        padding-top: max(12px, env(safe-area-inset-top, 12px));
    }
    .mchat-messages {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
    .mchat-msg {
        max-width: 85%;
    }
    .mchat-footer {
        padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
    }
    /* Contacts list: larger touch targets */
    .mchat-contact {
        min-height: 52px;
    }
}
/* Touch devices: suppress tap highlight + text selection everywhere in panel */
@media (pointer: coarse) {
    .mchat-panel,
    .mchat-panel * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        user-select: none !important;
    }
    /* Re-enable selection for inputs/textareas */
    .mchat-panel input,
    .mchat-panel textarea,
    .mchat-panel [contenteditable="true"] {
        -webkit-user-select: text !important;
        user-select: text !important;
        -webkit-touch-callout: default !important;
    }
    .mchat-contact {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
    /* Kill hover states on touch — only show :active */
    .mchat-ctx-item:hover {
        background: none;
    }
    .mchat-ctx-item--danger:hover {
        background: none;
    }
    .mchat-ctx-item:active {
        background: #f0f0f0;
    }
    .mchat-ctx-item--danger:active {
        background: #fce4ec;
    }
}

/* ─── TG Notification Toast (global, above FAB) ───────────────────── */
.mchat-tg-toast {
    position: fixed;
    bottom: 90px;
    right: 24px;
    z-index: 10002;
    background: rgba(26, 28, 40, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 14px 16px;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
    font-size: 13px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.18);
    max-width: 340px;
    min-width: 260px;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}
.mchat-tg-toast--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.mchat-tg-toast__header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.mchat-tg-toast__icon {
    flex-shrink: 0;
    color: #4caf50;
    margin-top: 1px;
}
.mchat-tg-toast__icon svg {
    width: 18px;
    height: 18px;
}
.mchat-tg-toast__body {
    flex: 1;
    min-width: 0;
}
.mchat-tg-toast__title {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.3;
    margin-bottom: 2px;
}
.mchat-tg-toast__channel {
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mchat-tg-toast__close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.4);
    cursor: pointer;
    padding: 2px;
    flex-shrink: 0;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
}
.mchat-tg-toast__close:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}
.mchat-tg-toast__close svg {
    width: 14px;
    height: 14px;
}
.mchat-tg-toast__actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.mchat-tg-toast__btn {
    flex: 1;
    padding: 5px 14px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    text-align: center;
}
.mchat-tg-toast__btn:active {
    transform: scale(0.97);
}
.mchat-tg-toast__btn--primary {
    background: rgba(66, 133, 244, 0.9);
    color: #fff;
}
.mchat-tg-toast__btn--primary:hover {
    background: rgba(66, 133, 244, 1);
}
.mchat-tg-toast__btn--secondary {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.7);
}
.mchat-tg-toast__btn--secondary:hover {
    background: rgba(255,255,255,0.14);
    color: #fff;
}

/* ─── Channel Message Highlight (scroll-to / toast navigation) ──── */
.mchat-channel-msg--highlight .mchat-channel-msg__bubble {
    animation: mchat-ch-highlight 2.5s ease-out;
}
@keyframes mchat-ch-highlight {
    0%   { box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.6); background-color: rgba(66, 133, 244, 0.12); }
    40%  { box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.3); background-color: rgba(66, 133, 244, 0.08); }
    100% { box-shadow: 0 0 0 0 transparent;                background-color: transparent; }
}
