/* aichat.css — Claude 清新风格 */
:root {
  --aichat-bg: #faf9f7;
  --aichat-sidebar-bg: #ffffff;
  --aichat-sidebar-border: #e8e5de;
  --aichat-sidebar-width: 280px;
  --aichat-radius: 12px;
  --aichat-radius-lg: 20px;
  --aichat-shadow: 0 1px 3px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --aichat-shadow-lg: 0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --aichat-accent: #FFA200;
  --aichat-accent-hover: #e69200;
  --aichat-user-bg: #FFA200;
  --aichat-user-text: #ffffff;
  --aichat-assistant-bg: #ffffff;
  --aichat-assistant-border: #e8e5de;
  --aichat-input-bg: #ffffff;
  --aichat-input-border: #e8e5de;
  --aichat-text: #1a1a1a;
  --aichat-text-muted: #8a8a8a;
  --aichat-text-light: #a3a3a3;
  --aichat-modal-bg: #ffffff;
  --aichat-counter-warn: #dc2626;
  --aichat-border: #e8e5de;
}

@media (prefers-color-scheme: dark) {
  :root {
    --aichat-bg: #1a1a1a;
    --aichat-sidebar-bg: #242424;
    --aichat-sidebar-border: #333333;
    --aichat-assistant-bg: #242424;
    --aichat-assistant-border: #333333;
    --aichat-input-bg: #242424;
    --aichat-input-border: #333333;
    --aichat-text: #e8e5de;
    --aichat-text-muted: #8a8a8a;
    --aichat-text-light: #666666;
    --aichat-modal-bg: #242424;
    --aichat-border: #333333;
    --aichat-accent: #FFA200;
    --aichat-accent-hover: #e69200;
    --aichat-user-bg: #FFA200;
    --aichat-shadow: 0 1px 3px rgba(0,0,0,.2), 0 2px 8px rgba(0,0,0,.15);
    --aichat-shadow-lg: 0 4px 16px rgba(0,0,0,.25), 0 2px 6px rgba(0,0,0,.15);
  }
}

*, *::before, *::after { box-sizing: border-box; }

body { margin: 0; background: var(--aichat-bg); }

/* ── App Shell ── */
.aichat-app {
  display: flex;
  height: 100vh;
  background: var(--aichat-bg);
  font-family: "Söhne", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--aichat-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ── */
.aichat-sidebar {
  width: var(--aichat-sidebar-width);
  background: var(--aichat-sidebar-bg);
  border-right: 1px solid var(--aichat-sidebar-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.aichat-sidebar-header {
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.aichat-back-hub {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--aichat-text-muted);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 0;
  transition: color .15s;
}
.aichat-back-hub:hover { color: var(--aichat-text); }

.aichat-new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 16px;
  background: var(--aichat-accent);
  color: #fff;
  border: none;
  border-radius: var(--aichat-radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.aichat-new-btn:hover { background: var(--aichat-accent-hover); box-shadow: var(--aichat-shadow); }
.aichat-new-btn:active { transform: scale(.98); }

.aichat-sessions { list-style: none; margin: 0; padding: 4px 8px; overflow-y: auto; flex: 1; }
.aichat-sessions::-webkit-scrollbar { width: 4px; }
.aichat-sessions::-webkit-scrollbar-thumb { background: var(--aichat-border); border-radius: 2px; }

.aichat-session-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: var(--aichat-radius);
  margin-bottom: 2px;
  transition: background .15s;
  position: relative;
  gap: 10px;
  animation: slideIn .2s ease-out;
}
.aichat-session-item:hover { background: var(--aichat-sidebar-border); }
.aichat-session-item.active { background: var(--aichat-sidebar-border); }
.aichat-session-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--aichat-accent);
}

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

.aichat-session-info { flex: 1; min-width: 0; }
.aichat-session-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--aichat-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.aichat-session-meta {
  font-size: 11px;
  color: var(--aichat-text-muted);
  margin-top: 1px;
}

.aichat-archive-btn {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--aichat-text-light);
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: opacity .15s, background .15s, color .15s;
  flex-shrink: 0;
}
.aichat-session-item:hover .aichat-archive-btn { opacity: 1; }
.aichat-archive-btn:hover { background: rgba(220,38,38,.08); color: #dc2626; }

/* ── Main ── */
.aichat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Message Stream ── */
.aichat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 70px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}
.aichat-stream::-webkit-scrollbar { width: 6px; }
.aichat-stream::-webkit-scrollbar-track { background: transparent; }
.aichat-stream::-webkit-scrollbar-thumb { background: var(--aichat-border); border-radius: 3px; }
.aichat-stream::-webkit-scrollbar-thumb:hover { background: var(--aichat-text-light); }

