/* ============================================================
   A³Infra UI — Design System  ✨ XuLAB Edition
   ============================================================ */

/* ----- Theme Tokens (Dark Default) ----- */
:root {
  --bg: #0b0f19;
  --bg-surface: rgba(15, 23, 42, 0.75);
  --bg-elevated: rgba(30, 41, 59, 0.6);
  --bg-input: rgba(15, 23, 42, 0.6);
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(99, 102, 241, 0.18);
  --border-light: rgba(99, 102, 241, 0.08);
  --shadow: 0 8px 32px rgba(0,0,0,0.35);

  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: rgba(129, 140, 248, 0.12);
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);

  --sidebar-w: 240px;
  --statusbar-h: 32px;
  --radius: 14px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Fira Code", Consolas, monospace;
}

/* ----- Light Theme Overrides ----- */
[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-surface: rgba(255, 255, 255, 0.72);
  --bg-elevated: rgba(241, 245, 249, 0.6);
  --bg-input: rgba(255, 255, 255, 0.6);
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: rgba(99, 102, 241, 0.15);
  --border-light: rgba(99, 102, 241, 0.06);
  --shadow: 0 4px 24px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
}

/* ----- Reset & Base ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  height: 100vh;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ----- App Shell ----- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 1fr var(--statusbar-h);
  height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: var(--bg-surface);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  grid-row: 1;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.lab-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-gradient);
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
  object-fit: cover;
}
img.lab-logo {
  background: #fff;
  object-fit: contain;
  padding: 2px;
}
.brand-text h2 {
  font-size: 16px;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
  margin: 0;
}
.brand-text span {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  position: relative;
  overflow: hidden;
}
.nav-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent-gradient);
  border-radius: 0 4px 4px 0;
  transform: scaleY(0);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text);
  transform: translateX(2px);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active::before {
  transform: scaleY(1);
}
.nav-icon { font-size: 16px; width: 22px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}
.nav-badge.ok { background: var(--success-soft); color: var(--success); }
.nav-badge.warn { background: var(--warning-soft); color: var(--warning); }
.nav-badge.err { background: var(--danger-soft); color: var(--danger); }

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 14px 4px;
  margin-top: 2px;
  user-select: none;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s;
}
.theme-toggle:hover { background: var(--bg-elevated); }
.connection-status {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}
.connection-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  background: var(--success);
}

/* ===== MAIN ===== */
.main-panel {
  grid-row: 1;
  overflow-y: auto;
  padding: 24px 28px 32px;
}
.section { display: none; }
.section.active { display: block; }

/* ===== STATUS BAR ===== */
.status-bar {
  grid-column: 1 / -1;
  grid-row: 2;
  background: linear-gradient(90deg, rgba(15,23,42,0.9) 0%, rgba(30,41,59,0.85) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  font-size: 11px;
  color: var(--text-muted);
}
.status-bar-item { display: flex; align-items: center; gap: 5px; }
.status-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted);
}
.status-dot.idle { background: var(--text-muted); }
.status-dot.running { background: var(--warning); animation: pulse 1.2s infinite; }
.status-dot.succeeded { background: var(--success); }
.status-dot.failed { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ===== COMPONENTS ===== */

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 16px;
}
.section-header h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.section-header p { color: var(--text-secondary); margin: 4px 0 0; font-size: 13px; }

