.stalkop-chat {
    --stalkop-fab-size: 60px;
    --stalkop-intro-ease: cubic-bezier(0.4, 0, 0.2, 1);
    position: fixed;
    right: 30px;
    bottom: 30px;
    z-index: 1040;
    font-family: "Open Sans", sans-serif;
    transition: right 0.78s var(--stalkop-intro-ease);
}

.stalkop-chat.is-intro-pending {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.stalkop-chat.is-intro-phase-expand,
.stalkop-chat.is-intro-phase-hide-label,
.stalkop-chat.is-intro-phase-collapse-pill,
.stalkop-chat.is-intro-done {
    right: 102px;
}

.stalkop-chat__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: var(--stalkop-fab-size);
    height: var(--stalkop-fab-size);
    padding: 0;
    border: 2px solid rgb(0, 125, 185);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 4px 16px rgba(49, 68, 83, 0.16);
    cursor: pointer;
    overflow: hidden;
    transition:
        width 0.78s var(--stalkop-intro-ease),
        border-radius 0.78s var(--stalkop-intro-ease),
        padding 0.78s var(--stalkop-intro-ease),
        box-shadow 0.15s ease;
}

.stalkop-chat.is-intro-phase-collapse-pill .stalkop-chat__toggle {
    transition:
        width 0.78s var(--stalkop-intro-ease),
        border-radius 0.78s var(--stalkop-intro-ease),
        padding 0.78s var(--stalkop-intro-ease),
        box-shadow 0.15s ease;
}

.stalkop-chat.is-intro-phase-spin .stalkop-chat__toggle {
    animation: stalkop-fab-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.stalkop-chat.is-intro-phase-expand .stalkop-chat__toggle,
.stalkop-chat.is-intro-phase-hide-label .stalkop-chat__toggle {
    width: auto;
    min-width: var(--stalkop-fab-size);
    padding: 0 14px 0 4px;
    border-radius: 999px;
    justify-content: flex-start;
}

.stalkop-chat.is-intro-phase-collapse-pill .stalkop-chat__toggle,
.stalkop-chat.is-intro-done .stalkop-chat__toggle {
    width: var(--stalkop-fab-size);
    min-width: var(--stalkop-fab-size);
    padding: 0 0 0 4px;
    border-radius: 50%;
    justify-content: flex-start;
}

.stalkop-chat__toggle-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: calc(var(--stalkop-fab-size) - 8px);
    height: calc(var(--stalkop-fab-size) - 8px);
    transform-origin: center center;
}

.stalkop-chat.is-intro-phase-spin .stalkop-chat__toggle-icon-wrap {
    animation: stalkop-spin-cw 0.6s var(--stalkop-intro-ease) 1 forwards;
}

.stalkop-chat.is-intro-phase-expand .stalkop-chat__toggle-icon-wrap {
    animation: none;
    transform: rotate(0deg);
}

.stalkop-chat.is-intro-phase-hide-label .stalkop-chat__toggle-icon-wrap {
    animation: stalkop-spin-ccw 0.62s var(--stalkop-intro-ease) 1 forwards;
}

.stalkop-chat.is-intro-phase-collapse-pill .stalkop-chat__toggle-icon-wrap,
.stalkop-chat.is-intro-done .stalkop-chat__toggle-icon-wrap {
    animation: none;
    transform: rotate(0deg);
}

