* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: #f3f0ff;
  color: #2b2b3a;
}
.app {
  max-width: 520px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: 0 0 24px rgba(120, 90, 220, 0.12);
}
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #8a6cf0, #6c5ce7);
  color: #fff;
}
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #ffd86b;
  color: #6c5ce7;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.title .name { font-weight: 700; font-size: 16px; }
.title .status { font-size: 12px; opacity: 0.85; }
.admin-link {
  margin-left: auto;
  color: #fff;
  font-size: 13px;
  text-decoration: none;
  background: rgba(255,255,255,0.18);
  padding: 5px 10px;
  border-radius: 14px;
}
.admin-link:hover { background: rgba(255,255,255,0.3); }
#newchat { margin-left: auto; border: none; cursor: pointer; font-family: inherit; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #faf8ff;
}
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg.bot { justify-content: flex-start; }
.bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user .bubble {
  background: #6c5ce7;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.bot .bubble {
  background: #fff;
  color: #2b2b3a;
  border: 1px solid #ece6ff;
  border-bottom-left-radius: 4px;
}
.msg.bot { flex-direction: column; align-items: flex-start; gap: 4px; }
.msg.bot .bubble { margin-right: auto; }
.typing { opacity: 0.6; font-style: italic; }

.inputbar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #ece6ff;
  background: #fff;
}
#input {
  flex: 1;
  resize: none;
  border: 1px solid #ddd;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  max-height: 120px;
  outline: none;
}
#input:focus { border-color: #6c5ce7; }
#send {
  border: none;
  background: #6c5ce7;
  color: #fff;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 15px;
  cursor: pointer;
}
#send:hover { background: #5a4bd6; }
#send:disabled { opacity: 0.5; cursor: default; }
