:root {
  /* OpenClaw Light 主题 (主背景浅色 + 红色 brand sidebar) */
  --bg: #f8f9fa;                    /* 页面主背景 */
  --bg-content: #f8f9fa;
  --bg-accent: #f1f3f5;
  --bg-elevated: #fff;              /* 提亮面板/卡片 */
  --bg-soft: #f1f3f5;               /* 微提亮底色 */
  --bg-soft2: #eceef0;
  --bg-hover: #eceef0;
  --bg-muted: #eceef0;
  --chrome: rgba(248, 249, 250, 0.78);  /* 顶栏半透明白 */
  --border: #e6e8eb;
  --border-soft: #d4d6da;
  --border-strong: #b8bcc2;
  --border-hover: #98a0aa;
  --text: #2a2c32;
  --text-strong: #1a1a1e;
  --text-dim: #6b6e76;
  --text-mute: #8b8b94;
  --muted: #8b8b94;
  /* Sidebar brand 红色 + 按钮 accent */
  --sidebar-bg: #e5243b;
  --sidebar-text: rgba(255, 255, 255, 0.92);
  --sidebar-text-dim: rgba(255, 255, 255, 0.65);
  --sidebar-text-mute: rgba(255, 255, 255, 0.4);
  --sidebar-hover: rgba(255, 255, 255, 0.1);
  --sidebar-active: rgba(255, 255, 255, 0.18);
  --sidebar-border: rgba(255, 255, 255, 0.12);
  --accent: #e5243b;
  --accent-hover: #f03e52;
  --accent-soft: #b81d31;
  --accent-glow: rgba(229, 36, 59, 0.25);
  --accent-subtle: rgba(229, 36, 59, 0.1);
  --green: #16a34a;
  --orange: #ea580c;
  --red: #dc2626;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.06);
  --mono: 'SF Mono', 'JetBrains Mono', 'Monaco', 'Inconsolata', monospace;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  /* OpenClaw 动画曲线 */
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.4, 0, .2, 1);
  --duration-fast: .12s;
  --duration-normal: .18s;
  --duration-slow: .3s;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
button, input, textarea, select { font: inherit; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
:where(button, input, textarea, select, [role="button"]):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 2px;
}
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Shell Grid Layout (OpenClaw 风: 258px sidebar + topbar + content) ===== */
.app {
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr);
  grid-template-rows: 52px 1fr;
  grid-template-areas: "nav topbar" "nav content";
  height: 100vh;
  animation: dashboard-enter 0.3s var(--ease-out);
  background: var(--bg);
  overflow: hidden;
}
@keyframes dashboard-enter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Sidebar collapsed: grid 列 1 宽度 0 */
.app.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}
.app.sidebar-collapsed .sidebar { width: 0; min-width: 0; padding: 0; border-right: none; }

.main-pane {
  grid-area: content;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0;
  background: var(--bg-content);
}
@media (max-width: 768px) {
  .main-pane { max-width: 100%; }
  /* Mobile: sidebar 总是浮起, grid 第一列 0 */
  .app {
    grid-template-columns: 0 minmax(0, 1fr) !important;
  }
}

/* Sidebar collapsed: grid 列 1 宽度 0 */
.app.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}
.app.sidebar-collapsed .sidebar { width: 0; min-width: 0; padding: 0; border-right: none; }

/* ===== Sidebar (grid-area: nav, 258px, OpenClaw panel 微提亮 + 深色文字) ===== */
.sidebar {
  grid-area: nav;
  width: 258px;
  background: var(--bg-soft);  /* OpenClaw panel: #f1f3f5 微提亮 */
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  color: var(--text);
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--border);
}

/* Sidebar 顶部品牌区 (logo + 名称) - OpenClaw 风 */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 14px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.sidebar-brand .logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(229, 36, 59, 0.3);
}
.sidebar-brand .brand-text { flex: 1; min-width: 0; }
.sidebar-brand h1 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.sidebar-brand .sub {
  font-size: 11px;
  color: var(--text-mute);
  line-height: 1.2;
  margin-top: 2px;
}
.sidebar-brand .sidebar-toggle {
  margin-left: auto;
}
.sidebar-new-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  box-shadow: var(--shadow-sm);
}
.sidebar-new-btn:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.sidebar-new-btn:active { transform: translateY(0); }
.sidebar-new-btn .icon { font-size: 15px; color: var(--accent); }
.sidebar-toggle {
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-strong);
  border-color: var(--border-strong);
}

.sidebar-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-search-input {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-strong);
  font-size: 13px;
  outline: none;
  transition: all var(--duration-fast) var(--ease-out);
  font-family: var(--font-body);
}
.sidebar-search-input::placeholder { color: var(--text-dim); }
.sidebar-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px 16px;
}
.sidebar-list::-webkit-scrollbar { width: 6px; }
.sidebar-list::-webkit-scrollbar-track { background: transparent; }
.sidebar-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.sidebar-list::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

