* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #e7ebf2;
  color: #1c1e21;
}
.hidden { display: none !important; }
.screen { height: 100dvh; display: flex; flex-direction: column; }

/* ---------- 登录 ---------- */
#login { align-items: center; justify-content: center; background: linear-gradient(160deg, #6a8dff 0%, #8f6aff 100%); }
.card {
  background: #fff;
  padding: 34px 30px;
  border-radius: 16px;
  width: min(340px, 88vw);
  box-shadow: 0 18px 50px rgba(30, 40, 90, .25);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card h1 { margin: 0; font-size: 26px; text-align: center; letter-spacing: 2px; }
.card .sub { margin: -6px 0 8px; text-align: center; color: #8a90a0; font-size: 13px; }
.card input { padding: 11px 12px; border: 1px solid #d7dbe4; border-radius: 10px; font-size: 15px; outline: none; }
.card input:focus { border-color: #6a8dff; }
.card button { padding: 11px; border: 0; border-radius: 10px; background: #5b7cfa; color: #fff; font-size: 15px; cursor: pointer; }
.card button:disabled { opacity: .6; }
.err { color: #d64541; font-size: 13px; text-align: center; }

/* ---------- 聊天 ---------- */
#chat header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid #e3e6ee;
}
#chat .title { font-weight: 700; font-size: 16px; }
#chat .who { flex: 1; color: #8a90a0; font-size: 13px; }
#chat header button { border: 0; background: #f0f2f7; color: #666; border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px; }

#list { flex: 1; overflow-y: auto; padding: 14px 12px 10px; display: flex; flex-direction: column; }
.chip { text-align: center; color: #98a0ae; font-size: 12px; margin: 14px 0 10px; }
.msg { display: flex; flex-direction: column; margin: 8px 0; max-width: 76%; }
.msg.other { align-self: flex-start; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg .name { font-size: 12px; color: #98a0ae; margin: 0 4px 3px; }
.bubble {
  position: relative;
  padding: 9px 12px 18px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
}
.msg.other .bubble { background: #fff; border-top-left-radius: 4px; box-shadow: 0 1px 2px rgba(0, 0, 0, .05); }
.msg.me .bubble { background: linear-gradient(135deg, #5b7cfa, #7a5cff); color: #fff; border-top-right-radius: 4px; }
.bubble .text { white-space: pre-wrap; }
.bubble .time { position: absolute; right: 10px; bottom: 4px; font-size: 10px; opacity: .55; }
.bubble img {
  display: block;
  max-width: min(260px, 60vw);
  max-height: 320px;
  border-radius: 8px;
  cursor: zoom-in;
  margin-bottom: 4px;
}
.empty { text-align: center; color: #98a0ae; margin-top: 40px; font-size: 14px; }

footer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid #e3e6ee;
}
footer button { border: 0; border-radius: 10px; cursor: pointer; }
#imgBtn { background: #f0f2f7; padding: 9px 12px; font-size: 18px; }
#sendBtn { background: #5b7cfa; color: #fff; padding: 10px 16px; font-size: 14px; }
#input {
  flex: 1;
  resize: none;
  border: 1px solid #dfe3ec;
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.4;
  max-height: 120px;
  outline: none;
}
#input:focus { border-color: #6a8dff; }

#toast {
  position: fixed;
  left: 50%; bottom: 90px;
  transform: translateX(-50%);
  background: rgba(20, 22, 30, .85);
  color: #fff;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 9;
  max-width: 80vw;
}
