/*
  Engineering UI theme (Simulink/PSCAD-like)
  - Apply by setting <body class="theme-engineering">
  - Overrides variables + key components to look clean and tool-like
*/

body.theme-engineering {
  /* Palette: neutral greys + MATLAB-ish blue */
  --bg-dark: #eef1f4;
  --bg-panel: #ffffff;
  --bg-card: #ffffff;

  --color-primary: #0072BD;
  --color-secondary: #005A9E;
  --color-tertiary: #EDB120;

  --color-success: #2E7D32;
  --color-warning: #B26A00;
  --color-danger: #C62828;

  --color-text: #111827;
  --color-text-secondary: #475569;
  --color-border: #cbd5e1;
  --color-grid: rgba(148, 163, 184, 0.25);

  --shadow-glow: 0 8px 18px rgba(2, 6, 23, 0.12);
  --font-main: 'Segoe UI', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
}

/* Background: reduce “sci-fi grid”, keep subtle workspace texture */
body.theme-engineering::before {
  background-image:
    radial-gradient(circle at 18% 30%, rgba(0, 114, 189, 0.08) 0%, transparent 55%),
    radial-gradient(circle at 82% 70%, rgba(0, 90, 158, 0.06) 0%, transparent 60%),
    repeating-linear-gradient(0deg, transparent, transparent 27px, var(--color-grid) 27px, var(--color-grid) 28px),
    repeating-linear-gradient(90deg, transparent, transparent 27px, var(--color-grid) 27px, var(--color-grid) 28px);
  background-size: 100% 100%, 100% 100%, 28px 28px, 28px 28px;
  opacity: 1;
}

/* Top bar: looks like desktop app title bar */
body.theme-engineering .top-bar {
  background: linear-gradient(to bottom, rgba(255,255,255,0.96), rgba(245,247,250,0.96));
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 2px 10px rgba(2, 6, 23, 0.08);
}

body.theme-engineering .app-logo {
  background: rgba(0, 114, 189, 0.08);
  border: 1px solid rgba(0, 114, 189, 0.25);
}

body.theme-engineering .app-logo::before {
  opacity: 0.2;
}

body.theme-engineering .app-name {
  -webkit-text-fill-color: unset;
  color: var(--color-text);
  background: none;
  letter-spacing: 0.5px;
  text-transform: none;
}

body.theme-engineering .app-name-btn {
  background: linear-gradient(120deg, rgba(0, 114, 189, 0.12), rgba(0, 90, 158, 0.08));
  border-color: rgba(0, 114, 189, 0.3);
  box-shadow: 0 2px 8px rgba(2, 6, 23, 0.12);
}

body.theme-engineering .app-name-btn::before {
  background: rgba(0, 114, 189, 0.75);
  box-shadow: 0 0 8px rgba(0, 114, 189, 0.35);
}

body.theme-engineering .app-name-btn::after {
  background: linear-gradient(90deg, rgba(0, 114, 189, 0), rgba(0, 114, 189, 0.55), rgba(0, 114, 189, 0));
  opacity: 0.6;
}

body.theme-engineering .status-indicator::before {
  animation: none;
}

/* Workflow tab strip: flatter + more “tool tabs” */
body.theme-engineering .sidebar {
  background: linear-gradient(to bottom, rgba(255,255,255,0.96), rgba(245,247,250,0.96));
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 2px 8px rgba(2, 6, 23, 0.06);
}

body.theme-engineering .sidebar::before,
body.theme-engineering .sidebar::after {
  display: none;
}

body.theme-engineering .workflow-title {
  color: var(--color-text-secondary);
}

body.theme-engineering .workflow-steps.workflow-tabs {
  border-bottom: 1px solid rgba(203, 213, 225, 0.9);
}

body.theme-engineering .workflow-steps.workflow-tabs .step-item {
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(203, 213, 225, 0.95);
  box-shadow: 0 2px 6px rgba(2, 6, 23, 0.08);
}

body.theme-engineering .workflow-steps.workflow-tabs .step-item:hover {
  background: rgba(255,255,255,1);
  box-shadow: 0 8px 18px rgba(2, 6, 23, 0.12);
}

body.theme-engineering .workflow-steps.workflow-tabs .step-item.active {
  background: linear-gradient(to bottom, rgba(0, 114, 189, 0.12), rgba(255,255,255,1));
  border-color: rgba(0, 114, 189, 0.35);
}

body.theme-engineering .workflow-steps.workflow-tabs .step-item.active::after {
  box-shadow: 0 0 0 rgba(0,0,0,0);
}

body.theme-engineering .workflow-steps.workflow-tabs .step-title {
  color: var(--color-text);
}

body.theme-engineering .workflow-steps.workflow-tabs .step-item.completed {
  background: rgba(46, 125, 50, 0.06);
  border-color: rgba(46, 125, 50, 0.25);
}

/* Main content spacing */
body.theme-engineering .main-content {
  padding: 18px;
  gap: 18px;
}

/* Workflow header */
body.theme-engineering .workflow-header {
  background: rgba(255,255,255,0.95);
  border: 1px solid rgba(203, 213, 225, 0.95);
  box-shadow: 0 8px 18px rgba(2, 6, 23, 0.08);
}

