/* ===== CSS 变量 (微信风格) ===== */
:root {
    --wechat-green: #07C160;
    --wechat-green-hover: #06AD56;
    --wechat-green-light: rgba(7, 193, 96, 0.08);

    --bg-body: #f5f5f5;
    --bg-sidebar: #e8e8e8;
    --bg-chat: #f5f5f5;
    --bg-white: #ffffff;
    --bg-input: #ffffff;

    --text-primary: #191919;
    --text-secondary: #666666;
    --text-muted: #999999;
    --text-placeholder: #b3b3b3;

    --bubble-other-bg: #ffffff;
    --bubble-other-text: #191919;
    --bubble-own-bg: #95EC69;
    --bubble-own-text: #000000;

    --border-color: #e0e0e0;
    --border-light: #ededed;
    --divider-color: #d9d9d9;

    --shadow-card: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-bubble: 0 1px 2px rgba(0,0,0,0.06);

    --sidebar-w: 300px;
    --header-h: 56px;
    --transition: 0.2s ease;
}

[data-theme="dark"] {
    --bg-body: #111111;
    --bg-sidebar: #1a1a1a;
    --bg-chat: #111111;
    --bg-white: #1e1e1e;
    --bg-input: #2a2a2a;

    --text-primary: #e0e0e0;
    --text-secondary: #999999;
    --text-muted: #666666;
    --text-placeholder: #555555;

    --bubble-other-bg: #2a2a2a;
    --bubble-other-text: #e0e0e0;
    --bubble-own-bg: #2B5E1A;
    --bubble-own-text: #e0e0e0;

    --border-color: #2a2a2a;
    --border-light: #2a2a2a;
    --divider-color: #2a2a2a;

    --shadow-card: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-bubble: none;
}

/* ===== 基础重置 ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background var(--transition), color var(--transition);
}

/* ===== 滚动条 (微信风格) ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.12);
    border-radius: 3px;
}
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
}

/* ===== 登录界面 ===== */
.login-overlay {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-body);
}
.login-card {
    width: 100%; max-width: 360px;
    background: var(--bg-white);
    border-radius: 12px;
    padding: 48px 32px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    animation: cardIn 0.4s ease;
}
@keyframes cardIn {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}
.login-icon { margin-bottom: 20px; }
.login-card h2 { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.login-subtitle { font-size: 14px; color: var(--text-secondary); margin-bottom: 28px; }
.login-input {
    width: 100%; padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px; outline: none;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color var(--transition);
}
.login-input:focus { border-color: var(--wechat-green); }
.color-picker { margin: 20px 0; text-align: left; }
.color-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; }
.color-options { display: flex; gap: 10px; flex-wrap: wrap; }
.color-dot {
    width: 30px; height: 30px; border-radius: 50%;
    cursor: pointer; border: 3px solid transparent;
    transition: transform var(--transition), border-color var(--transition);
}
.color-dot:hover { transform: scale(1.12); }
.color-dot.active { border-color: var(--wechat-green); transform: scale(1.08); }
.login-btn {
    width: 100%; padding: 12px;
    border: none; border-radius: 8px;
    background: var(--wechat-green);
    color: #fff; font-size: 16px; font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
}
.login-btn:hover { background: var(--wechat-green-hover); }
.login-btn:active { transform: scale(0.98); }

/* ===== 主布局 (微信PC双栏) ===== */
.chat-app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: 100vh; height: 100dvh;
    width: 100%;
    overflow: hidden;
}

/* ===== 左侧边栏 ===== */
.sidebar {
    display: flex; flex-direction: column;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    min-width: 0;
}

.sidebar-search {
    display: flex; align-items: center; gap: 8px;
    padding: 12px;
    flex-shrink: 0;
}
.search-box {
    flex: 1; display: flex; align-items: center;
    background: var(--bg-input);
    border-radius: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border-light);
    transition: background var(--transition);
}
.search-box:focus-within {
    background: var(--bg-white);
    border-color: var(--wechat-green);
}
.search-icon { color: var(--text-muted); flex-shrink: 0; margin-right: 6px; }
.search-input {
    flex: 1; border: none; outline: none;
    background: #fff;
    font-size: 13px; color: var(--text-primary);
}
.search-input::placeholder { color: var(--text-placeholder); }

