/* ==========================================================================
   Hermes Web · tokens & base
   ========================================================================== */
:root {
  --accent: #7c93ff;
  --accent-strong: #5f79ff;
  --accent-soft: rgba(124, 147, 255, 0.16);
  --accent-line: rgba(124, 147, 255, 0.34);
  --ok: #42c08a;
  --warn: #e0a44a;
  --danger: #ef6b6b;
  --radius-xl: 22px;
  --radius-lg: 18px;
  --radius: 13px;
  --radius-sm: 9px;
  --sidebar-w: 288px;
  --panel-w: 640px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

html[data-theme="dark"] {
  --bg: #0a0c10;
  --bg-elev: #0e1117;
  --surface: #13171f;
  --surface-2: #191e28;
  --surface-3: #212734;
  --hover: rgba(255, 255, 255, 0.045);
  --active: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e9ecf1;
  --text-2: #a5aebc;
  --text-3: #79828f;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.6);
  --code-bg: #0c0f15;
  --user-bubble: linear-gradient(140deg, #2b3350, #222a41);
  --user-bubble-text: #eef1f8;
  --scroll: rgba(255, 255, 255, 0.13);
}

html[data-theme="light"] {
  --bg: #f6f7f9;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e7eaef;
  --hover: rgba(15, 20, 30, 0.04);
  --active: rgba(15, 20, 30, 0.07);
  --border: rgba(15, 20, 30, 0.085);
  --border-strong: rgba(15, 20, 30, 0.16);
  --text: #13171e;
  --text-2: #59616e;
  --text-3: #868f9d;
  --shadow: 0 22px 55px rgba(15, 20, 30, 0.14);
  --code-bg: #f4f6f9;
  --user-bubble: linear-gradient(140deg, #e4e9ff, #dbe3ff);
  --user-bubble-text: #1b2440;
  --scroll: rgba(15, 20, 30, 0.18);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
::selection { background: var(--accent-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.mono { font-family: var(--mono); }
.only-mobile { display: none; }
:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }

/* ==========================================================================
   Buttons, fields, chips
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); font-weight: 550; font-size: 14px;
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .12s var(--ease), opacity .18s;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent-strong); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-danger { color: var(--danger); border-color: rgba(239, 107, 107, .3); background: rgba(239, 107, 107, .08); }
.btn-danger:hover { background: rgba(239, 107, 107, .16); }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn svg { width: 17px; height: 17px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  color: var(--text-2); border: 1px solid transparent;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.tiny { width: 24px; height: 24px; font-size: 16px; line-height: 1; }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; font-weight: 550; }
.field input, .field textarea, .field select,
.input, .select, .textarea {
  width: 100%; background-color: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 11px 13px; color: var(--text);
  transition: border-color .16s var(--ease), background-color .16s var(--ease);
}
.field input:focus, .field textarea:focus, .field select:focus,
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--accent-line); background-color: var(--surface);
}
.input::placeholder, .textarea::placeholder, .field input::placeholder { color: var(--text-3); }
.textarea { resize: vertical; min-height: 150px; font-family: var(--mono); font-size: 12.5px; line-height: 1.65; }
.field select,
.select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  padding-right: 36px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M6 8l4 4 4-4' stroke='%23868f9d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 16px 16px !important;
}
html[data-theme="light"] .field select,
html[data-theme="light"] .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M6 8l4 4 4-4' stroke='%2364748b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.field select:focus,
.select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M6 8l4 4 4-4' stroke='%234f7df9' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.form-error { color: var(--danger); font-size: 13px; min-height: 20px; margin-top: 10px; }
.form-hint { color: var(--text-3); font-size: 12.5px; margin-top: 6px; }
.form-ok { color: var(--ok); font-size: 13px; min-height: 20px; margin-top: 10px; }
.row { display: flex; gap: 10px; align-items: center; }
.row-end { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.grow { flex: 1; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px;
}
.card + .card { margin-top: 14px; }
.card-title { font-size: 14.5px; font-weight: 600; margin-bottom: 4px; }
.card-sub { font-size: 12.5px; color: var(--text-2); margin-bottom: 14px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.badge-ok { background: rgba(66, 192, 138, .12); color: var(--ok); border-color: rgba(66, 192, 138, .3); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(66, 192, 138, .16); }

/* ==========================================================================
   Login
   ========================================================================== */
.login-view {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 90% at 50% -10%, #151a27 0%, #0a0c10 55%, #08090c 100%);
  padding: 24px;
}
html[data-theme="light"] .login-view {
  background: radial-gradient(120% 90% at 50% -10%, #eef1fb 0%, #f7f8fa 55%, #f2f4f8 100%);
}
.login-glow {
  position: absolute; width: 620px; height: 620px; border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 147, 255, .22), transparent 62%);
  filter: blur(20px); top: -180px; pointer-events: none;
}
.login-card {
  position: relative; width: 100%; max-width: 396px; padding: 34px 32px 26px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--border-strong); border-radius: var(--radius-xl);
  box-shadow: var(--shadow); backdrop-filter: blur(18px);
  animation: rise .5s var(--ease);
}
.login-title { font-size: 27px; letter-spacing: -0.02em; margin-bottom: 6px; }
.login-sub { color: var(--text-2); font-size: 13.5px; margin-bottom: 26px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn-primary { height: 44px; margin-top: 6px; }
.login-foot { margin-top: 18px; text-align: center; font-size: 12px; color: var(--text-3); }
.login-error:empty { display: none; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px; color: #0b0d10;
  background: linear-gradient(140deg, #9fb0ff, #5f79ff);
  box-shadow: 0 10px 26px rgba(95, 121, 255, .32);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-mark-lg { width: 46px; height: 46px; border-radius: 14px; margin-bottom: 18px; }
.brand-mark-xl { width: 58px; height: 58px; border-radius: 18px; margin-bottom: 22px; }
.brand-mark-xl svg { width: 34px; height: 34px; }

/* ==========================================================================
   App shell
   ========================================================================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  transition: grid-template-columns .24s cubic-bezier(0.4, 0, 0.2, 1);
}
.app.sidebar-collapsed {
  grid-template-columns: 0px minmax(0, 1fr);
}

.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-elev); border-right: 1px solid var(--border);
  padding: 14px 12px 12px;
  overflow: hidden;
  transition: padding .24s cubic-bezier(0.4, 0, 0.2, 1), opacity .2s;
  white-space: nowrap;
}
.app.sidebar-collapsed .sidebar {
  padding-left: 0;
  padding-right: 0;
  border-right: none;
  opacity: 0;
  pointer-events: none;
}
.sidebar-head { position: relative; margin-bottom: 10px; }
.profile-chip {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border-radius: var(--radius); border: 1px solid transparent;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.profile-chip:hover { background: var(--hover); border-color: var(--border); }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  background: linear-gradient(140deg, #8ea4ff, #5f79ff); color: #0b0d10;
  font-weight: 650; font-size: 14px;
}
.avatar-sm { width: 26px; height: 26px; border-radius: 8px; font-size: 12px; }
.profile-chip-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; flex: 1; }
.profile-chip-name { font-weight: 600; font-size: 14px; }
.profile-chip-meta { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.chev { width: 16px; height: 16px; color: var(--text-3); flex: none; }

.profile-menu, .user-menu {
  position: absolute; z-index: 40; min-width: 240px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow);
  animation: rise .16s var(--ease);
}
.profile-menu { top: 56px; left: 0; right: 0; }
.profile-menu button, .user-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 9px 10px; border-radius: var(--radius-sm); font-size: 13.5px; color: var(--text);
}
.profile-menu button:hover, .user-menu button:hover { background: var(--hover); }
.profile-menu button.active { background: var(--accent-soft); color: var(--accent); }
.profile-menu .pm-name { font-weight: 600; }
.profile-menu .pm-desc { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-menu .pm-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; align-items: flex-start; }
.user-menu { bottom: 54px; left: 12px; right: 12px; }
.user-menu button.danger { color: var(--danger); }

.btn-new {
  width: 100%; height: 42px; margin-bottom: 12px;
  background: var(--surface-2); border-color: var(--border);
  font-weight: 560;
}
.btn-new:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

.search-wrap { position: relative; margin-bottom: 8px; }
.search-wrap .search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); }
.search-wrap input {
  width: 100%; height: 36px; padding: 0 12px 0 34px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid transparent; font-size: 13px;
}
.search-wrap input:focus { outline: none; border-color: var(--accent-line); background: var(--surface); }
.search-wrap input::placeholder { color: var(--text-3); }

.session-list { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 2px 8px; }
.session-group { margin-top: 12px; }
.session-group-title { font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); padding: 4px 8px 6px; }
.session-item {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer;
  transition: background .14s var(--ease);
}
.session-item:hover { background: var(--hover); }
.session-item.active { background: var(--accent-soft); }
.session-item.active .si-title { color: var(--accent); }
.si-body { min-width: 0; flex: 1; }
.si-title { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.si-meta { font-size: 11.5px; color: var(--text-3); display: flex; gap: 6px; align-items: center; }
.si-actions { display: none; gap: 4px; }
.session-item:hover .si-actions { display: flex; }
.si-actions button {
  width: 28px; height: 28px; border-radius: 8px;
  color: var(--text-2); display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent;
  transition: all .14s var(--ease);
}
.si-actions button:hover {
  background: var(--surface-3); color: var(--text);
  border-color: var(--border);
  transform: translateY(-1px);
}
.si-actions button[data-act="delete"]:hover {
  background: rgba(239, 107, 107, .16);
  color: var(--danger);
  border-color: rgba(239, 107, 107, .3);
}
.si-actions svg { width: 16px; height: 16px; }

/* Tooltip 系统 */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: rgba(18, 21, 28, 0.95);
  color: #f3f4f6;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 1000;
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.pin-flag { color: var(--accent); display: inline-flex; }
.pin-flag svg { width: 12px; height: 12px; }
.list-empty { padding: 22px 12px; text-align: center; color: var(--text-3); font-size: 12.5px; }

.sidebar-foot { position: relative; border-top: 1px solid var(--border); padding-top: 10px; margin-top: 6px; }
.user-chip { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 8px; border-radius: var(--radius-sm); }
.user-chip:hover { background: var(--hover); }
.user-chip-name { flex: 1; text-align: left; font-size: 13.5px; font-weight: 550; }

/* ==========================================================================
   Topbar & messages
   ========================================================================== */
.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.topbar {
  display: flex; align-items: center; gap: 12px; height: 62px; padding: 0 20px;
  border-bottom: 1px solid var(--border); flex: none;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px);
}
.topbar-text { min-width: 0; flex: 1; }
.topbar-text h2 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.topbar-text p { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.topbar-btn {
  width: 40px; height: 40px; border-radius: 10px;
  color: var(--text-2); border: 1px solid var(--border);
  background: var(--surface-2); display: inline-flex;
  align-items: center; justify-content: center;
  transition: all .16s var(--ease);
}
.topbar-btn:hover {
  background: var(--surface-3); color: var(--text);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}
.topbar-btn svg { width: 20px; height: 20px; }

/* 聊天视口与 Codex 导航器 */
.chat-viewport {
  position: relative; flex: 1; display: flex;
  flex-direction: column; min-height: 0; overflow: hidden;
}

.chat-navigator {
  position: absolute; right: 14px; top: 44%;
  transform: translateY(-50%); z-index: 50;
  display: flex; align-items: center; justify-content: flex-end;
  max-height: calc(100% - 150px);
}
.chat-navigator::before {
  content: ""; position: absolute; right: -8px; top: -16px; bottom: -16px; width: 75px;
}
.nav-rail {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-end;
  gap: clamp(4px, 1.1vh, 10px); padding: 8px 6px; cursor: pointer;
  max-height: calc(100vh - 200px);
  user-select: none;
}
.nav-rail::before {
  content: ""; position: absolute; right: -12px; top: -20px; bottom: -20px; width: 75px;
  pointer-events: auto;
}
.nav-dash-wrap {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 5px 4px; cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.nav-dash {
  width: 14px; height: 2.5px; border-radius: 2px;
  background: #525a68;
  transform-origin: right center;
  transition: width 0.18s cubic-bezier(0.16, 1, 0.3, 1), background 0.16s ease, height 0.16s ease;
  will-change: width;
}
/* 实时波浪跟踪中：彻底移除 transition 延迟，实现 0 延迟、100% 精准对齐光标 */
.chat-navigator.is-waving .nav-dash {
  transition: none !important;
}
html[data-theme="light"] .nav-dash {
  background: #94a3b8;
}
.nav-dash-wrap:hover .nav-dash {
  background: var(--text-2);
}
.nav-dash-wrap.is-peak .nav-dash {
  background: var(--text) !important;
}
.nav-dash-wrap.active .nav-dash,
.nav-dash.active {
  width: 22px; height: 3.5px; background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.nav-dash-wrap.active.is-peak .nav-dash {
  background: var(--accent) !important;
  box-shadow: 0 0 14px var(--accent) !important;
}

/* Collapsed 5-dash limit with top/bottom fade */
.chat-navigator:not(:hover) .nav-dash-wrap.is-collapsed-hidden {
  display: none !important;
}
.chat-navigator:not(:hover) .nav-dash-wrap.fade-edge-top .nav-dash,
.chat-navigator:not(:hover) .nav-dash-wrap.fade-edge-bottom .nav-dash {
  opacity: 0.32;
  width: 9px;
}
.chat-navigator:hover .nav-dash-wrap.is-collapsed-hidden {
  display: flex !important;
}
.chat-navigator:hover .nav-dash-wrap.fade-edge-top .nav-dash,
.chat-navigator:hover .nav-dash-wrap.fade-edge-bottom .nav-dash {
  opacity: 1 !important;
  width: 14px !important;
}

.chat-navigator:hover .nav-popover,
.chat-navigator.is-popover-open .nav-popover,
.chat-navigator.is-expanded .nav-popover {
  opacity: 1; visibility: visible; pointer-events: auto;
  transform: translateX(0);
}
/* 预览窗与横杆保留 76px 间距，充裕预留给 44px 波浪展开与呼吸呼吸空间，杜绝遮挡 */
.nav-popover {
  position: absolute; right: 76px; top: 0;
  transform: translateX(6px);
  width: 280px; max-height: 480px;
  background: var(--bg-elev); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong); border-radius: 14px;
  padding: 8px 6px; box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .18s var(--ease), transform .18s var(--ease), visibility .18s;
  z-index: 60;
  pointer-events: auto;
}
/* 悬浮连接桥：大幅加宽到 90px，覆盖横杆与预览窗之间所有空隙，鼠标在横杆与大纲之间滑动绝不丢失 hover */
.nav-popover::after {
  content: "";
  position: absolute;
  top: -30px;
  bottom: -30px;
  right: -90px;
  width: 95px;
  pointer-events: auto;
}
.nav-popover-list { display: flex; flex-direction: column; gap: 3px; }
.nav-popover-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 7px 10px; border-radius: 8px; cursor: pointer;
  transition: background .14s, color .14s;
  user-select: none;
}
.nav-popover-item:hover,
.nav-popover-item.wave-hover { background: var(--hover); }
.nav-popover-item.active { background: var(--accent-soft); }
.nav-popover-item-badge {
  font-size: 11px; font-weight: 700; color: var(--text-3);
  padding: 1.5px 5px; border-radius: 4px; background: var(--surface-2); flex: none;
}
.nav-popover-item.active .nav-popover-item-badge {
  color: var(--accent); background: rgba(59, 130, 246, 0.16);
}
.nav-popover-text {
  font-size: 12.5px; color: var(--text-2); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; flex: 1;
  pointer-events: none;
}
.nav-popover-item:hover .nav-popover-text,
.nav-popover-item.wave-hover .nav-popover-text {
  color: var(--text);
}
.nav-popover-item.active .nav-popover-text {
  color: var(--accent); font-weight: 600;
}
.nav-popover-dash {
  width: 13px; height: 2.5px; border-radius: 2px;
  background: var(--text-3); flex: none;
  transition: all .2s;
  pointer-events: none;
}
.nav-popover-item:hover .nav-popover-dash,
.nav-popover-item.wave-hover .nav-popover-dash {
  background: var(--text-2);
}
.nav-popover-item.active .nav-popover-dash {
  width: 18px; height: 3.5px; background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

@keyframes turnFlash {
  0% { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.6), 0 0 16px rgba(59, 130, 246, 0.35); transform: translateY(-2px); }
  60% { box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4), 0 0 10px rgba(59, 130, 246, 0.2); }
  100% { box-shadow: none; transform: none; }
}
.msg.msg-jump-target .msg-body {
  animation: turnFlash 1.8s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* 拖拽上传遮罩 */
.drop-overlay {
  position: absolute; inset: 0;
  background: rgba(11, 14, 20, 0.82); backdrop-filter: blur(10px);
  z-index: 100; display: flex; align-items: center; justify-content: center;
  pointer-events: none; animation: fadeIn .2s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.drop-box {
  padding: 36px 52px; border: 2.5px dashed #3b82f6; border-radius: 18px;
  background: rgba(59, 130, 246, 0.1); display: flex;
  flex-direction: column; align-items: center; gap: 12px;
  color: #93c5fd; font-size: 16px; font-weight: 550;
  box-shadow: 0 12px 32px rgba(59, 130, 246, 0.25);
}
.drop-box svg { width: 44px; height: 44px; }

/* 增强附件卡片预览 */
.attach-preview { margin-bottom: 8px; }
.attach-card {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px 12px; max-width: 100%;
}
.attach-card img {
  max-height: 48px; max-width: 80px; border-radius: 6px;
  object-fit: cover; border: 1px solid var(--border);
}
.attach-file-badge { display: flex; align-items: center; gap: 8px; }
.attach-file-badge svg { width: 22px; height: 22px; color: #3b82f6; flex: none; }
.attach-file-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.attach-file-name {
  font-size: 12.5px; font-weight: 550; color: var(--text);
  max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.attach-file-size { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.messages { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 26px 0 8px; scroll-behavior: smooth; }
.msg-wrap { max-width: 820px; margin: 0 auto; padding: 0 24px; }
.msg { display: flex; gap: 12px; margin-bottom: 22px; animation: fadeUp .28s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-user { justify-content: flex-end; }
.msg-user .msg-body {
  max-width: 78%; background: var(--user-bubble); color: var(--user-bubble-text);
  padding: 11px 15px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap;
  word-break: break-word; border: 1px solid var(--border);
}
.msg-assistant .msg-avatar {
  flex: none; width: 28px; height: 28px; border-radius: 9px; margin-top: 1px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, #9fb0ff, #5f79ff); color: #0b0d10; font-size: 13px; font-weight: 700;
}
.msg-assistant .msg-body { flex: 1; min-width: 0; padding-top: 2px; }
/* ==========================================================================
   Reasoning & Thinking Block (Antigravity Style)
   ========================================================================== */
.msg-reasoning {
  display: flex;
  flex-direction: column;
  margin: 0 0 12px 0;
  width: 100%;
}

.reasoning-header {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
  width: fit-content;
  color: var(--text-2);
  transition: color 0.16s ease;
}

.reasoning-header:hover {
  color: var(--text);
}

.reasoning-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: #3b82f6;
  flex: none;
}

.reasoning-icon svg {
  width: 17px;
  height: 17px;
}

.reasoning-title {
  font-size: 13.5px;
  font-weight: 550;
  letter-spacing: -0.01em;
}

.reasoning-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  color: var(--text-3);
  transition: transform 0.22s var(--ease);
}

.reasoning-caret svg {
  width: 13px;
  height: 13px;
}

.msg-reasoning.is-expanded .reasoning-caret {
  transform: rotate(180deg);
}

/* Partial preview when collapsed - matching user reference image */
.reasoning-preview {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 6px;
  padding: 4px 0 4px 12px;
  border-left: 2px solid rgba(255, 255, 255, 0.16);
  cursor: pointer;
  transition: border-color 0.16s ease;
}

.reasoning-preview:hover {
  border-left-color: rgba(96, 165, 250, 0.5);
}

.reasoning-preview-bullet {
  color: var(--text-3);
  font-size: 14px;
  line-height: 1.5;
  flex: none;
}

.reasoning-preview-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-3);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  white-space: pre-wrap;
}

/* Full content when expanded */
.reasoning-content {
  margin-top: 8px;
  padding: 8px 0 8px 14px;
  border-left: 2px solid rgba(59, 130, 246, 0.45);
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-2);
  word-break: break-word;
  max-height: 520px;
  overflow-y: auto;
}

.reasoning-content p {
  margin: 0 0 10px;
}
.reasoning-content p:last-child {
  margin-bottom: 0;
}

/* Antigravity-style streaming thinking animations */
@keyframes thinkShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.thinking-shimmer {
  background: linear-gradient(90deg, #9ca3af 0%, #ffffff 40%, #60a5fa 65%, #9ca3af 100%);
  background-size: 200% 100%;
  animation: thinkShimmer 2.2s infinite linear;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 600;
}

@keyframes thinkRotatePulse {
  0% { transform: scale(1) rotate(0deg); opacity: 0.85; }
  50% { transform: scale(1.18) rotate(180deg); opacity: 1; filter: drop-shadow(0 0 7px rgba(96, 165, 250, 0.8)); }
  100% { transform: scale(1) rotate(360deg); opacity: 0.85; }
}

.thinking-pulse svg {
  animation: thinkRotatePulse 3s infinite ease-in-out;
  color: #60a5fa;
}

.reasoning-streaming-text {
  margin-top: 6px;
  padding: 4px 0 4px 12px;
  border-left: 2px solid rgba(96, 165, 250, 0.4);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-3);
  max-height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.typing { display: inline-flex; gap: 4px; align-items: center; height: 20px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: blink 1.3s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .28; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.cursor-caret { display: inline-block; width: 2px; height: 1.05em; background: var(--accent); vertical-align: -2px; animation: caret 1s steps(2) infinite; margin-left: 2px; }
@keyframes caret { 50% { opacity: 0; } }

/* markdown */
.md { overflow-wrap: anywhere; word-break: break-word; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 { margin: 20px 0 10px; line-height: 1.35; }
.md h1 { font-size: 20px; }
.md h2 { font-size: 17px; }
.md h3 { font-size: 15.5px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 22px; }
.md li { margin: 4px 0; }
.md li > p { margin: 0; }
.md blockquote {
  margin: 0 0 12px; padding: 8px 14px; border-left: 3px solid var(--accent-line);
  background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-2);
}
.md code {
  font-family: var(--mono); font-size: 12.5px; background: var(--surface-2);
  padding: 1.5px 5px; border-radius: 6px; border: 1px solid var(--border);
}
.md pre {
  position: relative; margin: 0 0 14px; padding: 14px 15px; background: var(--code-bg);
  border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto;
}
.md pre code { background: none; border: none; padding: 0; font-size: 12.5px; line-height: 1.65; }
.md table { display: table; width: 100%; min-width: 100%; table-layout: auto; border-collapse: collapse; margin: 0 0 14px; font-size: 13px; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; word-break: normal; overflow-wrap: break-word; }
.md th { background: var(--surface-2); font-weight: 600; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.md img { max-width: 100%; border-radius: var(--radius); }
.code-copy {
  position: absolute; top: 8px; right: 8px; height: 26px; padding: 0 9px;
  font-size: 11.5px; border-radius: 7px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text-2); opacity: 0; transition: opacity .16s;
}
.md pre:hover .code-copy { opacity: 1; }
.code-copy:hover { color: var(--text); border-color: var(--border-strong); }

/* empty state */
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 24px 60px; }
.empty-state h3 { font-size: 20px; margin-bottom: 8px; }
.empty-state .muted { font-size: 13.5px; max-width: 440px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 28px; max-width: 620px; }
.suggestion {
  padding: 10px 15px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--border); font-size: 13px; color: var(--text-2);
  transition: all .16s var(--ease);
}
.suggestion:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); transform: translateY(-1px); }

/* ==========================================================================
   Composer
   ========================================================================== */
.composer-wrap { flex: none; padding: 0 24px 18px; }
.attach-preview { position: relative; display: inline-flex; margin: 0 0 8px 40px; }
.attach-preview img { width: 74px; height: 74px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border-strong); }
.attach-preview .icon-btn { position: absolute; top: -7px; right: -7px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 50%; }
.composer {
  display: flex; align-items: flex-end; gap: 8px; max-width: 820px; margin: 0 auto;
  padding: 8px 8px 8px 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.composer:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); }
.composer textarea {
  flex: 1; min-height: 24px; max-height: 200px; padding: 9px 2px;
  background: none; border: none; resize: none; outline: none; line-height: 1.55;
}
.composer textarea::placeholder { color: var(--text-3); }
.send-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: var(--accent-strong); color: #fff;
  transition: background .16s var(--ease), opacity .16s, transform .12s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.send-btn:hover { background: var(--accent); }
.send-btn:active:not(:disabled) { transform: scale(0.93); }
.send-btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.send-btn svg { width: 18px; height: 18px; }
.stop-btn { background: var(--surface-3); color: var(--text); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; max-width: 820px; margin: 8px auto 0; }
.composer-hint { font-size: 11.5px; color: var(--text-3); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12px; color: var(--text-2); }
.switch input { display: none; }
.switch-track { width: 32px; height: 18px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border); position: relative; transition: background .18s var(--ease); flex: none; }
.switch-thumb { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--text-3); transition: transform .18s var(--ease), background .18s; }
.switch input:checked + .switch-track { background: rgba(224, 164, 74, .22); border-color: rgba(224, 164, 74, .5); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(14px); background: var(--warn); }
.switch input:checked ~ .switch-label { color: var(--warn); }

