/**
 * 客户端样式 - WhatsApp 风格
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #128C7E;
    --secondary-color: #075E54;
    --accent-color: #25D366;
    --bg-color: #E5DDD5;
    --chat-bg: #ECE5DD;
    --message-sent: #DCF8C6;
    --message-received: #FFFFFF;
    --text-primary: #000000;
    --text-secondary: #667781;
    --border-color: #D1D7DB;
    --header-height: 60px;
    --input-height: 60px;
    /* iOS 刘海 / PWA 安全区适配 */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    /* header 实际占用高度（包含安全区） */
    --header-offset: calc(var(--header-height) + var(--safe-top));
    /* 输入区实际占用高度（包含安全区/多行扩展），JS 会动态更新 */
    --input-offset: calc(var(--input-height) + var(--safe-bottom));
    --ad-height: 0px;
    --content-top-offset: calc(var(--header-offset) + var(--ad-height));
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--chat-bg);
    height: 100vh; /* fallback */
    height: 100dvh; /* 动态视口高度（移动端地址栏/键盘更稳定） */
    overflow: hidden;
    /* 禁用 body 文本选择 */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* 头部 */
.chat-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-offset);
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--safe-top) 16px 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    z-index: 100;
    /* 禁用 header 文本选择 */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.chat-header h1 {
    font-size: 19px;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.status-indicator {
    font-size: 13px;
    font-weight: 400;
    opacity: 0.85;
    display: none;
    margin-top: 2px;
    align-self: flex-start;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.22);
}

.status-indicator.show {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-indicator.show::after {
    content: '';
    width: 16px;
    height: 4px;
    display: inline-block;
    background: radial-gradient(circle, rgba(255,255,255,0.95) 40%, transparent 42%) 0 50%/4px 4px repeat-x;
    animation: typingDots 0.9s linear infinite;
    opacity: 0.9;
}

@keyframes typingDots {
    from { background-position: 0 50%; }
    to { background-position: 12px 50%; }
}

.clear-chat-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-left: auto;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}

.clear-chat-btn svg {
    width: 20px;
    height: 20px;
}

.clear-chat-btn:hover {
    background: rgba(255, 59, 48, 0.8);
    transform: scale(1.1);
}

.clear-chat-btn:active {
    transform: scale(0.95);
}

/* 消息容器 */
.chat-container {
    position: fixed;
    top: var(--content-top-offset);
    bottom: 0;
    left: 0;
    right: 0;
    overflow-y: auto;
    padding: 12px;
    padding-bottom: calc(var(--input-offset) + 12px); /* 为输入区域留空间（含安全区/多行） */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    background-image: url('data:image/svg+xml;utf8,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="chat-bg" x="0" y="0" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="10" cy="10" r="2" fill="%23D1D7DB" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23chat-bg)"/></svg>');
    /* 禁用容器文本选择 */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.ad-bar {
    position: fixed;
    top: var(--header-offset);
    left: 0;
    right: 0;
    height: var(--ad-height);
    z-index: 98;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.ad-bar-inner {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
}

.ad-bar-image {
    width: 56px;
    height: 42px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(0,0,0,0.06);
    flex-shrink: 0;
}

.ad-bar-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ad-bar-content {
    flex: 1;
    min-width: 0;
}

.ad-bar-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 18px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    background: rgba(0,0,0,0.08);
    border: 1px solid rgba(0,0,0,0.08);
    opacity: 0.9;
    margin-bottom: 6px;
}

.ad-bar-title {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
}

.ad-marquee {
    display: inline-block;
    will-change: transform;
}

.ad-viewer {
    position: fixed;
    inset: 0;
    z-index: 300;
}

.ad-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.72);
}

.ad-viewer-panel {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 18px 14px;
}

.ad-viewer-close {
    position: absolute;
    top: max(12px, var(--safe-top));
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: none;
    background: rgba(0,0,0,0.45);
    color: #fff;
    font-size: 26px;
    line-height: 40px;
}

.ad-viewer-stage {
    width: 100%;
    max-width: 720px;
    height: min(70vh, 520px);
    border-radius: 14px;
    overflow: hidden;
    background: rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pan-y;
}

.ad-viewer-stage img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.ad-viewer-controls {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    user-select: none;
}

