* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: #eef1f6; }
.page { height: 100vh; display: flex; flex-direction: column; }

/* 工具栏 */
.toolbar { display: flex; align-items: center; padding: 0 20px; height: 60px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.menu-btn { width: 40px; height: 40px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: none; border: none; cursor: pointer; }
.menu-bar { width: 24px; height: 3px; background: #334155; border-radius: 3px; margin: 3px 0; }
.toolbar-title { flex: 1; text-align: center; font-size: 18px; font-weight: 700; color: #0f172a; }
.toolbar-right { display: flex; gap: 10px; align-items: center; }
.prompt-text { font-size: 14px; color: #64748b; background: #f1f5f9; padding: 6px 14px; border-radius: 16px; border: none; cursor: pointer; transition: background 0.2s; }
.prompt-text:hover { background: #e2e8f0; }
.select-btn { font-size: 14px; padding: 6px 18px; border-radius: 20px; border: none; cursor: pointer; background: #3b82f6; color: #fff; font-weight: 500; }

/* 聊天区 */
.chat-scroll { flex: 1; overflow-y: auto; padding: 20px; }
.chat-inner { max-width: 900px; margin: 0 auto; }
.empty-hint { display: flex; flex-direction: column; align-items: center; padding-top: 80px; }
.empty-icon-wrap { width: 80px; height: 80px; border-radius: 20px; background: linear-gradient(145deg, #3b82f6, #6366f1); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 32px; font-weight: 700; margin-bottom: 20px; box-shadow: 0 4px 16px rgba(99,102,241,0.3); }
.empty-icon-inner { line-height: 1; }
.empty-text { font-size: 24px; font-weight: 700; color: #0f172a; margin-bottom: 8px; }
.empty-sub { font-size: 14px; color: #94a3b8; }

/* 消息 */
.msg-row { display: flex; margin-bottom: 20px; }
.msg-row.row-left { justify-content: flex-start; }
.msg-row.row-right { justify-content: flex-end; }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.avatar-ai { background: linear-gradient(145deg, #6366f1, #8b5cf6); color: #fff; margin-right: 12px; }
.avatar-user { background: linear-gradient(145deg, #10b981, #059669); color: #fff; margin-left: 12px; }
.msg-content { max-width: 70%; }
.bubble { padding: 12px 16px; font-size: 15px; line-height: 1.6; word-break: break-word; border-radius: 16px; }
.bubble-user { background: linear-gradient(150deg, #3b82f6, #2563eb); color: #fff; border-radius: 16px 4px 16px 16px; }
.bubble-ai { background: #fff; color: #1e293b; border-radius: 4px 16px 16px 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.bubble-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.thinking { display: flex; align-items: center; gap: 8px; }
.thinking-text { font-size: 14px; color: #64748b; }
.dot-wave { display: flex; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #93c5fd; animation: dotPulse 1.4s infinite ease-in-out; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse { 0%,60%,100% { transform: scale(1); opacity: 0.4; } 30% { transform: scale(1.3); opacity: 1; } }
.msg-meta { margin-top: 6px; font-size: 12px; color: #94a3b8; display: flex; align-items: center; gap: 8px; }
.msg-image { max-width: 100%; border-radius: 8px; margin-bottom: 8px; }

/* 输入区 */
.input-bar { display: flex; align-items: flex-end; padding: 12px; background: #fff; box-shadow: 0 -1px 3px rgba(0,0,0,0.05); }
.img-btn { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: linear-gradient(135deg, #ec4899, #f43f5e); cursor: pointer; margin-right: 8px; }
.img-btn-icon { font-size: 28px; color: #fff; line-height: 1; }
.input-wrap { flex: 1; background: #f1f5f9; border-radius: 16px; margin-right: 12px; overflow: hidden; }
.img-preview-bar { padding: 8px; position: relative; }
.img-preview-thumb { width: 80px; height: 80px; border-radius: 8px; object-fit: cover; }
.img-preview-remove { position: absolute; top: 4px; left: 68px; width: 24px; height: 24px; background: rgba(0,0,0,0.6); border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; border: none; }
.remove-icon { color: #fff; font-size: 18px; }
.input-box { width: 100%; padding: 12px 16px; font-size: 15px; line-height: 1.5; min-height: 44px; max-height: 120px; border: none; background: transparent; resize: none; font-family: inherit; }
.input-box:focus { outline: none; }
.send-btn { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: none; cursor: pointer; background: #e2e8f0; }
.send-btn.active { background: linear-gradient(145deg, #3b82f6, #2563eb); box-shadow: 0 2px 8px rgba(37,99,235,0.3); }
.send-icon { font-size: 24px; color: #94a3b8; font-weight: 800; }
.send-btn.active .send-icon { color: #fff; }

/* 遮罩和面板 */
.mask { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15,23,42,0.5); z-index: 100; }
.settings-panel, .prompt-selector { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); background: #fff; border-radius: 20px; z-index: 101; padding: 24px; min-width: 400px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.panel-header, .prompt-hd { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.panel-title, .prompt-title { font-size: 20px; font-weight: 700; color: #0f172a; }
.panel-close, .prompt-close { width: 32px; height: 32px; border-radius: 50%; background: #f1f5f9; border: none; cursor: pointer; font-size: 20px; color: #64748b; }
.settings-body { margin-bottom: 20px; }
.field-label { font-size: 13px; color: #64748b; margin-bottom: 8px; }
.key-input-wrap { display: flex; align-items: center; background: #f8fafc; border-radius: 12px; border: 1px solid #e2e8f0; padding: 0 16px; height: 44px; }
.key-input { flex: 1; height: 100%; border: none; background: transparent; font-size: 14px; }
.key-input:focus { outline: none; }
.settings-footer { display: flex; gap: 12px; }
.btn-secondary, .btn-primary { flex: 1; padding: 12px; border-radius: 12px; border: none; cursor: pointer; font-size: 15px; font-weight: 600; }
.btn-secondary { background: #f1f5f9; color: #475569; }
.btn-primary { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff; }

/* 侧边栏 */
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 360px; background: #f8fafc; z-index: 200; box-shadow: 4px 0 20px rgba(0,0,0,0.15); display: none; }
.sidebar-hd { display: flex; justify-content: space-between; align-items: center; padding: 20px; background: #fff; border-bottom: 1px solid #f1f5f9; }
.sidebar-title { font-size: 18px; font-weight: 700; }
.sidebar-close { width: 32px; height: 32px; border-radius: 50%; background: #f1f5f9; border: none; cursor: pointer; font-size: 20px; color: #64748b; }
.new-chat-btn { display: flex; align-items: center; margin: 16px; padding: 14px 20px; background: linear-gradient(135deg, #3b82f6, #2563eb); border-radius: 12px; border: none; cursor: pointer; color: #fff; font-size: 16px; font-weight: 600; }
.new-chat-plus { font-size: 24px; margin-right: 8px; }
.new-chat-text { line-height: 1; }
.settings-link-btn { display: flex; align-items: center; justify-content: center; margin: 0 16px 16px 16px; padding: 12px 20px; background: #f8fafc; border-radius: 12px; border: 1px solid #e2e8f0; cursor: pointer; color: #475569; font-size: 15px; font-weight: 500; transition: all 0.2s; }
.settings-link-btn:hover { background: #f1f5f9; }
.sidebar-scroll { overflow-y: auto; height: calc(100vh - 160px); }
.sidebar-empty { padding: 40px 20px; text-align: center; }
.sidebar-empty-text { font-size: 14px; color: #94a3b8; }
.history-item { position: relative; padding: 14px 40px 14px 16px; margin: 8px 16px; background: #fff; border-radius: 12px; cursor: pointer; transition: all 0.2s; }
.history-item:hover { background: #f8fafc; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.history-title { font-size: 14px; color: #0f172a; font-weight: 500; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-date { font-size: 12px; color: #94a3b8; }
.history-delete { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border-radius: 50%; background: #fee2e2; border: none; color: #dc2626; font-size: 18px; cursor: pointer; opacity: 0; transition: opacity 0.2s; }
.history-item:hover .history-delete { opacity: 1; }
.history-delete:hover { background: #fecaca; }

/* 模板列表 */
.prompt-scroll { max-height: 400px; overflow-y: auto; }
.prompt-list { display: flex; flex-direction: column; gap: 10px; }
.prompt-item { padding: 14px 18px; background: #f8fafc; border-radius: 12px; border: 2px solid #e2e8f0; cursor: pointer; transition: all 0.2s; }
.prompt-item:hover { background: #f1f5f9; }
.prompt-item.active { background: linear-gradient(135deg, #ede9fe, #f3e8ff); border-color: #a78bfa; }
.prompt-name { font-size: 15px; color: #1e293b; font-weight: 500; }
.prompt-item.active .prompt-name { color: #8b5cf6; font-weight: 700; }

/* Toast提示 */
.toast { position: fixed; top: 80px; left: 50%; transform: translateX(-50%) translateY(-20px); background: rgba(15,23,42,0.95); color: #fff; padding: 12px 24px; border-radius: 8px; font-size: 14px; z-index: 9999; opacity: 0; transition: all 0.3s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 消息格式化 */
.bubble code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-family: 'Courier New', monospace; font-size: 14px; color: #dc2626; }
.bubble strong { font-weight: 600; color: #0f172a; }
.bubble em { font-style: italic; }
