* {
  box-sizing: border-box;
}

:root {
  /* ── Odysseus Dark Theme ─────────────────── */
  --bg-primary: #0d1117;
  --bg-secondary: #0d1117;
  --bg-tertiary: #161b22;
  --bg-header: #010409;
  --bg-panel: rgba(22, 27, 34, 0.9);
  --bg-panel-header: rgba(22, 27, 34, 0.95);
  --text-primary: #f0f6fc;
  --text-secondary: #adbac7;
  --text-tertiary: #636e7b;
  --text-inverse: #0d1117;
  --border-primary: rgba(48, 54, 61, 0.8);
  --border-secondary: rgba(48, 54, 61, 0.4);
  --accent-primary: #2f81f7;
  --accent-primary-hover: #58a6ff;
  --accent-secondary: #7c3aed;
  --accent-success: #3fb950;
  --accent-warning: #d29922;
  --accent-danger: #f85149;
  --accent-running: #58a6ff;
  /* Agent colors */
  --agent-red: #f85149;
  --agent-blue: #58a6ff;
  --agent-green: #3fb950;
  --agent-yellow: #d29922;
  --agent-purple: #bc8cff;
  --agent-orange: #e3b341;
  --agent-pink: #f778ba;
  --agent-cyan: #39c5cf;
  /* Thinking mode rainbow colors */
  --rainbow-red: #f85149;
  --rainbow-orange: #e3b341;
  --rainbow-yellow: #d29922;
  --rainbow-green: #3fb950;
  --rainbow-blue: #58a6ff;
  --rainbow-indigo: #7c3aed;
  --rainbow-violet: #bc8cff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(47, 129, 247, 0.12);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Glass effect */
  --glass-bg: rgba(22, 27, 34, 0.85);
  --glass-border: rgba(48, 54, 61, 0.6);
  --backdrop-blur: blur(16px);
}

[data-theme="light"] {
  --bg-primary: #f0f4f8;
  --bg-secondary: #e2e8f0;
  --bg-tertiary: #cbd5e1;
  --bg-header: #1a202c;
  --bg-panel: rgba(255, 255, 255, 0.85);
  --bg-panel-header: rgba(240, 244, 248, 0.92);
  --text-primary: #1a202c;
  --text-secondary: #4b5563;
  --text-tertiary: #718096;
  --text-inverse: #f0f4f8;
  --border-primary: #cbd5e1;
  --border-secondary: #e2e8f0;
  --accent-primary: #0284c7;
  --accent-primary-hover: #0369a1;
  --accent-secondary: #6d28d9;
  --accent-success: #059669;
  --accent-warning: #d97706;
  --accent-danger: #dc2626;
  --accent-running: #0284c7;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  --shadow-glow: 0 0 24px rgba(2, 132, 199, 0.15);
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(203, 213, 225, 0.5);
  --backdrop-blur: blur(18px);
}

body {
  font-family: "IBM Plex Sans", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: background-color 0.3s, color 0.3s;
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── 星空画布背景 ─────────────────────────────── */
#starfield-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.7;
}

/* CRT 扫描线叠加 */
body::after {
  display: none;
}

/* 背景渐变 — 左上角暗蓝色调 */
body::before {
  content: '';
  position: fixed;
  top: -300px;
  left: -200px;
  width: 700px;
  height: 700px;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle, rgba(47, 129, 247, 0.04) 0%, transparent 65%);
  border-radius: 50%;
}

[data-theme="light"] body::before {
  background: radial-gradient(circle, rgba(2, 132, 199, 0.03) 0%, transparent 65%);
}

/* ===== App Container ===== */
.app-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 340px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  position: relative;
  z-index: 2;
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--accent-primary), transparent);
  opacity: 0.4;
  pointer-events: none;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-primary);
  margin: 0;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
}

.new-chat-btn {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 12px rgba(47, 129, 247, 0.15);
}

.new-chat-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(47, 129, 247, 0.3);
}

.new-chat-btn:active {
  transform: translateY(0);
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.chat-item {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
}

.chat-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.chat-item.active {
  background: linear-gradient(135deg, rgba(47, 129, 247, 0.08), rgba(124, 58, 237, 0.04));
  color: var(--text-primary);
  border-color: rgba(47, 129, 247, 0.1);
}

.chat-item-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.chat-item-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  flex: 1;
}

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

.chat-item-time {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ===== Task Snapshot Panel ===== */

.sidebar-tabs {
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 2px;
}

.sidebar-tab {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  position: relative;
}

.sidebar-tab::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 12px;
  right: 12px;
  height: 2px;
  background: var(--accent-primary);
  transform: scaleX(0);
  transition: transform 0.2s ease;
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent-primary);
}

.sidebar-tab:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar-tab.active {
  background: linear-gradient(135deg, rgba(47, 129, 247, 0.08), rgba(124, 58, 237, 0.04));
  color: var(--accent-primary);
  border-color: rgba(48, 54, 61, 0.8);
  font-weight: 600;
}

.sidebar-tab.active::after {
  transform: scaleX(1);
}

.sidebar-tab-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-tab-label {
  font-size: 13px;
}

.sidebar-panels {
  flex: 1;
  overflow-y: auto;
}

.sidebar-panel {
  display: none;
  flex-direction: column;
  height: 100%;
}

.sidebar-panel.active {
  display: flex;
}

.panel-plan-content,
.cron-panel-list,
.session-panel-list,
.memory-panel-content {
  padding: 8px;
  flex: 1;
  overflow-y: auto;
}

#panel-plan-content {
  position: relative;
}

/* ── Sidebar Agent Panels ─────────────────────────────────────────── */

#panel-agent {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 8px;
  padding: 12px;
  overflow-y: auto;
}

/* Compact step items in sidebar */
#panel-plan .step-wrapper {
  margin-bottom: 6px;
}

#panel-plan .step-item {
  padding: 8px 12px;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  border-width: 1px;
}

#panel-plan .step-number {
  width: 22px;
  height: 22px;
  font-size: 11px;
}

#panel-plan .dag-node-title {
  font-size: 12px;
}

/* Compact agent panel in sidebar */
#panel-agent .agent-panel {
  height: auto;
  min-height: 0;
  max-height: 240px;
  border-radius: var(--radius-md);
}

#panel-agent .agent-panel:hover {
  transform: none;
}

#panel-agent .panel-header {
  padding: 8px 12px;
}

#panel-agent .panel-icon {
  width: 24px;
  height: 24px;
  font-size: 11px;
}

#panel-agent .panel-title {
  font-size: 12px;
}

#panel-agent .panel-status {
  font-size: 10px;
  padding: 2px 8px;
}

#panel-agent .panel-logs {
  padding: 8px 12px;
  font-size: 11px;
  max-height: 120px;
}

.memory-load-btn {
  width: 100%;
  padding: 10px;
  border: 1px dashed var(--border-primary);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s ease;
}

.memory-load-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.memory-panel-body {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.6;
}

.memory-panel-body h1,
.memory-panel-body h2,
.memory-panel-body h3 {
  font-size: 14px;
  margin: 8px 0 4px;
  color: var(--text-primary);
}

.memory-panel-body p {
  margin: 4px 0;
}

.memory-panel-body ul,
.memory-panel-body ol {
  padding-left: 16px;
  margin: 4px 0;
}

.cron-panel-item,
.session-panel-item {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.1s ease;
}

.session-panel-item {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  cursor: pointer;
}

.session-panel-item:hover {
  background: var(--bg-tertiary);
}

.session-panel-text {
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.session-panel-meta {
  font-size: 10px;
  color: var(--text-tertiary);
}

.cron-panel-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cron-panel-status.active {
  background: var(--accent-primary);
  box-shadow: 0 0 6px rgba(0, 212, 255, 0.45);
}

.cron-panel-status.disabled {
  background: var(--text-tertiary);
}

.cron-panel-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  flex: 1;
}