@keyframes stalkop-fab-in {
    from {
        opacity: 0;
        transform: scale(0.35);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes stalkop-spin-cw {
    to {
        transform: rotate(360deg);
    }
}

@keyframes stalkop-spin-ccw {
    to {
        transform: rotate(-360deg);
    }
}

.stalkop-chat__toggle:hover {
    box-shadow: 0 6px 24px rgba(49, 68, 83, 0.24);
}

.stalkop-chat__toggle:focus {
    outline: none;
}

.stalkop-chat__toggle:focus-visible {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgb(0, 125, 185);
}

.stalkop-chat__toggle-img {
    display: block;
    width: calc(var(--stalkop-fab-size) - 16px);
    height: calc(var(--stalkop-fab-size) - 16px);
    object-fit: contain;
    border-radius: 50%;
}

.stalkop-chat__toggle-label {
    display: block;
    flex: 0 0 auto;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 700;
    color: rgb(49, 68, 83);
    margin-left: 0;
    transform: translateX(8px);
    pointer-events: none;
    transition:
        max-width 0.72s var(--stalkop-intro-ease),
        opacity 0.52s ease,
        margin 0.72s var(--stalkop-intro-ease),
        transform 0.52s ease;
}

.stalkop-chat.is-intro-phase-expand .stalkop-chat__toggle-label {
    max-width: 140px;
    opacity: 1;
    margin-left: 2px;
    transform: translateX(0);
    transition:
        max-width 0.72s var(--stalkop-intro-ease) 0.06s,
        opacity 0.52s ease 0.18s,
        margin 0.72s var(--stalkop-intro-ease) 0.06s,
        transform 0.52s ease 0.18s;
}

/* Зеркало появления: сначала гаснет текст, потом сжимается ширина */
.stalkop-chat.is-intro-phase-hide-label .stalkop-chat__toggle-label {
    max-width: 0;
    opacity: 0;
    margin-left: 0;
    transform: translateX(8px);
    transition:
        opacity 0.52s ease,
        transform 0.52s ease,
        max-width 0.72s var(--stalkop-intro-ease) 0.12s,
        margin 0.72s var(--stalkop-intro-ease) 0.12s;
}

.stalkop-chat.is-intro-phase-collapse-pill .stalkop-chat__toggle-label,
.stalkop-chat.is-intro-done .stalkop-chat__toggle-label {
    position: absolute;
    width: 0;
    max-width: 0;
    opacity: 0;
    margin-left: 0;
    transform: translateX(8px);
    visibility: hidden;
    pointer-events: none;
}

.stalkop-chat__panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 12px);
    display: flex;
    flex-direction: column;
    width: min(380px, calc(100vw - 32px));
    max-height: min(520px, calc(100vh - 120px));
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 32px rgba(49, 68, 83, 0.22);
    overflow: hidden;
}

.stalkop-chat__panel[hidden] {
    display: none !important;
}

.stalkop-chat.is-open .stalkop-chat__toggle {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
}

.stalkop-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 14px 10px;
    background: linear-gradient(135deg, rgb(49, 68, 83) 0%, rgb(0, 125, 185) 100%);
    color: #fff;
}

.stalkop-chat__heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.stalkop-chat__title {
    font-family: "Arial Black", Arial, sans-serif;
    font-size: 18px;
    font-weight: 900;
    line-height: 1.2;
}

.stalkop-chat__badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: 1px solid rgb(231, 199, 17);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 11px;
    color: rgb(231, 199, 17);
}

.stalkop-chat__badge-from {
    opacity: 0.9;
}

.stalkop-chat__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
}

.stalkop-chat__close span {
    display: block;
    font-size: 24px;
    line-height: 1;
    transform: translateY(-1px);
}

.stalkop-chat__close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.stalkop-chat__messages {
    flex: 1 1 auto;
    min-height: 200px;
    max-height: 340px;
    overflow-y: auto;
    padding: 12px;
    background: rgb(246, 246, 246);
}

.stalkop-chat__msg {
    margin: 0 0 10px;
    max-width: 92%;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
}

.stalkop-chat__msg--bot {
    margin-right: auto;
    background: #fff;
    color: rgb(49, 68, 83);
    border-bottom-left-radius: 4px;
}

.stalkop-chat__msg--user {
    margin-left: auto;
    background: rgb(0, 125, 185);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.stalkop-chat__msg--typing {
    opacity: 0.7;
    font-style: italic;
}

.stalkop-chat__products {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 4px 0 10px;
}

.stalkop-chat__links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 4px 0 10px;
}

.stalkop-chat__link {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fff;
    text-decoration: none;
    color: inherit;
    border: 1px solid rgb(0, 125, 185);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.stalkop-chat__link:hover {
    background: rgba(0, 125, 185, 0.06);
    text-decoration: none;
    color: inherit;
}

.stalkop-chat__link-type {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: rgb(0, 125, 185);
}

.stalkop-chat__link-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    color: rgb(49, 68, 83);
}