/* Cards */
.card {
  background: var(--bg-surface);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.card:hover {
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  transform: translateY(-1px);
}
[data-theme="light"] .card:hover {
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
}
.card + .card { margin-top: 16px; }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.card-header h3 { font-size: 15px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.card-header .muted { font-size: 11.5px; color: var(--text-muted); }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-label { font-size: 11.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 28px; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; }
.stat-value.ok { color: var(--success); }
.stat-value.warn { color: var(--warning); }
.stat-value.err { color: var(--danger); }
.stat-value.info { color: var(--accent); }
.stat-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
  filter: brightness(1.08);
}
.btn-secondary { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-success { background: linear-gradient(135deg, #10b981 0%, #34d399 100%); color: #fff; box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3); }
.btn-success:hover:not(:disabled) { box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45); transform: translateY(-1px); }
.btn-danger { background: linear-gradient(135deg, #ef4444 0%, #f87171 100%); color: #fff; box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3); }
.btn-danger:hover:not(:disabled) { box-shadow: 0 6px 20px rgba(239, 68, 68, 0.45); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-elevated); color: var(--text); border-color: rgba(99, 102, 241, 0.3); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* Forms */
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  transition: border-color 0.14s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.form-textarea { min-height: 160px; resize: vertical; font-family: var(--font); }
.form-textarea.mono { font-family: var(--font-mono); font-size: 12px; }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-idle { background: var(--bg-elevated); color: var(--text-muted); }
.badge-running { background: var(--warning-soft); color: var(--warning); }
.badge-succeeded { background: var(--success-soft); color: var(--success); }
.badge-failed { background: var(--danger-soft); color: var(--danger); }

/* Progress Bar */
.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-elevated);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.4s;
}
.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }

/* Status Banner */
.status-banner {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  margin-bottom: 16px;
}
.status-banner .badge { min-width: 90px; justify-content: center; }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.tab-btn {
  padding: 7px 14px;
  border: none;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-bottom: 2px solid transparent;
  transition: color 0.12s, border-color 0.12s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Code Viewer */
.code-viewer {
  margin: 0;
  min-height: 300px;
  max-height: 60vh;
  overflow: auto;
  border-radius: var(--radius);
  padding: 16px;
  background: #0d1117;
  color: #e6edf3;
  border: 1px solid #21262d;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  tab-size: 2;
  white-space: pre;
}
[data-theme="light"] .code-viewer {
  background: #f6f8fa;
  color: #24292f;
  border-color: #d0d7de;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.data-table th {
  text-align: left;
  padding: 9px 12px;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}
.data-table tbody tr:hover { background: var(--bg-elevated); }

/* Agent LLM Config — Tier Cards */
.tier-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.tier-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.tier-header strong {
  font-size: 13px;
  white-space: nowrap;
}
.tier-header .form-hint {
  font-size: 11px;
}
.tier-header code {
  background: var(--bg-surface);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10.5px;
}
.tier-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.tier-inputs .form-input {
  font-size: 11.5px;
  padding: 6px 10px;
  min-width: 0;
}

@media (max-width: 768px) {
  .tier-inputs {
    grid-template-columns: 1fr;
  }
  .tier-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

/* Cards Grid (2-col) */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ===== VISUALIZATION ===== */
.vis-shell {
  min-height: 280px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.vis-shell.small { min-height: 200px; }
.vis-svg {
  display: none;
  width: 100%;
  height: 100%;
}
/* ---- Combined frame-geometry SVG hitboxes ---- */
.elem-line { cursor: pointer; transition: stroke 0.15s; }
.elem-line:hover { filter: brightness(1.3); }
.elem-hitbox {
  stroke: transparent;
  stroke-width: 12;
  cursor: pointer;
}
circle { cursor: pointer; transition: fill 0.15s; }
circle:hover { filter: brightness(1.2); }

/* ---- Legend bar ---- */
.geo-legend {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-top: 8px;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
}
.geo-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}
.geo-legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #00E5FF;
  border: 1px solid #a5f3fc;
  display: inline-block;
}
.geo-legend-line {
  width: 22px; height: 3px;
  border-radius: 2px;
  display: inline-block;
}
.geo-legend-line.elem-line { background: #2196F3; }
.geo-legend-line.beam-line { background: #FF5722; }
.vis-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 24px;
  font-size: 13px;
}
.vis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
.vis-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-surface);
}
.vis-panel-head {
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.vis-panel-body { padding: 12px; }

/* Node/Element interactive */
.node-point, .element-line { cursor: pointer; transition: opacity 0.12s; }
.node-point:hover, .element-line:hover { opacity: 0.8; }
.node-point.selected { stroke: var(--danger); stroke-width: 2; }
.element-line.selected { stroke: var(--danger); stroke-width: 3; }
.element-hitbox { cursor: pointer; stroke: transparent; stroke-width: 8; }

/* ===== MULTI-SELECT FEEDBACK ===== */
.selected-items-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.selected-item-card {
  transition: border-color 0.2s, background 0.2s;
}
.selected-item-card.has-error {
  border-color: var(--danger) !important;
  background: var(--danger-soft) !important;
}
.selected-item-card:hover {
  border-color: var(--accent);
}
.error-type-select {
  cursor: pointer;
}
.remove-selection {
  color: var(--danger);
  font-weight: bold;
  padding: 2px 8px;
  font-size: 14px;
}

/* ===== MIPROv2 OPTIMIZER ===== */
.mipro-config {
  gap: 10px;
}
.mipro-config .form-input {
  font-size: 12px;
  padding: 6px 8px;
}
#mipro-results .data-table {
  font-size: 11px;
}
#mipro-results .data-table th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
#mipro-results details {
  margin-top: 2px;
}

/* ===== DIAGRAM GRID ===== */
.diagram-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
}
.diagram-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-surface);
}
.diagram-card-head {
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.diagram-card-body {
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: #fff;
}
[data-theme="dark"] .diagram-card-body { background: #1a1a1a; }
.diagram-image { display: none; width: 100%; max-height: 380px; object-fit: contain; }
.diagram-empty { color: var(--text-muted); padding: 24px; text-align: center; font-size: 13px; }

/* ===== TOASTS ===== */
.toast-container {
  position: fixed;
  bottom: 44px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  max-width: 380px;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  font-size: 13px;
  color: var(--text);
  animation: slideIn 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }
.toast-msg { flex: 1; line-height: 1.4; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== RUN PIPELINE SECTION ===== */
.prompt-area {
  margin-bottom: 16px;
}
.prompt-area textarea {
  min-height: 200px;
  font-size: 13.5px;
  line-height: 1.6;
}
.prompt-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}
.prompt-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  align-items: center;
}

/* Pipeline Stage Visualization */
.pipeline-overview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.pipeline-stage {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  transition: border-color 0.2s;
}
.pipeline-stage.active { border-color: var(--accent); }
.pipeline-stage.done { border-color: var(--success); }
.pipeline-stage.failed { border-color: var(--danger); }
.pipeline-stage-icon { font-size: 22px; margin-bottom: 6px; }
.pipeline-stage-name { font-size: 11.5px; font-weight: 700; color: var(--text-secondary); }
.pipeline-stage-status { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }

/* Stage Detail Rail */
.stage-rail {
  display: grid;
  gap: 0;
  margin-top: 14px;
}
.stage-step {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: start;
  padding-bottom: 14px;
}
.stage-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stage-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  color: var(--text-muted);
  z-index: 1;
  flex-shrink: 0;
}
.stage-dot.done { background: var(--success); border-color: var(--success); color: #fff; }
.stage-dot.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.stage-dot.failed { background: var(--danger); border-color: var(--danger); color: #fff; }
.stage-line {
  width: 2px;
  flex: 1;
  min-height: 18px;
  background: var(--border);
  margin: 3px 0;
}
.stage-step:last-child .stage-line { display: none; }
.stage-line.done { background: var(--success); }
.stage-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.stage-card h4 { font-size: 13px; font-weight: 700; margin: 0 0 6px; }
.stage-card .agent-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.agent-tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
}
.agent-tag.ready { background: var(--success-soft); color: var(--success); }
.agent-tag.empty { background: var(--bg-elevated); color: var(--text-muted); border: 1px dashed var(--border); }

/* ===== HISTORY LIST ===== */
.history-list {
  display: grid;
  gap: 8px;
  max-height: 60vh;
  overflow-y: auto;
}
.history-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.history-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.history-item-top strong { font-size: 12px; }
.history-item p { font-size: 12.5px; color: var(--text-secondary); margin: 4px 0; }
.history-item-meta { display: flex; gap: 14px; font-size: 11px; color: var(--text-muted); }

/* ===== BENCHMARK ===== */
.benchmark-config {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.benchmark-case-list {
  display: grid;
  gap: 8px;
  max-height: 55vh;
  overflow-y: auto;
  margin-top: 12px;
}
.benchmark-case-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.benchmark-case-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.benchmark-case-id { font-size: 12px; font-weight: 700; font-family: var(--font-mono); color: var(--accent); }
.benchmark-case-prompt {
  margin: 8px 0;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
  font-family: var(--font);
}
.benchmark-case-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-muted);
}
.benchmark-case-meta span { white-space: nowrap; }
.benchmark-case-actions { margin-top: 8px; }
.benchmark-full-prompt {
  margin: 8px 0;
}
.benchmark-full-prompt summary {
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 0;
}
.benchmark-full-prompt pre {
  max-height: 180px;
  overflow: auto;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  margin-top: 6px;
}
.benchmark-output-panel { margin-top: 10px; }

