#xiaode-chat {
    --xd-primary: #1678d3;
    --xd-primary-deep: #0f5fa8;
    --xd-teal: #1aa6a6;
    --xd-bg: #f5f8fc;
    --xd-soft: #eaf3fb;
    --xd-text: #1f2937;
    --xd-muted: #6b7280;
    --xd-line: #dbe7f3;
    --xd-white: #ffffff;
    font-family: "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

#xiaode-chat * {
    box-sizing: border-box;
}

.xd-launcher {
    position: fixed;
    right: 24px;
    bottom: 26px;
    width: 66px;
    height: 66px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--xd-primary), var(--xd-teal));
    box-shadow: 0 14px 32px rgba(22, 120, 211, .34), inset 0 1px 0 rgba(255, 255, 255, .45);
    color: var(--xd-white);
    cursor: pointer;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .25s ease, box-shadow .25s ease;
}

.xd-launcher:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 18px 40px rgba(22, 120, 211, .44), inset 0 1px 0 rgba(255, 255, 255, .55);
}

.xd-launcher-orbit {
    position: absolute;
    inset: -7px;
    border-radius: 50%;
    border: 1px solid rgba(22, 120, 211, .35);
    animation: xd-pulse 2.8s ease-out infinite;
}

.xd-launcher-avatar {
    position: relative;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    color: var(--xd-primary-deep);
    font-size: 22px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .7);
}

.xd-launcher-label {
    position: absolute;
    bottom: -19px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
    color: var(--xd-primary-deep);
    text-shadow: 0 1px 3px rgba(255, 255, 255, .95);
}

.xd-panel {
    position: fixed;
    right: 24px;
    bottom: 108px;
    width: 380px;
    height: 548px;
    max-height: calc(100vh - 130px);
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, .97);
    border: 1px solid rgba(219, 231, 243, .95);
    border-radius: 20px;
    box-shadow: 0 24px 65px rgba(15, 71, 122, .22), 0 2px 8px rgba(15, 71, 122, .08);
    backdrop-filter: blur(14px);
    overflow: hidden;
    opacity: 0;
    transform: translateY(18px) scale(.965);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity .25s ease, transform .28s cubic-bezier(.2, .8, .2, 1);
    z-index: 99999;
}

#xiaode-chat.xd-open .xd-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.xd-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(120deg, var(--xd-primary-deep), var(--xd-primary) 55%, var(--xd-teal));
    color: var(--xd-white);
}

.xd-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .2);
    border: 1px solid rgba(255, 255, 255, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    font-weight: 600;
}

.xd-header-main {
    flex: 1;
    min-width: 0;
}

.xd-header-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: .5px;
}

.xd-header-status {
    font-size: 12px;
    opacity: .92;
    display: flex;
    align-items: center;
    gap: 6px;
}

.xd-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #7cf7c4;
    box-shadow: 0 0 0 3px rgba(124, 247, 196, .25);
}

.xd-close {
    border: 0;
    background: rgba(255, 255, 255, .16);
    color: var(--xd-white);
    width: 30px;
    height: 30px;
    border-radius: 9px;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background .2s ease;
}

.xd-close:hover {
    background: rgba(255, 255, 255, .3);
}

.xd-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 11px 14px 6px;
    background: linear-gradient(180deg, var(--xd-soft), rgba(245, 248, 252, .4));
}

.xd-chip {
    border: 1px solid #c9def3;
    background: var(--xd-white);
    color: var(--xd-primary-deep);
    border-radius: 999px;
    padding: 5px 11px;
    font-size: 12px;
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.xd-chip:hover {
    transform: translateY(-1px);
    border-color: var(--xd-primary);
    box-shadow: 0 4px 12px rgba(22, 120, 211, .14);
}

.xd-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px 6px;
    background: linear-gradient(180deg, rgba(245, 248, 252, .9), var(--xd-white));
    scrollbar-width: thin;
}

.xd-message {
    display: flex;
    margin-bottom: 11px;
    animation: xd-fade-in .25s ease both;
}

