/* 灵境在线客服 · 用户端 */

.cs-chat-launcher {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 9820;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px 12px 14px;
    border: 1px solid rgba(167, 139, 250, 0.35);
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(30, 20, 55, 0.92), rgba(45, 25, 75, 0.88));
    color: #f5f0ff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(88, 28, 135, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s ease, border-color 0.28s ease;
}

.cs-chat-launcher:hover {
    transform: translateY(-2px);
    border-color: rgba(196, 181, 253, 0.55);
    box-shadow: 0 12px 40px rgba(124, 58, 237, 0.4);
}

.cs-chat-launcher:active {
    transform: translateY(0) scale(0.97);
}

.cs-chat-launcher.is-active {
    border-color: rgba(167, 139, 250, 0.5);
    box-shadow: 0 8px 28px rgba(124, 58, 237, 0.3);
}

.cs-chat-launcher-glow {
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: radial-gradient(circle at 30% 30%, rgba(167, 139, 250, 0.35), transparent 60%);
    pointer-events: none;
    z-index: -1;
}

.cs-chat-launcher i {
    font-size: 18px;
    color: #c4b5fd;
}

.cs-chat-launcher.has-unread {
    animation: cs-chat-pulse 2.4s ease-in-out infinite;
}

.cs-chat-badge {
    position: absolute;
    top: -6px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(225, 29, 72, 0.5);
    animation: cs-badge-pop 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 1;
}

@keyframes cs-badge-pop {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes cs-chat-pulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(88, 28, 135, 0.35); }
    50% { box-shadow: 0 8px 32px rgba(244, 63, 94, 0.45), 0 0 0 4px rgba(244, 63, 94, 0.12); }
}

.cs-chat-panel {
    position: fixed;
    right: 18px;
    bottom: 88px;
    z-index: 9810;
    width: min(420px, calc(100vw - 24px));
    height: min(620px, calc(100vh - 120px));
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    border: 1px solid rgba(167, 139, 250, 0.28);
    background: linear-gradient(165deg, rgba(18, 12, 32, 0.97) 0%, rgba(28, 16, 48, 0.95) 100%);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    overflow: hidden;
    backdrop-filter: blur(20px);
    transform-origin: calc(100% - 36px) calc(100% + 44px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(20px) scale(0.88);
    transition:
        opacity 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        visibility 0.34s;
}

.cs-chat-root.is-open .cs-chat-panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.cs-chat-panel-aurora {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 80% 50% at 10% -10%, rgba(124, 58, 237, 0.18), transparent 55%),
        radial-gradient(ellipse 60% 40% at 90% 0%, rgba(236, 72, 153, 0.1), transparent 50%);
    z-index: 0;
}

.cs-chat-head,
.cs-chat-body {
    position: relative;
    z-index: 1;
}

.cs-chat-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cs-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 14px;
    border-bottom: 1px solid rgba(167, 139, 250, 0.15);
    background: rgba(255, 255, 255, 0.03);
}

.cs-chat-head-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.cs-chat-head-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.5), rgba(236, 72, 153, 0.35));
    color: #f5f0ff;
    font-size: 16px;
    flex-shrink: 0;
}

.cs-chat-head strong {
    display: block;
    font-size: 15px;
    color: #faf5ff;
}

.cs-chat-head-sub {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: rgba(196, 181, 253, 0.75);
}

.cs-chat-collapse {
    position: relative;
    z-index: 2;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(245, 240, 255, 0.8);
    cursor: pointer;
    transition: background 0.2s, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    flex-shrink: 0;
}

.cs-chat-collapse:hover {
    background: rgba(255, 255, 255, 0.14);
    transform: translateY(1px);
}

.cs-chat-collapse:active {
    transform: scale(0.94);
}

.cs-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    scroll-behavior: smooth;
    min-height: 0;
}

.cs-chat-compose {
    position: relative;
    z-index: 1;
    border-top: 1px solid rgba(167, 139, 250, 0.12);
    background: rgba(0, 0, 0, 0.15);
    padding: 10px 12px 12px;
    flex-shrink: 0;
}

.cs-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.cs-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(167, 139, 250, 0.25);
    border-radius: 999px;
}

.cs-chat-day {
    text-align: center;
    margin: 8px 0 14px;
}

.cs-chat-day span {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11px;
    color: rgba(196, 181, 253, 0.7);
    background: rgba(255, 255, 255, 0.04);
}

.cs-chat-bubble-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 12px;
    max-width: 88%;
}