/* ── Message Group (bubble + actions + meta) ── */
.aichat-msg-group {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: msgIn .3s cubic-bezier(.16,1,.3,1);
}
.aichat-msg-group--user {
  align-self: flex-end;
  align-items: flex-end;
}
.aichat-msg-group--assistant {
  align-self: flex-start;
  align-items: flex-start;
}
/* 动作栏和 meta 对齐气泡（偏移头像宽度 + 间距） */
.aichat-msg-group--assistant .aichat-msg-actions,
.aichat-msg-group--assistant .aichat-msg-meta {
  margin-left: 46px;
}
.aichat-msg-group--user .aichat-msg-actions,
.aichat-msg-group--user .aichat-msg-meta {
  margin-right: 46px;
}

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

.aichat-msg {
  padding: 14px 18px;
  border-radius: var(--aichat-radius-lg);
  position: relative;
  max-width: 100%;
}

.aichat-msg-user {
  background: var(--aichat-user-bg);
  color: var(--aichat-user-text);
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.aichat-msg-assistant {
  background: var(--aichat-assistant-bg);
  border: 1px solid var(--aichat-assistant-border);
  color: var(--aichat-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.aichat-msg-content {
  font-size: 14.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.aichat-msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--aichat-text-light);
}

/* 附件图片 */
.aichat-msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.aichat-msg-img {
  max-width: 240px;
  max-height: 240px;
  border-radius: var(--aichat-radius);
  object-fit: cover;
  cursor: pointer;
  border: 1px solid var(--aichat-border);
  transition: transform .2s;
}
.aichat-msg-img:hover { transform: scale(1.02); }
.aichat-msg-file {
  font-size: 12px;
  color: var(--aichat-text-muted);
}
.aichat-latency { }
.aichat-finish { color: #FFA200; font-size: 11px; }

/* typing indicator — 三点动画 */
.aichat-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
}
.aichat-typing-dots span {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--aichat-accent);
  opacity: .3;
  animation: typingBounce 1.4s ease-in-out infinite;
}
.aichat-typing-dots span:nth-child(2) { animation-delay: .2s; }
.aichat-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .3; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Input Bar ── */
.aichat-input {
  border-top: 1px solid var(--aichat-sidebar-border);
  padding: 16px 28px 24px;
  background: var(--aichat-bg);
  flex-shrink: 0;
}

.aichat-input-card {
  background: var(--aichat-input-bg);
  border: 1px solid var(--aichat-input-border);
  border-radius: var(--aichat-radius-lg);
  box-shadow: var(--aichat-shadow);
  overflow: visible;
  transition: box-shadow .2s, border-color .2s;
}
.aichat-input-card:focus-within {
  box-shadow: 0 0 0 3px rgba(255,162,0,.1), var(--aichat-shadow);
  border-color: var(--aichat-accent);
}

.aichat-input-toolbar {
  display: flex;
  align-items: center;
  padding: 10px 14px 4px;
  gap: 2px;
}

.aichat-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--aichat-text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.aichat-tool-btn:hover { background: var(--aichat-sidebar-border); color: var(--aichat-text); }
.aichat-tool-btn.active { background: rgba(255,162,0,.1); color: var(--aichat-accent); }

.aichat-tool-btn svg { display: block; }

.aichat-tool-btn--labeled {
  width: auto;
  padding: 0 10px;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
}
.aichat-tool-btn--labeled span {
  white-space: nowrap;
}

.aichat-tool-sep { width: 1px; height: 18px; background: var(--aichat-input-border); margin: 0 4px; flex-shrink: 0; }

.aichat-input-row {
  display: flex;
  align-items: flex-end;
  padding: 0 14px 10px;
  gap: 8px;
}

.aichat-input-textarea {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--aichat-text);
  font-family: inherit;
  outline: none;
  min-height: 42px;
  max-height: 160px;
  overflow-y: auto;
  padding: 8px 0;
}
.aichat-input-textarea::placeholder { color: var(--aichat-text-muted); }