.ad-viewer-nav {
    width: 44px;
    height: 38px;
    border-radius: 999px;
    border: none;
    background: rgba(0,0,0,0.45);
    color: #fff;
    font-size: 24px;
}

.ad-viewer-indicator {
    min-width: 64px;
    text-align: center;
    font-size: 13px;
    opacity: 0.9;
}

.ad-viewer-actions {
    margin-top: 10px;
    width: min(320px, 92%);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ad-viewer-share {
    width: 100%;
    height: 40px;
    border-radius: 999px;
    border: none;
    background: rgba(255,255,255,0.92);
    color: #111;
    font-weight: 700;
}

.attachment-viewer {
    position: fixed;
    inset: 0;
    z-index: 310;
}

.attachment-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.72);
}

.attachment-viewer-panel {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 18px 14px;
}

.attachment-viewer-close {
    position: absolute;
    top: max(12px, var(--safe-top));
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: none;
    background: rgba(0,0,0,0.45);
    color: #fff;
    font-size: 26px;
    line-height: 40px;
}

.attachment-viewer-stage {
    width: 100%;
    max-width: 720px;
    height: min(75vh, 560px);
    border-radius: 14px;
    overflow: hidden;
    background: rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pan-y;
}

.attachment-viewer-stage img,
.attachment-viewer-stage iframe {
    width: 100%;
    height: 100%;
    display: block;
    border: 0;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* 禁用容器文本选择 */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* 空消息提示 */
.empty-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    opacity: 0.7;
}

.upload-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin: 12px auto;
    max-width: 360px;
    padding: 0 12px;
    animation: uploadFadeIn 0.25s ease-out;
}

.upload-progress-card {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
    backdrop-filter: blur(12px);
}

.upload-progress-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1f2937;
    flex-shrink: 0;
}

.upload-progress-spinner {
    animation: uploadSpin 1s linear infinite;
}

.upload-progress-text {
    flex: 1;
    min-width: 0;
}

.upload-progress-title {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    letter-spacing: 0.2px;
}

.upload-progress-file {
    margin-top: 2px;
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-progress-bar {
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.08);
    overflow: hidden;
}

.upload-progress-bar-fill {
    display: block;
    height: 100%;
    width: 40%;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(136, 146, 255, 0.2), rgba(136, 146, 255, 0.7), rgba(136, 146, 255, 0.2));
    animation: uploadIndeterminate 1.2s ease-in-out infinite;
}

/* 消息气泡 */
.message {
    display: flex;
    margin-bottom: 4px;
    animation: slideIn 0.3s ease-out;
    /* 禁用 message 容器文本选择 */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

@keyframes uploadFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes uploadSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes uploadIndeterminate {
    0% {
        transform: translateX(-120%);
    }
    100% {
        transform: translateX(220%);
    }
}

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
    align-items: flex-end; /* 🔥 对齐头像和消息气泡 */
}