body.theme-engineering .workflow-step-pill {
  background: rgba(0, 114, 189, 0.08);
  border-color: rgba(0, 114, 189, 0.20);
  color: var(--color-text);
}

body.theme-engineering .workflow-step-title {
  color: var(--color-text);
}

body.theme-engineering .workflow-step-desc {
  color: var(--color-text-secondary);
}

/* Persistent panel compact */
body.theme-engineering .persistent-panel {
  min-width: 260px;
}

body.theme-engineering .dock-bar {
  padding: 6px 8px;
}

body.theme-engineering .panel-tabs {
  border-bottom: 1px solid rgba(203, 213, 225, 0.9);
}

body.theme-engineering .panel-tab {
  padding: 10px 10px;
  font-size: 0.9rem;
}

body.theme-engineering .panel-item {
  padding: 10px;
}

body.theme-engineering .card-header {
  padding: 12px 14px;
}

body.theme-engineering .card-content {
  padding: 14px;
}

/* -------------------------
   Fix dark remnants in light mode
   ------------------------- */

/* Generic tab containers (step6 etc.) */
body.theme-engineering .tabs-container {
  background-color: #ffffff;
  border-color: rgba(203, 213, 225, 0.95);
}

body.theme-engineering .tabs-header {
  background-color: rgba(248, 250, 252, 1);
  border-bottom: 1px solid rgba(203, 213, 225, 0.9);
}

body.theme-engineering .tab-button {
  color: var(--color-text-secondary);
}

body.theme-engineering .tab-button.active {
  color: var(--color-primary);
}

body.theme-engineering .tab-content {
  background: #ffffff;
}

/* KaTeX: text was hard-coded to light gray */
body.theme-engineering .katex {
  color: var(--color-text);
}

body.theme-engineering .katex-display {
  background: rgba(248, 250, 252, 1);
  border: 1px solid rgba(203, 213, 225, 0.9);
}

/* Note boxes */
body.theme-engineering .note-box {
  background-color: rgba(248, 250, 252, 1);
  border-left-color: rgba(0, 114, 189, 1);
  border: 1px solid rgba(203, 213, 225, 0.9);
}

body.theme-engineering .note-title {
  color: var(--color-text);
}

body.theme-engineering .note-content {
  color: var(--color-text-secondary);
}

/* Topology containers */
body.theme-engineering .topology-container,
body.theme-engineering .topology-editor {
  background-color: #ffffff;
  border: 1px solid rgba(203, 213, 225, 0.9);
}

body.theme-engineering .btn-tool.active {
  background-color: rgba(0, 114, 189, 0.10);
  color: var(--color-primary);
}

/* Chart overlays */
body.theme-engineering .chart-loading {
  background-color: rgba(255, 255, 255, 0.85);
  color: var(--color-text);
}

body.theme-engineering .complete-badge {
  background-color: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(203, 213, 225, 0.9);
}

body.theme-engineering .complete-badge.not-converged {
  background-color: rgba(255, 193, 7, 0.18);
  border-color: rgba(255, 193, 7, 0.55);
  color: #8a6d1f;
}

/* Small “info value” pill used in step5 topology info */
body.theme-engineering .info-value {
  background: rgba(0, 114, 189, 0.10);
}

/* Cards: flat, clean */
body.theme-engineering .card,
body.theme-engineering .card.full-height {
  background: var(--bg-card);
  border: 1px solid var(--color-border);
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.08);
}

body.theme-engineering .card::before {
  display: none;
}

body.theme-engineering .card:hover {
  border-color: rgba(0, 114, 189, 0.28);
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.12);
}

body.theme-engineering .card-header {
  background: linear-gradient(to bottom, rgba(248,250,252,1), rgba(255,255,255,1));
  border-bottom: 1px solid var(--color-border);
}

body.theme-engineering .card-header::after {
  display: none;
}

body.theme-engineering .card-title {
  color: var(--color-text);
  font-weight: 600;
}

body.theme-engineering .card-icon {
  background: rgba(0, 114, 189, 0.08);
  color: var(--color-primary);
}

/* Buttons: more “desktop software” */
body.theme-engineering .btn {
  border-radius: 6px;
  letter-spacing: 0;
}

body.theme-engineering .btn-primary {
  background: linear-gradient(180deg, rgba(0,114,189,1), rgba(0,90,158,1));
  color: #ffffff;
  border: 1px solid rgba(0, 90, 158, 0.35);
}

body.theme-engineering .btn-primary::before {
  display: none;
}

body.theme-engineering .btn-primary:hover {
  filter: none;
  box-shadow: 0 8px 18px rgba(0, 90, 158, 0.18);
}

body.theme-engineering .btn-outline {
  border-color: rgba(148, 163, 184, 0.9);
  color: var(--color-text);
}

body.theme-engineering .btn-outline:hover {
  background: rgba(2, 6, 23, 0.04);
  box-shadow: none;
}

body.theme-engineering .btn-success {
  background: linear-gradient(180deg, rgba(46,125,50,1), rgba(27,94,32,1));
  color: #ffffff;
  border: 1px solid rgba(27, 94, 32, 0.35);
}

body.theme-engineering .btn-danger {
  background: linear-gradient(180deg, rgba(198,40,40,1), rgba(183,28,28,1));
  color: #ffffff;
}

