:root {
  --bg: #0a0b14;
  --card: rgba(22, 24, 38, 0.62);
  --stroke: rgba(255, 255, 255, 0.08);
  --text: #eef1f8;
  --muted: #9aa3b8;
  --accent: #7c6cff;
  --accent2: #22d3ee;
  --user1: #7c6cff;
  --user2: #c44cff;
  --radius: 22px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
  position: relative;
}

.aurora {
  position: fixed;
  inset: -30%;
  z-index: 0;
  background:
    radial-gradient(40% 50% at 20% 25%, rgba(124, 108, 255, 0.35), transparent 60%),
    radial-gradient(45% 55% at 80% 30%, rgba(34, 211, 238, 0.28), transparent 60%),
    radial-gradient(50% 50% at 55% 85%, rgba(196, 76, 255, 0.22), transparent 60%);
  filter: blur(40px);
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(-4%, 3%, 0) scale(1.08); }
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  height: min(88vh, 800px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

/* 头部 */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.02);
}
.avatar {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 6px 18px rgba(124, 108, 255, 0.4);
}
.avatar.sm {
  width: 30px;
  height: 30px;
  font-size: 0.8rem;
  box-shadow: none;
}
.who { flex: 1; min-width: 0; }
.name {
  font-weight: 650;
  font-size: 1.02rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  color: #ffd9f0;
  background: rgba(196, 76, 255, 0.14);
  border: 1px solid rgba(196, 76, 255, 0.3);
}
.status {
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
.reset {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--stroke);
  padding: 7px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.reset:hover { color: #fff; border-color: rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.05); }

/* 消息区 */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 999px; }

.row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: rise 0.35s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.row.user { flex-direction: row-reverse; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.bubble {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 0.93rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.row.bot .bubble {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke);
  border-bottom-left-radius: 6px;
  color: var(--text);
}
.row.user .bubble {
  background: linear-gradient(135deg, var(--user1), var(--user2));
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 8px 22px rgba(124, 108, 255, 0.3);
}

.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* 输入区 */
.composer {
  display: flex;
  gap: 10px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.02);
}
.composer input {
  flex: 1;
  padding: 13px 16px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.composer input::placeholder { color: var(--muted); }
.composer input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.18);
}
.send {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 8px 22px rgba(124, 108, 255, 0.4);
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.send:hover { transform: scale(1.06); }
.send:active { transform: scale(0.94); }
.send:disabled { opacity: 0.5; cursor: default; transform: none; }

@media (max-width: 520px) {
  body { padding: 0; }
  .app { max-width: 100%; height: 100vh; border-radius: 0; border: none; }
}