/* ==========================================================================
   Settings panel
   ========================================================================== */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .22s var(--ease); z-index: 60;
}
.app.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }

.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(var(--panel-w), 100vw);
  display: flex; flex-direction: column; background: var(--bg-elev);
  border-left: 1px solid var(--border); box-shadow: var(--shadow);
  transform: translateX(102%); transition: transform .3s var(--ease); z-index: 70;
}
.panel.open { transform: none; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex: none; }
.panel-tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.panel-tabs button {
  padding: 8px 13px; border-radius: var(--radius-sm); font-size: 13.5px; color: var(--text-2); white-space: nowrap;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.panel-tabs button:hover { background: var(--hover); color: var(--text); }
.panel-tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; }
.panel-section { margin-bottom: 26px; }
.panel-section > h4 { font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); margin-bottom: 10px; }

.key-row, .file-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.key-row + .key-row, .file-row + .file-row { margin-top: 8px; }
.key-info { flex: 1; min-width: 0; }
.key-name { font-size: 13.5px; font-weight: 550; display: flex; align-items: center; gap: 8px; }
.key-value { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.key-empty { color: var(--text-3); font-size: 12.5px; }
.key-actions { display: flex; gap: 6px; flex: none; }
.key-input { width: 100%; margin-top: 8px; }

.skill-row { cursor: pointer; }
.skill-row:hover { border-color: var(--border-strong); background: var(--surface-2); }
.skill-row .file-info { min-width: 0; flex: 1; }
.skill-row .file-name { font-weight: 550; font-size: 13.5px; }
.skill-row .file-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.editor-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.editor-head .grow { min-width: 0; }
.editor-title { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor-actions { display: flex; gap: 8px; flex: none; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .search-wrap { flex: 1; margin: 0; }

/* ==========================================================================
   Toasts, loading bar
   ========================================================================== */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 10px 16px; border-radius: 999px; font-size: 13px;
  background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text);
  box-shadow: var(--shadow); animation: toastIn .22s var(--ease);
}
.toast.error { color: #fff; background: rgba(200, 60, 60, .92); border-color: transparent; }
.toast.ok { color: #fff; background: rgba(38, 148, 108, .94); border-color: transparent; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.loading-bar { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: var(--accent); z-index: 300; transition: width .3s var(--ease), opacity .3s; opacity: 0; }
.loading-bar.on { opacity: 1; }
.spinner { width: 15px; height: 15px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ==========================================================================
   Responsive
   ========================================================================== */
.sidebar-close-btn { display: none; }

@media (max-width: 1024px) {
  :root { --panel-w: 100vw; }
}
@media (max-width: 860px) {
  .app {
    grid-template-columns: minmax(0, 1fr) !important;
    height: 100dvh;
    min-height: -webkit-fill-available;
  }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: 86vw; max-width: 320px; z-index: 100;
    transform: translateX(-105%);
    transition: transform .28s cubic-bezier(0.32, 0.72, 0, 1);
    opacity: 1 !important; pointer-events: auto !important;
    box-shadow: 4px 0 28px rgba(0, 0, 0, 0.5);
    padding-top: max(14px, env(safe-area-inset-top));
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .app.sidebar-open .sidebar {
    transform: translateX(0) !important;
  }
  .sidebar-close-btn {
    display: inline-flex !important;
    width: 34px; height: 34px; border-radius: var(--radius-sm);
    color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
    align-items: center; justify-content: center;
    cursor: pointer;
  }
  .sidebar-close-btn:hover {
    color: var(--text); background: var(--surface-3);
  }
  .drawer-backdrop { z-index: 90; }
  .app.sidebar-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
  .only-mobile { display: inline-flex; }
  .topbar {
    padding: 0 10px; gap: 8px; height: 58px;
    padding-top: max(0px, env(safe-area-inset-top));
  }
  .topbar-btn { width: 36px; height: 36px; border-radius: 9px; }
  .topbar-btn svg { width: 18px; height: 18px; }
  .topbar-actions { gap: 6px; }
  .msg-wrap { padding: 0 12px; }
  .msg-user .msg-body { max-width: 90%; }
  .composer-wrap {
    padding: 0 10px max(12px, env(safe-area-inset-bottom));
  }
  .composer textarea {
    font-size: 16px; /* 防止 iOS 键盘弹出时网页被自动缩放 */
  }
  .send-btn {
    width: 38px;
    height: 38px;
  }
  .send-btn svg {
    width: 20px;
    height: 20px;
  }
  .empty-state { padding-bottom: 24px; padding-left: 12px; padding-right: 12px; }
  .suggestions { gap: 8px; }
  .panel {
    width: 100vw !important; max-width: 100vw !important; z-index: 110;
    padding-top: max(0px, env(safe-area-inset-top));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }
  .panel-resizer { display: none !important; }
  .panel-body { padding: 14px; }
  .chat-navigator { display: none !important; }
}
@media (max-width: 480px) {
  .login-card { padding: 28px 22px 22px; }
  .empty-state h3 { font-size: 18px; }
}

/* ==========================================================================
   富文本渲染增强（Markdown 阅读体验）
   ========================================================================== */
html[data-theme="dark"] {
  --hl-keyword: #a78bfa; --hl-string: #6fd39b; --hl-comment: #7a8595;
  --hl-number: #f0a868; --hl-func: #7cc4ff; --hl-tag: #ef7d8a;
  --hl-attr: #ffd479; --hl-var: #ffb3c1;
  --callout-note: rgba(88, 166, 255, .12); --callout-note-line: rgba(88, 166, 255, .5);
  --callout-tip: rgba(66, 192, 138, .12); --callout-tip-line: rgba(66, 192, 138, .5);
  --callout-important: rgba(157, 124, 255, .14); --callout-important-line: rgba(157, 124, 255, .55);
  --callout-warning: rgba(224, 164, 74, .14); --callout-warning-line: rgba(224, 164, 74, .55);
  --callout-caution: rgba(239, 107, 107, .14); --callout-caution-line: rgba(239, 107, 107, .55);
}
html[data-theme="light"] {
  --hl-keyword: #7c3aed; --hl-string: #0f7b53; --hl-comment: #8a94a6;
  --hl-number: #b45309; --hl-func: #1d63d6; --hl-tag: #c2185b;
  --hl-attr: #8a6d1f; --hl-var: #b23a5b;
  --callout-note: rgba(37, 99, 235, .08); --callout-note-line: rgba(37, 99, 235, .45);
  --callout-tip: rgba(15, 157, 109, .09); --callout-tip-line: rgba(15, 157, 109, .45);
  --callout-important: rgba(124, 58, 237, .09); --callout-important-line: rgba(124, 58, 237, .45);
  --callout-warning: rgba(180, 120, 10, .1); --callout-warning-line: rgba(180, 120, 10, .45);
  --callout-caution: rgba(225, 29, 72, .09); --callout-caution-line: rgba(225, 29, 72, .45);
}

.md { font-size: 15px; line-height: 1.75; }
.md p { margin: 0 0 13px; }
.md .md-strong { font-weight: 700; color: var(--text); }
.md .md-mark { background: linear-gradient(transparent 58%, var(--accent-soft) 58%); color: inherit; padding: 0 1px; border-radius: 3px; }
.md .md-link { border-bottom: 1px solid var(--accent-line); padding-bottom: .5px; word-break: break-all; }

/* 任务列表 */
.md .md-task { display: flex; align-items: flex-start; gap: 8px; }
.md .md-task input { margin: 5px 0 0; width: 14px; height: 14px; accent-color: var(--accent); flex: none; }
.md li.md-task-item { list-style: none; margin-left: -18px; }

/* 提示框 / Callout */
.md .callout { border-radius: var(--radius); border: 1px solid var(--border); border-left: 3px solid var(--border-strong); padding: 12px 14px; margin: 0 0 14px; }
.md .callout-head { display: flex; align-items: center; gap: 7px; font-weight: 650; font-size: 13.5px; margin-bottom: 6px; }
.md .callout-icon { font-size: 14px; }
.md .callout-body > *:last-child { margin-bottom: 0; }
.md .callout-note { background: var(--callout-note); border-left-color: var(--callout-note-line); }
.md .callout-tip { background: var(--callout-tip); border-left-color: var(--callout-tip-line); }
.md .callout-important { background: var(--callout-important); border-left-color: var(--callout-important-line); }
.md .callout-warning { background: var(--callout-warning); border-left-color: var(--callout-warning-line); }
.md .callout-caution { background: var(--callout-caution); border-left-color: var(--callout-caution-line); }

/* 代码块（语言标签 + 复制） */
.md .code-block { margin: 0 0 14px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--code-bg); }
.md .code-head { display: flex; align-items: center; justify-content: space-between; padding: 5px 8px 5px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.md .code-lang { font-size: 10.5px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.md .code-block pre { margin: 0; border: none; border-radius: 0; background: none; padding: 13px 15px; }
.md .code-block .code-copy {
  position: static; opacity: 1; height: 24px; padding: 0 10px; font-size: 11.5px;
  border-radius: 7px; background: transparent; border-color: transparent; color: var(--text-3);
}
.md .code-block .code-copy:hover { background: var(--hover); border-color: var(--border); color: var(--text); opacity: 1; }
.hl-keyword { color: var(--hl-keyword); }
.hl-string { color: var(--hl-string); }
.hl-comment { color: var(--hl-comment); font-style: italic; }
.hl-number { color: var(--hl-number); }
.hl-func { color: var(--hl-func); }
.hl-tag { color: var(--hl-tag); }
.hl-attr { color: var(--hl-attr); }
.hl-var { color: var(--hl-var); }

/* 表格渲染增强 */
.md .table-wrap {
  margin: 14px 0 18px;
  overflow-x: auto;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  -webkit-overflow-scrolling: touch;
}
.md .table-wrap table {
  margin: 0;
  border: none;
  border-collapse: separate;
  border-spacing: 0;
  display: table !important;
  width: max-content;
  min-width: 100% !important;
  table-layout: auto;
  font-size: 13px;
  line-height: 1.6;
}
.md .table-wrap th,
.md .table-wrap td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: middle;
  word-break: normal !important;
  overflow-wrap: break-word !important;
  line-height: 1.5;
}
.md .table-wrap thead th {
  background: var(--surface-2);
  font-weight: 650;
  color: var(--text);
  border-bottom: 2px solid var(--border-strong);
  position: sticky;
  top: 0;
  white-space: nowrap;
  z-index: 2;
}
.md .table-wrap thead th:first-child {
  z-index: 3;
  background: var(--surface-2);
}
.md .table-wrap table:not(.table-col1-compact) th:first-child,
.md .table-wrap table:not(.table-col1-compact) td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  min-width: 130px;
  max-width: 300px;
  font-weight: 600;
  white-space: normal;
  word-break: normal !important;
  overflow-wrap: break-word !important;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.12);
}
.md .table-wrap table.table-col1-compact th,
.md .table-wrap table.table-col1-compact td {
  padding: 6px 10px;
  font-size: 12.5px;
}
.md .table-wrap table.table-col1-compact th:first-child,
.md .table-wrap table.table-col1-compact td:first-child,
.table-col1-compact th:first-child,
.table-col1-compact td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  min-width: 38px !important;
  width: 52px !important;
  max-width: 70px !important;
  text-align: center !important;
  white-space: nowrap !important;
  padding: 6px 4px !important;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.12);
}
.md .table-wrap tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--surface-2) 45%, transparent);
}
.md .table-wrap tbody tr:nth-child(even) td:first-child {
  background: color-mix(in srgb, var(--surface-2) 85%, var(--surface));
}
.md .table-wrap tbody tr:hover td {
  background: var(--surface-hover);
}
.md .table-wrap tbody tr:hover td:first-child {
  background: var(--surface-hover);
}

