/* ==========================================================================
   chat.css —— 对话页（侧栏 + 主对话区 + 输入框）
   ========================================================================== */

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--surface);
}

/* ================================================================== 侧栏 */
.sidebar {
  display: flex;
  flex-direction: column;
  flex: none;
  width: var(--sidebar-w);
  height: 100%;
  padding: 14px 12px 12px;
  background: linear-gradient(180deg, #f2f7ff 0%, #eef4ff 100%);
  border-right: 1px solid var(--blue-150);
  transition: margin-left var(--transition);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 12px;
}
.brand-small {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--blue-700);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .03em;
}
.brand-small:hover { text-decoration: none; }
.brand-small svg {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  filter: drop-shadow(0 3px 8px rgba(61, 126, 240, .28));
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--blue-200);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--blue-700);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.new-chat-btn svg { width: 17px; height: 17px; }
.new-chat-btn:hover {
  border-color: var(--blue-400);
  box-shadow: 0 6px 16px rgba(61, 126, 240, .16);
}
.new-chat-btn:active { transform: translateY(1px); }
.new-chat-btn kbd {
  margin-left: auto;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--blue-50);
  color: var(--muted-2);
  font-size: 10.5px;
  font-weight: 400;
}

.conversation-nav {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  margin-top: 18px;
  overflow: hidden;
}
.nav-title {
  padding: 0 8px 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.conversation-item {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 8px 0 10px;
  border-radius: 9px;
  color: var(--text-soft);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.conversation-item:hover { background: rgba(255, 255, 255, .78); }
.conversation-item.is-active {
  background: var(--surface);
  color: var(--blue-700);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.conversation-item .chat-ico {
  flex: none;
  width: 15px;
  height: 15px;
  color: var(--blue-400);
}
.conversation-item.is-active .chat-ico { color: var(--blue-600); }

.conversation-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: inherit;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.conversation-actions {
  display: none;
  gap: 2px;
  flex: none;
}
.conversation-item:hover .conversation-actions,
.conversation-item.is-active .conversation-actions { display: flex; }
.conversation-actions .icon-btn { width: 24px; height: 24px; border-radius: 6px; }
.conversation-actions .icon-btn svg { width: 14px; height: 14px; }

.rename-input {
  flex: 1;
  min-width: 0;
  height: 26px;
  padding: 0 7px;
  border: 1px solid var(--blue-400);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}

.empty-hint {
  padding: 26px 12px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--muted-2);
}

.sidebar-foot {
  flex: none;
  padding-top: 10px;
  border-top: 1px solid var(--blue-150);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 11px;
  transition: background var(--transition);
}
.user-chip:hover { background: rgba(255, 255, 255, .7); }
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue-400), var(--blue-600));
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}
.user-meta {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}
.user-meta strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.user-meta small { font-size: 11px; color: var(--muted-2); }

.sidebar-mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  background: rgba(23, 45, 78, .3);
}

