:root {
    --customer-service-right: max(16px, env(safe-area-inset-right, 0px));
    --home-customer-service-launcher-width: 96px;
}

.customer-service {
    --customer-service-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    --customer-service-top: 112px;
    --customer-service-launcher-height: 44px;
    --customer-service-gap: 12px;
    position: fixed;
    right: var(--customer-service-right);
    bottom: var(--customer-service-bottom);
    z-index: 90;
    margin: 0;
    font: 14px/1.45 "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    text-align: left;
}

.customer-service__launcher,
.customer-service button {
    box-sizing: border-box;
    margin: 0;
    font: inherit;
    cursor: pointer;
}

.customer-service .customer-service__launcher {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--customer-service-launcher-height);
    padding: 0 16px;
    border: 1px solid #00b7ff;
    border-radius: 24px;
    background: #072338;
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 16px rgb(0 23 44 / 24%);
}

.customer-service .customer-service__launcher:hover {
    background: #0b3954;
}

.customer-service :focus-visible {
    outline: 2px solid #0088bd;
    outline-offset: 2px;
}

.customer-service__panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + var(--customer-service-gap));
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - var(--customer-service-bottom) - var(--customer-service-launcher-height) - var(--customer-service-gap) - var(--customer-service-top));
    max-height: calc(100dvh - var(--customer-service-bottom) - var(--customer-service-launcher-height) - var(--customer-service-gap) - var(--customer-service-top));
    overflow: hidden;
    border: 1px solid #a8c4d4;
    border-radius: 12px;
    background: #fff;
    color: #172d3b;
    color-scheme: light;
    box-shadow: 0 8px 28px rgb(0 23 44 / 24%);
}

.customer-service__header,
.customer-service__links {
    display: flex;
    flex: none;
    align-items: center;
    gap: 16px;
    margin: 0;
    padding: 4px 12px;
}

.customer-service__header {
    justify-content: space-between;
    border-bottom: 1px solid #dbe7ee;
}

.customer-service__header h2 {
    margin: 0;
    font: 600 16px/1.45 "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

.customer-service__header button {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #172d3b;
    font-size: 24px;
}

.customer-service__header button:hover,
.customer-service__content button:hover {
    background: #eef6fa;
}

.customer-service__content {
    position: relative;
    display: grid;
    flex: 1;
    place-content: center;
    justify-items: center;
    gap: 12px;
    min-height: 0;
    margin: 0;
    text-align: center;
}

.customer-service__content p {
    margin: 0;
}

.customer-service__content button {
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid #9eb7c7;
    border-radius: 6px;
    background: #fff;
    color: #172d3b;
}

.customer-service__frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.customer-service__frame[data-loading] {
    visibility: hidden;
}

.customer-service__links {
    border-top: 1px solid #dbe7ee;
}

.customer-service__links a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    color: #00618c;
    text-decoration: underline;
}

.customer-service [hidden] {
    display: none;
}

.customer-service--home {
    --customer-service-bottom: max(24px, env(safe-area-inset-bottom, 0px));
}

.customer-service--home .customer-service__launcher {
    width: var(--home-customer-service-launcher-width);
}

/* 首页首屏的 KTOS 链接为右下角客服入口留出空间。 */
#brand .home-brand-intro.home-brand-intro--with-customer-service {
    padding-right: max(3.90625vw, calc(var(--customer-service-right) + var(--home-customer-service-launcher-width) + 16px));
}

@media (max-width: 768px) {
    #brand .home-brand-intro.home-brand-intro--with-customer-service {
        height: auto;
        min-height: 94px;
        flex-basis: auto;
        padding-bottom: 8px;
    }
}

/* 首页桌面端的轮播分页在右侧，面板给分页标签留出空间。 */
.customer-service--home .customer-service__panel {
    right: 152px;
}

.ktos-page > .customer-service {
    --customer-service-gap: 64px;
    --customer-service-top: 144px;
}

.agent-bg:has(~ .customer-service) {
    padding-bottom: max(7vw, calc(68px + env(safe-area-inset-bottom, 0px)));
}

@media (max-width: 420px) {
    .article-page > .customer-service {
        --customer-service-bottom: max(64px, env(safe-area-inset-bottom, 0px));
    }
}