@media (max-width: 860px) {
  .md .table-wrap table:not(.table-col1-compact) th:first-child,
  .md .table-wrap table:not(.table-col1-compact) td:first-child {
    min-width: 110px;
    max-width: 42vw;
  }
}

/* 目录 */
.md .md-toc { margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.md .md-toc summary { cursor: pointer; font-size: 12.5px; font-weight: 650; color: var(--text-2); }
.md .md-toc ol { margin: 8px 0 0; padding-left: 18px; }
.md .md-toc li { font-size: 13px; margin: 3px 0; }
.md .md-toc .toc-l3 { margin-left: 14px; list-style: circle; }
.md .md-toc a { color: var(--text-2); border: none; }
.md .md-toc a:hover { color: var(--accent); }
.md .md-anchor { scroll-margin-top: 80px; }

/* 引用芯片（本地文件 / 附件 / 记忆链接） */
.file-chip, .wiki-chip {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%;
  margin: 2px 2px; padding: 4px 10px 4px 8px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text); cursor: pointer; vertical-align: baseline;
  transition: all .16s var(--ease);
}
.file-chip:hover, .wiki-chip:hover { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.file-chip-icon { font-size: 13px; }
.file-chip-name { font-family: var(--mono); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.file-chip-action { font-size: 11px; color: var(--text-3); border-left: 1px solid var(--border); padding-left: 7px; }
.file-chip:hover .file-chip-action { color: var(--accent); }
.file-chip-media { border-color: var(--accent-line); background: var(--accent-soft); }
.wiki-chip { font-size: 12px; }

/* RAG 知识库手册引用芯片 */
/* RAG 知识库手册引用芯片 */
.rag-chip {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  margin: 1px 3px; padding: 2.5px 9px 2.5px 7px; border-radius: 999px;
  background: rgba(59, 130, 246, 0.09); border: 1px solid rgba(59, 130, 246, 0.32);
  color: #3b82f6; font-size: 12px; font-family: var(--mono); font-weight: 550;
  cursor: pointer; vertical-align: baseline; text-decoration: none;
  transition: all .16s var(--ease);
}
.rag-chip:hover {
  background: rgba(59, 130, 246, 0.2); border-color: #3b82f6;
  color: #60a5fa; box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}
.rag-chip-icon { font-size: 13px; line-height: 1; }
.rag-chip-text { letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.rag-chip-arrow { font-size: 11px; color: var(--text-3); transition: transform .15s ease; }
.rag-chip:hover .rag-chip-arrow { transform: translateX(2px); color: #60a5fa; }

/* 未收录/置灰但可点击获取状态 */
.rag-chip.rag-chip-disabled, .rag-chip-disabled {
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
  color: var(--text-3) !important;
  cursor: pointer !important;
  opacity: 0.72;
  box-shadow: none !important;
  transition: all .16s var(--ease);
}
.rag-chip.rag-chip-disabled:hover, .rag-chip-disabled:hover {
  opacity: 0.95;
  border-color: var(--accent-line) !important;
  background: var(--surface-3) !important;
  color: var(--text-2) !important;
  transform: translateY(-1px);
}
.rag-badge-unavail {
  font-size: 10px; font-weight: normal;
  padding: 0.5px 4.5px; border-radius: 4px;
  background: var(--surface-3); color: var(--text-3);
  margin-left: 2px;
}

/* RAG 抽屉多小节连续滚动与导航 */
.rag-preview-container {
  display: flex; flex-direction: column; gap: 16px; width: 100%;
}
/* 吸顶书签栏 */
.rag-bookmark-bar {
  position: sticky; top: -16px; z-index: 25;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.rag-bar-left {
  display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;
}
.rag-bookmark-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .18s var(--ease); flex: none;
}
.rag-bookmark-trigger:hover,
.rag-bookmark-trigger.open {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
}
.rag-bookmark-icon {
  width: 15px; height: 15px; color: var(--accent); flex: none;
}
.rag-bookmark-count {
  font-size: 11px; padding: 1.5px 6px;
  background: rgba(59, 130, 246, 0.18); color: var(--accent);
  border-radius: 999px; font-weight: 700;
}
.rag-bookmark-arrow {
  width: 14px; height: 14px; transition: transform 0.2s ease; flex: none;
}
.rag-bookmark-trigger.open .rag-bookmark-arrow {
  transform: rotate(180deg);
}

.rag-current-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); min-width: 0; flex: 1;
}
.rag-current-order {
  font-size: 11px; font-weight: 700; color: #fff;
  background: #3b82f6; padding: 1.5px 6px; border-radius: 4px; flex: none;
}
.rag-current-title {
  font-size: 12.5px; color: var(--text); font-weight: 550;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.rag-bar-right {
  display: flex; align-items: center; gap: 4px; flex: none;
}
.rag-step-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-2); font-size: 14px;
  cursor: pointer; transition: all .15s ease;
}
.rag-step-btn:hover:not(:disabled) {
  background: var(--surface-hover); border-color: var(--accent); color: var(--text);
}
.rag-step-btn:disabled {
  opacity: 0.35; cursor: not-allowed;
}

/* 书签下拉浮层 */
.rag-bookmark-dropdown {
  position: absolute; top: 48px; left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
  max-height: 480px; display: flex; flex-direction: column; overflow: hidden;
  animation: dropSlideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes dropSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.rag-dropdown-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.rag-dropdown-title {
  font-size: 12.5px; font-weight: 650; color: var(--text-2);
}
.rag-dropdown-close {
  background: none; border: none; color: var(--accent); font-size: 12px;
  cursor: pointer; padding: 2px 6px;
}
.rag-dropdown-close:hover {
  text-decoration: underline;
}
.rag-bookmark-list {
  padding: 6px; overflow-y: auto; max-height: 380px;
  display: flex; flex-direction: column; gap: 4px;
}
.rag-bookmark-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-sm); text-align: left; cursor: pointer;
  transition: all .16s ease; width: 100%;
}
.rag-bookmark-item:hover {
  background: var(--surface-hover); border-color: var(--border);
}
.rag-bookmark-item.active {
  background: var(--accent-soft); border-color: var(--accent-line);
}
.rag-item-left {
  display: flex; align-items: center; gap: 6px; flex: none;
}
.rag-item-badge {
  font-size: 11px; font-weight: 700; padding: 2px 7px;
  background: var(--surface-2); color: var(--text-2); border-radius: 6px;
}
.rag-bookmark-item.active .rag-item-badge,
.rag-item-badge.target {
  background: #3b82f6; color: #fff;
}
.rag-item-center {
  flex: 1; min-width: 0;
}
.rag-item-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px;
}
.rag-bookmark-item.active .rag-item-title {
  color: #60a5fa;
}
.rag-item-meta {
  font-size: 11.5px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rag-item-right {
  flex: none;
}
.rag-item-target-tag {
  font-size: 11px; padding: 2px 7px;
  background: rgba(59, 130, 246, 0.2); color: #60a5fa;
  border-radius: 999px; font-weight: 600;
}
.rag-item-arrow {
  color: var(--text-3); font-size: 13px; opacity: 0.5; transition: all .15s;
}
.rag-bookmark-item:hover .rag-item-arrow {
  opacity: 1; transform: translateX(2px); color: var(--accent);
}
.rag-sec-list {
  display: flex; flex-direction: column; gap: 16px;
}
.rag-sec-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  transition: border-color .22s ease, box-shadow .22s ease;
  scroll-margin-top: 80px;
}
.rag-sec-card.rag-sec-target {
  border-color: rgba(59, 130, 246, 0.45);
}
.rag-sec-card.rag-sec-highlight {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25), 0 4px 18px rgba(59, 130, 246, 0.15);
  animation: ragCardPulse 1.8s ease-in-out;
}
.md-anchor.rag-sec-highlight,
h2.rag-sec-highlight,
h3.rag-sec-highlight,
h4.rag-sec-highlight {
  color: var(--accent) !important;
  background: rgba(59, 130, 246, 0.12);
  border-radius: 4px;
  outline: 2px solid rgba(59, 130, 246, 0.4);
  padding: 2px 6px;
  transition: all 0.3s ease;
}
@keyframes ragCardPulse {
  0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.6); }
  50% { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.2); }
  100% { box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25); }
}
.rag-sec-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 10px; margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.rag-sec-head-left {
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.rag-sec-badge {
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-2); flex: none;
}
.rag-sec-badge-target {
  background: #3b82f6; color: #fff;
}
.rag-sec-head-title {
  margin: 0; font-size: 14.5px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rag-target-tag {
  font-size: 11px; font-weight: 600; color: #3b82f6;
  background: rgba(59, 130, 246, 0.12); padding: 2px 8px; border-radius: 999px;
  flex: none; border: 1px solid rgba(59, 130, 246, 0.3);
}
.rag-sec-content {
  font-size: 14px; line-height: 1.7;
}

/* 技能与记忆元信息卡片 */
.skill-meta-card {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 14px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 16px;
}
.skill-meta-desc { font-size: 12.5px; color: var(--text-2); line-height: 1.5; width: 100%; margin-top: 4px; }

/* 消息工具条 / 折叠 */
.msg-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; opacity: 0; transition: opacity .18s var(--ease); }
.msg-assistant:hover .msg-actions { opacity: 1; }
.msg-actions button {
  height: 24px; padding: 0 9px; border-radius: 7px; font-size: 11.5px; color: var(--text-3);
  border: 1px solid transparent; background: transparent;
}
.msg-actions button:hover { color: var(--text); background: var(--hover); border-color: var(--border); }
.msg-time { font-size: 11px; color: var(--text-3); margin-left: 2px; }
.md-collapsed { position: relative; max-height: 420px; overflow: hidden; }
.md-collapsed::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 96px;
  background: linear-gradient(transparent, var(--bg)); pointer-events: none;
}
.md-expand {
  display: inline-flex; align-items: center; gap: 5px; margin: 2px 0 14px;
  padding: 5px 12px; border-radius: 999px; font-size: 12.5px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
}
.md-expand:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }

/* 回到最新 */
.scroll-fab {
  position: absolute; right: 20px; bottom: 18px; z-index: 80;
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28); transition: all .18s var(--ease);
  pointer-events: auto;
}
.scroll-fab:hover { color: var(--accent); border-color: var(--accent-line); transform: translateY(-2px); }
.scroll-fab svg { width: 18px; height: 18px; }

/* ==========================================================================
   文件预览抽屉
   ========================================================================== */
.preview-panel {
  width: var(--preview-panel-width, min(760px, 100vw));
  min-width: 380px;
  max-width: 100vw;
}
.panel-resizer {
  position: absolute;
  left: -5px;
  top: 0;
  bottom: 0;
  width: 10px;
  cursor: col-resize;
  z-index: 100;
  user-select: none;
  touch-action: none;
}
.panel-resizer::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: transparent;
  transition: background .16s, box-shadow .16s;
}
.panel-resizer:hover::after,
.panel-resizer.is-dragging::after {
  background: #3b82f6;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.7);
}
body.is-resizing-drawer {
  user-select: none !important;
  cursor: col-resize !important;
}

.preview-title-wrap { flex: 1; min-width: 0; }
.preview-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-path { font-family: var(--mono); font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; }
.preview-actions { display: flex; gap: 6px; flex: none; }
.preview-panel .drawer-content { display: flex; flex-direction: column; height: 100%; }
.preview-body {
  flex: 1; min-height: 0;
  overflow-x: auto; overflow-y: auto;
  padding: 16px 20px 24px;
  display: flex; flex-direction: column;
  -webkit-overflow-scrolling: touch;
}
.preview-body::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}
.preview-body::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track {
  background: var(--surface-2);
  border-radius: 4px;
}
.preview-body::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.preview-body::-webkit-scrollbar-thumb:hover,
.table-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
  background-clip: content-box;
}
.preview-doc { max-width: 100%; }
.preview-pre {
  margin: 0; padding: 14px 16px; background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius); font-family: var(--mono); font-size: 12.5px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word; color: var(--text);
}
.preview-media { text-align: center; }
.preview-media img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.preview-pdf-wrap, .preview-web-wrap {
  flex: 1; width: 100%; height: 100%; display: flex; flex-direction: column; min-height: calc(100vh - 140px);
}
.preview-web-banner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; margin-bottom: 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-3); flex: none;
}
.preview-frame {
  width: 100%; height: 100%; flex: 1; min-height: calc(100vh - 160px);
  border: 1px solid var(--border); border-radius: var(--radius); background: #ffffff;
}
.preview-empty { padding: 26px 8px; text-align: center; color: var(--text-3); font-size: 13px; }
.preview-dir .file-row { cursor: pointer; }
.preview-dir .file-row:hover { border-color: var(--border-strong); background: var(--surface-2); }