.xd-message--user {
    justify-content: flex-end;
}

.xd-bubble {
    max-width: 84%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    word-break: break-word;
    white-space: normal;
}

.xd-message--bot .xd-bubble {
    background: var(--xd-white);
    color: var(--xd-text);
    border: 1px solid var(--xd-line);
    border-top-left-radius: 4px;
    box-shadow: 0 4px 14px rgba(31, 41, 55, .05);
}

.xd-message--user .xd-bubble {
    background: linear-gradient(135deg, var(--xd-primary), var(--xd-primary-deep));
    color: var(--xd-white);
    border-top-right-radius: 4px;
    box-shadow: 0 5px 16px rgba(22, 120, 211, .2);
}

.xd-bubble a {
    color: #0b5fa8;
    text-decoration: underline;
}

.xd-message--user .xd-bubble a {
    color: var(--xd-white);
}

.xd-sources {
    margin: -4px 0 12px;
    padding: 8px 12px;
    background: rgba(234, 243, 251, .75);
    border: 1px solid var(--xd-line);
    border-radius: 10px;
    font-size: 12px;
    color: var(--xd-muted);
    line-height: 1.7;
    animation: xd-fade-in .25s ease both;
}

.xd-sources-label {
    font-weight: 600;
    color: var(--xd-primary-deep);
    margin-right: 6px;
}

.xd-sources a {
    display: inline-block;
    margin: 2px 10px 2px 0;
    color: var(--xd-primary);
    text-decoration: none;
    border-bottom: 1px dashed rgba(22, 120, 211, .45);
}

.xd-sources a:hover {
    color: var(--xd-primary-deep);
    border-bottom-color: var(--xd-primary-deep);
}

.xd-typing {
    display: none;
    gap: 5px;
    padding: 0 16px 8px;
}

.xd-typing.xd-active {
    display: flex;
}

.xd-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--xd-primary);
    animation: xd-bounce 1s infinite ease-in-out;
}

.xd-typing span:nth-child(2) { animation-delay: .15s; }
.xd-typing span:nth-child(3) { animation-delay: .3s; }

.xd-form {
    display: flex;
    gap: 8px;
    padding: 10px 12px 4px;
    border-top: 1px solid var(--xd-line);
    background: var(--xd-white);
}

.xd-form input {
    flex: 1;
    min-width: 0;
    height: 42px;
    border: 1px solid var(--xd-line);
    border-radius: 11px;
    padding: 0 12px;
    font-size: 13.5px;
    color: var(--xd-text);
    background: var(--xd-bg);
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.xd-form input:focus {
    border-color: var(--xd-primary);
    box-shadow: 0 0 0 3px rgba(22, 120, 211, .12);
}

.xd-form button {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border: 0;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--xd-primary), var(--xd-teal));
    color: var(--xd-white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .18s ease, opacity .18s ease;
}

.xd-form button:hover {
    transform: translateY(-1px);
}

.xd-form button:disabled {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
}

.xd-footnote {
    padding: 2px 14px 10px;
    font-size: 11px;
    color: var(--xd-muted);
    text-align: center;
    background: var(--xd-white);
}

@keyframes xd-pulse {
    0% { transform: scale(.92); opacity: .8; }
    70% { transform: scale(1.18); opacity: 0; }
    100% { transform: scale(1.18); opacity: 0; }
}

@keyframes xd-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .55; }
    30% { transform: translateY(-5px); opacity: 1; }
}

@keyframes xd-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
    .xd-launcher {
        right: 18px;
        bottom: 20px;
        width: 60px;
        height: 60px;
    }

    .xd-launcher-avatar {
        width: 42px;
        height: 42px;
        font-size: 20px;
    }

    .xd-panel {
        left: 10px;
        right: 10px;
        bottom: 92px;
        width: auto;
        height: 68vh;
        max-height: 620px;
        border-radius: 18px;
        transform-origin: bottom center;
    }
}

@media (prefers-reduced-motion: reduce) {
    #xiaode-chat *,
    #xiaode-chat *::before,
    #xiaode-chat *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