/* ===== RL SECTION ===== */
.rl-score-circle {
  width: 100px; height: 100px;
  border-radius: 50%;
  border: 5px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.rl-score-circle.ok { border-color: var(--success); }
.rl-score-circle.warn { border-color: var(--warning); }
.rl-score-circle.err { border-color: var(--danger); }
.rl-score-value { font-size: 28px; font-weight: 800; }
.rl-score-label { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; }
.rl-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.rl-metric-item {
  text-align: center;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.rl-metric-value { font-size: 18px; font-weight: 700; }
.rl-metric-label { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }
.rl-components { margin-top: 14px; }
.rl-component-bar {
  display: grid;
  grid-template-columns: 140px 1fr 60px;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.rl-component-name { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.rl-component-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-elevated);
  overflow: hidden;
}
.rl-component-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.4s;
}
.rl-component-value { font-size: 12px; font-weight: 700; text-align: right; }
.feedback-actions { display: flex; gap: 10px; margin-top: 12px; }

/* ===== EXECUTION ===== */
.execution-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
.execution-pane h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.execution-pane pre {
  min-height: 180px;
  max-height: 280px;
  overflow: auto;
  font-size: 12px;
}

/* ===== AGENT REWARDS ===== */
.agent-rewards-table { margin-top: 12px; }
.agent-rewards-table td:first-child { font-weight: 600; color: var(--text); }

/* ===== SECTION ASSIGNMENTS ===== */
.prop-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.prop-card .prop-label {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.prop-card .prop-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.open { display: flex; position: fixed; top: 0; left: 0; bottom: var(--statusbar-h); z-index: 50; width: var(--sidebar-w); }
  .main-panel { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .cards-grid { grid-template-columns: 1fr; }
  .pipeline-overview { grid-template-columns: 1fr 1fr; }
  .execution-grid { grid-template-columns: 1fr; }
  .benchmark-config { grid-template-columns: 1fr; }
  .rl-metrics { grid-template-columns: 1fr; }
  .diagram-grid { grid-template-columns: 1fr; }
  .vis-grid { grid-template-columns: 1fr; }
  .mobile-menu-btn {
    display: flex !important;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 60;
    width: 36px; height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    font-size: 18px;
  }
}

@media (min-width: 769px) {
  .mobile-menu-btn { display: none; }
  .sidebar-overlay { display: none; }
}

/* ============================================================
   XuLAB Branding & Visual Polish
   ============================================================ */

/* ----- Lab Banner (sidebar) ----- */
.lab-banner {
  padding: 10px 14px;
  margin: 8px 12px 4px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(99,102,241,0.12) 0%, rgba(139,92,246,0.08) 100%);
  border: 1px solid rgba(99,102,241,0.15);
  display: flex;
  flex-direction: column;
  gap: 2px;
  backdrop-filter: blur(8px);
}
.lab-banner .lab-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.03em;
}
.lab-banner .lab-affil {
  font-size: 10.5px;
  color: var(--text-secondary);
  font-weight: 500;
}
.lab-banner .lab-dept {
  font-size: 9.5px;
  color: var(--text-muted);
}