.cron-panel-name {
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cron-panel-schedule {
  font-size: 10px;
  color: var(--text-tertiary);
  font-family: monospace;
}

.task-item-empty {
  padding: 16px 12px;
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
}

/* ===== Skill Panel ===== */

.skill-list {
  padding: 4px 0;
}

.skill-item {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s ease;
}

.skill-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.skill-icon {
  font-size: 12px;
  flex-shrink: 0;
}

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

/* ===== Chat Messages ===== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-messages:empty::after {
  content: '输入指令开始会话...';
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-tertiary);
  font-size: 14px;
  font-family: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
  letter-spacing: 0.05em;
  opacity: 0.5;
}

.chat-bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.65;
  word-wrap: break-word;
  animation: bubble-appear 0.18s ease;
}

@keyframes bubble-appear {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-bubble.user {
  align-self: flex-end;
  background: #1c2d4a;
  color: #e6edf3;
  border: 1px solid rgba(47, 129, 247, 0.3);
  border-bottom-right-radius: 3px;
  max-width: 72%;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: #1c2433;
  border: 1px solid rgba(56, 68, 90, 0.8);
  border-radius: var(--radius-md);
  border-bottom-left-radius: 3px;
  color: #e6edf3;
  padding: 10px 14px;
  max-width: 96%;
}

.chat-bubble.assistant.streaming::after {
  content: '▍';
  animation: cursor-blink 0.8s step-end infinite;
  color: var(--accent-primary);
}

/* Markdown inside chat bubbles (both user and assistant) */
.chat-bubble p { margin: 0.4em 0; }
.chat-bubble p:first-child { margin-top: 0; }
.chat-bubble p:last-child { margin-bottom: 0; }

.chat-bubble pre {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 13px;
  line-height: 1.5;
}

.chat-bubble code {
  font-family: "JetBrains Mono", "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 13px;
}

.chat-bubble :not(pre) > code {
  background: rgba(0,0,0,0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.chat-bubble ul, .chat-bubble ol {
  margin: 4px 0;
  padding-left: 20px;
}

.chat-bubble strong { font-weight: 700; }

.chat-bubble h1, .chat-bubble h2, .chat-bubble h3,
.chat-bubble h4, .chat-bubble h5, .chat-bubble h6 {
  margin: 0.7em 0 0.3em;
  line-height: 1.3;
}
.chat-bubble h1:first-child, .chat-bubble h2:first-child,
.chat-bubble h3:first-child { margin-top: 0; }

.chat-bubble a {
  color: var(--accent-primary);
  text-decoration: none;
}
.chat-bubble a:hover { text-decoration: underline; }

.chat-bubble blockquote {
  border-left: 3px solid var(--accent-primary);
  margin: 8px 0;
  padding: 4px 12px;
  color: var(--text-secondary);
}

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

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

.chat-bubble th {
  background: rgba(0,0,0,0.2);
  font-weight: 600;
}

/* Keep assistant-specific styles */
.chat-bubble.assistant p { margin: 0.4em 0; }

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.chat-tool-badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-running);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  font-family: "JetBrains Mono", "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  animation: bubble-appear 0.25s ease;
  transition: background 0.2s, color 0.2s;
}

.chat-tool-badge::before {
  content: '⚙';
  font-size: 13px;
}

.tool-badge-label {
  flex: 1;
}

.tool-badge-timer {
  font-size: 11px;
  opacity: 0.6;
  min-width: 20px;
  text-align: right;
}

.chat-tool-badge.done {
  background: rgba(5, 150, 105, 0.1);
  color: var(--accent-success);
}

.chat-tool-badge.done::before {
  content: '✓';
}

.chat-tool-badge.cancelled {
  background: rgba(245, 33, 47, 0.08);
  color: var(--accent-danger);
  opacity: 0.7;
}

.chat-tool-badge.cancelled::before {
  content: '■';
}

/* Spinner for running tool badge */
.tool-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: tool-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes tool-spin {
  to { transform: rotate(360deg); }
}

/* Tool result block: label + pre */
.tool-result-block {
  align-self: flex-start;
  width: 100%;
  max-width: 100%;
  animation: bubble-appear 0.2s ease;
}

.tool-result-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 4px 4px;
}

.tool-result-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  font-family: "JetBrains Mono", "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tool-result-copy {
  font-size: 11px;
  color: var(--text-tertiary);
  background: none;
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tool-result-copy:hover {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.tool-result-pre {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  font-family: "JetBrains Mono", "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-secondary);
  margin: 0;
  max-height: 240px;
  overflow-y: auto;
}

/* Cancelled streaming bubble styling */
.chat-bubble.assistant.cancelled {
  opacity: 0.75;
  border-color: var(--accent-danger);
}

/* Interrupt hint — mirrors claude-code-fresh InterruptedByUser component */
.interrupt-hint {
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 6px 12px;
  margin: 4px 0 8px;
}
.interrupt-hint .interrupt-prompt {
  color: var(--accent-primary);
  font-style: italic;
}

/* Todo step fade-out (mirrors TaskListV2 TTL pattern) */
@keyframes step-fade-out {
  from { opacity: 1; }
  to   { opacity: 0.35; }
}
.step-item.fading-out {
  animation: step-fade-out 0.8s ease forwards;
  animation-delay: 0.2s;
}

/* ===== Hidden State ===== */
.hidden {
  display: none !important;
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-secondary);
}

/* ===== Header ===== */
header {
  background: var(--glass-bg);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  color: var(--text-inverse);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-primary);
  box-shadow: 0 1px 0 rgba(47, 129, 247, 0.08), inset 0 -1px 0 rgba(47, 129, 247, 0.04);
  position: relative;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-primary), #7dd3fc, var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.05em;
  text-shadow: none;
  filter: drop-shadow(0 0 12px rgba(0, 212, 255, 0.4));
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 4px 8px;
  background: var(--bg-tertiary);
  border-radius: 20px;
  transition: all 0.3s ease;
}

#connection-text {
  display: none;
}

.connection-status.connected {
  background: rgba(47, 129, 247, 0.08);
  color: var(--accent-primary);
  box-shadow: 0 0 12px rgba(48, 54, 61, 0.6);
}

.connection-status.reconnecting {
  background: rgba(245, 158, 11, 0.08);
  color: var(--accent-warning);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.1);
}

.connection-status.failed {
  background: rgba(255, 61, 0, 0.08);
  color: var(--accent-danger);
  box-shadow: 0 0 12px rgba(255, 61, 0, 0.1);
}

.autonomous-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
  font-weight: 500;
  margin-left: 8px;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: all 0.3s ease;
  position: relative;
}

.status-dot::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: inherit;
  opacity: 0.4;
  animation: none;
}

.status-dot.connected {
  background-color: var(--accent-success);
  box-shadow: 0 0 8px var(--accent-success);
}

.status-dot.connected::after {
  animation: ping 1.5s ease-out infinite;
}

.status-dot.disconnected {
  background-color: var(--accent-danger);
}

.status-dot.reconnecting {
  background-color: var(--accent-warning);
  animation: pulse-dot 1s infinite;
}

.status-dot.failed {
  background-color: var(--accent-danger);
}

.reconnect-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.2s ease;
  opacity: 0.7;
}

.reconnect-btn:hover {
  opacity: 1;
  background: var(--bg-tertiary);
  transform: rotate(180deg);
}

.reconnect-btn:active {
  transform: rotate(360deg);
}

@keyframes ping {
  0% { transform: scale(1); opacity: 0.4; }
  100% { transform: scale(2); opacity: 0; }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

.theme-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

#theme-text {
  display: none;
}

.theme-toggle:hover {
  background: rgba(48, 54, 61, 0.6);
  color: var(--accent-primary);
  border-color: rgba(0, 212, 255, 0.25);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(47, 129, 247, 0.1);
}

/* Connect button */
.connect-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

#connect-btn-text {
  display: none;
}

.connect-btn:hover {
  background: rgba(124, 58, 237, 0.1);
  color: var(--accent-secondary);
  border-color: rgba(124, 58, 237, 0.25);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.2);
}

/* QR Modal */
.qr-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.qr-modal.hidden {
  display: none;
}

.qr-modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--border-primary);
  border-radius: 16px;
  padding: 24px;
  max-width: 360px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.qr-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.qr-modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.qr-modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 4px;
}

.qr-modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.qr-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.qr-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.qr-status.connected {
  color: var(--accent-success);
}

.qr-status.failed {
  color: var(--accent-danger);
}

.qr-code {
  padding: 16px;
  background: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-code {
  background: white;
}

.qr-spinner {
  animation: spin 1s linear infinite;
}

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

.qr-hint {
  font-size: 13px;
  color: var(--text-tertiary);
  text-align: center;
  margin: 0;
}

/* ===== DAG Progress Section ===== */
#dag-progress {
  padding: 24px;
  background: var(--glass-bg);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid var(--border-primary);
  min-height: 180px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

#dag-progress::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary), var(--accent-primary));
  background-size: 200% 100%;
  animation: gradient-shift 3s ease infinite;
  opacity: 0.8;
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.dag-intent {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.dag-intent::before {
  content: '🎯';
  font-size: 16px;
}

.dag-flowchart {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding: 20px 10px;
  position: relative;
  min-height: 140px;
}

.dag-flowchart::-webkit-scrollbar {
  height: 6px;
}

.dag-flowchart::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

.dag-flowchart::-webkit-scrollbar-thumb {
  background: var(--border-primary);
  border-radius: 3px;
}

/* ===== SVG Container for Arrows ===== */
.dag-svg-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.dag-svg-container path {
  fill: none;
  stroke: var(--border-primary);
  stroke-width: 2;
  transition: stroke 0.4s ease, stroke-width 0.3s ease;
}

.dag-svg-container path.active {
  stroke: var(--accent-primary);
  stroke-width: 3;
  filter: drop-shadow(0 0 4px var(--accent-primary));
}

.dag-svg-container path.running {
  stroke: var(--accent-running);
  stroke-width: 3;
  stroke-dasharray: 8 4;
  animation: dash-flow 0.5s linear infinite;
}

.dag-svg-container path.path-traced {
  stroke: var(--accent-success);
  stroke-width: 3;
  filter: drop-shadow(0 0 6px var(--accent-success));
  animation: path-glow 1s ease-out;
}

@keyframes path-glow {
  0% {
    stroke-width: 5;
    filter: drop-shadow(0 0 12px var(--accent-success));
  }
  100% {
    stroke-width: 3;
    filter: drop-shadow(0 0 6px var(--accent-success));
  }
}

@keyframes dash-flow {
  to { stroke-dashoffset: -12; }
}

/* Arrowhead marker */
.dag-svg-container defs marker path {
  fill: var(--border-primary);
  transition: fill 0.4s ease;
}

.dag-svg-container defs marker.active path {
  fill: var(--accent-primary);
}

.dag-svg-container defs marker.running path {
  fill: var(--accent-running);
}

/* ===== Roadmap Steps (single-agent) ===== */
.step-wrapper {
  display: flex;
  align-items: stretch;
  position: relative;
  z-index: 2;
  margin-bottom: 12px;
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 2px solid var(--border-primary);
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  min-width: 180px;
  max-width: 600px;
  position: relative;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: default;
  flex: 1;
}

.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: white;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.step-content {
  flex: 1;
}

.step-item.pending {
  border-color: var(--border-primary);
  opacity: 0.7;
}

.step-item.running {
  border-color: var(--accent-running);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
  opacity: 1;
}

.step-item.done {
  border-color: var(--accent-done);
  background: rgba(5, 150, 105, 0.06);
  opacity: 1;
}

.step-item.done .step-number {
  background: var(--accent-done);
}

.step-item.error {
  border-color: var(--accent-error);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* ===== DAG Nodes ===== */
.dag-node-wrapper {
  display: flex;
  align-items: center;
  position: relative;
  z-index: 2;
}

.dag-node {
  border: 2px solid var(--border-primary);
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  min-width: 180px;
  max-width: 220px;
  position: relative;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  overflow: hidden;
}

.dag-node::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border-primary);
  transition: all 0.3s ease;
}

.dag-node::after {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--bg-primary);
  border: 3px solid var(--border-primary);
  transition: all 0.3s ease;
  z-index: 1;
}

