* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}
html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #f0f2f5;
}
body {
    display: flex;
    justify-content: center;
    align-items: center;
}
#app {
    width: 100%;
    max-width: 1000px;
    height: 100%;
    max-height: 100dvh;          /* 动态视口高度，避免地址栏遮挡 */
    background: #fff;
    border-radius: 0;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
@media (min-width: 768px) {
    body { padding: 20px; }
    #app { border-radius: 24px; height: 700px; max-height: 700px; }
}

/* 登录样式 */
.auth-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #f5f7fa;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: white;
    border-radius: 28px;
    padding: 28px 22px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.05);
    margin: auto;               /* 确保垂直居中 */
}
.auth-header h2 { font-size: 28px; font-weight: 650; color: #1e293b; }
.auth-header p { color: #64748b; margin-top: 6px; }
.input-group { margin-bottom: 18px; }
.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    margin-bottom: 6px;
}
.input-group input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 16px;
    font-size: 16px;            /* 防止移动端自动缩放 */
    outline: none;
    transition: border 0.2s;
    background: #fafbfc;
}
.input-group input:focus {
    border-color: #3b82f6;
    background: white;
}
.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 40px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.15s;
    background: #eef2ff;
    color: #2563eb;
}
.btn-primary {
    background: #2563eb;
    color: white;
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.2);
}
.btn-primary:hover { background: #1d4ed8; }
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.small-btn {
    padding: 8px 14px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 40px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.small-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #e2e8f0;
    color: #94a3b8;
}
.link-text {
    color: #3b82f6;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
}
.auth-footer {
    text-align: center;
    margin-top: 16px;
    color: #64748b;
    font-size: 14px;
}
.error-message { color: #dc2626; font-size: 13px; margin-top: 4px; }
.flex-row { display: flex; gap: 8px; }
.hidden { display: none !important; }
.register-panel { display: none; }

/* 配置折叠 */
.server-config-wrapper { margin-top: 16px; }
.config-toggle-btn {
    width: 100%;
    padding: 10px 0;
    background: transparent;
    border: 1px dashed #cbd5e1;
    border-radius: 40px;
    color: #475569;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s;
}
.config-toggle-btn:hover { background: #f8fafc; }
.toggle-arrow { font-size: 12px; transition: transform 0.2s; }
.config-toggle-btn.expanded .toggle-arrow { transform: rotate(180deg); }
.server-config { margin-top: 12px; }
.config-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.config-row input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 40px;
    font-size: 16px;
    background: #fafbfc;
}

/* 聊天界面 */
.chat-container {
    display: flex;
    flex: 1;
    height: 100%;
    background: #f5f5f5;
    position: relative;
    overflow: hidden;
}
.chat-sidebar {
    width: 280px;
    background: #fafbfc;
    border-right: 1px solid #e9eef2;
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    transition: transform 0.25s ease;
    z-index: 20;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
@media (max-width: 767px) {
    .chat-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        box-shadow: 4px 0 12px rgba(0,0,0,0.05);
        transform: translateX(-100%);
    }
    .chat-sidebar.show-sidebar { transform: translateX(0); }
    .sidebar-overlay {
        position: absolute;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.3);
        z-index: 15;
        display: none;
    }
    .sidebar-overlay.show { display: block; }
}

/* 用户信息卡片 */
.user-info-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 20px;
    color: white;
}
.user-info-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.user-avatar-large {
    width: 50px;
    height: 50px;
    border-radius: 50px;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 600;
    border: 2px solid rgba(255,255,255,0.5);
    flex-shrink: 0;
}
.user-name-large {
    font-size: 18px;
    font-weight: 650;
    word-break: break-word;
}
.user-group-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 6px;
    background: rgba(255,255,255,0.2);
}
.user-reg-time {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 8px;
    word-break: break-all;
}

