/* 基础样式 */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    color: #2c3e50;
    margin-bottom: 10px;
}

header p {
    color: #7f8c8d;
}

/* 聊天容器样式 */
.chat-container {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-bottom: 20px;
}

.chat-history {
    height: 500px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 5px;
    margin-bottom: 15px;
    background-color: #fafafa;
}

.message {
    margin-bottom: 15px;
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
}

.user-message {
    background-color: #e3f2fd;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.ai-message {
    background-color: #f1f1f1;
    margin-right: auto;
    border-bottom-left-radius: 5px;
}

.message-time {
    font-size: 0.8em;
    color: #7f8c8d;
    margin-top: 5px;
    text-align: right;
}

/* 输入区域样式 */
.input-area {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 0;
}

textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    resize: none;
    font-family: inherit;
    min-height: 60px;
    padding-bottom: 48px; /* 预留按钮高度 */
}

.button-group {
    position: absolute;
    right: 20px;
    bottom: 12px;
    display: flex;
    gap: 10px;
    z-index: 2;
}

button {
    padding: 10px 15px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
}

button:hover {
    background-color: #2980b9;
}

button:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

#clear-btn {
    background-color: #e74c3c;
}

#clear-btn:hover {
    background-color: #c0392b;
}

/* 页脚样式 */
footer {
    text-align: center;
    padding: 0px 0 30px 0;
    color: #7f8c8d;
    font-size: 14px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .chat-history {
        height: 400px;
    }
    
    .message {
        max-width: 90%;
    }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-left: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 在原有样式基础上添加以下内容 */

/* Markdown渲染样式 */
.message div p {
    margin: 0.5em 0;
}

.message div ul,
.message div ol {
    padding-left: 1.5em;
    margin: 0.5em 0;
}

.message div pre {
    background-color: #f6f8fa;
    border-radius: 6px;
    padding: 1em;
    overflow-x: auto;
    margin: 0.5em 0;
}

.message div code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    background-color: rgba(175, 184, 193, 0.2);
    border-radius: 3px;
    padding: 0.2em 0.4em;
    font-size: 0.9em;
}

.message div pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
}

.message div blockquote {
    border-left: 4px solid #dfe2e5;
    color: #6a737d;
    padding: 0 1em;
    margin: 0.5em 0;
}

.message div table {
    border-collapse: collapse;
    margin: 0.5em 0;
    width: 100%;
}

.message div table th,
.message div table td {
    border: 1px solid #dfe2e5;
    padding: 6px 13px;
}

.message div table tr {
    background-color: #fff;
    border-top: 1px solid #c6cbd1;
}

.message div table tr:nth-child(2n) {
    background-color: #f6f8fa;
}

.message div h1,
.message div h2,
.message div h3,
.message div h4,
.message div h5,
.message div h6 {
    margin: 0.8em 0 0.4em 0;
    font-weight: 600;
    line-height: 1.25;
}

.message div h1 {
    font-size: 1.5em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
}

.message div h2 {
    font-size: 1.3em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
}

.message div h3 {
    font-size: 1.1em;
}

.message div a {
    color: #0366d6;
    text-decoration: none;
}

.message div a:hover {
    text-decoration: underline;
}

/* 猫娘消息特殊样式 */
.ai-message {
  background-color: #fff0f5 !important;
  border-left: 3px solid #ffb6c1;
}

.cat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 10px;
  float: left;
}

/* 用户消息强调主人身份 */
.user-message {
  background-color: #f0f8ff !important;
  border-right: 3px solid #4682b4;
}

.user-message::before {
  content: "博士";
  font-weight: bold;
  color: #1e90ff;
  margin-right: 5px;
}