:root {
    --bg-color: #f5f7fa;
    --text-color: #0f172a;
    --card-bg: white;
    --input-bg: white;
    --border-color: #e1e4e8;
    --primary-color: #0284c7;
    --ai-bubble-bg: rgba(2, 132, 199, 0.1);
}

html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100%;
    width: 100%;
}

@media (max-width: 768px) {
    .container {
        width: 100%;
        padding: 0 5px;
    }
    .header h1 {
        font-size: 20px;
    }
    .toolbar {
        padding: 8px;
        margin: 8px;
    }
    .toolbar-btn {
        padding: 6px 10px;
        font-size: 13px;
        margin: 0 2px;
    }
    .chat-display {
        padding: 10px;
        margin: 0 8px 8px 8px;
    }
    .message-bubble {
        max-width: 90%;
      padding: 1px 14px;
    
    }
    .input-area .button-group {
        flex-direction: column;
        align-items: stretch;
    }
    .nav-buttons {
        display: flex;
        justify-content: space-between;
        margin-bottom: 8px;
    }
    .send-btn, .clear-btn {
        width: 100%;
        padding: 10px;
    }
}

.dark-mode {
    --bg-color: #000000;
    --text-color: #ffffff;
    --card-bg: #121212;
    --input-bg: #1e1e1e;
    --border-color: #333333;
    --primary-color: #3b82f6;
    --ai-bubble-bg: rgba(59, 130, 246, 0.2);
}

.container {
    width: 100vw;
    height: 100vh;
    padding: 0;
    margin: 0;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
      transition: all 0.2s ease;
    box-sizing: border-box;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    color: #000000;
    margin-bottom: 5px;
}

.header h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.header-buttons {
    display: flex;
    gap: 10px;
}

.header-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 6px;
    font-size: 13px;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    transition: all 0.2s ease;
}

.header-btn:hover {
    background-color: #0369a1;
    transform: translateY(-1px);
}

.header-btn:active {
    transform: translateY(1px);
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}



.chat-display {
    flex-grow: 1;
    background-color: transparent;
    margin: 0 15px;
    padding: 15px;
    overflow-y: auto;
    overflow-x: hidden;
    font-size: 15px;
    line-height: 1.6;
    width: calc(100% - 30px);
    box-sizing: border-box;
    max-height: calc(100vh - 120px);
}

.chat-display {
    flex-grow: 1;
    background-color: var(--card-bg);
    border-radius: 12px;
    margin: 0 15px 15px 15px;
    padding: 15px;
    overflow-y: auto;
    overflow-x: hidden;
    font-size: 15px;
    line-height: 1.6;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    width: calc(100% - 30px);
    box-sizing: border-box;
    max-height: calc(100vh - 180px);
}

/* 消息容器样式 */
.message-container {
    margin: 3px 0;
    padding: 0;
    overflow-wrap: break-word;
    min-height: auto;
    box-sizing: border-box;
    max-width: 100%;
}

.user-message-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    position: relative;
    padding-bottom: 0;
}

.ai-message-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    padding-bottom: 0;
}

.message-sender {
    font-weight: bold;
    margin-bottom: 0;
    font-size: 14px;
    color: var(--text-color);
}

.user-message-container .message-sender {
    display: none;
}

.message-bubble {
    display: inline-block; /* 使元素按内容宽度显示 */
    vertical-align: top; /* 消除基线对齐导致的额外空间 */
    padding: 1px 14px; /* 内边距：上下1px优化视觉对齐，左右14px控制宽度 */
    border-radius: 12px; /* 气泡圆角 */
    max-width: 70%; /* 最大宽度限制，防止气泡过宽 */
    word-wrap: break-word; /* 长单词换行 */
    text-align: left; /* 文本左对齐 */
    box-sizing: border-box; /* 盒模型计算方式：包含padding和border */
    overflow-wrap: break-word; /* 溢出内容强制换行 */
    white-space: pre-wrap; /* 保留空白和换行符 */
    word-break: break-word; /* 允许在单词内换行 */
    line-height: 1.3; /* 行高增大，优化行间距 */
    font-size: 14px; /* 字体大小 */
}

