:root {
  --bg: #fff5f7;
  --topbar: #ffffffcc;
  --her-bubble: #ffffff;
  --me-bubble: #ff8fb1;
  --me-text: #ffffff;
  --text: #33282c;
  --soft: #9b8e93;
  --line: #ffe1e9;
  --accent: #ff6f9c;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, system-ui, "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: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--topbar); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #ffd0dd, #ffb3c8);
  display: grid; place-items: center; font-size: 20px;
}
.who .name { font-weight: 600; font-size: 16px; line-height: 1.1; }
.who .status { font-size: 12px; color: var(--accent); }
.reset { margin-left: auto; border: none; background: none; font-size: 20px; color: var(--soft); cursor: pointer; padding: 6px; }

/* 消息区 */
.messages {
  flex: 1 1 auto; overflow-y: auto;
  padding: 16px 12px 8px;
  display: flex; flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.msg { display: flex; }
.msg.me { justify-content: flex-end; }
.bubble {
  max-width: 78%; padding: 9px 13px; border-radius: 18px;
  font-size: 15px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  box-shadow: 0 1px 1px #0000000a;
}
.msg.her .bubble { background: var(--her-bubble); border-bottom-left-radius: 5px; }
.msg.me .bubble { background: var(--me-bubble); color: var(--me-text); border-bottom-right-radius: 5px; }
.bubble.typing { color: var(--soft); }

/* 输入栏 */
.composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: #fffdfd; border-top: 1px solid var(--line);
  flex: 0 0 auto;
}
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 20px;
  padding: 9px 14px; font-size: 15px; font-family: inherit; line-height: 1.4;
  outline: none; background: #fff; max-height: 120px;
}
.composer textarea:focus { border-color: var(--accent); }
.composer button {
  border: none; background: var(--accent); color: #fff; border-radius: 20px;
  padding: 0 16px; height: 38px; font-size: 15px; font-weight: 600; cursor: pointer;
  flex: 0 0 auto;
}
.composer button:disabled { opacity: .5; }

/* 口令门 */
.gate { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 20; }
.hidden { display: none !important; }
.gate-card { text-align: center; padding: 28px; }
.gate-card h1 { font-size: 48px; margin: 0 0 6px; }
.gate-card p { color: var(--soft); margin: 0 0 16px; }
.gate-card input {
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px;
  font-size: 16px; width: 220px; outline: none; display: block; margin: 0 auto 12px;
}
.gate-card input:focus { border-color: var(--accent); }
.gate-card button {
  border: none; background: var(--accent); color: #fff; border-radius: 12px;
  padding: 11px 28px; font-size: 16px; font-weight: 600; cursor: pointer;
}
.gate-err { color: #e23a6a; font-size: 13px; margin-top: 10px; height: 16px; }