/* Node States */
.dag-node.pending {
  border-color: var(--border-primary);
  opacity: 0.8;
}

.dag-node.pending::before {
  background: var(--border-primary);
}

.dag-node.pending::after {
  border-color: var(--text-tertiary);
}

.dag-node.queued {
  border-color: var(--accent-secondary);
  opacity: 0.9;
}

.dag-node.queued::before {
  background: linear-gradient(90deg, var(--accent-secondary), var(--accent-primary));
}

.dag-node.queued::after {
  border-color: var(--accent-secondary);
  animation: float 2s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-3px); }
}

.dag-node.running {
  border-color: var(--accent-running);
  box-shadow: var(--shadow-glow), 0 0 0 4px rgba(59, 130, 246, 0.15);
  transform: translateY(-2px);
  animation: node-running 1.5s ease-in-out infinite;
}

.dag-node.running::before {
  background: linear-gradient(90deg, var(--accent-running), var(--accent-secondary));
  animation: shimmer 1.5s ease infinite;
}

.dag-node.running::after {
  border-color: var(--accent-running);
  background: var(--accent-running);
  animation: pulse-ring 1s ease-out infinite;
}

@keyframes node-running {
  0%, 100% { box-shadow: var(--shadow-glow), 0 0 0 4px rgba(59, 130, 246, 0.15); }
  50% { box-shadow: var(--shadow-glow), 0 0 0 8px rgba(59, 130, 246, 0.1); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.6); }
  100% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0); }
}

.dag-node.done {
  border-color: var(--accent-success);
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.05), rgba(5, 150, 105, 0.1));
}

.dag-node.done::before {
  background: var(--accent-success);
}

.dag-node.done::after {
  border-color: var(--accent-success);
  background: var(--accent-success);
  box-shadow: 0 0 10px var(--accent-success);
}

.dag-node.error {
  border-color: var(--accent-danger);
  background: linear-gradient(135deg, rgba(245, 33, 47, 0.05), rgba(245, 33, 47, 0.1));
}

.dag-node.error::before {
  background: var(--accent-danger);
}

.dag-node.error::after {
  border-color: var(--accent-danger);
  background: var(--accent-danger);
}

/* Path highlight animation during execution */
.dag-node.path-highlight {
  animation: path-pulse 0.3s ease-out;
}

@keyframes path-pulse {
  0% {
    transform: scale(1.05);
    box-shadow: 0 0 0 0 rgba(0, 212, 255, 0.45);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.25);
  }
  100% {
    transform: scale(1);
    box-shadow: none;
  }
}

/* Node Content */
.dag-node-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 6px;
  margin-top: 8px;
  letter-spacing: -0.01em;
}

.dag-node-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Node hover effect */
.dag-node:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* ===== Sequence Connectors ===== */
.sequence-connectors {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 8px;
  flex-shrink: 0;
}

.connector-line {
  width: 40px;
  height: 2px;
  background: var(--border-primary);
  position: relative;
  transition: all 0.4s ease;
}

.connector-line::after {
  content: '';
  position: absolute;
  right: -5px;
  top: -4px;
  border: 5px solid transparent;
  border-left-color: var(--border-primary);
  transition: all 0.4s ease;
}

.connector-line.active {
  background: var(--accent-primary);
}

.connector-line.active::after {
  border-left-color: var(--accent-primary);
}

.connector-line.running {
  background: repeating-linear-gradient(
    90deg,
    var(--accent-running),
    var(--accent-running) 8px,
    transparent 8px,
    transparent 12px
  );
  animation: connector-flow 0.6s linear infinite;
}

@keyframes connector-flow {
  from { background-position: 0 0; }
  to { background-position: 20px 0; }
}

/* ===== Execution Progress Enhancement ===== */
.progress-current-node {
  font-size: 12px;
  color: var(--accent-running);
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(59, 130, 246, 0.08);
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: node-pulse 1.5s ease-in-out infinite;
}

@keyframes node-pulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

.progress-current-node .node-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-running);
  animation: dot-blink 1s infinite;
}

@keyframes dot-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.progress-complete-icon {
  color: var(--accent-success);
  font-size: 16px;
}

.progress-error-text {
  color: var(--accent-danger);
  font-weight: 600;
}

/* ===== Log Panel Completion Animation ===== */
.panel-logs.completed {
  background: linear-gradient(
    180deg,
    rgba(5, 150, 105, 0.03) 0%,
    var(--bg-panel) 100%
  );
}

.completion-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  margin: 12px;
  background: rgba(5, 150, 105, 0.08);
  border-radius: var(--radius-md);
  color: var(--accent-success);
  font-weight: 600;
  font-size: 13px;
  animation: banner-appear 0.4s ease;
  border: 1px solid rgba(5, 150, 105, 0.15);
}

@keyframes banner-appear {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== DAG Node Sequence Number ===== */
.dag-node .sequence-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-primary);
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0, 212, 255, 0.25);
}

.dag-node.done .sequence-badge,
.dag-node.running .sequence-badge {
  opacity: 1;
}

.dag-node.running .sequence-badge {
  background: var(--accent-running);
  animation: badge-pulse 1s infinite;
}

@keyframes badge-pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.1); }
}

/* ===== Improved Step Items ===== */
.step-item.executed {
  border-color: var(--accent-success);
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.04), rgba(5, 150, 105, 0.08));
}

.step-item.executed .step-number {
  background: var(--accent-success);
}

.step-item.current {
  border-color: var(--accent-running);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.step-item.current .step-number {
  background: var(--accent-running);
  animation: step-pulse 1.5s infinite;
}

@keyframes step-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); }
}

/* ===== Enhanced Arrow Curves ===== */
.dag-svg-container path {
  fill: none;
  stroke: var(--border-primary);
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke 0.4s ease, stroke-width 0.3s ease;
}

.dag-svg-container path.active {
  stroke: var(--accent-success);
  stroke-width: 3;
  filter: drop-shadow(0 0 5px var(--accent-success));
}

.dag-svg-container path.running {
  stroke: var(--accent-running);
  stroke-width: 3;
  stroke-dasharray: 12 6;
  animation: arrow-flow 0.8s linear infinite;
}

@keyframes arrow-flow {
  to { stroke-dashoffset: -18; }
}

.dag-svg-container path.path-traced {
  stroke: var(--accent-success);
  stroke-width: 3;
  filter: drop-shadow(0 0 6px var(--accent-success));
}

/* ===== Node Execution Ripple Effect ===== */
.dag-node.running::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: inherit;
  border: 2px solid var(--accent-running);
  animation: ripple-out 1.5s ease-out infinite;
  pointer-events: none;
}

@keyframes ripple-out {
  0% {
    opacity: 0.6;
    transform: scale(0.98);
  }
  100% {
    opacity: 0;
    transform: scale(1.02);
  }
}

/* ===== Better Status Colors ===== */
:root {
  --accent-done: #34d399;
  --accent-error: #f87171;
  --accent-queued: #a78bfa;
}

[data-theme="light"] {
  --accent-done: #059669;
  --accent-error: #dc2626;
  --accent-queued: #7c3aed;
}


/* ===== Agent Panel Base Styles ===== */
.agent-panel {
  background: var(--glass-bg);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  height: 400px;
  box-shadow: var(--shadow-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border-primary);
  overflow: hidden;
  position: relative;
}

.agent-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--agent-color, var(--accent-primary));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.agent-panel:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.agent-panel:hover::before {
  opacity: 1;
}

.agent-panel.collapsed {
  height: auto;
  min-height: auto;
}

.agent-panel.collapsed .panel-logs {
  display: none;
}

.agent-panel.running::before {
  opacity: 1;
  animation: panel-glow 2s ease-in-out infinite;
}