.cs-chat-bubble-wrap.is-mine {
    align-items: flex-end;
    margin-left: auto;
}

.cs-chat-bubble-wrap.is-system {
    align-items: center;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.cs-chat-sender {
    font-size: 11px;
    color: rgba(196, 181, 253, 0.65);
    margin-bottom: 4px;
    padding-left: 4px;
}

.cs-chat-bubble {
    position: relative;
    padding: 10px 14px 22px;
    border-radius: 16px 16px 16px 6px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(167, 139, 250, 0.12);
    color: #f3eeff;
    word-break: break-word;
}

.is-mine .cs-chat-bubble {
    border-radius: 16px 16px 6px 16px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.55), rgba(109, 40, 217, 0.45));
    border-color: rgba(196, 181, 253, 0.25);
}

.is-system .cs-chat-bubble {
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    font-size: 12px;
    color: rgba(196, 181, 253, 0.85);
    text-align: center;
    padding-bottom: 10px;
}

.cs-chat-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.cs-chat-time {
    position: absolute;
    right: 10px;
    bottom: 6px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.35);
}

.cs-chat-img-link {
    display: block;
    border-radius: 10px;
    overflow: hidden;
    max-width: 240px;
}

.cs-chat-img {
    display: block;
    width: 100%;
    height: auto;
    vertical-align: middle;
}

.cs-chat-file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    color: #e9d5ff;
    text-decoration: none;
    font-size: 13px;
}

.cs-chat-file:hover {
    background: rgba(0, 0, 0, 0.3);
}

.cs-chat-empty {
    height: 100%;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: rgba(196, 181, 253, 0.5);
    font-size: 14px;
}

.cs-chat-empty i {
    font-size: 32px;
    opacity: 0.6;
}

.cs-chat-pending {
    margin-bottom: 8px;
}

.cs-chat-pending-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(124, 58, 237, 0.15);
    border: 1px dashed rgba(167, 139, 250, 0.35);
    font-size: 12px;
    color: #ddd6fe;
}

.cs-chat-pending-inner.is-image img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
}

.cs-chat-pending-clear {
    margin-left: auto;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
}

.cs-chat-toolbar {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.cs-chat-tool {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(196, 181, 253, 0.85);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.cs-chat-tool:hover {
    background: rgba(167, 139, 250, 0.2);
    color: #f5f0ff;
}

.cs-chat-tool.is-active {
    background: rgba(167, 139, 250, 0.28);
    color: #f5f0ff;
    box-shadow: inset 0 0 0 1px rgba(196, 181, 253, 0.35);
}

.cs-chat-emoji-panel {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(100% - 4px);
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    max-height: 168px;
    overflow-y: auto;
    padding: 10px;
    border-radius: 14px;
    border: 1px solid rgba(167, 139, 250, 0.28);
    background: linear-gradient(165deg, rgba(28, 18, 48, 0.98), rgba(22, 14, 38, 0.98));
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
    animation: csChatBannerIn 0.22s ease;
}

.cs-chat-emoji-panel[hidden] {
    display: none !important;
}

.cs-chat-emoji-item {
    width: 100%;
    aspect-ratio: 1;
    min-height: 32px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.cs-chat-emoji-item:hover {
    background: rgba(167, 139, 250, 0.2);
    transform: scale(1.12);
}

.cs-chat-emoji-item:active {
    transform: scale(0.95);
}

.cs-chat-emoji-panel::-webkit-scrollbar {
    width: 5px;
}

.cs-chat-emoji-panel::-webkit-scrollbar-thumb {
    background: rgba(167, 139, 250, 0.3);
    border-radius: 999px;
}

.cs-chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.cs-chat-input {
    flex: 1;
    min-height: 42px;
    max-height: 120px;
    padding: 10px 14px;
    border: 1px solid rgba(167, 139, 250, 0.2);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    color: #faf5ff;
    font-size: 14px;
    line-height: 1.45;
    resize: none;
    outline: none;
    font-family: inherit;
}

.cs-chat-input::placeholder {
    color: rgba(196, 181, 253, 0.45);
}

.cs-chat-input:focus {
    border-color: rgba(167, 139, 250, 0.45);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.cs-chat-send {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
    transition: transform 0.15s, box-shadow 0.15s;
}

.cs-chat-send:hover {
    transform: scale(1.04);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.5);
}

.cs-chat-send:active {
    transform: scale(0.96);
}

.ms-cs-online-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 14px;
    padding: 12px 18px;
    border: 1px solid rgba(167, 139, 250, 0.35);
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.35), rgba(236, 72, 153, 0.2));
    color: #f5f0ff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.ms-cs-online-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(196, 181, 253, 0.55);
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.25);
}

