.ai-customer {
    --ai-primary: #0759c7;
    --ai-primary-deep: #003f98;
    --ai-accent: #19a7ff;
    --ai-ink: #14213d;
    --ai-muted: #72809a;
    --ai-line: #e8edf5;
    --ai-surface: #ffffff;
    --ai-soft: #f4f7fb;
    position: fixed;
    right: 26px;
    bottom: 92px;
    z-index: 1190;
    font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ai-ink);
    line-height: 1.5;
}

.ai-customer[hidden] { display: none !important; }
.ai-customer *, .ai-customer *::before, .ai-customer *::after { box-sizing: border-box; }
.ai-customer button, .ai-customer textarea { font: inherit; }

.ai-customer__launcher {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 174px;
    height: 62px;
    padding: 8px 16px 8px 9px;
    overflow: visible;
    color: #fff;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 18px;
    background: linear-gradient(135deg, #0871e8 0%, #0754bd 54%, #003d91 100%);
    box-shadow: 0 15px 35px rgba(0,70,160,.28), inset 0 1px 0 rgba(255,255,255,.25);
    cursor: pointer;
    isolation: isolate;
    transition: transform .25s ease, box-shadow .25s ease, opacity .2s ease;
}

.ai-customer__launcher:hover { transform: translateY(-3px); box-shadow: 0 19px 42px rgba(0,70,160,.35), inset 0 1px 0 rgba(255,255,255,.25); }
.ai-customer__launcher:focus-visible { outline: 3px solid rgba(25,167,255,.35); outline-offset: 4px; }
.ai-customer.is-open .ai-customer__launcher { opacity: 0; transform: translateY(12px) scale(.88); pointer-events: none; }

.ai-customer__launcher-glow {
    position: absolute;
    inset: -8px;
    z-index: -1;
    border-radius: 25px;
    background: rgba(25,167,255,.16);
    animation: ai-customer-pulse 2.6s ease-out infinite;
}

.ai-customer__launcher-icon {
    display: grid;
    place-items: center;
    width: 45px;
    height: 45px;
    flex: 0 0 45px;
    border-radius: 14px;
    background: rgba(255,255,255,.16);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
}

.ai-customer__launcher-icon svg { width: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ai-customer__launcher-copy { display: flex; flex-direction: column; align-items: flex-start; white-space: nowrap; }
.ai-customer__launcher-copy strong { font-size: 15px; letter-spacing: .02em; }
.ai-customer__launcher-copy small { color: rgba(255,255,255,.72); font-size: 11px; }
.ai-customer__online-dot { position: absolute; top: 7px; left: 45px; width: 10px; height: 10px; border: 2px solid #0871e8; border-radius: 50%; background: #48dc8b; box-shadow: 0 0 0 2px rgba(72,220,139,.22); }

.ai-customer__panel {
    position: absolute;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    width: min(400px, calc(100vw - 32px));
    height: min(650px, calc(100vh - 126px));
    min-height: 480px;
    overflow: hidden;
    border: 1px solid rgba(216,226,240,.9);
    border-radius: 25px;
    background: rgba(255,255,255,.98);
    box-shadow: 0 28px 80px rgba(23,45,83,.24), 0 4px 18px rgba(23,45,83,.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(22px) scale(.96);
    transform-origin: right bottom;
    transition: opacity .24s ease, transform .32s cubic-bezier(.22,1,.36,1), visibility .24s;
}

.ai-customer.is-open .ai-customer__panel { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

.ai-customer__header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 82px;
    padding: 15px 17px 14px 18px;
    color: #fff;
    background:
        radial-gradient(circle at 15% -35%, rgba(87,198,255,.7), transparent 42%),
        linear-gradient(130deg, #0872e5 0%, #0753bd 57%, #003f94 100%);
}

.ai-customer__header::after { content: ""; position: absolute; right: 85px; bottom: -40px; width: 110px; height: 110px; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; }
.ai-customer__identity { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.ai-customer__avatar { display: grid; place-items: center; width: 46px; height: 46px; flex: 0 0 46px; border-radius: 15px; background: rgba(255,255,255,.16); box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); backdrop-filter: blur(6px); }
.ai-customer__avatar svg { width: 29px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ai-customer__heading { display: flex; flex-direction: column; min-width: 0; }
.ai-customer__heading strong { overflow: hidden; font-size: 16px; letter-spacing: .02em; text-overflow: ellipsis; white-space: nowrap; }
.ai-customer__heading small { display: flex; align-items: center; gap: 6px; color: rgba(255,255,255,.76); font-size: 12px; }
.ai-customer__heading i { width: 7px; height: 7px; border-radius: 50%; background: #5ce69a; box-shadow: 0 0 0 3px rgba(92,230,154,.13); }
.ai-customer__header-actions { position: relative; z-index: 2; display: flex; gap: 4px; }
.ai-customer__header-actions button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; color: rgba(255,255,255,.86); border: 0; border-radius: 10px; background: transparent; cursor: pointer; transition: background .2s, color .2s; }
.ai-customer__header-actions button:hover { color: #fff; background: rgba(255,255,255,.16); }
.ai-customer__header-actions button:focus-visible { outline: 2px solid rgba(255,255,255,.8); outline-offset: 1px; }
.ai-customer__header-actions svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.ai-customer__messages {
    flex: 1 1 auto;
    min-height: 0;
    padding: 22px 18px 16px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    background:
        radial-gradient(circle at 100% 0, rgba(12,105,219,.055), transparent 32%),
        linear-gradient(180deg, #f8fafe 0%, #fff 72%);
    scrollbar-width: thin;
    scrollbar-color: #ccd7e7 transparent;
}

.ai-customer__messages::-webkit-scrollbar { width: 5px; }
.ai-customer__messages::-webkit-scrollbar-thumb { border-radius: 5px; background: #ccd7e7; }
.ai-customer__loading { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 5px; height: 100%; color: var(--ai-muted); }
.ai-customer__loading span { width: 7px; height: 7px; border-radius: 50%; background: var(--ai-primary); animation: ai-customer-bounce 1s ease-in-out infinite; }
.ai-customer__loading span:nth-child(2) { animation-delay: .13s; }
.ai-customer__loading span:nth-child(3) { animation-delay: .26s; }
.ai-customer__loading p { width: 100%; margin-top: 8px; text-align: center; font-size: 12px; }

.ai-customer__message { display: flex; align-items: flex-end; gap: 9px; margin-bottom: 17px; animation: ai-customer-message-in .28s ease both; }
.ai-customer__message--user { justify-content: flex-end; }
.ai-customer__message-avatar { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 30px; color: var(--ai-primary); border: 1px solid #dae6f6; border-radius: 10px; background: #fff; box-shadow: 0 4px 10px rgba(27,66,120,.08); }
.ai-customer__message-avatar svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ai-customer__bubble { position: relative; max-width: 80%; padding: 11px 14px; color: #33405a; border: 1px solid #e4eaf3; border-radius: 7px 17px 17px 17px; background: #fff; box-shadow: 0 5px 18px rgba(34,57,90,.055); font-size: 14px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.ai-customer__message--user .ai-customer__bubble { color: #fff; border-color: transparent; border-radius: 17px 7px 17px 17px; background: linear-gradient(135deg, #1479e4, #0759c7); box-shadow: 0 7px 18px rgba(7,89,199,.18); }
.ai-customer__message--error .ai-customer__bubble { color: #a04444; border-color: #f4d9d9; background: #fff7f7; }
.ai-customer__retry { display: block; margin-top: 7px; padding: 0; color: #a04444; border: 0; border-bottom: 1px solid currentColor; background: transparent; font-size: 12px; cursor: pointer; }
.ai-customer__typing .ai-customer__bubble { display: flex; gap: 4px; padding: 14px 17px; }
.ai-customer__typing i { width: 6px; height: 6px; border-radius: 50%; background: #7d8ba3; animation: ai-customer-bounce 1s ease-in-out infinite; }
.ai-customer__typing i:nth-child(2) { animation-delay: .13s; }.ai-customer__typing i:nth-child(3) { animation-delay: .26s; }

.ai-customer__suggestions { display: flex; gap: 7px; padding: 5px 17px 10px; overflow-x: auto; background: #fff; scrollbar-width: none; }
.ai-customer__suggestions::-webkit-scrollbar { display: none; }
.ai-customer__suggestions button { flex: 0 0 auto; padding: 7px 11px; color: #386096; border: 1px solid #d9e6f5; border-radius: 999px; background: #f7faff; font-size: 12px; cursor: pointer; transition: color .2s, border-color .2s, background .2s; }
.ai-customer__suggestions button:hover { color: var(--ai-primary); border-color: #a9caef; background: #edf6ff; }

.ai-customer__composer { display: flex; align-items: flex-end; gap: 9px; padding: 11px 14px 9px; border-top: 1px solid var(--ai-line); background: #fff; }
.ai-customer__input-wrap { position: relative; flex: 1; min-width: 0; }
.ai-customer__input-wrap textarea { display: block; width: 100%; min-height: 47px; max-height: 116px; resize: none; padding: 11px 64px 10px 13px; color: var(--ai-ink); border: 1px solid #dce4ef; border-radius: 14px; outline: 0; background: var(--ai-soft); font-size: 14px; line-height: 24px; transition: border .2s, box-shadow .2s, background .2s; }
.ai-customer__input-wrap textarea::placeholder { color: #9aa5b5; }
.ai-customer__input-wrap textarea:focus { border-color: #86b8ef; background: #fff; box-shadow: 0 0 0 3px rgba(7,89,199,.08); }
.ai-customer__counter { position: absolute; right: 10px; bottom: 8px; color: #9ca6b6; font-size: 10px; pointer-events: none; }
.ai-customer__counter.is-near-limit { color: #d47a35; }
.ai-customer__send { display: grid; place-items: center; width: 47px; height: 47px; flex: 0 0 47px; padding: 0; color: #fff; border: 0; border-radius: 14px; background: linear-gradient(135deg, #1681ec, #0754bd); box-shadow: 0 7px 17px rgba(7,84,189,.2); cursor: pointer; transition: opacity .2s, transform .2s, box-shadow .2s; }
.ai-customer__send:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(7,84,189,.27); }
.ai-customer__send:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.ai-customer__send svg { width: 23px; fill: currentColor; }
.ai-customer__send.is-sending svg { animation: ai-customer-send 1s ease-in-out infinite; }
.ai-customer__notice { margin: 0; padding: 0 14px 10px; color: #98a3b4; background: #fff; text-align: center; font-size: 10px; }
.ai-customer__backdrop { display: none; }

@keyframes ai-customer-pulse { 0% { opacity: .8; transform: scale(.92); } 70%,100% { opacity: 0; transform: scale(1.14); } }
@keyframes ai-customer-bounce { 0%,60%,100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes ai-customer-message-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ai-customer-send { 50% { transform: translate(3px,-2px); } }

@media (max-width: 640px) {
    .ai-customer { right: 15px; bottom: calc(76px + env(safe-area-inset-bottom)); }
    .ai-customer__launcher { min-width: 0; width: 56px; height: 56px; padding: 6px; border-radius: 18px; }
    .ai-customer__launcher-icon { width: 44px; height: 44px; flex-basis: 44px; }
    .ai-customer__launcher-copy { display: none; }
    .ai-customer__online-dot { top: 2px; right: 1px; left: auto; border-color: #0871e8; }
    .ai-customer__panel {
        position: fixed;
        inset: auto 0 0;
        width: 100%;
        height: min(92dvh, 760px);
        min-height: 0;
        border-width: 1px 0 0;
        border-radius: 24px 24px 0 0;
        padding-bottom: env(safe-area-inset-bottom);
        transform: translateY(105%);
        transform-origin: center bottom;
    }
    .ai-customer.is-open .ai-customer__panel { transform: translateY(0); }
    .ai-customer__backdrop { position: fixed; inset: 0; display: block; background: rgba(13,27,51,.38); opacity: 0; visibility: hidden; backdrop-filter: blur(3px); transition: opacity .25s, visibility .25s; }
    .ai-customer.is-open .ai-customer__backdrop { opacity: 1; visibility: visible; }
    .ai-customer__panel { z-index: 1; }
    .ai-customer__header { min-height: 76px; padding: 12px 14px 12px 16px; }
    .ai-customer__avatar { width: 42px; height: 42px; flex-basis: 42px; border-radius: 13px; }
    .ai-customer__messages { padding: 18px 14px 12px; }
    .ai-customer__bubble { max-width: 84%; font-size: 14px; }
    .ai-customer__suggestions { padding-right: 14px; padding-left: 14px; }
    .ai-customer__composer { padding-right: 10px; padding-left: 10px; }
    .ai-customer__notice { padding-bottom: 7px; }
    body.ai-customer-lock { overflow: hidden !important; touch-action: none; }
}

@media (max-height: 570px) and (min-width: 641px) {
    .ai-customer__panel { height: calc(100vh - 24px); min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .ai-customer *, .ai-customer *::before, .ai-customer *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