@media (max-width: 860px) {
  .md { font-size: 14.5px; }
  .file-chip-name { max-width: 150px; }
  .scroll-fab { right: 14px; bottom: 132px; }
  .preview-body { padding: 14px 14px 22px; }
  .preview-actions .btn { padding: 0 9px; }
}

/* 长会话分页加载 */
.load-earlier {
  display: block; margin: 0 auto 22px; padding: 7px 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2); font-size: 12.5px;
  transition: all .16s var(--ease);
}
.load-earlier:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }

/* ==========================================================================
   Mermaid 图表 / 折叠块 / 图片 / 脚注
   ========================================================================== */
.md .mermaid-block {
  margin: 0 0 16px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); text-align: center; overflow-x: auto;
}
.md .mermaid-block svg { max-width: 100%; height: auto; }
.md .mermaid-src {
  margin: 0; font-family: var(--mono); font-size: 12px; color: var(--text-3);
  white-space: pre-wrap; text-align: left;
}
.md .mermaid-error { border-color: rgba(239, 107, 107, .45); }
.md .mermaid-error-tip { margin-top: 8px; font-size: 11.5px; color: var(--danger, #ef6b6b); }

.md .md-details {
  margin: 0 0 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); overflow: hidden;
}
.md .md-details > summary {
  padding: 9px 14px; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text-2);
  list-style: none; display: flex; align-items: center; gap: 8px;
}
.md .md-details > summary::-webkit-details-marker { display: none; }
.md .md-details > summary::before { content: '▸'; font-size: 12px; color: var(--text-3); transition: transform .18s var(--ease); }
.md .md-details[open] > summary::before { transform: rotate(90deg); }
.md .md-details > summary:hover { color: var(--accent); background: var(--hover); }
.md .md-details-body { padding: 2px 14px 12px; border-top: 1px solid var(--border); }
.md .md-details-body > *:first-child { margin-top: 12px; }
.md .md-details-body > *:last-child { margin-bottom: 0; }