.aichat-input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 14px 10px;
}

.aichat-input-counter {
  font-size: 12px;
  color: var(--aichat-text-light);
  transition: color .15s;
}
.aichat-counter-warn { color: var(--aichat-counter-warn); font-weight: 500; }

.aichat-input-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--aichat-accent);
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  transition: background .15s, transform .1s, box-shadow .15s;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(255,162,0,.25);
}
.aichat-input-send:hover:not(:disabled) { background: var(--aichat-accent-hover); transform: scale(1.05); box-shadow: 0 3px 10px rgba(255,162,0,.3); }
.aichat-input-send:active:not(:disabled) { transform: scale(.94); }
.aichat-input-send:disabled { opacity: .35; cursor: not-allowed; }

/* ── Role Modal ── */
.aichat-role-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26,26,26,.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: backdropIn .2s ease-out;
}
@keyframes backdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.aichat-role-modal {
  background: var(--aichat-modal-bg);
  border-radius: var(--aichat-radius-lg);
  box-shadow: var(--aichat-shadow-lg);
  width: min(480px, 92vw);
  overflow: hidden;
  animation: modalIn .25s cubic-bezier(.16,1,.3,1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.aichat-role-modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--aichat-sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.aichat-role-modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--aichat-text);
}
.aichat-role-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--aichat-text-muted);
  font-size: 20px;
  padding: 4px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.aichat-role-modal-close:hover { background: var(--aichat-sidebar-border); color: var(--aichat-text); }

.aichat-role-list { list-style: none; margin: 0; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }

.aichat-role-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--aichat-radius);
  cursor: pointer;
  transition: background .12s;
  border: 1px solid transparent;
}
.aichat-role-item:hover { background: rgba(255,162,0,.06); border-color: rgba(255,162,0,.15); }
.aichat-role-item.selected { background: rgba(255,162,0,.1); border-color: var(--aichat-accent); }

.aichat-role-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #fef3c7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.aichat-role-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--aichat-text);
}
.aichat-role-desc {
  font-size: 12px;
  color: var(--aichat-text-muted);
  margin-top: 2px;
  line-height: 1.4;
}
.aichat-role-provider {
  font-size: 11px;
  color: var(--aichat-text-light);
  margin-top: 3px;
}

.aichat-role-modal-footer {
  padding: 12px 24px 16px;
  text-align: right;
}

.aichat-role-cancel {
  padding: 9px 18px;
  border-radius: var(--aichat-radius);
  border: 1px solid var(--aichat-input-border);
  background: transparent;
  color: var(--aichat-text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s;
}
.aichat-role-cancel:hover { background: var(--aichat-sidebar-border); }

/* ── P1: Attachment Preview ── */
.aichat-attachments-preview {
  display: none;
  padding: 8px 14px;
  gap: 8px;
  overflow-x: auto;
  flex-wrap: nowrap;
}
.aichat-attachment-thumb {
  position: relative;
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  border-radius: var(--aichat-radius);
  overflow: hidden;
  border: 2px solid var(--aichat-input-border);
  transition: border-color .15s;
}
.aichat-attachment-thumb:hover { border-color: var(--aichat-accent); }
.aichat-attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.aichat-attachment-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.6);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s;
}
.aichat-attachment-thumb:hover .aichat-attachment-remove { opacity: 1; }
.aichat-attachment-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2px 4px;
  background: rgba(0,0,0,.5);
  color: #fff;
  font-size: 9px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

