:root {
  --green-900: #0b2e24;
  --green-800: #123c2f;
  --green-700: #1a4c3b;
  --green-100: #e8f0ea;
  --gold: #c9a24b;
  --gold-soft: #e6d3a3;
  --cream: #f6f2e9;
  --ink: #1f2a26;
  --muted: #7b877f;
  --line: #e5e0d4;
  --white: #ffffff;
  --shadow: 0 24px 60px rgba(11, 46, 36, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(201, 162, 75, 0.18), transparent 42%),
    radial-gradient(circle at 88% 92%, rgba(18, 60, 47, 0.16), transparent 48%),
    var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.page {
  width: 100%;
  max-width: 920px;
}

.card {
  display: flex;
  flex-direction: column;
  height: min(88vh, 860px);
  min-height: 560px;
  background: var(--white);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid rgba(201, 162, 75, 0.22);
}

/* 顶部栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 26px;
  background: linear-gradient(135deg, var(--green-900), var(--green-700));
  color: #f4efe2;
  border-bottom: 3px solid var(--gold);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.logo {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--gold-soft);
  color: var(--gold-soft);
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-size: 22px;
  letter-spacing: 1px;
  background: rgba(255, 255, 255, 0.06);
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status {
  margin: 5px 0 0;
  font-size: 12px;
  color: rgba(244, 239, 226, 0.72);
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5fd4a0;
  box-shadow: 0 0 0 3px rgba(95, 212, 160, 0.18);
  animation: pulse 2.4s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.ghost {
  flex: 0 0 auto;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--gold-soft);
  background: transparent;
  border: 1px solid rgba(230, 211, 163, 0.45);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ghost:hover {
  background: rgba(230, 211, 163, 0.12);
  border-color: var(--gold-soft);
}

/* 聊天区 */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 26px 26px 10px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
  background:
    linear-gradient(rgba(246, 242, 233, 0.55), rgba(246, 242, 233, 0.55)),
    repeating-linear-gradient(45deg, transparent 0 18px, rgba(201, 162, 75, 0.035) 18px 19px);
}

.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: rise 0.28s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--green-800);
  color: var(--gold-soft);
  border: 1px solid rgba(201, 162, 75, 0.5);
  font-family: Georgia, serif;
  font-size: 16px;
}

.message.user .avatar {
  background: #f0e7d2;
  color: #8a6d2f;
  border-color: #ddcda4;
}

.content {
  max-width: min(78%, 640px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message.user .content {
  align-items: flex-end;
}

.bubble {
  padding: 13px 17px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--white);
  border: 1px solid var(--line);
  border-top-left-radius: 5px;
  box-shadow: 0 4px 14px rgba(31, 42, 38, 0.04);
}

.bubble p {
  margin: 0;
}

.bubble p + p {
  margin-top: 8px;
}

.message.user .bubble {
  background: linear-gradient(135deg, var(--green-800), var(--green-700));
  color: #f6f2e9;
  border: none;
  border-top-left-radius: 16px;
  border-top-right-radius: 5px;
}

.meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  line-height: 1.5;
  letter-spacing: 0.3px;
  border: 1px solid transparent;
}

.badge.kb {
  color: #7a5b16;
  background: #f7edd4;
  border-color: #e8d6a8;
}

.badge.ai {
  color: #1d5c43;
  background: #e4f2ea;
  border-color: #c4e1d2;
}

.badge.tip {
  color: #8a3a2c;
  background: #fbe9e4;
  border-color: #f1cdc3;
}

/* 打字提示 */
.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 4px 2px;
}

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

.typing span:nth-child(2) { animation-delay: 0.18s; }
.typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* 流式输出光标 */
.bubble.streaming::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  vertical-align: -2px;
  background: var(--gold);
  animation: caret 0.9s steps(1) infinite;
}

@keyframes caret {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* 快捷问题 */
.chips {
  display: flex;
  gap: 9px;
  padding: 12px 26px 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chips button {
  flex: 0 0 auto;
  padding: 8px 15px;
  font-size: 12.5px;
  color: #6c5a2c;
  background: #faf6ec;
  border: 1px solid #e6d8b6;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.chips button:hover {
  background: #f3e9d1;
  border-color: var(--gold);
  transform: translateY(-1px);
}

/* 输入区 */
.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 26px 4px;
}

.composer input {
  flex: 1;
  height: 48px;
  padding: 0 18px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--ink);
  background: #faf8f2;
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  transition: all 0.2s ease;
}

.composer input::placeholder {
  color: #a9a99f;
}

.composer input:focus {
  background: var(--white);
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(201, 162, 75, 0.14);
}

.send {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  color: #f6f2e9;
  background: linear-gradient(135deg, var(--green-800), var(--green-700));
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 6px 16px rgba(18, 60, 47, 0.28);
}

.send:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 9px 20px rgba(18, 60, 47, 0.34);
}

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

.hint {
  margin: 6px 0 14px;
  text-align: center;
  font-size: 11px;
  color: #a3a297;
}

/* 滚动条 */
.chat::-webkit-scrollbar {
  width: 6px;
}

.chat::-webkit-scrollbar-thumb {
  background: #ddd5c2;
  border-radius: 3px;
}

/* 响应式 */
@media (max-width: 640px) {
  body {
    padding: 0;
  }

  .card {
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }

  .topbar {
    padding: 14px 18px;
  }

  .brand-text h1 {
    font-size: 15px;
  }

  .chat {
    padding: 20px 16px 8px;
  }

  .content {
    max-width: 84%;
  }

  .chips {
    padding: 10px 16px 4px;
  }

  .composer {
    padding: 10px 16px 4px;
  }

  .ghost {
    padding: 7px 12px;
  }
}
