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

:root {
  --bg: #ededed;
  --header-bg: #2e2e2e;
  --header-text: #ffffff;
  --bubble-user: #95ec69;
  --bubble-ai: #ffffff;
  --text: #1a1a1a;
  --text-dim: #999999;
  --send: #07c160;
  --avatar-user: #4a90d9;
  --avatar-ai: #07c160;
}

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: #d6d6d6;
  display: flex;
  justify-content: center;
  align-items: center;
}

.app {
  width: 100%;
  max-width: 720px;
  height: 100vh;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

@media (min-width: 720px) {
  .app {
    height: 92vh;
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  }
}

/* 顶栏 */
.chat-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px;
  background: var(--header-bg);
  color: var(--header-text);
  font-size: 17px;
  font-weight: 500;
}

.clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #c8c8c8;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
}

.clear-btn:hover {
  color: #ff7a7a;
}

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

.msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

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

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

/* 头像 */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  user-select: none;
}

.avatar-user {
  background: var(--avatar-user);
  order: 2;
}

.avatar-ai {
  background: var(--avatar-ai);
}

/* 气泡 */
.bubble {
  max-width: 68%;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
  color: var(--text);
}

.msg.user .bubble {
  background: var(--bubble-user);
  order: 1;
}

.msg.ai .bubble {
  background: var(--bubble-ai);
}

/* 气泡小三角 */
.bubble::before {
  content: "";
  position: absolute;
  top: 14px;
  width: 0;
  height: 0;
  border: 6px solid transparent;
}

.msg.user .bubble::before {
  right: -12px;
  border-left-color: var(--bubble-user);
}

.msg.ai .bubble::before {
  left: -12px;
  border-right-color: var(--bubble-ai);
}

/* 时间分隔 */
.time-divider {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  margin: 4px 0;
  user-select: none;
}

/* 输入栏 */
.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #f7f7f7;
  border-top: 1px solid #e2e2e2;
}

.composer input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e2e2e2;
  border-radius: 6px;
  background: #fff;
  font-size: 16px;
  outline: none;
  color: var(--text);
}

.composer input:focus {
  border-color: var(--send);
}

.composer button {
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  background: var(--send);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

.composer button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