/* ----- Status Bar Lab Tag ----- */
.lab-tag {
  background: linear-gradient(135deg, rgba(99,102,241,0.15) 0%, rgba(139,92,246,0.1) 100%);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 999px;
  padding: 3px 10px;
  font-weight: 600;
  color: var(--accent);
  font-size: 10.5px;
  letter-spacing: 0.02em;
}
.lab-tag .lab-icon {
  font-size: 11px;
  margin-right: 2px;
}
.lab-tag .lab-divider {
  opacity: 0.4;
  margin: 0 4px;
}

/* ----- Enhanced Toast ----- */
.toast {
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  border: 1px solid var(--border);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }

/* ----- Section Header Accent ----- */
.section-header h2 {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ----- Animations ----- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.section.active {
  animation: fadeInUp 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* Shimmer loading effect for empty states */
.vis-empty {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, rgba(99,102,241,0.06) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
  border-radius: var(--radius-sm);
}

/* ----- Scrollbar Polish ----- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(99,102,241,0.35) 0%, rgba(139,92,246,0.25) 100%);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(99,102,241,0.55) 0%, rgba(139,92,246,0.45) 100%);
}

/* ----- Code Viewer Glow ----- */
.code-viewer {
  border: 1px solid rgba(99,102,241,0.12);
  box-shadow: inset 0 0 20px rgba(99,102,241,0.04);
}

/* ----- Progress Bar Gradient ----- */
.progress-fill {
  background: var(--accent-gradient);
}
.progress-fill.success { background: linear-gradient(90deg, #10b981, #34d399); }
.progress-fill.warning { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress-fill.running { background: var(--accent-gradient); animation: shimmer 1.5s infinite linear; background-size: 200% 100%; }

/* ----- Vis Panel Polish ----- */
.vis-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-surface);
  backdrop-filter: blur(8px);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.vis-panel:hover {
  border-color: rgba(99,102,241,0.25);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

/* ----- Stage Dot Glow ----- */
.stage-dot.done {
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.35);
}
.stage-dot.active {
  box-shadow: 0 0 12px rgba(129, 140, 248, 0.4);
}
.stage-dot.failed {
  box-shadow: 0 0 12px rgba(248, 113, 113, 0.35);
}

/* ----- RL Score Circle Gradient ----- */
.rl-score-circle.ok { border-color: #34d399; box-shadow: 0 0 20px rgba(52, 211, 153, 0.15); }
.rl-score-circle.warn { border-color: #fbbf24; box-shadow: 0 0 20px rgba(251, 191, 36, 0.15); }
.rl-score-circle.err { border-color: #f87171; box-shadow: 0 0 20px rgba(248, 113, 113, 0.15); }

/* ----- Diagram Card Polish ----- */
.diagram-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-surface);
  backdrop-filter: blur(8px);
  transition: transform 0.2s, box-shadow 0.2s;
}
.diagram-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
  border-color: rgba(99,102,241,0.2);
}

/* ----- Status Banner Gradient ----- */
.status-banner {
  background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(99,102,241,0.06) 100%);
  border: 1px solid var(--border);
}

/* ----- Form Input Focus Glow ----- */
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15), 0 0 20px rgba(99,102,241,0.08);
}

/* ----- Connection Dot Pulse ----- */
.connection-dot {
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.4);
  animation: pulse 2s infinite;
}