.md .md-figure { margin: 0 0 14px; text-align: center; }
.md .md-img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); cursor: zoom-in; }
.md .md-figure figcaption { margin-top: 6px; font-size: 12px; color: var(--text-3); }

.md .md-footnotes { margin-top: 20px; padding-top: 12px; border-top: 1px dashed var(--border); }
.md .md-footnotes-title { font-size: 12px; font-weight: 650; letter-spacing: .06em; color: var(--text-3); margin-bottom: 6px; }
.md .md-footnotes ol { margin: 0; padding-left: 20px; }
.md .md-footnotes li { font-size: 12.5px; color: var(--text-2); margin: 3px 0; }
.md .md-fn-ref a { color: var(--accent); font-size: 11px; text-decoration: none; padding: 0 1px; }
.md .md-link-ext { font-size: 10px; opacity: .7; margin-left: 2px; }

/* ==========================================================================
   侧边栏导航 / 项目（长任务工作台）
   ========================================================================== */
.btn-projects {
  width: 100%; height: 42px; margin-bottom: 10px; position: relative;
  background: var(--surface-2); border-color: var(--border);
}
.btn-projects:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.nav-badge {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
}
.sidebar-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.sidebar-nav button {
  height: 32px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2); font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: all .16s var(--ease);
}
.sidebar-nav button:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.active-project {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 7px 10px;
  border-radius: var(--radius-sm); background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.active-project .ap-icon { font-size: 15px; }
.active-project .ap-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.active-project .ap-name { font-size: 12.5px; font-weight: 600; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.active-project .ap-path { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.active-project .ap-clear { width: 22px; height: 22px; border-radius: 7px; color: var(--text-3); flex: none; }
.active-project .ap-clear:hover { background: var(--active); color: var(--text); }

.projects-panel { width: min(720px, 100vw); }
.project-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); padding: 14px 16px;
}
.project-card + .project-card { margin-top: 10px; }
.project-card.active { border-color: var(--accent-line); }
.project-card-head { display: flex; gap: 10px; align-items: flex-start; }
.project-icon { font-size: 20px; line-height: 1.2; }
.project-card-title { flex: 1; min-width: 0; }
.pc-name { font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.pc-desc { font-size: 12.5px; color: var(--text-3); margin-top: 3px; word-break: break-word; }
.pc-meta { font-size: 11.5px; color: var(--text-3); text-align: right; white-space: nowrap; }
.pc-folders { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.pc-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Mermaid 工具条 */
.mermaid-toolbar { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 10px; opacity: .5; transition: opacity .16s var(--ease); }
.mermaid-block:hover .mermaid-toolbar { opacity: 1; }
.mermaid-toolbar button {
  height: 24px; padding: 0 10px; border-radius: 7px; font-size: 11.5px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
}
.mermaid-toolbar button:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }

.sidebar-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sidebar-nav button.active { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.badge-danger { background: rgba(239, 107, 107, .12); color: var(--danger); border-color: rgba(239, 107, 107, .3); }

.cron-job {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); padding: 14px 16px;
}
.cron-job + .cron-job { margin-top: 10px; }
.cron-job.paused { background: var(--surface-2); }
.cj-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cj-title { font-size: 14.5px; font-weight: 600; }
.cj-prompt {
  margin-top: 6px; font-size: 12.5px; color: var(--text-2); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.cj-meta { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; font-size: 11.5px; color: var(--text-3); }
.cj-error {
  margin: 0 0 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  background: rgba(239, 107, 107, .1); border: 1px solid rgba(239, 107, 107, .28);
  color: var(--danger); font-size: 11.5px; word-break: break-word;
}
.cj-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.cron-run {
  display: flex; align-items: center; gap: 10px; padding: 7px 2px;
  border-bottom: 1px dashed var(--border); font-size: 12px;
}
.cron-run:last-child { border-bottom: none; }
.cron-run .cr-name { font-weight: 550; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cron-run .cr-time { color: var(--text-3); font-size: 11.5px; }
.cron-run .cr-delivery { color: var(--text-3); font-size: 11.5px; }
.cron-run .cr-error { color: var(--danger); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   移动端轮次快速导航胶囊与大纲抽屉 (Mobile Turn Navigation & Outline Sheet)
   ========================================================================== */
.mobile-turn-pill {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 75;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 5px;
  border-radius: 999px;
  background: rgba(22, 26, 35, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
  user-select: none;
  touch-action: manipulation;
  transition: opacity .18s var(--ease), transform .18s var(--ease);
}
html[data-theme="light"] .mobile-turn-pill {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
}

.mtp-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  padding: 0;
  transition: all .15s;
}
.mtp-btn svg {
  width: 17px;
  height: 17px;
}
.mtp-btn:active {
  transform: scale(0.9);
  background: var(--surface-3);
  color: var(--text);
}
.mtp-btn.disabled,
.mtp-btn:disabled {
  opacity: 0.25;
  pointer-events: none;
}

.mtp-center {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  color: var(--text);
  transition: all .15s;
}
html[data-theme="light"] .mtp-center {
  background: rgba(0, 0, 0, 0.05);
}
.mtp-center:active {
  background: rgba(59, 130, 246, 0.2);
  transform: scale(0.97);
}
.mtp-icon {
  font-size: 13px;
  line-height: 1;
}
.mtp-label {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--text);
  letter-spacing: 0.2px;
}

/* 移动端底部大纲抽屉 (Bottom Sheet) */
.mobile-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .25s cubic-bezier(0.16, 1, 0.3, 1), visibility .25s;
}
.mobile-sheet-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.mobile-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 82vh;
  min-height: 42vh;
  background: var(--surface);
  border-top: 1px solid var(--border-strong);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}
.mobile-sheet-overlay.is-open .mobile-sheet {
  transform: translateY(0);
}

.sheet-drag-handle {
  width: 38px;
  height: 4.5px;
  border-radius: 999px;
  background: var(--text-3);
  opacity: 0.35;
  margin: 10px auto 4px;
  flex: none;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px 12px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.sheet-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sheet-title {
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  margin: 0;
}
.sheet-badge {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
}

.sheet-scrubber-wrap {
  padding: 10px 18px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.sheet-scrubber-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
}
.sheet-scrub-hint {
  color: var(--text-3);
}
.sheet-scrub-val {
  font-weight: 600;
  color: var(--accent);
  font-family: var(--mono);
}
.sheet-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.scrub-label {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-3);
  min-width: 14px;
  text-align: center;
}
.sheet-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--border-strong);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.sheet-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #3b82f6;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
  cursor: pointer;
  transition: transform .12s;
}
.sheet-slider::-webkit-slider-thumb:active {
  transform: scale(1.25);
}

