/* K解助手前台 · 品牌蓝现代化重设计（2026-07）
   原则：中性白/灰为底，K 蓝 #2878ff 只做点缀（主按钮/激活态/链接/focus 环）；
   消息排版驱动、去卡片化；助手回答经 MarkdownRenderer 渲染（.md）。 */

:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --line: #e4e7ec;
  --line-soft: #eef0f4;
  --fill-soft: #f2f4f7;
  --text: #182230;
  --muted: #667085;
  --faint: #98a2b3;
  --accent: #2878ff;
  --accent-strong: #1a63e6;
  --accent-soft: #eef4ff;
  --accent-mid: #b8d4ff;
  --accent-text: #175cd3;
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --warning: #b54708;
  --warning-soft: #fffaeb;
  --success: #067647;
  --success-soft: #ecfdf3;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, 0.14);
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --sidebar-width: 288px;
  --content-max: 780px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Segoe UI",
    system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

/* ── 通用控件 ── */

.primary {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  transition: background 0.15s, opacity 0.15s;
}

.primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.primary.danger {
  background: var(--danger);
}

.primary.danger:hover:not(:disabled) {
  background: #b42318;
}

.secondary {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  padding: 8px 12px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-text);
}

.secondary.danger {
  color: var(--danger);
}

.secondary.danger:hover:not(:disabled) {
  border-color: #fda29b;
  background: var(--danger-soft);
  color: var(--danger);
}

.text-btn {
  border: 0;
  background: none;
  color: var(--accent-text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 4px;
}

.text-btn:hover:not(:disabled) {
  color: var(--accent-strong);
}

.primary:disabled,
.secondary:disabled,
.text-btn:disabled,
select:disabled,
textarea:disabled,
input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}

.icon-btn[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  padding: 9px 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(40, 120, 255, 0.14);
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.hint.feedback {
  color: var(--accent-text);
  min-height: 1.2em;
}

/* ── 瞬态滚动条（JS 在滚动时加 .is-scrolling）── */

.sidebar,
.session-list,
.messages,
.message.thinking pre,
.composer-box textarea {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.sidebar.is-scrolling,
.session-list.is-scrolling,
.messages.is-scrolling,
.message.thinking pre.is-scrolling,
.composer-box textarea.is-scrolling {
  scrollbar-color: rgba(102, 112, 133, 0.38) transparent;
}

.sidebar::-webkit-scrollbar,
.session-list::-webkit-scrollbar,
.messages::-webkit-scrollbar,
.message.thinking pre::-webkit-scrollbar,
.composer-box textarea::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.sidebar::-webkit-scrollbar-track,
.session-list::-webkit-scrollbar-track,
.messages::-webkit-scrollbar-track,
.message.thinking pre::-webkit-scrollbar-track,
.composer-box textarea::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.session-list::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb,
.message.thinking pre::-webkit-scrollbar-thumb,
.composer-box textarea::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background-color: transparent;
  background-clip: content-box;
}

.sidebar.is-scrolling::-webkit-scrollbar-thumb,
.session-list.is-scrolling::-webkit-scrollbar-thumb,
.messages.is-scrolling::-webkit-scrollbar-thumb,
.message.thinking pre.is-scrolling::-webkit-scrollbar-thumb,
.composer-box textarea.is-scrolling::-webkit-scrollbar-thumb {
  background-color: rgba(102, 112, 133, 0.34);
}

.sidebar::-webkit-scrollbar-thumb:hover,
.session-list::-webkit-scrollbar-thumb:hover,
.messages::-webkit-scrollbar-thumb:hover,
.message.thinking pre::-webkit-scrollbar-thumb:hover,
.composer-box textarea::-webkit-scrollbar-thumb:hover {
  background-color: rgba(102, 112, 133, 0.54);
}

/* ── 侧栏 ── */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: var(--space-lg);
  overflow-y: auto;
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-shrink: 0;
}

.mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.brand h1 {
  font-size: 15px;
  font-weight: 700;
}

.brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}

