        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
            background: #f1f5f9;
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 12px;
        }

        .chat-container {
            max-width: 1000px;
            width: 100%;
            height: 100%;
            max-height: 920px;
            background: white;
            border-radius: 28px;
            box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.1);
            border: 1px solid #e9edf2;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            position: relative;
        }

        /* 头部样式 */
        .chat-header {
            padding: 14px 20px;
            border-bottom: 1px solid #edf2f7;
            background: white;
            display: flex;
            align-items: center;
            justify-content: space-between;
            flex-wrap: wrap;
            gap: 10px;
        }
        .header-left {
            display: flex;
            align-items: center;
            gap: 12px;
        }
        .history-btn {
            background: #f1f4f9;
            border: none;
            border-radius: 40px;
            padding: 8px 14px;
            font-size: 0.85rem;
            font-weight: 500;
            color: #1e293b;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
            transition: all 0.2s ease;
        }
        .history-btn i { font-size: 1rem; color: #2563eb; }
        .history-btn:hover {
            background: #e6edf8;
            transform: scale(0.97);
        }
        .header-title {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .header-title i { font-size: 1.5rem; color: #2563eb; }
        .header-title h1 { font-size: 1.25rem; font-weight: 600; color: #0f172a; }
        .icon-btn {
            background: transparent;
            border: 1px solid #e2e8f0;
            border-radius: 40px;
            padding: 8px 14px;
            font-size: 0.85rem;
            color: #475569;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .icon-btn:hover {
            background: #f8fafc;
            border-color: #cbd5e1;
        }

        /* 历史侧边栏 */
        .history-sidebar {
            position: absolute;
            top: 0;
            left: 0;
            width: 320px;
            max-width: 85vw;
            height: 100%;
            background: #ffffff;
            z-index: 1000;
            transform: translateX(-100%);
            transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.4, 1.1);
            box-shadow: 5px 0 25px rgba(0, 0, 0, 0.08);
            border-right: 1px solid #eef2f6;
            display: flex;
            flex-direction: column;
            border-radius: 0 20px 20px 0;
            overflow: hidden;
        }
        .history-sidebar.open {
            transform: translateX(0);
        }
        .sidebar-header {
            padding: 20px 20px 16px;
            border-bottom: 1px solid #edf2f7;
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: #fefefe;
        }
        .sidebar-header h3 {
            font-weight: 600;
            font-size: 1.2rem;
            color: #0f172a;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .close-sidebar {
            background: #f1f5f9;
            border: none;
            width: 34px;
            height: 34px;
            border-radius: 40px;
            cursor: pointer;
            font-size: 1.2rem;
        }
        .history-list {
            flex: 1;
            overflow-y: auto;
            padding: 12px 12px 20px;
            background: #fcfdff;
        }
        .history-item {
            background: white;
            border-radius: 16px;
            padding: 14px;
            margin-bottom: 10px;
            border: 1px solid #eef2f6;
            transition: all 0.15s;
            cursor: pointer;
        }
        .history-item:hover {
            background: #fafcff;
            border-color: #cbdff5;
            transform: translateX(2px);
        }
        .history-item.active {
            background: #eff6ff;
            border-left: 4px solid #2563eb;
        }
        .history-preview {
            font-size: 0.85rem;
            font-weight: 500;
            color: #1e293b;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            margin-bottom: 6px;
        }
        .history-meta {
            display: flex;
            justify-content: space-between;
            font-size: 0.7rem;
            color: #64748b;
            align-items: center;
        }
        .delete-history {
            background: transparent;
            border: none;
            color: #94a3b8;
            cursor: pointer;
            padding: 4px 8px;
            border-radius: 30px;
        }
        .delete-history:hover {
            background: #fee2e2;
            color: #dc2626;
        }
        .empty-history {
            text-align: center;
            padding: 40px 20px;
            color: #94a3b8;
            font-size: 0.85rem;
        }
        .overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.2);
            z-index: 999;
            backdrop-filter: blur(2px);
            display: none;
        }
        .overlay.active {
            display: block;
        }

        /* 聊天区域 */
        .chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 20px 20px 10px;
            background: #fcfdff;
            display: flex;
            flex-direction: column;
            gap: 18px;
        }
        .message {
            display: flex;
            gap: 12px;
            max-width: 85%;
        }
        .message.user {
            align-self: flex-end;
            flex-direction: row-reverse;
        }
        .message.assistant {
            align-self: flex-start;
        }
        .avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: #eef2ff;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #2563eb;
            font-weight: 600;
            flex-shrink: 0;
            border: 1px solid #cbd5e1;
        }
        .message.user .avatar {
            background: #2563eb;
            color: white;
        }
        .bubble {
            background: white;
            padding: 14px 18px;
            border-radius: 20px;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
            border: 1px solid #eef2f6;
            line-height: 1.6;
            color: #1e293b;
            font-size: 0.95rem;
            word-break: break-word;
        }
        .message.user .bubble {
            background: #2563eb;
            color: white;
            border: none;
        }
        .code-block-wrapper {
            margin-top: 12px;
            margin-bottom: 4px;
            border-radius: 14px;
            overflow: hidden;
            border: 1px solid #d1d5db;
            background: #1e1e2e;
        }
        .code-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 8px 16px;
            background: #2d2d3d;
            border-bottom: 1px solid #3e3e52;
        }
        .code-lang {
            font-size: 0.8rem;
            font-weight: 600;
            color: #cbd5e1;
            text-transform: uppercase;
        }
        .copy-code-btn {
            background: transparent;
            border: 1px solid #4b5563;
            color: #e2e8f0;
            padding: 4px 12px;
            border-radius: 20px;
            font-size: 0.75rem;
            cursor: pointer;
        }
        .code-body {
            padding: 16px;
            overflow-x: auto;
            background: #1e1e2e;
        }
        .code-body pre {
            margin: 0;
        }
        .inline-code {
            background: #f1f5f9;
            padding: 2px 6px;
            border-radius: 6px;
            font-family: monospace;
            font-size: 0.85em;
            color: #b45309;
        }

        /* 输入区域 — 针对移动端输入法优化 */
        .chat-input-area {
            padding: 16px 24px 20px;
            border-top: 1px solid #eef2f6;
            background: white;
            /* 确保在软键盘弹出时保持可见 */
            position: relative;
            z-index: 10;
        }
        .input-wrapper {
            display: flex;
            align-items: flex-end;
            gap: 12px;
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            border-radius: 32px;
            padding: 8px 8px 8px 20px;
            transition: all 0.1s;
        }
        .input-wrapper:focus-within {
            border-color: #2563eb;
            box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
        }
        .chat-input {
            flex: 1;
            border: none;
            background: transparent;
            padding: 12px 0;
            font-size: 0.95rem;
            resize: none;
            outline: none;
            font-family: inherit;
            max-height: 140px;
            line-height: 1.4;
        }
        .send-btn {
            background: #2563eb;
            border: none;
            color: white;
            width: 46px;
            height: 46px;
            border-radius: 40px;
            cursor: pointer;
            transition: 0.15s;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }
        .send-btn:disabled {
            opacity: 0.5;
            background: #94a3b8;
            cursor: not-allowed;
        }
        .typing-indicator {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 0;
        }
        .marker-hint {
            font-size: 0.7rem;
            color: #64748b;
            margin-top: 8px;
            margin-left: 10px;
        }

        /* 手机键盘优化以及滚动条 */
        @media (max-width: 640px) {
            .chat-container {
                border-radius: 20px;
                max-height: 95vh;
            }
            .chat-header {
                padding: 12px 16px;
            }
            .history-btn span {
                display: none;
            }
            .history-btn i {
                margin: 0;
            }
            .history-btn {
                padding: 8px 12px;
            }
            .icon-btn span {
                display: none;
            }
            .icon-btn {
                padding: 8px 12px;
            }
            .message {
                max-width: 92%;
            }
            .chat-input-area {
                padding: 12px 16px 16px;
            }
            .input-wrapper {
                padding: 4px 4px 4px 16px;
            }
            .chat-input {
                font-size: 16px;  /* 避免iOS缩放 */
                padding: 10px 0;
            }
        }

        /* 空状态占位 */
        .empty-chat {
            text-align: center;
            padding: 40px 20px;
            color: #94a3b8;
            font-size: 0.9rem;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
        }

        /* toast提示 */
        #toast {
            position: fixed;
            bottom: 30px;
            left: 50%;
            transform: translateX(-50%) translateY(80px);
            background: #1e293be6;
            backdrop-filter: blur(8px);
            color: white;
            padding: 10px 24px;
            border-radius: 40px;
            font-size: 0.85rem;
            z-index: 1100;
            transition: transform 0.2s ease;
            pointer-events: none;
            white-space: nowrap;
        }