/* ========================================
   Ranking · 智能任务编排 — 设计系统 v5.0
   金融风格 · 深蓝金 · 精准稳重
   ======================================== */

/* ---- CSS Variables (Dark Theme - Default) ---- */
:root {
  /* 金融深色调 — 午夜蓝基底，克制冷静 */
  --color-bg: #0b0e1a;
  --color-surface: #111524;
  --color-surface-raised: #171b2e;
  --color-border: #1e233a;
  --color-border-hover: #2a3052;
  --color-text-primary: #e8e9ef;
  --color-text-secondary: #8f93b0;
  --color-text-muted: #5b6080;
  --color-accent: #c9a94e;
  --color-accent-hover: #dbb85c;
  --color-accent-subtle: rgba(201, 169, 78, 0.08);
  --color-accent-glow: rgba(201, 169, 78, 0.15);
  --color-success: #3cc27e;
  --color-success-subtle: rgba(60, 194, 126, 0.08);
  --color-warning: #d99a3e;
  --color-warning-subtle: rgba(217, 154, 62, 0.08);
  --color-danger: #d95454;
  --color-danger-subtle: rgba(217, 84, 84, 0.08);
  --color-info: #5b9bd5;
  --color-info-subtle: rgba(91, 155, 213, 0.08);
  --color-running: #7b93d4;
  --color-running-subtle: rgba(123, 147, 212, 0.08);

  /* 金融品牌渐变 — 金色系 */
  --brand-gradient: linear-gradient(135deg, #c9a94e 0%, #dbb85c 35%, #e8c97a 70%, #b8943a 100%);
  --brand-gradient-subtle: linear-gradient(135deg, rgba(201,169,78,0.05) 0%, rgba(219,184,92,0.03) 50%, rgba(184,148,58,0.02) 100%);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  /* 金融阴影 — 精准、克制 */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.25), 0 0 0 1px rgba(201,169,78,0.03);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.35), 0 0 0 1px rgba(201,169,78,0.04);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.45), 0 0 0 1px rgba(201,169,78,0.05);
  --shadow-glow: 0 0 20px rgba(201, 169, 78, 0.12);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.25), 0 0 0 1px rgba(201,169,78,0.03);

  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', 'Consolas', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-serif: 'Georgia', 'Times New Roman', 'Songti SC', 'Noto Serif SC', serif;

  --sidebar-width: 230px;
  --topbar-height: 56px;
  --transition-fast: 180ms cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition-smooth: 280ms cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition-spring: 450ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---- Light Theme ---- */
:root.light-theme {
  --color-bg: #f8f9fc;
  --color-surface: #ffffff;
  --color-surface-raised: #ffffff;
  --color-border: #e8ebf3;
  --color-border-hover: #d1d5e0;
  --color-text-primary: #1e2030;
  --color-text-secondary: #5f6375;
  --color-text-muted: #8f93a5;
  --color-accent: #6366f1;
  --color-accent-hover: #5558e6;
  --color-accent-subtle: rgba(99, 102, 241, 0.07);
  --color-accent-glow: rgba(99, 102, 241, 0.12);
  --color-success: #22c55e;
  --color-success-subtle: rgba(34, 197, 94, 0.07);
  --color-warning: #f59e0b;
  --color-warning-subtle: rgba(245, 158, 11, 0.07);
  --color-danger: #ef4444;
  --color-danger-subtle: rgba(239, 68, 68, 0.07);
  --color-info: #3b82f6;
  --color-info-subtle: rgba(59, 130, 246, 0.07);
  --color-running: #8b5cf6;
  --color-running-subtle: rgba(139, 92, 246, 0.07);

  --brand-gradient-subtle: linear-gradient(135deg, rgba(99,102,241,0.03) 0%, rgba(168,85,247,0.02) 50%, rgba(236,72,153,0.01) 100%);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.03), 0 0px 1px rgba(0,0,0,0.02);
  --shadow-md: 0 4px 10px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.03);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.03);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.08);
  --shadow-card: 0 1px 2px rgba(0,0,0,0.03), 0 1px 4px rgba(0,0,0,0.02);
}

/* 亮色主题 — 半透明元素覆写 */
.light-theme .sidebar,
.light-theme .topbar {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.light-theme .btn-secondary {
  background: rgba(0,0,0,0.02);
}

.light-theme .btn-secondary:hover {
  background: rgba(0,0,0,0.05);
}

.light-theme .log-viewport {
  background: rgba(248, 249, 252, 0.8);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.04);
}

.light-theme .toast {
  background: rgba(255, 255, 255, 0.92);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  position: relative;
}

/* 柔光层1 — 顶部暖光 */
body::before {
  content: '';
  position: fixed;
  top: -30%;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 70%;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 0%,
    rgba(124, 127, 246, 0.05) 0%,
    rgba(167, 139, 250, 0.03) 30%,
    transparent 65%);
  filter: blur(80px);
}

/* 柔光层2 — 右下角冷光 */
body::after {
  content: '';
  position: fixed;
  bottom: -15%;
  right: -10%;
  width: 55%;
  height: 50%;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center,
    rgba(96, 165, 250, 0.03) 0%,
    rgba(124, 127, 246, 0.02) 40%,
    transparent 70%);
  filter: blur(70px);
}

