/* ── 全局重置 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --bg3: #1a1a24;
  --border: #2a2a3a;
  --accent: #6366f1;
  --accent2: #818cf8;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --user-bg: #1e1e2e;
  --ai-bg: #13131e;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* ── 应用布局 ── */
.app { display: flex; flex-direction: column; height: 100vh; max-width: 900px; margin: 0 auto; }

/* ── 顶部导航 ── */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--bg2);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.avatar { font-size: 32px; line-height: 1; }
.header-info h1 { font-size: 18px; font-weight: 700; color: var(--text); }
.status { font-size: 12px; color: var(--text2); }
.status.online { color: #4ade80; }
.status.error { color: #f87171; }
.header-right { display: flex; gap: 8px; }
.btn-icon {
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg3); color: var(--text2); cursor: pointer;
  font-size: 13px; text-decoration: none; transition: all .2s;
}
.btn-icon:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── 聊天区域 ── */
.chat-container {
  flex: 1; overflow-y: auto; padding: 24px 20px;
  display: flex; flex-direction: column; gap: 0;
  scroll-behavior: smooth;
}
.chat-container::-webkit-scrollbar { width: 6px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── 欢迎屏 ── */
.welcome { text-align: center; padding: 60px 20px; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.welcome-avatar { font-size: 64px; margin-bottom: 20px; }
.welcome h2 { font-size: 22px; font-weight: 600; margin-bottom: 10px; color: var(--text); }
.welcome p { color: var(--text2); margin-bottom: 28px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 600px; }
.suggestion-btn {
  padding: 10px 16px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--bg3); color: var(--text2); cursor: pointer; font-size: 13px;
  transition: all .2s;
}
.suggestion-btn:hover { border-color: var(--accent); color: var(--accent2); background: rgba(99,102,241,.1); }

/* ── 消息气泡 ── */
.message { display: flex; gap: 12px; padding: 16px 0; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.message.user { flex-direction: row-reverse; }
.message-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.message.ai .message-avatar { background: var(--bg3); border: 1px solid var(--border); }
.message.user .message-avatar { background: var(--accent); }

.message-content { max-width: 75%; }
.message-name { font-size: 12px; color: var(--text2); margin-bottom: 6px; }
.message.user .message-name { text-align: right; }
.message-bubble {
  padding: 12px 16px; border-radius: var(--radius); line-height: 1.65;
  font-size: 15px; word-break: break-word; white-space: pre-wrap;
}
.message.ai .message-bubble { background: var(--ai-bg); border: 1px solid var(--border); border-top-left-radius: 4px; }
.message.user .message-bubble { background: var(--accent); color: #fff; border-top-right-radius: 4px; }
.message-time { font-size: 11px; color: var(--text2); margin-top: 4px; }
.message.user .message-time { text-align: right; }

/* ── 计算引擎提示气泡 ── */
.compute-hint {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 1px solid rgba(99, 179, 237, 0.35);
  color: #63b3ed; font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  padding: 6px 14px; border-radius: 20px;
  margin: 6px auto; width: fit-content;
  animation: computePulse 1.5s ease-in-out infinite, fadeInUp 0.3s ease;
  box-shadow: 0 0 12px rgba(99, 179, 237, 0.15);
}
@keyframes computePulse {
  0%, 100% { opacity: 1; border-color: rgba(99, 179, 237, 0.35); }
  50% { opacity: 0.7; border-color: rgba(99, 179, 237, 0.7); box-shadow: 0 0 18px rgba(99, 179, 237, 0.3); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 打字指示器 ── */
.typing-indicator { display: flex; align-items: center; gap: 4px; padding: 16px 0 0 48px; }
.typing-indicator span {
  width: 8px; height: 8px; border-radius: 50%; background: var(--text2);
  animation: bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

/* ── 输入区域 ── */
.input-area {
  padding: 16px 20px 20px; background: var(--bg2);
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.input-wrapper {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
  transition: border-color .2s;
}
.input-wrapper:focus-within { border-color: var(--accent); }
textarea#userInput {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 15px; resize: none; max-height: 160px;
  font-family: inherit; line-height: 1.5;
}
textarea#userInput::placeholder { color: var(--text2); }
.input-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.stream-toggle { display: flex; align-items: center; gap: 4px; cursor: pointer; font-size: 12px; color: var(--text2); }
.stream-toggle input { accent-color: var(--accent); }
.send-btn {
  width: 36px; height: 36px; border-radius: 8px; border: none;
  background: var(--accent); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s; flex-shrink: 0;
}
.send-btn:hover { background: var(--accent2); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; }
.send-btn svg { width: 16px; height: 16px; }
.input-footer { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--text2); padding: 0 2px; }

/* ── 响应式 ── */
@media (max-width: 600px) {
  .header { padding: 10px 14px; }
  .chat-container { padding: 16px 12px; }
  .input-area { padding: 12px 14px 16px; }
  .message-content { max-width: 88%; }
  .welcome { padding: 40px 16px; }
  .welcome-avatar { font-size: 48px; }
}
