:root {
  --bg: #ffffff;
  --ink: #1f2328;
  --ink-soft: #8b9199;
  --accent: #3b6ea5;
  --accent-dark: #2f5a89;
  --accent-soft: #eef3f9;
  --user-gradient: linear-gradient(135deg, #4a7fb5, #2f5a89);
  --border: #eceef1;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.06);
  --max-w: 720px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 100%;
}

/* ---------- 顶部标题栏 ---------- */
.app-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent-soft);
  flex: 0 0 auto;
}

.header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.header-text h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.header-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}

/* ---------- 对话区 ---------- */
.chat-container {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat-container::-webkit-scrollbar {
  width: 8px;
}

.chat-container::-webkit-scrollbar-thumb {
  background: #e6e8eb;
  border-radius: 4px;
}

.chat-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px 16px 8px;
}

.welcome {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 4px 24px;
}

.welcome-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent-soft);
  flex: 0 0 auto;
}

.welcome-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.welcome-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink-soft);
}

/* ---------- 预设问题 ---------- */
.preset-section {
  margin: 0 0 20px;
}

.preset-section.hidden {
  display: none;
}

.preset-label {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 10px;
}

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preset-btn {
  text-align: left;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}

.preset-btn:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.preset-btn:active {
  transform: translateY(1px);
}

/* ---------- 消息气泡 ---------- */
.messages {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 8px 0 24px;
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.msg.user {
  flex-direction: row-reverse;
}

.avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.msg.assistant .avatar {
  background: var(--accent-soft);
}

.msg.user .avatar {
  background: #f0f1f3;
  color: var(--ink-soft);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bubble-wrap {
  max-width: 72%;
  display: flex;
  flex-direction: column;
}

.bubble {
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.75;
  font-size: 15px;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg.assistant .bubble {
  background: #fff;
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  box-shadow: var(--shadow-sm);
  color: var(--ink);
}

.msg.user .bubble {
  background: var(--user-gradient);
  color: #fff;
  border-top-right-radius: 4px;
  box-shadow: var(--shadow-sm);
}

/* ---------- 输入中指示 ---------- */
.typing-dots i {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 4px;
  border-radius: 50%;
  background: #b6bcc4;
  animation: blink 1.2s infinite;
}

.typing-dots i:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots i:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}

/* ---------- 底部输入栏 ---------- */
.input-bar {
  border-top: 1px solid var(--border);
  background: #fff;
  padding: 12px 16px 10px;
}

.input-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: var(--max-w);
  margin: 0 auto;
  background: #f5f6f8;
  border: 1px solid transparent;
  border-radius: 24px;
  padding: 7px 7px 7px 16px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.input-box:focus-within {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 110, 165, 0.1);
}

#inputBox {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  max-height: 120px;
  padding: 6px 0;
}

.send-btn {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.send-btn:hover {
  background: var(--accent-dark);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-tip {
  max-width: var(--max-w);
  margin: 8px auto 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 520px) {
  .bubble-wrap {
    max-width: 84%;
  }

  .chat-inner {
    padding: 16px 12px 8px;
  }
}