/* 点阵纹理 — 用径向渐变模拟柔和点阵，替代硬朗网格 */
.background-dots {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: radial-gradient(rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* 亮色主题调整 */
.light-theme body::before {
  background: radial-gradient(ellipse at 50% 0%,
    rgba(99, 102, 241, 0.035) 0%,
    rgba(168, 85, 247, 0.02) 30%,
    transparent 65%);
}

.light-theme body::after {
  background: radial-gradient(ellipse at center,
    rgba(59, 130, 246, 0.02) 0%,
    rgba(99, 102, 241, 0.015) 40%,
    transparent 70%);
}

.light-theme .background-dots {
  opacity: 0.45;
  background-image: radial-gradient(rgba(0,0,0,0.05) 1px, transparent 1px);
}

input, textarea, select, button { font-family: inherit; font-size: inherit; }

a { color: inherit; text-decoration: none; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-hover); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ---- App Shell ---- */
.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  position: relative;
  z-index: 1;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: rgba(22, 25, 34, 0.85);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-smooth);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--color-border);
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: var(--brand-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 2px 10px rgba(124, 127, 246, 0.25);
}

.brand-icon svg { width: 18px; height: 18px; }

.brand-text {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-smooth);
  cursor: pointer;
  position: relative;
  user-select: none;
}

.nav-item:hover {
  background: rgba(124, 127, 246, 0.06);
  color: var(--color-text-primary);
}

.nav-item.active {
  background: rgba(124, 127, 246, 0.08);
  color: var(--color-accent);
  font-weight: 600;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--color-accent);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.nav-dot {
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

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

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

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

.status-indicator.offline { background: var(--color-text-muted); }
.status-indicator.connecting { background: var(--color-warning); animation: pulse-dot 1s infinite; }
.status-indicator.online { background: var(--color-success); }

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ---- Top Bar ---- */
.topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  background: rgba(22, 25, 34, 0.85);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  z-index: 50;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.menu-toggle:hover { background: var(--color-accent-subtle); color: var(--color-text-primary); }
.menu-toggle svg { width: 20px; height: 20px; }

.page-title {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---- Buttons ---- */
button {
  cursor: pointer;
  border: none;
  outline: none;
  transition: all var(--transition-fast);
  position: relative;
}

button:active { transform: scale(0.975); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--brand-gradient);
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  letter-spacing: -0.01em;
  box-shadow: 0 2px 8px rgba(124, 127, 246, 0.2);
}

.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(124, 127, 246, 0.35);
  transform: translateY(-1px);
}
.btn-primary svg { width: 16px; height: 16px; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(255,255,255,0.03);
  color: var(--color-text-secondary);
  font-weight: 500;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.06);
  color: var(--color-text-primary);
  border-color: var(--color-border-hover);
}
.btn-secondary svg { width: 16px; height: 16px; }

.btn-warning {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--color-warning);
  color: #1a1c2e;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-warning:hover {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}
.btn-warning svg { width: 16px; height: 16px; }

.btn-icon {
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover { background: var(--color-accent-subtle); color: var(--color-text-primary); }
.btn-icon svg { width: 18px; height: 18px; }

/* 主题切换按钮 */
.btn-theme-toggle {
  position: relative;
}
.btn-theme-toggle .icon-sun,
.btn-theme-toggle .icon-moon {
  transition: all var(--transition-spring);
}
/* 暗色主题下显示太阳图标（点击切换到亮色） */
.btn-theme-toggle .icon-sun { display: block; }
.btn-theme-toggle .icon-moon { display: none; }
/* 亮色主题下显示月亮图标（点击切换到暗色） */
.light-theme .btn-theme-toggle .icon-sun { display: none; }
.light-theme .btn-theme-toggle .icon-moon { display: block; }

.btn-icon-sm {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-sm:hover { background: var(--color-surface-raised); color: var(--color-text-primary); }
.btn-icon-sm svg { width: 16px; height: 16px; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--color-danger-subtle);
  color: var(--color-danger);
  font-weight: 500;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-danger:hover { background: var(--color-danger); color: white; }

.btn-success {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--color-success-subtle);
  color: var(--color-success);
  font-weight: 500;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-success:hover { background: var(--color-success); color: white; }

/* ---- Content Panels ---- */
.content-panels {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  scroll-behavior: smooth;
}

.panel {
  display: none;
  animation: fadeSlideIn 0.3s ease;
}

.panel.active { display: block; }

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

.panel-inner {
  max-width: 720px;
  margin: 0 auto;
  min-height: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-sm);
}

/* 配置页面和 API 文档 panel：内容靠左，不受 max-width 限制 */
#panel-config .panel-inner,
#panel-api-documentation .panel-inner {
  max-width: none;
  margin: 0;
  text-align: left;
}
#panel-api-documentation .view-toggle-bar {
  justify-content: flex-start;
}
#panel-api-documentation .api-docs-layout {
  align-items: flex-start;
}

/* ---- 运行页分栏布局（已废弃，任务和日志已合并到配置页） ---- */
/* ---- 配置页分割线 ---- */
.section-divider {
  height: 1px;
  background: var(--color-border);
  margin: 32px 0;
  opacity: 0.6;
}