/* Inputs / selects */
body.theme-engineering .numeric-input,
body.theme-engineering .fancy-select {
  background-color: #ffffff;
  border-color: rgba(203, 213, 225, 0.95);
  color: var(--color-text);
}

body.theme-engineering .numeric-input:focus,
body.theme-engineering .fancy-select:focus {
  border-color: rgba(0, 114, 189, 0.55);
  box-shadow: 0 0 0 3px rgba(0, 114, 189, 0.12);
}

/* Tables */
body.theme-engineering .results-table th {
  background-color: rgba(0, 114, 189, 0.08);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}

body.theme-engineering .results-table td {
  border-bottom: 1px solid rgba(203, 213, 225, 0.7);
}

body.theme-engineering .results-table tr:hover {
  background-color: rgba(2, 6, 23, 0.03);
}

/* Code blocks / logs */
body.theme-engineering .code-block {
  background-color: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(203, 213, 225, 0.9);
  color: #0f172a;
}

/* Step5 中间结果面板（避免默认深色方案在浅色主题里突兀） */
body.theme-engineering .iteration-results-panel {
  background-color: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(203, 213, 225, 0.9);
  color: #0f172a;
}

/* Step5: 完成提示与迭代列表在白底主题下更清爽 */
body.theme-engineering #complete-badge {
  background-color: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(203, 213, 225, 0.9);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.10);
  color: var(--color-text);
}

body.theme-engineering #complete-badge.not-converged {
  background-color: rgba(255, 193, 7, 0.18);
  border-color: rgba(255, 193, 7, 0.55);
  color: #8a6d1f;
}

body.theme-engineering .iteration-list-empty {
  color: var(--color-text-secondary);
}

body.theme-engineering .iteration-link {
  background: rgba(255, 255, 255, 1);
  border: 1px solid rgba(203, 213, 225, 0.9);
  color: var(--color-text);
}

body.theme-engineering .iteration-link:hover {
  border-color: rgba(0, 114, 189, 0.35);
  background: rgba(248, 250, 252, 1);
}

body.theme-engineering .iteration-item th,
body.theme-engineering .final-result th {
  background-color: rgba(0, 114, 189, 0.08);
  color: #0f172a;
  border-color: rgba(203, 213, 225, 0.9);
}

body.theme-engineering .iteration-item td,
body.theme-engineering .final-result td {
  border-color: rgba(203, 213, 225, 0.8);
}

body.theme-engineering .iteration-item tr:nth-child(odd),
body.theme-engineering .final-result tr:nth-child(odd) {
  background-color: rgba(2, 6, 23, 0.02);
}

body.theme-engineering .final-result blockquote {
  background-color: rgba(2, 6, 23, 0.03);
  border-left-color: rgba(0, 114, 189, 0.45);
}

/* Charts */
body.theme-engineering .chart-container {
  background: #ffffff;
  border: 1px solid rgba(203, 213, 225, 0.9);
  box-shadow: inset 0 0 0 rgba(0,0,0,0);
}

body.theme-engineering .chart-container::before {
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.15) 1px, transparent 1px);
}

/* Step6 可视化分析：控制条/输入在浅色主题下更清爽 */
body.theme-engineering #visualization .chart-controls {
  background: rgba(248, 250, 252, 0.92);
  border-bottom: 1px solid rgba(203, 213, 225, 0.9);
}

body.theme-engineering #visualization .chart-nav-btn,
body.theme-engineering #visualization .view-btn,
body.theme-engineering #visualization .search-btn {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(203, 213, 225, 0.95);
  color: var(--color-text);
}

body.theme-engineering #visualization .node-search-input {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(203, 213, 225, 0.95);
  color: var(--color-text);
}

/* Right panel tabs */
body.theme-engineering .persistent-panel {
  background-color: rgba(255,255,255,0.92);
  border-left: 1px solid var(--color-border);
}

body.theme-engineering .panel-tabs {
  background: rgba(248,250,252,1);
}

body.theme-engineering .panel-tab {
  color: var(--color-text-secondary);
}

body.theme-engineering .panel-tab.active {
  color: var(--color-primary);
}

/* Dock bar */
body.theme-engineering .dock-bar {
  background: rgba(248, 250, 252, 1);
  border-bottom: 1px solid var(--color-border);
}

body.theme-engineering .dock-btn {
  background: rgba(255,255,255,1);
  border-color: rgba(203, 213, 225, 0.95);
  color: var(--color-text-secondary);
}

body.theme-engineering .dock-btn:hover {
  background: rgba(2, 6, 23, 0.03);
  border-color: rgba(0, 114, 189, 0.35);
  color: var(--color-text);
}

body.theme-engineering .dock-btn.active {
  border-color: rgba(0, 114, 189, 0.45);
  box-shadow: 0 0 0 3px rgba(0, 114, 189, 0.10);
  color: var(--color-primary);
}

/* Theme toggle button in top bar */
body.theme-engineering .theme-toggle.btn-outline {
  border-color: rgba(148, 163, 184, 0.9);
  color: var(--color-text);
}

/* Title area guide button (使用说明) */
body.theme-engineering .guide-button {
  color: var(--color-text);
  border: 1px solid rgba(203, 213, 225, 0.95);
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 6px;
  padding: 4px 10px;
}