.sheet-quick-actions {
  display: flex;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.sheet-quick-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: all .15s;
}
.sheet-quick-btn svg {
  width: 15px;
  height: 15px;
}
.sheet-quick-btn:active {
  background: var(--surface-3);
  color: var(--text);
  transform: scale(0.98);
}

.sheet-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sheet-item {
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all .16s ease;
  user-select: none;
}
.sheet-item:active {
  background: var(--surface-hover);
  transform: scale(0.985);
}
.sheet-item.active {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.18);
}
.sheet-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}
.sheet-item-num {
  font-size: 12px;
  font-weight: 650;
  color: #3b82f6;
  font-family: var(--mono);
}
.sheet-item-active-badge {
  display: none;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #3b82f6;
  color: #ffffff;
  font-weight: 600;
}
.sheet-item.active .sheet-item-active-badge {
  display: inline-block;
}
.sheet-item-text {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

@media (min-width: 861px) {
  .mobile-turn-pill,
  .mobile-sheet-overlay {
    display: none !important;
  }
}
@media (max-width: 860px) {
  .mobile-turn-pill {
    display: flex;
  }
  .mobile-turn-pill.hidden {
    display: none !important;
  }
  .rag-bookmark-bar {
    top: -12px;
    padding: 6px 10px;
    gap: 8px;
  }
  .rag-bookmark-trigger {
    padding: 5px 8px;
    font-size: 12px;
  }
  .rag-bookmark-btn-label {
    display: none;
  }
  .rag-current-pill {
    padding: 3px 8px;
  }
  .rag-current-title {
    max-width: 140px;
    font-size: 11.5px;
  }
}

/* ==========================================================================
   密码明/暗切换
   ========================================================================== */
.pw-field { position: relative; display: block; }
.pw-field input { padding-right: 42px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border-radius: 9px; color: var(--text-3);
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px;
  background: transparent; border: none; cursor: pointer;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.pw-toggle:hover { background: var(--hover); color: var(--text); }

/* ==========================================================================
   输入框待发送附件列表 (支持多文件上传、进度条、删除)
   ========================================================================== */
.attach-list {
  display: flex; flex-wrap: wrap; gap: 8px; max-width: 820px;
  margin: 0 auto 8px; padding: 0 4px;
}
.attach-item {
  display: flex; align-items: center; gap: 9px; min-width: 200px; max-width: 320px;
  padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  animation: fadeUp .18s var(--ease);
}
.attach-item.failed { border-color: rgba(239, 107, 107, .45); background: rgba(239, 107, 107, .06); }
.ai-thumb { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex: none; }
.ai-icon {
  width: 34px; height: 34px; border-radius: 8px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); font-size: 17px;
}
.ai-body { flex: 1; min-width: 0; }
.ai-name { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-meta { font-size: 11px; color: var(--text-3); }
.attach-item.failed .ai-meta { color: var(--danger); }
.ai-bar { height: 4px; margin-top: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.ai-bar span { display: block; height: 100%; background: var(--accent); transition: width .18s linear; }
.ai-remove { flex: none; color: var(--text-3); }
.ai-remove:hover { color: var(--danger); background: rgba(239, 107, 107, .12); }

/* ==========================================================================
   消息气泡内随附文件与图片 (用户消息气泡 & 历史消息)
   ========================================================================== */
.msg-files {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;
}
.msg-gallery {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;
}
.msg-img-wrap {
  display: inline-flex; flex-direction: column; gap: 4px;
  max-width: 240px; cursor: pointer;
}
.msg-img-thumb {
  max-width: 240px; max-height: 180px; border-radius: 10px;
  object-fit: cover; cursor: pointer; border: 1px solid rgba(255, 255, 255, 0.2);
  background: var(--surface-2);
  transition: transform .16s ease, box-shadow .16s ease;
  display: block;
}
html[data-theme="light"] .msg-img-thumb {
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}
.msg-img-thumb:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}
.msg-img-name {
  font-size: 11px; color: inherit; opacity: .82;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 0 2px;
}
.msg-file {
  display: inline-flex; align-items: center; gap: 9px; max-width: 100%;
  padding: 7px 11px; border-radius: 12px; cursor: pointer; text-align: left;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .22);
  color: inherit; transition: all .16s var(--ease);
  font-family: inherit;
}
html[data-theme="light"] .msg-file {
  background: rgba(255, 255, 255, .72);
  border-color: rgba(16, 26, 44, .14);
}
.msg-file:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.mf-icon { font-size: 16px; flex: none; }
.mf-body { display: flex; flex-direction: column; min-width: 0; max-width: 240px; }
.mf-name { font-size: 12.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mf-size { font-size: 10.5px; opacity: .78; }
.mf-action { font-size: 11px; opacity: .82; border-left: 1px solid currentColor; padding-left: 8px; flex: none; }
.msg-file:hover .mf-action { color: var(--accent); opacity: 1; }

.msg-user .msg-files:only-child,
.msg-user .msg-gallery:only-child {
  margin-top: 0;
}

/* 获取模型列表按钮：高度对齐输入框 (44px)，圆润轻巧，精致悬浮微光 */
.model-fetch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  height: 44px;
  width: 44px;
  min-width: 44px;
  border-radius: var(--radius);
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  padding: 0;
  transition: all .16s var(--ease);
  box-sizing: border-box;
}
.model-fetch-btn:hover {
  background-color: var(--surface-3);
  border-color: var(--accent-line);
  color: var(--accent);
  box-shadow: 0 2px 10px rgba(79, 125, 249, 0.12);
  transform: translateY(-1px);
}
.model-fetch-btn:active {
  transform: translateY(1px) scale(0.97);
}
.model-fetch-btn svg {
  width: 18px;
  height: 18px;
  transition: transform .18s var(--ease), color .18s var(--ease);
}
.model-fetch-btn:hover svg {
  transform: translateY(1px);
}
.model-fetch-btn.is-loading {
  pointer-events: none;
  opacity: 0.8;
}
.model-fetch-btn.is-loading svg {
  animation: modelFetchSpin .75s linear infinite;
}
@keyframes modelFetchSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@media (max-width: 600px) {
  .model-control-row {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .reasoning-field {
    min-width: 0 !important;
    margin-top: 12px !important;
  }
}

/* ==========================================================================
   通用模态对话框 (Dialog Modal) & 2FA 交互体系
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  transition: opacity .2s var(--ease), visibility .2s var(--ease);
}
.modal-backdrop.hidden {
  display: none !important;
  opacity: 0;
  visibility: hidden;
}
.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPopIn .22s var(--ease);
}
@keyframes modalPopIn {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(85vh - 120px);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

/* 2FA 专属组件样式 */
.twofa-card {
  text-align: center;
  padding: 8px 4px;
}
.twofa-num-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
  height: 60px;
  padding: 0 16px;
  font-size: 36px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: 2px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 2px solid var(--accent-line);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(124, 147, 255, 0.22);
  margin: 12px auto;
}
.twofa-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  background: var(--surface-2);
  color: var(--text-2);
  margin-top: 4px;
}
.twofa-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  animation: twofaPulse 1.4s infinite;
}
@keyframes twofaPulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.6; }
}
.twofa-instruction {
  font-size: 13px;
  color: var(--text-2);
  margin: 10px 0 16px;
  line-height: 1.5;
}
.twofa-code-input {
  width: 100%;
  text-align: center;
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 6px;
  padding: 10px 14px;
}

