:root {
  --bg: #0b0f1a;
  --bg-soft: #131a2a;
  --line: #1f2a40;
  --text: #e8edf8;
  --muted: #8593ad;
  --me: #2f6df6;
  --me-text: #ffffff;
  --her: #1a2438;
  --accent: #7fb2ff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* 关键：下面 .login/.typing 都设了 display，会盖掉浏览器默认的 [hidden]{display:none}，
   必须显式声明，否则登录框永远盖在页面上、点了也进不去。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(13, 18, 32, .88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--bg-soft); object-fit: cover; }
.who { display: flex; flex-direction: column; line-height: 1.25; }
.name { font-weight: 600; font-size: 16px; }
.state { font-size: 12px; color: var(--muted); }

.log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.row { display: flex; }
.row.me { justify-content: flex-end; }
.row.her { justify-content: flex-start; }

.bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 18px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}
.me .bubble { background: var(--me); color: var(--me-text); border-bottom-right-radius: 6px; }
.her .bubble { background: var(--her); color: var(--text); border-bottom-left-radius: 6px; border: 1px solid var(--line); }
.bubble time { display: block; margin-top: 4px; font-size: 11px; opacity: .55; }

.typing {
  display: flex;
  gap: 5px;
  padding: 0 22px 6px;
  color: var(--muted);
}
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .18s; }
.typing span:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(13, 18, 32, .94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 132px;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  outline: none;
}
.composer textarea:focus { border-color: #2f4a78; }
.composer button {
  width: 42px; height: 42px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: var(--me);
  color: #fff;
  display: grid;
  place-items: center;
}
.composer button:disabled { opacity: .45; }
/* 发图按钮：跟发送键区分开，用底色而不是蓝色 */
.composer button.pick {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--muted);
}
/* 气泡里的图片：别撑破屏幕，圆角贴合气泡 */
.bubble .shot {
  display: block;
  max-width: 100%;
  width: 220px;
  border-radius: 12px;
  margin-bottom: 2px;
}
.bubble .txt { white-space: pre-wrap; }

.login {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 24px;
}
.login-card { width: 100%; max-width: 320px; text-align: center; }
.login-icon { width: 96px; height: 96px; border-radius: 24px; }
.login h1 { margin: 12px 0 4px; font-size: 22px; }
.login p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.login input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  text-align: center;
  letter-spacing: .08em;
}
.login button {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border: 0;
  border-radius: 12px;
  background: var(--me);
  color: #fff;
  font: inherit;
  font-weight: 600;
}
.err { margin-top: 10px; color: #ff7a7a; font-size: 13px; min-height: 18px; }