/* ================================================================== 主区 */
.main {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  background:
    radial-gradient(72% 40% at 50% 0%, #f6faff 0%, rgba(246, 250, 255, 0) 70%),
    var(--surface);
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  height: 56px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(8px);
}
/* 顶栏中间：当前模型别名 */
.topbar-alias {
  position: absolute;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 46vw;
  padding: 4px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transform: translateX(-50%);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.topbar-alias:hover {
  border-color: var(--blue-150);
  background: var(--blue-50);
  color: var(--blue-700);
}
.topbar-alias:focus-visible {
  outline: none;
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px rgba(77, 141, 255, .15);
}
.topbar-alias span:last-child {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* 右下角：模型配置入口 */
.settings-fab {
  position: absolute;
  right: 20px;
  bottom: 22px;
  z-index: 20;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--blue-200);
  border-radius: 50%;
  background: var(--surface);
  color: var(--blue-600);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform var(--transition), border-color var(--transition), background var(--transition);
}
.settings-fab svg { width: 19px; height: 19px; }
.settings-fab:hover { border-color: var(--blue-400); background: var(--blue-50); transform: translateY(-1px); }
.settings-fab:active { transform: scale(.96); }

@media (max-width: 960px) {
  .settings-fab { right: 14px; bottom: 150px; }
}

/* ============================================================== 对话滚动区 */
.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.chat-inner {
  display: flex;
  flex-direction: column;
  width: min(var(--content-max), calc(100% - 40px));
  min-height: 100%;
  margin: 0 auto;
  padding: 26px 0 18px;
}

/* 欢迎页 */
.welcome {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 0 6vh;
  text-align: center;
}
.welcome-logo svg {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  filter: drop-shadow(0 12px 26px rgba(61, 126, 240, .26));
}
.welcome h2 {
  margin-top: 22px;
  font-size: clamp(20px, 2.2vw, 25px);
  font-weight: 700;
  letter-spacing: .01em;
  color: #17355f;
}
.welcome > p {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.75;
  color: var(--muted);
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(620px, 100%);
  margin-top: 32px;
}
.suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.suggestion svg {
  flex: none;
  width: 17px;
  height: 17px;
  color: var(--blue-500);
}
.suggestion span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.suggestion:hover {
  border-color: var(--blue-300);
  box-shadow: 0 8px 20px rgba(61, 126, 240, .13);
  transform: translateY(-1px);
}

/* 消息 */
.messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 22px;
  padding-bottom: 8px;
}

.message {
  display: flex;
  gap: 12px;
  animation: msg-in .22s ease-out;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.msg-avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.message.assistant .msg-avatar {
  background: linear-gradient(135deg, var(--blue-400), var(--blue-600));
  box-shadow: 0 4px 12px rgba(61, 126, 240, .24);
}
/* 人设有专属头像时，用 emoji / 文字 + 专属配色 */
.message.assistant .msg-avatar.has-persona {
  font-size: 17px;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}
.message.user { flex-direction: row-reverse; }
.message.user .msg-avatar {
  background: #e7f0ff;
  color: var(--blue-700);
}

.msg-body {
  min-width: 0;
  max-width: calc(100% - 48px);
}
/* 助手消息体固定占满可用宽度：展开/收起面板时宽度不变 */
.message.assistant .msg-body {
  flex: 1 1 auto;
  width: 100%;
}
.message.user .msg-body {
  max-width: min(78%, 620px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11.5px;
  color: var(--muted-2);
}
/* 用户消息不显示名字/时间，保持与 DeepSeek 一致的清爽感 */
.message.user .msg-meta { display: none; }
.message.user .msg-body { margin-top: 2px; }
.msg-meta strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
}

.bubble {
  padding: 11px 15px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  font-size: 14px;
  line-height: 1.78;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
}
.message.user .bubble {
  background: linear-gradient(135deg, #e8f1ff, #dcebff);
  border-color: var(--blue-200);
  border-top-right-radius: 5px;
  color: #143358;
  white-space: pre-wrap;
}
.message.assistant .bubble {
  /* 与 DeepSeek 官方一致：助手回复不加气泡，直接铺在页面上 */
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

/* 深度思考面板 */
.reasoning {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 8px;
  border: 1px dashed var(--blue-200);
  border-radius: 11px;
  background: #f8fbff;
}
.reasoning summary {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--blue-700);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning-title { flex: 1 1 auto; min-width: 0; }
.reasoning-toggle,
.sources-toggle {
  flex: none;
  margin-left: auto;
  padding: 1px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11.5px;
  font-style: normal;
  line-height: 18px;
}
.reasoning[open] summary .reasoning-toggle,
.sources-panel[open] > summary .sources-toggle {
  color: var(--blue-700);
  border-color: var(--blue-200);
}
.reasoning .reasoning-body {
  padding: 0 12px 10px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--muted);
  white-space: pre-wrap;
}

/* 流式光标 */
.streaming .bubble::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 3px;
  border-radius: 2px;
  background: var(--blue-500);
  vertical-align: -2px;
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.typing-dots { display: inline-flex; gap: 4px; padding: 3px 0; }
.typing-dots i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--blue-300);
  animation: bounce 1s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* 消息操作 */
/* 复制 / 重新生成：常驻显示，只保留图标，悬停时浮出功能名 */
.msg-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.msg-action {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.msg-action svg { width: 14px; height: 14px; }
.msg-action:hover { background: var(--blue-50); color: var(--blue-600); }

/* 悬停浮出的功能提示（显示在按钮下方，避免遮挡上方的回复内容） */
.msg-action::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(22, 38, 60, .92);
  color: #fff;
  font-size: 11.5px;
  line-height: 1.5;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-2px);
  transition: opacity .12s ease, transform .12s ease;
}
.msg-action:hover::after,
.msg-action:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --------------------------------------------------------------- Markdown */
.markdown > *:first-child { margin-top: 0; }
.markdown > *:last-child { margin-bottom: 0; }
.markdown p { margin: 0 0 9px; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 {
  margin: 16px 0 8px;
  font-weight: 700;
  line-height: 1.45;
  color: #14335e;
}
.markdown h1 { font-size: 19px; }
.markdown h2 { font-size: 17px; }
.markdown h3 { font-size: 15.5px; }
.markdown h4 { font-size: 14.5px; }
.markdown ul, .markdown ol { margin: 0 0 10px; padding-left: 22px; }
.markdown ul { list-style: disc; }
.markdown ol { list-style: decimal; }
.markdown li { margin: 3px 0; }
.markdown li::marker { color: var(--blue-400); }
.markdown strong { font-weight: 700; color: #10294b; }
.markdown em { font-style: italic; }
.markdown del { color: var(--muted-2); }
.markdown a { color: var(--blue-600); border-bottom: 1px solid var(--blue-200); }
.markdown a:hover { text-decoration: none; border-bottom-color: var(--blue-400); }
.markdown blockquote {
  margin: 0 0 10px;
  padding: 7px 13px;
  border-left: 3px solid var(--blue-300);
  border-radius: 0 8px 8px 0;
  background: #f7fbff;
  color: var(--muted);
}
.markdown hr {
  height: 1px;
  margin: 14px 0;
  border: 0;
  background: var(--line);
}
.markdown code:not(pre code) {
  padding: 1.5px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f5f9ff;
  color: #25508c;
  font-size: .92em;
}
.markdown table {
  width: 100%;
  margin: 0 0 12px;
  border-collapse: collapse;
  font-size: 13px;
}
.markdown th, .markdown td {
  padding: 7px 10px;
  border: 1px solid var(--line);
  text-align: left;
}
.markdown th { background: var(--blue-50); font-weight: 600; }

.code-block {
  margin: 0 0 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f8fbff;
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  background: #f2f7ff;
  font-size: 11.5px;
  color: var(--muted);
}
.code-lang { letter-spacing: .04em; text-transform: lowercase; }
.code-copy {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.code-copy:hover { color: var(--blue-600); border-color: var(--blue-300); }
.code-block pre {
  margin: 0;
  padding: 13px 14px;
  overflow-x: auto;
  font-size: 12.8px;
  line-height: 1.7;
  color: #1d3557;
}
.code-block pre code { white-space: pre; }

/* ================================================================ 输入框 */
.composer-wrap {
  position: relative;
  flex: none;
  padding: 6px 18px 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #fff 46%);
}
/* 底部渐隐，消息滚到输入框上方时过渡更自然 */
.composer-wrap::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -26px;
  height: 26px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff);
  pointer-events: none;
}
.composer {
  width: min(var(--content-max), 100%);
  margin: 0 auto;
  padding: 12px 12px 10px 16px;
  border: 1px solid var(--blue-200);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(48, 100, 180, .11);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.composer:focus-within {
  border-color: var(--blue-400);
  box-shadow: 0 12px 34px rgba(48, 100, 180, .17), 0 0 0 4px rgba(77, 141, 255, .08);
}


.composer textarea {
  display: block;
  width: 100%;
  max-height: 184px;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  line-height: 1.7;
  resize: none;
  outline: none;
}
.composer textarea::placeholder { color: var(--muted-2); }

.composer-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.tools-spacer { flex: 1; }

.chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 29px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.chip-toggle svg { width: 14px; height: 14px; }
.chip-toggle:hover { border-color: var(--blue-300); color: var(--blue-600); }
.chip-toggle[aria-pressed="true"] {
  border-color: var(--blue-400);
  background: var(--blue-100);
  color: var(--blue-700);
  font-weight: 600;
}


.send-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
  color: #fff;
  cursor: pointer;
  transition: transform var(--transition), filter var(--transition), background var(--transition);
  box-shadow: 0 5px 14px rgba(61, 126, 240, .3);
}
.send-btn svg { width: 18px; height: 18px; }
.send-btn .icon-stop { display: none; }
.send-btn:hover:not([disabled]) { filter: brightness(1.06); transform: translateY(-1px); }
.send-btn[disabled] {
  background: var(--blue-150);
  color: var(--blue-300);
  cursor: not-allowed;
  box-shadow: none;
}
.send-btn.is-streaming {
  background: var(--surface);
  border: 1px solid var(--blue-300);
  color: var(--blue-600);
  box-shadow: none;
}
.send-btn.is-streaming .icon-send { display: none; }
.send-btn.is-streaming .icon-stop { display: block; }


.only-mobile { display: none; }

/* =============================================================== 响应式 */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    z-index: 50;
    top: 0;
    bottom: 0;
    left: 0;
    margin-left: calc(-1 * var(--sidebar-w) - 8px);
    box-shadow: var(--shadow-lg);
  }
  .app.sidebar-open .sidebar { margin-left: 0; }
  .app.sidebar-open .sidebar-mask { display: block; }
  .only-mobile { display: inline-grid; }
  .chat-inner { width: calc(100% - 28px); padding-top: 18px; }
  .suggestions { grid-template-columns: 1fr; }
  .welcome { padding-top: 24px; }
  .composer-wrap { padding: 6px 12px 12px; }
  .message.user .msg-body { max-width: 86%; }
}

