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

:root {
  --green: #07C160;
  --green-dark: #06AD56;
  --bg: #EDEDED;
  --white: #FFFFFF;
  --bubble-me: #95EC69;
  --bubble-other: #FFFFFF;
  --text: #353535;
  --text-secondary: #888;
  --border: #D9D9D9;
  --input-bg: #F7F7F7;
}

body {
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

#app {
  width: 100%;
  max-width: 500px;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== 聊天区域 ===== */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

/* 时间标签 */
.time-tag {
  text-align: center;
  margin: 12px 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* 消息行 */
.message {
  display: flex;
  margin-bottom: 14px;
  animation: fadeIn .25s ease;
}
@keyframes fadeIn {
  from { opacity:0; transform:translateY(6px); }
  to   { opacity:1; transform:translateY(0); }
}

/* 头像 */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.avatar.me {
  background: #07C160;
  color: #fff;
  margin-left: 10px;
  order: 2;
}
.avatar.other {
  background: #EDEDED;
  margin-right: 10px;
  order: 0;
}

/* 气泡 */
.bubble-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 70%;
  gap: 2px;
}

.message.me {
  justify-content: flex-end;
}
.message.other {
  justify-content: flex-start;
}
.message.me .bubble-wrapper {
  order: 1;
  align-items: flex-end;
}
.message.other .bubble-wrapper {
  order: 1;
  align-items: flex-start;
}

.bubble {
  padding: 10px 14px;
  font-size: 16px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
  border-radius: 4px;
}
.bubble.me {
  background: var(--bubble-me);
  color: #000;
  border-radius: 4px;
}
.bubble.other {
  background: var(--bubble-other);
  color: var(--text);
  border-radius: 4px;
  box-shadow: 0 1px 1px rgba(0,0,0,.04);
}

/* 气泡小三角 */
.bubble.me::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 12px;
  border-left: 6px solid var(--bubble-me);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}
.bubble.other::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 12px;
  border-right: 6px solid var(--bubble-other);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

/* 输入中动画 */
.typing {
  padding: 8px 14px;
  flex-shrink: 0;
}
.typing.hidden { display: none; }
.typing-bubble {
  display: inline-flex;
  gap: 4px;
  background: var(--bubble-other);
  padding: 12px 16px;
  border-radius: 4px;
  box-shadow: 0 1px 1px rgba(0,0,0,.04);
}
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #BDBDBD;
  animation: bounce 1.4s infinite ease-in-out;
}
.dot:nth-child(2) { animation-delay: .2s; }
.dot:nth-child(3) { animation-delay: .4s; }
@keyframes bounce {
  0%,80%,100% { transform:scale(.6); }
  40% { transform:scale(1); }
}

/* ===== 底部输入栏 ===== */
.input-bar {
  background: var(--input-bg);
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.input-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
}
#input {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  border: none;
  border-radius: 4px;
  font-size: 15px;
  outline: none;
  background: var(--white);
  color: var(--text);
}
#input::placeholder { color: #B2B2B2; }
#sendBtn {
  height: 38px;
  padding: 0 18px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
#sendBtn:active { background: var(--green-dark); }
#sendBtn:disabled {
  background: #C8C8C8;
  color: #888;
}

/* 快捷提问 */
.quick-bar {
  display: flex;
  gap: 8px;
  padding: 8px 14px 0;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.quick-bar span {
  font-size: 13px;
  color: #576B95;
  background: var(--white);
  padding: 6px 14px;
  border-radius: 14px;
  border: 1px solid #E5E5E5;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.quick-bar span:active { background: #EAEAEA; }

/* 空状态 */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  gap: 10px;
}
.empty-state .emoji { font-size: 56px; }
.empty-state h2 { font-size: 18px; color: var(--text); }
.empty-state p { font-size: 14px; text-align: center; line-height: 1.5; }