.sidebar-empty {
  text-align: center;
  color: var(--text-mute);
  font-size: 12.5px;
  padding: 48px 16px;
  line-height: 1.8;
}
.sidebar-loading {
  text-align: center;
  color: var(--text-mute);
  font-size: 12.5px;
  padding: 40px 0;
}

.sidebar-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 10px 10px 12px;
  margin: 3px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  transition: all var(--duration-fast) var(--ease-out);
  border: 1px solid transparent;
  color: var(--text);
}
.sidebar-item:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}
.sidebar-item.active {
  background: var(--accent-subtle);
  border-color: color-mix(in srgb, var(--accent) 22%, var(--border) 78%);
  color: var(--text-strong);
}
.sidebar-item.active .sidebar-item-title { color: var(--accent); font-weight: 600; }

/* LLM 生成中状态: 出现小闪点 + 微微发光 */
.sidebar-item.is-generating .sidebar-item-title {
  color: var(--text-dim);
  font-style: italic;
}
.sidebar-item-spinner {
  display: inline-block;
  font-size: 12px;
  color: var(--accent);
  margin-right: 4px;
  animation: title-pulse 1.4s ease-in-out infinite;
}
@keyframes title-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50%      { opacity: 1;   transform: scale(1.1); }
}
/* 标题刚更新高亮 */
.sidebar-item.just-renamed {
  animation: title-glow 2.5s ease-out;
}
@keyframes title-glow {
  0%   { background: color-mix(in srgb, var(--accent) 22%, transparent); }
  100% { background: var(--bg-hover); }
}
.sidebar-item-body { flex: 1; min-width: 0; }
.sidebar-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-strong);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  word-break: break-all;
}
.sidebar-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-mute);
}
.sidebar-item-count { font-variant-numeric: tabular-nums; }
.sidebar-item-time { flex: 1; text-align: right; }
.sidebar-item-del {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  background: transparent;
  border: none;
  color: var(--text-mute);
  cursor: pointer;
  font-size: 12px;
  border-radius: 3px;
  opacity: 0;
  transition: all 0.12s;
}
.sidebar-item:hover .sidebar-item-del { opacity: 1; }
.sidebar-item-del:hover { background: rgba(229, 36, 59, 0.12); color: var(--accent); }

.sidebar-item-rename {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 2px 5px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.sidebar-handle {
  position: fixed;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 64px;
  background: var(--bg-soft2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.sidebar-handle:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-50%) scale(1.05);
}

/* Mobile: sidebar fixed 浮动 + 半透明遮罩 */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 35;
    width: min(280px, 82vw);  /* 宽度上限 82vw, 适配小屏 */
    box-shadow: 4px 0 28px rgba(0,0,0,0.45);
    transform: translateX(-100%);  /* 默认滑出左侧隐藏 */
    visibility: hidden;
    transition: transform 0.22s var(--ease-out), visibility 0.22s;
  }
  /* Sidebar 打开: 滑入 */
  .app.sidebar-open-mobile .sidebar {
    transform: translateX(0);
    visibility: visible;
  }
  /* 半透明遮罩 */
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 34;
    animation: fadeIn 0.18s ease;
  }
  /* Hamburger menu (mobile only) */
  .hamburger {
    display: flex !important;
  }
  /* Mobile backdrop 显示 (备用, 主逻辑看上面) */
  .sidebar-backdrop {
    display: block;
  }
  .sidebar-handle { display: none; }
}

/* ===== Header (OpenClaw 风: grid-area: topbar, 52px, chrome 半透明白 + blur 12px) ===== */
.header {
  grid-area: topbar;
  z-index: 40;
  min-height: 52px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 74%, transparent);
  background: var(--chrome);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  align-items: center;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  position: sticky;
  top: 0;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(229, 36, 59, 0.3);
}
.brand h1 { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; color: var(--text-strong); line-height: 1.2; }
.brand .sub { font-size: 11px; color: var(--text-mute); line-height: 1.2; }

/* Hamburger (永远可见, mobile 下重要入口) */
.hamburger {
  display: flex;
  width: 38px;
  height: 38px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 18px;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.hamburger:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-strong);
}

/* Sidebar backdrop (默认隐藏, sidebar 打开且 mobile 时显示) */
.sidebar-backdrop { display: none; }
.app.sidebar-open-mobile .sidebar-backdrop {
  display: block;
}