@media (max-width: 520px) {
  .topbar { padding: 0 12px; }
  .new-chat-btn kbd { display: none; }
  .msg-avatar { display: none; }
  .msg-body { max-width: 100%; }
  .message.user .msg-body { max-width: 92%; }
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ========================================================== 模型设置弹窗 */
.settings-modal {
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  max-height: min(88vh, 780px);
  padding: 0;
  overflow: hidden;
}

.settings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex: none;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.settings-head h3 { font-size: 17px; }
.settings-sub { margin-top: 4px; font-size: 12.5px; color: var(--muted); }

.settings-body {
  flex: 1;
  min-height: 0;
  padding: 18px 22px 8px;
  overflow-y: auto;
}
.settings-body select {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.settings-body select:hover { border-color: var(--blue-300); }
.settings-body select:focus {
  border-color: var(--blue-400);
  box-shadow: 0 0 0 4px rgba(77, 141, 255, .12);
}

.settings-body textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.65;
  resize: vertical;
  min-height: 78px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.settings-body textarea::placeholder { color: var(--muted-2); }
.settings-body textarea:hover { border-color: var(--blue-300); }
.settings-body textarea:focus {
  border-color: var(--blue-400);
  box-shadow: 0 0 0 4px rgba(77, 141, 255, .12);
}

.field-tag {
  margin-left: 6px;
  padding: 1px 7px;
  border: 1px solid var(--blue-150);
  border-radius: 999px;
  background: var(--blue-50);
  color: var(--blue-600);
  font-size: 11px;
  font-weight: 400;
}

.preset-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.preset {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--blue-700);
  font-size: 11.5px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.preset:hover { border-color: var(--blue-300); background: var(--blue-50); }

.settings-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex: none;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}
.settings-save {
  width: auto;
  height: 38px;
  margin: 0;
  padding: 0 22px;
  font-size: 14px;
  letter-spacing: .02em;
}

@media (max-width: 560px) {
  .settings-head { padding: 16px 16px 12px; }
  .settings-body { padding: 14px 16px 6px; }
  .settings-foot { padding: 12px 16px 14px; }
}
/* ============================================================ 附件与录音 */
.attachment-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 8px;
}
.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 10px;
  border: 1px solid var(--blue-150);
  border-radius: 9px;
  background: var(--blue-50);
  color: var(--text-soft);
  font-size: 12.5px;
}
.attachment-item svg { flex: none; width: 15px; height: 15px; color: var(--blue-500); }
.attachment-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.attachment-size { flex: none; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.attachment-remove {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.attachment-remove:hover { background: #fdeeee; color: #c74b4b; }
.attachment-remove svg { width: 13px; height: 13px; }

.chip-toggle.icon-square {
  width: 31px;
  padding: 0;
  justify-content: center;
}
.chip-toggle.icon-square svg { width: 16px; height: 16px; }
.chip-toggle.is-recording {
  border-color: #f0b4b4;
  background: #fdeeee;
  color: #c74b4b;
  animation: rec-pulse 1.2s ease-in-out infinite;
}
@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(199, 75, 75, .28); }
  50% { box-shadow: 0 0 0 6px rgba(199, 75, 75, 0); }
}

/* 消息里的附件标签 */
.msg-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  padding: 4px 10px;
  border: 1px solid var(--blue-200);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
}
.file-chip svg { width: 13px; height: 13px; color: var(--blue-500); flex: none; }
.file-chip span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.message.user .file-chip { background: rgba(255, 255, 255, .75); }
/* 顶栏别名下拉：只用来切换已保存的配置 */
.alias-chevron {
  width: 14px;
  height: 14px;
  color: var(--muted-2);
  transition: transform var(--transition), color var(--transition);
}
.topbar-alias[aria-expanded="true"] .alias-chevron { transform: rotate(180deg); color: var(--blue-600); }