body.theme-engineering .guide-button:hover {
  background-color: rgba(2, 6, 23, 0.04);
}

body.theme-engineering .guide-gate-cta .guide-gate-experiment-btn {
  color: #0b3558;
  border-color: rgba(0, 114, 189, 0.45);
  background: linear-gradient(180deg, rgba(255,255,255,1), rgba(230,243,252,1));
  box-shadow: 0 6px 14px rgba(2, 6, 23, 0.08);
}

body.theme-engineering .guide-gate-cta .guide-gate-experiment-btn:hover:not(:disabled) {
  color: #082a45;
  border-color: rgba(0, 114, 189, 0.62);
  background: linear-gradient(180deg, rgba(255,255,255,1), rgba(214,236,250,1));
}

body.theme-engineering .guide-gate-cta .guide-gate-experiment-btn:disabled,
body.theme-engineering .guide-gate-cta .guide-gate-experiment-btn[aria-disabled="true"] {
  color: #0b3558;
  border-color: rgba(0, 114, 189, 0.42);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(232,242,249,0.98));
  opacity: 1;
}

body.theme-engineering .tool-window-hint {
  border-color: rgba(0, 114, 189, 0.20);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(243,247,250,0.98));
  box-shadow: 0 14px 28px rgba(2, 6, 23, 0.12);
}

body.theme-engineering .tool-window-hint::before {
  background: rgba(255,255,255,0.98);
  border-left-color: rgba(0, 114, 189, 0.20);
  border-top-color: rgba(0, 114, 189, 0.20);
}

body.theme-engineering .tool-window-hint-text {
  color: var(--color-text);
}

body.theme-engineering .tool-window-hint-text strong {
  color: var(--color-primary);
}

body.theme-engineering .tool-window-hint-close {
  background: rgba(2, 6, 23, 0.05);
  color: var(--color-text);
}

body.theme-engineering .tool-window-hint-close:hover {
  background: rgba(2, 6, 23, 0.09);
}

/* -------------------------
   Remaining light-mode fixes (user-reported)
   - AI assistant bubbles
   - Step1 topology description
   - Step4 algorithm selection + inline editable code
   - Step6 status overview
   - AI report bubbles/code blocks
   ------------------------- */

/* AI assistant: chat bubbles (chat.css uses !important for dark gradients) */
body.theme-engineering .message.assistant .message-content {
  background: rgba(255, 255, 255, 0.98) !important;
  color: var(--color-text) !important;
  border: 1px solid rgba(203, 213, 225, 0.95) !important;
  border-left: 3px solid rgba(0, 114, 189, 0.9) !important;
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.10) !important;
}

body.theme-engineering .message.user .message-content {
  background: rgba(248, 250, 252, 1) !important;
  color: var(--color-text) !important;
  border: 1px solid rgba(203, 213, 225, 0.95) !important;
  border-right: 3px solid rgba(0, 114, 189, 0.55) !important;
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.08) !important;
}

body.theme-engineering .message-content code {
  background-color: rgba(2, 6, 23, 0.05) !important;
  color: #0f172a !important;
  border: 1px solid rgba(203, 213, 225, 0.8);
}

/* AI assistant: character bubble (ai-character.css hardcodes white + text-shadow) */
body.theme-engineering .character-bubble {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(203, 213, 225, 0.95);
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.10);
}

body.theme-engineering .character-bubble:before {
  background: rgba(255, 255, 255, 0.98);
  box-shadow: -2px 2px 3px rgba(2, 6, 23, 0.06);
}

body.theme-engineering .character-bubble p {
  color: var(--color-text);
  text-shadow: none;
}

body.theme-engineering .highlight-keyword {
  color: var(--color-primary);
}

/* Step1: topology description panel contrast */
body.theme-engineering .topology-info {
  background: #ffffff;
  border-color: rgba(203, 213, 225, 0.95);
}

body.theme-engineering .topology-preview {
  background-color: rgba(248, 250, 252, 1);
}

body.theme-engineering .topology-description {
  background-color: #ffffff;
  color: var(--color-text);
}

body.theme-engineering .stat-item {
  background-color: rgba(248, 250, 252, 1);
  border: 1px solid rgba(203, 213, 225, 0.75);
}

body.theme-engineering .current-topology-info {
  background-color: rgba(248, 250, 252, 1);
  border: 1px solid rgba(203, 213, 225, 0.8);
}

/* Step4: algorithm selection cards */
body.theme-engineering #workflow-step4-content .algorithm-selection .selection-item {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(203, 213, 225, 0.95);
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.08);
}

body.theme-engineering #workflow-step4-content .algorithm-selection .selection-item:hover {
  box-shadow: 0 12px 22px rgba(2, 6, 23, 0.12);
}

body.theme-engineering #workflow-step4-content .algorithm-selection .selection-item.active {
  background: linear-gradient(180deg, rgba(0, 114, 189, 0.10), rgba(255, 255, 255, 1));
  border-color: rgba(0, 114, 189, 0.35);
  box-shadow: 0 0 0 3px rgba(0, 114, 189, 0.10);
}

body.theme-engineering #workflow-step4-content .selection-title {
  color: var(--color-text);
}

body.theme-engineering #workflow-step4-content .selection-description {
  color: var(--color-text-secondary);
}

