* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; display: flex; height: 100vh; background-color: #f5f5f5; }

.sidebar { width: 260px; background-color: #202123; color: white; display: flex; flex-direction: column; padding: 10px; }
.new-chat-btn { background-color: transparent; border: 1px solid #4d4d4f; color: white; padding: 12px; border-radius: 5px; cursor: pointer; text-align: left; margin-bottom: 20px; transition: background 0.2s; }
.new-chat-btn:hover { background-color: #2a2b32; }
.chat-list { list-style: none; overflow-y: auto; flex: 1; }
.chat-item { padding: 10px; margin-bottom: 5px; border-radius: 5px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.chat-item:hover, .chat-item.active { background-color: #343541; }
.chat-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-actions button { background: none; border: none; color: #ccc; cursor: pointer; margin-left: 5px; font-size: 12px; padding: 2px 5px; }

.main-area { flex: 1; display: flex; flex-direction: column; position: relative; }
.header { height: 60px; border-bottom: 1px solid #e5e5e5; display: flex; justify-content: space-between; align-items: center; padding: 0 20px; background: white; }
.settings-icon { font-size: 24px; cursor: pointer; }

.chat-container { flex: 1; overflow-y: auto; padding: 20px; background: white; }
.message { margin-bottom: 20px; display: flex; max-width: 100%; }
.message.user { justify-content: flex-end; }

/* 用户发出的消息背景，改为深灰 */
.message.user .content { background-color: #6e6e80; color: white; }

.message.assistant .content { background-color: #f1f1f1; color: black; }
.content { max-width: 80%; padding: 15px; border-radius: 8px; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; }

/* 完美解决单行空格问题的 CSS */
.content p { margin-bottom: 10px; }
.content p:only-child { margin-bottom: 0; }
.content ul, .content ol { margin-left: 20px; margin-top: 10px; margin-bottom: 10px; }
.content li { margin-bottom: 5px; }

.input-area { padding: 20px; background: white; border-top: 1px solid #e5e5e5; }
.input-box { display: flex; max-width: 800px; margin: 0 auto; }
.input-box input { flex: 1; padding: 15px; border: 1px solid #ccc; border-radius: 5px; outline: none; font-size: 16px; }

/* 发送按钮，改为深灰 */
.input-box button { padding: 0 20px; background-color: #6e6e80; color: white; border: none; border-radius: 5px; margin-left: 10px; cursor: pointer; transition: background 0.2s;}
.input-box button:hover { background-color: #565869; }

.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); justify-content: center; align-items: center; z-index: 1000; }
.modal-content { background: white; padding: 30px; border-radius: 10px; width: 500px; max-width: 90%; max-height: 80vh; overflow-y: auto;}
.modal-content h2 { margin-bottom: 20px; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; }
.form-group input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
.modal-btns { text-align: right; margin-top: 20px; }
.modal-btns button { padding: 8px 15px; margin-left: 10px; cursor: pointer; border-radius: 4px; border: 1px solid #ccc; }

.kb-list { border: 1px solid #eee; padding: 10px; max-height: 150px; overflow-y: auto; margin-top: 10px; }
.kb-item { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; font-size: 14px;}
.kb-item button { color: red; cursor: pointer; border: none; background: none; font-size: 16px; padding: 2px 5px;}