/* MAX, Telegram и чат сайта в одном плавающем блоке. */
.contact-group__panel {
    position: fixed;
    right: max(24px, env(safe-area-inset-right, 0px));
    bottom: calc(var(--contact-group-bottom, 24px) + env(safe-area-inset-bottom, 0px));
    z-index: 900;
    width: 224px;
    max-width: calc(100vw - 32px);
    box-sizing: border-box;
    overflow: hidden;
    border: 1px solid #d6d4cc;
    border-radius: 16px;
    background: #fffefb;
    box-shadow: 0 4px 20px #24241f18;
}

.contact-group__panel[hidden] {
    display: none;
}

.contact-group__launcher {
    display: none;
}

.contact-group__launcher[hidden] {
    display: none !important;
}

.contact-group__action {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 0;
    background: transparent;
    color: #24241f;
    font: 500 12px/1.4 "IBM Plex Mono", monospace;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 160ms ease;
}

.contact-group__messengers {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.contact-group__messenger {
    justify-content: center;
    gap: 7px;
    min-height: 46px;
    padding: 10px 8px;
}

.contact-group__messenger + .contact-group__messenger {
    border-left: 1px solid #e5e3dc;
}

.contact-group__chat-action {
    justify-content: center;
    border-top: 1px solid #e5e3dc;
}

.contact-group__action:not([disabled]):hover {
    background: #f2f1eb;
}

.contact-group__action[disabled] {
    cursor: default;
}

.contact-group__action:focus-visible {
    outline: 2px solid #5149d8;
    outline-offset: -4px;
    border-radius: 12px;
}

.contact-group__icon {
    display: block;
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
}

.contact-group__chat-icon {
    color: #5b5c54;
}

/* Внешний чат показывается только раскрытым; свёрнутую панель заменяет общая кнопка. */
html[data-contact-group-ready] iframe[src^="https://webchat.dialog.online/"] {
    visibility: hidden !important;
    pointer-events: none !important;
}

html[data-contact-chat-open] iframe[src^="https://webchat.dialog.online/"] {
    visibility: visible !important;
    pointer-events: auto !important;
}

html[data-contact-chat-open] .contact-group__panel {
    visibility: hidden;
}

.contact-group__close {
    position: fixed;
    z-index: 1101;
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid #d6d4cc;
    border-radius: 50%;
    background: #fffefb;
    color: #24241f;
    font: 24px/1 Arial, sans-serif;
    cursor: pointer;
}

html[data-contact-chat-open] .contact-group__close {
    display: flex;
}

.contact-group__close:focus-visible {
    outline: 2px solid #5149d8;
    outline-offset: 2px;
}

.contact-group__notice {
    width: min(360px, calc(100vw - 32px));
    box-sizing: border-box;
    padding: 24px;
    border: 1px solid #d6d4cc;
    border-radius: 16px;
    background: #fffefb;
    color: #24241f;
    font: 14px/1.6 "IBM Plex Mono", monospace;
}

.contact-group__notice::backdrop {
    background: #24241f50;
}

.contact-group__notice p {
    margin: 0 0 16px;
}

.contact-group__notice button {
    min-height: 44px;
    padding: 8px 18px;
    border: 1px solid #d6d4cc;
    border-radius: 999px;
    background: #f2f1eb;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

@media (max-width: 600px) {
    .contact-group__panel {
        right: max(16px, env(safe-area-inset-right, 0px));
        bottom: calc(var(--contact-group-bottom, 16px) + env(safe-area-inset-bottom, 0px));
        width: 208px;
        border-radius: 14px;
    }

    .contact-group__action {
        min-height: 44px;
        gap: 7px;
        padding: 9px 8px;
        font-size: 12px;
    }

    .contact-group__messenger {
        font-size: 11px;
    }

    .contact-group__icon {
        flex-basis: 20px;
        width: 20px;
        height: 20px;
    }

    /* Компактный вариант включается только после готовности нового поведения. */
    html[data-contact-collapsible] .contact-group__panel {
        width: 132px;
        height: 44px;
        overflow: visible;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    html[data-contact-collapsible] .contact-group__options {
        position: absolute;
        right: 0;
        bottom: calc(100% + 10px);
        display: none;
        width: 188px;
        max-height: calc(100dvh - 76px);
        padding: 4px;
        box-sizing: border-box;
        overflow-x: hidden;
        overflow-y: auto;
        border: 1px solid #d6d4cc;
        border-radius: 16px;
        background: #fffefb;
        box-shadow: 0 8px 24px #24241f20;
    }

    html[data-contact-collapsible] .contact-group__panel[data-contact-menu-open] .contact-group__options {
        display: block;
    }

    html[data-contact-collapsible] .contact-group__messengers {
        display: contents;
    }

    html[data-contact-collapsible] .contact-group__options .contact-group__action {
        justify-content: flex-start;
        gap: 8px;
        min-height: 44px;
        padding: 10px 12px;
        border-radius: 11px;
        font-size: 12px;
    }

    html[data-contact-collapsible] .contact-group__messenger + .contact-group__messenger {
        border-top: 1px solid #efeee9;
        border-left: 0;
    }

    html[data-contact-collapsible] .contact-group__chat-action {
        border-top-color: #efeee9;
    }

    html[data-contact-collapsible] .contact-group__options .contact-group__icon {
        width: 22px;
        height: 22px;
        flex-basis: 22px;
    }

    html[data-contact-collapsible] .contact-group__launcher {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 132px;
        height: 44px;
        box-sizing: border-box;
        padding: 0 10px;
        border: 1px solid #d6d4cc;
        border-radius: 999px;
        background: #fffefb;
        color: #24241f;
        box-shadow: 0 4px 18px #24241f18;
        font: 500 12px/1.4 "IBM Plex Mono", monospace;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    html[data-contact-collapsible] .contact-group__launcher:hover {
        background: #f2f1eb;
    }

    html[data-contact-collapsible] .contact-group__launcher:focus-visible {
        outline: 2px solid #5149d8;
        outline-offset: -3px;
    }

    .contact-group__chevron {
        width: 8px;
        height: 8px;
        margin-left: 1px;
        flex: 0 0 8px;
        transition: transform 160ms ease;
    }

    .contact-group__launcher[aria-expanded="true"] .contact-group__chevron {
        transform: rotate(180deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .contact-group__action,
    .contact-group__chevron {
        transition: none;
    }
}