.message-bubble {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 8px;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    /* 允许选择气泡内的文本，Select All 只会选择当前气泡 */
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

/* 🔥 客服头像样式 */
.staff-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.message.sent .message-bubble {
    background: var(--message-sent);
    border-bottom-right-radius: 2px;
}

.message.received .message-bubble {
    background: var(--message-received);
    border-bottom-left-radius: 2px;
}

.message-content {
    font-size: 14px;
    line-height: 19px;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: pre-wrap !important; /* 保留换行和空格 */
    word-wrap: break-word; /* 自动换行 */
    overflow-wrap: break-word; /* 兼容性 */
}

.message-bubble-media {
    padding: 0;
    overflow: hidden;
}

.message-content-media {
    margin-bottom: 0;
}

.message-bubble-media .image-placeholder {
    width: 100%;
    border-radius: 0;
}

.message-bubble-media img {
    width: 100%;
    height: auto;
    display: block;
}

/* 引用消息样式 */
.message-reply {
    background: rgba(37, 211, 102, 0.1);
    border-left: 3px solid var(--accent-color);
    padding: 6px 10px;
    margin-bottom: 8px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
    max-width: 300px;
}

/* 横杠复制按钮 */
.dash-copy-btn {
    display: inline-block;
    color: #075E54; /* WhatsApp dark green */
    font-weight: 600;
    cursor: pointer;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(37, 211, 102, 0.15);
    transition: all 0.2s;
    margin: 0 2px;
    border: 1px solid rgba(37, 211, 102, 0.3);
    user-select: none;
}

.dash-copy-btn:hover {
    background: rgba(37, 211, 102, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.dash-copy-btn:active {
    transform: translateY(0);
}

.dash-copy-btn.copied {
    background: #25D366;
    color: white;
    border-color: #25D366;
}

.message-reply:hover {
    background: rgba(37, 211, 102, 0.15);
}

.message-reply-author {
    font-weight: 600;
    color: var(--accent-color);
    margin-bottom: 2px;
    font-size: 12px;
}

.message-reply-content {
    color: var(--text-secondary);
    max-width: 100%;
    font-size: 12px;
    opacity: 0.8;
}

/* 当引用内容是纯文本时，截断显示 */
.message-reply-content:not(:has(div)) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 回复预览面板（输入框上方） */
.reply-preview {
    display: none;
    position: fixed;
    bottom: var(--input-offset);
    left: 0;
    right: 0;
    background: #F0F2F5;
    padding: 8px 12px;
    border-left: 3px solid var(--accent-color);
    align-items: center;
    justify-content: space-between;
    animation: slideDown 0.2s ease-out;
    box-shadow: 0 -1px 2px rgba(0,0,0,0.1);
    z-index: 10;
}

.reply-preview.active {
    display: flex;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reply-preview-content {
    flex: 1;
    overflow: hidden;
}

.reply-preview-author {
    font-weight: 600;
    font-size: 13px;
    color: var(--accent-color);
    margin-bottom: 2px;
}

.reply-preview-text {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reply-preview-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 0 8px;
    margin-left: 12px;
}

/* 长按菜单 */
/* 滑动回复图标样式（在 JS 中动态创建） */
.swipe-reply-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.06);
    color: rgba(15, 23, 42, 0.7);
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    font-size: 11px;
    color: var(--text-secondary);
}

.message-time {
    white-space: nowrap;
}

.message-status {
    display: flex;
    align-items: center;
}

.status-icon {
    width: 16px;
    height: 16px;
}

.system-message {
    align-self: center;
    max-width: 92%;
    padding: 10px 14px;
    margin: 10px auto;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    font-weight: 500;
    text-align: center;
    letter-spacing: 0.1px;
    backdrop-filter: blur(10px);
}

.blocked-notice {
    color: #5b2420;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 245, 244, 0.92));
    border: 1px solid rgba(178, 59, 46, 0.18);
    box-shadow: 0 10px 24px rgba(120, 40, 32, 0.12);
}

.blocked-notice i {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #b23b2e;
    background: rgba(178, 59, 46, 0.08);
    margin-right: 8px;
}

/* 输入区域 */
.chat-input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    /* iPhone 底部安全区会增大 padding-bottom；min-height 需要把安全区算进去，否则内容区被挤压 */
    min-height: calc(var(--input-height) + var(--safe-bottom));
    max-height: 200px; /* 最大高度限制 */
    background: #F0F2F5;
    padding: 8px;
    padding-bottom: calc(env(safe-area-inset-bottom) + 8px);
    display: flex;
    align-items: flex-end; /* 对齐底部 */
    gap: 8px;
    box-shadow: 0 -1px 2px rgba(0,0,0,0.1);
    will-change: transform;
    z-index: 200;
    transform: translateZ(0);
}

.file-upload-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: background 0.2s;
}

.file-upload-btn:hover {
    background: rgba(0,0,0,0.05);
}

.file-upload-btn:active {
    background: rgba(0,0,0,0.1);
}

#fileInput {
    display: none;
}

.message-input-wrapper {
    flex: 1;
    background: white;
    border-radius: 24px;
    padding: 8px 16px;
    display: flex;
    align-items: center; /* 垂直居中，解决输入时未对齐 */
    min-height: 44px;
    max-height: 150px; /* 最大高度 */
}

#messageInput {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    line-height: 22px; /* 更好的垂直对齐 */
    padding: 6px 0; /* 增加内边距使光标居中 */
    font-family: inherit;
    resize: none;
    max-height: 120px; /* 最大高度 */
    min-height: 22px; /* 最小高度匹配行高 */
    overflow-y: auto; /* 超过最大高度时滚动（隐藏滚动条） */
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* 允许在输入框中选择文本 */
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