@keyframes panel-glow {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.panel-header {
  padding: 16px 20px;
  background: var(--bg-panel-header);
  border-bottom: 1px solid var(--border-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.panel-header:hover {
  background: rgba(47, 129, 247, 0.04);
}

.panel-title-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: white;
}

.panel-collapse-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.panel-collapse-btn:hover {
  color: var(--accent-primary);
}

.agent-panel.collapsed .panel-collapse-btn {
  transform: rotate(-90deg);
}

.panel-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.panel-status {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

.panel-status.pending {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
}

.panel-status.queued {
  background: rgba(124, 58, 237, 0.12);
  color: var(--accent-secondary);
}

.panel-status.running {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-running);
  animation: status-pulse 1s ease-in-out infinite;
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.panel-status.done {
  background: rgba(5, 150, 105, 0.12);
  color: var(--accent-success);
}

.panel-status.error {
  background: rgba(245, 33, 47, 0.15);
  color: var(--accent-danger);
}

.panel-logs {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  color: var(--text-primary);
  font-family: "JetBrains Mono", "JetBrains Mono", "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  background: var(--bg-panel);
  scrollbar-width: thin;
  scrollbar-color: var(--border-primary) transparent;
  position: relative;
}

.panel-logs::before {
  content: '';
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(to bottom, var(--bg-panel), transparent);
  pointer-events: none;
  z-index: 1;
  margin-bottom: -20px;
}

.panel-logs::-webkit-scrollbar {
  width: 8px;
}

.panel-logs::-webkit-scrollbar-track {
  background: transparent;
}

.panel-logs::-webkit-scrollbar-thumb {
  background: var(--border-primary);
  border-radius: 4px;
}

.panel-logs::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Log line enhancements */
.log-line {
  margin-bottom: 4px;
  word-wrap: break-word;
  white-space: pre-wrap;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s ease;
  position: relative;
}

.log-line::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  border-radius: 2px;
  transition: background 0.15s ease;
}

.log-line:hover {
  background: rgba(47, 129, 247, 0.04);
}

.log-line:hover::before {
  background: var(--accent-primary);
}

.log-line.new {
  animation: log-appear 0.3s ease;
}

.log-line.new::before {
  background: var(--accent-primary);
  animation: log-indicator 0.5s ease forwards;
}

@keyframes log-appear {
  from {
    opacity: 0;
    transform: translateX(-10px);
    background: rgba(47, 129, 247, 0.08);
  }
  to {
    opacity: 1;
    transform: translateX(0);
    background: transparent;
  }
}

@keyframes log-indicator {
  0% {
    height: 0;
    opacity: 0;
  }
  100% {
    height: 100%;
    opacity: 1;
  }
}

/* 截断内容的折叠/展开（Ctrl+O 或点击按钮触发） */
.log-line.truncated {
  border-left: 3px solid var(--accent-warning);
  margin-top: 4px;
}

.expand-btn {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  vertical-align: middle;
  transition: all 0.15s ease;
}

.expand-btn:hover {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

/* 展开状态 */
.log-line.truncated[data-expanded="true"] {
  border-left-color: var(--accent-primary);
}

/* Thinking mode — rainbow color classes for thinking block chars */
.thinking-char-0 { color: var(--rainbow-red); }
.thinking-char-1 { color: var(--rainbow-orange); }
.thinking-char-2 { color: var(--rainbow-yellow); }
.thinking-char-3 { color: var(--rainbow-green); }
.thinking-char-4 { color: var(--rainbow-blue); }
.thinking-char-5 { color: var(--rainbow-indigo); }
.thinking-char-6 { color: var(--rainbow-violet); }

/* Thinking block shimmer animation */
.thinking-block {
  display: inline;
  background: linear-gradient(
    90deg,
    var(--rainbow-red),
    var(--rainbow-orange),
    var(--rainbow-yellow),
    var(--rainbow-green),
    var(--rainbow-blue),
    var(--rainbow-indigo),
    var(--rainbow-violet)
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: thinking-shimmer 3s linear infinite;
}

@keyframes thinking-shimmer {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

/* Thinking block badge */
.thinking-badge {
  display: inline-block;
  padding: 1px 6px;
  background: linear-gradient(90deg, var(--rainbow-red), var(--rainbow-violet));
  border-radius: 4px;
  font-size: 10px;
  color: white;
  margin-right: 4px;
  vertical-align: middle;
}

/* Error/warning log highlighting */
.log-line.ansi-fg-red,
.log-line.ansi-fg-yellow {
  background: rgba(0, 0, 0, 0.03);
}

.log-line.ansi-fg-red,
.log-line.ansi-fg-yellow {
  background: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] .log-line.ansi-fg-red,
[data-theme="light"] .log-line.ansi-fg-yellow {
  background: rgba(0, 0, 0, 0.03);
}

/* ANSI colors */
.log-line .ansi-bold { font-weight: 700; }
.log-line .ansi-fg-black { color: #484f58; }
.log-line .ansi-fg-red { color: #f85149; }
.log-line .ansi-fg-green { color: #3fb950; }
.log-line .ansi-fg-yellow { color: #d29922; }
.log-line .ansi-fg-blue { color: #58a5ff; }
.log-line .ansi-fg-magenta { color: #bc8cff; }
.log-line .ansi-fg-cyan { color: #39c5cf; }
.log-line .ansi-fg-white { color: #e6edf3; }
.log-line .ansi-bg-black { background-color: #484f58; }
.log-line .ansi-bg-red { background-color: #f85149; }
.log-line .ansi-bg-green { background-color: #3fb950; }
.log-line .ansi-bg-yellow { background-color: #d29922; }
.log-line .ansi-bg-blue { background-color: #58a5ff; }
.log-line .ansi-bg-magenta { background-color: #bc8cff; }
.log-line .ansi-bg-cyan { background-color: #39c5cf; }
.log-line .ansi-bg-white { background-color: #e6edf3; }

/* ===== Footer / Input ===== */
footer {
  padding: 20px 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border-primary);
  box-shadow: 0 -1px 0 rgba(47, 129, 247, 0.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.3s ease;
}
.input-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}
.attachment-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}
.attachment-previews.hidden { display: none; }
.attachment-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-primary);
  flex-shrink: 0;
}
.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.attachment-thumb .file-icon {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  font-size: 20px;
  gap: 2px;
}
.attachment-thumb .file-icon span {
  font-size: 9px;
  color: var(--text-secondary);
  max-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-thumb .remove-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.thumb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border-radius: 8px;
}
.thumb-error { background: rgba(200,0,0,0.5); }

  background: none;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 0 14px;
  height: 64px;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s;
}
.attach-btn:hover { border-color: var(--accent-primary); color: var(--text-primary); }
footer.drag-over { border-top-color: var(--accent-primary); background: rgba(0,212,255,0.04); }


#intent-input {
  flex: 1;
  height: 64px;
  padding: 14px 18px;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.25s ease;
}

#intent-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(48, 54, 61, 0.6), 0 0 24px rgba(48, 54, 61, 0.6);
}

#intent-input::placeholder {
  color: var(--text-tertiary);
}

#submit-btn {
  padding: 0 28px;
  background: linear-gradient(135deg, #0088aa, var(--accent-primary));
  color: #060f1e;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.25);
  letter-spacing: 0.03em;
}

#submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(0, 212, 255, 0.4);
}

#submit-btn:active {
  transform: translateY(0);
}

#submit-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#cancel-btn {
  padding: 0 20px;
  background: var(--accent-danger);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(255, 61, 0, 0.2);
}

#cancel-btn:hover {
  box-shadow: 0 6px 24px rgba(255, 61, 0, 0.3);
}

.busy-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 2px 4px 4px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.busy-hint.hidden {
  display: none;
}

/* ===== Execution Progress ===== */
.execution-progress {
  position: fixed;
  bottom: 100px;
  right: 24px;
  background: var(--glass-bg);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  color: var(--text-primary);
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  border: 1px solid var(--border-primary);
  display: none;
  z-index: 100;
  min-width: 240px;
}

.execution-progress.visible {
  display: block;
  animation: slide-up 0.3s ease;
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.progress-header {
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}

.progress-header-icon {
  font-size: 18px;
  animation: spin 2s linear infinite;
}

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

.progress-bar-container {
  background: var(--bg-tertiary);
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 5px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.progress-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.25), transparent);
  border-radius: 5px 5px 0 0;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: progress-shimmer 1.5s infinite;
}

@keyframes progress-shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

/* Progress states */
.progress-bar.complete {
  background: linear-gradient(90deg, var(--accent-success), #3fb950);
  animation: progress-complete 0.5s ease;
}

.progress-bar.error {
  background: linear-gradient(90deg, var(--accent-danger), #ff6b6b);
}

@keyframes progress-complete {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
}

.progress-text {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
}

/* ===== Responsive / Tablet ===== */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  /* 平板端精简 header */
  .context-status {
    max-width: 120px;
  }

  .session-model-label {
    max-width: 100px;
  }

  /* 平板上 chat 减少横向 padding */
  .chat-messages {
    padding: 16px 16px;
  }
}

/* 全局交互优化 */
button, a, [role="button"] {
  touch-action: manipulation;
}

/* ===== Scrollbar polish ===== */
.panel-logs::-webkit-scrollbar-thumb {
  background: var(--border-primary);
  border-radius: 4px;
}

.panel-logs::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ===== Log line fade-in animation ===== */
.log-line.new {
  animation: log-appear 0.3s ease;
}

@keyframes log-appear {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── 深空指挥舱动画 ──────────────────────────── */
@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(48, 54, 61, 0.6); }
  50% { box-shadow: 0 0 20px rgba(0, 212, 255, 0.25); }
}

@keyframes border-glow {
  0%, 100% { border-color: rgba(48, 54, 61, 0.6); }
  50% { border-color: rgba(0, 212, 255, 0.3); }
}

/* ===== Execution Error State ===== */
.agent-panel.error .panel-header {
  background: rgba(245, 33, 47, 0.1);
  border-bottom-color: rgba(245, 33, 47, 0.2);
}

.agent-panel.error .panel-icon {
  background: linear-gradient(135deg, var(--accent-danger), #ff6b6b);
}

.execution-progress.error-state {
  border-color: rgba(245, 33, 47, 0.3);
}

/* ===== DAG Empty State ===== */
.dag-flowchart:empty::after {
  content: '等待任务提交...';
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  color: var(--text-tertiary);
  font-size: 14px;
  width: 100%;
}

/* ===== Agent Panel Empty State ===== */
.panel-logs:empty::after {
  content: '等待日志输出...';
  display: block;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
  font-size: 12px;
  font-family: inherit;
}

/* ===== Better Focus States ===== */
#intent-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 4px rgba(47, 129, 247, 0.1), var(--shadow-md);
}

/* ===== Node Tooltip ===== */
.dag-node[data-tooltip] {
  position: relative;
}

.dag-node-tooltip {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-header);
  color: var(--text-inverse);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.dag-node:hover .dag-node-tooltip {
  opacity: 1;
}

/* ===== Status Transition Smoothness ===== */
.dag-node,
.agent-panel,
.panel-status,
.progress-bar {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Better Agent Panel Grid ===== */

/* System notice bubble (compact boundary, context warnings) */
/* Context status bar */
.context-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 160px;
  overflow: hidden;
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex-shrink: 1;
}
.context-bar {
  display: none;
  width: 60px;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}
.context-bar.visible {
  display: block;
}
.context-fill {
  height: 100%;
  width: 0%;
  background: var(--accent, #3b82f6);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.context-text {
  display: none;
}
.context-text.visible {
  display: inline;
}
[data-theme="light"] .context-bar {
  background: rgba(0,0,0,0.08);
}

/* Toolbar buttons */
.toolbar-btn {
  background: none;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 5px 7px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.toolbar-btn:hover {
  background: var(--bg-tertiary);
  color: var(--accent-primary);
  box-shadow: 0 0 12px rgba(48, 54, 61, 0.6);
}

.system-notice {
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary, #9ca3af);
  padding: 6px 16px;
  margin: 4px auto;
  max-width: 480px;
  background: var(--bg-tertiary, #f3f4f6);
  border-radius: 12px;
  border: 1px solid var(--border-primary, #e5e7eb);
}

[data-theme="light"] .system-notice {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.08);
}

/* Permission dialog stack */
.permission-stack {
position: fixed; inset: 0;
z-index: 9998;
pointer-events: none;
}
.permission-card {
position: fixed;
top: 50%; left: 50%;
transform: translate(calc(-50% + var(--stack-offset-x, 0px)), calc(-50% + var(--stack-offset-y, 0px)));
background: var(--glass-bg, rgba(10, 22, 40, 0.92));
backdrop-filter: blur(20px);
border: 1px solid var(--border-primary, rgba(47, 129, 247, 0.1));
  border-radius: 12px;
  padding: 24px 28px;
  min-width: 380px; max-width: 560px;
box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 40px rgba(0,212,255,0.06);
pointer-events: auto;
transition: transform 0.2s ease;
}
.permission-card h3 { margin: 0 0 10px; font-size: 1.1em; color: var(--accent-primary, #00d4ff); }
.permission-card p  { margin: 0 0 10px; font-size: 0.9em; opacity: 0.8; }
.permission-agent-tag {
  display: inline-block;
  font-size: 0.7em;
  padding: 2px 8px;
  border-radius: 10px;
  background: #6c5ce7;
  color: #fff;
  vertical-align: middle;
  margin-left: 8px;
}
.permission-detail {
  background: var(--bg-primary, #111);
  border-radius: 6px; padding: 10px 14px;
  font-size: 0.85em; overflow-x: auto;
  white-space: pre-wrap; word-break: break-all;
  max-height: 200px; overflow-y: auto;
}
.permission-actions {
  display: flex; gap: 12px; justify-content: flex-end; margin-top: 18px;
}
.btn-deny    { padding: 8px 20px; border-radius: 6px; border: none; cursor: pointer; background: #555; color: #fff; }
.btn-approve { padding: 8px 20px; border-radius: 6px; border: none; cursor: pointer; background: #2ecc71; color: #fff; font-weight: bold; }
.btn-approve-session { padding: 8px 20px; border-radius: 6px; border: none; cursor: pointer; background: var(--accent-secondary); color: #fff; font-weight: bold; }
.btn-deny:hover    { background: #e74c3c; }
.btn-approve:hover { background: #27ae60; }
.btn-approve-session:hover { opacity: 0.85; }

/* Settings modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 1001;
}
.modal-overlay.hidden { display: none; }
.modal-content {
  background: var(--bg-panel); border: 1px solid var(--border-primary);
  border-radius: 16px; padding: 24px; max-width: 420px; width: 90%;
  box-shadow: var(--shadow-lg);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 18px; font-weight: 600; margin: 0; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-secondary); padding: 4px 8px; border-radius: 4px; }
.modal-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.modal-body { display: flex; flex-direction: column; gap: 12px; }

.settings-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: -8px; }
.settings-input {
  background: var(--bg-primary); border: 1px solid var(--border-primary);
  border-radius: 8px; padding: 10px 14px; font-size: 14px; color: var(--text-primary);
  font-family: monospace; outline: none;
}
.settings-input:focus { border-color: var(--accent-primary); }
.settings-input-row { display: flex; align-items: center; gap: 6px; }
.settings-input-row .settings-input { flex: 1; }
.settings-eye-btn {
  background: none; border: 1px solid var(--border-primary); border-radius: 8px;
  padding: 9px 10px; cursor: pointer; font-size: 14px; color: var(--text-secondary);
  line-height: 1; flex-shrink: 0;
}
.settings-eye-btn:hover { border-color: var(--accent-primary); color: var(--text-primary); }
.settings-message { font-size: 13px; color: var(--accent-success); min-height: 20px; margin: 0; }
.settings-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.btn-primary { padding: 10px 20px; border-radius: 8px; border: none; cursor: pointer; background: var(--accent-primary); color: #fff; font-weight: 600; font-size: 14px; }
.btn-primary:hover { opacity: 0.85; }

/* v0.4.0: Access Token 认证模态框 */
.auth-modal-content { max-width: 400px; }
.auth-hint { font-size: 14px; color: var(--text-secondary); margin: 0 0 4px 0; text-align: center; }
.auth-error { font-size: 13px; color: var(--accent-danger); margin: 4px 0 0 0; min-height: 0; }
.auth-error.hidden { display: none; }

.settings-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.settings-toggle-label { font-size: 13px; color: var(--text-secondary); flex: 1; }
.toggle-switch {
  position: relative; display: inline-block; width: 44px; height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border-primary);
  border-radius: 24px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: ""; position: absolute;
  height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-primary);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ── Command Palette ─────────────────────────────────────────────── */
.cmd-palette {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 2000;
}
.cmd-palette.hidden { display: none; }
.cmd-palette-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(2px);
}
.cmd-palette-content {
  position: absolute; top: 18%; left: 50%; transform: translateX(-50%);
  width: 520px; max-width: 90vw;
  background: var(--bg-panel); border: 1px solid var(--border-primary);
  border-radius: 14px; box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,0.05);
  overflow: hidden;
}
.cmd-palette-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border-secondary);
}
.cmd-palette-icon { font-size: 18px; opacity: 0.4; }
.cmd-palette-input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 15px; color: var(--text-primary);
  font-family: inherit;
}
.cmd-palette-input::placeholder { color: var(--text-tertiary); }
.cmd-palette-hint {
  font-size: 11px; padding: 2px 6px;
  border: 1px solid var(--border-primary); border-radius: 4px;
  color: var(--text-tertiary); font-family: monospace;
}
.cmd-palette-results { max-height: 320px; overflow-y: auto; padding: 6px 0; }
.cmd-palette-results:empty { padding: 24px 16px; }
.cmd-palette-results:empty::after {
  content: '没有匹配的命令'; display: block; text-align: center;
  color: var(--text-tertiary); font-size: 13px;
}
.cmd-palette-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; cursor: pointer; font-size: 14px;
  color: var(--text-primary); transition: background 0.1s;
}
.cmd-palette-item:hover, .cmd-palette-item.selected {
  background: var(--bg-secondary);
}
.cmd-palette-item-icon { font-size: 16px; width: 24px; text-align: center; flex-shrink: 0; }
.cmd-palette-item-label { flex: 1; }
.cmd-palette-item-shortcut {
  font-size: 11px; color: var(--text-tertiary); font-family: monospace;
  padding: 1px 5px; border: 1px solid var(--border-primary); border-radius: 3px;
}

/* ── System Health Bar ───────────────────────────────────────────── */
.health-bar {
  display: flex; gap: 18px; padding: 4px 16px;
  font-size: 10px; font-family: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
  background: rgba(6, 15, 30, 0.9);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-primary);
  overflow-x: auto; white-space: nowrap;
  letter-spacing: 0.04em;
}
.health-item { display: flex; align-items: center; gap: 4px; opacity: 0.55; transition: opacity 0.2s; }
.health-item:hover { opacity: 1; }
.health-item.warn { color: var(--accent-warning); opacity: 0.9; }
.health-item.critical { color: var(--accent-danger); opacity: 0.9; }
[data-theme="light"] .health-bar {
  background: rgba(240, 244, 248, 0.9);
}

/* ── Setup Wizard ─────────────────────────────────────────────────── */
.wizard-modal-content {
  max-width: 480px; width: 92%;
}
.wizard-steps { position: relative; min-height: 220px; }
.wizard-step { display: none; }
.wizard-step.active { display: block; }
.wizard-step h2 { font-size: 18px; font-weight: 600; margin: 0 0 6px; }
.wizard-step p { font-size: 13px; color: var(--text-secondary); margin: 0 0 16px; }
.wizard-step-body {
  display: flex; flex-direction: column; gap: 12px;
}
.wizard-actions {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border-secondary);
}
.wizard-btn {
  padding: 8px 18px; border-radius: 6px; border: 1px solid var(--border-primary);
  cursor: pointer; background: var(--bg-primary); color: var(--text-primary);
  font-size: 13px;
}
.wizard-btn:disabled { opacity: 0.35; cursor: default; }
.wizard-dots { display: flex; gap: 6px; }
.wiz-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border-primary); transition: background 0.2s;
}
.wiz-dot.active { background: var(--accent-primary); }
.wizard-radio-group { display: flex; flex-direction: column; gap: 10px; }
.wizard-radio {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-primary); cursor: pointer;
  padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border-secondary);
  transition: border-color 0.15s;
}
.wizard-radio:hover { border-color: var(--accent-primary); }
.wizard-radio:has(input:checked) {
  border-color: var(--accent-primary);
  background: color-mix(in srgb, var(--accent-primary) 8%, transparent);
}

/* ── Kanban Board ──────────────────────────────────────────────────── */
.kanban-board {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px;
  padding: 12px 0; min-height: 200px;
}
.kanban-board.hidden { display: none; }
.kanban-column {
  background: var(--glass-bg, rgba(255,255,255,0.5));
  backdrop-filter: blur(8px); border-radius: 12px;
  border: 1px solid var(--border-secondary);
  display: flex; flex-direction: column; min-height: 160px;
}
.kanban-col-header {
  padding: 10px 12px; font-size: 13px; font-weight: 600;
  border-bottom: 1px solid var(--border-secondary);
  display: flex; justify-content: space-between;
}
.kanban-count {
  background: var(--bg-tertiary); border-radius: 10px;
  padding: 0 7px; font-size: 11px; line-height: 18px;
}
.kanban-col-body { flex: 1; padding: 8px; overflow-y: auto; min-height: 60px; }
.kanban-card {
  background: var(--bg-primary); border: 1px solid var(--border-primary);
  border-radius: 8px; padding: 8px 10px; margin-bottom: 6px;
  font-size: 13px; cursor: grab; transition: box-shadow 0.15s;
  color: var(--text-primary);
}
.kanban-card:hover { box-shadow: var(--shadow-sm); }
.kanban-card.dragging { opacity: 0.4; }
.kanban-card .kanban-card-idx {
  font-size: 10px; color: var(--text-tertiary); margin-right: 6px;
}

/* ── Cron Job Manager ─────────────────────────────────────────────── */
.cron-modal-content { max-width: 560px; }
.cron-list { display: flex; flex-direction: column; gap: 8px; }
.cron-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--bg-primary); border: 1px solid var(--border-secondary);
  border-radius: 8px; font-size: 13px;
}
.cron-item-name { font-weight: 600; min-width: 80px; color: var(--text-primary); }
.cron-item-schedule {
  font-family: monospace; font-size: 12px; color: var(--text-secondary);
  background: var(--bg-tertiary); padding: 2px 6px; border-radius: 4px;
}
.cron-item-desc { flex: 1; color: var(--text-tertiary); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cron-status {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.cron-status.active { background: var(--accent-success); }
.cron-status.disabled { background: var(--text-tertiary); }
.cron-actions { display: flex; gap: 4px; flex-shrink: 0; }
.cron-actions button {
  padding: 3px 8px; font-size: 11px; border-radius: 4px; border: 1px solid var(--border-primary);
  cursor: pointer; background: var(--bg-primary); color: var(--text-primary);
}
.cron-actions button:hover { background: var(--bg-tertiary); }
.cron-actions .cron-btn-delete { color: var(--accent-danger); border-color: transparent; }
.cron-actions .cron-btn-delete:hover { background: rgba(245,33,47,0.1); }

/* ── Analytics Dashboard ──────────────────────────────────────────── */
.analytics-modal-content { max-width: 480px; }
.analytics-summary {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 16px;
}
.analytics-card {
  background: var(--bg-primary); border: 1px solid var(--border-secondary);
  border-radius: 10px; padding: 14px; text-align: center;
}
.analytics-card-value { font-size: 24px; font-weight: 700; color: var(--accent-primary); }
.analytics-card-label { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }
.analytics-breakdown { font-size: 13px; color: var(--text-secondary); }

/* ── File Browser ──────────────────────────────────────────────────── */
.files-modal-content { max-width: 860px; height: 560px; }
.files-modal-content .modal-header { gap: 8px; }
.files-toolbar { display: flex; align-items: center; gap: 6px; flex: 1; }
.files-cwd {
  font-size: 12px; color: var(--text-tertiary); font-family: monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px;
}
.files-body {
  display: grid; grid-template-columns: 280px 1fr; gap: 0;
  flex: 1; overflow: hidden; min-height: 0;
}
.files-tree {
  border-right: 1px solid var(--border-primary);
  overflow-y: auto; padding: 4px 0;
  font-size: 13px; user-select: none;
}
.files-tree-loading { color: var(--text-tertiary); padding: 16px; text-align: center; }
.files-tree-item {
  display: flex; align-items: center; gap: 4px; padding: 3px 12px;
  cursor: pointer; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.files-tree-item:hover { background: var(--bg-hover); }
.files-tree-item.active { background: var(--accent-primary); color: #fff; }
.files-tree-item.dir { font-weight: 500; color: var(--text-primary); }
.files-tree-item .tree-icon { font-size: 14px; flex-shrink: 0; width: 18px; text-align: center; }
.files-tree-item .tree-size { font-size: 10px; color: var(--text-tertiary); margin-left: auto; padding-left: 4px; }
.files-tree-children { padding-left: 14px; }
.files-tree-children.collapsed { display: none; }
.files-preview {
  overflow-y: auto; padding: 12px 16px;
  font-size: 13px; font-family: monospace;
  background: var(--bg-primary);
}
.files-preview-placeholder {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text-tertiary); font-family: inherit;
}
.files-preview pre {
  margin: 0; white-space: pre-wrap; word-break: break-all;
  background: transparent;
}
.files-preview-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border-secondary);
}
.files-preview-name {
  font-weight: 600; color: var(--text-primary); font-size: 13px;
}
.files-preview-size {
  font-size: 11px; color: var(--text-tertiary);
}

/* ── 图片/视频预览 ── */
.files-preview-media {
  display: flex; align-items: center; justify-content: center;
  min-height: 120px; padding: 12px; overflow: auto;
}
.preview-image {
  max-width: 100%; max-height: 420px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  object-fit: contain;
}
.preview-video {
  max-width: 100%; max-height: 420px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  outline: none;
}

/* ── HTML 文件预览（沙箱 iframe）── */
.preview-iframe {
  width: 100%; min-height: 420px;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  background: #fff;
}

/* ── Markdown 文件预览 ── */
.files-preview-md {
  padding: 8px 0;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
}
.files-preview-md h1, .files-preview-md h2, .files-preview-md h3 {
  margin: 16px 0 8px;
  font-weight: 600;
  color: var(--text-primary);
}
.files-preview-md h1 { font-size: 1.3em; }
.files-preview-md h2 { font-size: 1.15em; }
.files-preview-md h3 { font-size: 1.05em; }
.files-preview-md p { margin: 8px 0; }
.files-preview-md ul, .files-preview-md ol { padding-left: 20px; margin: 8px 0; }
.files-preview-md code {
  font-family: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
  font-size: 13px;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
}
.files-preview-md pre {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  margin: 12px 0;
}
.files-preview-md pre code {
  background: none;
  padding: 0;
}
.files-preview-md blockquote {
  border-left: 3px solid var(--accent-primary);
  margin: 8px 0;
  padding: 4px 12px;
  color: var(--text-secondary);
}
.files-preview-md a {
  color: var(--accent-primary);
  text-decoration: none;
}
.files-preview-md a:hover { text-decoration: underline; }
.files-preview-md table {
  border-collapse: collapse; margin: 8px 0; font-size: 13px;
}
.files-preview-md th, .files-preview-md td {
  border: 1px solid var(--border-primary); padding: 6px 10px;
}
.files-preview-md th {
  background: var(--bg-tertiary); font-weight: 600;
}
.files-preview-md img {
  max-width: 100%; border-radius: var(--radius-md);
}

/* ── Session Picker ─────────────────────────────────────────────────── */
.session-modal-content { max-width: 520px; }
.session-hint { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }
.session-list { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; }
.session-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.session-item:hover { background: var(--bg-tertiary); border-color: var(--accent-primary); }
.session-item-icon {
  font-size: 20px; flex-shrink: 0; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-tertiary); border-radius: 50%;
}
.session-item-body { flex: 1; min-width: 0; }
.session-item-text {
  font-size: 13px; color: var(--text-primary); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-item-meta {
  font-size: 11px; color: var(--text-tertiary);
  display: flex; gap: 12px; margin-top: 2px;
}
.session-item-model {
  background: var(--bg-tertiary);
  padding: 1px 6px; border-radius: 4px;
  font-family: monospace; font-size: 10px;
  color: var(--text-secondary);
}
.session-item-btn {
  font-size: 12px; padding: 5px 14px;
  background: var(--accent-primary); color: #fff; border: none;
  border-radius: 6px; cursor: pointer; flex-shrink: 0;
  font-weight: 500; transition: background 0.15s;
}
.session-item-btn:hover { background: var(--accent-primary-hover); }
.session-item-btn:disabled { background: var(--text-tertiary); cursor: not-allowed; opacity: 0.6; }
.session-live-badge {
  display: inline-block; font-size: 10px; font-weight: 600;
  color: var(--accent-running); background: rgba(59,130,246,0.12);
  padding: 1px 6px; border-radius: 4px; margin-left: 6px;
  vertical-align: middle;
}
.session-item-live { opacity: 0.7; cursor: default; }
.session-item-live:hover { background: transparent; border-color: var(--border-primary); }
.session-actions { margin-top: 14px; display: flex; justify-content: center; }
.session-new-btn {
  font-size: 13px; padding: 8px 24px;
  background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-primary);
  border-radius: 8px; cursor: pointer; font-weight: 500; transition: background 0.15s;
}
.session-new-btn:hover { background: var(--bg-hover, #f0f0f0); }
.session-empty { text-align: center; color: var(--text-tertiary); padding: 24px; font-size: 13px; }

/* Vision Skills 多配置 */
.vision-skills-section { display: flex; flex-direction: column; gap: 8px; }
.vision-skills-list { display: flex; flex-direction: column; gap: 4px; }
.vision-skill-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--bg-tertiary); border-radius: 8px; border: 1px solid var(--border-primary);
}
.vision-skill-item-info { flex: 1; min-width: 0; }
.vision-skill-item-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.vision-skill-item-model { font-size: 11px; color: var(--text-secondary); font-family: monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vision-skill-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
.vision-skill-form {
  display: flex; flex-direction: column; gap: 8px; padding: 12px;
  background: var(--bg-tertiary); border-radius: 8px; border: 1px solid var(--accent-primary);
}
.vision-skill-form.hidden { display: none; }
.vision-skill-form-actions { display: flex; gap: 8px; justify-content: flex-end; }
.vision-skill-add-btn { align-self: flex-start; font-size: 12px; padding: 5px 12px; }
.vision-active-section { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px solid var(--border-primary); margin-top: 4px; }
.vision-active-row { display: flex; align-items: center; gap: 10px; }
.vision-active-label { font-size: 12px; color: var(--text-secondary); white-space: nowrap; width: 80px; flex-shrink: 0; }
.vision-active-select { flex: 1; }
.btn-ghost {
  background: none; border: 1px solid var(--border-primary); border-radius: 8px;
  padding: 7px 14px; cursor: pointer; font-size: 13px; color: var(--text-secondary);
}
.btn-ghost:hover { border-color: var(--accent-primary); color: var(--text-primary); }
.btn-sm { padding: 5px 11px !important; font-size: 12px !important; }
.btn-icon {
  background: none; border: none; cursor: pointer; padding: 3px 6px;
  border-radius: 6px; font-size: 14px; color: var(--text-secondary); line-height: 1;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Vision Skill 状态图标 */
.vision-skill-status {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0; cursor: default; position: relative;
  background: var(--border-primary);
}
.status-dot-ok    { background: #4ade80; box-shadow: 0 0 6px rgba(74,222,128,.5); }
.status-dot-error { background: #f87171; box-shadow: 0 0 6px rgba(248,113,113,.5); }
.status-dot-unknown { background: #6b7280; }
.vision-skill-status[title]:hover::after {
  content: attr(title);
  position: absolute; right: 0; top: 120%;
  background: var(--bg-secondary); border: 1px solid var(--border-primary);
  color: var(--text-primary); font-size: 11px; white-space: nowrap;
  padding: 4px 8px; border-radius: 6px; z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
/* 表单里的双列行 */
.vsk-row { display: flex; gap: 8px; }
.vsk-half { flex: 1; min-width: 0; }

/* 用户消息气泡里的附件缩略图 */
.chat-bubble-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chat-bubble-thumb { width: 80px; height: 60px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border-primary); display: block; }
.chat-bubble-file-tag { font-size: 12px; color: var(--text-secondary); background: var(--bg-tertiary); border-radius: 6px; padding: 4px 8px; }


/* ═══════════════════════════════════════════════════════════
   Activity Bar 布局（v0.5）
   ══════════════════════════════════════════════════════════ */

/* app-shell: activity-bar + sidebar-panel + main-area 横向排列 */
.app-shell {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  z-index: 1;
  height: calc(100vh - 28px);
  height: calc(100dvh - 28px); /* 留出 health-bar 高度 */
}

/* ── Activity Bar ── */
.activity-bar {
  width: 52px;
  flex-shrink: 0;
  background: var(--bg-header);
  border-right: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  z-index: 10;
}

.activity-bar-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.activity-bar-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.act-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #adbac7;
  position: relative;
  transition: background 0.15s, color 0.15s;
}

.act-btn:hover {
  background: rgba(48, 54, 61, 0.8);
  color: #e6edf3;
}

.act-btn.active {
  background: rgba(33, 99, 186, 0.55);
  color: #79c0ff;
}

.act-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 28px;
  background: #58a6ff;
  border-radius: 0 3px 3px 0;
}

.act-icon { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; }
.act-icon svg { width: 20px; height: 20px; }
.act-label { font-size: 9px; letter-spacing: 0.02em; font-family: "IBM Plex Sans", sans-serif; }

/* ── 折叠侧边辅助面板 ── */
.sidebar-panel {
  width: 260px;
  flex-shrink: 0;
  background: var(--glass-bg);
  backdrop-filter: var(--backdrop-blur);
  border-right: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease;
}

.sidebar-panel.hidden {
  width: 0;
  border-right: none;
}

.sidebar-panel-header {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-primary);
  flex-shrink: 0;
}

.sidebar-panel-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-panel-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
}
.sidebar-panel-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.sidebar-panel-body { flex: 1; overflow-y: auto; }
.sidebar-sub-panel { padding: 8px 0; }

/* ── 主内容区 ── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── 标题栏（Session Tabs + 工具）── */
.main-header {
  height: 42px;
  flex-shrink: 0;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: flex-end;
  padding: 0 8px 0 0;
  gap: 0;
  z-index: 5;
}

/* Session Tabs */
.session-tabs {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  overflow: hidden;
  padding: 0 6px;
}

.session-tab {
  height: 36px;
  padding: 0 16px;
  border-radius: 8px 8px 0 0;
  border: 1px solid rgba(48, 54, 61, 0.6);
  border-bottom: none;
  background: #0d1117;
  color: #8b949e;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.session-tab:hover {
  background: #161b22;
  color: #adbac7;
}

.session-tab.active {
  background: #1c2d4a;
  color: #e6edf3;
  border-color: rgba(47, 129, 247, 0.45);
  font-weight: 500;
  box-shadow: 0 -3px 0 #2f81f7;
}

.session-tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-success);
  flex-shrink: 0;
}

.session-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.session-tab-close {
  opacity: 0.4;
  font-size: 12px;
  flex-shrink: 0;
  margin-left: 4px;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
}
.session-tab-close:hover { opacity: 1; background: rgba(255,61,0,0.15); color: var(--accent-danger); }

.session-tab-new {
  height: 28px;
  width: 28px;
  border-radius: 6px;
  background: none;
  border: 1px dashed var(--border-primary);
  color: var(--text-secondary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-bottom: 3px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.session-tab-new:hover { border-color: var(--accent-primary); color: var(--accent-primary); background: rgba(47,129,247,0.06); }

/* 会话模型指示器 */
.session-tab-model {
  font-size: 10px;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  border-radius: 4px;
  padding: 1px 6px;
  line-height: 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  flex-shrink: 0;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 会话配置齿轮按钮区域 */
.session-model-area {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  flex-shrink: 0;
}

.session-model-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-model-apply {
  height: 28px;
  width: 28px;
  border-radius: 6px;
  border: 1px solid var(--border-primary);
  background: var(--bg-tertiary);
  color: var(--accent-primary);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.session-model-apply:hover {
  background: rgba(47,129,247,0.12);
  border-color: var(--accent-primary);
}

/* 右侧工具组 */
.header-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 1;
  min-width: 0;
  padding-bottom: 4px;
}

/* ── 视图容器 ── */
.view-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.main-view {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.main-view.active {
  display: flex;
}

/* 视图通用 header */
.view-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg-header);
}

.view-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.view-header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── 对话视图 footer ── */
.chat-footer {
  border-top: 1px solid var(--border-primary);
  padding: 8px 12px 10px;
  background: var(--bg-primary);
  flex-shrink: 0;
}

/* ── 历史会话视图 ── */
.history-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.history-item-info { flex: 1; min-width: 0; }

.history-item-cwd {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.history-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.history-item.active {
  border-color: var(--accent-primary);
  background: rgba(0, 212, 255, 0.06);
}

.history-item.active .history-item-name {
  color: var(--accent-primary);
}

.history-item.inactive {
  opacity: 0.55;
}

.history-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 2px 2px 4px;
}

.history-divider {
  border: none;
  border-top: 1px solid var(--border-primary);
  margin: 4px 0 8px;
}
  flex-shrink: 0;
}

/* ── 设置全页视图 ── */
.settings-page {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.settings-nav {
  width: 180px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-primary);
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-secondary);
}

.settings-nav-item {
  padding: 9px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  border-left: 2px solid transparent;
  transition: all 0.15s;
}

.settings-nav-item:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.settings-nav-item.active { color: var(--accent-primary); border-left-color: var(--accent-primary); background: rgba(0,212,255,0.06); }

.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.settings-tab { display: none; }
.settings-tab.active { display: block; }

.settings-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-item {
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── 新建会话弹框 ── */
.new-session-modal-content {
  width: 460px;
}

.dir-picker {
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  overflow: hidden;
}

.dir-picker-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-primary);
}

.dir-picker-current {
  flex: 1;
  font-size: 11px;
  font-family: monospace;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dir-picker-list {
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-secondary);
}

.dir-picker-loading {
  padding: 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
}

.dir-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-primary);
  transition: background 0.1s;
}

