:root, :root[data-theme="light"] {
  color-scheme: light;
  --bg-app: #f4f5f7;
  --bg-app-grad: linear-gradient(180deg, #f4f5f7, #e2e8f0);
  --bg1: #f0f2f5;
  --panel: rgba(255, 255, 255, 0.65);
  --panel2: rgba(255, 255, 255, 0.85);
  --line: rgba(17, 24, 39, 0.10);
  --text: rgba(17, 24, 39, 0.95);
  --muted: rgba(17, 24, 39, 0.55);
  --muted2: rgba(17, 24, 39, 0.40);
  --danger: #ef4444;
  --ok: #10b981;
  --brand: #0ea5e9;
  --brand2: #0284c7;
  --shadow: 0 8px 32px rgba(17, 24, 39, 0.08);
  --glow-shadow: 0 4px 24px rgba(14, 165, 233, 0.15);
  --glass-blur: blur(16px);
  --radius: 12px;
  --radius-sm: 8px;
  --fg: var(--text);
  --matrix-dot: rgba(17, 24, 39, 0.06);
  --matrix-bg: var(--bg-app);
  --nav-hover: rgba(14, 165, 233, 0.06);
  --nav-active: rgba(14, 165, 233, 0.1);
  --nav-active-border: rgba(14, 165, 233, 0.18);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-app: #09090b;
  --bg-app-grad: linear-gradient(180deg, #09090b, #18181b);
  --bg1: #18181b;
  --panel: rgba(24, 24, 27, 0.65);
  --panel2: rgba(39, 39, 42, 0.75);
  --line: rgba(255, 255, 255, 0.12);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.55);
  --muted2: rgba(255, 255, 255, 0.35);
  --danger: #ef4444;
  --ok: #10b981;
  --brand: #38bdf8;
  --brand2: #7dd3fc;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --glow-shadow: 0 4px 24px rgba(56, 189, 248, 0.2);
  --glass-blur: blur(16px);
  --radius: 12px;
  --radius-sm: 8px;
  --fg: var(--text);
  --matrix-dot: rgba(255, 255, 255, 0.06);
  --matrix-bg: var(--bg-app);
  --nav-hover: rgba(56, 189, 248, 0.1);
  --nav-active: rgba(56, 189, 248, 0.15);
  --nav-active-border: rgba(56, 189, 248, 0.3);
}

/* ── Scrollbar: hidden by default, visible on hover ── */
* {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
*:hover {
  scrollbar-color: var(--line) transparent;
}
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
}
*:hover::-webkit-scrollbar-thumb {
  background: var(--line);
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--muted2);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background-color: var(--matrix-bg);
  background-image: radial-gradient(var(--matrix-dot) 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: "Noto Sans SC", ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC",
    sans-serif;
  letter-spacing: 0.2px;
}

* {
  box-sizing: border-box;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.appShell {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 12px;
  height: 100vh;
  padding: 14px;
  transition: grid-template-columns 0.2s ease;
}
.appShellCollapsed {
  grid-template-columns: 56px 1fr;
}

.sidebar {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.sidebarCollapsed .sidebarHeader { padding: 12px 8px 10px 8px; justify-content: center; }
.sidebarCollapsed .sidebarNav { padding: 6px 4px; }
.sidebarCollapsed .navItem { justify-content: center; padding: 8px 0; gap: 0; }
.sidebarCollapsed .configSection { padding: 0 4px; }
.sidebarCollapsed .configHeader { justify-content: center; padding: 8px 0; }

.sidebarHeader {
  padding: 12px 14px 10px 14px;
  border-bottom: 1px solid var(--line);
}

.brandLogo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
}

.brandTitle {
  font-family: "Noto Serif SC", ui-serif, Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brandSub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted2);
  letter-spacing: 0.3px;
}

/* ─── Sidebar navigation ─── */

.sidebarNav {
  padding: 8px 8px 4px 8px;
}

.navItem {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s;
}

.navItem:hover {
  background: var(--nav-hover);
  color: var(--text);
}

.navItemActive {
  background: var(--nav-active);
  color: var(--brand);
  border-color: var(--nav-active-border);
}

/* ─── Config section (collapsible) ─── */

.configSection {
  border-top: 1px solid var(--line);
  margin-top: auto;
}

.configHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.15s;
}

.configHeader:hover {
  background: rgba(14, 165, 233, 0.04);
}

.configProgress {
  font-size: 11px;
  color: var(--muted2);
  background: rgba(14, 165, 233, 0.08);
  padding: 1px 6px;
  border-radius: 8px;
}

.stepList {
  padding: 4px 8px 8px 8px;
  overflow: auto;
  max-height: 320px;
}

.stepItem {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
}

.stepItem:not(.stepItemDisabled):hover {
  background: var(--nav-hover);
  border-color: var(--nav-active-border);
}

.stepItemActive {
  background: var(--nav-active);
  border-color: var(--nav-active-border);
}

.stepItemActive:hover {
  background: var(--nav-active);
  border-color: var(--nav-active-border);
}

.stepItemDisabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.stepItemDisabled:hover {
  background: transparent;
  border-color: transparent;
}

.stepDot {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.96);
  background: linear-gradient(135deg, rgba(14, 165, 233, 1), rgba(124, 58, 237, 1));
  box-shadow: 0 4px 8px rgba(17, 24, 39, 0.1);
  flex: 0 0 auto;
}

.stepDotDone {
  background: linear-gradient(135deg, rgba(16, 185, 129, 1), rgba(14, 165, 233, 1));
}

.stepMeta {
  padding-top: 1px;
}

.stepTitle {
  font-size: 13px;
  font-weight: 650;
}

.stepDesc {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.main {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.topbar {
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
}

.topbarStatusRow {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}

.topbarWs {
  font-weight: 700;
  color: var(--text);
  padding: 2px 8px;
  background: rgba(14, 165, 233, 0.06);
  border-radius: 6px;
}

.topbarIndicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.topbarEpCount {
  color: var(--muted2);
}

.topbarRefreshBtn {
  padding: 4px 8px !important;
  border-radius: 8px !important;
  background: transparent !important;
  border: 1px solid var(--line) !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.topbarRefreshBtn:hover {
  background: rgba(14, 165, 233, 0.06) !important;
}

.topbarConnectBtn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px !important;
  border-radius: 6px !important;
  border: 1px solid var(--brand) !important;
  background: transparent !important;
  color: var(--brand) !important;
  font-size: 11px !important;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.topbarConnectBtn:hover {
  background: rgba(14,165,233,0.06) !important;
}
.topbarConnectBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Window control buttons (custom title bar) */
.winCtrl {
  width: 32px; height: 24px;
  border: none; background: transparent;
  cursor: pointer; font-size: 14px;
  color: var(--muted); display: inline-flex;
  align-items: center; justify-content: center;
  border-radius: 4px;
  transition: background 0.12s;
  -webkit-app-region: no-drag;
}
.winCtrl:hover { background: rgba(0,0,0,0.06); }
.winCtrlClose:hover { background: rgba(255,0,0,0.75); color: #fff; }

/* Secondary button */
.btnSecondary {
  padding: 8px 24px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--fg);
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s;
}
.btnSecondary:hover { background: var(--bg-app); border-color: var(--brand); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--nav-hover);
  color: var(--muted);
  font-size: 12px;
}

.content {
  padding: 18px;
  overflow: auto;
  min-width: 0;
}

.card {
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
  overflow: hidden;
}

.card + .card {
  margin-top: 12px;
}

.cardTitle {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.2px;
  margin: 0 0 8px 0;
}

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

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Welcome step guide */
.welcomeInfoTag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--nav-hover);
  font-size: 12px;
  color: var(--muted);
  font-family: "SF Mono", ui-monospace, monospace;
}
.welcomeSteps {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.welcomeStepRow {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.welcomeStepRow:last-child { border-bottom: none; }
.welcomeStepNum {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.grid3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.labelRow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.label {
  font-size: 12px;
  color: var(--text);
  font-weight: 650;
}

.help {
  font-size: 11px;
  color: var(--muted2);
  line-height: 1.35;
}

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

select option {
  background: var(--bg-app);
  color: var(--text);
}

textarea {
  min-height: 90px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--bg-app), 0 0 8px var(--brand);
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.btnRow {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* (legacy btnSmall override removed; see status section) */

button {
  border: 0;
  cursor: pointer;
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--panel2);
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.2px;
  border: 1px solid var(--line);
  transition: background 0.15s, border-color 0.15s;
}

button:not(.btnPrimary):not(.btnDanger):not(.btnApplyRestart):hover {
  background: var(--bg-app);
  border-color: var(--muted2);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btnPrimary {
  background: var(--brand);
  color: #fff;
  border: 1px solid transparent;
}

.btnPrimary:hover {
  background: var(--brand2);
}

.btnApplyRestart {
  background: #0e7490;
  color: #fff;
  border: 1px solid transparent;
}

.btnApplyRestart:hover {
  background: #0c6a82;
}

.btnDanger {
  background: rgba(255, 77, 109, 0.16);
  border-color: rgba(255, 77, 109, 0.28);
}

.btnDanger:hover {
  background: rgba(255, 77, 109, 0.18);
  border-color: rgba(255, 77, 109, 0.32);
}
.footer {
  border-top: 1px solid var(--line);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.errorBox {
  margin-top: 10px;
  border: 1px solid rgba(255, 77, 109, 0.28);
  background: rgba(255, 77, 109, 0.1);
  color: var(--danger);
  border-radius: 14px;
  padding: 12px;
  white-space: pre-wrap;
}

.okBox {
  margin-top: 10px;
  border: 1px solid rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.1);
  border-radius: 14px;
  padding: 12px;
  color: var(--ok);
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 12px 0;
}

/* Chat view: full-height content without padding */
.contentChat {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Chat markdown content styling */
.chatMdContent {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

.chatMdContent p {
  margin: 0.4em 0;
}

.chatMdContent pre {
  background: var(--bg-app);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  overflow-x: auto;
  font-size: 12px;
  margin: 8px 0;
  color: var(--text);
}

.chatMdContent code {
  background: var(--bg-app);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--text);
}

.chatMdContent pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

/* Dark mode: override highlight.js github-light colors for readability */
:root[data-theme="dark"] .hljs {
  color: #adbac7;
  background: transparent;
}
:root[data-theme="dark"] .hljs-doctag,
:root[data-theme="dark"] .hljs-keyword,
:root[data-theme="dark"] .hljs-meta .hljs-keyword,
:root[data-theme="dark"] .hljs-template-tag,
:root[data-theme="dark"] .hljs-template-variable,
:root[data-theme="dark"] .hljs-type,
:root[data-theme="dark"] .hljs-variable.language_ {
  color: #f47067;
}
:root[data-theme="dark"] .hljs-title,
:root[data-theme="dark"] .hljs-title.class_,
:root[data-theme="dark"] .hljs-title.class_.inherited__,
:root[data-theme="dark"] .hljs-title.function_ {
  color: #dcbdfb;
}
:root[data-theme="dark"] .hljs-attr,
:root[data-theme="dark"] .hljs-attribute,
:root[data-theme="dark"] .hljs-literal,
:root[data-theme="dark"] .hljs-meta,
:root[data-theme="dark"] .hljs-number,
:root[data-theme="dark"] .hljs-operator,
:root[data-theme="dark"] .hljs-variable,
:root[data-theme="dark"] .hljs-selector-attr,
:root[data-theme="dark"] .hljs-selector-class,
:root[data-theme="dark"] .hljs-selector-id {
  color: #6cb6ff;
}
:root[data-theme="dark"] .hljs-regexp,
:root[data-theme="dark"] .hljs-string,
:root[data-theme="dark"] .hljs-meta .hljs-string {
  color: #96d0ff;
}
:root[data-theme="dark"] .hljs-built_in,
:root[data-theme="dark"] .hljs-symbol {
  color: #f69d50;
}
:root[data-theme="dark"] .hljs-comment,
:root[data-theme="dark"] .hljs-code,
:root[data-theme="dark"] .hljs-formula {
  color: #768390;
}
:root[data-theme="dark"] .hljs-name,
:root[data-theme="dark"] .hljs-quote,
:root[data-theme="dark"] .hljs-selector-tag,
:root[data-theme="dark"] .hljs-selector-pseudo {
  color: #8ddb8c;
}
:root[data-theme="dark"] .hljs-subst {
  color: #adbac7;
}
:root[data-theme="dark"] .hljs-section {
  color: #316dca;
}
:root[data-theme="dark"] .hljs-bullet {
  color: #eac55f;
}
:root[data-theme="dark"] .hljs-emphasis {
  color: #adbac7;
}
:root[data-theme="dark"] .hljs-strong {
  color: #adbac7;
}
:root[data-theme="dark"] .hljs-addition {
  color: #b4f1b4;
  background-color: #1b4721;
}
:root[data-theme="dark"] .hljs-deletion {
  color: #ffd8d3;
  background-color: #78191b;
}

/* Light mode: ensure hljs background is transparent (parent provides it) */
:root[data-theme="light"] .hljs {
  background: transparent;
}

.chatMdContent ul,
.chatMdContent ol {
  padding-left: 20px;
  margin: 0.4em 0;
}

.chatMdContent blockquote {
  border-left: 3px solid var(--brand);
  margin: 0.4em 0;
  padding: 4px 12px;
  color: var(--muted);
  background: var(--bg1);
  border-radius: 0 8px 8px 0;
}

.chatMdContent table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}

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

.chatMdContent th {
  background: var(--bg1);
  font-weight: 700;
}

/* Bouncing dots animation */
.dotBounce {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: var(--muted);
  animation: dotBounce 1.2s infinite ease-in-out;
}

@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Health status dot */
.healthDot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 4px;
  margin-right: 6px;
  flex-shrink: 0;
}

.healthDot.healthy { background: rgba(16, 185, 129, 1); }
.healthDot.degraded { background: rgba(245, 158, 11, 1); }
.healthDot.unhealthy { background: rgba(255, 77, 109, 1); }
.healthDot.unknown { background: var(--muted); }
.healthDot.disabled { background: var(--line); }

/* Spinning animation for health check */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spinner {
  border: 2px solid #e0e0e0;
  border-top: 2px solid var(--primary, #1976d2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loadingDots::after {
  content: '';
  animation: dots 1.4s steps(4, end) infinite;
}

@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* Pulse animation for voice recording */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.spinIcon {
  display: inline-block;
  animation: spin 1s linear infinite;
}

/* ─── Status page compact layout ─── */
.statusGrid3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.statusGrid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.statusCard {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel2);
  padding: 12px 14px;
}
.statusCardHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.statusCardLabel {
  font-weight: 700;
  font-size: 13px;
  color: var(--fg);
}
.statusCardValue {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 2px;
}
.statusCardSub {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.statusCardActions {
  margin-top: 6px;
  display: flex;
  gap: 6px;
}
/* ─── Small buttons ─── */
.btnSmall {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  transition: all 0.15s ease;
  line-height: 1.4;
  white-space: nowrap;
}
.btnSmall:hover {
  background: var(--bg1);
  border-color: rgba(0,0,0,0.15);
}
.btnSmall:disabled { opacity: 0.35; cursor: not-allowed; }
.btnSmallPrimary {
  border-color: var(--brand);
  color: var(--brand);
  background: rgba(37,99,235,0.04);
}
.btnSmallPrimary:hover {
  background: rgba(37,99,235,0.10);
}
.btnSmallDanger {
  border-color: rgba(239,68,68,0.3);
  color: #dc2626;
}
.btnSmallDanger:hover {
  background: rgba(239,68,68,0.06);
}

/* ─── Endpoint table ─── */
.epTable {
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.epTableHeader {
  display: grid;
  grid-template-columns: 1.4fr 1.6fr 44px 64px 90px;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg1);
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.epTableRow {
  display: grid;
  grid-template-columns: 1.4fr 1.6fr 44px 64px 90px;
  gap: 12px;
  padding: 10px 16px;
  align-items: center;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background 0.1s;
}
.epTableRow:last-child { border-bottom: none; }
.epTableRow:hover { background: rgba(37,99,235,0.02); }
.epTableName {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.epTableModel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}
.epTableStatus {
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* IM status row */
.imStatusRow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.imStatusRow:last-child { border-bottom: none; }
.imStatusLabel { font-size: 11px; color: var(--muted); }

/* Status metrics */
.statusMetric {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 13px;
}

/* Log display */
.logPre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 11px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-app);
  max-height: 200px;
  overflow: auto;
  margin: 0;
}

/* ─── Modal & Dialog ─── */
.modalOverlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.15s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modalContent {
  background: var(--bg-app);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  width: 480px;
  max-width: 100%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.05);
  animation: slideUp 0.2s ease-out;
}
.modalContent > * {
  padding-left: 24px;
  padding-right: 24px;
}
.modalContent > *:first-child {
  padding-top: 20px;
}
.modalContent > *:last-child {
  padding-bottom: 20px;
}

/* Dialog body — scrollable middle area */
.dialogBody {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

/* Dialog header — sticky top */
.dialogHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.dialogHeader .cardTitle {
  margin: 0;
  font-size: 16px;
}
.dialogCloseBtn {
  width: 28px;
  height: 28px;
  border-radius: 8px !important;
  border: none !important;
  background: transparent !important;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  font-size: 16px;
  transition: all 0.12s;
}
.dialogCloseBtn:hover {
  background: var(--bg1) !important;
  color: var(--text);
}

/* Dialog sections */
.dialogSection {
  margin-bottom: 16px;
  padding-left: 24px;
  padding-right: 24px;
}
.dialogLabel {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}
.dialogSection input,
.dialogSection select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: var(--panel2);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.dialogSection input:focus,
.dialogSection select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

/* Dialog footer — sticky bottom */
.dialogFooter {
  padding: 12px 24px 20px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* 端点连接测试结果 */
.connTestResult {
  margin: 0 24px 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
}
.connTestOk {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #059669;
}
.connTestFail {
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #dc2626;
}

/* Capability chips */
.capChip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  color: var(--muted);
}
.capChip:hover {
  border-color: rgba(0,0,0,0.15);
  background: var(--bg1);
}
.capChipActive {
  border-color: var(--nav-active-border);
  color: var(--brand);
  background: var(--nav-active);
}
.capChipActive:hover {
  background: var(--nav-hover);
}

/* Advanced details */
.dialogDetails {
  margin: 8px 24px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.dialogDetails summary {
  cursor: pointer;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg1);
  user-select: none;
  list-style: none;
}
.dialogDetails summary::before {
  content: "\25B8  ";
}
.dialogDetails[open] summary::before {
  content: "\25BE  ";
}
.dialogDetails summary:hover {
  background: rgba(0,0,0,0.04);
}
.dialogDetails > div {
  padding: 12px 14px;
}

/* ─── Config page details (no side margin) ─── */
.configDetails {
  margin: 6px 0 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.configDetails summary {
  cursor: pointer;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg1);
  user-select: none;
  list-style: none;
}
.configDetails summary::before {
  content: "\25B8  ";
  color: var(--muted);
}
.configDetails[open] summary::before {
  content: "\25BE  ";
}
.configDetails summary:hover {
  background: rgba(0,0,0,0.04);
}
.configDetailsBody {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── Password eye button ─── */
.btnEye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
}
.btnEye:hover {
  color: var(--text);
  background: var(--bg1);
}

/* ─── Field tooltip (info icon) ─── */
.fieldTip {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  color: var(--muted);
  cursor: help;
  vertical-align: middle;
}
.fieldTip:hover {
  color: var(--brand);
}

/* ─── Chat top bar ─── */

.chatTopBar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.chatTopBarBtn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px !important;
  border-radius: 8px !important;
  border: 1px solid var(--line) !important;
  background: transparent !important;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.chatTopBarBtn:hover {
  background: rgba(14, 165, 233, 0.06) !important;
  color: var(--text);
}

/* ─── Floating Plan Bar (above input) ─── */

.floatingPlanBar {
  margin: 0 16px;
  border: 1px solid var(--nav-active-border);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  background: var(--nav-hover);
  overflow: hidden;
  transition: all 0.2s;
}

.floatingPlanHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.floatingPlanHeader:hover {
  background: var(--nav-active);
}

.floatingPlanHeaderLeft {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.floatingPlanTitle {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.floatingPlanProgress {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.5;
}

.floatingPlanChevron {
  display: inline-flex;
  align-items: center;
  opacity: 0.4;
  transition: transform 0.2s;
}

.floatingPlanProgressBar {
  height: 3px;
  background: rgba(14, 165, 233, 0.1);
  overflow: hidden;
}

.floatingPlanProgressFill {
  height: 100%;
  background: var(--brand);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.floatingPlanActive {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 8px;
  font-size: 12px;
  color: var(--brand);
}

.floatingPlanActiveIcon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.floatingPlanActiveText {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.floatingPlanDone {
  color: rgba(16, 185, 129, 1);
}

.floatingPlanSteps {
  padding: 4px 12px 8px;
}

.floatingPlanStepRow {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 3px 0;
  font-size: 12px;
  transition: background 0.1s;
  border-radius: 4px;
}

.floatingPlanStepActive {
  color: var(--brand);
  font-weight: 600;
}

.floatingPlanStepIcon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  font-weight: 800;
  padding-top: 1px;
}

.floatingPlanStepContent {
  flex: 1;
  min-width: 0;
}

.floatingPlanStepResult {
  font-size: 11px;
  opacity: 0.5;
  margin-top: 1px;
}

/* ─── Cursor-style unified input box ─── */

.chatInputArea {
  padding: 12px 16px;
  flex-shrink: 0;
  position: relative;
}

.chatInputBox {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel2);
  overflow: visible;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chatInputBox:focus-within {
  border-color: rgba(14, 165, 233, 0.35);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.08);
}

.chatInputBoxPlan {
  border-color: rgba(124, 58, 237, 0.3);
  background: rgba(124, 58, 237, 0.02);
}

.chatInputBoxPlan:focus-within {
  border-color: rgba(124, 58, 237, 0.4);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.08);
}

.chatInputTop {
  padding: 8px 12px 0 12px;
}

.chatModelSelect {
  font-size: 12px !important;
  padding: 3px 8px !important;
  border-radius: 8px !important;
  border: 1px solid var(--line) !important;
  background: rgba(255, 255, 255, 0.7) !important;
  color: var(--muted) !important;
  width: auto !important;
  cursor: pointer;
}

/* Compact model picker button */
.chatModelPickerBtn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--fg);
  font-size: 12px;
  cursor: pointer;
  max-width: 220px;
  transition: background 0.15s, border-color 0.15s;
}
.chatModelPickerBtn:hover { background: var(--bg-app); border-color: var(--brand); }
.chatModelPickerLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Floating model menu (opens upward) */
.chatModelMenu {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  min-width: 240px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-app);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 100;
  padding: 4px 0;
  color: var(--text);
}
.chatModelMenuItem {
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background 0.1s;
}
.chatModelMenuItem:hover { background: var(--panel); }
.chatModelMenuItemActive {
  background: rgba(14, 165, 233, 0.15);
  color: var(--brand);
  font-weight: 600;
}

.chatInputTextarea {
  width: 100% !important;
  border: none !important;
  background: transparent !important;
  padding: 8px 12px !important;
  font-size: 14px;
  line-height: 1.5;
  font-family: inherit;
  resize: none !important;
  max-height: 120px;
  overflow: auto;
  outline: none !important;
  box-shadow: none !important;
  min-height: 36px !important;
}

.chatInputToolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 8px 8px;
}

.chatInputToolbarLeft {
  display: flex;
  align-items: center;
  gap: 2px;
}

.chatInputToolbarRight {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chatInputIconBtn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 5px 8px !important;
  border-radius: 8px !important;
  border: none !important;
  background: transparent !important;
  color: var(--muted2) !important;
  cursor: pointer;
  font-size: 12px;
  transition: color 0.15s, background 0.15s;
}

.chatInputIconBtn:hover {
  background: rgba(14, 165, 233, 0.08) !important;
  color: var(--text) !important;
}

.chatInputIconBtnActive {
  color: rgba(124, 58, 237, 0.9) !important;
  background: rgba(124, 58, 237, 0.08) !important;
}

.chatInputIconBtnDanger {
  color: var(--danger) !important;
  background: rgba(255, 77, 109, 0.08) !important;
  animation: pulse 1.5s infinite;
}

.chatInputSendBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50% !important;
  border: none !important;
  background: var(--brand) !important;
  color: #fff !important;
  cursor: pointer;
  transition: opacity 0.15s;
  padding: 0;
  line-height: 1;
}
.chatInputSendBtn svg {
  width: 14px;
  height: 14px;
  display: block;
}