.ms-cs-online-btn i {
    color: #c4b5fd;
}

@media (max-width: 480px) {
    .cs-chat-panel {
        right: 0;
        left: 0;
        bottom: 72px;
        width: 100%;
        height: min(78vh, calc(100vh - 88px));
        max-height: calc(100dvh - 88px);
        border-radius: 20px 20px 0 0;
        transform-origin: 50% calc(100% + 44px);
    }

    .cs-chat-root.is-open .cs-chat-panel {
        transform: translateY(0) scale(1);
    }

    .cs-chat-launcher-label {
        display: none;
    }

    .cs-chat-launcher {
        right: 14px;
        bottom: 14px;
        padding: 14px 16px;
        min-width: 52px;
        min-height: 52px;
        justify-content: center;
    }

    .cs-chat-launcher.is-active {
        padding: 14px;
        border-radius: 50%;
    }
}

html[data-theme="light"] .cs-chat-launcher {
    background: linear-gradient(135deg, #ffffff, #f3eeff);
    color: #5b21b6;
    border-color: rgba(124, 58, 237, 0.28);
    box-shadow: 0 8px 28px rgba(124, 58, 237, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

html[data-theme="light"] .cs-chat-launcher i {
    color: #7c3aed;
}

html[data-theme="light"] .cs-chat-launcher-glow {
    background: radial-gradient(circle at 30% 30%, rgba(124, 58, 237, 0.18), transparent 62%);
}

html[data-theme="light"] .cs-chat-launcher:hover {
    border-color: rgba(124, 58, 237, 0.42);
    box-shadow: 0 12px 36px rgba(124, 58, 237, 0.2);
}

html[data-theme="light"] .cs-chat-launcher.is-active {
    border-color: rgba(124, 58, 237, 0.38);
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.16);
}

html[data-theme="light"] .cs-chat-launcher.has-unread {
    animation: cs-chat-pulse-light 2.4s ease-in-out infinite;
}

@keyframes cs-chat-pulse-light {
    0%, 100% { box-shadow: 0 8px 28px rgba(124, 58, 237, 0.14); }
    50% { box-shadow: 0 8px 28px rgba(244, 63, 94, 0.22), 0 0 0 4px rgba(244, 63, 94, 0.08); }
}

html[data-theme="light"] .cs-chat-panel {
    background: linear-gradient(165deg, #ffffff 0%, #f8f5ff 48%, #faf8ff 100%);
    border-color: rgba(124, 58, 237, 0.2);
    box-shadow: 0 20px 60px rgba(91, 33, 182, 0.1), 0 0 0 1px rgba(124, 58, 237, 0.06) inset;
    backdrop-filter: none;
}

html[data-theme="light"] .cs-chat-panel-aurora {
    background:
        radial-gradient(ellipse 80% 50% at 10% -10%, rgba(124, 58, 237, 0.08), transparent 55%),
        radial-gradient(ellipse 60% 40% at 90% 0%, rgba(236, 72, 153, 0.06), transparent 50%);
}

html[data-theme="light"] .cs-chat-head {
    background: linear-gradient(180deg, rgba(124, 58, 237, 0.06), rgba(124, 58, 237, 0.02));
    border-bottom-color: rgba(124, 58, 237, 0.12);
}

html[data-theme="light"] .cs-chat-head-icon {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.18), rgba(236, 72, 153, 0.12));
    color: #6d28d9;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.12);
}

html[data-theme="light"] .cs-chat-head strong {
    color: #4c1d95;
}

html[data-theme="light"] .cs-chat-head-sub {
    color: #7c3aed;
}

html[data-theme="light"] .cs-chat-collapse {
    background: rgba(124, 58, 237, 0.08);
    color: #6d28d9;
}

html[data-theme="light"] .cs-chat-collapse:hover {
    background: rgba(124, 58, 237, 0.14);
}

html[data-theme="light"] .cs-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(124, 58, 237, 0.22);
}

html[data-theme="light"] .cs-chat-day span {
    color: #7c3aed;
    background: rgba(124, 58, 237, 0.08);
}

html[data-theme="light"] .cs-chat-sender {
    color: #8b5cf6;
}

html[data-theme="light"] .cs-chat-bubble {
    background: #f3f0ff;
    border-color: rgba(124, 58, 237, 0.14);
    color: #3730a3;
}

