* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f1117;
  --panel: #171a21;
  --panel-2: #1e222c;
  --border: #262b38;
  --text: #e6e9ef;
  --text-dim: #8b93a7;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --user-bubble: #4f46e5;
  --bot-bubble: #232836;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.app { display: flex; height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff; box-shadow: 0 4px 14px rgba(99,102,241,.35);
}
.brand-name { font-weight: 600; font-size: 15px; }

/* ---------- 微信用户卡片 ---------- */
.user-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 8px 10px; margin: 0 0 14px;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: #07c160; object-fit: cover;
}
.user-meta { min-width: 0; }
.user-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-tag { font-size: 11px; color: #07c160; margin-top: 2px; }
.logout-btn {
  margin-left: auto; flex-shrink: 0;
  font-size: 11px; padding: 4px 8px;
  border: 1px solid var(--border); border-radius: 6px;
  background: transparent; color: var(--text-dim); cursor: pointer;
  transition: all .15s;
}
.logout-btn:hover { border-color: #f87171; color: #f87171; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: none; border-radius: 8px;
  background: transparent; color: var(--text-dim);
  font-size: 14px; cursor: pointer; transition: all .15s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--panel-2); color: var(--text); }
.nav-item .icon { font-size: 13px; }

.sidebar-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 8px 4px; font-size: 12px; color: var(--text-dim);
  border-top: 1px solid var(--border);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #34d399; box-shadow: 0 0 8px rgba(52,211,153,.6);
}

/* ---------- Chat area ---------- */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: rgba(15,17,23,.6); backdrop-filter: blur(8px);
}
.chat-header h1 { font-size: 16px; font-weight: 600; }
.model-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text-dim);
}

/* ---------- Messages ---------- */
.messages {
  flex: 1; overflow-y: auto; padding: 24px;
  display: flex; flex-direction: column; gap: 18px;
  scroll-behavior: smooth;
}

.msg { display: flex; gap: 12px; max-width: 78%; animation: pop .2s ease; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.bot { align-self: flex-start; }

@keyframes pop {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.avatar {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.msg.bot .avatar { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.msg.user .avatar { background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim); }

.bubble {
  padding: 10px 14px; border-radius: 12px;
  font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
}
.msg.bot .bubble { background: var(--bot-bubble); border-top-left-radius: 4px; }
.msg.user .bubble { background: var(--user-bubble); border-top-right-radius: 4px; }

/* typing indicator */
.typing .bubble { display: flex; gap: 5px; align-items: center; padding: 14px 16px; }
.typing .bubble span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim);
  animation: blink 1.2s infinite;
}
.typing .bubble span:nth-child(2) { animation-delay: .2s; }
.typing .bubble span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- Composer ---------- */
.composer { padding: 16px 24px 20px; border-top: 1px solid var(--border); }
.input-wrap {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 14px; padding: 8px 10px 8px 16px;
  transition: border-color .15s, box-shadow .15s;
}
.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.18);
}
.input-wrap textarea {
  flex: 1; background: transparent; border: none; outline: none; resize: none;
  color: var(--text); font-size: 14px; font-family: inherit; line-height: 1.5;
  max-height: 140px; padding: 4px 0;
}
.input-wrap textarea::placeholder { color: var(--text-dim); }

.send-btn {
  width: 38px; height: 38px; border: none; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s, opacity .15s;
}
.send-btn:hover { transform: scale(1.05); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.hint { text-align: center; color: var(--text-dim); font-size: 11px; margin-top: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .sidebar { display: none; }
  .messages { padding: 16px; }
  .msg { max-width: 92%; }
  .composer { padding: 12px 14px 16px; }
}

/* scrollbar */
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.messages::-webkit-scrollbar-thumb:hover { background: #333a4d; }