/* Step4: inline <style> uses !important, so we must also use !important + higher specificity */
body.theme-engineering #workflow-step4-content pre {
  background-color: rgba(248, 250, 252, 1) !important;
  border: 1px solid rgba(203, 213, 225, 0.95) !important;
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.08) !important;
}

body.theme-engineering #workflow-step4-content pre code {
  color: #0f172a !important;
}

body.theme-engineering #workflow-step4-content .editable-code {
  background-color: rgba(0, 114, 189, 0.08) !important;
  border: 1px solid rgba(0, 114, 189, 0.28) !important;
  color: rgba(0, 90, 158, 1) !important;
}

body.theme-engineering #workflow-step4-content .editable-code:empty::before {
  color: rgba(71, 85, 105, 0.85) !important;
}

body.theme-engineering #workflow-step4-content .editable-code:focus {
  background-color: rgba(0, 114, 189, 0.12) !important;
  box-shadow: 0 0 0 3px rgba(0, 114, 189, 0.15) !important;
  border-color: rgba(0, 114, 189, 0.55) !important;
}

body.theme-engineering #workflow-step4-content .code-container-exercise::before {
  background-color: rgba(0, 114, 189, 0.12) !important;
  color: rgba(0, 90, 158, 1) !important;
  border: 1px solid rgba(0, 114, 189, 0.22) !important;
}

/* Step4: bottom code-group switch buttons (inline <style> uses !important) */
body.theme-engineering #workflow-step4-content .group-nav-btn {
  background: rgba(255, 255, 255, 0.98) !important;
  color: var(--color-text) !important;
  border: 1px solid rgba(203, 213, 225, 0.95) !important;
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.08) !important;
}

body.theme-engineering #workflow-step4-content .group-nav-btn:hover {
  background: rgba(2, 6, 23, 0.03) !important;
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.12) !important;
}

body.theme-engineering #workflow-step4-content .group-nav-btn::before {
  background: linear-gradient(to bottom, rgba(0, 114, 189, 0.95), rgba(0, 90, 158, 0.9)) !important;
}

body.theme-engineering #workflow-step4-content .group-nav-btn.active {
  background: linear-gradient(180deg, rgba(0, 114, 189, 0.14), rgba(255, 255, 255, 1)) !important;
  color: rgba(0, 90, 158, 1) !important;
  border-color: rgba(0, 114, 189, 0.35) !important;
  box-shadow: 0 0 0 3px rgba(0, 114, 189, 0.10), 0 10px 22px rgba(2, 6, 23, 0.10) !important;
}

/* Step6: status overview grid */
body.theme-engineering .status-item {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(203, 213, 225, 0.95);
}

body.theme-engineering .status-item::after {
  opacity: 0.25;
}

body.theme-engineering .status-item.highlight {
  background: rgba(0, 114, 189, 0.08);
  border-color: rgba(0, 114, 189, 0.28);
  animation: none;
  box-shadow: 0 0 0 3px rgba(0, 114, 189, 0.10);
}

body.theme-engineering .status-item.success {
  background-color: rgba(46, 125, 50, 0.08);
  border-color: rgba(46, 125, 50, 0.25);
}

body.theme-engineering .status-label {
  color: var(--color-text-secondary);
}

/* AI report: avoid dark code blocks + ensure bubble consistency */
body.theme-engineering .ai-report-header {
  background: rgba(248, 250, 252, 1);
  color: var(--color-text);
  border-bottom: 1px solid rgba(203, 213, 225, 0.95);
}

body.theme-engineering .ai-report-close {
  color: var(--color-text);
}

body.theme-engineering .ai-report-close:hover {
  background: rgba(2, 6, 23, 0.06);
}

body.theme-engineering .ai-report-content .message-content {
  background-color: rgba(255, 255, 255, 0.98);
  border-color: rgba(203, 213, 225, 0.95);
}

body.theme-engineering .ai-report-content pre {
  background-color: rgba(248, 250, 252, 1);
  border-color: rgba(203, 213, 225, 0.95);
}

body.theme-engineering .ai-report-content code {
  color: #0f172a;
}

body.theme-engineering .ai-report-title i {
  color: rgba(0, 114, 189, 1);
}

body.theme-engineering .ai-report-content .message-avatar {
  background-color: rgba(0, 114, 189, 0.10);
  color: rgba(0, 90, 158, 1);
  box-shadow: none;
}

body.theme-engineering .ai-report-content table th {
  background-color: rgba(2, 6, 23, 0.03);
  border-bottom-color: rgba(203, 213, 225, 0.95);
}

body.theme-engineering .ai-report-content tr:nth-child(even) {
  background-color: rgba(2, 6, 23, 0.02);
}

/* Step2/3: formulas (decorations.css + formulas.css add dark backgrounds with higher specificity) */
body.theme-engineering .formula {
  background-color: rgba(248, 250, 252, 1);
  border: 1px solid rgba(203, 213, 225, 0.95);
  border-left-color: rgba(0, 114, 189, 1);
  color: var(--color-text);
}

body.theme-engineering .formula::after {
  background: radial-gradient(circle at top right, rgba(0, 114, 189, 0.10), transparent 70%);
  animation: none;
}

body.theme-engineering .workflow-content .katex-display {
  background: rgba(248, 250, 252, 1);
  border: 1px solid rgba(203, 213, 225, 0.95);
  border-left: 3px solid rgba(0, 114, 189, 1);
}