/* ----- Benchmark Case Item Hover ----- */
.benchmark-case-item {
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.benchmark-case-item:hover {
  transform: translateX(3px);
  border-color: rgba(99,102,241,0.25);
}

/* ----- History Item Hover ----- */
.history-item {
  transition: transform 0.15s, border-color 0.15s;
}
.history-item:hover {
  transform: translateX(3px);
  border-color: rgba(99,102,241,0.25);
}

/* ----- Tier Card Polish ----- */
.tier-card {
  background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(99,102,241,0.04) 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  transition: border-color 0.2s;
}
.tier-card:hover {
  border-color: rgba(99,102,241,0.25);
}

/* ----- Tab Button Active Glow ----- */
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-shadow: 0 0 12px rgba(129, 140, 248, 0.3);
}

/* ----- Data Table Header Glow ----- */
.data-table th {
  background: linear-gradient(180deg, var(--bg-elevated) 0%, rgba(99,102,241,0.04) 100%);
}

/* ----- Mobile Menu Button ----- */
.mobile-menu-btn {
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
}

/* ----- Light Theme Specific Tweaks ----- */
[data-theme="light"] .lab-banner {
  background: linear-gradient(135deg, rgba(99,102,241,0.08) 0%, rgba(139,92,246,0.04) 100%);
}
[data-theme="light"] .status-bar {
  background: linear-gradient(90deg, rgba(248,250,252,0.9) 0%, rgba(241,245,249,0.85) 100%);
}
[data-theme="light"] .sidebar {
  background: rgba(255,255,255,0.72);
}
[data-theme="light"] .card {
  background: rgba(255,255,255,0.65);
}
[data-theme="light"] .vis-panel,
[data-theme="light"] .diagram-card {
  background: rgba(255,255,255,0.6);
}
[data-theme="light"] .code-viewer {
  box-shadow: inset 0 0 20px rgba(99,102,241,0.02);
}
[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(99,102,241,0.25) 0%, rgba(139,92,246,0.18) 100%);
}

/* ===== Section Divider (Dashboard workflow stages) ===== */
.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.section-divider-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

/* Stage workflow dividers */
.stage-divider {
  border-bottom: 2px solid var(--accent);
  padding: 10px 0;
}
.stage-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  margin-right: 4px;
  line-height: 1;
}