.config-section + .config-section {
  margin-top: 0;
}

.panel-header {
  margin-bottom: 28px;
}

.panel-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.panel-desc {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.panel-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-actions {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
}

/* ---- Form ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-field.span-2 { grid-column: span 2; }

.form-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.field-header label {
  margin-bottom: 0;
}

.field-header .btn-secondary {
  padding: 4px 10px;
  font-size: 0.75rem;
  gap: 4px;
}

.field-header .btn-secondary svg {
  width: 14px;
  height: 14px;
}

.form-field label .required { color: var(--color-danger); }

.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 10px 14px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  outline: none;
}

.form-field input:focus,
.form-field textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(124, 127, 246, 0.08);
}

.form-field textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.form-field input::placeholder,
.form-field textarea::placeholder {
  color: var(--color-text-muted);
}

.input-with-icon {
  position: relative;
}

.input-with-icon svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  pointer-events: none;
}

.input-with-icon input { padding-left: 38px; }

/* ==================== 自定义下拉面板（替代 datalist） ==================== */

.dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 500;
  max-height: 220px;
  overflow-y: auto;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 4px 0;
}

.dropdown-panel.open {
  display: block;
}

.dropdown-panel .dropdown-item {
  padding: 8px 14px;
  cursor: pointer;
  color: var(--color-text-primary);
  font-size: 0.85rem;
  transition: background var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-panel .dropdown-item:hover {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
}

.dropdown-panel .dropdown-item.active {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
}

.dropdown-panel .dropdown-empty {
  padding: 12px 14px;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* 确保 dropdown-trigger 作为定位父容器 */
.dropdown-trigger {
  position: relative;
}

.input-with-suffix {
  position: relative;
}

.input-with-suffix input { padding-right: 40px; }

.input-suffix-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-suffix-btn:hover { background: var(--color-accent-subtle); color: var(--color-accent); }
.input-suffix-btn svg { width: 16px; height: 16px; }

/* Concurrency Control */
.concurrency-control {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface-raised);
}

.concurrency-control input {
  width: 50px;
  text-align: center;
  border: none !important;
  background: transparent !important;
  font-weight: 600;
  font-size: 1rem;
  padding: 10px 4px !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  -moz-appearance: textfield;
}

.concurrency-control input::-webkit-outer-spin-button,
.concurrency-control input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.concurrency-btn {
  width: 36px;
  height: 38px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.concurrency-btn:hover { background: var(--color-accent-subtle); color: var(--color-accent); }
.concurrency-btn svg { width: 16px; height: 16px; }

/* ---- Task List ---- */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-item {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--transition-smooth);
  animation: fadeSlideIn 0.4s ease;
  box-shadow: var(--shadow-sm);
}

.task-item:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.task-item.executing {
  border-color: rgba(167, 139, 250, 0.4);
  box-shadow: 0 0 16px rgba(167, 139, 250, 0.1);
  background: linear-gradient(135deg, rgba(124,127,246,0.03) 0%, rgba(167,139,250,0.02) 50%, rgba(249,168,212,0.01) 100%);
  animation: executingPulse 3s ease-in-out infinite;
}

@keyframes executingPulse {
  0%, 100% {
    box-shadow: 0 0 12px rgba(167, 139, 250, 0.08);
    border-color: rgba(167, 139, 250, 0.35);
  }
  50% {
    box-shadow: 0 0 22px rgba(167, 139, 250, 0.18);
    border-color: rgba(167, 139, 250, 0.55);
  }
}

.task-item-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
}

.task-index {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-muted);
  min-width: 24px;
}

.task-target-input {
  flex: 0 0 auto;
  width: 120px;
  background: none;
  border: none;
  color: var(--color-text-primary);
  font-size: 0.9rem;
  font-family: var(--font-mono);
  outline: none;
  padding: 4px 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-target-input::placeholder { color: var(--color-text-muted); font-family: var(--font-sans); }
.task-target-input:focus { color: var(--color-accent); }

.task-runid-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  /* 移除宽度限制，让标签自适应内容以显示完整进度信息 */
  transition: all 0.15s ease;
}
.task-runid-label:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: transparent;
}

/* RunID 状态样式 */
.task-runid-label.runid-running {
  color: var(--color-running);
  border-color: var(--color-running);
}
.task-runid-label.runid-completed {
  color: var(--color-success);
  border-color: var(--color-success);
}
.task-runid-label.runid-failed {
  color: var(--color-danger);
  border-color: var(--color-danger);
}
.task-runid-label.runid-unknown {
  color: var(--color-warning);
  border-color: var(--color-warning);
}
.task-runid-label.runid-pending {
  color: var(--color-text-muted);
  border-color: var(--color-border);
}
.task-runid-label.runid-error {
  color: var(--color-danger);
  border-color: var(--color-danger);
}

/* 任务卡片内续做按钮 */
.task-item-continue-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.task-item-continue-btn svg {
  width: 12px;
  height: 12px;
}

.task-item-continue-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: rgba(99, 102, 241, 0.08);
}