.dir-picker-item:hover { background: var(--bg-hover); }
.dir-picker-item.active { background: var(--bg-active); }
.dir-picker-item .dir-icon { color: var(--accent-primary); font-size: 14px; }
.dir-picker-item.parent { color: var(--text-secondary); }

.dir-picker-footer {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-primary);
}

.dir-picker-input {
  flex: 1;
  font-size: 12px;
  padding: 5px 8px;
  height: auto;
}

/* 桌面端隐藏会话按钮（只在移动端显示） */
#act-sessions-mobile { display: none; }

/* ══ 移动端会话抽屉 ══ */
.mobile-session-badge {
  display: inline-block;
  font-size: 10px;
  background: var(--accent-primary);
  color: #fff;
  border-radius: 8px;
  padding: 0 4px;
  margin-left: 3px;
  min-width: 14px;
  text-align: center;
  line-height: 14px;
  vertical-align: middle;
}
.mobile-session-badge:empty { display: none; }

.mobile-session-drawer { display: none; }

@media (max-width: 640px) {
  #act-sessions-mobile { display: none; }

  .mobile-session-drawer {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 1000;
    flex-direction: column;
    justify-content: flex-end;
  }
  .mobile-session-drawer.hidden { display: none; }

  .mobile-session-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
  }

  .mobile-session-drawer-sheet {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 16px 16px 0 0;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .mobile-session-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
  }

  .mobile-session-drawer-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
  }

  .mobile-session-drawer-new {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
  }

  .mobile-session-list {
    overflow-y: auto;
    flex: 1;
    padding: 8px 0;
  }

  .mobile-session-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-primary);
  }
  .mobile-session-item:last-child { border-bottom: none; }
  .mobile-session-item.active { background: var(--bg-tertiary); }
  .mobile-session-item:active { opacity: 0.7; }

  .mobile-session-item-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-primary);
    flex-shrink: 0;
  }
  .mobile-session-item.active .mobile-session-item-dot { background: var(--accent-primary); }

  .mobile-session-item-info { flex: 1; min-width: 0; }
  .mobile-session-item-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mobile-session-item-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
  }

  .mobile-session-item-close {
    color: var(--text-tertiary);
    font-size: 18px;
    padding: 4px 8px;
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
  }
}

