* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: sans-serif; background: #1a1a1a; color: #eee; height: 100vh; }

/* Auth */
.auth-container { display: flex; justify-content: center; align-items: center; height: 100vh; }
.auth-box { background: #2a2a2a; padding: 40px; border-radius: 12px; width: 340px; display: flex; flex-direction: column; gap: 14px; }
.auth-box h1 { text-align: center; font-size: 22px; margin-bottom: 6px; }
.auth-tabs { display: flex; gap: 8px; }
.auth-tab { flex: 1; padding: 8px; background: #333; border: none; color: #aaa; border-radius: 6px; cursor: pointer; }
.auth-tab.active { background: #7c3aed; color: #fff; }
.auth-box input { padding: 10px 14px; background: #333; border: none; border-radius: 6px; color: #eee; font-size: 14px; }
.btn-primary { padding: 10px; background: #7c3aed; border: none; border-radius: 6px; color: #fff; cursor: pointer; font-size: 15px; }
.btn-primary:hover { background: #6d28d9; }
.error-msg { color: #f87171; font-size: 13px; text-align: center; min-height: 18px; }

/* Chat layout */
.chat-container { display: flex; height: 100vh; }
.sidebar { width: 260px; background: #1e1e1e; display: flex; flex-direction: column; padding: 16px; gap: 10px; flex-shrink: 0; }
.sidebar-header { display: flex; justify-content: space-between; align-items: center; }
.btn-logout { background: none; border: 1px solid #444; color: #aaa; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.btn-logout:hover { border-color: #f87171; color: #f87171; }
.btn-new { background: #7c3aed; border: none; color: #fff; padding: 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.btn-new:hover { background: #6d28d9; }
#conversation-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; flex: 1; }
.conv-item { padding: 10px 12px; background: #2a2a2a; border-radius: 8px; cursor: pointer; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.conv-item:hover, .conv-item.active { background: #3a2a5a; }
.conv-item .del-btn { color: #666; font-size: 16px; background: none; border: none; cursor: pointer; line-height: 1; }
.conv-item .del-btn:hover { color: #f87171; }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.top-bar { display: flex; align-items: center; gap: 24px; padding: 12px 20px; background: #1e1e1e; border-bottom: 1px solid #2e2e2e; flex-shrink: 0; flex-wrap: wrap; }
.model-selector, .temperature-control, .memory-control { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #aaa; }
.model-selector select, .memory-control select { background: #2a2a2a; border: 1px solid #3a3a3a; color: #eee; padding: 4px 8px; border-radius: 6px; font-size: 13px; }
.temperature-control input[type=range] { width: 100px; accent-color: #7c3aed; }

/* Messages */
#messages { flex: 1; overflow-y: auto; padding: 24px 20px; display: flex; flex-direction: column; gap: 16px; }
.msg { max-width: 72%; padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: #7c3aed; color: #fff; }
.msg.assistant { align-self: flex-start; background: #2a2a2a; color: #eee; }
.msg.error { align-self: flex-start; background: #3a1a1a; color: #f87171; border-radius: 12px; padding: 12px 16px; }

/* 引用框 */
#quote-box { background: #2a2a2a; border-left: 3px solid #7c3aed; margin: 0 20px 8px 20px; padding: 8px 12px; border-radius: 0 6px 6px 0; }
.quote-inner { display: flex; align-items: center; gap: 8px; width: 100%; }
.quote-label { color: #7c3aed; font-weight: bold; flex-shrink: 0; font-size: 13px; }
#quote-text { color: #aaa; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.quote-close { background: none; border: none; color: #666; cursor: pointer; font-size: 16px; flex-shrink: 0; }
.quote-close:hover { color: #f87171; }

/* 文件预览 */
#file-preview { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px 8px 20px; min-height: 0; }
.file-tag { display: flex; align-items: center; gap: 4px; background: #2a2a2a; border: 1px solid #3a3a3a; border-radius: 16px; padding: 4px 10px; font-size: 12px; color: #ccc; }
.file-tag button { background: none; border: none; color: #888; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 0 0 4px; }
.file-tag button:hover { color: #f87171; }

/* 消息里的文件标记 */
.file-chip { display: inline-block; background: rgba(255,255,255,0.15); border-radius: 6px; padding: 2px 8px; font-size: 12px; margin-bottom: 4px; }

/* 输入区域 */
.input-area { display: flex; gap: 10px; padding: 16px 20px; background: #1e1e1e; border-top: 1px solid #2e2e2e; flex-shrink: 0; transition: background 0.2s; }
.input-area.drag-over { background: #2a1a4a; border-top-color: #7c3aed; }
#input { flex: 1; background: #2a2a2a; border: none; border-radius: 8px; padding: 10px 14px; color: #eee; font-size: 14px; resize: none; min-height: 44px; max-height: 160px; }
.btn-send { background: #7c3aed; border: none; color: #fff; padding: 0 20px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.btn-send:hover { background: #6d28d9; }
.btn-send:disabled { background: #444; cursor: not-allowed; }

/* 代码块 */
.code-block { position: relative; margin: 8px 0; }
.code-block pre { background: #1e1e1e; color: #d4d4d4; padding: 36px 12px 12px 12px; border-radius: 6px; overflow-x: auto; margin: 0; white-space: pre-wrap; word-break: break-all; }

/* 复制按钮和引用按钮统一样式 */
.copy-btn, .quote-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #444;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 2px 10px;
  cursor: pointer;
  font-size: 12px;
  z-index: 1;
}
.copy-btn:hover, .quote-btn:hover { background: #666; }

/* 引用按钮不是absolute，覆盖position */
.quote-btn {
  position: relative;
  top: auto;
  right: auto;
  display: block;
  margin-top: 6px;
}

/* 重试按钮 */
.retry-btn { margin-left: 10px; background: #3a1a1a; border: 1px solid #f87171; color: #f87171; padding: 3px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.retry-btn:hover { background: #f87171; color: #fff; }

/* 模型标签 */
.model-tag { margin-top: 8px; font-size: 11px; color: #888; text-align: right; }

/* 上传按钮 */
.btn-img { background: none; border: 1px solid #555; border-radius: 6px; color: #ccc; padding: 4px 8px; cursor: pointer; font-size: 16px; flex-shrink: 0; }
.btn-img:hover { background: #333; }

/* 加载动画 */
@keyframes blink { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }
.dots { display: inline-block; font-size: 20px; letter-spacing: 4px; animation: blink 1.2s infinite; }