/* ── P2: Tool Call/Result Cards ── */
.aichat-msg-tool {
  align-self: flex-start;
}
.aichat-tool-card {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--aichat-radius);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  max-width: 85%;
  overflow: hidden;
}
.aichat-tool-card--call {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}
.aichat-tool-card--result {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}
@media (prefers-color-scheme: dark) {
  .aichat-tool-card--call { background: #431407; border-color: #9a3412; color: #fdba74; }
  .aichat-tool-card--result { background: #052e16; border-color: #16a34a; color: #86efac; }
}
.aichat-tool-icon { font-size: 13px; flex-shrink: 0; }
.aichat-tool-name { font-weight: 600; flex-shrink: 0; }
.aichat-tool-args {
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 11px;
  opacity: .85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.aichat-tool-result {
  font-size: 11px;
  opacity: .85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

/* ── Copy Button ── */
.aichat-copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  opacity: 0;
  background: var(--aichat-sidebar-bg);
  border: 1px solid var(--aichat-border);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--aichat-text-muted);
  transition: opacity .15s, background .15s, color .15s;
  z-index: 2;
}
.aichat-msg-content { position: relative; }
.aichat-msg-content:hover .aichat-copy-btn { opacity: 1; }
.aichat-copy-btn:hover { background: var(--aichat-sidebar-border); color: var(--aichat-text); }
.aichat-copy-copied { background: #16a34a !important; color: #fff !important; border-color: #16a34a !important; opacity: 1 !important; }

/* ── Message Actions ── */
.aichat-msg-actions {
  display: flex;
  gap: 2px;
  margin-top: 6px;
}
.aichat-msg-group:hover .aichat-msg-actions { opacity: 1; }
.aichat-msg-action-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--aichat-text-muted);
  font-size: 12px;
  cursor: pointer;
  border-radius: 6px;
  transition: background .12s, color .12s;
}
.aichat-msg-action-btn:hover { background: var(--aichat-sidebar-border); color: var(--aichat-text); }
.aichat-msg-action-btn--active { font-weight: 600; }
.aichat-msg-action-btn svg { width: 13px; height: 13px; }

/* ── Code Block ── */
.aichat-code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 14px;
  background: #1c1917;
  border-radius: var(--aichat-radius) var(--aichat-radius) 0 0;
  font-size: 11px;
  color: #a8a29e;
  margin-top: 10px;
  margin-bottom: -1px;
}
.aichat-code-header + pre {
  border-radius: 0 0 var(--aichat-radius) var(--aichat-radius);
  margin-top: 0;
}
.aichat-code-copy {
  background: none;
  border: none;
  color: #a8a29e;
  cursor: pointer;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  transition: color .12s, background .12s;
}
.aichat-code-copy:hover { color: #e7e5e4; background: rgba(255,255,255,.06); }
.aichat-msg-content pre {
  margin: 12px 0;
  padding: 14px 16px;
  border-radius: var(--aichat-radius);
  background: #292524;
  color: #e7e5e4;
  font-size: 12.5px;
  line-height: 1.65;
  overflow-x: auto;
  border: 1px solid #44403c;
}
.aichat-msg-content pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: inherit;
  border-radius: 0;
}
.aichat-msg-content code {
  font-family: "SF Mono", "Menlo", "Cascadia Code", "Consolas", monospace;
  font-size: 12.5px;
  background: var(--aichat-sidebar-border);
  padding: 2px 6px;
  border-radius: 5px;
}
.aichat-msg-user .aichat-msg-content code {
  background: rgba(255,255,255,.18);
}
.aichat-msg-content strong { font-weight: 600; }

/* ── Tag ── */
.aichat-tag {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 500;
}
.aichat-tag--stop {
  background: rgba(22,163,74,.08);
  color: #16a34a;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--aichat-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--aichat-text-light); }

/* ── Role Cards Grid ── */
.aichat-role-cards {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  overflow-y: auto;
}

.aichat-role-cards-header {
  text-align: center;
  margin-bottom: 36px;
}

.aichat-role-cards-header h2 {
  margin: 0 0 10px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--aichat-text);
}

.aichat-role-cards-header p {
  margin: 0;
  font-size: 14px;
  color: var(--aichat-text-muted);
}

.aichat-role-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  max-width: 960px;
  width: 100%;
}

.aichat-role-card {
  background: var(--aichat-assistant-bg);
  border: 1px solid var(--aichat-assistant-border);
  border-radius: var(--aichat-radius-lg);
  padding: 22px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.aichat-role-card:hover {
  border-color: var(--aichat-text-light);
  box-shadow: var(--aichat-shadow-lg);
  transform: translateY(-3px);
}

.aichat-role-card-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,162,0,.08);
  color: var(--aichat-accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.aichat-role-card-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.aichat-role-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--aichat-text);
  margin-bottom: 6px;
}