/* ══ 移动端：底部 Tab Bar ══ */
@media (max-width: 640px) {
  /* ── 移动端隐藏顶部 session tabs ── */
  .session-tabs { display: none !important; }
  .session-model-area { display: none !important; }

  /* ── 整体布局 ── */
  .app-shell {
    flex-direction: column;
    /* activity-bar(56px) + health-bar(28px) = 84px, 但 health-bar 在 app-shell 外，所以仅减 activity-bar */
    height: calc(100vh - 28px);
    height: calc(100dvh - 28px);
  }

  /* ── activity bar → 底部导航条 ── */
  .activity-bar {
    width: 100%;
    height: 56px;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border-primary);
    padding: 0 4px;
    order: 10;
    justify-content: space-around;
    flex-shrink: 0;
    position: relative;
    z-index: 950;  /* 高于 sidebar-panel overlay(900)，低于 session-drawer(1000) */
  }

  .activity-bar-top {
    flex-direction: row;
    flex: 1;
    justify-content: space-around;
  }

  .activity-bar-bottom {
    flex-direction: row;
  }

  .act-btn {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
  }

  .act-btn.active::before { display: none; }
  .act-label { font-size: 10px; }

  /* ── 侧边面板：移动端隐藏（已由 view-plan/view-agent 替代）── */
  .sidebar-panel {
    display: none;
  }

  /* ── 标题栏 ── */
  /* session-tabs 和 model-area 移动端由底部抽屉替代，已在上方隐藏 */

  .main-header {
    height: auto;
    min-height: 44px;
    padding: env(safe-area-inset-top, 8px) 8px 6px;
    flex-wrap: wrap;
    gap: 4px;
  }

  /* 工具栏精简：隐藏不必要的按钮 */
  .header-tools {
    flex-wrap: nowrap;
    overflow: hidden;
    gap: 4px;
    padding-bottom: 0;
  }

  /* 移动端工具栏全部保留 */

  /* 确保剩余按钮有足够触摸区域 */
  .toolbar-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .theme-toggle {
    padding: 6px 10px;
    height: 36px;
    min-width: 36px;
    flex-shrink: 0;
  }

  .connection-status {
    padding: 4px 8px;
    font-size: 11px;
    flex-shrink: 0;
  }

  .context-status {
    max-width: 80px;
  }

  /* ── 聊天消息区 ── */
  .chat-messages {
    padding: 12px 12px;
    gap: 6px;
  }

  .chat-bubble {
    max-width: 96%;
    font-size: 14px;
    padding: 10px 12px;
  }

  .chat-bubble.user {
    max-width: 88%;
  }

  /* ── 输入区域 ── */
  .chat-footer {
    padding: 6px 10px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  }

  .input-row {
    gap: 8px;
  }

  #intent-input {
    height: 52px;
    padding: 10px 12px;
    font-size: 16px; /* 防止 iOS 自动缩放 */
  }

  .attach-btn {
    height: 52px;
    width: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  #submit-btn {
    height: 52px;
    padding: 0 18px;
    font-size: 14px;
    flex-shrink: 0;
  }

  #cancel-btn {
    height: 52px;
    padding: 0 14px;
    font-size: 13px;
    flex-shrink: 0;
  }

  /* ── 设置页：单栏布局 ── */
  .settings-page {
    flex-direction: column;
    overflow-y: auto;
  }

  .settings-nav {
    width: 100%;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 8px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border-primary);
    gap: 4px;
    flex-shrink: 0;
  }

  .settings-nav-item {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .settings-content {
    overflow-y: auto;
    flex: 1;
  }

  /* ── 看板 ── */
  .kanban-board {
    grid-template-columns: 1fr;
    overflow-y: auto;
    padding: 8px;
    gap: 8px;
  }

  .kanban-column {
    min-height: 100px;
  }

  /* ── 模态框 ── */
  .modal-content {
    width: 95vw !important;
    max-width: none !important;
    margin: 16px auto;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
  }

  .session-config-panel {
    width: 100vw;
    height: 100dvh;
  }

  /* ── 文件浏览视图 ── */
  .files-body {
    grid-template-columns: 1fr;
    grid-template-rows: 180px 1fr;
  }

  .files-tree {
    border-right: none;
    border-bottom: 1px solid var(--border-primary);
    overflow-y: auto;
    max-height: none;
  }

  .files-preview {
    overflow-y: auto;
  }

  /* ── health bar 精简 ── */
  .health-bar {
    gap: 10px;
    padding: 3px 10px;
    font-size: 9px;
  }

  /* ── 日志行 ── */
  .log-line {
    font-size: 12px;
  }
}