.contact-list {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    /* 自定义滚动条（始终可见 + 立体感），方便快速翻找大量房间 */
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,.28) transparent;
}
[data-theme="dark"] .contact-list {
    scrollbar-color: rgba(255,255,255,.32) transparent;
}
.contact-list::-webkit-scrollbar { width: 8px; }
.contact-list::-webkit-scrollbar-track { background: transparent; }
.contact-list::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,.22); border-radius: 4px; border: 2px solid transparent; background-clip: content-box;
}
.contact-list::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.4); background-clip: content-box; }
[data-theme="dark"] .contact-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.28); background-clip: content-box; }
[data-theme="dark"] .contact-list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.5); background-clip: content-box; }

.contact-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
}
.contact-item:hover { background: rgba(0,0,0,0.04); }
[data-theme="dark"] .contact-item:hover { background: rgba(255,255,255,0.04); }
.contact-item.active { background: rgba(0,0,0,0.06); }
[data-theme="dark"] .contact-item.active { background: rgba(255,255,255,0.08); }

.contact-avatar {
    width: 44px; height: 44px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 18px; font-weight: 600;
    flex-shrink: 0;
}
.contact-info {
    flex: 1; min-width: 0;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--divider-color);
}
.contact-item:last-child .contact-info { border-bottom: none; }
.contact-name-row {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 4px;
}
.contact-name {
    font-size: 14px; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contact-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.contact-preview {
    font-size: 12px; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 180px;
}

/* 未读徽标 */
.contact-badge {
    position: absolute; right: 16px; top: 34px;
    background: #FA5151;
    color: #fff; font-size: 10px; font-weight: 600;
    min-width: 18px; height: 18px; line-height: 18px; text-align: center;
    border-radius: 9px; padding: 0 5px;
    display: none;
}

/* 侧边栏底部 */
.sidebar-footer {
    display: flex; justify-content: center; gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--divider-color);
    flex-shrink: 0;
}