/* 身份组颜色 */
.group-admin { background: #f59e0b; color: white; }
.group-big-admin { background: #ef4444; color: white; }
.group-user { background: #3b82f6; color: white; }
.group-bot { background: #8b5cf6; color: white; }

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    min-width: 0;
    position: relative;
    overflow: hidden;
    height: 100%;
}
.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid #edf2f7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fdfdfd;
    flex-shrink: 0;
}
.chat-title-section {
    display: flex;
    align-items: center;
    gap: 12px;
}
.menu-icon {
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 20px;
    display: none;
    user-select: none;
}
@media (max-width: 767px) { .menu-icon { display: block; } }
.chat-title {
    font-weight: 650;
    font-size: 18px;
    color: #0f1825;
}
.online-badge {
    background: #e6f7e6;
    color: #2e7d32;
    padding: 4px 12px;
    border-radius: 40px;
    font-size: 13px;
    white-space: nowrap;
}
.messages-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f9fbfd;
    -webkit-overflow-scrolling: touch;
}
.message-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.message-row.self { flex-direction: row-reverse; }
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
    font-size: 16px;
}
.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 75%;
}
.msg-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    margin-left: 4px;
    flex-wrap: wrap;
}
.self .msg-header {
    flex-direction: row-reverse;
    margin-right: 4px;
    margin-left: 0;
}
.msg-sender {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}
.msg-group {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
}
.message-bubble {
    background: white;
    padding: 10px 14px;
    border-radius: 18px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    border: 1px solid #edf2f7;
    word-break: break-word;
}
.self .message-bubble {
    background: #dbeafe;
    border-color: #bbd6f5;
}
.msg-content {
    line-height: 1.5;
    color: #1e293b;
    font-size: 15px;
    white-space: pre-wrap;
}
.msg-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    margin-left: 8px;
    cursor: default;
}
.self .msg-time {
    text-align: right;
    margin-right: 8px;
    margin-left: 0;
}