body.theme-engineering .message-content .katex-display {
  background: rgba(248, 250, 252, 1);
  border: 1px solid rgba(203, 213, 225, 0.85);
}

/* Code snippet / selection items (data-display.css has dark gradients) */
body.theme-engineering .selection-item {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(203, 213, 225, 0.95);
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.08);
}

body.theme-engineering .selection-item:hover {
  box-shadow: 0 12px 22px rgba(2, 6, 23, 0.12);
}

body.theme-engineering .selection-item.active {
  background: linear-gradient(180deg, rgba(0, 114, 189, 0.10), rgba(255, 255, 255, 1));
  border-color: rgba(0, 114, 189, 0.35);
  box-shadow: 0 0 0 3px rgba(0, 114, 189, 0.10);
}

body.theme-engineering .selection-title {
  color: var(--color-text);
}

body.theme-engineering .selection-description {
  color: var(--color-text-secondary);
}

body.theme-engineering .selection-item i {
  color: rgba(71, 85, 105, 1);
}

body.theme-engineering .selection-item.active i {
  color: rgba(0, 114, 189, 1);
}

body.theme-engineering .metric-bar {
  background-color: rgba(203, 213, 225, 0.55);
}

/* Step6: AI report generate button should not look “dark” in light theme */
body.theme-engineering .btn-ai {
  background: linear-gradient(180deg, rgba(0, 114, 189, 0.10), rgba(0, 114, 189, 0.06));
  color: rgba(0, 90, 158, 1);
  border: 1px solid rgba(0, 114, 189, 0.28);
  box-shadow: none;
}

body.theme-engineering .btn-ai:hover {
  background: linear-gradient(180deg, rgba(0, 114, 189, 0.16), rgba(0, 114, 189, 0.10));
  box-shadow: 0 8px 18px rgba(0, 90, 158, 0.14);
}

body.theme-engineering .btn-ai:active {
  transform: translateY(0);
}

body.theme-engineering .btn-ai:disabled,
body.theme-engineering .btn-ai[disabled] {
  background: rgba(248, 250, 252, 1);
  color: rgba(100, 116, 139, 1);
  border-color: rgba(203, 213, 225, 0.95);
  box-shadow: none;
}

body.theme-engineering .btn-ai i {
  color: rgba(0, 90, 158, 1);
}

/* Global modals: view data / compare selected / report preview / report editor / AI assist */
body.theme-engineering .data-modal {
  background: rgba(2, 6, 23, 0.55);
}

body.theme-engineering .data-modal .modal-content,
body.theme-engineering .data-modal .data-modal-content {
  background: rgba(255, 255, 255, 0.98);
  color: var(--color-text);
  border: 1px solid rgba(203, 213, 225, 0.95);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
}

body.theme-engineering .data-modal .modal-header,
body.theme-engineering .data-modal .data-modal-header {
  background: rgba(248, 250, 252, 1);
  border-bottom: 1px solid rgba(203, 213, 225, 0.95);
}

body.theme-engineering .data-modal .modal-body,
body.theme-engineering .data-modal .data-modal-body {
  color: var(--color-text);
}

body.theme-engineering .data-modal .close-modal {
  color: rgba(71, 85, 105, 1);
}

body.theme-engineering .data-modal .close-modal:hover {
  background: rgba(2, 6, 23, 0.06);
}

body.theme-engineering .data-modal .modal-body th,
body.theme-engineering .data-modal .modal-body td {
  border-color: rgba(203, 213, 225, 0.95);
  color: var(--color-text);
}

body.theme-engineering .data-modal .modal-body th {
  background: rgba(2, 6, 23, 0.03);
}

/*
  Light-theme guardrails:
  ai-report.css contains global `!important` rules for `.modal-body table` / `.markdown-body table`
  that are tuned for dark theme. In engineering (light) theme we must override them explicitly.
*/
body.theme-engineering .data-modal .modal-body table,
body.theme-engineering .data-modal .data-modal-body table {
  color: var(--color-text) !important;
}

body.theme-engineering .data-modal .modal-body table tr,
body.theme-engineering .data-modal .data-modal-body table tr,
body.theme-engineering .data-modal .modal-body .markdown-body table tr,
body.theme-engineering .data-modal .data-modal-body .markdown-body table tr {
  color: var(--color-text) !important;
  background-color: transparent !important;
}

body.theme-engineering .data-modal .modal-body table tr:nth-child(odd),
body.theme-engineering .data-modal .data-modal-body table tr:nth-child(odd),
body.theme-engineering .data-modal .modal-body .markdown-body table tr:nth-child(odd),
body.theme-engineering .data-modal .data-modal-body .markdown-body table tr:nth-child(odd) {
  background-color: transparent !important;
}

body.theme-engineering .data-modal .modal-body table tr:nth-child(even),
body.theme-engineering .data-modal .data-modal-body table tr:nth-child(even),
body.theme-engineering .data-modal .modal-body .markdown-body table tr:nth-child(even),
body.theme-engineering .data-modal .data-modal-body .markdown-body table tr:nth-child(even) {
  background-color: rgba(2, 6, 23, 0.02) !important;
}