/* Sidebar 底部: 模型选择按钮 (mobile 主入口) */
.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text-dim);
  font-size: 12px;
  padding: 4px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-fixate-btn {
  display: none;
  width: 100%;
  min-height: 44px;
  margin-bottom: 8px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border) 72%);
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}
.sidebar-fixate-btn:disabled { opacity: .5; cursor: not-allowed; }
.sidebar-user-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
}
.sidebar-model-btn {
  display: none;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  box-shadow: var(--shadow-sm);
}
.sidebar-model-btn:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}
.sidebar-model-btn .model-dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 14%, transparent);
  flex-shrink: 0;
}
.sidebar-model-btn .model-label {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-model-btn .model-caret {
  color: var(--text-mute);
  font-size: 11px;
}

/* Mobile: 隐藏 header model-pill, 显示 sidebar 底部模型按钮 */
@media (max-width: 768px) {
  .model-pill { display: none !important; }
  .sidebar-model-btn { display: flex; }
  .sidebar-fixate-btn { display: block; }
  .sidebar-item-del { opacity: 1; width: 44px; height: 44px; margin: -6px -8px -6px 0; }
}

.header-actions { display: flex; gap: 8px; align-items: center; position: relative; }
.model-pill {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  display: flex; align-items: center; gap: 8px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.model-pill:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
  color: var(--text-strong);
}
.model-pill::before {
  content: ''; width: 6px; height: 6px;
  background: var(--green); border-radius: 50%;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 14%, transparent);
}
.icon-btn {
  width: 38px; height: 38px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  transition: all var(--duration-fast) var(--ease-out);
  box-shadow: var(--shadow-sm);
}
.icon-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-strong);
  transform: translateY(-1px);
}
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.icon-btn:hover {
  color: var(--text);
  background: var(--bg-soft2);
  border-color: var(--border);
}
.model-menu {
  position: absolute;
  top: 38px; right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  min-width: 200px;
  z-index: 30;
  box-shadow: var(--shadow-lg);
}
/* Mobile: model-menu 居中底部弹出 */
@media (max-width: 768px) {
  .model-menu {
    position: fixed;
    top: auto;
    right: 16px;
    left: 16px;
    bottom: 80px;
    z-index: 50;
  }
}
.model-menu-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s;
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text);
}
.model-menu-item:hover { background: var(--bg-soft); }
.model-menu-item.active { color: var(--accent); }
.model-menu-item .check { color: var(--accent); font-weight: 600; }

/* ===== Chat Area ===== */
.chat {
  flex: 1; overflow-y: auto;
  padding: 4px 16px 8px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
}
.chat::-webkit-scrollbar { width: 8px; }
.chat::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.chat::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }
.chat::-webkit-scrollbar-track { background: transparent; }

.msg {
  margin-bottom: 14px;
  animation: fadeIn 0.25s ease-out;
}
.msg:first-child { margin-top: 0; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-row { display: flex; gap: 14px; align-items: flex-start; }
/* 用户消息: 头像在右, 内容靠右 (OpenClaw 风) */
.msg.user .msg-row { flex-direction: row-reverse; }
.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  margin-top: 2px;
  box-shadow: var(--shadow-sm);
}
.msg.user .msg-avatar { background: var(--bg-soft); color: var(--text-dim); border: 1px solid var(--border); }
.msg.assistant .msg-avatar { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%); color: #fff; box-shadow: 0 2px 8px rgba(229, 36, 59, 0.3); }
.msg.failed .msg-avatar { background: var(--red); }

.msg-content { flex: 1; min-width: 0; }
/* 用户消息气泡: OpenClaw 风 (白底 + 浅边框, 靠右, max-width 限制) */
.msg.user .msg-content { display: flex; justify-content: flex-end; }
.msg-user-text {
  background: #fff;
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius);
  color: var(--text-strong);
  max-width: 75%;
  text-align: left;
  box-shadow: var(--shadow-sm);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Streaming cursor */
.cancel-btn {
  margin-left: auto;
  background: var(--bg-elevated);
  color: var(--text-mute);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
}
.cancel-btn:hover {
  background: var(--accent-subtle);
  color: white;
  border-color: var(--accent);
}
.streaming-cursor {
  display: inline-block;
  width: 7px; height: 14px;
  background: var(--accent);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ===== Progress Indicator ===== */
.progress {
  margin: 6px 0;
  padding: 8px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px;
  color: var(--text-dim);
  box-shadow: var(--shadow-sm);
}
.progress .spinner {
  width: 12px; height: 12px;
  border: 2px solid var(--accent-glow);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress .progress-text { flex: 1; }
.progress .progress-count { color: var(--accent); font-weight: 500; font-family: var(--mono); }
.progress-elapsed,
.task-elapsed {
  color: var(--text-mute);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ===== Markdown ===== */
.md {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 12px 0; color: var(--text); }
.md pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 12px 0;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-strong);
}
.md code {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 1px 6px;
  background: var(--bg-soft2);
  border-radius: 4px;
  color: var(--accent);
}
.md pre code { background: transparent; padding: 0; color: var(--text-strong); }
.md h1, .md h2, .md h3, .md h4 {
  margin: 22px 0 12px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-strong);
}
.md h1 { font-size: 17px; }
.md h2 {
  font-size: 15.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.md h2::before {
  content: '';
  width: 4px;
  height: 15px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}
.md h3 { font-size: 14.5px; color: var(--text-strong); }
.md h4 { font-size: 13.5px; color: var(--text-dim); }
.md ul, .md ol {
  margin: 12px 0 12px 4px;
  padding-left: 22px;
}
.md li {
  margin: 6px 0;
  line-height: 1.7;
  color: var(--text);
}
.md ul li {
  list-style: none;
  position: relative;
}
.md ul li::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 0.7em;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.85;
}
.md ol li {
  padding-left: 4px;
}
.md ol li::marker {
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.md table {
  border-collapse: separate;
  border-spacing: 0;
  margin: 16px 0;
  width: 100%;
  font-size: 13.5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
  display: table;
  box-shadow: var(--shadow-sm);
}
.md thead { background: var(--bg-soft); }
.md th, .md td {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  color: var(--text);
}
.md tr:last-child td { border-bottom: none; }
.md tbody tr {
  transition: background 0.12s;
}
.md tbody tr:hover {
  background: var(--bg-soft);
}
.md th {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}
.md blockquote {
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border) 70%);
  padding: 8px 14px;
  margin: 14px 0;
  color: var(--text-dim);
  background: var(--bg-soft);
  border-radius: 6px;
}
.md strong { font-weight: 600; color: var(--text-strong); }