/* ── 右侧会话配置面板 ── */
.session-config-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  height: 100dvh;
  z-index: 60;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
  transform: translateX(0);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.session-config-panel.hidden {
  transform: translateX(100%);
}

.session-config-panel-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-primary);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.session-config-panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.session-config-panel-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.session-config-panel-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.session-config-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.session-config-panel-body .settings-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sess-config-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.sess-config-actions > * {
  flex: 1;
}

/* 新建会话高级配置 */
.new-session-advanced {
  margin-top: 8px;
}
.new-session-advanced summary {
  font-size: 12px;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px 0;
}
.new-session-advanced .settings-label {
  margin-top: 8px;
}

/* ── Cron Toast Notifications ── */
.cron-toast-container {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.cron-toast {
  pointer-events: auto;
  min-width: 280px; max-width: 360px;
  background: var(--glass-bg, rgba(10, 22, 40, 0.94));
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-primary, rgba(47, 129, 247, 0.18));
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: opacity 0.4s ease, transform 0.4s ease;
  transform: translateX(0);
  opacity: 1;
  cursor: default;
}
.cron-toast.dismissing {
  opacity: 0;
  transform: translateX(20px);
}
.cron-toast.type-start { border-left: 3px solid #f59e0b; }
.cron-toast.type-done  { border-left: 3px solid #10b981; }
.cron-toast.type-error { border-left: 3px solid #ef4444; }
.cron-toast-title {
  font-size: 0.85em;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
  margin: 0;
}
.cron-toast-body {
  font-size: 0.78em;
  color: var(--text-secondary, #94a3b8);
  margin: 0;
  line-height: 1.4;
  word-break: break-word;
}
.cron-toast-link {
  font-size: 0.75em;
  color: var(--accent-primary, #00d4ff);
  text-decoration: none;
  margin-top: 2px;
  cursor: pointer;
  align-self: flex-start;
}
.cron-toast-link:hover { text-decoration: underline; }
.cron-toast-close {
  position: absolute;
  top: 8px; right: 10px;
  background: none; border: none;
  color: var(--text-secondary, #94a3b8);
  font-size: 1em; cursor: pointer;
  line-height: 1; padding: 0;
  opacity: 0.6;
}
.cron-toast-close:hover { opacity: 1; }

/* ── Accessibility: reduce motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  #starfield-canvas { display: none; }
}
