:root {
    /* 颜色系统 - 豆包风格 */
    --primary: #3b82f6; /* 蓝色主色调 */
    --primary-hover: #2563eb;
    --primary-bg: #eff6ff;
    
    /* 侧边栏 */
    --bg-sidebar: #f9f9fb; /* 浅色侧边栏 */
    --sidebar-text: #334155;
    --sidebar-hover: #e2e8f0;
    
    /* 主体背景 */
    --bg-body: #ffffff;
    --bg-surface: #ffffff;
    
    /* 边框 */
    --border-color: #f1f5f9;
    
    /* 文字颜色 */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-inverse: #ffffff;

    /* 尺寸与间距 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

/* 布局 */
.app-container {
    display: flex;
    height: 100%;
}

/* 侧边栏 - 浅色风格 */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 16px;
    /* border-bottom: 1px solid var(--border-color); */ /* 移除分割线，更干净 */
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 0 4px;
}

.logo-icon-wrapper {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.2);
}

.app-brand-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

/* 新建对话按钮 - 蓝色胶囊样式 */
.new-chat-btn {
    width: 100%;
    padding: 10px;
    background: #eef2ff; /* 浅蓝背景 */
    color: var(--primary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    font-size: 14px;
}

.new-chat-btn:hover {
    background: #e0e7ff;
}

/* 导航/历史记录 */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.nav-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 12px;
    padding-left: 10px;
    font-weight: 600;
}

.history-list {
    display: flex;
    flex-direction: column;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
    font-size: 14px;
    position: relative; /* 为定位删除按钮做准备 */
}

.history-item:hover, .history-item.active {
    background-color: #eef2ff; /* 激活态浅蓝背景 */
    color: var(--primary);
}

.history-item .text {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1; /* 占据剩余空间 */
    margin-right: 24px; /* 为删除按钮留出空间 */
}

/* 删除图标默认隐藏，hover时显示 */
.delete-icon {
    display: none;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: 50%;
    color: #94a3b8;
    font-size: 16px;
    z-index: 2; /* 确保在最上层 */
}

.history-item:hover .delete-icon {
    display: block;
}

.delete-icon:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: #ef4444; /* 红色 */
}

/* 侧边栏底部 */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.profile-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.profile-btn:hover {
    background-color: var(--sidebar-hover);
}

/* 主内容区 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-body);
}

/* 顶部标题栏 */
.mobile-header {
    height: 60px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    z-index: 10;
}

.chat-window-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 对话区域 */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0; /* 上下padding，中间留白 */
    scroll-behavior: smooth;
}

.chat-history {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px 40px 20px;
}

/* 消息气泡 */
.message {
    margin-bottom: 24px;
    display: flex;
    gap: 16px;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.message.user {
    flex-direction: row-reverse;
}

/* 头像 */
.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    border: 1px solid #e2e8f0;
}

.message.user .message-avatar {
    background: #dbeafe; /* 用户头像浅蓝 */
    color: var(--primary);
    border: none;
}

/* 消息内容容器 */
.message-content {
    max-width: 85%;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
}

/* 用户消息气泡 */
.message.user .message-content {
    background: #f3f4f6; /* 浅灰背景 */
    color: #1f2937; /* 深灰字 */
    padding: 12px 16px;
    border-radius: 12px 12px 0 12px; /* 圆角处理 */
}

/* AI消息 - 无气泡背景，纯文本风格 */
.message.ai .message-content {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

/* 思考过程样式 - 仿卡片风格 */
.thinking-container {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%; /* 确保占满宽度以便子元素控制 */
}

.thinking-header {
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 13px;
    color: #64748b;
    transition: all 0.2s;
    gap: 8px;
}

.thinking-header:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
}

/* 内容区域 - 展开时显示在下方 */
.thinking-content {
    margin-top: 8px;
    padding: 12px 16px;
    background-color: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    font-size: 14px;
    color: #475569;
    line-height: 1.6;
    display: none;
    width: 100%;
}

/* 只有当容器展开且有内容时才显示 */
.thinking-container.active .thinking-content.has-content {
    display: block;
}

/* 思考加载动画 */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.thinking-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 折叠箭头 */
.thinking-toggle-icon {
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.2s;
    opacity: 0.6;
}

.thinking-container.active .thinking-toggle-icon {
    transform: rotate(180deg);
}

/* 思考完成状态 */
.thinking-container.finished .thinking-header {
    background-color: #f0fdf4; /* 浅绿背景 */
    border-color: #dcfce7;
    color: #166534;
}

.thinking-container.finished .thinking-toggle-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23166534' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* 回答区域样式 */
.answer-content {
    font-size: 15px;
    line-height: 1.7;
    color: #1e293b;
    /* AI回答不需要额外背景 */
}

/* 输入区域 - 悬浮卡片风格 */
.input-area {
    padding: 20px;
    background: transparent; /* 背景透明，让body颜色透出来 */
    position: relative;
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
}

.input-wrapper {
    position: relative;
    border: 1px solid #e2e8f0;
    border-radius: 16px; /* 更大的圆角 */
    background: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: all 0.2s;
    padding: 8px; /* 内边距 */
}

.input-wrapper:focus-within {
    border-color: #bfdbfe;
    box-shadow: 0 4px 12px -2px rgba(59, 130, 246, 0.15);
}

#user-input {
    width: 100%;
    border: none;
    padding: 10px 12px;
    font-size: 15px;
    resize: none;
    outline: none;
    max-height: 200px;
    font-family: inherit;
    background: transparent;
    min-height: 48px; /* 增加高度 */
}

/* 底部工具栏 (模拟) */
.input-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    margin-top: 4px;
}

.tool-left {
    display: flex;
    gap: 8px;
}

.tool-btn {
    padding: 6px;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.tool-btn:hover {
    background: #f1f5f9;
    color: #334155;
}

.deep-think-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #eff6ff;
    color: var(--primary);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}

/* 发送按钮 */
.send-btn {
    background: #e2e8f0; /* 默认灰色，输入时变色 */
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%; /* 圆形按钮 */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn.active {
    background: var(--primary);
}

.send-btn:hover.active {
    background: var(--primary-hover);
}

/* 底部提示文字 */
.footer-text {
    text-align: center;
    font-size: 12px;
    color: #cbd5e1;
    margin-top: 8px;
}

/* 欢迎页 */
.welcome-screen {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.welcome-content {
    max-width: 800px;
    width: 100%;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.welcome-content h2 {
    font-size: 24px;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-weight: 600;
}

.scenario-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 强制3列 */
    gap: 16px;
    padding: 0 20px;
    margin-top: 40px;
}

.scenario-card {
    background: #f8fafc; /* 浅灰卡片 */
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.scenario-card:hover {
    background: white;
    border-color: #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .menu-btn {
        display: block; /* 移动端显示菜单按钮 */
    }

    .scenario-grid {
        grid-template-columns: 1fr;
    }
    
    .input-area {
        padding: 12px;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 100;
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }
}