.chatInputSendBtn:hover {
  opacity: 0.9;
}

.chatInputSendBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chatInputStopBtn {
  background: rgba(255, 77, 109, 0.9) !important;
}

/* ─── Queued Messages (Cursor-style) ─── */

.queuedContainer {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-app);
  margin: 0 4px 6px 4px;
  overflow: hidden;
}

.queuedHeader {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.15s;
  user-select: none;
}

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

.queuedHeaderChevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: inherit;
}

.queuedHeaderLabel {
  color: inherit;
}

.queuedList {
  display: flex;
  flex-direction: column;
  padding: 0 0 4px 0;
}

.queuedItem {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 13px;
  transition: background 0.12s;
  position: relative;
}

.queuedItem:hover {
  background: rgba(0, 0, 0, 0.03);
}

.queuedItemIndicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--muted);
  opacity: 0.5;
}

.queuedItemText {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.queuedItemActions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.queuedItem:hover .queuedItemActions {
  opacity: 1;
}

.queuedItemBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 5px;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.queuedItemBtn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}

.queuedItemBtn:disabled {
  opacity: 0.2;
  cursor: default;
}

.queuedItemSendBtn:hover {
  color: var(--brand, #0ea5e9) !important;
}

.queuedItemDeleteBtn:hover {
  color: var(--danger, #ef4444) !important;
}

/* ─── Tool Step Skip Button ─── */

.chainToolSkipBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  background: var(--bg-app);
  color: var(--muted);
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
  margin-left: 6px;
  opacity: 0.7;
  transition: opacity 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.chainToolSkipBtn:hover {
  opacity: 1;
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger, #ef4444);
  color: var(--danger, #ef4444);
}

/* ─── IM View ─── */

.imView {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100%;
  overflow: hidden;
}

.imLeft {
  border-right: 1px solid var(--line);
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.imRight {
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.imSectionTitle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 6px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.imRefreshBtn {
  padding: 2px 4px !important;
  border-radius: 6px !important;
  border: none !important;
  background: transparent !important;
  cursor: pointer;
  color: var(--muted2);
}

.imRefreshBtn:hover {
  background: rgba(14, 165, 233, 0.08) !important;
  color: var(--text);
}

.imChannelList, .imSessionList {
  padding: 0 6px;
}

.imChannelItem, .imSessionItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  transition: background 0.15s;
}

.imChannelItem:hover, .imSessionItem:hover {
  background: var(--nav-hover);
}

.imChannelItemActive, .imSessionItemActive {
  background: var(--nav-active);
}

.imChannelName {
  font-weight: 600;
}

.imChannelCount {
  font-size: 11px;
  color: var(--muted2);
  background: var(--nav-active);
  padding: 1px 6px;
  border-radius: 8px;
}

.imSessionId {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.imSessionMeta {
  font-size: 11px;
  color: var(--muted2);
  margin-top: 2px;
}

.imViewEmpty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted2);
}

.imEmptyHint {
  padding: 16px;
  text-align: center;
  color: var(--muted2);
  font-size: 12px;
}

.imMessages {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.imMessagesHeader {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.imMessagesList {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
}

.imMsg {
  margin-bottom: 12px;
}

.imMsgRole {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted2);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.imMsgTime {
  font-weight: 400;
  color: var(--muted2);
  font-size: 10px;
}

.imMsgUser .imMsgRole {
  color: var(--brand);
}

.imMsgContent {
  font-size: 13px;
  line-height: 1.6;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
}

.imMsgUser .imMsgContent {
  background: rgba(14, 165, 233, 0.04);
  border-color: rgba(14, 165, 233, 0.12);
}

.imMediaCard {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--nav-hover);
  border: 1px solid var(--nav-active-border);
  font-size: 12px;
  color: var(--brand);
  margin: 2px;
}

/* ── Toast Notifications ── */
.toastContainer {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  animation: toastSlideIn 0.3s ease;
  cursor: pointer;
  word-break: break-word;
}
.toastInfo {
  background: var(--nav-active);
  border: 1px solid var(--nav-active-border);
  color: var(--brand);
}
.toastOk {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--ok);
}
.toastError {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
}
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── Icon Buttons (for table rows) ── */
.btnIcon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel2);
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
  padding: 0;
}
.btnIcon:hover {
  background: var(--bg1);
  color: var(--text);
  border-color: var(--text-secondary);
}
.btnIconDanger:hover {
  background: rgba(239,68,68,0.08);
  color: var(--danger);
  border-color: rgba(239,68,68,0.3);
}
.btnIcon:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (max-width: 980px) {
  .appShell {
    grid-template-columns: 1fr;
    height: auto;
  }
  .imView {
    grid-template-columns: 1fr;
  }
}

/* ──────────────────────────────────────────────────
   Onboarding Wizard (全屏首次安装引导)
   ────────────────────────────────────────────────── */

.onboardingShell {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-app-grad);
  overflow: hidden;
}