.new-session-btn {
  width: 100%;
  flex-shrink: 0;
}

.session-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.session-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xs);
  padding: 3px;
  border-radius: 10px;
  background: var(--fill-soft);
  flex-shrink: 0;
}

.session-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 8px;
  transition: background 0.15s, color 0.15s;
}

.session-tab:hover {
  color: var(--text);
}

.session-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.count {
  display: inline-flex;
  min-width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e8ebef;
  color: #475467;
  font-size: 11px;
  font-weight: 600;
}

.session-tab.active .count {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.session-empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.session-item {
  position: relative;
  width: 100%;
  border-radius: 10px;
  background: transparent;
  min-width: 0;
  transition: background 0.15s;
}

.session-item-main {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 0;
  border-radius: inherit;
  background: transparent;
  padding: 9px 10px;
  color: inherit;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}

.session-item-main:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.session-item:hover {
  background: var(--fill-soft);
}

.session-item.active {
  background: var(--accent-soft);
}

.session-item.active .session-item-top strong {
  color: var(--accent-text);
}

.session-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
  padding-right: 28px;
  min-width: 0;
}

.session-item-top strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.session-item.archived .session-item-top strong {
  color: var(--muted);
}

.session-badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.5;
}

.session-badge.idle {
  background: var(--fill-soft);
  color: var(--muted);
}

.session-badge.running {
  background: var(--warning-soft);
  color: var(--warning);
}

.session-badge.archived {
  background: var(--fill-soft);
  color: var(--faint);
}

.session-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  min-width: 0;
}

.session-item-user {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-item-time {
  color: var(--faint);
  font-size: 11px;
  flex-shrink: 0;
}

.session-item-id {
  color: var(--faint);
  font-size: 10px;
  font-family: ui-monospace, "Cascadia Code", "SF Mono", monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 6;
}

.session-actions-trigger,
.session-rename-save,
.session-rename-cancel {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.session-actions-trigger {
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.session-item:hover .session-actions-trigger,
.session-item:focus-within .session-actions-trigger,
.session-item.menu-open .session-actions-trigger {
  opacity: 1;
}

.session-actions-trigger:hover:not(:disabled),
.session-actions-trigger[aria-expanded="true"],
.session-rename-save:hover:not(:disabled),
.session-rename-cancel:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
}

.session-actions-trigger:focus-visible,
.session-rename-save:focus-visible,
.session-rename-cancel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.session-actions-menu {
  position: absolute;
  top: 32px;
  right: 0;
  z-index: 8;
  display: grid;
  gap: 2px;
  width: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 5px;
  box-shadow: var(--shadow-lg);
}

.session-actions-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 12.5px;
  padding: 7px 9px;
  text-align: left;
}

.session-actions-menu button:hover:not(:disabled),
.session-actions-menu button:focus-visible {
  outline: 0;
  background: var(--fill-soft);
}

.session-actions-menu button.danger {
  color: var(--danger);
}

.session-archive-confirm {
  gap: 9px;
  width: 172px;
  padding: 10px;
}

.session-archive-confirm p {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.session-archive-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
}

.session-actions-menu .session-archive-confirm-actions button {
  justify-content: center;
  width: auto;
  min-height: 28px;
  padding: 5px 8px;
  font-size: 11.5px;
}

.session-actions-menu button:disabled,
.session-actions-trigger:disabled,
.session-rename-save:disabled,
.session-rename-cancel:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.session-item.menu-open {
  z-index: 7;
}

.session-item.editing {
  background: var(--fill-soft);
  padding: 7px;
}

.session-rename-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px 28px;
  align-items: center;
  gap: 3px;
}

.session-rename-input {
  min-width: 0;
  height: 32px;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12.5px;
}

.session-rename-save {
  color: var(--success);
}

.session-rename-cancel {
  color: var(--muted);
}

.session-rename-error {
  margin-top: 4px;
  color: var(--danger);
  font-size: 10.5px;
  line-height: 1.4;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  border-top: 1px solid var(--line-soft);
  padding-top: var(--space-md);
  flex-shrink: 0;
}

