:root {
  --primary: #1d4ed8;
  --primary-strong: #1e40af;
  --primary-soft: #eaf1ff;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --text-soft: #6b7280;
  --border: #e5e9f2;
  --ai-bubble: #ffffff;
  --user-bubble: #1d4ed8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #4f8df9);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; letter-spacing: 0.5px;
}
.brand-text h1 { font-size: 17px; font-weight: 700; }
.brand-text p { font-size: 12px; color: var(--text-soft); margin-top: 1px; }
.badge {
  font-size: 12px; color: var(--primary);
  background: var(--primary-soft);
  padding: 4px 12px; border-radius: 999px; font-weight: 600;
}

/* 聊天区 */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.welcome {
  margin: auto;
  max-width: 520px;
  text-align: center;
  padding: 20px;
}
.welcome-emoji { font-size: 44px; margin-bottom: 10px; }
.welcome h2 { font-size: 20px; margin-bottom: 8px; }
.welcome p { color: var(--text-soft); font-size: 14px; line-height: 1.6; margin-bottom: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* 消息 */
.msg { display: flex; flex-direction: column; max-width: 86%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.ai { align-self: flex-start; align-items: flex-start; }
.bubble {
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user .bubble { background: var(--user-bubble); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai .bubble { background: var(--ai-bubble); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.typing { color: var(--text-soft); font-size: 14px; }
.sources {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-soft);
  padding: 0 4px;
}

/* 输入栏 */
.inputbar {
  padding: 10px 16px 8px;
  background: var(--card);
  border-top: 1px solid var(--border);
}
.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 8px 8px 14px;
  max-width: 780px;
  margin: 0 auto;
}
.input-wrap:focus-within { border-color: var(--primary); background: #fff; }
#input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
  max-height: 120px;
}
#send {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
#send:hover { background: var(--primary-strong); }
.hint { text-align: center; font-size: 11px; color: #9aa3b2; margin-top: 6px; }

@media (max-width: 520px) {
  .msg { max-width: 94%; }
  .brand-text p { display: none; }
}