/* 失败状态时续做按钮高亮 */
.task-item.failed .task-item-continue-btn,
.task-status-badge.failed ~ .task-item-header .task-item-continue-btn {
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.task-item.failed .task-item-continue-btn:hover {
  background: rgba(239, 68, 68, 0.08);
}

.task-status-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.task-status-badge.pending { background: var(--color-border); color: var(--color-text-muted); }
.task-status-badge.running { background: var(--color-running-subtle); color: var(--color-running); }
.task-status-badge.completed { background: var(--color-success-subtle); color: var(--color-success); }
.task-status-badge.failed { background: var(--color-danger-subtle); color: var(--color-danger); }
.task-status-badge.failed[data-error] { position: relative; cursor: help; }
.task-status-badge.failed[data-error]:hover::after {
  content: "失败原因: " attr(data-error);
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 5px;
  background: #ff4444;
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  z-index: 10000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  max-width: 300px;
  word-wrap: break-word;
  pointer-events: none;
  white-space: normal;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-dot.running { animation: pulse-dot 1s infinite; }

.task-item-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.task-item-btn {
  width: 30px;
  height: 30px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.task-item-btn:hover { background: var(--color-border); color: var(--color-text-primary); }
.task-item-btn.danger:hover { background: var(--color-danger-subtle); color: var(--color-danger); }
.task-item-btn svg { width: 15px; height: 15px; }

.task-item-detail {
  display: none;
  padding: 0 16px 14px 52px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.task-item.expanded .task-item-detail { display: block; }

.task-runid {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-accent);
  margin-bottom: 4px;
}

/* ---- Progress Overview ---- */
.progress-overview {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.progress-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 14px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-item.running .stat-value { color: var(--color-running); }
.stat-item.success .stat-value { color: var(--color-success); }
.stat-item.danger .stat-value { color: var(--color-danger); }
.stat-item.current .stat-value {
  color: #f59e0b;
  font-size: 1.6rem;
  font-weight: 800;
}

.progress-bar-wrap {
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--brand-gradient);
  border-radius: 2px;
  transition: width 0.8s var(--transition-smooth);
  width: 0%;
  box-shadow: 0 0 8px rgba(124, 127, 246, 0.25);
}

/* ---- Empty State ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-muted);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; color: var(--color-text-secondary); }
.empty-state p { font-size: 0.85rem; }

/* ---- Log Viewport ---- */
.log-viewport {
  background: rgba(14, 17, 23, 0.7);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  max-height: 400px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
  padding: 16px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.08);
}

.log-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: var(--color-text-muted);
  gap: 8px;
}

.log-placeholder svg { width: 32px; height: 32px; opacity: 0.3; }

.log-entry {
  padding: 4px 0;
  display: flex;
  gap: 8px;
  animation: logIn 0.2s ease;
}

@keyframes logIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

.log-time {
  color: var(--color-text-muted);
  flex-shrink: 0;
  font-size: 0.75rem;
}

.log-msg { word-break: break-all; }

.log-entry.info .log-msg { color: var(--color-text-secondary); }
.log-entry.success .log-msg { color: var(--color-success); }
.log-entry.error .log-msg { color: var(--color-danger); }
.log-entry.warning .log-msg { color: var(--color-warning); }

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

/* ---- Path Results ---- */
.path-results {
  margin-top: 12px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.path-results-header {
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border);
}

.path-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-bottom: 1px solid var(--color-border);
}

.path-result-item:last-child { border-bottom: none; }
.path-result-item:hover { background: var(--color-accent-subtle); }

.path-result-name { font-family: var(--font-mono); font-size: 0.8rem; }
.path-result-meta { font-size: 0.7rem; color: var(--color-text-muted); }

/* ---- Toast ---- */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: rgba(27, 31, 43, 0.95);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  font-weight: 500;
  pointer-events: auto;
  animation: toastIn 0.5s var(--transition-spring);
  min-width: 280px;
  max-width: 420px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.toast.removing { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(100%) scale(0.95); }
}

.toast-icon { width: 20px; height: 20px; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--color-success); }
.toast.error .toast-icon { color: var(--color-danger); }
.toast.warning .toast-icon { color: var(--color-warning); }
.toast.info .toast-icon { color: var(--color-info); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-dialog {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 440px;
  width: 90%;
  text-align: center;
  animation: modalIn 0.4s var(--transition-spring);
  box-shadow: var(--shadow-lg);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-icon { margin-bottom: 12px; }
.modal-icon svg { width: 40px; height: 40px; }

.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.modal-body { color: var(--color-text-secondary); font-size: 0.875rem; margin-bottom: 20px; line-height: 1.5; }

.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* ---- Loading spinner ---- */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ========================================
   结果页面 — 树形浏览 + 详情面板
   ======================================== */

.results-layout {
  display: flex;
  gap: 0;
  height: calc(100vh - var(--topbar-height) - 48px);
  max-height: calc(100vh - var(--topbar-height) - 48px);
}

/* 左侧树面板 */
.results-tree-panel {
  width: 300px;
  min-width: 280px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-right: none;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

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

.results-tree-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.results-tree {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
}

.results-tree .empty-state {
  padding: 32px 16px;
}

.results-tree .empty-state svg { width: 36px; height: 36px; }
.results-tree .empty-state h3 { font-size: 0.875rem; }
.results-tree .empty-state p { font-size: 0.75rem; }

/* 树节点 */
.tree-node { user-select: none; }

.tree-node-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.85rem;
}

.tree-node-header:hover {
  background: var(--color-accent-subtle);
}

.tree-node-header.selected {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
}

.tree-node-header.selected .tree-node-name {
  color: var(--color-accent);
}

/* 展开/折叠箭头 */
.tree-arrow {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast);
  color: var(--color-text-muted);
}

.tree-arrow svg { width: 12px; height: 12px; }

.tree-node.expanded > .tree-node-header .tree-arrow {
  transform: rotate(90deg);
}

.tree-node.leaf > .tree-node-header .tree-arrow {
  visibility: hidden;
}

/* 节点图标 */
.tree-node-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tree-node-icon svg { width: 14px; height: 14px; }

.tree-node-icon.category { color: var(--color-accent); }
.tree-node-icon.sub-category { color: var(--color-info); }
.tree-node-icon.user { color: var(--color-warning); }
.tree-node-icon.data-item { color: var(--color-success); }

/* 节点名称 */
.tree-node-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text-primary);
}

