:root {
  --bg: #0b1020;
  --card: rgba(17, 24, 39, 0.9);
  --line: rgba(148, 163, 184, 0.2);
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #2563eb;
  --accent: #ec4899;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at 0 0, #1e1b4b, var(--bg));
  color: var(--text);
}

#app {
  min-height: 100vh;
  padding: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.title { font-size: 32px; font-weight: 700; color: #f9a8d4; }
.subtitle { font-size: 14px; color: var(--muted); margin-top: 4px; }

.btn {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  color: #dbeafe;
  background: rgba(37, 99, 235, 0.25);
  cursor: pointer;
}

.section { padding: 14px; margin-bottom: 12px; }
.section-title { font-size: 13px; color: #cbd5e1; margin-bottom: 10px; }

.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.muted { color: var(--muted); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-height: 52vh;
  overflow: auto;
}

.persona {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(30, 41, 59, 0.45);
  cursor: pointer;
}

.persona.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.persona-head { display: flex; gap: 8px; align-items: center; }
.emoji {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(71, 85, 105, 0.7);
  display: grid;
  place-items: center;
}

.name { font-size: 14px; font-weight: 600; }
.detail { font-size: 12px; color: var(--muted); }

.tag {
  display: inline-block;
  margin-right: 6px;
  margin-top: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(71, 85, 105, 0.5);
  color: #cbd5e1;
}

.type {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
}

.type.bot { background: rgba(6, 182, 212, 0.18); color: #67e8f9; }
.type.human { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }

.start {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 13px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(90deg, #ec4899, #7c3aed);
}

.start:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.chat {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto auto;
  gap: 10px;
  height: calc(100vh - 40px);
}

.chat-top {
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.back { cursor: pointer; color: #cbd5e1; }
.chat-meta { flex: 1; min-width: 0; }

.status {
  font-size: 12px;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

.status.ok {
  color: #86efac;
  background: rgba(22, 163, 74, 0.2);
}

.status.bad {
  color: #fecaca;
  background: rgba(220, 38, 38, 0.2);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 8px;
}

.tab {
  text-align: center;
  padding: 8px;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  background: rgba(99, 102, 241, 0.35);
  color: #fff;
}

.panel {
  padding: 10px 12px;
  font-size: 13px;
  color: #cbd5e1;
}

.messages {
  padding: 12px;
  overflow: auto;
}

.msg {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
}

.msg.user { align-items: end; }
.msg.system { align-items: start; }
.msg.bot { align-items: start; }

.bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(51, 65, 85, 0.8);
  line-height: 1.45;
}

.msg.user .bubble { background: var(--primary); }
.msg.system .bubble {
  background: rgba(168, 85, 247, 0.25);
  color: #f3e8ff;
}

.time {
  margin-top: 3px;
  font-size: 11px;
  color: #64748b;
}

.composer {
  display: flex;
  gap: 8px;
  padding: 10px;
}

input {
  flex: 1;
  border: 0;
  outline: 0;
  border-radius: 10px;
  background: rgba(51, 65, 85, 0.6);
  color: #fff;
  padding: 10px;
}

.send {
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  padding: 0 16px;
}

.send:disabled,
input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.reconnect {
  text-align: center;
  font-size: 12px;
  color: #fbbf24;
}

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  #app { padding: 12px; }
  .title { font-size: 28px; }
  .chat { height: calc(100vh - 24px); }
}
