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

:root {
  --bg: #ededed;              /* 微信经典灰底 */
  --header-bg: #ededed;
  --bubble-bot: #ffffff;      /* 对方白泡 */
  --bubble-user: #95ec69;     /* 我方绿泡 */
  --text: #191919;
  --muted: #9a9a9a;
  --border: #dcdcdc;
  --navy: #2e2e2e;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  display: flex;
  justify-content: center;
}

.chat-wrap {
  width: 100%;
  max-width: 520px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ===== 顶栏（微信风） ===== */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.avatar {
  width: 40px; height: 40px;
  border-radius: 8px;          /* 微信圆角方形头像 */
  object-fit: cover;
  background: #fff;
}
.header-title { font-size: 17px; font-weight: 600; color: var(--text); }
.header-sub { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.dot-online {
  width: 7px; height: 7px; border-radius: 50%;
  background: #10d06a; display: inline-block;
}

/* ===== 聊天区 ===== */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.time-divider {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
  background: rgba(0,0,0,.04);
  padding: 2px 10px;
  border-radius: 4px;
}

.msg { display: flex; align-items: flex-start; gap: 10px; }
.msg.user { justify-content: flex-end; }

.msg-avatar {
  width: 36px; height: 36px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #fff;
  margin-top: 2px;
}
/* 用户消息不用头像，占位对齐 */
.msg.user .msg-avatar { visibility: hidden; }

.bubble {
  max-width: 72%;
  padding: 10px 13px;
  border-radius: 8px;
  font-size: 15.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}
.msg.bot .bubble {
  background: var(--bubble-bot);
  color: var(--text);
  /* 微信小三角 */
}
.msg.bot .bubble::before {
  content: "";
  position: absolute;
  left: -5px; top: 13px;
  width: 10px; height: 10px;
  background: var(--bubble-bot);
  transform: rotate(45deg);
  border-radius: 2px;
}
.msg.user .bubble {
  background: var(--bubble-user);
  color: var(--text);
}
.msg.user .bubble::after {
  content: "";
  position: absolute;
  right: -5px; top: 13px;
  width: 10px; height: 10px;
  background: var(--bubble-user);
  transform: rotate(45deg);
  border-radius: 2px;
}

/* 打字指示 */
.typing .bubble { display: flex; gap: 4px; align-items: center; padding: 13px 15px; }
.typing .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #bbb; animation: blink 1.2s infinite;
}
.typing .dot:nth-child(2) { animation-delay: .2s; }
.typing .dot:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{opacity:.3} 40%{opacity:1} }

/* ===== 输入区（微信风） ===== */
.chat-input {
  display: flex;
  gap: 10px;
  padding: 9px 12px;
  background: #f7f7f7;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input input {
  flex: 1;
  border: none;
  background: #fff;
  border-radius: 6px;
  padding: 11px 14px;
  font-size: 15.5px;
  outline: none;
  box-shadow: inset 0 0 0 1px var(--border);
}
.chat-input input:focus { box-shadow: inset 0 0 0 1.5px #0abd54; }
.chat-input button {
  border: none;
  background: #0abd54;          /* 微信绿按钮 */
  color: #fff;
  font-size: 15px;
  padding: 0 22px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.chat-input button:active { background: #0a9e48; }
.chat-input button:disabled { background: #c8e8d3; }