.aichat-role-card-desc {
  font-size: 12px;
  color: var(--aichat-text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.aichat-role-card-meta {
  font-size: 11px;
  color: var(--aichat-text-light);
  padding-top: 14px;
  margin-top: auto;
  border-top: 1px solid var(--aichat-assistant-border);
}

@media (prefers-color-scheme: dark) {
  .aichat-role-card {
    background: #242424;
    border-color: #333333;
  }
  .aichat-role-card:hover {
    border-color: var(--aichat-text-light);
  }
  .aichat-role-card-icon {
    background: rgba(245,158,11,.12);
    color: #FFA200;
  }
  .aichat-role-card-meta {
    border-top-color: #333333;
  }
}

/* ── 自定义角色卡片 ── */
.aichat-role-card--custom {
  position: relative;
  background: linear-gradient(135deg, rgba(124,58,237,.03), rgba(255,162,0,.03));
  border: 1.5px dashed rgba(124,58,237,.35);
}
.aichat-role-card--custom:hover {
  border-color: rgba(124,58,237,.6);
}
.aichat-role-card--add {
  background: var(--aichat-sidebar-border);
  border: 1.5px dashed var(--aichat-text-light);
}
.aichat-role-card--add:hover {
  border-color: var(--aichat-accent);
  background: rgba(255,162,0,.04);
}
.aichat-role-card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(124,58,237,.08);
  color: #7c3aed;
}
.aichat-role-card-icon--custom {
  background: rgba(124,58,237,.08) !important;
  color: #7c3aed !important;
}
.aichat-role-card-icon--add {
  background: rgba(0,0,0,.04) !important;
  color: var(--aichat-text-muted) !important;
}
.aichat-role-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.aichat-role-card-edit {
  background: transparent;
  border: none;
  color: var(--aichat-text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
}
.aichat-role-card-edit:hover {
  background: var(--aichat-sidebar-border);
  color: var(--aichat-accent);
}
.aichat-role-card-del {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--aichat-text-light);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  z-index: 2;
}
.aichat-role-card--custom:hover .aichat-role-card-del {
  opacity: 1;
}
.aichat-role-card-del:hover {
  background: rgba(220,38,38,.08);
  color: #ef4444;
}
@media (prefers-color-scheme: dark) {
  .aichat-role-card--add {
    background: rgba(255,255,255,.02);
    border-color: #444444;
  }
  .aichat-role-card-badge {
    background: rgba(124,58,237,.15);
    color: #c4b5fd;
  }
  .aichat-role-card-icon--add {
    background: rgba(255,255,255,.04) !important;
    color: #8a8a8a !important;
  }
  .aichat-role-card-edit:hover {
    background: rgba(255,255,255,.06);
  }
  .aichat-role-card-del:hover {
    background: rgba(239,68,68,.15);
    color: #f87171;
  }
}

/* ── 自定义角色模态框 ── */
.aichat-custom-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26,26,26,.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.aichat-custom-modal-backdrop.show {
  display: flex !important;
}
.aichat-custom-modal {
  background: var(--aichat-modal-bg);
  border-radius: var(--aichat-radius-lg);
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.aichat-custom-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--aichat-sidebar-border);
}
.aichat-custom-modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}
.aichat-custom-modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--aichat-text-muted);
  cursor: pointer;
  padding: 0 8px;
  line-height: 1;
}
.aichat-custom-modal-close:hover { color: var(--aichat-text); }
.aichat-custom-form {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.aichat-custom-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.aichat-custom-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--aichat-text);
}
.aichat-custom-field input,
.aichat-custom-field textarea {
  padding: 10px 12px;
  border: 1px solid var(--aichat-sidebar-border);
  border-radius: var(--aichat-radius);
  background: var(--aichat-input-bg);
  color: var(--aichat-text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.aichat-custom-field input:focus,
.aichat-custom-field textarea:focus {
  outline: none;
  border-color: var(--aichat-accent);
  box-shadow: 0 0 0 3px rgba(255,162,0,.1);
}
.aichat-custom-field--toggle label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.aichat-custom-field--toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--aichat-accent);
  cursor: pointer;
}
.aichat-custom-required { color: #ef4444; }
.aichat-custom-hint {
  background: rgba(255,162,0,.06);
  color: var(--aichat-text-muted);
  padding: 10px 12px;
  border-radius: var(--aichat-radius);
  font-size: 12px;
  line-height: 1.5;
}
.aichat-custom-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
}
.aichat-custom-btn-cancel,
.aichat-custom-btn-save {
  padding: 9px 18px;
  border-radius: var(--aichat-radius);
  border: 1px solid var(--aichat-sidebar-border);
  background: var(--aichat-input-bg);
  color: var(--aichat-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.aichat-custom-btn-save {
  background: var(--aichat-accent);
  color: #ffffff;
  border-color: var(--aichat-accent);
}
.aichat-custom-btn-save:hover {
  background: var(--aichat-accent-hover);
}
@media (prefers-color-scheme: dark) {
  .aichat-custom-modal {
    background: #242424;
    border: 1px solid #333333;
  }
  .aichat-custom-modal-header {
    border-bottom-color: #333333;
  }
  .aichat-custom-field input,
  .aichat-custom-field textarea {
    background: #1a1a1a;
    border-color: #333333;
    color: #e8e5de;
  }
  .aichat-custom-field input:focus,
  .aichat-custom-field textarea:focus {
    border-color: #FFA200;
  }
  .aichat-custom-btn-cancel,
  .aichat-custom-btn-save {
    background: #242424;
    border-color: #333333;
    color: #e8e5de;
  }
  .aichat-custom-btn-save {
    background: #FFA200;
    border-color: #FFA200;
  }
}

/* ═══════════════════════════════════════════════════════
   Toast 通知
   ═══════════════════════════════════════════════════════ */
.aichat-toast-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
.aichat-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--aichat-radius-lg);
  background: var(--aichat-modal-bg);
  border: 1px solid var(--aichat-border);
  box-shadow: var(--aichat-shadow-lg);
  font-size: 13px;
  color: var(--aichat-text);
  animation: aichatToastIn .35s cubic-bezier(.16,1,.3,1);
  pointer-events: auto;
}
.aichat-toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.aichat-toast--success svg { color: #16a34a; }
.aichat-toast--error svg { color: #dc2626; }
@keyframes aichatToastIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: none; }
}