/* ===== Review & Confirm Panel ===== */
#dash-review-panel {
  transition: box-shadow 0.4s ease;
}
.review-grid-top {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.review-stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: center;
}
.review-stat-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}
.review-stat-lbl {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.review-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
}
.review-detail-label {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  min-width: 120px;
}
.review-section-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  margin: 14px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-light);
}
.review-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
}
.review-sec-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.review-sec-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(99,102,241,0.12);
}
.review-sec-icon {
  font-size: 22px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}
.review-sec-body {
  flex: 1;
  min-width: 0;
}
.review-sec-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}
.review-sec-type {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}
.review-sec-dims {
  font-size: 10.5px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  margin-top: 3px;
}
.review-mat-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  margin-top: 6px;
}
.review-mat-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.review-mat-body {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
  font-size: 12px;
  color: var(--text);
}
.review-mat-model {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 3px;
}
.review-mat-param {
  font-size: 10.5px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}
.review-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

/* ===== Run Pipeline — larger prompt input ===== */
#prompt-input {
  min-height: 300px;
  line-height: 1.55;
  font-size: 14px;
}

/* ===== Prop card unit ===== */
.prop-card .prop-unit {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 4px;
}

/* ===== Section geometry viewer ===== */
.section-geometry-host {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}
.section-geo-card {
  border: 1px solid var(--border, #1f2937);
  border-radius: var(--radius-sm, 8px);
  background: #0f172a;
  padding: 12px;
}
.section-geo-card svg {
  display: block;
  width: 100%;
  height: 320px;
}
.section-geo-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text, #e2e8f0);
  margin-bottom: 6px;
  text-align: center;
}
.section-geo-title span {
  font-weight: 400;
  font-size: 10px;
  color: var(--text-muted);
}


/* ===== History — clickable prompt text ===== */
.history-prompt-text { cursor: pointer; }
.history-item { cursor: pointer; }
.history-prompt-text:hover { color: var(--accent, #6366f1); }

/* ===== Modal overlay (history prompt detail) ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  width: min(760px, 100%);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-card, #111827);
  border: 1px solid var(--border, #1f2937);
  border-radius: var(--radius, 12px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  padding: 18px 20px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.modal-prompt {
  flex: 1;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.6;
  background: var(--bg-elevated, #0f172a);
  border: 1px solid var(--border, #1f2937);
  border-radius: var(--radius-sm, 8px);
  padding: 14px 16px;
  margin: 0;
}

/* ===== Section detail modal ===== */
.section-detail-box { max-width: 820px; }
.section-detail-box .section-geo-props-table {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}
.section-geo-props-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
}
.section-geo-props-table td:first-child {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  width: 80px;
}
.section-geo-props-table td:last-child {
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 600;
}
.section-geo-card { cursor: pointer; }
.section-geo-card:hover { border-color: var(--accent, #6366f1); }

/* ===== Dimensionality Toggle ===== */
.dim-toggle {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 12px;
}
.dim-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 10px;
}
.dim-option {
  padding: 6px 16px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.dim-option:first-of-type { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.dim-option:last-of-type { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: none; }
.dim-option:hover { background: var(--bg-input); color: var(--text); }
.dim-option.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.dim-option input[type="radio"] { display: none; }

/* Fidelity level dropdown — reuses dim-toggle row layout */
.fidelity-select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.fidelity-select:hover { background: var(--bg-input); color: var(--text); }
.fidelity-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ===== CAD Upload ===== */
.input-mode-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: fit-content;
}
.input-mode-tab {
  padding: 8px 20px;
  border: none;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border-right: 1px solid var(--border);
}
.input-mode-tab:last-child { border-right: none; }
.input-mode-tab:hover { background: var(--bg-input); color: var(--text); }
.input-mode-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.cad-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg-elevated);
}
.cad-drop-zone:hover,
.cad-drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.1);
}
.cad-drop-icon {
  font-size: 40px;
  margin-bottom: 10px;
}
.cad-drop-zone p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 4px 0;
}

.cad-file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  margin-top: 8px;
}
.cad-file-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  flex: 1;
}
.cad-file-size {
  font-size: 11px;
  color: var(--text-muted);
}

.cad-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

/* Shared CAD / Image preview stat cards */
.cad-preview-stat {
  text-align: center;
  padding: 10px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.cad-preview-stat-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}
