/* 独立样式避免依赖静态页面生成器，常规页面统一保留客服和回顶槽位。 */
.customer-service {
    --customer-service-bottom: 100px;
    --customer-service-contact-height: 72px;
    --customer-service-top-height: 64px;
    position: fixed;
    right: 70px;
    bottom: var(--customer-service-bottom);
    z-index: 1000;
    display: none;
    width: 64px;
    height: calc(var(--customer-service-contact-height) + 8px + var(--customer-service-top-height));
    color: #1f2937;
    font-family: inherit;
}

.customer-service,
.customer-service * {
    box-sizing: border-box;
}

.customer-service [hidden] {
    display: none !important;
}

.customer-service__contact {
    position: absolute;
    top: 0;
    right: 0;
    width: 64px;
    height: var(--customer-service-contact-height);
}

.customer-service__trigger {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 64px;
    height: 100%;
    border-radius: 4px;
    background: #0077ff;
    color: #fff;
    font-size: 12px;
    font-weight: 400;
    line-height: 20px;
    text-decoration: none;
    white-space: nowrap;
}

.customer-service__trigger > img,
.customer-service__top > img,
.customer-service__action > img {
    display: block;
    flex-shrink: 0;
}

.customer-service__trigger:hover,
.customer-service__trigger[aria-expanded="true"],
.customer-service__top:hover,
.customer-service__action:hover {
    background-color: #0045ff;
    color: #fff;
}

.customer-service__trigger:focus-visible,
.customer-service__action:focus-visible,
.customer-service__top:focus-visible {
    outline: 2px solid #0045ff;
    outline-offset: 3px;
}

.customer-service__panel {
    position: absolute;
    right: 76px;
    bottom: calc(-8px - var(--customer-service-top-height));
    width: 240px;
}

/* 将按钮与卡片之间的 12px 空隙也纳入悬停范围。 */
.customer-service__panel::after {
    position: absolute;
    top: 0;
    right: -12px;
    width: 12px;
    height: 100%;
    content: "";
}

.customer-service__card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-height: calc(100vh - var(--customer-service-bottom) - 16px);
    padding: 20px 16px 22px;
    overflow-y: auto;
    border: 1px solid #e5ebf3;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 28px rgba(31, 61, 112, .12);
}

.customer-service__title,
.customer-service__caption {
    flex-shrink: 0;
    width: 176px;
    max-width: 100%;
    margin: 0;
    text-align: center;
}

.customer-service__title {
    font-size: 16px;
    font-weight: 500;
    line-height: 24px;
}

.customer-service__scan {
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 176px;
    max-width: 100%;
}

.customer-service__qrcode {
    flex-shrink: 0;
    width: 100%;
}

/* 正式原图包含二维码与底部说明，保持完整比例和扫码留白。 */
.customer-service__qrcode img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
}

.customer-service__caption {
    color: #6b7280;
    font-size: 12px;
    font-weight: 400;
    line-height: 20px;
}

.customer-service__action {
    position: relative;
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 176px;
    max-width: 100%;
    height: 40px;
    border-radius: 4px;
    background: #0045ff;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    line-height: 22px;
    text-decoration: none;
}

.customer-service__action > img {
    position: absolute;
    top: 13px;
    right: 16px;
}

.customer-service__top {
    position: absolute;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: var(--customer-service-top-height);
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: #0077ff;
    cursor: pointer;
}

@media (min-width: 1024px) {
    .customer-service {
        display: block;
    }
}

/* 卡片按实际底边距限高，较矮窗口向下移动工具条，仍可滚动查看完整原图。 */
@media (max-height: 480px) {
    .customer-service {
        --customer-service-bottom: 16px;
    }
}

/* 极矮窗口先缩小边距，再按可用高度收缩按钮槽位。 */
@media (max-height: 175px) {
    .customer-service {
        --customer-service-bottom: 8px;
    }
}

@media (max-height: 159px) {
    .customer-service {
        --customer-service-contact-height: calc((100vh - 24px) * .529411765);
        --customer-service-top-height: calc((100vh - 24px) * .470588235);
    }

    .customer-service__trigger {
        gap: 2px;
        overflow: hidden;
        line-height: 14px;
    }

    .customer-service__trigger > img {
        width: auto;
        max-width: 24px;
        height: 40%;
    }

    .customer-service__top > img {
        width: auto;
        max-width: 28px;
        max-height: 60%;
    }
}