.logout-control {
  position: relative;
}

.logout-confirm {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 10;
  display: grid;
  gap: var(--space-md);
  width: 218px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  box-shadow: var(--shadow-lg);
}

.logout-confirm p {
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
}

.logout-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

.logout-confirm-actions button {
  padding: 7px 10px;
  font-size: 12px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 9px;
  background: var(--fill-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.role-badge.admin {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.sidebar-note {
  font-size: 11px;
  color: var(--faint);
  flex-shrink: 0;
}

/* ── 聊天区框架 ── */

.chat {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  grid-template-areas:
    "head"
    "notice"
    "summary"
    "messages"
    "composer";
  min-width: 0;
  min-height: 0;
  height: 100vh;
  background: var(--bg);
}

.chat-head {
  grid-area: head;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 10px var(--space-xl);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}

.chat-head-main {
  flex: 1;
  min-width: 0;
}

.chat-head h2 {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-head p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── 版本更新公告 ── */

.update-notice {
  grid-area: notice;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
  border-bottom: 1px solid #d9e5f5;
  background: #f5f8fc;
  padding: 8px var(--space-xl);
  color: var(--text);
}

.update-notice-copy {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  min-width: 0;
  flex: 1;
}

.update-notice-copy strong {
  flex-shrink: 0;
  color: var(--accent-text);
  font-size: 11.5px;
  font-weight: 700;
}

.update-notice-copy p {
  min-width: 0;
  color: #475467;
  font-size: 12.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.update-notice-dismiss {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.update-notice-dismiss:hover {
  background: #e8eef7;
  color: var(--text);
}

.update-notice-dismiss:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-badge.idle {
  background: var(--fill-soft);
  color: var(--muted);
}

.status-badge.idle::before {
  background: var(--faint);
}

.status-badge.running {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-badge.running::before {
  background: var(--warning);
  animation: pulse 1.4s ease-in-out infinite;
}

.status-badge.archived {
  background: var(--fill-soft);
  color: var(--faint);
}

.status-badge.archived::before {
  background: var(--faint);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* ── 会话摘要条（内嵌整宽，不再悬浮）── */

.conversation-summary {
  grid-area: summary;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  padding: 6px var(--space-xl);
}

.summary-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  min-width: 0;
}

.summary-trigger::-webkit-details-marker {
  display: none;
}

.summary-trigger::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  flex-shrink: 0;
}

.conversation-summary.pre-sale .summary-trigger::before {
  background: #12b76a;
}

.conversation-summary.after-sale .summary-trigger::before {
  background: var(--warning);
}

.summary-trigger::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--faint);
  border-bottom: 1.5px solid var(--faint);
  transform: rotate(45deg);
  flex-shrink: 0;
  transition: transform 0.15s;
}

.conversation-summary[open] .summary-trigger::after {
  transform: rotate(-135deg);
}

.summary-main {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  min-width: 0;
  flex: 1;
}

.summary-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.summary-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.summary-type {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 1px 7px;
  background: var(--fill-soft);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  white-space: nowrap;
}

.conversation-summary.pre-sale .summary-type {
  background: var(--success-soft);
  color: var(--success);
}

.conversation-summary.after-sale .summary-type {
  background: var(--warning-soft);
  color: var(--warning);
}

.summary-compact {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.summary-list {
  display: none;
  gap: 4px 24px;
  margin: 8px 0 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.conversation-summary[open] .summary-list {
  display: grid;
}

.summary-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}

.summary-row dt,
.summary-row dd {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
}

.summary-row dt {
  color: var(--faint);
}

.summary-row dd {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-row.conclusion dd {
  display: -webkit-box;
  overflow: hidden;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* ── 消息区 ── */

.messages-wrap {
  grid-area: messages;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.messages {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
  padding-block: 24px 12px;
  padding-inline: max(var(--space-xl), calc((100% - var(--content-max)) / 2));
  scroll-behavior: smooth;
}

/* 空状态 */

.empty-state {
  display: grid;
  gap: var(--space-md);
  max-width: 460px;
  margin: auto;
  padding: var(--space-xl) 0;
  text-align: center;
}

.empty-icon {
  font-size: 32px;
  line-height: 1;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 650;
}

.empty-state > p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.example-prompts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

.example-label {
  color: var(--muted);
  font-size: 12px;
  width: 100%;
}

.example-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  padding: 6px 14px;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.example-chip:hover:not(:disabled) {
  border-color: var(--accent-mid);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.example-chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* 消息本体：去卡片化，meta 小字 + 内容 */

.message {
  flex-shrink: 0;
  min-width: 0;
}

.msg-meta {
  margin-bottom: 5px;
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1;
}

.message.user {
  align-self: flex-end;
  max-width: min(680px, 88%);
  text-align: right;
}

.message.user .msg-body {
  display: inline-block;
  border-radius: 14px 14px 4px 14px;
  border: 1px solid var(--accent-mid);
  background: var(--accent-soft);
  box-shadow: 0 1px 2px rgba(40, 120, 255, 0.1);
  color: #173b75;
  padding: 9px 14px;
  text-align: left;
}

.message.user .msg-meta {
  color: var(--accent-text);
  font-weight: 600;
}

.message-image {
  display: block;
  width: min(360px, 100%);
  max-height: 360px;
  margin-bottom: 8px;
  border: 1px solid rgba(40, 120, 255, 0.22);
  border-radius: 10px;
  background: white;
  object-fit: contain;
}

.msg-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
  font-size: 14px;
}

.message.assistant {
  align-self: stretch;
}

.message.error {
  align-self: flex-start;
  max-width: min(680px, 88%);
}

.message.error .msg-body {
  display: inline-block;
  border-radius: 14px 14px 14px 4px;
  background: var(--danger-soft);
  color: var(--danger);
  padding: 9px 14px;
}

/* thinking：折叠的思考过程 */

.message.thinking {
  align-self: stretch;
}

.message.thinking details {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.message.thinking summary {
  cursor: pointer;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 12.5px;
  user-select: none;
}

.message.thinking pre {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  border-top: 1px solid var(--line-soft);
  padding: 10px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  line-height: 1.6;
  font-size: 12.5px;
}

.thinking-status {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  border-radius: 999px;
  background: var(--fill-soft);
  color: var(--muted);
  font-size: 12px;
  padding: 6px 13px;
}

.thinking-bar {
  flex: 1;
  height: 3px;
  border-radius: 999px;
  background: #e4e7ec;
  overflow: hidden;
}

.thinking-status .thinking-bar {
  width: 48px;
}

.thinking-bar span {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: 999px;
  background: var(--accent);
  animation: thinking-slide 1.6s ease-in-out infinite;
}

@keyframes thinking-slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}

/* ── Markdown 排版（仅 assistant 消息）── */

.md {
  font-size: 14.5px;
  line-height: 1.75;
  word-break: break-word;
}

.md > :first-child {
  margin-top: 0;
}

.md > :last-child {
  margin-bottom: 0;
}

.md p {
  margin: 0 0 10px;
}

.md h2,
.md h3,
.md h4,
.md h5 {
  margin: 16px 0 8px;
  line-height: 1.4;
  font-weight: 650;
}

.md h2 {
  font-size: 16px;
}

.md h3 {
  font-size: 15px;
}

.md h4,
.md h5 {
  font-size: 14px;
}

.md ul,
.md ol {
  margin: 0 0 10px;
  padding-left: 22px;
}

.md li {
  margin: 3px 0;
}

.md li > ul,
.md li > ol {
  margin: 4px 0 2px;
}

.md code {
  border-radius: 5px;
  background: var(--fill-soft);
  padding: 1px 5px;
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
}

.md pre.md-code {
  margin: 0 0 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #f8fafc;
  padding: 10px 14px;
  overflow: auto;
}

.md pre.md-code[data-lang]::before {
  content: attr(data-lang);
  display: block;
  margin-bottom: 6px;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.md pre.md-code code {
  background: none;
  padding: 0;
  font-size: 12.5px;
  line-height: 1.6;
}

.md .md-mermaid {
  width: 100%;
  max-width: 100%;
  margin: 0 0 12px;
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  text-align: center;
}

.md .md-mermaid svg {
  display: block;
  width: auto;
  min-width: min-content;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.md pre.md-mermaid-error {
  border-color: rgba(217, 45, 32, 0.28);
}

.md pre.md-mermaid-error::before {
  color: var(--danger);
}

@media (max-width: 720px) {
  .md .md-mermaid svg {
    min-width: 640px;
    max-width: none;
  }
}

.md blockquote {
  margin: 0 0 10px;
  border-left: 3px solid var(--line);
  padding-left: 12px;
  color: var(--muted);
}

.md hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 14px 0;
}

.md table.md-table {
  border-collapse: collapse;
  margin: 0 0 12px;
  font-size: 13px;
  max-width: 100%;
}

.md table.md-table th,
.md table.md-table td {
  border: 1px solid var(--line-soft);
  padding: 6px 10px;
  text-align: left;
}

.md table.md-table th {
  background: var(--fill-soft);
  font-weight: 600;
}

.md a {
  color: var(--accent-text);
  text-decoration: none;
}

.md a:hover {
  text-decoration: underline;
}

/* ── 输入区 ── */

.composer-wrap {
  grid-area: composer;
  flex-shrink: 0;
  padding: 4px var(--space-xl) 16px;
}

.composer-blocked {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: var(--content-max);
  margin: 0 auto var(--space-sm);
  border-radius: 10px;
  background: var(--fill-soft);
  color: var(--muted);
  font-size: 12px;
  padding: var(--space-sm) var(--space-lg);
}

.composer {
  max-width: var(--content-max);
  margin: 0 auto;
}

.composer-box {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(40, 120, 255, 0.12);
}

.composer-box textarea {
  display: block;
  border: 0;
  background: transparent;
  resize: none;
  min-height: 46px;
  max-height: 160px;
  line-height: 1.55;
  padding: 12px 14px 4px;
  font-size: 14px;
}

.composer-box textarea:focus {
  border: 0;
  box-shadow: none;
}

.composer-attachment-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 100%;
  margin: 10px 14px 0;
}

.composer-attachment {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--fill-soft);
  color: var(--muted);
  font-size: 12px;
}

.composer-attachment img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
}

.composer-attachment span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-attachment .attachment-loading {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 6px;
  background: var(--fill);
  color: var(--muted);
  font-size: 10px;
  white-space: normal;
  text-align: center;
}

.composer-attachment button,
.image-picker-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.composer-attachment button {
  width: 26px;
  height: 26px;
  margin-left: auto;
  border-radius: 6px;
  font-size: 20px;
}

.composer-attachment button:hover,
.image-picker-btn:hover:not(:disabled) {
  background: var(--fill-soft);
  color: var(--text);
}

.image-input {
  display: none;
}

.image-picker-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex-shrink: 0;
}

.image-picker-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.composer-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 4px 8px 8px 14px;
  min-height: 42px;
}

.composer-config {
  display: flex;
  align-items: center;
  gap: 1px;
  min-width: 0;
  flex-shrink: 0;
}

.config-menu {
  position: relative;
}

.config-menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  padding: 0 7px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}

.config-menu-trigger:hover:not(:disabled),
.config-menu-trigger[aria-expanded="true"] {
  background: var(--fill-soft);
  color: var(--text);
}

.config-menu-trigger:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 2px rgba(40, 120, 255, 0.18);
}

.config-menu-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.config-menu-chevron {
  flex-shrink: 0;
  transition: transform 0.15s;
}

.config-menu-trigger[aria-expanded="true"] .config-menu-chevron {
  transform: rotate(180deg);
}

.composer-model-trigger {
  max-width: 132px;
}

.composer-model-trigger span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-reasoning-trigger {
  min-width: 44px;
}

.config-menu-options {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 12;
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 5px;
  box-shadow: var(--shadow-lg);
}

.composer-model-options {
  width: 178px;
}

.composer-reasoning-options {
  width: 124px;
}

.config-menu-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 12.5px;
  padding: 7px 9px;
  text-align: left;
}

.config-menu-option:hover,
.config-menu-option:focus-visible {
  outline: 0;
  background: var(--fill-soft);
}

.config-menu-option[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.config-menu-check {
  visibility: hidden;
  color: var(--accent-text);
  font-size: 13px;
}

.config-menu-option[aria-selected="true"] .config-menu-check {
  visibility: visible;
}

.composer-hint {
  color: var(--warning);
  font-size: 11px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-bar .hint.feedback {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.composer-hint + .hint.feedback:empty {
  display: none;
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-left: auto;
  flex-shrink: 0;
}

.send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 36px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-strong);
}

.send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.send-btn.sending {
  opacity: 0.7;
}

.send-label {
  display: none;
}

.interrupt-btn {
  height: 34px;
  border: 1px solid #fda29b;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 12.5px;
  font-weight: 600;
  padding: 0 13px;
  transition: border-color 0.15s, opacity 0.15s;
}

.interrupt-btn:hover:not(:disabled) {
  border-color: var(--danger);
}

.interrupt-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.jump-bottom {
  position: absolute;
  right: var(--space-xl);
  bottom: var(--space-lg);
  z-index: 5;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-text);
  cursor: pointer;
  padding: 7px 14px;
  font-size: 12px;
  box-shadow: var(--shadow-md);
  transition: border-color 0.15s;
}

.jump-bottom:hover {
  border-color: var(--accent);
}

/* ── 登录弹窗 ── */

.entry-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: var(--space-lg);
  background: rgba(16, 24, 40, 0.45);
  backdrop-filter: blur(3px);
}