/* runId 标签（数据项名称后面） */
.tree-node-runid {
  font-size: 0.6rem;
  font-family: var(--font-mono, 'SF Mono', 'Consolas', monospace);
  color: var(--color-text-muted);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0px 5px;
  margin-left: 6px;
  flex-shrink: 0;
  cursor: pointer;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.tree-node-runid:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
}

/* 节点状态标记 */
.tree-node-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}

.tree-node-badge.pending { background: var(--color-border); color: var(--color-text-muted); }
.tree-node-badge.running { background: var(--color-running-subtle); color: var(--color-running); }
.tree-node-badge.completed { background: var(--color-success-subtle); color: var(--color-success); }
.tree-node-badge.failed { background: var(--color-danger-subtle); color: var(--color-danger); }

/* 子节点容器 */
.tree-children {
  display: none;
  padding-left: 18px;
}

.tree-node.expanded > .tree-children {
  display: block;
}

/* 右侧详情面板 */
.results-detail-panel {
  flex: 1;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-left: none;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.results-detail-panel .empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.results-detail-panel .empty-state svg { width: 48px; height: 48px; opacity: 0.25; }
.results-detail-panel .empty-state h3 { font-size: 1rem; color: var(--color-text-secondary); }
.results-detail-panel .empty-state p { font-size: 0.8rem; color: var(--color-text-muted); }

.detail-content {
  padding: 16px;
  flex: 1;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.detail-header-main {
  flex: 1;
  min-width: 0;
}

.detail-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.btn-upload-public {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-upload-public svg {
  width: 14px;
  height: 14px;
}

.detail-breadcrumb {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.detail-breadcrumb span {
  color: var(--color-text-secondary);
}

.detail-breadcrumb .sep {
  color: var(--color-text-muted);
  margin: 0 2px;
}

/* 元信息 */
.detail-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.detail-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.detail-meta-item .label {
  color: var(--color-text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-meta-item .value {
  font-weight: 600;
  color: var(--color-text-primary);
}

.detail-meta-item .value.runId {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-accent);
}

/* 分区标题 */
.detail-section {
  margin-bottom: 24px;
}

.detail-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-section-title svg {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
}

/* 图片预览 */
.detail-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.detail-image-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.detail-image-card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-glow);
}

.detail-image-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  background: var(--color-bg);
}

.detail-image-card .image-label {
  padding: 8px 10px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-image-card .image-label .type-badge {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--color-accent-subtle);
  color: var(--color-accent);
}

.detail-empty-hint {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  padding: 8px 0;
}

/* 历史记录列表 */
.detail-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.82rem;
}

.history-item:hover {
  border-color: var(--color-border-hover);
  background: var(--color-surface-raised);
}

.history-item.selected {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
}

.history-item .history-date {
  font-weight: 600;
  color: var(--color-text-primary);
  min-width: 90px;
}

.history-item .history-status {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.history-item .history-status.pending { background: var(--color-border); color: var(--color-text-muted); }
.history-item .history-status.running { background: var(--color-running-subtle); color: var(--color-running); }
.history-item .history-status.completed { background: var(--color-success-subtle); color: var(--color-success); }
.history-item .history-status.failed { background: var(--color-danger-subtle); color: var(--color-danger); }

.history-item .history-runid {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.history-item .history-arrow {
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.history-item .history-arrow svg {
  width: 14px;
  height: 14px;
  transition: transform var(--transition-fast);
}

.history-item.selected .history-arrow svg {
  transform: rotate(90deg);
}

/* 图片大图预览模态框 */
.image-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: fadeIn 0.2s ease;
}

.image-preview-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.image-preview-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.image-preview-close:hover {
  background: rgba(255,255,255,0.2);
}

/* ========================================
   接口文档页面样式
   ======================================== */

/* 视图切换按钮栏 */
.view-toggle-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.view-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.view-toggle-btn:hover {
  background: var(--color-border);
  color: var(--color-text-primary);
  border-color: var(--color-border-hover);
}

.view-toggle-btn.active {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.view-toggle-btn .icon {
  font-size: 1.1rem;
}

/* 接口文档布局 */
.api-docs-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.api-docs-content {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.api-docs-sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.api-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 8px;
}

.api-list-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.api-list-item:hover {
  background: var(--color-accent-subtle);
  color: var(--color-text-primary);
}

.api-list-item.active {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  font-weight: 600;
}

.api-docs-detail {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--color-surface-raised);
}

.api-detail-content {
  max-width: 100%;
  margin: 0;
}

.api-detail-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
  color: var(--color-text-primary);
}

.api-endpoint {
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.api-endpoint code {
  color: var(--color-accent);
  font-weight: 600;
}

.api-description {
  margin-bottom: 24px;
  padding: 16px;
  background: var(--color-surface);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
}

.api-description strong {
  display: block;
  margin-bottom: 8px;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
}

.api-description p {
  color: var(--color-text-primary);
  line-height: 1.6;
}

.api-params-section,
.api-example-section,
.api-table-section {
  margin-bottom: 24px;
}

.api-params-section h3,
.api-example-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.params-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.params-table thead {
  background: var(--color-border);
}

.params-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.params-table td {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  font-size: 0.85rem;
  color: var(--color-text-primary);
}

/* 内联代码通用样式 */
.params-table code,
.api-table-section code {
  font-family: var(--font-mono);
  color: var(--color-accent);
  background: var(--color-accent-subtle);
  padding: 2px 6px;
  border-radius: 4px;
}

.params-table code { font-size: 0.8rem; }
.api-table-section code { font-size: 0.85rem; padding: 4px 8px; }

/* 代码示例 */
.api-example-section pre {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.api-example-section code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--color-text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* 表格分区 */
.api-table-section {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

/* 原始 MD 视图 */
.raw-md-view {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  background: var(--color-bg);
}

.raw-md-view .md-content {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--color-text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* ---- Responsive ---- */

/* ===== 移动端基础适配 (≤768px) ===== */
@media (max-width: 768px) {
  /* 基础字号放大，提升可读性 */
  html { font-size: 14px; }

  /* 移动端允许 body 滚动（某些子元素需要独立滚动） */
  body {
    overflow: hidden; /* 保持主布局不滚动 */
    -webkit-overflow-scrolling: touch;
  }

  /* ===== 侧边栏遮罩 ===== */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: fadeIn 0.25s ease;
  }

  .sidebar-overlay.active {
    display: block;
  }

  /* ===== 侧边栏 ===== */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    min-width: 260px;
    transform: translateX(-100%);
    z-index: 100;
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.4);
    transition: transform var(--transition-smooth);
  }

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

  /* 移动端菜单按钮 */
  .menu-toggle {
    display: flex;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
  }

  .menu-toggle svg { width: 22px; height: 22px; }

  /* ===== 顶部栏 ===== */
  .topbar {
    padding: 0 12px;
    gap: 8px;
    height: 52px;
    min-height: 52px;
  }

  .page-title {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-actions {
    gap: 2px;
    flex-shrink: 0;
  }

  /* 主按钮保留文字，图标按钮加大触摸区域 */
  .btn-primary {
    padding: 8px 14px;
    font-size: 0.8rem;
    gap: 4px;
    border-radius: var(--radius-sm);
  }

  .btn-primary svg { width: 16px; height: 16px; }

  .btn-icon {
    width: 40px;
    height: 40px;
  }

  .btn-icon svg { width: 20px; height: 20px; }

  .btn-secondary {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .btn-secondary svg { width: 16px; height: 16px; }

  /* 隐藏"续做失败"文字，只显示图标 */
  .btn-warning span { display: none; }
  .btn-warning {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
  }

  /* ===== 内容面板 ===== */
  .content-panels {
    padding: 12px;
    -webkit-overflow-scrolling: touch;
  }

  .panel-inner {
    padding: 20px 16px;
    border-radius: var(--radius-md);
    max-width: 100%;
  }

  /* 配置页和 API 文档 */
  #panel-config .panel-inner,
  #panel-api-documentation .panel-inner {
    max-width: 100%;
  }

  .panel-header {
    margin-bottom: 20px;
  }

  .panel-header h2 {
    font-size: 1.2rem;
  }

  .panel-desc {
    font-size: 0.8rem;
  }

  .panel-header-row {
    flex-wrap: wrap;
    gap: 10px;
  }

  .panel-actions {
    margin-top: 16px;
    padding-top: 14px;
  }

  /* ===== 表单 ===== */
  .form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .form-field.span-2 { grid-column: span 1; }

  .form-field label {
    font-size: 0.75rem;
    margin-bottom: 4px;
  }

  .form-field input,
  .form-field textarea,
  .form-field select {
    padding: 12px 14px;
    font-size: 1rem; /* 防止 iOS 缩放 */
    border-radius: var(--radius-sm);
  }

  .input-with-icon input { padding-left: 40px; }

  .input-with-icon svg {
    left: 14px;
    width: 18px;
    height: 18px;
  }

  .field-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .field-header .btn-secondary {
    font-size: 0.75rem;
    padding: 6px 12px;
  }

  .input-with-suffix input { padding-right: 44px; }

  .input-suffix-btn {
    right: 2px;
    width: 36px;
    height: 36px;
  }

  .concurrency-btn {
    width: 44px;
    height: 44px;
  }

  .concurrency-btn svg { width: 18px; height: 18px; }

  .concurrency-control input {
    width: 44px;
    font-size: 1.1rem;
    padding: 12px 4px !important;
  }

  /* ===== 分割线 ===== */
  .section-divider {
    margin: 20px 0;
  }

  /* ===== 进度概览 ===== */
  .progress-overview {
    padding: 14px;
    margin-bottom: 14px;
  }

  .progress-stats {
    gap: 12px;
    flex-wrap: wrap;
  }

  .stat-value {
    font-size: 1.1rem;
  }

  .stat-item.current .stat-value {
    font-size: 1.3rem;
  }

  .stat-label {
    font-size: 0.65rem;
  }

  /* ===== 任务列表 ===== */
  .task-list {
    gap: 8px;
  }

  .task-item {
    border-radius: var(--radius-sm);
  }

  .task-item-header {
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: nowrap;
  }

  .task-index {
    font-size: 0.7rem;
    min-width: 20px;
  }

  .task-target-input {
    width: 80px;
    font-size: 0.85rem;
  }

  .task-status-badge {
    font-size: 0.7rem;
    padding: 3px 8px;
  }

  .task-item-detail {
    padding: 0 12px 12px 40px;
    font-size: 0.75rem;
  }

  .task-runid-label {
    font-size: 0.65rem;
    padding: 2px 5px;
  }

  .task-item-btn {
    width: 34px;
    height: 34px;
  }

  .task-item-btn svg { width: 16px; height: 16px; }

  .task-item-continue-btn {
    padding: 4px 8px;
    font-size: 0.65rem;
  }

  .task-item-actions {
    gap: 2px;
  }

  /* ===== 日志 ===== */
  .log-viewport {
    max-height: 280px;
    font-size: 0.7rem;
    padding: 12px;
    border-radius: var(--radius-sm);
  }

  .log-placeholder {
    min-height: 140px;
  }

  .log-time {
    font-size: 0.65rem;
  }

  .log-actions {
    gap: 2px;
  }

  .btn-icon-sm {
    width: 36px;
    height: 36px;
  }

  .btn-icon-sm svg { width: 18px; height: 18px; }

  /* ===== 结果页 ===== */
  .results-layout {
    flex-direction: column;
    height: auto;
    max-height: none;
    gap: 0;
  }

  .results-tree-panel {
    width: 100%;
    min-width: 0;
    max-height: 40vh;
    min-height: 180px;
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  .results-tree-header {
    padding: 12px 14px 10px;
  }

  .results-tree-header h2 {
    font-size: 0.9rem;
  }

  .results-tree {
    padding: 6px;
  }

  .tree-node-header {
    padding: 8px 10px;
    font-size: 0.82rem;
    gap: 4px;
  }

  .tree-children {
    padding-left: 14px;
  }

  .tree-node-runid {
    font-size: 0.55rem;
    max-width: 120px;
  }

  .results-detail-panel {
    flex: 1;
    min-height: 300px;
    border-left: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
  }

  .detail-content {
    padding: 12px;
  }

  .detail-header {
    flex-direction: column;
    gap: 10px;
    padding-bottom: 12px;
    margin-bottom: 14px;
  }

  .detail-header h2 {
    font-size: 1.1rem;
  }

  .detail-meta {
    gap: 8px;
    margin-bottom: 16px;
  }

  .detail-meta-item {
    padding: 5px 10px;
    font-size: 0.75rem;
  }

  .detail-section {
    margin-bottom: 16px;
  }

  .detail-section-title {
    font-size: 0.78rem;
    margin-bottom: 8px;
  }

  .detail-images {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
  }

  .detail-image-card img {
    height: 100px;
  }

  .detail-image-card .image-label {
    padding: 6px 8px;
    font-size: 0.7rem;
  }

  /* 历史记录 */
  .history-item {
    padding: 8px 10px;
    gap: 8px;
    font-size: 0.75rem;
  }

  .history-item .history-date {
    font-size: 0.75rem;
    min-width: 70px;
  }

  .history-item .history-runid {
    font-size: 0.65rem;
    max-width: 120px;
  }

  /* ===== 接口文档页面 ===== */
  .view-toggle-bar {
    padding: 10px 12px;
    gap: 6px;
    flex-wrap: wrap;
  }

  .view-toggle-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
    gap: 4px;
  }

  .view-toggle-btn .icon {
    font-size: 1rem;
  }

  .api-docs-content {
    flex-direction: column;
  }

  .api-docs-sidebar {
    width: 100%;
    min-width: 0;
    max-height: 40vh;
    min-height: 150px;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .api-list {
    padding: 8px 6px;
    gap: 1px;
  }

  .api-list-item {
    padding: 10px 12px;
    font-size: 0.82rem;
  }

  .api-docs-detail {
    padding: 14px;
  }

  .api-detail-content h2 {
    font-size: 1.2rem;
    margin-bottom: 14px;
  }

  .api-endpoint {
    padding: 10px 12px;
    font-size: 0.78rem;
    gap: 4px;
  }

  .api-description {
    padding: 12px;
    margin-bottom: 16px;
  }

  .params-table th,
  .params-table td {
    padding: 8px 10px;
    font-size: 0.75rem;
  }

  .api-example-section pre {
    padding: 12px;
    max-height: 300px;
  }

  .api-example-section code {
    font-size: 0.75rem;
  }

  .raw-md-view {
    padding: 14px;
  }

  .raw-md-view .md-content {
    font-size: 0.75rem;
  }

  /* ===== 空状态 ===== */
  .empty-state {
    padding: 32px 16px;
  }

  .empty-state svg {
    width: 36px;
    height: 36px;
    margin-bottom: 12px;
  }

  .empty-state h3 {
    font-size: 0.9rem;
  }

  .empty-state p {
    font-size: 0.78rem;
  }

  /* ===== Toast ===== */
  #toast-container {
    left: 10px;
    right: 10px;
    top: 10px;
  }

  .toast {
    min-width: auto;
    max-width: none;
    padding: 12px 16px;
    font-size: 0.8rem;
  }

  /* ===== 模态框 ===== */
  .modal-dialog {
    padding: 24px 20px;
    width: 92%;
    max-width: 380px;
    border-radius: var(--radius-md);
  }

  .modal-title {
    font-size: 1rem;
  }

  .modal-body {
    font-size: 0.82rem;
  }

  /* ===== 图片预览 ===== */
  .image-preview-overlay img {
    max-width: 95vw;
    max-height: 85vh;
  }

  .image-preview-close {
    width: 36px;
    height: 36px;
    top: 10px;
    right: 10px;
  }
}

/* ===== 小屏手机 (≤480px) ===== */
@media (max-width: 480px) {
  html { font-size: 13px; }

  .sidebar {
    width: 85vw;
    min-width: 85vw;
    max-width: 300px;
  }

  .topbar {
    padding: 0 8px;
    gap: 4px;
    height: 48px;
    min-height: 48px;
  }

  .page-title { font-size: 0.9rem; }

  .topbar-actions { gap: 1px; }

  /* 执行按钮保留文字 */
  .btn-primary {
    padding: 7px 12px;
    font-size: 0.75rem;
  }

  .btn-primary svg { width: 14px; height: 14px; }

  .btn-icon {
    width: 36px;
    height: 36px;
  }

  .btn-icon svg { width: 18px; height: 18px; }

  .btn-secondary {
    padding: 7px 10px;
    font-size: 0.75rem;
  }

  .btn-secondary svg { width: 14px; height: 14px; }

  .content-panels { padding: 8px; }

  .panel-inner {
    padding: 16px 12px;
    border-radius: var(--radius-sm);
  }

  .panel-header h2 { font-size: 1.1rem; }

  .form-field input,
  .form-field textarea {
    font-size: 0.95rem;
    padding: 10px 12px;
  }

  .task-target-input {
    width: 60px;
    font-size: 0.8rem;
  }

  .task-index {
    min-width: 18px;
    font-size: 0.65rem;
  }

  .task-item-header {
    padding: 8px 10px;
    gap: 6px;
  }

  .task-item-detail {
    padding: 0 8px 10px 32px;
  }

  .task-item-btn {
    width: 30px;
    height: 30px;
  }

  .task-item-btn svg { width: 14px; height: 14px; }

  .task-status-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
  }

  .progress-stats { gap: 8px; }
  .stat-value { font-size: 1rem; }
  .stat-item.current .stat-value { font-size: 1.15rem; }

  .log-viewport {
    max-height: 240px;
    font-size: 0.65rem;
  }

  .results-tree-panel {
    max-height: 35vh;
    min-height: 150px;
  }

  .results-tree-header {
    padding: 10px 12px 8px;
  }

  .tree-node-header {
    padding: 7px 8px;
    font-size: 0.78rem;
  }

  .results-detail-panel {
    min-height: 250px;
  }

  .detail-content {
    padding: 10px;
  }

  .detail-header h2 {
    font-size: 1rem;
  }

  .detail-images {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }

  .detail-image-card img {
    height: 80px;
  }

  .history-item .history-date {
    min-width: 60px;
    font-size: 0.7rem;
  }

  .api-docs-sidebar {
    max-height: 35vh;
    min-height: 130px;
  }

  .api-list-item {
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  .view-toggle-btn {
    padding: 5px 8px;
    font-size: 0.7rem;
  }

  .modal-dialog {
    padding: 20px 16px;
    width: 94%;
  }

  #toast-container {
    left: 6px;
    right: 6px;
    top: 6px;
  }

  .toast {
    padding: 10px 14px;
    font-size: 0.75rem;
    gap: 8px;
  }

  .toast-icon {
    width: 18px;
    height: 18px;
  }
}

/* ===== 横屏手机 (高度较小) ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar {
    height: 44px;
    min-height: 44px;
  }

  .results-layout {
    flex-direction: row;
    height: calc(100vh - 44px - 16px);
    max-height: calc(100vh - 44px - 16px);
  }

  .results-tree-panel {
    width: 45%;
    max-height: none;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    border-bottom: none;
    border-right: none;
  }

  .results-detail-panel {
    width: 55%;
    min-height: 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    border-left: none;
  }

  .log-viewport {
    max-height: 160px;
  }

  .panel-inner {
    padding: 14px 16px;
  }
}