.user-message-bubble {
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 5px;
}

.ai-message-bubble {
    background-color: var(--ai-bubble-bg); /* AI消息气泡背景色，使用CSS变量 */
    color: var(--text-color); /* 文本颜色，使用CSS变量 */
    border-bottom-left-radius: 5px; /* 左下角圆角，与用户气泡区分 */
}

/* 消息操作按钮容器样式 */
.message-actions {
    display: flex; /* 使用flex布局 */
    justify-content: flex-end; /* 元素靠右排列 */
    gap: 8px; /* 元素之间的间距为8px */
    margin-top: 0; /* 消除操作栏额外间距 */
}

.regenerate-btn {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.regenerate-btn:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.message-actions {
    position: absolute;
    bottom: 5px;
    right: 10px;
    display: flex;
    gap: 8px;
    margin-top: 0;
}

.message-actions button {
    padding: 4px 8px;
    font-size: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background-color: var(--card-bg);
    color: var(--text-color);
    height: 28px;
    box-sizing: border-box;
}

.message-actions button:hover {
    background-color: var(--border-color);
}

.input-area {
    background-color: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    margin: 3px 15px 10px 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 10;
    width: calc(100% - 30px);
    box-sizing: border-box;
}

.input-container {
    display: flex;
    gap: 10px;
    height: 100%;
    position: relative;
    background-color: transparent;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.user-input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 14px;
    resize: none;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: var(--input-bg);
    color: var(--text-color);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-height: 40px;
}

.user-input:focus {
    outline: none;
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 8px;
}

.nav-btn {
    padding: 4px;
    font-size: 10px;
    width: 80px;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: var(--card-bg);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background-color: #e8eaed;
}

.send-btn {
    background-color: #0284c7;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    transition: all 0.2s ease;
}

.send-btn:hover {
    background-color: #0369a1;
    transform: translateY(-1px);
}

.send-btn:active {
    transform: translateY(1px);
}

.send-btn:disabled {
    background-color: #94a3b8;
    cursor: not-allowed;
    transform: none;
}

.clear-btn {
    background-color: var(--card-bg);
    color: var(--text-color);
    border: none;
    padding: 5px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 11px;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    transition: all 0.2s ease;
}

.clear-btn:hover {
    background-color: #e8eaed;
}

.disclaimer {
    position: sticky;
    bottom: 20px;
    text-align: center;
    font-size: 12px;
    color: var(--text-color);
    background-color: transparent;
    padding: 5px;
    width: 100%;
}

/* 代码块复制按钮样式 */
pre {
    position: relative;
}

.copy-code-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 3px;
    padding: 3px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.copy-code-btn:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

/* 表格样式 */
table {
    border-collapse: collapse;
    width: 100%;
    margin: 15px 0;
}

table th, table td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

table th {
    background-color: #f5f5f5;
    font-weight: bold;
}

/* 数学公式样式调整 */
.katex {
    font-size: 1.1em !important;
}

span.math {
    white-space: nowrap;
}

div.math {
    margin: 15px 0;
}

.tooltip {
    position: fixed;
    background-color: #4CAF50;
    color: white;
    padding: 5px 10px;
    border-radius: 0;
    display: none;
    font-family: 'Microsoft YaHei', sans-serif;
    font-size: 10px;

    border: 1px solid black;
}

.timeout {
    color: red;
    background-color: #fff3e0;
    padding: 8px 12px;
    border-radius: 4px;
    margin: 10px 0;
    text-align: center;
}

.ai-message {
    color: #1565C0;
    font-weight: bold;
}

.user-message {
    font-weight: bold;
}

.separator {
    color: #ccc;
    margin: 10px 0;
}

.thinking {
    color: #757575;
    padding: 1px 14px;
    min-height: auto;
    display: inline-block;
    border-radius: 12px;
    max-width: 70%;
    background-color: var(--ai-bubble-bg);
    line-height: 1;
}

.timeout {
    color: red;
    font-weight: bold;
}