body.theme-engineering .data-modal .modal-body table td,
body.theme-engineering .data-modal .modal-body table th,
body.theme-engineering .data-modal .data-modal-body table td,
body.theme-engineering .data-modal .data-modal-body table th,
body.theme-engineering .data-modal .modal-body .markdown-body table td,
body.theme-engineering .data-modal .modal-body .markdown-body table th,
body.theme-engineering .data-modal .data-modal-body .markdown-body table td,
body.theme-engineering .data-modal .data-modal-body .markdown-body table th {
  color: var(--color-text) !important;
  border-color: rgba(203, 213, 225, 0.95) !important;
}

body.theme-engineering .data-modal .modal-body table th,
body.theme-engineering .data-modal .data-modal-body table th,
body.theme-engineering .data-modal .modal-body .markdown-body table th,
body.theme-engineering .data-modal .data-modal-body .markdown-body table th {
  background-color: rgba(2, 6, 23, 0.03) !important;
}

body.theme-engineering .data-modal .modal-body pre,
body.theme-engineering .data-modal .data-modal-body pre {
  background-color: rgba(2, 6, 23, 0.03) !important;
  color: rgba(15, 23, 42, 1) !important;
  border: 1px solid rgba(203, 213, 225, 0.95) !important;
}

body.theme-engineering .data-modal .modal-body code,
body.theme-engineering .data-modal .data-modal-body code {
  color: rgba(15, 23, 42, 1) !important;
}

body.theme-engineering .data-modal .preview-content {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(203, 213, 225, 0.95);
}

body.theme-engineering .data-modal .compare-table th {
  background: rgba(2, 6, 23, 0.03);
  color: var(--color-text);
}

body.theme-engineering .data-modal .compare-table td {
  color: var(--color-text);
}

/* View-data modal: topology + parameter blocks should not keep dark skins */
body.theme-engineering .data-modal .topology-info {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(203, 213, 225, 0.95);
  border-radius: 8px;
}

body.theme-engineering .data-modal .topology-name,
body.theme-engineering .data-modal .topology-nodes {
  color: var(--color-text);
}

body.theme-engineering .data-modal .parameters-section {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(203, 213, 225, 0.95);
}

body.theme-engineering .data-modal .parameter-item {
  background: rgba(2, 6, 23, 0.03);
  border: 1px solid rgba(203, 213, 225, 0.95);
}

body.theme-engineering .data-modal .parameter-name {
  color: rgba(0, 90, 158, 1);
}

body.theme-engineering .data-modal .parameter-value {
  background: rgba(0, 114, 189, 0.10);
  color: rgba(0, 90, 158, 1);
}

body.theme-engineering .data-modal .results-summary {
  color: var(--color-text);
}

body.theme-engineering .data-modal .record-time {
  color: rgba(71, 85, 105, 1);
}

/* Table zebra stripes in modals: override dark defaults */
body.theme-engineering .data-modal .modal-body tr:nth-child(even),
body.theme-engineering .data-modal .data-modal-body tr:nth-child(even) {
  background: rgba(2, 6, 23, 0.02);
}

/* “写作报告” button (report-ui-manager.js) */
body.theme-engineering .write-report-btn {
  background: rgba(0, 114, 189, 0.10);
  border: 1px solid rgba(0, 114, 189, 0.28);
  color: rgba(0, 90, 158, 1);
}

body.theme-engineering .write-report-btn:hover {
  background: rgba(0, 114, 189, 0.16);
  color: rgba(0, 90, 158, 1);
}

body.theme-engineering .write-report-btn:disabled {
  background: rgba(248, 250, 252, 1);
  border: 1px solid rgba(203, 213, 225, 0.95);
  color: rgba(100, 116, 139, 1);
}

/* AI assist report modal content area */
body.theme-engineering .ai-report-modal .ai-report-content {
  background: rgba(255, 255, 255, 1);
  color: var(--color-text);
}

/* AI assist modal (write-report): ensure typography/table/code match light theme */
body.theme-engineering .ai-report-modal .ai-report-content,
body.theme-engineering .ai-report-modal .ai-report-content * {
  color: var(--color-text) !important;
}

body.theme-engineering .ai-report-modal .ai-report-content.markdown-body {
  background-color: transparent !important;
}

body.theme-engineering .ai-report-modal .ai-report-content.markdown-body h1,
body.theme-engineering .ai-report-modal .ai-report-content.markdown-body h2,
body.theme-engineering .ai-report-modal .ai-report-content.markdown-body h3,
body.theme-engineering .ai-report-modal .ai-report-content.markdown-body h4 {
  color: rgba(0, 90, 158, 1) !important;
  border-bottom-color: rgba(203, 213, 225, 0.95) !important;
}

body.theme-engineering .ai-report-modal .ai-report-content.markdown-body p,
body.theme-engineering .ai-report-modal .ai-report-content.markdown-body li,
body.theme-engineering .ai-report-modal .ai-report-content.markdown-body ul,
body.theme-engineering .ai-report-modal .ai-report-content.markdown-body ol {
  color: var(--color-text) !important;
}

body.theme-engineering .ai-report-modal .ai-report-content.markdown-body strong {
  color: rgba(15, 23, 42, 1) !important;
}

body.theme-engineering .ai-report-modal .ai-report-content.markdown-body a {
  color: rgba(0, 90, 158, 1) !important;
}

