/* 云朵咖啡 · 智能客服 —— 移动优先简洁风格 */
:root {
  --bg: #faf7f2;
  --header: #6f4e37;
  --header-dark: #5a3e2c;
  --bubble-bot: #ffffff;
  --bubble-user: #6f4e37;
  --text: #2b2119;
  --text-sub: #8a7a6a;
  --border: #e8dfd3;
  --accent: #c98a4b;
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* 顶部栏（窄屏自动换行，防止按钮溢出） */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;               /* iPhone 窄屏时按钮换行到第二行 */
  row-gap: 8px;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: linear-gradient(135deg, var(--header), var(--header-dark));
  color: #fff;
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;                  /* 允许收缩，配合省略号 */
  flex: 1 1 auto;
}
.brand-logo { font-size: 26px; flex-shrink: 0; }
.brand h1 {
  font-size: 16px; font-weight: 600; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-sub {
  font-size: 11px; opacity: 0.8; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header-actions {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; margin-left: auto;
}
.btn-ghost {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
}
.btn-ghost:active { background: rgba(255,255,255,0.25); }

/* 消息区 */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}
.messages { display: flex; flex-direction: column; gap: 12px; }

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

.bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-user .bubble {
  background: var(--bubble-user);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-bot .bubble {
  background: var(--bubble-bot);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* 版本徽标（发版时与 ?v=N、SW CACHE_NAME 同步） */
.app-version {
  font-size: 0.7rem; font-weight: 400; margin-left: 8px;
  color: rgba(255,255,255,0.75);
  white-space: nowrap; user-select: none; vertical-align: middle;
}

/* 输入中动画 */
.typing { display: flex; gap: 5px; padding: 10px 14px; background: var(--bubble-bot); border: 1px solid var(--border); border-radius: 16px; border-bottom-left-radius: 4px; width: fit-content; }
.typing.hidden { display: none; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* 底部输入栏（上下内边距统一，不加底部安全区——避免 iPhone 15 Pro 按钮下方多余空白；头部顶部安全区保留） */
.input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 15px;
  outline: none;
  background: var(--bg);
}
#input:focus { border-color: var(--accent); }
.btn-send {
  border: none;
  border-radius: 999px;
  background: var(--header);
  color: #fff;
  font-size: 15px;
  padding: 0 20px;
  cursor: pointer;
}
.btn-send:disabled { background: #c9b9a8; cursor: not-allowed; }

/* 错误提示 */
.bubble.error { background: #fdecea; color: #b3261e; border-color: #f5c6c0; }

/* 商品卡片列表（对话气泡样式：限宽不占满，2 列紧凑） */
.cards-block {
  width: fit-content;
  max-width: 320px;               /* 与文字气泡的对话感一致 */
  background: var(--bubble-bot);
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}
.product-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
}
.product-emoji { font-size: 30px; line-height: 1.2; }
.product-name { font-size: 13px; font-weight: 600; margin: 5px 0 2px; word-break: break-all; }
.product-price { color: var(--accent); font-weight: 700; font-size: 14px; }
.product-desc { font-size: 11px; color: var(--text-sub); margin-top: 3px; line-height: 1.35; }