/* 图片占位与过渡样式（独立定义，避免影响输入框布局） */
.image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.05);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}
.image-loading {
    background-image: linear-gradient(90deg, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.08) 50%, rgba(0,0,0,0.05) 100%);
    background-size: 200% 100%;
    animation: imageShimmer 1.2s linear infinite;
}
.image-loader {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 2px solid rgba(15, 23, 42, 0.12);
    border-top-color: rgba(15, 23, 42, 0.5);
    animation: imageSpin 0.9s linear infinite;
}
@keyframes imageShimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@keyframes imageSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.image-error {
    background: #ffebee;
    color: #c62828;
    font-size: 12px;
    text-align: center;
}
.image-retry-btn {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    background: #10b981;
    color: #fff;
    margin-top: 6px;
}
.image-blur {
    filter: blur(12px);
    opacity: 0.8;
}
.fade-in {
    transition: filter .25s ease, opacity .25s ease;
    opacity: 1;
}

#messageInput::-webkit-scrollbar {
    width: 0;
    height: 0;
}

#messageInput::-webkit-scrollbar-button,
#messageInput::-webkit-resizer,
#messageInput::-webkit-inner-spin-button,
#messageInput::-webkit-outer-spin-button {
    display: none;
    width: 0;
    height: 0;
}

.svg-icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    fill: currentColor;
}

.svg-icon-lg {
    width: 1.5em;
    height: 1.5em;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background 0.2s;
}

.send-btn:hover {
    background: var(--secondary-color);
}

.send-btn:active {
    transform: scale(0.95);
}

.message-menu {
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.96);
}

.message-menu-item {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #0f172a;
}

.message-menu-item i {
    width: 16px;
    text-align: center;
    color: rgba(15, 23, 42, 0.6);
}

.message-menu-item:hover {
    background: rgba(15, 23, 42, 0.04);
}

.message-menu-item.danger {
    color: #dc2626;
}

.message-menu-item.danger i {
    color: #dc2626;
}

.message-menu-item.is-disabled {
    opacity: 0.35;
    pointer-events: none;
}

.message-menu-divider {
    height: 1px;
    background: rgba(15, 23, 42, 0.08);
    margin: 4px 0;
}

.send-btn:disabled {
    background: #CCC;
    cursor: not-allowed;
}