/* ===== Hero 结论 (OpenClaw 风: 白底 + 红色渐变 + 柔和阴影) ===== */
.md-hero {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 22px;
  margin: 4px 0 24px;
  background: linear-gradient(135deg, #fff 0%, color-mix(in srgb, var(--accent) 4%, #fff) 100%);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border) 80%);
  border-radius: var(--radius);
  position: relative;
  box-shadow: var(--shadow-sm);
}
.md-hero-icon {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}
.md-hero-body { flex: 1; min-width: 0; }
.md-hero-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.md-hero-text {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.55;
  color: var(--text-strong);
}

/* ===== 4 段卡片 (浅色: 白底 + 柔和背景 + 阴影) ===== */
.md-section {
  margin: 18px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.md-section:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.md-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.md-section-icon {
  font-size: 17px;
  line-height: 1;
  flex-shrink: 0;
}
.md-section-title {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  flex: 1;
}
.md-section-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}
.md-section-copy:hover {
  background: var(--bg);
  border-color: var(--border-hover);
  color: var(--text-strong);
  transform: scale(1.05);
}
.md-section-copy:active { transform: scale(0.92); }
.md-section-body {
  padding: 14px 18px;
}
.md-section-body > *:first-child { margin-top: 0; }
.md-section-body > *:last-child { margin-bottom: 0; }

/* 不同 section 颜色主题 (OpenClaw 风: 更柔和的背景色 + 高对比标题色) */
.md-section-logic .md-section-header { background: color-mix(in srgb, #3b82f6 6%, #fff); border-bottom-color: color-mix(in srgb, #3b82f6 18%, var(--border) 82%); }
.md-section-logic { border-color: color-mix(in srgb, #3b82f6 22%, var(--border) 78%); }
.md-section-logic .md-section-icon { color: #2563eb; }
.md-section-logic .md-section-title { color: #1d4ed8; }

.md-section-scenario .md-section-header { background: color-mix(in srgb, #16a34a 6%, #fff); border-bottom-color: color-mix(in srgb, #16a34a 18%, var(--border) 82%); }
.md-section-scenario { border-color: color-mix(in srgb, #16a34a 22%, var(--border) 78%); }
.md-section-scenario .md-section-icon { color: #15803d; }
.md-section-scenario .md-section-title { color: #166534; }

.md-section-warn .md-section-header { background: color-mix(in srgb, #ea580c 6%, #fff); border-bottom-color: color-mix(in srgb, #ea580c 18%, var(--border) 82%); }
.md-section-warn { border-color: color-mix(in srgb, #ea580c 22%, var(--border) 78%); }
.md-section-warn .md-section-icon { color: #c2410c; }
.md-section-warn .md-section-title { color: #9a3412; }

.md-section-hero .md-section-header { background: color-mix(in srgb, #a855f7 6%, #fff); border-bottom-color: color-mix(in srgb, #a855f7 18%, var(--border) 82%); }
.md-section-hero { border-color: color-mix(in srgb, #a855f7 22%, var(--border) 78%); }
.md-section-hero .md-section-icon { color: #9333ea; }
.md-section-hero .md-section-title { color: #7e22ce; }
.md em { font-style: italic; color: var(--text-dim); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* ===== Thinking (Collapsed by Default) ===== */
.thinking {
  margin: 6px 0 10px;
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 12px;
}
.thinking summary {
  cursor: pointer;
  padding: 6px 10px;
  color: var(--text-dim);
  user-select: none;
  display: flex; align-items: center; gap: 6px;
  list-style: none;
  transition: background 0.1s;
}
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary:hover { background: var(--bg-soft); color: var(--text); }
.thinking summary::before {
  content: '▶';
  font-size: 8px;
  transition: transform 0.15s;
  color: var(--text-mute);
}
.thinking[open] summary::before { transform: rotate(90deg); }
.thinking summary .label { font-weight: 500; }
.thinking-live {
  margin-inline-start: auto;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--green) 12%, #fff);
  color: #08734f;
  font-size: 10px;
  font-weight: 600;
}
.thinking-live::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-inline-end: 5px;
  border-radius: 50%;
  background: var(--green);
  animation: blink 1.2s ease-in-out infinite;
}
.thinking-body {
  padding: 4px 10px 8px;
  max-height: 220px;
  overflow-y: auto;
}
.thinking-body::-webkit-scrollbar { width: 4px; }
.thinking-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.thinking-step {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 0;
  color: var(--text-mute);
  font-size: 11.5px;
}
.activity-marker {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
}
.activity-marker.is-result { background: var(--green); }
.activity-text {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.activity-text.is-result { color: var(--text-mute); }

/* Thinking hint (default collapsed) */
.thinking-hint {
  margin: 6px 0 10px;
  padding: 6px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
  display: inline-block;
}
.thinking-hint:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.code-ref-toggle {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
  background: transparent;
  cursor: pointer;
  padding: 3px 8px;
  display: inline-block;
  border: 1px dashed var(--border);
  border-radius: 4px;
  transition: all 0.15s;
}
.code-ref-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  border-style: solid;
}

/* ===== Code Refs ===== */
.code-refs {
  margin-top: 10px;
  display: flex; flex-wrap: wrap; gap: 4px;
}
.code-ref {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  padding: 2px 7px;
  background: var(--bg-soft2);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  transition: all 0.15s;
  cursor: default;
}
.code-ref:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== Error Banner ===== */
.error-banner {
  margin: 8px 0;
  padding: 10px 12px;
  background: rgba(248, 81, 73, 0.08);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  color: var(--red);
}
.error-banner .icon { font-size: 14px; flex-shrink: 0; }
.error-banner .msg-text { flex: 1; color: var(--text); }
.error-banner .retry-btn {
  padding: 4px 12px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  display: flex; align-items: center; gap: 4px;
  transition: opacity 0.15s;
}
.error-banner .retry-btn:hover { opacity: 0.85; }

/* ===== Actions ===== */
.msg-actions {
  display: flex; gap: 6px;
  margin-top: 8px;
}
.btn {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 4px;
}
.btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--bg-soft2);
}
.btn-primary {
  background: #fff;
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border) 72%);
  font-weight: 500;
}
.btn-primary:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent-soft);
}
.btn-success {
  color: var(--green);
  border-color: var(--green);
  cursor: default;
}
.btn-success:hover { background: transparent; color: var(--green); border-color: var(--green); }

/* ===== 回复反馈 (满意/不满意) ===== */
.feedback-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.feedback-prompt {
  font-size: 12px;
  color: var(--text-mute);
  margin-right: 2px;
}
.fb-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.fb-btn:hover {
  border-color: var(--accent);
  color: var(--text-strong);
  background: var(--bg-soft2);
}
.fb-btn.fb-up.active { background: var(--green); border-color: var(--green); color: #fff; }
.fb-btn.fb-down.active { background: var(--red); border-color: var(--red); color: #fff; }
.feedback-done {
  font-size: 12px;
  color: var(--green);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.feedback-input-panel {
  flex-basis: 100%;
  margin-top: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}
.feedback-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  min-height: 60px;
  box-sizing: border-box;
}
.feedback-input:focus { outline: none; border-color: var(--accent); }
.feedback-input-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}
.sidebar-admin-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-mute);
  font-size: 12px;
  text-decoration: none;
  transition: all 0.15s;
}
.sidebar-admin-link:hover {
  color: var(--accent);
  background: var(--bg-soft2);
}

/* ===== Input Area (Fixed Bottom) ===== */
.input-area {
  padding: 14px 16px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  position: relative;
}
.input-wrap {
  display: flex; gap: 10px;
  align-items: flex-end;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 10px 10px 16px;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle), var(--shadow-md);
}
.input-wrap textarea {
  flex: 1;
  background: transparent;
  color: var(--text-strong);
  border: none;
  outline: none;
  font-size: 14.5px;
  resize: none;
  font-family: inherit;
  min-height: 26px;
  max-height: 180px;
  line-height: 1.5;
  padding: 4px 0;
}
.input-wrap textarea::placeholder { color: var(--text-dim); }
.btn-send {
  width: 40px; height: 40px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  box-shadow: 0 2px 8px rgba(229, 36, 59, 0.25);
}
.btn-send:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.05);
  box-shadow: 0 4px 14px rgba(229, 36, 59, 0.4);
}
.btn-send:disabled {
  background: var(--bg-soft2);
  color: var(--text-mute);
  cursor: not-allowed;
  box-shadow: none;
}
.btn-send svg { width: 16px; height: 16px; }

/* ===== Empty State ===== */
.empty {
  text-align: center;
  padding: 12px 20px 20px;
  max-width: 540px;
  margin: auto;  /* flex 容器内 auto margin = 上下左右居中 */
  width: 100%;
}
.empty .icon {
  width: 64px; height: 64px;
  margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  border: 1px solid rgba(229, 36, 59, 0.3);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  box-shadow: 0 8px 24px rgba(229, 36, 59, 0.25);
}
.empty h2 { font-size: 18px; font-weight: 600; margin-bottom: 8px; color: var(--text-strong); }
.empty p { color: var(--text-dim); font-size: 13.5px; margin-bottom: 28px; line-height: 1.6; }
.examples {
  display: flex; flex-direction: column; gap: 8px;
  text-align: left;
}
.example-chip {
  width: 100%;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; gap: 10px;
  text-align: left;
  box-shadow: var(--shadow-sm);
}
.example-chip:hover {
  border-color: var(--accent);
  color: var(--text-strong);
  background: #fff;
  transform: translateX(2px);
  box-shadow: var(--shadow-md);
}
.example-chip .arrow {
  margin-left: auto;
  color: var(--text-mute);
  font-size: 12px;
  transition: transform 0.15s, color 0.15s;
}
.example-chip:hover .arrow {
  color: var(--accent);
  transform: translateX(3px);
}

/* ===== Fixate Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal h2 { font-size: 16px; font-weight: 600; margin-bottom: 4px; color: var(--text-strong); }
.modal .sub { font-size: 12px; color: var(--text-dim); margin-bottom: 18px; }
.modal textarea, .modal input[type=text] {
  width: 100%;
  background: var(--bg-soft);
  color: var(--text-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 12px;
  resize: vertical;
  transition: border-color 0.12s;
}
.modal textarea:focus, .modal input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}
.modal textarea { min-height: 60px; }
.modal .label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
  display: block;
  font-weight: 600;
}
.modal-actions {
  display: flex; gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}
.modal-actions .btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  transition: all 0.12s;
}
.modal-actions .btn:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}
.modal-actions .btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(229, 36, 59, 0.25);
}
.modal-actions .btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* ===== 会话固化模态框 ===== */
.modal.modal-fixate {
  max-width: 760px;
  width: 95%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 0;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin-bottom: 4px; }
.modal-header .sub { font-size: 12px; color: var(--text-dim); margin-bottom: 0; }
.modal-close {
  width: 32px; height: 32px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 20px;
  cursor: pointer;
  color: var(--text-dim);
  transition: all 0.12s;
}
.modal-close:hover {
  background: var(--bg-soft);
  border-color: var(--border);
  color: var(--text-strong);
}
.fixate-steps {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}
.fixate-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-mute);
  font-weight: 500;
  transition: color 0.15s;
}
.fixate-step .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
}
.fixate-step.active { color: var(--text-strong); }
.fixate-step.active .step-num { background: var(--accent); color: #fff; }
.fixate-step.done .step-num { background: var(--green); color: #fff; }
.fixate-step.done { color: var(--text-strong); }
.fixate-step-line {
  flex: 1;
  height: 1px;
  background: var(--border);
  margin: 0 12px;
}
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}
.fixate-pane { min-height: 200px; }
.fixate-loading {
  text-align: center;
  padding: 60px 0;
  color: var(--text-dim);
}
.fixate-loading .spinner {
  width: 32px; height: 32px;
  margin: 0 auto 14px;
  border: 3px solid var(--accent-subtle);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.fixate-loading p { font-size: 13px; }
.fixate-empty {
  text-align: center;
  padding: 60px 0;
  color: var(--text-mute);
}
.fixate-hint {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.fixate-hint strong { color: var(--text-strong); }
.fixate-group-list { display: flex; flex-direction: column; gap: 10px; }
.fixate-group-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.12s;
}
.fixate-group-item:hover { border-color: var(--border-strong); background: var(--bg-soft); }
.fixate-group-item.selected {
  border-color: var(--accent);
  background: var(--accent-subtle);
}
.fixate-group-item input[type="checkbox"] {
  margin-top: 2px;
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.fixate-group-info { flex: 1; min-width: 0; }
.fixate-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.fixate-topic { font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.fixate-pairs-count {
  font-size: 11px;
  color: var(--text-mute);
  background: var(--bg-soft2);
  padding: 2px 8px;
  border-radius: 10px;
}
.fixate-pair-preview { display: flex; flex-direction: column; gap: 4px; }
.fixate-pair-item {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  padding-left: 8px;
  border-left: 2px solid var(--border);
}
.fixate-pair-item .q-label {
  color: var(--accent);
  font-weight: 600;
  margin-right: 4px;
  font-family: var(--mono);
}
.fixate-pair-item .ellipsis { color: var(--text-mute); }

.fixate-summaries { display: flex; flex-direction: column; gap: 18px; }
.fixate-summary-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}
.fixate-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}
.fixate-original-count {
  font-size: 11px;
  color: var(--text-mute);
  background: var(--bg-soft2);
  padding: 2px 8px;
  border-radius: 10px;
}
.fixate-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.fixate-input, .fixate-select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-strong);
  margin-bottom: 12px;
  resize: vertical;
}
.fixate-input:focus, .fixate-select:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}
.fixate-input-lg { font-family: var(--mono); line-height: 1.55; min-height: 180px; }

.fixate-done { text-align: center; padding: 60px 0; }
.fixate-success-icon {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  background: var(--green);
  color: #fff;
  font-size: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.3);
}
.fixate-done h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.fixate-done p { color: var(--text-dim); margin-bottom: 8px; }

/* ===== 用户自定义分组 (旧版 LLM 强制分组的取代) ===== */
.fixate-usergroups { margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px dashed var(--border-soft); }
.fixate-group-actions { display: inline-flex; align-items: center; gap: 6px; }
.fixate-icon-btn {
  background: transparent; border: 1px solid transparent;
  border-radius: 6px; padding: 3px 7px; cursor: pointer;
  font-size: 13px; transition: all 0.12s;
  color: var(--text-dim);
}
.fixate-icon-btn:hover { background: var(--bg-soft2); border-color: var(--border); }
.fixate-icon-danger:hover { background: #fee; border-color: #fcc; color: #c33; }
.fixate-icon-tiny {
  font-size: 11px; padding: 1px 5px; opacity: 0.6;
}
.fixate-icon-tiny:hover { opacity: 1; }

.fixate-rename-input {
  flex: 1; padding: 4px 8px; border: 1px solid var(--accent);
  border-radius: 4px; font-size: 13px;
}

.fixate-pairs-toolbar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px; margin-bottom: 12px;
}
.fixate-ai-suggest-btn {
  background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
  color: #b45309;
  border-color: #fcd34d;
}
.fixate-ai-suggest-btn:hover {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: #f59e0b;
}

.fixate-pairs-list {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-content);
}
.fixate-pair-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.1s;
}
.fixate-pair-row:last-child { border-bottom: none; }
.fixate-pair-row:hover { background: var(--bg-soft); }
.fixate-pair-row.selected {
  background: var(--accent-subtle);
  color: var(--text-strong);
}
.fixate-pair-row.in_group {
  opacity: 0.6;
  background: var(--bg-soft2);
}
.fixate-pair-row.in_group.selected {
  /* 已进组 + 勾选: 不允许, 取消 background */
  background: var(--bg-soft2);
  border-left: none;
  padding-left: 12px;
}
.fixate-pair-row input[type="checkbox"] {
  margin-top: 4px; accent-color: var(--accent); cursor: pointer;
  width: 15px; height: 15px;
}
.fixate-pair-content { flex: 1; min-width: 0; }
.fixate-pair-q {
  font-size: 13px; color: var(--text);
  display: flex; align-items: flex-start; gap: 6px;
  margin-bottom: 4px; font-weight: 500;
}
.fixate-pair-q .q-label {
  color: var(--accent); font-weight: 600;
  font-family: var(--mono); font-size: 12px;
  flex-shrink: 0; padding-top: 1px;
}
.fixate-pair-a {
  font-size: 12px; color: var(--text-dim);
  line-height: 1.5;
  padding-left: 22px;
}
.fixate-pair-a .ellipsis { color: var(--text-mute); }
.fixate-pair-belong {
  font-size: 11px; color: var(--green);
  margin-top: 4px; padding-left: 22px;
}
.fixate-pair-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim);
  padding: 3px 0;
}

/* 命名对话框 */
.fixate-name-modal { max-width: 420px; }
.fixate-name-input {
  width: 100%; padding: 10px 12px;
  font-size: 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
}
.fixate-name-input:focus { outline: none; border-color: var(--accent); }

/* 确认提交页 */
.fixate-confirm-list { padding: 8px 0; }
.fixate-confirm-items { display: flex; flex-direction: column; gap: 12px; }
.fixate-confirm-item {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.fixate-confirm-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
}
.fixate-confirm-qa { font-size: 12.5px; line-height: 1.5; color: var(--text-dim); }
.fixate-confirm-qa strong { color: var(--text-strong); margin-right: 4px; }
.fixate-confirm-a { margin-top: 4px; padding-left: 22px; }

/* Header 固化按钮 (顶部右角) */
.header-fixate-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--accent-subtle);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border) 72%);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}
.header-fixate-btn:hover {
  background: color-mix(in srgb, var(--accent) 18%, #fff);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(229, 36, 59, 0.2);
}
/* Mobile: 隐藏头部按钮 (用 sidebar 里点) */
@media (max-width: 768px) {
  .header-fixate-btn { display: none; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .chat { padding: 6px 12px 8px; }
  .input-area { padding: 10px 12px 14px; }
  .msg-avatar { width: 28px; height: 28px; font-size: 13px; border-radius: 8px; }
  .msg-user-text { max-width: 85%; }
}
@media (max-width: 640px) {
  .header { padding: 0 14px; }
  .chat { padding: 6px 10px 8px; }
  .input-area { padding: 8px 10px 12px; }
  .msg-avatar { width: 24px; height: 24px; font-size: 11px; }
  .brand .sub { display: none; }
  .empty { padding: 40px 16px; }
}

/* ===== 全局任务条 (跨 session 跟踪) ===== */
.global-task-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 0;
  background: var(--bg-content);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--bg-hover);
}
.global-task-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(229, 36, 59, 0.06) 0%, rgba(229, 36, 59, 0.02) 100%);
  border: 1px solid rgba(229, 36, 59, 0.18);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 13px;
  animation: taskPillSlideIn 0.25s ease-out;
}
.global-task-pill:hover {
  background: linear-gradient(135deg, rgba(229, 36, 59, 0.1) 0%, rgba(229, 36, 59, 0.04) 100%);
  border-color: rgba(229, 36, 59, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(229, 36, 59, 0.1);
}
.global-task-pill.is-done {
  background: rgba(40, 167, 69, 0.06);
  border-color: rgba(40, 167, 69, 0.2);
}
.global-task-pill.is-done:hover {
  background: rgba(40, 167, 69, 0.1);
  border-color: rgba(40, 167, 69, 0.3);
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.1);
}
.global-task-pill.is-fail {
  background: rgba(229, 36, 59, 0.08);
  border-color: rgba(229, 36, 59, 0.3);
}
.task-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 13px;
  flex-shrink: 0;
}
.task-spinner.spinning {
  animation: spin 1.4s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes taskPillSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.task-q {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-strong);
  font-weight: 500;
}
.task-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--mono, monospace);
  flex-shrink: 0;
}
.task-step {
  background: rgba(229, 36, 59, 0.12);
  color: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 11px;
}
.global-task-pill.is-done .task-step {
  background: rgba(40, 167, 69, 0.12);
  color: #1e7e34;
}
.task-msg {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
.task-cancel {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.1s ease;
}
.task-cancel:hover {
  background: rgba(229, 36, 59, 0.15);
  color: var(--accent);
  border-color: rgba(229, 36, 59, 0.3);
}

/* 跳到任务时高亮目标消息 */
.msg.flash-highlight {
  animation: flashHighlight 1.5s ease-out;
}
@keyframes flashHighlight {
  0% { background: rgba(229, 36, 59, 0.18); }
  100% { background: transparent; }
}

/* 移动端: 任务条紧凑 */
@media (max-width: 768px) {
  .global-task-bar { padding: 6px 8px 0; }
  .global-task-pill { padding: 6px 10px; font-size: 12px; }
  .task-msg { max-width: 140px; }
  .task-elapsed { display: none; }
}

/* ===== 同 session 任务锁 UI (输入区禁用提示) ===== */
.input-lock-tip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, rgba(229, 36, 59, 0.08) 0%, rgba(229, 36, 59, 0.04) 100%);
  border: 1px solid rgba(229, 36, 59, 0.2);
  border-radius: var(--radius-sm, 8px);
  font-size: 13px;
  color: var(--accent-soft);
  animation: lockTipSlideIn 0.25s ease-out;
}
@keyframes lockTipSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.input-lock-tip .lock-icon {
  animation: lockIconSpin 1.5s linear infinite;
  font-size: 14px;
  flex-shrink: 0;
}
@keyframes lockIconSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.input-wrap.is-locked {
  opacity: 0.7;
  background: var(--bg-soft, #f1f3f5);
}
.input-wrap.is-locked textarea {
  cursor: not-allowed;
  color: var(--text-dim);
}

/* ===== Toast (右下角浮窗) ===== */
.app-toast {
  position: fixed;
  right: 24px;
  bottom: 80px;       /* 让位给输入区 */
  padding: 12px 18px;
  background: var(--bg-elevated, #fff);
  color: var(--text-strong, #1a1a1e);
  border: 1px solid var(--accent, #e5243b);
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
  z-index: 9999;
  max-width: 380px;
  line-height: 1.5;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
}
.app-toast.app-toast-show {
  opacity: 1;
  transform: translateX(0);
}
.app-toast.app-toast-leave {
  opacity: 0;
  transform: translateX(20px);
}
.app-toast-info { border-color: var(--accent, #e5243b); }
.app-toast-warn {
  border-color: #f59e0b;
  background: linear-gradient(135deg, #fff8e6 0%, #fff 100%);
}
.app-toast-error {
  border-color: #dc2626;
  background: linear-gradient(135deg, #fef2f2 0%, #fff 100%);
}
.app-toast-success {
  border-color: #10b981;
  background: linear-gradient(135deg, #ecfdf5 0%, #fff 100%);
}

/* 移动端: toast 从底部居中 */
@media (max-width: 768px) {
  .app-toast {
    right: 16px; left: 16px; bottom: 100px; max-width: none;
  }
  .hamburger,
  .btn-send,
  .modal-close,
  .task-cancel {
    min-width: 44px;
    min-height: 44px;
  }
  .fixate-icon-btn,
  .btn,
  .modal-actions .btn,
  .retry-btn,
  .code-ref-toggle,
  .thinking-hint {
    min-height: 44px;
  }
  .fixate-icon-btn { min-width: 44px; }
  .input-wrap textarea,
  .modal textarea,
  .modal input,
  .fixate-input,
  .fixate-select {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html:focus-within { scroll-behavior: auto; }
  .app,
  .msg,
  .modal-overlay,
  .sidebar-backdrop,
  .input-lock-tip,
  .msg.flash-highlight { animation: none; }
  .spinner,
  .task-spinner.spinning,
  .streaming-cursor,
  .thinking-live::before,
  .input-lock-tip .lock-icon { animation: none; }
  .sidebar,
  .app-toast,
  .example-chip,
  .btn-send { transition: none; }
  .chat { scroll-behavior: auto; }
}
