:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --line: #e8e5de;
  --ink: #1c1c1a;
  --ink-2: #4f4d47;
  --muted: #918e86;
  --accent: #1b5e4b;
  --accent-dark: #144a3a;
  --soft: #f1f0ec;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.phone {
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding-top: calc(14px + env(safe-area-inset-top));
}

.avatar {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 16px;
  letter-spacing: 0.5px;
}

.head-text {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
  min-width: 0;
}

.head-text strong {
  font-size: 15px;
  font-weight: 500;
}

.head-text span {
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.live {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #3f9d76;
}

.head-clear {
  margin-left: auto;
  flex: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
}

.head-clear:active { background: var(--soft); }

.msgs {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overscroll-behavior: contain;
}

.msg {
  max-width: 84%;
  padding: 11px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14.5px;
}

.msg.bot {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}

.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.msg.muted {
  background: var(--soft);
  border-color: transparent;
  color: var(--ink-2);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.chip:active { background: var(--soft); }

.typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 14px;
}

/* ---------- 命中：标题 + 答案 + 链接 ---------- */

.msg.faq {
  padding: 13px 15px;
}

.faq-title {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 14.5px;
}

.faq-answer {
  white-space: pre-wrap;
  word-break: break-word;
}

.faq-link {
  display: inline-block;
  margin-top: 10px;
  padding: 7px 14px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  text-decoration: none;
}

.faq-link:active { background: var(--accent-dark); }

.faq-link-plain {
  margin-top: 9px;
  font-size: 13px;
  color: var(--accent);
  word-break: break-all;
}

/* ---------- 未命中：推荐问题 ---------- */

.sug-intro {
  color: var(--ink-2);
  margin-bottom: 10px;
}

.sug-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sug {
  text-align: left;
  border: 1px solid var(--line);
  background: #fbfaf8;
  color: var(--accent);
  border-radius: 10px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  cursor: pointer;
}

.sug:active { background: var(--soft); }

.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c4c1b8;
  animation: blink 1.2s infinite ease-in-out;
}

.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes blink {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

.composer {
  flex: none;
  display: flex;
  gap: 9px;
  align-items: flex-end;
  padding: 10px 14px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}

.composer textarea {
  flex: 1;
  min-height: 42px;
  max-height: 110px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 10px 13px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  outline: none;
}

.composer textarea:focus { border-color: #b9cfc6; }

.composer button {
  flex: none;
  height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.composer button:disabled { opacity: 0.45; }

.composer button:active { background: var(--accent-dark); }

@media (min-width: 620px) {
  body { padding: 0; }
  .phone {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
}
