:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #8e8e93;
  --line: #e8e8ed;
  --brand: #0098ef;
  --brand-soft: #e9f5ff;
  --radius: 20px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
.app { max-width: 780px; height: 100vh; margin: 0 auto; display: flex; flex-direction: column; padding: 0 20px; }

/* 顶部 */
.topbar { flex: none; height: 60px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; font-size: 15px; }
.logo { width: 26px; height: 26px; border-radius: 8px; object-fit: cover; display: block; }
.date { color: var(--muted); font-size: 12px; }

/* 数据概览 */
.stats { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding-bottom: 14px; }
.stat { background: var(--surface); border-radius: 14px; padding: 12px 16px; display: flex; align-items: baseline; gap: 8px; }
.stat .num { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.stat .label { color: var(--muted); font-size: 12px; }

/* 消息区 */
.chat { flex: 1; overflow-y: auto; padding: 8px 0 20px; scroll-behavior: smooth; }
.chat::-webkit-scrollbar { width: 6px; }
.chat::-webkit-scrollbar-thumb { background: #d8d8dc; border-radius: 3px; }

.welcome { padding: 56px 8px 24px; text-align: center; }
.welcome-title { font-size: 30px; font-weight: 600; letter-spacing: -.03em; }
.welcome-sub { color: var(--muted); margin-top: 10px; font-size: 14px; line-height: 1.6; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; justify-content: center; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 9px 16px; font-size: 13px; cursor: pointer; transition: background .15s, border-color .15s, transform .15s; font-family: inherit; }
.chip:hover { background: var(--brand-soft); border-color: #a8d7f8; }
.chip:active { transform: scale(.97); }

.msg { margin-bottom: 26px; display: flex; gap: 10px; max-width: 100%; }
.msg.user { justify-content: flex-end; }
.msg.assistant { justify-content: flex-start; }

/* 助手：头像 + 内容列（文字铺满，meta 固定底部） */
.msg .avatar { flex: none; width: 30px; height: 30px; border-radius: 9px; object-fit: cover; display: block; margin-top: 2px; }
.msg.assistant .msg-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0; }
.msg.assistant .bubble { width: 100%; order: 1; background: transparent; padding: 2px 0 0; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }

/* 用户：浅色气泡，深色文字 */
.msg.user .bubble { max-width: 78%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); border-bottom-right-radius: 6px; padding: 11px 16px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }

.meta-line { order: 3; color: var(--muted); font-size: 12px; margin-top: 10px; }

/* 结果表格 */
.result { order: 2; margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); }
.result table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.result th, .result td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.result th { color: var(--muted); font-weight: 500; background: #fafafa; }
.result tr:last-child td { border-bottom: 0; }
.result .scroll { max-height: 320px; overflow: auto; }
.empty { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }

/* 输入区 */
.composer { flex: none; padding: 10px 0 16px; }
.input-wrap { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 8px 8px 18px; transition: border-color .15s, box-shadow .15s; }
.input-wrap:focus-within { border-color: #8ccbf7; box-shadow: 0 0 0 3px rgba(0,152,239,.08); }
#question { flex: 1; border: 0; outline: 0; resize: none; font: inherit; line-height: 24px; min-height: 24px; max-height: 120px; padding: 0; margin: 0; background: transparent; color: var(--text); display: block; }
.send { flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--brand); color: #fff; font-size: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: opacity .15s, transform .15s; }
.send::after { content: "↑"; font-size: 20px; line-height: 1; font-weight: 300; }
.send:active { transform: scale(.92); }
.send:disabled { opacity: .4; cursor: default; }
.hint { text-align: center; color: var(--muted); font-size: 11px; margin-top: 8px; }

@media (max-width: 640px) {
  .app { padding: 0 14px; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .stat { padding: 10px 12px; }
  .stat .num { font-size: 17px; }
  .welcome { padding-top: 36px; }
  .welcome-title { font-size: 25px; }
  .msg .bubble { max-width: 88%; }
  .msg.user .bubble { max-width: 84%; }
}