.stalkop-chat__link-desc {
    font-size: 12px;
    line-height: 1.35;
    color: rgb(68, 68, 68);
}

.stalkop-chat__product {
    display: flex;
    gap: 10px;
    padding: 8px;
    border-radius: 10px;
    background: #fff;
    text-decoration: none;
    color: inherit;
    border: 1px solid rgb(216, 216, 216);
    transition: border-color 0.15s ease;
}

.stalkop-chat__product:hover {
    border-color: rgb(0, 125, 185);
    text-decoration: none;
    color: inherit;
}

.stalkop-chat__product-img {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 6px;
    background: #fff;
}

.stalkop-chat__product-body {
    min-width: 0;
}

.stalkop-chat__product-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    color: rgb(49, 68, 83);
}

.stalkop-chat__product-price {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    font-weight: 700;
    color: rgb(0, 125, 185);
}

.stalkop-chat__form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid rgb(216, 216, 216);
    background: #fff;
}

.stalkop-chat__input {
    width: 100%;
    min-height: 44px;
    max-height: 120px;
    padding: 10px 12px;
    border: 1px solid rgb(216, 216, 216);
    border-radius: 10px;
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
}

.stalkop-chat__input:focus {
    outline: none;
    border-color: rgb(0, 125, 185);
    box-shadow: 0 0 0 2px rgba(0, 125, 185, 0.15);
}

.stalkop-chat__send {
    align-self: flex-end;
    min-height: 40px;
    padding: 8px 18px;
    border: none;
    border-radius: 10px;
    background: rgb(0, 125, 185);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.stalkop-chat__send:hover {
    opacity: 0.92;
}

.stalkop-chat__send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@media (max-width: 767px) {
    .stalkop-chat {
        --stalkop-fab-size: 50px;
    }

    /* Над нижним меню (60px), в полосе footer2 справа от иконок оплаты */
    .stalkop-chat:not(.is-open) {
        bottom: 70px;
        right: 12px;
    }

    .stalkop-chat.is-intro-phase-spin,
    .stalkop-chat.is-intro-phase-expand,
    .stalkop-chat.is-intro-phase-hide-label,
    .stalkop-chat.is-intro-phase-collapse-pill,
    .stalkop-chat.is-intro-done:not(.is-open) {
        right: 12px;
    }

    .stalkop-chat.is-open {
        inset: 0;
        right: 0;
        bottom: 0;
    }

    .stalkop-chat.is-open .stalkop-chat__panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        box-shadow: none;
    }

    .stalkop-chat.is-open .stalkop-chat__messages {
        max-height: none;
    }

    .stalkop-chat__panel {
        width: calc(100vw - 20px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .stalkop-chat.is-intro-pending {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .stalkop-chat,
    .stalkop-chat__toggle,
    .stalkop-chat__toggle-label,
    .stalkop-chat__toggle-icon-wrap {
        transition: none !important;
        animation: none !important;
    }

    .stalkop-chat.is-intro-pending,
    .stalkop-chat.is-intro-phase-spin,
    .stalkop-chat.is-intro-phase-expand,
    .stalkop-chat.is-intro-phase-hide-label,
    .stalkop-chat.is-intro-phase-collapse-pill,
    .stalkop-chat.is-intro-done {
        right: 102px;
    }

    .stalkop-chat.is-intro-done .stalkop-chat__toggle,
    .stalkop-chat.is-intro-phase-collapse-pill .stalkop-chat__toggle {
        width: var(--stalkop-fab-size);
        padding: 0 0 0 4px;
        border-radius: 50%;
        justify-content: flex-start;
    }

    .stalkop-chat.is-intro-done .stalkop-chat__toggle-label {
        max-width: 0;
        opacity: 0;
    }
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
    .stalkop-chat.is-intro-pending,
    .stalkop-chat.is-intro-phase-spin,
    .stalkop-chat.is-intro-phase-expand,
    .stalkop-chat.is-intro-phase-hide-label,
    .stalkop-chat.is-intro-phase-collapse-pill,
    .stalkop-chat.is-intro-done:not(.is-open) {
        right: 12px;
    }

    .stalkop-chat:not(.is-open) {
        bottom: 70px;
    }
}