.cad-preview-stat-lbl {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Detail rows */
.cad-preview-detail-row {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}
.cad-preview-detail-label {
  font-weight: 600;
  color: var(--text-primary);
}

/* Section labels */
.cad-preview-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 10px;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* Section rows */
.cad-preview-section-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  font-size: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-xs);
  margin-bottom: 3px;
}
.cad-preview-section-name {
  font-weight: 600;
  color: var(--accent);
  font-family: var(--font-mono);
  min-width: 70px;
}
.cad-preview-section-type {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 3px;
}
.cad-preview-section-desc {
  color: var(--text-secondary);
  flex: 1;
  font-size: 11px;
}

/* Image preview */
.image-preview-wrap {
  text-align: center;
}
.image-preview-wrap img {
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ===== Interactive Frame Viewer ===== */
.interactive-viewer {
  min-height: 300px;
  max-height: 500px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
  position: relative;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.interactive-viewer.is-3d {
  height: clamp(540px, 68vh, 820px);
  min-height: 540px;
  max-height: none;
}
.interactive-viewer.is-3d #detailed-frame-canvas-3d {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.interactive-svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 300px;
}
@media (max-width: 900px) {
  .interactive-viewer.is-3d {
    height: clamp(430px, 60vh, 620px);
    min-height: 430px;
  }
}
@media (max-width: 600px) {
  .interactive-viewer.is-3d {
    height: 420px;
    min-height: 420px;
  }
}
/* Viewer control bar */
.viewer-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  flex-wrap: wrap;
}
.viewer-ctrl-btn {
  font-size: 12px;
  padding: 3px 8px;
  min-width: 32px;
  text-align: center;
}
.viewer-ctrl-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.viewer-ctrl-sep {
  color: var(--border);
  font-size: 14px;
  margin: 0 4px;
}
.zoom-slider, .rotate-slider {
  width: 80px;
  height: 4px;
  cursor: pointer;
  accent-color: var(--accent);
  margin: 0 4px;
}

/* ===== Element Hover Tooltip ===== */
.element-tooltip {
  position: fixed;
  z-index: 300;
  pointer-events: none;
  background: #0f172a;
  border: 1px solid var(--accent, #6366f1);
  border-radius: var(--radius-sm, 8px);
  padding: 10px 12px;
  min-width: 160px;
  max-width: 200px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  font-size: 11px;
  color: var(--text, #e2e8f0);
  display: none;
}
.tooltip-head {
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 4px;
  color: var(--text);
}
.tooltip-type {
  font-weight: 400;
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 6px;
}
.tooltip-section-svg {
  margin: 6px 0;
  display: flex;
  justify-content: center;
  background: #0b0f19;
  border-radius: 4px;
  overflow: hidden;
}
.tooltip-dims {
  width: 100%;
  border-collapse: collapse;
  font-size: 10.5px;
}
.tooltip-dims td {
  padding: 2px 6px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}
.tooltip-dims td:first-child {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.tooltip-dims td:last-child {
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 600;
  text-align: right;
}
.tooltip-mat-chip {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(52,211,153,0.15);
  color: #34d399;
  margin-left: 6px;
  vertical-align: middle;
}
.tooltip-mat-table {
  margin-top: 6px;
  border-top: 1px solid rgba(99,102,241,0.15);
}
.tooltip-mat-sep td {
  font-size: 9.5px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 6px;
  padding-bottom: 2px;
}
.tooltip-mat-badge {
  font-size: 10.5px;
  font-weight: 600;
  color: #34d399;
}

/* ===== Overall Frame Overview ===== */
#frame-overview-svg line,
#frame-overview-svg circle,
#frame-overview-svg text {
  pointer-events: none;
}

/* ===== Login Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  min-width: 360px;
}
.modal-header { padding: 1.25rem 1.5rem 0.5rem; }
.modal-header h3 { margin: 0; }
.modal-body { padding: 1rem 1.5rem 1.5rem; }
.form-group { display: flex; flex-direction: column; }
.form-label { font-size: 0.8rem; font-weight: 600; margin-bottom: 0.3rem; opacity: 0.85; }
.form-input {
  padding: 0.55rem 0.75rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--input-bg, #1e1e2e); color: var(--text); font-size: 0.9rem;
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(99,102,241,0.2); }
.form-hint { font-size: 0.75rem; opacity: 0.55; margin: 0.25rem 0 0; }

/* Sidebar user block */
.sidebar-user { border-top: 1px solid var(--border); }