.icon-btn-sm {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border: none; border-radius: 6px;
    background: #fff; color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.icon-btn-sm:hover { background: rgba(0,0,0,0.06); color: var(--text-primary); }
[data-theme="dark"] .icon-btn-sm:hover { background: rgba(255,255,255,0.08); }

/* ===== 右侧主面板 ===== */
.main-panel {
    display: flex; flex-direction: column;
    background: var(--bg-chat);
    min-width: 0; min-height: 0;
    position: relative;
}

/* 空状态 */
.no-chat-placeholder {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    flex: 1; gap: 16px;
    color: var(--text-muted);
    font-size: 14px;
    opacity: 0.5;
    background: var(--bg-chat);
}

/* 聊天内容 */
.chat-content {
    display: flex; flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* ===== 聊天顶部栏 ===== */
.chat-header {
    display: flex; align-items: center; justify-content: space-between;
    height: var(--header-h);
    padding: 0 20px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
    z-index: 5;
}
.chat-header-info {
    display: flex; align-items: center; gap: 10px;
}
.chat-contact-name {
    font-size: 17px; font-weight: 600;
}
.chat-header-actions {
    display: flex; align-items: center; gap: 12px;
}
.connection-status {
    display: flex; align-items: center; gap: 6px;
}
.status-dot {
    width: 7px; height: 7px; border-radius: 50%;
}
.status-connected { background: var(--wechat-green); }
.status-connecting { background: #f0ad4e; animation: pulse 1.5s infinite; }
.status-disconnected { background: #d9534f; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }
.status-text { font-size: 12px; color: var(--text-muted); }

/* ===== 消息区域 ===== */
.messages-area {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding: 16px 20px;
    scroll-behavior: smooth;
    display: flex; flex-direction: column;
    gap: 8px;
}

.loading-indicator {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; padding: 24px;
    color: var(--text-secondary); font-size: 13px;
}
.spinner {
    width: 18px; height: 18px;
    border: 2px solid var(--border-color);
    border-top-color: var(--wechat-green);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 空消息状态 */
.empty-chat {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    flex: 1; gap: 12px;
    color: var(--text-muted); font-size: 13px;
}

/* ===== 消息气泡 (微信风格) ===== */
.message-wrapper {
    display: flex; gap: 10px;
    animation: msgIn 0.25s ease;
    margin-bottom: 4px;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.message-wrapper.own { flex-direction: row-reverse; }

.message-avatar {
    width: 36px; height: 36px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 14px; font-weight: 600;
    flex-shrink: 0;
    margin-top: 4px;
}

.message-body {
    max-width: min(58%, 640px);
    display: flex; flex-direction: column;
    gap: 4px;
    position: relative;
}
.message-wrapper.own .message-body { align-items: flex-end; }

/* 消息元信息 */
.message-meta {
    display: flex; align-items: center; gap: 8px;
    padding: 0 6px;
}
.message-username { font-size: 12px; color: var(--text-muted); }
.message-time {
    font-size: 11px; color: var(--text-muted);
}

/* 文本气泡 */
.message-bubble {
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 14px; line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    position: relative;
}
.message-wrapper:not(.own) .message-bubble {
    background: var(--bubble-other-bg);
    color: var(--bubble-other-text);
    box-shadow: var(--shadow-bubble);
}
.message-wrapper:not(.own) .message-bubble::before {
    content: ''; position: absolute;
    left: -6px; top: 10px;
    border: 6px solid transparent;
    border-right-color: var(--bubble-other-bg);
    border-left: 0;
}
.message-wrapper.own .message-bubble {
    background: var(--bubble-own-bg);
    color: var(--bubble-own-text);
}
.message-wrapper.own .message-bubble::after {
    content: ''; position: absolute;
    right: -6px; top: 10px;
    border: 6px solid transparent;
    border-left-color: var(--bubble-own-bg);
    border-right: 0;
}

/* 图片消息 */
.message-image {
    display: block;
    max-width: 240px; max-height: 240px;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.15s;
    object-fit: cover;
}
.message-image:hover { transform: scale(1.03); }

/* 图片气泡 */
.message-bubble-image {
    padding: 3px !important;
    background: transparent !important;
    box-shadow: none !important;
}
.message-bubble-image::before,
.message-bubble-image::after { display: none !important; }
.message-wrapper.own .message-bubble-image,
.message-wrapper:not(.own) .message-bubble-image {
    background: transparent !important;
    box-shadow: none !important;
}

/* 文件消息 */
.message-file {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: 4px;
    text-decoration: none;
    min-width: 200px; max-width: 260px;
    transition: transform 0.15s;
    cursor: pointer;
}
.message-file:hover { transform: translateY(-1px); }
.message-wrapper:not(.own) .message-file {
    background: var(--bubble-other-bg);
    color: var(--bubble-other-text);
    box-shadow: var(--shadow-bubble);
}
.message-wrapper.own .message-file {
    background: var(--bubble-own-bg);
    color: var(--bubble-own-text);
}
.file-icon {
    width: 36px; height: 36px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    background: rgba(0,0,0,0.05);
}
[data-theme="dark"] .file-icon { background: rgba(255,255,255,0.08); }
.file-info { flex: 1; min-width: 0; }
.file-name {
    font-size: 13px; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-size { font-size: 11px; opacity: 0.7; }
.file-download-icon { flex-shrink: 0; opacity: 0.6; }

/* ===== 日期分隔 ===== */
.date-separator {
    display: flex; align-items: center; justify-content: center;
    margin: 12px 0 6px; gap: 10px;
}
.date-separator span {
    font-size: 11px; color: var(--text-muted);
    background: rgba(0,0,0,0.04); padding: 3px 10px; border-radius: 3px;
}
[data-theme="dark"] .date-separator span {
    background: rgba(255,255,255,0.06);
}

/* ===== 输入区域 ===== */
.chat-input-area {
    flex-shrink: 0;
    background: var(--bg-white);
    border-top: 1px solid var(--border-light);
    position: relative;
}

/* 粘贴预览 */
.paste-preview {
    padding: 10px 16px 0;
    border-top: 1px solid var(--border-light);
}
.preview-items {
    display: flex; gap: 8px; flex-wrap: wrap;
}
.preview-item {
    position: relative;
    width: 72px; height: 72px;
    border-radius: 4px; overflow: hidden;
    border: 1px solid var(--border-light);
    flex-shrink: 0;
}
.preview-item img {
    width: 100%; height: 100%; object-fit: cover;
}
.preview-item .preview-file {
    width: 100%; height: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; padding: 8px;
    background: var(--bg-input);
    font-size: 10px; color: var(--text-secondary);
    text-align: center;
    overflow: hidden;
}
.preview-file .pf-name {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    width: 100%;
}
.preview-remove {
    position: absolute; top: 2px; right: 2px;
    width: 18px; height: 18px;
    border: none; border-radius: 50%;
    background: rgba(0,0,0,0.5); color: #fff;
    font-size: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.15s;
    line-height: 1;
}
.preview-item:hover .preview-remove { opacity: 1; }

/* 上传进度条 */
.upload-progress-mini {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px;
    font-size: 12px; color: var(--text-secondary);
}
.upload-progress-mini .upload-progress-track {
    flex: 1; height: 3px; background: var(--border-light); border-radius: 2px; overflow: hidden;
}
.upload-progress-mini .upload-progress-fill {
    height: 100%; background: var(--wechat-green);
    border-radius: 2px; transition: width 0.2s; width: 0%;
}
.upload-progress-text { flex-shrink: 0; white-space: nowrap; }

/* 工具栏 */
.input-toolbar {
    display: flex; gap: 2px; padding: 6px 12px 0;
}
.toolbar-btn {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border: none; border-radius: 4px;
    background: #fff; color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.toolbar-btn:hover {
    background: var(--wechat-green-light);
    color: var(--wechat-green);
}

/* 输入栏 */
.input-bar {
    display: flex; align-items: flex-end; gap: 10px;
    padding: 8px 16px 12px;
}
.input-wrapper { flex: 1; min-width: 0; }
.message-input {
    width: 100%; min-height: 60px; max-height: 120px;
    padding: 10px 12px;
    border: none; outline: none; resize: none;
    font-size: 14px; line-height: 1.5;
    font-family: inherit;
    background: #fff;
    color: var(--text-primary);
}
.message-input::placeholder { color: var(--text-placeholder); }

.send-btn {
    padding: 7px 20px;
    border: none; border-radius: 4px;
    background: var(--wechat-green);
    color: #fff; font-size: 14px; font-weight: 500;
    cursor: pointer; white-space: nowrap;
    transition: background var(--transition), transform var(--transition);
    flex-shrink: 0;
}
.send-btn:hover { background: var(--wechat-green-hover); }
.send-btn:active { transform: scale(0.97); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; background: var(--text-muted); }

/* 拖拽提示 */
.drop-zone-hint {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px;
    background: rgba(7, 193, 96, 0.06);
    backdrop-filter: blur(4px);
    color: var(--wechat-green); font-size: 14px; font-weight: 500;
    z-index: 20; pointer-events: none;
}

/* ===== 图片灯箱 ===== */
.lightbox {
    position: fixed; inset: 0; z-index: 2000;
    display: flex; align-items: center; justify-content: center;
}
.lightbox-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.88);
}
.lightbox-img {
    position: relative; max-width: 90vw; max-height: 85vh;
    border-radius: 4px;
    animation: lbIn 0.2s ease;
}
@keyframes lbIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.lightbox-close, .lightbox-download {
    position: absolute; top: 20px;
    width: 40px; height: 40px; border: none; border-radius: 50%;
    background: rgba(255,255,255,0.12);
    color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--transition);
}
.lightbox-close { right: 20px; }
.lightbox-download { right: 70px; text-decoration: none; }
.lightbox-close:hover, .lightbox-download:hover {
    background: rgba(255,255,255,0.25);
}

/* ===== Toast ===== */
.toast-container {
    position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
    z-index: 3000; display: flex; flex-direction: column; gap: 6px;
    pointer-events: none;
}
.toast {
    padding: 10px 18px; border-radius: 6px;
    font-size: 13px; color: #fff;
    animation: toastIn 0.25s ease;
    text-align: center; max-width: 90vw;
}
.toast.success { background: rgba(7, 193, 96, 0.9); }
.toast.error { background: rgba(250, 81, 81, 0.9); }
.toast.info { background: rgba(0,0,0,0.75); }
[data-theme="dark"] .toast.info { background: rgba(255,255,255,0.15); }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}
.toast.fade-out { animation: toastOut 0.25s ease forwards; }
@keyframes toastOut {
    to { opacity: 0; transform: translateY(-12px); }
}

/* ===== 移动端汉堡菜单按钮（默认隐藏） ===== */
.mobile-menu-btn {
    display: none;
    align-items: center; justify-content: center;
    width: 40px; height: 40px; border: none; border-radius: 6px;
    background: #fff; color: var(--text-secondary);
    cursor: pointer; flex-shrink: 0;
    margin-right: 4px; margin-left: -8px;
}
.mobile-menu-btn:active { background: rgba(0,0,0,0.06); }

/* ===== 侧边栏遮罩（默认隐藏） ===== */
.sidebar-backdrop {
    display: none;
}

/* ===== 移动端侧边栏头部（默认隐藏） ===== */
.sidebar-mobile-header {
    display: none;
}

/* ===== 响应式 (移动端) ===== */
@media (max-width: 768px) {
    /* --- 全局 --- */
    .toast-container { top: 20px; max-width: 90vw; }

    /* --- 登录页 --- */
    .login-overlay { padding: 16px; align-items: flex-start; padding-top: 15vh; }
    .login-card {
        max-width: 100%; padding: 36px 20px;
        border-radius: 12px;
    }
    .login-card h2 { font-size: 20px; }
    .login-input { font-size: 16px; padding: 14px 16px; }
    .color-dot { width: 36px; height: 36px; }

    /* --- 主布局：单栏 --- */
    .chat-app {
        grid-template-columns: 1fr;
        position: relative;
    }

    /* --- 侧边栏：全屏浮层 + 左滑入 --- */
    .sidebar {
        display: flex; flex-direction: column;
        position: fixed; top: 0; left: 0; bottom: 0;
        width: 300px; max-width: 85vw;
        z-index: 200;
        background: var(--bg-sidebar);
        border-right: 1px solid var(--border-color);
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
        box-shadow: none;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    }

    /* 侧边栏遮罩 */
    .sidebar-backdrop {
        display: block;
        position: fixed; inset: 0; z-index: 199;
        background: rgba(0,0,0,0.45);
        opacity: 0; pointer-events: none;
        transition: opacity 0.28s ease;
    }
    .sidebar-backdrop.active {
        opacity: 1; pointer-events: auto;
    }

    /* 移动端侧边栏头部 */
    .sidebar-mobile-header {
        display: flex; align-items: center; justify-content: space-between;
        padding: 8px 12px;
        border-bottom: 1px solid var(--divider-color);
        flex-shrink: 0;
    }
    .sidebar-mobile-title { font-size: 16px; font-weight: 600; }

    /* 汉堡菜单按钮显示 */
    .mobile-menu-btn { display: flex; }

    /* --- 右侧主面板 --- */
    .main-panel { width: 100%; }

    /* --- 聊天头部 --- */
    .chat-header {
        padding: 0 12px;
        height: 52px;
    }
    .chat-header-info { margin-left: 0; }
    .chat-contact-name { font-size: 16px; }

    /* --- 消息区域 --- */
    .messages-area { padding: 10px 12px 8px; gap: 6px; }
    .message-wrapper { gap: 8px; }
    .message-avatar { width: 32px; height: 32px; font-size: 13px; }
    .message-body { max-width: 78%; }
    .message-bubble { padding: 9px 12px; font-size: 15px; line-height: 1.45; }
    .message-username { font-size: 11px; }
    .message-time { font-size: 10px; opacity: 1; }
    .message-image { max-width: 180px; max-height: 180px; }

    /* 去掉气泡三角箭头（移动端不协调） */
    .message-wrapper:not(.own) .message-bubble::before,
    .message-wrapper.own .message-bubble::after { display: none; }

    /* --- 输入区域 --- */
    .chat-input-area { padding-bottom: env(safe-area-inset-bottom, 0px); }
    .input-toolbar { padding: 4px 8px 0; }
    .toolbar-btn { width: 36px; height: 36px; }
    .input-bar { padding: 6px 8px 10px; gap: 8px; }
    .message-input {
        min-height: 44px; max-height: 100px;
        font-size: 16px; padding: 10px 12px;
    }
    .send-btn { padding: 8px 16px; font-size: 15px; border-radius: 6px; }

    /* 粘贴预览 */
    .paste-preview { padding: 8px 10px 0; }
    .preview-item { width: 60px; height: 60px; border-radius: 6px; }
    .preview-remove { opacity: 1; width: 20px; height: 20px; font-size: 14px; }

    /* --- 联系人列表 --- */
    .contact-item { padding: 10px 12px; gap: 10px; }
    .contact-avatar { width: 40px; height: 40px; border-radius: 4px; font-size: 16px; }
    .contact-name { font-size: 15px; }
    .contact-preview { max-width: none; font-size: 13px; }
    .contact-badge { right: 12px; top: 30px; }

    /* --- 拖拽提示 --- */
    .drop-zone-hint { font-size: 15px; }

    /* --- 灯箱 --- */
    .lightbox-img { max-width: 95vw; max-height: 80vh; }
    .lightbox-close, .lightbox-download { top: 12px; width: 36px; height: 36px; }
    .lightbox-close { right: 12px; }
    .lightbox-download { right: 54px; }
}

/* ===== 滚动到底部箭头 ===== */
.scroll-to-bottom {
    position: fixed;
    right: 32px;
    bottom: 96px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(7,193,96,0.9);
    color: #fff;
    border: none;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .2s, transform .2s;
}
.scroll-to-bottom:hover {
    background: #07C160;
    transform: scale(1.1);
}
.scroll-to-bottom.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

/* ===== 滚动到底部箭头（始终可见测试版） ===== */
.scroll-to-bottom-v2 {
    position: fixed !important;
    right: 24px !important;
    bottom: 100px !important;
    width: 48px !important;
    height: 48px !important;
    border-radius: 50% !important;
    background: #07C160 !important;
    color: #fff !important;
    border: 2px solid #fff !important;
    font-size: 22px !important;
    cursor: pointer !important;
    box-shadow: 0 2px 16px rgba(0,0,0,0.25) !important;
    z-index: 9999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* ===== 出单确认表单 (order_form) ===== */
.message-bubble.order-form-bubble {
    width: 100%;
    max-width: 560px;
    box-sizing: border-box;
    padding: 8px 14px 10px;
    background: #fff;
    border: 1px solid #e5e6eb;
}
.of-header {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    padding-bottom: 6px;
    margin-bottom: 4px;
    border-bottom: 1px solid #e5e7eb;
}
.of-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    line-height: 1.6;
    margin: 4px 0 8px;
    margin: 4px 0 8px;
    font-size: 13px;
    color: #191919;
    margin: 4px 0 8px;
}
.of-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
}
.of-label {
    color: #191919;
    margin-right: 4px;
    white-space: nowrap;
}
.of-input {
    flex: 1;
    min-width: 80px;
    padding: 2px 6px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    color: #191919;
    background: #fff;
    outline: none;
    box-sizing: border-box;
    min-width: 0;
    transition: border-color .15s, box-shadow .15s;
}
.of-input:hover {
    border-color: #07C160;
}
.of-input:focus {
    border-color: #07C160;
    box-shadow: 0 0 0 2px rgba(7,193,96,.15);
}
.of-input:focus {
    border-color: #07C160;
    outline: none;
}
.of-actions {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}
.of-btn {
    background: #07C160;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}
.of-btn:active { opacity: 0.85; }
.of-cancel-btn {
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 7px 16px;
    font-size: 13px;
    cursor: pointer;
    width: 100%;
}
.of-cancel-btn:active { opacity: 0.85; }
.of-hint {
    font-size: 12px;
    color: #22c55e;
    text-align: center;
}


/* ===== 移动端适配 ===== */
@media (max-width: 640px) {
    .message-bubble.order-form-bubble {
        padding: 8px 10px;
        width: 100%;
        max-width: 100%;
    }
    .of-row {
        flex-wrap: wrap;
    }
    .of-label {
        flex: 0 0 auto;
        min-width: 0;
        margin-right: 4px;
    }
    .of-input {
        flex: 1 1 50%;
        min-width: 60px;
        padding: 3px 6px;
        font-size: 12px;
    }
    .of-header {
        font-size: 12px;
        padding-bottom: 4px;
        margin-bottom: 2px;
    }
}