.system-msg {
    text-align: center;
    color: #64748b;
    font-size: 13px;
    margin: 8px 0;
    white-space: pre-wrap;
}
.loading-tip {
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
    padding: 8px;
}
.input-area {
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    background: white;
    flex-shrink: 0;
    /* 保证键盘弹起时不被遮挡 */
    position: relative;
    z-index: 5;
}
.input-area textarea {
    flex: 1;
    padding: 12px 18px;
    border: 1.5px solid #e2e8f0;
    border-radius: 24px;
    outline: none;
    font-size: 16px;
    background: #f9fafb;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    font-family: inherit;
}
.input-area textarea:focus { border-color: #3b82f6; background: white; }
.input-area button {
    padding: 0 20px;
    border-radius: 48px;
    border: none;
    background: #2563eb;
    color: white;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    white-space: nowrap;
    align-self: flex-end;
    height: 48px;
    flex-shrink: 0;
}
.input-area button:active { background: #1d4ed8; }

.scroll-to-bottom {
    position: absolute;
    bottom: 80px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: #ffffff;
    border-radius: 44px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #e2e8f0;
    z-index: 10;
}
.scroll-to-bottom:hover { background: #f8fafc; }
.scroll-to-bottom .arrow-down { font-size: 20px; color: #64748b; }
.scroll-to-bottom .unread-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid white;
}

.sidebar-section-title {
    font-weight: 600;
    margin: 16px 0 8px 0;
    color: #475569;
    font-size: 13px;
}
.user-list {
    list-style: none;
}
.user-item {
    padding: 10px 12px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #1e293b;
    font-size: 15px;
}
.online-dot {
    width: 10px;
    height: 10px;
    border-radius: 10px;
    background: #22c55e;
    flex-shrink: 0;
}
.logout-btn {
    margin-top: auto;
    background: none;
    border: 1px solid #ddd;
    padding: 12px;
    border-radius: 40px;
    cursor: pointer;
    font-size: 15px;
    color: #475569;
    transition: all 0.2s;
}
.logout-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}
/* 颜色预览块 */
.color-preview {
    display: inline-block;
    width: 1em;
    height: 1em;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
    vertical-align: middle;
    margin: 0 2px 0 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* 机器人列表 */
.bot-list {
    margin-bottom: 8px;
    max-height: 150px;
    overflow-y: auto;
}

.bot-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 12px;
    font-size: 14px;
    color: #1e293b;
}

.bot-item:hover {
    background: #f1f5f9;
}

.bot-icon {
    font-size: 16px;
}

.bot-name {
    flex: 1;
}

.bot-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.bot-btn {
    flex: 1;
    padding: 8px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 30px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.bot-btn:hover {
    background: #e2e8f0;
}

.group-tourist {
    background: #94a3b8;
    color: white;
}

/* 访客登录按钮 */
.guest-btn {
    margin-top: 10px;
    background: #f1f5f9;
    color: #475569;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.guest-btn:hover {
    background: #e2e8f0;
}

/* 输入区域按钮 */
.input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    background: white;
    flex-shrink: 0;
}

.input-btn {
    width: 48px;
    height: 48px;
    border-radius: 24px;
    border: 1.5px solid #e2e8f0;
    background: #f9fafb;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.input-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.send-btn {
    padding: 0 24px;
    height: 48px;
    border-radius: 24px;
    border: none;
    background: #2563eb;
    color: white;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.2s;
}

.send-btn:hover {
    background: #1d4ed8;
}

/* 图片预览区域 */
.image-preview-area {
    padding: 8px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.image-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
    color: #475569;
}

.clear-preview-btn {
    padding: 4px 12px;
    border: none;
    background: #fee2e2;
    color: #dc2626;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
}

.image-preview-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.image-preview-item {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid #e2e8f0;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 10px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* 消息中的图片 */
.message-images {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.message-image {
    width: 100%;
    max-width: 250px;
    border-radius: 12px;
    cursor: pointer;
    border: 1px solid #e2e8f0;
}

.admin-context-menu {
    position: fixed;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 140px;
    overflow: hidden;
}

.context-menu-item {
    padding: 12px 16px;
    font-size: 14px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}

.context-menu-item:last-child {
    border-bottom: none;
}

.context-menu-item:hover {
    background: #f8fafc;
}

.context-menu-item:active {
    background: #e2e8f0;
}

.avatar-clickable {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.avatar-clickable:hover {
    opacity: 0.9;
}

.settings-btn {
    width: 100%;
    padding: 10px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 30px;
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 10px;
    transition: all 0.2s;
}
.settings-btn:hover { background: #e2e8f0; }

.settings-panel {
    background: white;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #e2e8f0;
}
.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 600;
}
.close-settings-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #94a3b8;
}
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

/* 开关 */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.switch input { display: none; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #cbd5e1;
    border-radius: 24px;
    transition: 0.3s;
}
.slider:before {
    content: "";
    position: absolute;
    height: 18px; width: 18px;
    left: 3px; bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}
input:checked + .slider { background: #2563eb; }
input:checked + .slider:before { transform: translateX(20px); }

.two-factor-info { margin-top: 12px; }
.two-factor-info input {
    width: 100%;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    margin-top: 8px;
}
.verify-btn {
    width: 100%;
    padding: 10px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 20px;
    margin-top: 8px;
    cursor: pointer;
}
#qrCodeContainer { text-align: center; margin: 10px 0; }
#qrCodeContainer img { max-width: 200px; }


/* 隐私/关于/开放平台链接 */
.auth-links {
    text-align: center;
    margin-top: 14px;
    font-size: 12px;
}

.auth-link {
    color: #94a3b8;
    text-decoration: none;
    transition: color 0.2s;
}

.auth-link:hover {
    color: #3b82f6;
    text-decoration: underline;
}

.auth-link-divider {
    color: #cbd5e1;
    margin: 0 8px;
}

/* 机器人建议列表 */
.bot-suggestions {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
    max-height: 200px;
    overflow-y: auto;
    z-index: 20;
    margin-bottom: 4px;
}

.bot-suggestion-item {
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}

.bot-suggestion-item:last-child {
    border-bottom: none;
}

.bot-suggestion-item:hover {
    background: #f8fafc;
}

.bot-suggestion-item:active {
    background: #e2e8f0;
}