.obPage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  overflow-y: auto;
}

.obCenter {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 520px;
  gap: 16px;
}

.obLogo {
  width: 80px;
  height: 80px;
  margin-bottom: 8px;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.obTitle {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.obDesc {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

.obBtn {
  padding: 12px 40px;
  font-size: 15px;
  border-radius: 10px;
  margin-top: 8px;
}

.obLinkBtn {
  background: none;
  border: none;
  color: var(--brand);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  opacity: 0.7;
}
.obLinkBtn:hover {
  opacity: 1;
}

.obWarning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: left;
  width: 100%;
  font-size: 13px;
  color: var(--text);
}
.obWarning ul {
  margin: 8px 0 0 16px;
  padding: 0;
}
.obWarning li {
  margin-bottom: 4px;
}

/* Environment auto-cleaned info box */
.obInfo {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: left;
  width: 100%;
  font-size: 13px;
  color: var(--text);
}
.obInfo ul {
  margin: 8px 0 0 16px;
  padding: 0;
}
.obInfo li {
  margin-bottom: 4px;
}

/* Onboarding content pages (LLM, IM, Modules) */
.obContent {
  flex: 1;
  width: 100%;
  max-width: 680px;
  padding: 24px;
  overflow-y: auto;
}

.obStepTitle {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}

.obStepDesc {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 20px;
}

.obFormArea {
  background: var(--panel2);
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--line);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* Onboarding footer */
.obFooter {
  width: 100%;
  max-width: 680px;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.obFooterBtns {
  display: flex;
  gap: 10px;
  align-items: center;
}

.obSkipBtn {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.obSkipBtn:hover {
  background: var(--nav-hover);
}

/* Skip hint text */
.obSkipHint {
  margin-top: 12px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  background: var(--nav-hover);
  border-left: 3px solid var(--line);
  border-radius: 0 4px 4px 0;
}

/* Step indicator dots */
.obStepIndicator {
  display: flex;
  gap: 8px;
  padding: 16px;
}

.obDot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted2);
  transition: all 0.2s;
}

.obDotActive {
  background: var(--brand);
  transform: scale(1.3);
}

.obDotDone {
  background: var(--ok);
}

/* Module selection list */
.obModuleList {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.obModuleItem {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.obModuleItem:hover {
  border-color: var(--brand);
}
.obModuleItem input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.obModuleInstalled {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}

.obModuleInfo {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.obModuleInfo strong {
  font-size: 14px;
  color: var(--text);
}

.obModuleDesc {
  font-size: 12px;
  color: var(--muted);
}

.obModuleSize {
  font-size: 11px;
  color: var(--muted2);
}

.obModuleBadge {
  font-size: 11px;
  color: var(--ok);
  background: rgba(16, 185, 129, 0.15);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

/* Progress log */
.obProgressLog {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 13px;
  color: var(--text);
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
}

.obProgressLine {
  padding: 2px 0;
  line-height: 1.5;
}

.obProgressSpinner {
  color: #5B8DEF;
}
.obProgressSpinner::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid #5B8DEF;
  border-top-color: transparent;
  border-radius: 50%;
  animation: obSpin 0.8s linear infinite;
}

@keyframes obSpin {
  to { transform: rotate(360deg); }
}

/* Inline spinning icon for progress tasks */
.obProgressSpinnerIcon {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.5px solid #3b82f6;
  border-top-color: transparent;
  border-radius: 50%;
  animation: obSpin 0.75s linear infinite;
  vertical-align: middle;
}

/* Done page */
.obDoneIcon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #22c55e;
  color: #fff;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

/* ═══════════════════════════════════════════════════════
   思维链 (Thinking Chain) - Cursor 风格
   ═══════════════════════════════════════════════════════ */

.thinkingChain {
  padding: 4px 0;
  margin-bottom: 8px;
}

.chainGroup {
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

/* --- 折叠隐藏叙事流 --- */
.chainGroupCollapsed .chainNarrFlow {
  display: none;
}

.chainThinkingHeader {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}

.chainChevron {
  display: inline-flex;
  align-items: center;
  opacity: 0.4;
  transition: transform 0.15s;
  flex-shrink: 0;
}

.chainThinkingLabel {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted, #888);
  opacity: 0.7;
}

/* --- 紧凑行（无 entries） --- */
.chainGroupCompact {
  margin-bottom: 4px;
}

.chainProcessedLine {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted, #888);
  opacity: 0.6;
  padding: 2px 0;
}

.chainProcessedLine svg {
  opacity: 0.5;
}

/* ========== 叙事流容器 ========== */
.chainNarrFlow {
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
  scroll-behavior: smooth;
}

/* thinking 块: 斜体灰色 */
.chainNarrThinking {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  opacity: 0.55;
  padding: 3px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.chainNarrThinkingLabel {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.5;
  margin-right: 6px;
  vertical-align: middle;
  border: 1px solid rgba(128,128,128,0.2);
  border-radius: 3px;
  padding: 0 4px;
  line-height: 1.6;
}

.chainNarrThinkingText {
  font-style: italic;
}

/* chain_text 叙事文本（LLM 推理意图 / 工具描述 / 结果摘要） */
.chainNarrText {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  opacity: 0.72;
  padding: 1px 0;
  animation: chainFadeIn 0.18s ease;
}

/* 工具开始行: spinner + 描述 */
.chainNarrToolStart {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--brand, #0ea5e9);
  padding: 2px 0;
  animation: chainFadeIn 0.18s ease;
}

.chainNarrToolName {
  opacity: 0.85;
}

/* 旋转 spinner */
.chainSpinner {
  animation: chainSpin 0.8s linear infinite;
}

@keyframes chainSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 工具结束行 */
.chainNarrToolEnd {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  font-size: 12px;
  color: var(--ok, #22c55e);
  padding: 1px 0 2px 0;
  animation: chainFadeIn 0.18s ease;
}

.chainNarrToolEnd svg {
  margin-top: 2px;
  flex-shrink: 0;
}

.chainNarrToolError {
  color: var(--danger, #ef4444);
}

.chainToolResultInline {
  color: var(--muted, #888);
  font-size: 11.5px;
  opacity: 0.7;
}

.chainToolResultCollapsible {
  display: inline;
}

.chainToolResultToggle {
  font-size: 11px;
  color: var(--brand, #0ea5e9);
  cursor: pointer;
  opacity: 0.7;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.chainToolResultToggle:hover {
  opacity: 1;
}

.chainToolResult {
  margin: 4px 0 4px 0;
  padding: 6px 10px;
  background: var(--bg-app);
  border-radius: 6px;
  font-size: 11px;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 上下文压缩 */
.chainNarrCompressed {
  font-size: 11px;
  color: var(--warning, #f59e0b);
  opacity: 0.7;
  padding: 2px 0;
  font-weight: 500;
}

/* 流式输出光标 */
.chainNarrCursor {
  width: 6px;
  height: 14px;
  background: var(--brand, #0ea5e9);
  opacity: 0.5;
  border-radius: 1px;
  animation: chainBlink 0.8s step-end infinite;
}

@keyframes chainBlink {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0; }
}

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

.chainCollapsedSummary {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  opacity: 0.5;
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
  transition: opacity 0.15s;
}

.chainCollapsedSummary:hover {
  opacity: 0.8;
}

/* IM 思维链摘要 */
.imChainSummary {
  margin: 6px 0;
  padding: 6px 10px;
  background: rgba(124, 58, 237, 0.04);
  border-radius: 8px;
  border-left: 3px solid rgba(124, 58, 237, 0.2);
}

.imChainGroup {
  margin-bottom: 4px;
}

.imChainCompressedLine {
  font-size: 10px;
  color: var(--warning, #f59e0b);
  opacity: 0.7;
  margin-bottom: 2px;
}

.imChainThinkingLine {
  font-size: 12px;
  opacity: 0.6;
  font-weight: 600;
  margin-bottom: 2px;
}

.imChainToolLine {
  font-size: 11px;
  opacity: 0.5;
  padding-left: 12px;
}

/* ═══════════════════════════════════════════════════════
   Flat Mode (Cursor 风格无气泡模式)
   ═══════════════════════════════════════════════════════ */

.flatMessage {
  margin-bottom: 16px;
}

.flatMsgUser {
  /* No changes needed, see flatUserContent */
}

.flatUserContent {
  display: inline-block;
  background: var(--bg1);
  border-radius: 12px;
  padding: 8px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  max-width: 85%;
  word-break: break-word;
}

.flatMsgAssistant {
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
}

.flatMsgSystem {
  text-align: center;
  font-size: 12px;
  opacity: 0.4;
  padding: 4px 0;
  margin-bottom: 8px;
}

/* 思考模式关闭状态 */
.chatInputIconBtnOff {
  color: rgba(156, 163, 175, 0.7) !important;
  background: rgba(156, 163, 175, 0.06) !important;
}

/* 深度思考下拉菜单 */
.chatThinkingMenu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 200px;
  background: var(--bg-app);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 200;
  animation: thinkingMenuFadeIn 0.15s ease;
}

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

.chatThinkingMenuSection {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary, #6b7280);
  padding: 6px 10px 4px;
  opacity: 0.6;
}

.chatThinkingMenuItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.12s;
}

.chatThinkingMenuItem:hover {
  background: rgba(14, 165, 233, 0.06);
}

.chatThinkingMenuItemActive {
  background: rgba(124, 58, 237, 0.08) !important;
  color: rgba(124, 58, 237, 0.9);
  font-weight: 600;
}

.chatThinkingMenuDivider {
  height: 1px;
  background: var(--line, #e5e7eb);
  margin: 4px 8px;
}

/* 思维链 & 模式切换 按钮 */
.chainToggleBtn,
.modeToggleBtn {
  transition: opacity 0.15s, background 0.15s;
}
