* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #eef1f5;
  color: #1f2937;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
button { font-family: inherit; cursor: pointer; }
.app {
  width: min(1120px, calc(100vw - 32px));
  height: calc(100vh - 32px);
  margin: 16px auto;
  background: #f6f7f9;
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(15, 23, 42, .12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  height: 76px;
  flex: 0 0 auto;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #60a5fa);
  color: #fff;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: .5px;
}
.logo.big { width: 52px; height: 52px; border-radius: 16px; font-size: 18px; }
.brand-text { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 20px; margin: 0; font-weight: 700; }
.badge {
  font-size: 12px;
  color: #059669;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  padding: 2px 8px;
}
.userbox { display: flex; align-items: center; gap: 12px; color: #475569; font-size: 14px; }
.ghost {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  border-radius: 8px;
  padding: 7px 12px;
}
.ghost:hover { background: #f9fafb; }
.banner {
  flex: 0 0 auto;
  margin: 10px 24px 0;
  padding: 10px 14px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  border-radius: 10px;
  font-size: 13px;
}
.chat {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 22px 24px;
}
.messages { width: min(900px, 100%); margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }
.avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}
.msg.user .avatar { background: #2563eb; border-color: #2563eb; color: #fff; font-size: 12px; font-weight: 700; }
.bubble {
  max-width: min(78%, 760px);
  padding: 12px 15px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
}
.msg.user .bubble {
  background: #2f8bfd;
  border-color: #2f8bfd;
  color: #fff;
}
.msg.system { justify-content: center; }
.msg.system .bubble {
  background: transparent;
  border: 0;
  color: #94a3b8;
  font-size: 12px;
  box-shadow: none;
  padding: 2px 0;
}
.meta { font-size: 12px; color: #94a3b8; margin-bottom: 4px; }
.quickbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px 0;
}
.chip {
  border: 1px solid #bbf7d0;
  background: #ecfdf5;
  color: #047857;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
}
.chip:hover { background: #d1fae5; }
.hint { color: #94a3b8; font-size: 12px; margin-left: 4px; }
.composer {
  flex: 0 0 auto;
  display: flex;
  gap: 12px;
  padding: 14px 24px 20px;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid #dbe1e8;
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.5;
  outline: none;
  min-height: 54px;
}
.composer textarea:focus { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(96, 165, 250, .15); }
.composer button {
  border: 0;
  background: #2f8bfd;
  color: #fff;
  border-radius: 10px;
  height: 42px;
  padding: 0 22px;
  font-size: 14px;
}
.composer button:disabled { opacity: .5; cursor: default; }
.mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.mask[hidden] { display: none; }
.login-card {
  width: min(430px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .3);
}
.login-head { display: flex; gap: 14px; align-items: center; margin-bottom: 20px; }
.login-head h2 { margin: 0 0 4px; font-size: 19px; }
.login-head p { margin: 0; color: #64748b; font-size: 12px; line-height: 1.5; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #475569; }
.login-card input {
  height: 42px;
  border: 1px solid #dbe1e8;
  border-radius: 9px;
  padding: 0 12px;
  font-size: 14px;
  outline: none;
}
.login-card input:focus { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(96, 165, 250, .15); }
.login-card button[type="submit"] {
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: #2f8bfd;
  color: #fff;
  font-size: 15px;
}
.login-card button[type="submit"]:disabled { opacity: .6; cursor: default; }
.error { color: #dc2626; font-size: 13px; min-height: 18px; }
@media (max-width: 640px) {
  .app { width: 100vw; height: 100vh; margin: 0; border-radius: 0; }
  .topbar, .chat, .quickbar, .composer { padding-left: 14px; padding-right: 14px; }
  .bubble { max-width: 84%; }
  .hint { display: none; }
}