html[data-theme="light"] .is-mine .cs-chat-bubble {
    background: linear-gradient(135deg, #7c3aed, #9333ea);
    border-color: rgba(109, 40, 217, 0.35);
    color: #fff;
}

html[data-theme="light"] .is-system .cs-chat-bubble {
    background: #f8fafc;
    border: 1px dashed rgba(124, 58, 237, 0.2);
    color: #64748b;
}

html[data-theme="light"] .cs-chat-time {
    color: rgba(55, 48, 163, 0.45);
}

html[data-theme="light"] .is-mine .cs-chat-time {
    color: rgba(255, 255, 255, 0.72);
}

html[data-theme="light"] .cs-chat-file {
    background: rgba(124, 58, 237, 0.08);
    color: #5b21b6;
}

html[data-theme="light"] .cs-chat-file:hover {
    background: rgba(124, 58, 237, 0.14);
}

html[data-theme="light"] .cs-chat-empty {
    color: #a78bfa;
}

html[data-theme="light"] .cs-chat-empty i {
    color: #c4b5fd;
    opacity: 0.85;
}

html[data-theme="light"] .cs-chat-pending-inner {
    background: rgba(124, 58, 237, 0.08);
    border-color: rgba(124, 58, 237, 0.28);
    color: #5b21b6;
}

html[data-theme="light"] .cs-chat-pending-clear {
    background: rgba(124, 58, 237, 0.1);
    color: #6d28d9;
}

html[data-theme="light"] .cs-chat-tool {
    background: rgba(124, 58, 237, 0.08);
    color: #7c3aed;
}

html[data-theme="light"] .cs-chat-tool:hover {
    background: rgba(124, 58, 237, 0.16);
    color: #5b21b6;
}

html[data-theme="light"] .cs-chat-tool.is-active {
    background: rgba(124, 58, 237, 0.2);
    color: #5b21b6;
    box-shadow: inset 0 0 0 1px rgba(124, 58, 237, 0.25);
}

html[data-theme="light"] .cs-chat-emoji-panel {
    background: linear-gradient(165deg, #ffffff, #f8f5ff);
    border-color: rgba(124, 58, 237, 0.22);
    box-shadow: 0 -8px 28px rgba(124, 58, 237, 0.12);
}

html[data-theme="light"] .cs-chat-emoji-item:hover {
    background: rgba(124, 58, 237, 0.12);
}

html[data-theme="light"] .cs-chat-input {
    background: #fff;
    border-color: rgba(124, 58, 237, 0.22);
    color: #312e81;
}

html[data-theme="light"] .cs-chat-input::placeholder {
    color: #a78bfa;
}

html[data-theme="light"] .cs-chat-input:focus {
    border-color: rgba(124, 58, 237, 0.45);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

html[data-theme="light"] .cs-chat-send {
    background: linear-gradient(135deg, #7c3aed, #9333ea);
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.32);
}

html[data-theme="light"] .cs-chat-compose {
    background: #faf8ff;
    border-top-color: rgba(124, 58, 237, 0.1);
}

html[data-theme="light"] .ms-cs-online-btn {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(236, 72, 153, 0.06));
    color: #5b21b6;
    border-color: rgba(124, 58, 237, 0.22);
}

html[data-theme="light"] .ms-cs-online-btn:hover {
    border-color: rgba(124, 58, 237, 0.38);
    box-shadow: 0 8px 22px rgba(124, 58, 237, 0.14);
}

html[data-theme="light"] .ms-cs-online-btn i {
    color: #7c3aed;
}

.cs-chat-status-banner,
.cs-chat-idle-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 10px 12px 0;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.45;
    animation: csChatBannerIn 0.35s ease;
}

@keyframes csChatBannerIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.cs-chat-status-banner i,
.cs-chat-idle-banner i {
    margin-top: 2px;
    font-size: 14px;
    flex-shrink: 0;
}

.cs-chat-status-banner strong,
.cs-chat-idle-banner strong {
    display: block;
    font-size: 13px;
    margin-bottom: 2px;
}

.cs-chat-status-banner.is-closed {
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: #cbd5e1;
}

.cs-chat-idle-banner.is-warn {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fde68a;
}

.cs-chat-idle-banner.is-warn strong {
    color: #fcd34d;
}

html[data-theme="light"] .cs-chat-status-banner.is-closed {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}

html[data-theme="light"] .cs-chat-idle-banner.is-warn {
    background: #fffbeb;
    border-color: #fcd34d;
    color: #92400e;
}

html[data-theme="light"] .cs-chat-idle-banner.is-warn strong {
    color: #b45309;
}