/* ═══════════════════════════════════════════════════════
   AlertDialog 确认弹窗
   ═══════════════════════════════════════════════════════ */
.aichat-alert-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,26,26,.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  backdrop-filter: blur(4px);
  animation: aichatFadeIn .2s ease-out;
}
.aichat-alert-overlay.aichat-show { display: flex; }
@keyframes aichatFadeIn { from { opacity: 0; } to { opacity: 1; } }
.aichat-alert-box {
  background: var(--aichat-modal-bg);
  border: 1px solid var(--aichat-border);
  border-radius: var(--aichat-radius-lg);
  padding: 28px;
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
  animation: aichatScaleIn .25s cubic-bezier(.16,1,.3,1);
}
@keyframes aichatScaleIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.aichat-alert-title { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.aichat-alert-desc { font-size: 13.5px; color: var(--aichat-text-muted); margin-bottom: 24px; line-height: 1.6; }
.aichat-alert-actions { display: flex; justify-content: flex-end; gap: 8px; }
.aichat-alert-btn {
  padding: 9px 18px;
  border-radius: var(--aichat-radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--aichat-border);
  background: var(--aichat-modal-bg);
  color: var(--aichat-text);
  transition: background .12s;
}
.aichat-alert-btn:hover { background: var(--aichat-sidebar-border); }
.aichat-alert-btn--danger {
  background: #dc2626;
  color: #fff;
  border-color: transparent;
}
.aichat-alert-btn--danger:hover { background: #b91c1c; }

/* ═══════════════════════════════════════════════════════
   消息头像
   ═══════════════════════════════════════════════════════ */
.aichat-msg-group {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: msgIn .3s cubic-bezier(.16,1,.3,1);
}
.aichat-msg-group--user {
  align-self: flex-end;
  align-items: flex-end;
}
.aichat-msg-group--assistant {
  align-self: flex-start;
  align-items: flex-start;
}
.aichat-msg-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.aichat-msg-group--user .aichat-msg-row { flex-direction: row-reverse; }

.aichat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  position: relative;
}
.aichat-avatar--user { background: var(--aichat-user-bg); color: var(--aichat-user-text); }
.aichat-avatar--wang { background: #fef3c7; color: #d97706; border: 2px solid #fde68a; }
.aichat-avatar--listing { background: #ecfeff; color: #0891b2; border: 2px solid #a5f3fc; }
.aichat-avatar--ceo { background: #f5f3ff; color: #7c3aed; border: 2px solid #c4b5fd; }
.aichat-avatar--scorer { background: #ecfdf5; color: #059669; border: 2px solid #a7f3d0; }
.aichat-avatar--general { background: #f5f5f5; color: #737373; border: 2px solid #e5e5e5; }
@media (prefers-color-scheme: dark) {
  .aichat-avatar--wang { background: #451a03; border-color: #92400e; }
  .aichat-avatar--listing { background: #164e63; border-color: #155e75; }
  .aichat-avatar--ceo { background: #2e1065; border-color: #4c1d95; }
  .aichat-avatar--scorer { background: #052e16; border-color: #065f46; }
  .aichat-avatar--general { background: #262626; color: #a3a3a3; border-color: #404040; }
}
.aichat-avatar--user::after { display: none; }
.aichat-avatar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--aichat-bg);
  background: #16a34a;
}

/* ═══════════════════════════════════════════════════════
   日期分割线
   ═══════════════════════════════════════════════════════ */
.aichat-date-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0;
  font-size: 11px;
  color: var(--aichat-text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 500;
}
.aichat-date-divider::before,
.aichat-date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--aichat-border);
}

/* ═══════════════════════════════════════════════════════
   会话搜索框
   ═══════════════════════════════════════════════════════ */
.aichat-session-search {
  padding: 0 12px 8px;
}
.aichat-session-search input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--aichat-border);
  border-radius: var(--aichat-radius);
  background: var(--aichat-sidebar-border);
  color: var(--aichat-text);
  font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a8a8a' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}
.aichat-session-search input:focus {
  border-color: var(--aichat-accent);
  box-shadow: 0 0 0 3px rgba(255,162,0,.1);
  background-color: var(--aichat-sidebar-bg);
}
.aichat-session-search input::placeholder { color: var(--aichat-text-muted); }

/* ═══════════════════════════════════════════════════════
   会话列表头像
   ═══════════════════════════════════════════════════════ */
.aichat-session-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

/* ═══════════════════════════════════════════════════════
   Header
   ═══════════════════════════════════════════════════════ */
.aichat-header {
  height: 52px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--aichat-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  background: var(--aichat-sidebar-bg);
}
.aichat-header-title {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
}
.aichat-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--aichat-sidebar-border);
  color: var(--aichat-text-muted);
  border: 1px solid var(--aichat-border);
}
.aichat-header-badge .aichat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #16a34a;
}
.aichat-header-actions {
  display: flex;
  gap: 2px;
}
.aichat-header-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--aichat-radius);
  border: none;
  background: transparent;
  color: var(--aichat-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s;
}
.aichat-header-btn:hover {
  background: var(--aichat-sidebar-border);
  color: var(--aichat-text);
}

/* ═══════════════════════════════════════════════════════
   图片灯箱
   ═══════════════════════════════════════════════════════ */
.aichat-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(26,26,26,.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  cursor: zoom-out;
}
.aichat-lightbox.aichat-show { display: flex; }
.aichat-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--aichat-radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}

/* ═══════════════════════════════════════════════════════
   拖拽上传覆盖层
   ═══════════════════════════════════════════════════════ */
.aichat-drag-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,162,0,.04);
  border: 2px dashed var(--aichat-accent);
  border-radius: var(--aichat-radius-lg);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  font-size: 14px;
  color: var(--aichat-accent);
  font-weight: 500;
  pointer-events: none;
}
.aichat-drag-overlay.aichat-show { display: flex; }

/* ═══════════════════════════════════════════════════════
   快捷键提示
   ═══════════════════════════════════════════════════════ */
.aichat-shortcuts {
  font-size: 11px;
  color: var(--aichat-text-light);
  display: flex;
  gap: 12px;
}
.aichat-shortcuts kbd {
  padding: 1px 5px;
  border-radius: 4px;
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 10px;
  background: var(--aichat-sidebar-border);
  border: 1px solid var(--aichat-border);
  color: var(--aichat-text-muted);
}