/* 加载动画 */
.loading {
    display: flex;
    justify-content: center;
    padding: 20px;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 连接状态提示 */
.connection-status {
    position: fixed;
    top: var(--header-offset);
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(135deg, rgba(255, 244, 244, 0.92), rgba(255, 236, 236, 0.92));
    color: #7a3a3a;
    text-align: center;
    padding: 8px 12px 10px;
    font-size: 13px;
    border-bottom: 1px solid rgba(172, 96, 96, 0.18);
    box-shadow: 0 10px 24px rgba(80, 33, 33, 0.12);
    backdrop-filter: blur(10px);
    transform: translateY(-100%);
    transition: transform 0.3s;
    z-index: 99;
}

.connection-status.show {
    transform: translateY(0);
}

.connection-status.is-restored {
    background: linear-gradient(135deg, rgba(236, 249, 243, 0.92), rgba(230, 246, 239, 0.92));
    color: #2b6b55;
    border-bottom: 1px solid rgba(90, 158, 128, 0.22);
    box-shadow: 0 10px 24px rgba(36, 86, 68, 0.14);
}

.connection-status .loading-dots span {
    background: currentColor;
    opacity: 0.5;
}

.connection-status .reconnect-btn {
    margin-left: 0;
    padding: 5px 16px;
    background: rgba(255, 255, 255, 0.42);
    border: 1px solid rgba(122, 58, 58, 0.28);
    color: inherit;
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
    opacity: 0.8;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.connection-status .reconnect-btn .svg-icon {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.connection-status .reconnect-btn:active {
    transform: scale(0.98);
}

.connection-status .reconnect-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

.connection-status .reconnect-btn.is-spinning .svg-icon {
    animation: reconnectSpin 1s linear infinite;
}

@keyframes reconnectSpin {
    to { transform: rotate(360deg); }
}

/* 文件预览 */
.file-preview {
    margin-top: 8px;
    padding: 8px;
    background: rgba(0,0,0,0.05);
    border-radius: 4px;
}

.file-preview-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    font-size: 20px;
}

.file-info {
    flex: 1;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
}

.file-size {
    font-size: 12px;
    color: var(--text-secondary);
}

/* 图片消息 */
.message-image {
    max-width: 100%;
    border-radius: 4px;
    cursor: pointer;
}

/* 🔥 图片消息的气泡：根据图片尺寸自适应 */
.message-bubble:has(.message-image) {
    max-width: 90%; /* 增加到 90%，给图片更多空间 */
    padding: 4px; /* 减少内边距，让图片更大 */
}

/* 视频消息 */
.message-video {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    background: #000;
    outline: none;
}

.message-video::-webkit-media-controls-panel {
    background: linear-gradient(transparent, rgba(0,0,0,0.5));
}

.message-video::-webkit-media-controls-play-button,
.message-video::-webkit-media-controls-current-time-display,
.message-video::-webkit-media-controls-time-remaining-display,
.message-video::-webkit-media-controls-timeline,
.message-video::-webkit-media-controls-volume-slider,
.message-video::-webkit-media-controls-mute-button,
.message-video::-webkit-media-controls-fullscreen-button {
    filter: brightness(1.2);
}

.message.typing-message .message-bubble {
    background: rgba(255, 255, 255, 0.92);
}

.message.typing-message {
    opacity: 0;
    transform: translate3d(0, 6px, 0);
    transition: opacity 0.22s ease, transform 0.22s ease;
    will-change: opacity, transform;
}

.message.typing-message.is-visible {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}

.message.typing-message .typing-content {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap !important;
}

.typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    contain: paint;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(102, 119, 129, 0.9);
    transform: translate3d(0, 0, 0) scale(0.65);
    opacity: 0.45;
    will-change: transform, opacity;
    animation: typingPulse 1.05s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingPulse {
    0%, 80%, 100% {
        transform: translate3d(0, 0, 0) scale(0.65);
        opacity: 0.45;
    }
    40% {
        transform: translate3d(0, -2px, 0) scale(1);
        opacity: 0.95;
    }
}

/* 移动端视频优化 */
@media (max-width: 767px) {
    .message-video {
        max-width: 100%;
        max-height: 250px;
    }
}

/* 响应式 */
@media (min-width: 768px) {
    body {
        display: flex;
        justify-content: center;
        align-items: center;
        background: #D9DBD5;
    }
    
    .chat-wrapper {
        width: 100%;
        max-width: 600px;
        height: 100vh;
        max-height: 800px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        position: relative;
    }
}

/* 滚动条样式 */
.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.3);
}

/* 举报按钮 */
.report-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    color: white;
    font-size: 18px;
}

.report-btn i {
    pointer-events: none; /* 点击命中按钮本身，提升可点性 */
}

.report-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.report-btn:active {
    transform: scale(0.95);
}

/* 分享按钮 */
.share-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    color: white;
    font-size: 18px;
}

.share-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.share-btn:active {
    transform: scale(0.95);
}

/* 举报弹窗 */
.report-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.report-modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.report-modal-header {
    background: var(--primary-color);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.report-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.report-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.report-modal-close:hover {
    opacity: 0.8;
}

.report-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.report-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.report-cancel-btn,
.report-submit-btn {
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.report-cancel-btn {
    background: #f5f5f5;
    color: #666;
}

.report-cancel-btn:hover {
    background: #e0e0e0;
}

.report-submit-btn {
    background: var(--primary-color);
    color: white;
}

.report-submit-btn:hover {
    background: var(--secondary-color);
}

/* 闲置断线提示弹窗 */
.inactivity-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s;
}

.inactivity-modal {
    background: white;
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    max-width: 90%;
    width: 320px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    animation: slideUp 0.3s;
}

.inactivity-icon {
    width: 64px;
    height: 64px;
    background: #f0f4f8;
    color: #64748b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 16px;
}

.inactivity-modal h3 {
    margin: 0 0 8px;
    color: #1e293b;
    font-size: 18px;
    font-weight: 600;
}

.inactivity-modal p {
    margin: 0 0 24px;
    color: #64748b;
    font-size: 14px;
    line-height: 1.5;
}

.reconnect-btn-large {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 99px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    transition: transform 0.1s;
}

.reconnect-btn-large:active {
    transform: scale(0.98);
}

.report-submit-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}
