:root {
  --pink: #ec4899;
  --pink-dark: #db2777;
  --bg: #fdf2f8;
  --bubble-her: #ffffff;
  --bubble-me: #ec4899;
  --text: #3b2f36;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

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

/* ---------- 顶部栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  background: linear-gradient(135deg, var(--pink), var(--pink-dark));
  color: #fff;
}
.topbar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #fff2;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.topbar-title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
}
.icon-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
}

/* ---------- 未配置提示 ---------- */
.setup-banner {
  display: none;
  align-items: center;
  gap: 8px;
  background: #fbbf24;
  color: #7c2d12;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
}

/* ---------- 消息区 ---------- */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}
.msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 100%;
}
.msg.user { flex-direction: row-reverse; }
.avatar {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #fce7f3;
  color: var(--pink-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  font-weight: 600;
}
.msg.user .avatar {
  background: var(--pink);
  color: #fff;
}
.bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--bubble-her);
  line-height: 1.5;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.msg.user .bubble {
  background: var(--bubble-me);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.assistant .bubble {
  border-bottom-left-radius: 4px;
}

/* ---------- 正在输入 ---------- */
.typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
}
.typing-bubble {
  display: flex;
  gap: 4px;
  padding: 14px;
}
.typing-bubble span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #d6a8c2;
  animation: blink 1.2s infinite ease-in-out;
}
.typing-bubble span:nth-child(2) { animation-delay: .2s; }
.typing-bubble span:nth-child(3) { animation-delay: .4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: .3; }
  40% { opacity: 1; }
}

/* ---------- 输入区 ---------- */
.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
  background: #fff;
  border-top: 1px solid #f1e6ec;
}
.input-bar textarea {
  flex: 1;
  resize: none;
  border: 1px solid #ecd9e5;
  border-radius: 18px;
  padding: 10px 14px;
  font-size: 15px;
  font-family: inherit;
  max-height: 120px;
  outline: none;
}
.input-bar textarea:focus { border-color: var(--pink); }
#send-btn {
  flex: none;
  background: var(--pink);
  color: #fff;
  border: none;
  border-radius: 18px;
  padding: 10px 18px;
  font-size: 15px;
  cursor: pointer;
}
#send-btn:disabled { opacity: .5; }

/* ---------- 设置面板 ---------- */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
}
.settings-overlay.open { display: flex; }
.settings-card {
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 18px 20px calc(env(safe-area-inset-bottom) + 18px);
}
.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.settings-head h2 { margin: 0; font-size: 18px; }
.settings-card h3 {
  margin: 18px 0 8px;
  font-size: 14px;
  color: var(--pink-dark);
  border-left: 3px solid var(--pink);
  padding-left: 8px;
}
.settings-card label {
  display: block;
  font-size: 13px;
  color: #8a7a83;
  margin: 10px 0 4px;
}
.settings-card input,
.settings-card textarea {
  width: 100%;
  border: 1px solid #ecd9e5;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}
.settings-card input:focus,
.settings-card textarea:focus { border-color: var(--pink); }
.settings-card .icon-btn { color: var(--text); }
.save-btn {
  width: 100%;
  margin-top: 18px;
  background: var(--pink);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-size: 16px;
  cursor: pointer;
}