/* 未收录手册抽屉导引卡片 */
.unindexed-guide-card {
  padding: 24px 20px;
  text-align: center;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  margin: 20px auto;
  max-width: 480px;
}
.unindexed-guide-icon {
  font-size: 40px;
  margin-bottom: 12px;
  line-height: 1;
}
.unindexed-guide-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.unindexed-guide-code {
  display: inline-block;
  padding: 3px 10px;
  background: var(--surface-3);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 12px;
}
.unindexed-guide-desc {
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 20px;
}

/* 消息气泡底部的 Airbus 登录提醒卡片 */
.msg-airbus-login-prompt {
  margin-top: 14px;
  margin-bottom: 6px;
  padding: 0;
}
.msg-airbus-login-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3.5px solid var(--accent);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.msg-airbus-login-badge:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}
.msg-airbus-login-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.msg-airbus-login-icon {
  font-size: 22px;
  line-height: 1;
  flex: none;
}
.msg-airbus-login-texts {
  min-width: 0;
  flex: 1;
}
.msg-airbus-login-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.msg-airbus-login-sub {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.4;
  margin-top: 2px;
}
.msg-airbus-login-btn {
  flex: none;
  font-weight: 500;
  white-space: nowrap;
  padding: 0 14px;
  height: 36px;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

@media (max-width: 640px) {
  .msg-airbus-login-badge {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .msg-airbus-login-btn {
    width: 100%;
    justify-content: center;
    height: 38px;
  }
}

