/* 手机优先；颜色跟随系统深浅色 */
:root {
  --bg: #f6f6f8;
  --panel: #ffffff;
  --text: #1c1c1e;
  --muted: #8a8a90;
  --her: #ffffff;
  --me: #ff6b8b;
  --me-text: #ffffff;
  --line: #e4e4e8;
  --warn: #fff4d6;
  --warn-text: #6b5200;
  --accent: #ff6b8b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0d;
    --panel: #17171b;
    --text: #ececf0;
    --muted: #8a8a92;
    --her: #232329;
    --me: #c2456a;
    --me-text: #ffffff;
    --line: #2a2a30;
    --warn: #3a3118;
    --warn-text: #f0d98a;
    --accent: #ff7d9a;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, "PingFang SC", "Noto Sans CJK SC", sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button {
  background: var(--accent); color: #fff; border: 0; border-radius: 18px;
  padding: 8px 16px; cursor: pointer;
}
a { color: var(--accent); word-break: break-all; }

#login {
  max-width: 360px; margin: 0 auto; padding: 20vh 24px 0;
  display: flex; flex-direction: column; gap: 12px;
}
#login h1 { margin: 0; text-align: center; }
#login input, #composer textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.error { color: #d33; min-height: 1.5em; margin: 0; }

#chat { display: flex; flex-direction: column; height: 100%; height: 100dvh; }
#chat header {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
#chat header strong { flex: 1; }
#chat header button { padding: 4px 12px; font-size: 14px; }
#logout { background: transparent; color: var(--muted); }
#enable-push.link { background: transparent; color: var(--muted); text-decoration: underline; font-size: 12px; }
.banner { background: #fde8e8; color: #8a1c1c; padding: 8px 14px; font-size: 14px; }
@media (prefers-color-scheme: dark) { .banner { background: #3a1a1a; color: #f3b4b4; } }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.on { background: #34c759; }

#log { flex: 1; overflow-y: auto; padding: 12px 12px 4px; -webkit-overflow-scrolling: touch; }
#load-more {
  display: block; margin: 0 auto 12px; background: transparent; color: var(--muted);
  border: 1px solid var(--line);
}
#messages { display: flex; flex-direction: column; gap: 8px; }

.bubble {
  max-width: 82%; padding: 8px 12px; border-radius: 16px; white-space: pre-wrap;
  word-break: break-word; background: var(--her); border: 1px solid var(--line);
}
.bubble.me { align-self: flex-end; background: var(--me); color: var(--me-text); border-color: transparent; }
.bubble.me a { color: var(--me-text); }
.bubble.her { align-self: flex-start; }
.bubble img { display: block; max-width: 100%; border-radius: 10px; margin-top: 6px; }
.time { font-size: 11px; color: var(--muted); margin-top: 2px; }
.bubble.me .time { color: rgba(255, 255, 255, .75); }
.notice {
  align-self: center; max-width: 92%; background: var(--warn); color: var(--warn-text);
  border-radius: 10px; padding: 6px 12px; font-size: 14px; white-space: pre-wrap; word-break: break-word;
}
.notice a { color: inherit; font-weight: 600; }
.call {
  align-self: center; background: var(--panel); border: 2px solid var(--accent);
  border-radius: 14px; padding: 12px 18px; text-align: center;
}
.call small { display: block; color: var(--muted); }

#composer {
  display: flex; gap: 8px; padding: 8px 12px; align-items: flex-end;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
}
#composer textarea { flex: 1; resize: none; max-height: 30vh; }