.entry-panel {
  display: grid;
  gap: var(--space-md);
  width: min(380px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.entry-panel .primary {
  padding: 10px 14px;
}

/* ── 移动端抽屉 ── */

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 14;
  background: rgba(16, 24, 40, 0.35);
}

.sidebar-backdrop.visible {
  display: block;
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 15;
    width: min(var(--sidebar-width), 88vw);
    height: 100vh;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .chat {
    height: 100vh;
  }

  .chat-head {
    padding: 8px var(--space-lg);
  }

  .update-notice {
    align-items: flex-start;
    padding: 8px var(--space-lg);
  }

  .update-notice-copy {
    display: grid;
    gap: 2px;
  }

  .conversation-summary {
    padding: 6px var(--space-lg);
  }

  .summary-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .messages {
    padding-inline: var(--space-lg);
  }

  .message.user,
  .message.error {
    max-width: 94%;
  }

  .composer-wrap {
    padding: 4px var(--space-lg) 12px;
  }

  .composer-bar {
    gap: var(--space-xs);
    padding-left: 8px;
  }

  .composer-config {
    gap: 0;
  }

  .composer-model-trigger {
    max-width: 116px;
    padding-inline: 6px;
  }

  .composer-reasoning-trigger {
    min-width: 40px;
    padding-inline: 5px;
  }

  .send-btn {
    width: auto;
    padding: 0 13px;
  }

  .send-label {
    display: inline;
    font-size: 12.5px;
    font-weight: 650;
  }

  .session-actions-trigger {
    opacity: 1;
  }
}

.feishu-login-wrap {
  margin-bottom: 12px;
}

.feishu-login-btn {
  width: 100%;
  background: #3370ff;
}

.feishu-login-btn:hover {
  filter: brightness(1.05);
}

.key-login-fallback.collapsed label,
.key-login-fallback.collapsed #modalJoinButton {
  display: none;
}

.key-login-toggle {
  width: 100%;
  margin-bottom: 10px;
  text-align: center;
}

#linkFeishuButton {
  margin-right: 8px;
}

