:root {
  --primary: #e64a3b;
  --page-bg: #ededed;
  --bot-bubble: #ffffff;
  --user-bubble: #e64a3b;
  --button-bg: #e64a3b;
  --button-text: #ffffff;
  --button-radius: 24px;
  --font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

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

/* 隐藏滚动条（保留滚动功能） */
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  background: var(--page-bg);
  font-family: var(--font-family);
  color: #1a1a1a;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- 布局 ---------- */

.app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: var(--page-bg);
  overflow: hidden;
}

/* ---------- 标题栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--primary);
  color: #ffffff;
}

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.35);
  flex: 0 0 32px;
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------- 聊天区 ---------- */

.chat {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.msg-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 12px 20px;
}

.row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: pop 0.28s ease both;
}

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

.avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #d9d9d9;
}

.col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
}

.bubble {
  background: var(--bot-bubble);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.75;
  word-break: break-word;
  overflow-wrap: anywhere;
  width: 80%;
  max-width: 680px;
}

.row.user .bubble {
  background: var(--user-bubble);
  color: #ffffff;
  width: 80%;
  max-width: 680px;
}

.hl {
  color: var(--primary);
  font-weight: 600;
}

/* ---------- 正在输入 ---------- */

.bubble.typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 15px 16px;
  min-height: 20px;
}

.bubble.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b0b0b0;
  animation: bounce 1.2s infinite ease-in-out;
}

.bubble.typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.bubble.typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.55;
  }
  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

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

/* ---------- 选项按钮（气泡内，两列网格） ---------- */

.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 80%;
  max-width: 680px;
}

.options.is-hidden {
  display: none;
}

.opt-btn {
  width: 100%;
  min-height: 38px;
  padding: 8px 14px;
  border: none;
  border-radius: 999px;
  background: var(--button-bg);
  color: var(--button-text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.opt-btn:active {
  transform: scale(0.96);
}

/* ---------- 卡片（独立卡片式气泡） ---------- */

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 80%;
  max-width: 680px;
  min-width: 0;
  padding: 14px;
  background: #ffffff;
  border: 1px solid #e6e6e6;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}

.card-img {
  width: calc(100% + 28px);
  margin: -14px -14px 0;
  border-radius: 14px 14px 0 0;
  display: block;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  word-break: break-word;
}

.card-title-link {
  color: var(--primary);
  text-decoration: underline;
}

.card-desc {
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.card-more {
  font-size: 14px;
  color: var(--primary);
  text-decoration: none;
}

.card-btn {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  min-height: 44px;
  border-radius: var(--button-radius);
  background: var(--primary);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: transform 0.12s ease;
}

.card-btn:active {
  transform: scale(0.97);
}

/* ---------- 图片消息 ---------- */

.img-msg {
  display: block;
  max-width: 75%;
  border-radius: 8px;
}

/* ---------- 底部输入栏 ---------- */

.input-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: #f7f7f7;
  border-top: 1px solid #e3e3e3;
}

.input-bar input {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  border: 1px solid #dddddd;
  border-radius: 22px;
  background: #ffffff;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}

.input-bar input:focus {
  border-color: var(--primary);
}

.input-bar button {
  flex: 0 0 auto;
  min-width: 76px;
  height: 44px;
  padding: 0 18px;
  border: none;
  border-radius: 22px;
  background: var(--primary);
  color: #ffffff;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.input-bar button:active {
  transform: scale(0.96);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  top: 16%;
  left: 50%;
  transform: translateX(-50%);
  max-width: 80%;
  padding: 10px 18px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 99;
}

.toast.show {
  opacity: 1;
}