body.theme-engineering .ai-report-modal .ai-report-content.markdown-body blockquote {
  color: rgba(71, 85, 105, 1) !important;
  border-left-color: rgba(203, 213, 225, 0.95) !important;
  background-color: rgba(2, 6, 23, 0.03) !important;
}

body.theme-engineering .ai-report-modal .ai-report-content table {
  color: var(--color-text) !important;
}

body.theme-engineering .ai-report-modal .ai-report-content table tr {
  color: var(--color-text) !important;
  background-color: transparent !important;
}

body.theme-engineering .ai-report-modal .ai-report-content table tr:nth-child(even) {
  background-color: rgba(2, 6, 23, 0.02) !important;
}

body.theme-engineering .ai-report-modal .ai-report-content table td,
body.theme-engineering .ai-report-modal .ai-report-content table th {
  color: var(--color-text) !important;
  border-color: rgba(203, 213, 225, 0.95) !important;
}

body.theme-engineering .ai-report-modal .ai-report-content table th {
  background-color: rgba(2, 6, 23, 0.03) !important;
}

body.theme-engineering .ai-report-modal .ai-report-content pre {
  background-color: rgba(2, 6, 23, 0.03) !important;
  color: rgba(15, 23, 42, 1) !important;
  border: 1px solid rgba(203, 213, 225, 0.95) !important;
}

body.theme-engineering .ai-report-modal .ai-report-content code {
  color: rgba(15, 23, 42, 1) !important;
}

body.theme-engineering .ai-report-modal .modal-footer {
  border-top-color: rgba(203, 213, 225, 0.95);
}

/* Report editor toolbar buttons (预览 / AI辅助 / 保存 / 历史) */
body.theme-engineering .report-editor-modal .editor-toolbar button {
  background: rgba(0, 114, 189, 0.10);
  border: 1px solid rgba(0, 114, 189, 0.25);
  color: rgba(0, 90, 158, 1);
  box-shadow: none;
}

body.theme-engineering .report-editor-modal .editor-toolbar button:hover {
  background: rgba(0, 114, 189, 0.16);
  color: rgba(0, 90, 158, 1);
}

body.theme-engineering .report-editor-modal .editor-toolbar .save-report-btn {
  background: rgba(46, 125, 50, 0.10);
  border-color: rgba(46, 125, 50, 0.25);
  color: rgba(18, 83, 43, 1);
}

body.theme-engineering .report-editor-modal .editor-toolbar .save-report-btn:hover {
  background: rgba(46, 125, 50, 0.16);
}

body.theme-engineering .report-editor-modal .editor-toolbar .ai-assist-btn {
  background: rgba(124, 77, 255, 0.10);
  border-color: rgba(124, 77, 255, 0.25);
  color: rgba(88, 62, 190, 1);
}

body.theme-engineering .report-editor-modal .editor-toolbar .ai-assist-btn:hover {
  background: rgba(124, 77, 255, 0.16);
  color: rgba(88, 62, 190, 1);
}

/* AI assist modal footer buttons */
body.theme-engineering .ai-report-modal .modal-footer button {
  background: rgba(0, 114, 189, 0.10);
  border: 1px solid rgba(0, 114, 189, 0.28);
  color: rgba(0, 90, 158, 1);
  box-shadow: none;
}

body.theme-engineering .ai-report-modal .modal-footer button:hover {
  background: rgba(0, 114, 189, 0.16);
  transform: none;
}

/* Topology floating tool window */
body.theme-engineering .topology-window {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(203, 213, 225, 0.95);
  box-shadow: 0 18px 46px rgba(2, 6, 23, 0.18);
}

body.theme-engineering .topology-window-header {
  background: rgba(248, 250, 252, 1);
  border-bottom-color: rgba(203, 213, 225, 0.95);
}

body.theme-engineering .topology-window-title {
  color: var(--color-text);
}

/* Workbench panels (Project Explorer + Output) */
body.theme-engineering .project-explorer {
  background: rgba(255, 255, 255, 0.92);
  border-right: 1px solid rgba(203, 213, 225, 0.95);
}

body.theme-engineering .project-header {
  background: rgba(248, 250, 252, 1);
  border-bottom: 1px solid rgba(203, 213, 225, 0.95);
}

body.theme-engineering .project-section-title {
  color: rgba(71, 85, 105, 1);
}

body.theme-engineering .tree-item {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(203, 213, 225, 0.95);
  color: var(--color-text);
}

body.theme-engineering .tree-item:hover {
  background: rgba(2, 6, 23, 0.03);
  border-color: rgba(0, 114, 189, 0.35);
}

body.theme-engineering .tree-badge {
  background: rgba(0, 114, 189, 0.10);
  border-color: rgba(0, 114, 189, 0.22);
  color: rgba(0, 90, 158, 1);
}

body.theme-engineering .output-panel {
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid rgba(203, 213, 225, 0.95);
}

body.theme-engineering .output-header {
  background: rgba(248, 250, 252, 1);
  border-bottom: 1px solid rgba(203, 213, 225, 0.95);
}

body.theme-engineering .output-resizer::after {
  background: rgba(0, 114, 189, 0.45);
}

body.theme-engineering .output-content {
  color: #0f172a;
}
