:root {
  color-scheme: light;
  --bg: #f4efe6;
  --panel: rgba(255, 252, 246, 0.92);
  --panel-strong: #fffdf8;
  --text: #1f1a17;
  --muted: #6f6257;
  --line: rgba(111, 98, 87, 0.18);
  --accent: #225f4b;
  --accent-soft: rgba(34, 95, 75, 0.12);
  --warn: #8c5f2f;
  --shadow: 0 12px 40px rgba(54, 39, 24, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #f8f3ea 0%, #f1ebdf 100%);
  color: var(--text);
}

.chat-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.85);
  backdrop-filter: blur(10px);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.brand p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  white-space: nowrap;
}

.badge.online {
  background: var(--accent);
  color: #fff;
}

.badge.low {
  background: rgba(140, 95, 47, 0.12);
  color: var(--warn);
}

.ghost-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  background: var(--accent-soft);
  color: var(--accent);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  display: flex;
}

.msg.user {
  justify-content: flex-end;
}

.msg.agent {
  justify-content: flex-start;
}

.bubble {
  max-width: 82%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: grid;
  gap: 10px;
}

.msg.user .bubble {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.answer-text {
  margin: 0;
  line-height: 1.85;
  font-size: 16px;
  white-space: pre-wrap;
  word-break: break-word;
}

.yu-view {
  border-left: 3px solid rgba(34, 95, 75, 0.35);
  padding: 4px 0 4px 12px;
}

.yu-view-label {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 4px;
}

.tool-events {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tool-chip {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 10px;
}

.thinking summary,
.citations summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
}

.thinking-text {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.boundary-note {
  margin: 0;
  font-size: 13px;
  color: var(--warn);
}

.boundary-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-note {
  font-size: 12px;
  color: var(--warn);
}

.citation-item {
  margin-top: 8px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.citation-head {
  font-weight: 600;
  font-size: 14px;
}

.citation-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.citation-quote {
  margin-top: 6px;
  padding-left: 10px;
  border-left: 2px solid rgba(34, 95, 75, 0.22);
  line-height: 1.75;
  font-size: 14px;
}

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

.chips.indent {
  margin-left: 12px;
}

.chip {
  font: inherit;
  font-size: 13px;
  text-align: left;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--text);
}

.chip:hover {
  border-color: rgba(34, 95, 75, 0.4);
}

.chip.follow {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

.pending .bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.dots {
  display: inline-flex;
  gap: 4px;
}

.dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s infinite ease-in-out;
}

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

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

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

.composer-wrap {
  border-top: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.9);
  backdrop-filter: blur(10px);
  padding: 12px 20px 10px;
}

.composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
  line-height: 1.6;
  max-height: 180px;
}

.primary-btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px 20px;
  cursor: pointer;
  font: inherit;
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.disclaimer {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.share-banner {
  margin: 0 20px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.primary-btn.small {
  padding: 7px 14px;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 10;
}

.hidden {
  display: none;
}

@media (max-width: 640px) {
  .bubble {
    max-width: 94%;
  }

  .brand p {
    display: none;
  }
}
