/* 智谈 AgentStudio — 精致深色主题 */
:root {
  --bg: #0e1116;
  --bg-soft: #151a22;
  --bg-panel: #1a212c;
  --bg-hover: #222b38;
  --border: #2a3442;
  --text: #e8edf4;
  --text-dim: #93a1b5;
  --text-faint: #5d6b7f;
  --accent: #6c8cff;
  --accent-2: #9a6cff;
  --accent-grad: linear-gradient(135deg, #6c8cff, #9a6cff);
  --danger: #ff6b7a;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0,0,0,.45);
  --sidebar-w: 288px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
.hidden { display: none !important; }

#app { display: flex; height: 100dvh; }

/* ---------- 侧栏 ---------- */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: transform .28s ease;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.brand-text h1 { font-size: 15px; letter-spacing: .3px; }
.brand-text p { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.sidebar-close { margin-left: auto; display: none; }

.sidebar-section { flex: 1; overflow-y: auto; padding: 14px 12px; }
.section-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 6px 10px;
  font-size: 12px; color: var(--text-faint); letter-spacing: 1px;
}
.text-btn {
  background: none; border: none; color: var(--accent);
  font-size: 12px; padding: 2px 4px;
}
.text-btn:hover { text-decoration: underline; }

.persona-list { display: flex; flex-direction: column; gap: 6px; }
.persona-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid transparent;
  background: none; width: 100%; text-align: left;
  color: var(--text); transition: background .15s, border-color .15s;
}
.persona-item:hover { background: var(--bg-hover); }
.persona-item.active {
  background: var(--bg-panel);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(108,140,255,.25);
}
.persona-avatar {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--bg-hover);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.persona-item.active .persona-avatar { background: var(--accent-grad); }
.persona-meta { min-width: 0; }
.persona-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.persona-tagline { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.persona-edit {
  margin-left: auto; background: none; border: none;
  color: var(--text-faint); font-size: 14px; padding: 4px; opacity: 0;
  transition: opacity .15s;
}
.persona-item:hover .persona-edit { opacity: 1; }
.persona-edit:hover { color: var(--text); }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.footer-btn {
  width: 100%; padding: 10px;
  background: var(--bg-panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 13px;
}
.footer-btn:hover { background: var(--bg-hover); }
.disclaimer { font-size: 10.5px; color: var(--text-faint); line-height: 1.6; margin-top: 10px; padding: 0 2px; }

.sidebar-mask { display: none; }

/* ---------- 聊天区 ---------- */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(14,17,22,.8); backdrop-filter: blur(8px);
  min-height: 64px;
}
.icon-btn {
  background: none; border: none; color: var(--text-dim);
  font-size: 16px; padding: 6px; border-radius: 8px;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.hamburger { display: none; }
.chat-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-avatar { font-size: 24px; }
.chat-title h2 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-tagline { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }
.chat-actions { margin-left: auto; display: flex; gap: 8px; }
.small-btn {
  padding: 6px 14px; font-size: 12.5px;
  background: var(--bg-panel); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 8px;
}
.small-btn:hover { color: var(--text); background: var(--bg-hover); }
.small-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

/* 消息列表 */
.messages { flex: 1; overflow-y: auto; padding: 24px 20px 12px; scroll-behavior: smooth; }
.empty-state {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  gap: 12px; color: var(--text-dim);
}
.empty-icon { font-size: 52px; filter: drop-shadow(0 4px 20px rgba(108,140,255,.35)); }
.empty-state h2 { font-size: 20px; color: var(--text); }
.empty-state p { font-size: 13.5px; line-height: 1.9; }
.empty-note { font-size: 11.5px !important; color: var(--text-faint) !important; }

.msg { max-width: 780px; margin: 0 auto 18px; display: flex; gap: 12px; animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg-avatar {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: var(--bg-hover);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.msg.user { flex-direction: row-reverse; }
.msg.user .msg-avatar { background: var(--accent-grad); }
.msg-bubble {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 14.5px; line-height: 1.75; min-width: 0;
  overflow-wrap: break-word; white-space: pre-wrap;
}
.msg.assistant .msg-bubble { background: var(--bg-panel); border: 1px solid var(--border); }
.msg.user .msg-bubble { background: linear-gradient(135deg, #3d4f8f, #5a3d8f); }
.msg-name { font-size: 11px; color: var(--text-faint); margin-bottom: 4px; }
.msg.user .msg-name { text-align: right; }
.typing-dot { display: inline-block; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* 输入区 */
.composer { padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); }
.composer-inner {
  max-width: 780px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 10px 10px 16px;
  transition: border-color .15s;
}
.composer-inner:focus-within { border-color: var(--accent); }
textarea#input {
  flex: 1; background: none; border: none; outline: none; resize: none;
  color: var(--text); font-size: 14.5px; line-height: 1.6;
  max-height: 160px; padding: 4px 0;
}
.send-btn {
  width: 38px; height: 38px; border-radius: 11px; border: none;
  background: var(--accent-grad); color: #fff; font-size: 15px;
  flex-shrink: 0; transition: opacity .15s, transform .1s;
}
.send-btn:hover { opacity: .9; }
.send-btn:active { transform: scale(.94); }
.send-btn.stop { background: var(--bg-hover); border: 1px solid var(--border); color: var(--danger); }
.composer-hint {
  max-width: 780px; margin: 8px auto 0; text-align: center;
  font-size: 11px; color: var(--text-faint);
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  width: 100%; max-width: 480px;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow);
  animation: rise .22s ease; max-height: 90dvh; display: flex; flex-direction: column;
}
.modal-box.small { max-width: 380px; }
.modal-box header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-box header h3 { font-size: 15px; }
.modal-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-body label { font-size: 12.5px; color: var(--text-dim); display: flex; flex-direction: column; gap: 6px; }
.modal-body input, .modal-body textarea {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px;
  color: var(--text); font-size: 13.5px; outline: none;
  transition: border-color .15s;
}
.modal-body input:focus, .modal-body textarea:focus { border-color: var(--accent); }
.modal-body textarea { resize: vertical; line-height: 1.6; }
.row { display: flex; gap: 12px; }
.modal-box footer {
  display: flex; gap: 10px; padding: 14px 20px;
  border-top: 1px solid var(--border); justify-content: flex-end;
}
.btn {
  padding: 9px 20px; border-radius: 10px; font-size: 13.5px;
  background: var(--bg-panel); color: var(--text);
  border: 1px solid var(--border);
}
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent-grad); border: none; color: #fff; }
.btn.primary:hover { opacity: .92; }
.btn.danger { color: var(--danger); border-color: rgba(255,107,122,.4); }
.btn.danger:hover { background: rgba(255,107,122,.1); }
.security-note {
  font-size: 11.5px; color: var(--text-faint); line-height: 1.7;
  background: var(--bg); border-radius: 10px; padding: 10px 12px;
  border: 1px dashed var(--border);
}
.error-note { font-size: 12px; color: var(--danger); }
.export-opts { display: flex; flex-direction: column; gap: 10px; }

/* Toast */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--bg-panel); border: 1px solid var(--border);
  color: var(--text); padding: 10px 20px; border-radius: 12px;
  font-size: 13px; box-shadow: var(--shadow); z-index: 200;
  animation: rise .2s ease;
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 90;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .sidebar-mask.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 80; }
  .sidebar-close { display: block; }
  .hamburger { display: block; }
  .messages { padding: 16px 14px 8px; }
  .composer { padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); }
  .chat-header { padding: 10px 14px; }
  .msg { gap: 8px; margin-bottom: 14px; }
  .msg-bubble { font-size: 14px; padding: 10px 13px; }
}