.alias-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 50%;
  display: none;
  width: 300px;
  max-height: 60vh;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
}
.alias-menu.is-open { display: block; animation: alias-menu-in .14s ease-out; }
@keyframes alias-menu-in {
  from { opacity: 0; transform: translate(-50%, -4px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.alias-empty {
  padding: 10px 12px;
  color: var(--muted-2);
  font-size: 12.5px;
}

.alias-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition);
}
.alias-item:hover { background: var(--blue-50); }
.alias-item.is-active { background: var(--blue-100); }
.alias-item .a-main { min-width: 0; flex: 1; }
.alias-item .a-name {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.alias-item .a-meta {
  display: block;
  overflow: hidden;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.alias-item .a-check { flex: none; color: var(--blue-600); font-size: 13px; }
.alias-divider { height: 1px; margin: 6px 4px; background: var(--line-soft); }
.alias-action {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--blue-700);
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.alias-action:hover { background: var(--blue-50); }
.alias-action svg { width: 15px; height: 15px; color: var(--blue-500); }

/* 弹窗里的删除按钮 */
.settings-foot .danger-ghost {
  margin-right: auto;
  border-color: #f0d2d2;
  color: #c14b4b;
}
.settings-foot .danger-ghost:hover { background: #fdeeee; }
/* 用户头像：图片或昵称首字（默认样式与助手头像一致） */
.avatar { overflow: hidden; }
.avatar img,
.msg-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}
.message.user .msg-avatar {
  background: linear-gradient(135deg, var(--blue-400), var(--blue-600));
  color: #fff;
}
.msg-avatar.has-persona { font-size: 17px; }
/* 侧栏用户卡片：可点开个人资料 */
.user-chip { cursor: pointer; transition: background var(--transition); }
.user-chip:hover { background: rgba(255, 255, 255, .78); }
.user-chip:focus-visible { outline: 2px solid var(--blue-400); outline-offset: 2px; }
/* ---------------------------------------------------------------- 联网来源 */
.msg-sources {
  margin: 10px 0 4px;
}
.sources-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12.5px;
}
.sources-head svg {
  width: 14px;
  height: 14px;
  color: var(--blue-500);
}
.sources-status {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}
.sources-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.source-item {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface-2);
}
.source-index {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 6px;
  background: var(--blue-100);
  color: var(--blue-700);
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}
.source-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.source-main a {
  overflow: hidden;
  color: var(--blue-700);
  font-size: 13px;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.source-main a:hover { text-decoration: underline; }
.source-snippet {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
/* ---------------------------------------------------------------- 桌面端收起侧栏 */
.sidebar {
  overflow: hidden;
  transition: margin-left var(--transition), width var(--transition), padding var(--transition),
    border-color var(--transition), opacity var(--transition);
}
@media (min-width: 901px) {
  .app.sidebar-collapsed .sidebar {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    border-right-width: 0;
    opacity: 0;
  }
  .app.sidebar-collapsed #sidebarOpen {
    display: inline-grid;
  }
}
/* 联网来源：默认折叠，整行可点，开关固定在最右侧 */
.sources-panel {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 8px;
  border: 1px dashed var(--blue-200);
  border-radius: 11px;
  background: transparent;
}
.sources-panel[open] {
  background: #f8fbff;
}
.sources-panel > summary {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 8px 12px;
  color: var(--blue-700);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.sources-panel > summary::-webkit-details-marker { display: none; }
.sources-head { margin: 0; }
.sources-panel .sources-list { margin-top: 2px; }

/* ---------------------------------------------------------------- 会话批量删除 */
.nav-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 8px 8px;
}
.nav-head .nav-title { flex: 1 1 auto; margin: 0; padding: 0; }
.nav-action {
  flex: none;
  width: 24px;
  height: 24px;
  color: var(--muted-2);
}
.nav-action:hover { color: #d64545; background: #fdecec; }

.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 4px 8px;
  padding: 7px 8px;
  border: 1px solid var(--blue-200);
  border-radius: 10px;
  background: var(--surface);
  font-size: 12px;
}
.bulk-all {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  color: var(--text-soft);
  cursor: pointer;
}
.bulk-count {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  text-align: right;
  color: var(--muted);
  font-size: 11.5px;
}
.bulk-delete {
  flex: 1 1 calc(50% - 3px);
  height: 26px;
  padding: 0 8px;
  white-space: nowrap;
  border: 0;
  border-radius: 7px;
  background: #e25555;
  color: #fff;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.bulk-delete:disabled {
  background: #f0d6d6;
  color: #fff;
  cursor: not-allowed;
}
.bulk-cancel {
  flex: 1 1 calc(50% - 3px);
  height: 26px;
  padding: 0 8px;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-soft);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.conversation-list.is-selecting .conversation-item { cursor: pointer; }
.conversation-list.is-selecting .conversation-actions { display: none; }
.conversation-item.is-selected {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--blue-200);
}
.conv-check {
  flex: none;
  width: 15px;
  height: 15px;
  margin: 0 2px 0 0;
  accent-color: var(--blue-500);
  cursor: pointer;
}

/* ---------------------------------------------------------------- 顶栏头像菜单 */
.topbar { align-items: center; }
.user-avatar-btn {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  line-height: 0;
}
.user-avatar-btn .avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  overflow: hidden;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue-400), var(--blue-600));
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(61, 126, 240, .22);
  transition: transform var(--transition), box-shadow var(--transition);
}
.user-avatar-btn:hover .avatar {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(61, 126, 240, .3);
}
.user-avatar-btn .avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 16px;
  z-index: 40;
  display: grid;
  gap: 2px;
  min-width: 168px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.user-menu-head {
  display: grid;
  gap: 2px;
  padding: 4px 8px 8px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 4px;
}
.user-menu-head strong {
  font-size: 13px;
  color: var(--text);
}
.user-menu-head small {
  font-size: 11.5px;
  color: var(--muted);
}
.user-menu-item {
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.user-menu-item:hover { background: var(--blue-50); color: var(--blue-700); }
.user-menu-item.danger:hover { background: #fdecec; color: #d64545; }

/* ---------------------------------------------------------------- 会话列表区域边框 */
.conversation-list {
  margin: 0;
  padding: 6px;
  border: 1px solid var(--blue-150, #d3e4ff);
  border-radius: 12px;
  background: rgba(255, 255, 255, .55);
}
.conversation-list:empty {
  display: none;
}

/* 会话列表：边框撑到底部，内容超出时在框内滚动 */
.conversation-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--blue-200) transparent;
}
.conversation-list::-webkit-scrollbar { width: 6px; }
.conversation-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--blue-200);
}
.conversation-list::-webkit-scrollbar-track { background: transparent; }
