:root {
  --bg-app: #eff2f6;
  --bg-panel: #f9f9f9;
  --bg-panel-elevated: #f1f5f9;
  --bg-card: #f4f6f9;
  --bg-card-hover: #e8f0fe;
  --bg-canvas: #ffffff;
  --bg-glass: rgba(249, 249, 249, 0.94);
  --border-subtle: rgba(16, 16, 16, 0.11);
  --border-strong: rgba(16, 16, 16, 0.22);
  --border-accent: rgba(0, 122, 204, 0.5);
  --text-primary: #101010;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-primary: #007acc;
  --accent-secondary: #2563eb;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;
  --accent-violet: #7c3aed;
  --shadow-lg: 0 18px 40px -10px rgba(15, 23, 42, 0.18), 0 0 1px 1px rgba(15, 23, 42, 0.08);
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Fira Code", Consolas, monospace;
}

body.theme-light,
[data-theme="light"] {
  --bg-app: #eff2f6;
  --bg-panel: #f9f9f9;
  --bg-panel-elevated: #f1f5f9;
  --bg-card: #f4f6f9;
  --bg-card-hover: #e8f0fe;
  --bg-canvas: #ffffff;
  --bg-glass: rgba(249, 249, 249, 0.94);
  --border-subtle: rgba(16, 16, 16, 0.11);
  --border-strong: rgba(16, 16, 16, 0.22);
  --border-accent: rgba(0, 122, 204, 0.5);
  --text-primary: #101010;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-primary: #007acc;
  --accent-secondary: #2563eb;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;
  --accent-violet: #7c3aed;
  --shadow-lg: 0 18px 40px -10px rgba(15, 23, 42, 0.18), 0 0 1px 1px rgba(15, 23, 42, 0.08);
}

body.theme-dark,
[data-theme="dark"] {
  --bg-app: #1e2030;
  --bg-panel: #24273a;
  --bg-panel-elevated: #2c3047;
  --bg-card: #292d42;
  --bg-card-hover: #343954;
  --bg-canvas: #24273a;
  --bg-glass: rgba(36, 39, 58, 0.90);
  --border-subtle: rgba(202, 211, 245, 0.14);
  --border-strong: rgba(202, 211, 245, 0.28);
  --border-accent: rgba(198, 160, 246, 0.55);
  --text-primary: #cad3f5;
  --text-secondary: #a5adcb;
  --text-muted: #8087a2;
  --accent-primary: #38bdf8;
  --accent-secondary: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-violet: #c6a0f6;
  --shadow-lg: 0 20px 45px -10px rgba(0, 0, 0, 0.55), 0 0 1px 1px rgba(255, 255, 255, 0.07);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.45);
}

/* Layout Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* Top Navbar */
.top-navbar {
  height: 54px;
  min-height: 54px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  z-index: 20;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 11px;
}

.btn-demo-files {
  border: 1px solid rgba(56, 189, 248, 0.55) !important;
  background: rgba(56, 189, 248, 0.08) !important;
  color: var(--accent-primary) !important;
  font-weight: 800 !important;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.btn-demo-files:hover {
  background: rgba(56, 189, 248, 0.16) !important;
  border-color: rgba(56, 189, 248, 0.9) !important;
}

.brand-brandmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  cursor: default;
}

.brand-logo-img {
  height: 34px;
  width: 34px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(56, 189, 248, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
}

.brand-logo-img:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35), 0 0 0 1.5px rgba(56, 189, 248, 0.6);
}

.brand-title {
  font-size: 17px;
  font-weight: 800;
  font-family: var(--font-sans);
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1;
}

.brand-title-accent {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 900;
}

body.theme-dark .brand-title-accent,
[data-theme="dark"] .brand-title-accent {
  background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-primary);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.nav-center-group,
.nav-right-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, #0891b2 0%, #2563eb 100%);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 2px 10px rgba(6, 182, 212, 0.28);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #06b6d4 0%, #1d4ed8 100%);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-accent {
  background: rgba(6, 182, 212, 0.14);
  color: var(--accent-primary);
  border-color: rgba(6, 182, 212, 0.35);
}

.btn-accent:hover {
  background: rgba(6, 182, 212, 0.24);
}

/* Green scope for Excel/CSV export buttons only */
.btn.btn-file-export {
  background: linear-gradient(135deg, #10b981 0%, #047857 100%);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.28);
}

.btn.btn-file-export:hover {
  background: linear-gradient(135deg, #34d399 0%, #059669 100%);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn.btn-file-export.btn-accent {
  background: rgba(16, 185, 129, 0.14);
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.35);
}

.btn.btn-file-export.btn-accent:hover {
  background: rgba(16, 185, 129, 0.24);
}

.btn-sm {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 6px;
}

.btn-xs {
  padding: 2px 6px;
  font-size: 10.5px;
  border-radius: 5px;
}

/* Active Button State across all toolbars, button groups, and spectrum action bars */
.btn.active,
.btn-group .btn.active,
.toolbar-group .btn.active,
.spectrum-top-bar .btn.active {
  background: var(--accent-primary) !important;
  color: #ffffff !important;
  border-color: var(--accent-primary) !important;
  font-weight: 700 !important;
}

.btn-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 1px;
  gap: 1px;
}

.btn-group .btn {
  border: none;
  background: transparent;
  color: var(--text-primary);
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
}

.btn-group .btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: transparent;
}

/* Direct Numerical Input for Line Widths */
.line-width-input {
  width: 44px;
  height: 22px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  padding: 0 2px;
  outline: none;
  -moz-appearance: textfield;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.line-width-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1.5px var(--accent-primary);
}

.line-width-input-sm {
  width: 38px;
  height: 20px;
  font-size: 10.5px;
}

/* Larger Deconvolution Action Button on Far Right */
.btn-deconv-run {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-sans);
  border-radius: 8px;
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.32);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: all 0.18s ease;
}

.btn-deconv-run:hover {
  background: linear-gradient(135deg, #0369a1 0%, #1d4ed8 100%);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.44);
  transform: translateY(-1px);
}

.btn-deconv-run:active {
  transform: translateY(1px);
}

/* Dedicated Top-of-Spectrum Action Area (Outside Canvas, Directly Above Spectrum) */
.spectrum-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 14px;
  background: var(--bg-panel-elevated);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 36px;
  user-select: none;
  z-index: 5;
}

.spectrum-top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.spectrum-bar-section {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.spectrum-bar-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.spectrum-top-bar .btn-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.spectrum-top-bar .btn-xs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.spectrum-top-bar button#btnExportPng,
.spectrum-top-bar button#btnResetView {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.spectrum-top-bar button#btnExportPng:hover,
.spectrum-top-bar button#btnResetView:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* Top-Level 3-Tab Navigation Bar */
.top-tabs-nav {
  background: var(--bg-panel-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 3px;
  gap: 4px;
}

.top-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1.5px solid rgba(2, 132, 199, 0.28);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.top-tab-btn:hover {
  color: #0284c7;
  border-color: #0284c7;
  background: rgba(2, 132, 199, 0.06);
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.16);
}

.top-tab-btn.active {
  background: rgba(2, 132, 199, 0.12);
  color: #0284c7;
  border-color: #0284c7;
  box-shadow: 0 0 12px rgba(2, 132, 199, 0.3);
}

body.theme-dark .top-tab-btn,
[data-theme="dark"] .top-tab-btn {
  border: 1.5px solid rgba(56, 189, 248, 0.32);
  background: #111827;
  color: #94a3b8;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

body.theme-dark .top-tab-btn:hover,
[data-theme="dark"] .top-tab-btn:hover {
  color: #38bdf8;
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.22);
}

body.theme-dark .top-tab-btn.active,
[data-theme="dark"] .top-tab-btn.active {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border-color: #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.45);
}

/* Subtle Green Blinking Indicator for Unread Deconvolution Results */
.deconv-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.75);
  flex-shrink: 0;
  animation: deconvPulseGreen 1.5s infinite ease-in-out;
}

.top-tab-btn.has-new-deconv {
  border-color: rgba(16, 185, 129, 0.45);
}

.top-tab-btn.has-new-deconv #deconvPeakCountBadge {
  background: rgba(16, 185, 129, 0.18);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.45);
}

@keyframes deconvPulseGreen {
  0% {
    opacity: 1;
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.75);
  }
  60% {
    opacity: 0.45;
    transform: scale(1.12);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    opacity: 1;
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* Workspace 2-Column Grid (Left Sidebar + Full-Width Main Content) */
.workspace-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 316px 1fr;
  min-height: 0;
  overflow: hidden;
  position: relative;
  transition: grid-template-columns 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: grid-template-columns;
}

.workspace-grid.sidebar-collapsed {
  grid-template-columns: 0px 1fr;
}

.sidebar-left {
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid var(--border-subtle);
  transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.22s ease;
  visibility: visible;
  opacity: 1;
}

.sidebar-left > .panel-section {
  min-width: 316px;
  width: 316px;
  box-sizing: border-box;
}

.workspace-grid.sidebar-collapsed .sidebar-left {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  border-right-color: transparent;
}

/* =========================================================================
   COLLAPSIBLE LOADED SPECTRA SIDEBAR CONTROLS & ANIMATION
   ========================================================================= */
.btn-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.btn-sidebar-toggle .sidebar-toggle-chevron {
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

body.sidebar-collapsed .btn-sidebar-toggle,
.workspace-grid.sidebar-collapsed .btn-sidebar-toggle {
  background: rgba(56, 189, 248, 0.16) !important;
  border-color: rgba(56, 189, 248, 0.55) !important;
  color: var(--accent-primary, #38bdf8) !important;
  font-weight: 700;
}

body.sidebar-collapsed .btn-sidebar-toggle .sidebar-toggle-chevron,
.workspace-grid.sidebar-collapsed .btn-sidebar-toggle .sidebar-toggle-chevron {
  transform: rotate(180deg);
}

.btn-collapse-sidebar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-collapse-sidebar:hover {
  color: var(--accent-primary, #38bdf8);
  border-color: var(--accent-primary, #38bdf8);
  background: rgba(56, 189, 248, 0.12);
}

/* Floating Edge Pull Handle docked to left screen edge when collapsed */
.sidebar-edge-toggle {
  position: absolute;
  left: 0;
  top: 110px;
  z-index: 95;
  width: 22px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-left: none;
  border-radius: 0 7px 7px 0;
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.24);
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s ease,
              width 0.18s ease,
              background 0.15s ease,
              color 0.15s ease,
              border-color 0.15s ease,
              box-shadow 0.15s ease;
}

.workspace-grid.sidebar-collapsed .sidebar-edge-toggle {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.sidebar-edge-toggle:hover {
  width: 28px;
  background: var(--bg-card-hover, rgba(56, 189, 248, 0.14));
  border-color: var(--accent-primary, #38bdf8);
  color: var(--accent-primary, #38bdf8);
  box-shadow: 2px 4px 16px rgba(56, 189, 248, 0.28);
}

.main-content-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-canvas);
  position: relative;
  overflow: hidden;
}

.main-tab-pane {
  display: none;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.main-tab-pane.active {
  display: flex;
}

.panel-section {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Spectrum Cards Container - Full Smooth Vertical Scroll Without Shrinking */
.spectra-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding-right: 6px;
  padding-bottom: 18px;
  min-height: 0;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 189, 248, 0.45) var(--bg-panel);
}

.spectra-list::-webkit-scrollbar {
  width: 7px;
}

.spectra-list::-webkit-scrollbar-track {
  background: var(--bg-panel);
  border-radius: 4px;
}

.spectra-list::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.45);
  border-radius: 4px;
}

.spectra-list::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

.spectrum-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid transparent;
  border-radius: 8px;
  padding: 8px 9px;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  flex-shrink: 0; /* Crucial: NEVER squish or collapse cards regardless of how many spectra are loaded */
  min-height: fit-content;
  box-sizing: border-box;
}

.spectrum-card:hover {
  border-color: var(--border-strong);
  transform: translateX(1px);
}

/* Sidebar Folder Grouping Styles */
.spectra-folder {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-card);
  margin-bottom: 6px;
  overflow: hidden;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.spectra-folder.selected-folder {
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.30);
}

.spectra-folder.selected-folder .folder-header {
  background: rgba(6, 182, 212, 0.12);
}

body.theme-light .spectra-folder.selected-folder .folder-header,
[data-theme="light"] .spectra-folder.selected-folder .folder-header {
  background: rgba(0, 122, 204, 0.10);
}

.spectra-folder.drag-over {
  border-color: var(--accent-primary);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.35);
  background: rgba(6, 182, 212, 0.08);
}

.folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: var(--bg-panel-elevated);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border-subtle);
  gap: 6px;
}

.folder-header:hover {
  background: var(--bg-panel);
}

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

.folder-toggle-icon {
  font-size: 10px;
  transition: transform 0.15s ease;
  display: inline-block;
  color: var(--text-muted);
}

.spectra-folder.collapsed .folder-toggle-icon {
  transform: rotate(-90deg);
}

.folder-name-text {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-actions-group {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.folder-body {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.spectra-folder.collapsed .folder-body {
  display: none;
}

.folder-drop-zone-empty {
  padding: 10px 8px;
  text-align: center;
  font-size: 10.5px;
  color: var(--text-muted);
  border: 1px dashed var(--border-subtle);
  border-radius: 6px;
  margin: 2px 0;
}

/* Crystal-clear Active Spectrum Card Highlight */
.spectrum-card.active-spectrum {
  border-color: var(--accent-primary);
  border-left: 4px solid var(--accent-primary);
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.12) 0%, var(--bg-card) 60%);
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.30), inset 0 0 16px rgba(6, 182, 212, 0.06);
}

/* Multi-selected Spectrum Card (Ctrl/Shift Click Batch Selection) */
.spectrum-card.multi-selected {
  outline: 2px solid var(--accent-primary);
  outline-offset: -1px;
  background: rgba(6, 182, 212, 0.15) !important;
}

body.theme-light .spectrum-card.multi-selected,
[data-theme="light"] .spectrum-card.multi-selected {
  outline: 2px solid var(--accent-primary);
  background: rgba(0, 122, 204, 0.12) !important;
}

.spectrum-card.hidden-spectrum {
  opacity: 0.52;
}

.spec-card-top {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
}

.spec-color-picker {
  width: 18px;
  height: 18px;
  border: none;
  padding: 0;
  border-radius: 5px;
  cursor: pointer;
  background: transparent;
  flex-shrink: 0;
}

.spec-name-input {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 12px;
  font-family: var(--font-sans);
  padding: 2px 5px;
  border-radius: 4px;
  min-width: 0;
}

.spec-name-input:hover,
.spec-name-input:focus {
  border-color: var(--border-strong);
  background: var(--bg-panel);
  outline: none;
}

.meta-pill {
  background: rgba(148, 163, 184, 0.12);
  padding: 2px 7px;
  border-radius: 4px;
}

/* Dynamic Action Buttons Row - Perfectly Sized & Never Squished */
.spec-actions-row {
  display: flex;
  align-items: center;
  gap: 3px;
  width: 100%;
  box-sizing: border-box;
}

.spec-actions-row .btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 2px 3px;
  font-size: 10px;
  justify-content: center;
  flex-shrink: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.spec-actions-row .spec-del-btn {
  flex: 0 0 24px !important;
  width: 24px !important;
  min-width: 24px !important;
  max-width: 24px !important;
  height: 22px;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-sizing: border-box;
}

.spec-actions-row .spec-del-btn:hover {
  background: rgba(244, 63, 94, 0.18);
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.45);
}

/* Multi-Spectrum Batch Selection Bar */
.batch-selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 8px;
  margin-bottom: 6px;
  border-radius: 6px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.35);
  animation: fadeIn 0.15s ease;
  user-select: none;
}

body.theme-light .batch-selection-bar,
[data-theme="light"] .batch-selection-bar {
  background: rgba(0, 122, 204, 0.10);
  border: 1px solid rgba(0, 122, 204, 0.30);
}

.batch-count-pill {
  font-size: 10.5px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-primary);
  white-space: nowrap;
}

.batch-bar-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

/* Custom Context Menu for Spectra and Folders */
.spectra-context-menu {
  position: fixed;
  z-index: 100000;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid rgba(2, 132, 199, 0.45);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35), 0 0 16px rgba(2, 132, 199, 0.08);
  padding: 5px;
  min-width: 210px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  user-select: none;
  font-family: var(--font-sans);
  animation: contextMenuFadeIn 0.12s ease-out;
}

@keyframes contextMenuFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.context-menu-header {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 8px 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.context-menu-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 3px 2px;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.context-menu-item:hover {
  background: var(--accent-primary);
  color: #ffffff;
}

.context-menu-item.disabled {
  opacity: 0.40;
  cursor: not-allowed;
  pointer-events: none;
}

.context-menu-item.danger:hover {
  background: var(--accent-rose);
  color: #ffffff;
}

.context-menu-icon {
  font-size: 12px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
}

.context-menu-check {
  font-weight: 700;
}

.context-menu-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Spectrum Viewer Toolbar & Canvas */
.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 4px;
  margin: 6px 12px 0 12px;
  padding: 4px 8px;
  background: var(--bg-card);
  border: 1.5px solid #0284c7;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  overflow-x: auto;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chart-toolbar:hover {
  border-color: #0369a1;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.16);
}

.toolbar-actions-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-card);
  padding: 2px 4px;
  border-radius: 7px;
  border: 1px solid var(--border-subtle);
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
  margin: 0 2px;
}

.chart-toolbar .btn-sm {
  padding: 3px 6px;
  font-size: 11px;
}

.chart-toolbar .line-width-input {
  width: 32px;
  height: 20px;
  font-size: 10.5px;
  text-align: center;
  padding: 0 2px;
}

.chart-toolbar .checkbox-label {
  font-size: 11px;
  gap: 4px;
}

.chart-toolbar .btn-deconv-run {
  padding: 4px 10px;
  font-size: 11.5px;
  gap: 6px;
}

.canvas-wrapper {
  flex: 1;
  position: relative;
  min-height: 0;
  margin: 6px 12px;
  background: var(--bg-canvas);
  border: 1.5px solid #0284c7;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.12), 0 1px 3px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  user-select: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.canvas-wrapper:hover {
  border-color: #0369a1;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.2);
}

#spectrumCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  image-rendering: -webkit-optimize-contrast;
}

/* 3. Active Spectrum Legend Positioned Cleanly Inside Upper-Right Plot Area */
.canvas-hud-top-right-legend {
  position: absolute;
  top: 32px;
  right: 34px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 7px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  z-index: 10;
  max-height: calc(100% - 96px);
  overflow-y: auto;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}

.hud-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.hud-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* 2. Bottom Bar Below Spectrum Canvas: Left-Docked SNIP Bar + Right-Pinned Fixed-Width Hover Readout */
.canvas-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 2px 12px 4px 12px;
  background: transparent;
  border-top: none;
  flex-shrink: 0;
}

.canvas-bottom-docks-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  margin-right: auto;
}

.snip-bottom-dock {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  flex: 1 1 auto;
  gap: 6px;
  background: var(--bg-card);
  border: 1.5px solid #0284c7;
  border-radius: 8px;
  padding: 3px 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.snip-bottom-dock.bcf-map-bg-dock {
  border: 1px solid rgba(2, 132, 199, 0.45);
  box-shadow: 0 1px 4px rgba(2, 132, 199, 0.05);
}

.snip-bottom-dock:hover {
  border-color: #0369a1;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.16);
}

.snip-dock-header {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.snip-dock-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.snip-collapse-btn {
  font-weight: 700;
  font-size: 11px;
  line-height: 1;
  padding: 2px 5px;
  flex-shrink: 0;
}

.snip-bottom-dock .meta-pill {
  font-size: 10px;
  padding: 1px 6px;
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.snip-dock-body {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 7px;
  padding-left: 6px;
  border-left: 1px solid var(--border-subtle);
}

.snip-bottom-dock .checkbox-label {
  font-size: 10.5px;
  gap: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.snip-slider-group > span {
  font-size: 10.5px;
}

.snip-bottom-dock.collapsed .snip-dock-body,
.snip-dock-body.collapsed {
  display: none !important;
}

.snip-slider-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.snip-window-readout {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  width: 112px;
  min-width: 112px;
  max-width: 112px;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
}

#lblSnipChannels {
  display: inline-block;
  width: 2ch;
  text-align: right;
  margin: 0 1px 0 3px;
  color: var(--accent-primary);
  font-weight: 700;
}

#lblSnipKeV {
  display: inline-block;
  width: 4ch;
  text-align: right;
  margin: 0 1px;
  color: var(--accent-primary);
  font-weight: 700;
}

.snip-range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 136px;
  height: 6px;
  border-radius: 999px;
  background: var(--border-strong);
  outline: none;
  cursor: grab;
  margin: 0 2px;
  flex-shrink: 0;
  accent-color: var(--accent-primary);
}

.snip-range-slider:active {
  cursor: grabbing;
}

.snip-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #38bdf8;
  border: 2px solid #ffffff;
  box-shadow: 0 0 8px rgba(2, 132, 199, 0.55), 0 1px 3px rgba(0, 0, 0, 0.35);
  cursor: grab;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.1s ease;
}

.snip-range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  background: #0284c7;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.85);
}

.snip-range-slider:active::-webkit-slider-thumb {
  cursor: grabbing;
  transform: scale(1.2);
  background: #0284c7;
}

.snip-range-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #38bdf8;
  border: 2px solid #ffffff;
  box-shadow: 0 0 8px rgba(2, 132, 199, 0.55), 0 1px 3px rgba(0, 0, 0, 0.35);
  cursor: grab;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.1s ease;
}

.snip-range-slider:active::-moz-range-thumb {
  cursor: grabbing;
  transform: scale(1.2);
  background: #0284c7;
}

.snip-options-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.canvas-hud-bottom-right {
  background: var(--bg-card);
  border: 1.5px solid #0284c7;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  padding: 3px 7px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  white-space: nowrap;
  width: 300px;
  min-width: 300px;
  flex-shrink: 0;
  margin-left: auto;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.canvas-hud-bottom-right:hover {
  border-color: #0369a1;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.16);
}

.hud-hover-seg {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#hudHoverE {
  display: inline-block;
  min-width: 64px;
  text-align: right;
}

#hudHoverCh {
  display: inline-block;
  min-width: 30px;
  text-align: right;
}

#hudHoverY {
  display: inline-block;
  min-width: 70px;
  text-align: right;
}

@media (max-width: 999px) {
  .snip-bottom-dock {
    flex-wrap: wrap;
  }

  .snip-dock-body {
    flex-wrap: wrap;
    border-left: none;
    padding-left: 0;
  }
}

@media (max-width: 720px) {
  .canvas-hud-bottom-right {
    width: 100%;
    min-width: 0;
  }
}

.hud-hover-sep {
  color: var(--text-muted);
  opacity: 0.6;
}

/* Controls & Inputs */
.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11.5px;
}

.input-num {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 7px;
  border-radius: 5px;
  width: 78px;
  text-align: right;
}

.input-num:focus {
  border-color: var(--accent-primary);
  outline: none;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 5px 0;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  cursor: pointer;
  user-select: none;
  color: var(--text-primary);
}

/* Full-Width Dedicated Tab Views (ROI Management & Deconvolution Results) */
.full-tab-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 18px 24px;
  background: var(--bg-panel);
  min-height: 0;
  overflow: hidden;
}

.full-tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1.5px solid #0284c7;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.full-tab-header:hover {
  border-color: #0369a1;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.16);
}

.full-tab-title-group {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
  flex-shrink: 0;
}

.full-tab-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.full-tab-actions {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  flex-shrink: 0;
}

.full-tab-subtitle {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.deconv-controls-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1.5px solid #0284c7;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.deconv-controls-strip:hover {
  border-color: #0369a1;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.16);
}

.deconv-summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
}

.deconv-display-options {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
}

.full-table-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  border: 1.5px solid #0284c7;
  border-radius: 8px;
  background: var(--bg-card);
  min-height: 0;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.full-table-wrapper:hover {
  border-color: #0369a1;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.16);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--bg-panel-elevated);
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-strong);
  z-index: 2;
  white-space: nowrap;
}

.data-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 13px;
  vertical-align: middle;
}

.deconv-full-table th,
.deconv-full-table td,
.roi-management-table th,
.roi-management-table td {
  text-align: center;
}

.data-table tr.deconv-row,
.data-table tr.roi-table-row {
  transition: background 0.12s ease;
}

.data-table tr.deconv-row {
  cursor: pointer;
}

.data-table tr.deconv-row:hover,
.data-table tr.roi-table-row:hover {
  background: var(--bg-card-hover);
}

.roi-name-input {
  flex: 1;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 13px;
  font-family: var(--font-sans);
  padding: 4px 8px;
  border-radius: 5px;
  min-width: 140px;
}

.roi-name-input:focus {
  border-color: var(--accent-primary);
  outline: none;
}

/* 7. Floating Periodic Table & Compact Line Cursor Element Identification Window */
.ptable-floating-win {
  width: 660px;
  max-width: 95vw;
  right: 18px;
  top: 64px;
}

.ptable-fw-body {
  padding: 10px 12px !important;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.compact-cursor-section {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.cursor-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cursor-panel-title {
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.cursor-energy-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 2px 8px;
  border: 1px solid rgba(2, 132, 199, 0.32);
  border-radius: 5px;
  background: rgba(2, 132, 199, 0.10);
  color: var(--accent-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
}

.cursor-controls-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-card);
}

.cursor-control-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 22px;
}

.cursor-control-label {
  flex: 0 0 88px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  text-align: right;
  white-space: nowrap;
}

.cursor-control-input {
  width: 58px;
  padding: 2px 5px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  text-align: right;
}

.cursor-preset-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.cursor-preset-group .btn {
  padding: 2px 6px;
  font-size: 10px;
  line-height: 1.15;
}

.cursor-preset-group .btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

.cursor-control-hint {
  font-size: 9.5px;
  line-height: 1.3;
  color: var(--text-muted);
}

.cursor-control-hint b {
  color: var(--text-secondary);
}

.cursor-filter-row .cursor-series-group {
  margin: 0;
  gap: 7px;
  flex-wrap: nowrap;
}

.cursor-filter-row .checkbox-label {
  font-size: 10px;
  gap: 4px;
}

.cursor-match-count {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.cursor-view-row {
  padding-top: 5px;
  border-top: 1px dashed var(--border-subtle);
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  overflow: hidden;
  background: var(--bg-panel);
}

.segmented-control .seg-btn {
  padding: 3px 9px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}

.segmented-control .seg-btn + .seg-btn {
  border-left: 1px solid var(--border-subtle);
}

.segmented-control .seg-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.segmented-control .seg-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
}

.prob-table-container {
  overflow: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-card);
  height: 185px;
  max-height: 185px;
}

.prob-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10.5px;
}

.prob-table th {
  position: sticky;
  top: 0;
  background: var(--bg-panel-elevated);
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: 0.04em;
  padding: 4px 5px;
  text-align: left;
  border-bottom: 1px solid var(--border-strong);
  z-index: 2;
  white-space: nowrap;
}

.prob-table td {
  padding: 3px 5px;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  line-height: 1.2;
  vertical-align: middle;
}

.prob-table tr:last-child td {
  border-bottom: none;
}

.prob-table tr.candidate-row {
  cursor: pointer;
  transition: background 0.12s ease;
}

.prob-table tr.candidate-row:hover {
  background: var(--bg-card-hover);
}

.prob-table tr.candidate-row.pinned-element {
  background: rgba(16, 185, 129, 0.14);
}

.prob-table td.cand-prob-cell {
  min-width: 76px;
}

.prob-bar-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
}

.prob-bar-track {
  width: 30px;
  height: 5px;
  background: rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  overflow: hidden;
  flex: 0 0 auto;
}

.prob-bar-fill {
  height: 100%;
  border-radius: 999px;
}

.cand-element-cell {
  white-space: nowrap;
}

.cand-z {
  display: inline-block;
  min-width: 16px;
  margin-right: 3px;
  padding: 0 3px;
  border-radius: 3px;
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
  text-align: center;
}

.cand-symbol {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
}

.cand-family-label {
  margin-left: 3px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 8.5px;
}

.cand-esc-tag {
  display: inline-block;
  margin-left: 3px;
  padding: 0 3px;
  border-radius: 3px;
  background: rgba(244, 63, 94, 0.14);
  color: var(--accent-rose);
  font-family: var(--font-sans);
  font-size: 8px;
  font-weight: 700;
}

.rel-int-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 48px;
}

.rel-int-track {
  width: 24px;
  height: 4px;
  background: rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  overflow: hidden;
  flex: 0 0 auto;
}

.rel-int-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-primary);
}

.rel-int-value {
  color: var(--text-secondary);
  font-size: 9.5px;
  white-space: nowrap;
}

.cursor-table-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 12px;
  padding: 0 2px;
  color: var(--text-muted);
  font-size: 9px;
  line-height: 1.3;
}

.cursor-table-legend b {
  color: var(--text-secondary);
  font-weight: 700;
}

.series-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

/* Series tags follow the fitted-group palette (K red, L blue, M violet).
   The K red is softened so it reads as an accent rather than an alarm. */
.series-K {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}
.series-L {
  background: rgba(6, 182, 212, 0.16);
  color: #38bdf8;
}
.series-M {
  background: rgba(168, 85, 247, 0.18);
  color: #c084fc;
}

/* Light-theme series tags: dark text on the pastel shell backgrounds. */
body.theme-light .series-K {
  color: #b91c1c;
}
body.theme-light .series-L {
  color: #0369a1;
}
body.theme-light .series-M {
  color: #7e22ce;
}

/* Interactive Periodic Table inside Floating Window */
.pinned-ptable-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 6px 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.ptable-grid-embedded {
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  gap: 2px;
  margin: 4px 0 6px 0;
}

.ptable-cell {
  height: 24px;
  border-radius: 3.5px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.1s ease;
  position: relative;
  padding: 1px;
}

.ptable-cell:hover {
  border-color: var(--accent-primary);
  transform: scale(1.14);
  z-index: 4;
  background: var(--bg-card-hover);
}

.ptable-cell.pt-candidate {
  border-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.22);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.35);
}

.ptable-cell.pt-pinned {
  border-color: #ffffff;
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.pt-z {
  font-size: 6.5px;
  color: var(--text-secondary);
  line-height: 1;
}

.ptable-cell.pt-pinned .pt-z {
  color: rgba(255, 255, 255, 0.85);
}

.pt-sym {
  font-size: 9px;
  font-weight: 700;
  line-height: 1.05;
}

.ptable-hover-info {
  padding: 4px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  min-height: 24px;
  margin-bottom: 5px;
}

.active-elements-color-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.active-el-color-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px 2px 4px;
  border-radius: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  font-size: 11px;
  font-weight: 600;
}

.active-el-color-input {
  width: 15px;
  height: 15px;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 3px;
}

.active-el-remove {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 11px;
  margin-left: 2px;
}

.active-el-remove:hover {
  color: var(--accent-rose);
}

/* Floating Windows Layer (Per-Spectrum Parameters) */
#floatingWindowsLayer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}

.floating-window {
  position: absolute;
  pointer-events: auto;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 320px;
  max-height: 86vh;
}

.floating-window.focused-window {
  border-color: var(--accent-primary);
}

.fw-header {
  padding: 10px 14px;
  background: var(--bg-panel-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: move;
  user-select: none;
}

.fw-title {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.fw-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fw-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 5px;
}

.fw-close-btn:hover {
  background: rgba(244, 63, 94, 0.2);
  color: var(--accent-rose);
}

.fw-body {
  padding: 14px;
  overflow-y: auto;
  flex: 1;
}

/* Hotmax Spots window */
.hotmax-spots-window {
  display: flex;
  flex-direction: column;
  min-width: 420px;
  min-height: 460px;
}

.hotmax-spots-window .fw-header {
  gap: 8px;
}

.hotmax-spots-window .fw-sub {
  font-size: 9.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.hotmax-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 9px 10px 8px;
  overflow: hidden;
}

.hotmax-kicker {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.55px;
  color: #f59e0b;
  white-space: nowrap;
}

.hotmax-summary {
  font-size: 10px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

#hotmaxSpotCanvas {
  width: 100%;
  height: 210px;
  display: block;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  background: #090d16;
  flex-shrink: 0;
}

.hotmax-list {
  flex: 1;
  min-height: 90px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  background: var(--bg-canvas, #0b111a);
}

.hotmax-row {
  display: grid;
  grid-template-columns: 30px minmax(90px, 1fr) auto 38px;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  font-size: 10px;
  color: var(--text-secondary);
}

.hotmax-row:last-child {
  border-bottom: none;
}

.hotmax-row:hover {
  background: var(--bg-hover, rgba(56, 189, 248, 0.07));
}

.hotmax-row.active {
  background: rgba(245, 158, 11, 0.12);
  box-shadow: inset 2px 0 0 #f59e0b;
}

.hotmax-row-index {
  font-family: var(--font-mono);
  font-weight: 800;
  color: #f59e0b;
  font-size: 9.5px;
}

.hotmax-row-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.hotmax-row-main b {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-primary);
}

.hotmax-row-main small {
  font-size: 8.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.hotmax-row-peaks {
  font-family: var(--font-mono);
  font-size: 9px;
  color: #fbbf24;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.hotmax-map-btn {
  border: 1px solid rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border-radius: 3px;
  font-size: 8.5px;
  font-weight: 700;
  padding: 2px 4px;
  cursor: pointer;
}

.hotmax-map-btn:hover {
  background: rgba(245, 158, 11, 0.22);
}

.hotmax-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 8.5px;
  font-weight: 600;
}

.hotmax-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.hotmax-note {
  font-size: 8.5px;
  line-height: 1.35;
  color: var(--text-muted);
}

/* Parameter Tables inside Per-Spectrum Windows */
.param-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-primary);
  margin: 12px 0 6px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.param-group-title:first-child {
  margin-top: 0;
}

.param-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  background: var(--bg-card);
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.param-table tr {
  border-bottom: 1px solid var(--border-subtle);
}

.param-table tr:last-child {
  border-bottom: none;
}

.param-table td {
  padding: 5px 9px;
}

.param-table td.param-key {
  color: var(--text-secondary);
  width: 46%;
  font-weight: 500;
}

.param-table td.param-val {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-weight: 600;
}

/* Drag-and-Drop Overlay */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 182, 212, 0.18);
  backdrop-filter: blur(6px);
  border: 3px dashed var(--accent-primary);
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drop-overlay.visible {
  display: flex;
}

.drop-box {
  background: var(--bg-panel);
  padding: 28px 42px;
  border-radius: 16px;
  border: 1px solid var(--border-accent);
  text-align: center;
  box-shadow: var(--shadow-lg);
}

/* ARTAX Forbidden Element Styling in Periodic Table */
.ptable-cell.pt-forbidden {
  opacity: 0.42;
  cursor: not-allowed;
  background: rgba(100, 116, 139, 0.15);
}

/* ARTAX Element Options Modal Grid & Legend */
.artax-options-grid {
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  gap: 3px;
  user-select: none;
  padding: 8px;
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

.artax-option-cell {
  height: 29px;
  border-radius: 4px;
  border: 1px solid rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.artax-option-cell:hover {
  transform: scale(1.12);
  z-index: 4;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  border-color: #ffffff;
}

.artax-option-cell .ao-z {
  font-size: 7.5px;
  font-family: var(--font-mono);
  opacity: 0.88;
}

.artax-option-cell .ao-sym {
  font-size: 10.5px;
  font-weight: 800;
}

.artax-grid-placeholder {
  font-size: 8px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.artax-legend-box {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}

.artax-legend-col {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.artax-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}

.artax-swatch {
  width: 28px;
  height: 20px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(15, 23, 42, 0.4);
  flex-shrink: 0;
}

/* ==========================================================================
   Antigravity-Style Appearance & Theme Preferences Modal
   ========================================================================== */
.appearance-win {
  width: 540px !important;
  max-width: 94vw;
}

.appearance-body {
  padding: 18px 22px 22px !important;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 82vh;
  overflow-y: auto;
}

.appearance-intro-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.appearance-intro-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.appearance-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.appearance-section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.appearance-card-group {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  overflow: hidden;
}

.appearance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
}

.appearance-row:last-child {
  border-bottom: none;
}

.appearance-row-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
}

.appearance-seg-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 2px;
  gap: 2px;
}

.appearance-seg-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 4px 11px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.14s ease, color 0.14s ease;
}

.appearance-seg-btn:hover {
  color: var(--text-primary);
}

.appearance-seg-btn.active {
  background: var(--bg-panel-elevated);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
}

.appearance-preset-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.appearance-reset-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background 0.12s ease, color 0.12s ease;
}

.appearance-reset-btn:hover {
  background: var(--bg-panel-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.appearance-select {
  background: var(--bg-panel-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  min-width: 148px;
  cursor: pointer;
  outline: none;
}

.appearance-select:focus {
  border-color: var(--accent-primary);
}

.appearance-color-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 3px 8px 3px 5px;
  min-width: 148px;
}

.appearance-color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  padding: 0;
  cursor: pointer;
  background: transparent;
  flex-shrink: 0;
}

.appearance-color-swatch::-webkit-color-swatch-wrapper {
  padding: 0;
}

.appearance-color-swatch::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

.appearance-hex-prefix {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  user-select: none;
}

.appearance-hex-input {
  width: 72px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  outline: none;
}

/* Shell Grouping Modal Window & Card Styling */
#shellGroupingModalWin {
  border: 1.5px solid #0284c7 !important;
  border-radius: 10px !important;
  box-shadow: 0 8px 32px rgba(2, 132, 199, 0.22), 0 2px 10px rgba(0, 0, 0, 0.1) !important;
}

body.theme-dark #shellGroupingModalWin,
[data-theme="dark"] #shellGroupingModalWin {
  border: 1.5px solid rgba(56, 189, 248, 0.55) !important;
  box-shadow: 0 8px 36px rgba(56, 189, 248, 0.25), 0 2px 12px rgba(0, 0, 0, 0.4) !important;
}

/* ==========================================================================
   8. TAB 4: INTERACTIVE 2D ELEMENTAL MAPPING & HYPERMAPPING SUITE (BCF)
   ========================================================================== */

#mainPaneMapping {
  background: var(--bg-app);
}

.mapping-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  min-height: 0;
  min-width: 0;
  gap: 8px;
  padding: 8px 10px;
  overflow: hidden;
}

/* Header & Metadata Banner */
.mapping-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.mapping-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mapping-brand-badge {
  font-weight: 700;
  font-size: 13px;
  color: var(--accent-primary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.mapping-dataset-name {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text-primary);
}

.mapping-pills-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

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

/* Controls Sub-Toolbar (Unified Oceanic Blue Glow & Perigram) */
.mapping-toolbar {
  display: flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--bg-panel);
  border: 1.5px solid #0284c7;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
  font-size: 11px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mapping-toolbar:hover {
  border-color: #0369a1;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.16);
}

/* Individual Toolbar Section Capsules (Perigrams with Oceanic Blue Glow) */
.mapping-toolbar-section {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  height: 28px;
  border: 1.2px solid rgba(2, 132, 199, 0.45);
  border-radius: 6px;
  background: rgba(2, 132, 199, 0.04);
  box-shadow: 0 0 8px rgba(2, 132, 199, 0.08);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  flex-shrink: 0;
}

.mapping-toolbar-section:hover {
  border-color: rgba(2, 132, 199, 0.8);
  background: rgba(2, 132, 199, 0.08);
  box-shadow: 0 0 12px rgba(2, 132, 199, 0.2);
}

.mapping-toolbar-section .toolbar-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
  white-space: nowrap;
  user-select: none;
}

/* Dropdown Select Elements inside Toolbar Sections */
.mapping-select {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1.2px solid rgba(2, 132, 199, 0.35);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: var(--font-sans);
  outline: none;
  cursor: pointer;
  height: 22px;
  line-height: 20px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.mapping-select:hover {
  border-color: rgba(2, 132, 199, 0.75);
}

.mapping-select:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.25);
}

/* Color Picker inside Colormap Section Capsule */
.mapping-toolbar-section .color-picker-inline {
  width: 24px;
  height: 22px;
  border: 1.2px solid rgba(2, 132, 199, 0.45);
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.mapping-toolbar-section .color-picker-inline:hover {
  border-color: #0284c7;
  box-shadow: 0 0 6px rgba(2, 132, 199, 0.35);
  transform: scale(1.06);
}

/* View Mode Switcher Capsule */
.mapping-section-mode {
  padding: 2px 4px;
  gap: 2px;
}

.mapping-section-mode .btn-group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.mapping-section-mode .btn {
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mapping-section-mode .btn:hover {
  color: var(--text-primary);
  background: rgba(2, 132, 199, 0.08);
}

.mapping-section-mode .btn.active {
  background: #0284c7 !important;
  color: #ffffff !important;
  border-color: #0284c7 !important;
  box-shadow: 0 1px 4px rgba(2, 132, 199, 0.35);
}

/* Multi-Element Composite Toolbar Section Capsule */
.mapping-section-composite {
  gap: 6px;
  padding: 2px 6px;
}

/* Pixel Method Capsule (Gross / RoI Net / Deconv) */
.mapping-section-method {
  gap: 6px;
  padding: 2px 6px;
}

.mapping-section-method .mapping-section-mode {
  padding: 0;
}

.mapping-section-method #btnMappingSumDeconv {
  white-space: nowrap;
  font-weight: 600;
}

.meta-pill.pill-deconv {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  color: #c084fc;
  background: rgba(168, 85, 247, 0.14);
  border: 1px solid rgba(168, 85, 247, 0.42);
  white-space: nowrap;
}

body.theme-dark .meta-pill.pill-deconv,
[data-theme="dark"] .meta-pill.pill-deconv {
  color: #d8b4fe;
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(192, 132, 252, 0.55);
}

/* Compact circular info affordance used by the Deconv fit-source explanations */
.deconv-info-btn {
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.55);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.deconv-info-btn:hover,
.deconv-info-btn:focus-visible {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  background: rgba(2, 132, 199, 0.1);
  outline: none;
}

/* Visible fit-source badge in the Deconvolution Results tab header */
.deconv-fit-source-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.deconv-fit-source-pill {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: help;
  user-select: none;
}

.deconv-fit-source-pill.pixel-sum {
  color: #c084fc;
  background: rgba(168, 85, 247, 0.14);
  border-color: rgba(168, 85, 247, 0.45);
}

.deconv-fit-source-pill.header-sum {
  color: #38bdf8;
  background: rgba(2, 132, 199, 0.1);
  border-color: rgba(2, 132, 199, 0.45);
}

.deconv-fit-source-pill.no-fit {
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.3);
}

body.theme-dark .deconv-fit-source-pill.pixel-sum,
[data-theme="dark"] .deconv-fit-source-pill.pixel-sum {
  color: #d8b4fe;
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(192, 132, 252, 0.55);
}

body.theme-dark .deconv-fit-source-pill.header-sum,
[data-theme="dark"] .deconv-fit-source-pill.header-sum {
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.5);
}

/* Rich hover card: explains pixel-sum vs header-sum deconvolution fits */
.rich-info-hover-card {
  position: fixed;
  z-index: 1000001;
  display: none;
  pointer-events: auto;
  width: min(390px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(2, 132, 199, 0.62);
  background: var(--bg-panel-elevated, #0f172a);
  color: var(--text-primary);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.42), 0 3px 10px rgba(0, 0, 0, 0.28);
  font-family: var(--font-sans);
  font-size: 11.5px;
  line-height: 1.5;
  text-align: left;
}

.rich-info-title {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--accent-primary);
  margin-bottom: 7px;
}

.rich-info-section {
  margin: 7px 0;
}

.rich-info-section:first-of-type {
  margin-top: 0;
}

.rich-info-section:last-child {
  margin-bottom: 0;
}

.rich-info-kicker {
  display: block;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.55px;
  text-transform: uppercase;
  color: var(--accent-amber, #f59e0b);
  margin-bottom: 2px;
}

.rich-info-hover-card b {
  color: var(--text-primary);
  font-weight: 800;
}

.rich-info-hover-card code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent-primary);
  background: rgba(2, 132, 199, 0.1);
  padding: 0 3px;
  border-radius: 3px;
}

.rich-info-footnote {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--border-subtle);
  font-size: 10.5px;
  color: var(--text-secondary);
}

/* Dark Theme Overrides for Mapping Toolbar & Capsules */
body.theme-dark .mapping-toolbar-section,
[data-theme="dark"] .mapping-toolbar-section {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.05);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.08);
}

body.theme-dark .mapping-toolbar-section:hover,
[data-theme="dark"] .mapping-toolbar-section:hover {
  border-color: rgba(56, 189, 248, 0.8);
  background: rgba(56, 189, 248, 0.09);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.2);
}

body.theme-dark .mapping-toolbar-section .toolbar-label,
[data-theme="dark"] .mapping-toolbar-section .toolbar-label {
  color: #94a3b8;
}

body.theme-dark .mapping-select,
[data-theme="dark"] .mapping-select {
  border-color: rgba(56, 189, 248, 0.35);
  background: #0f172a;
}

body.theme-dark .mapping-select:hover,
[data-theme="dark"] .mapping-select:hover {
  border-color: rgba(56, 189, 248, 0.75);
}

body.theme-dark .mapping-select:focus,
[data-theme="dark"] .mapping-select:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

body.theme-dark .mapping-toolbar-section .color-picker-inline,
[data-theme="dark"] .mapping-toolbar-section .color-picker-inline {
  border-color: rgba(56, 189, 248, 0.45);
}

body.theme-dark .mapping-section-mode .btn:hover,
[data-theme="dark"] .mapping-section-mode .btn:hover {
  background: rgba(56, 189, 248, 0.1);
  color: #f1f5f9;
}

body.theme-dark .mapping-section-mode .btn.active,
[data-theme="dark"] .mapping-section-mode .btn.active {
  background: #0284c7 !important;
  color: #ffffff !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 1px 6px rgba(56, 189, 248, 0.4);
}

/* Viewport 3-Column Grid: Maximized Center Map Area */
.mapping-viewport-grid {
  display: grid;
  grid-template-columns: 224px minmax(460px, 1fr) 250px;
  gap: 8px;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

@media (max-width: 1280px) {
  .mapping-viewport-grid {
    grid-template-columns: 212px 1fr 230px;
  }
}

.mapping-left-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.mapping-panel {
  background: var(--bg-panel);
  border: 1.5px solid #0284c7;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mapping-panel:hover {
  border-color: #0369a1;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.16);
}

.mapping-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-panel-elevated);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.mapping-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

/* Center Panel: Map Header Right Alignment */
.mapping-main-panel .mapping-panel-header {
  justify-content: flex-end;
  padding: 5px 10px;
}

/* Specimen Atlas control bar directly above the image viewport */
.mapping-atlas-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 9px;
  min-height: 34px;
  padding: 4px 9px;
  background: linear-gradient(180deg, var(--bg-panel-elevated), var(--bg-panel));
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.atlas-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.45px;
  text-transform: uppercase;
  color: var(--accent-primary);
  white-space: nowrap;
  user-select: none;
}

.atlas-brand-mark {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(135deg, #38bdf8 0%, #a855f7 100%);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.65);
  transform: rotate(45deg);
}

.atlas-control {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
}

.atlas-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.25px;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
}

.atlas-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.atlas-toggle input[type="checkbox"] {
  width: 12px;
  height: 12px;
  margin: 0;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.atlas-select {
  height: 22px !important;
  padding: 1px 5px !important;
  font-size: 10.5px !important;
  max-width: 118px;
}

.atlas-slider {
  width: 92px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.atlas-value {
  min-width: 34px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: right;
}

.btn-icon-atlas {
  width: 24px;
  min-width: 24px;
  padding: 2px 0 !important;
  font-size: 12px !important;
  line-height: 1;
}

.atlas-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Atlas deck canvas */
.mapping-atlas-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 5;
  background: #05070c;
  cursor: grab;
  touch-action: none;
}

.mapping-canvas-container.atlas-active .mapping-atlas-canvas {
  cursor: grab;
}

.mapping-canvas-container.atlas-active .mapping-floating-toolbox {
  display: none;
}

.mapping-canvas-container.atlas-active .mapping-canvas-wrapper {
  left: 6px;
  right: 6px;
  cursor: grab;
  border-color: rgba(56, 189, 248, 0.35);
}

.mapping-canvas-container.atlas-active .mapping-hud,
.mapping-canvas-container.atlas-active .mapping-colorbar-container,
.mapping-canvas-container.atlas-active .mapping-composite-legend {
  display: none !important;
}

/* Atlas owns photo blending and grid display; hide the Solo-only map toggles. */
.mapping-main-panel.atlas-mode #lblMapGridToggle,
.mapping-main-panel.atlas-mode #lblMapPhotoBlendToggle {
  display: none !important;
}

/* Atlas registration / drape popovers */
.atlas-popover {
  position: absolute;
  top: 78px;
  right: 14px;
  z-index: 60;
  width: 332px;
  max-width: calc(100% - 28px);
  background: var(--bg-panel-elevated, var(--bg-panel));
  border: 1.5px solid rgba(2, 132, 199, 0.65);
  border-radius: 9px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.atlas-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: rgba(2, 132, 199, 0.1);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-primary);
}

.atlas-popover-close {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  padding: 0 2px;
}

.atlas-popover-close:hover {
  color: var(--accent-danger, #ef4444);
}

.atlas-popover-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}

.atlas-popover-hint {
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.atlas-field {
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  color: var(--text-secondary);
}

.atlas-field > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  white-space: nowrap;
}

.atlas-field b {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-weight: 700;
}

.atlas-field .atlas-slider {
  width: 100%;
}

.atlas-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(2, 132, 199, 0.035);
}

/* Dark theme polish */
body.theme-dark .mapping-atlas-bar,
[data-theme="dark"] .mapping-atlas-bar {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.055), rgba(15, 23, 42, 0.2));
  border-bottom-color: rgba(56, 189, 248, 0.16);
}

body.theme-dark .atlas-popover,
[data-theme="dark"] .atlas-popover {
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.62);
}

/* Specimen Atlas Panel Slot Dropdown / Reorder Popover */
.atlas-panel-popover {
  position: fixed;
  z-index: 10000;
  width: 260px;
  max-height: 380px;
  background: var(--bg-panel-elevated, #0f172a);
  border: 1.5px solid rgba(56, 189, 248, 0.65);
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65), 0 0 16px rgba(56, 189, 248, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: atlasMenuFade 0.15s ease-out;
}

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

.atlas-panel-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: rgba(2, 132, 199, 0.18);
  border-bottom: 1px solid rgba(56, 189, 248, 0.25);
  font-size: 11px;
  font-weight: 800;
  color: var(--text-primary, #f8fafc);
}

.atlas-panel-popover-move-row {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.atlas-panel-popover-move-row button {
  flex: 1;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 6px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #38bdf8;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.atlas-panel-popover-move-row button:hover:not(:disabled) {
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  color: #ffffff;
}

.atlas-panel-popover-move-row button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.atlas-panel-popover-list {
  flex: 1;
  overflow-y: auto;
  max-height: 290px;
  padding: 4px;
}

.atlas-panel-popover-section-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-secondary, #94a3b8);
  padding: 6px 8px 3px 8px;
}

.atlas-panel-popover-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
  cursor: pointer;
  transition: background 0.1s;
}

.atlas-panel-popover-item:hover {
  background: rgba(56, 189, 248, 0.15);
  color: #ffffff;
}

.atlas-panel-popover-item.active {
  background: rgba(2, 132, 199, 0.3);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #38bdf8;
}

.atlas-panel-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.btn-tray-composite {
  background: rgba(168, 85, 247, 0.15) !important;
  border: 1px solid rgba(168, 85, 247, 0.45) !important;
  color: #d8b4fe !important;
  font-weight: 700 !important;
  cursor: grab !important;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px !important;
}

.btn-tray-composite:hover {
  background: rgba(168, 85, 247, 0.3) !important;
  border-color: #c084fc !important;
  color: #f3e8ff !important;
}

.btn-tray-composite .tray-composite-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f43f5e, #10b981, #38bdf8);
  flex-shrink: 0;
}

.btn-tray-composite.is-dragging {
  opacity: 0.5;
  outline: 2px dashed #c084fc;
}

/* Right Panel: Mapping Regions Header Refinements */
.mapping-features-panel .mapping-panel-header {
  padding: 6px 8px;
  gap: 6px;
  min-width: 0;
}

.mapping-features-panel .mapping-panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.mapping-features-panel #lblFeaturesPanelTitle {
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  flex-shrink: 0;
}

.mapping-features-panel #lblFeaturesCountBadge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  flex-shrink: 0;
  min-width: 18px;
  text-align: center;
  line-height: 14px;
  white-space: nowrap;
}

.mapping-features-panel .mapping-panel-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.mapping-features-panel #btnClearAllFeatures {
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 16px;
}

/* Left: Camera Overview Panel */
.mapping-camera-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.mapping-camera-panel .mapping-panel-header {
  padding: 5px 8px;
  gap: 4px;
}

.mapping-camera-panel .mapping-panel-title {
  min-width: 0;
  flex: 1 1 auto;
}

.mapping-camera-panel .mapping-panel-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.camera-zoom-pill {
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-weight: 700;
  line-height: 14px;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}

.mapping-camera-body {
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.camera-canvas-wrapper {
  width: 100%;
  aspect-ratio: 930 / 792;
  background: #000000;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
  cursor: grab;
  user-select: none;
}

.camera-canvas-wrapper.panning {
  cursor: grabbing;
}

#mappingCameraCanvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Display & Intensity Suite Panel (Area 2) */
.mapping-intensity-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mapping-intensity-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.intensity-control-group {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}

.intensity-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.intensity-group-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.intensity-group-badge {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  font-weight: 600;
  font-family: var(--font-mono);
}

.intensity-select {
  width: 100%;
}

.intensity-field-hint {
  font-size: 9.5px;
  color: var(--text-muted);
  line-height: 1.35;
}

.intensity-slider-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.intensity-slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
}

.intensity-slider-label {
  color: var(--text-secondary);
  font-weight: 600;
}

.intensity-slider-readout {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 10px;
  color: var(--text-primary);
}

.intensity-slider {
  width: 100%;
  margin: 1px 0;
}

.intensity-range-preview {
  height: 4px;
  border-radius: 2px;
  background: var(--border-subtle);
  position: relative;
  overflow: hidden;
  margin-top: 3px;
}

.intensity-range-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0%;
  width: 100%;
  background: linear-gradient(90deg, #0284c7, #38bdf8, #00ff66);
  border-radius: 2px;
  transition: left 0.1s ease, width 0.1s ease;
}

.intensity-action-btn {
  width: 100%;
  justify-content: center;
  gap: 5px;
  font-weight: 600;
  padding: 3px 6px;
}

.custom-bands-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 90px;
  overflow-y: auto;
}

.custom-band-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border-subtle);
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.custom-band-chip:hover {
  border-color: var(--accent-primary);
  background: rgba(56, 189, 248, 0.08);
}

.custom-band-chip.active {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.16);
}

.custom-band-chip-left {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}

.custom-band-chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.custom-band-chip-name {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-band-chip-energy {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-secondary);
}

.custom-band-chip-remove {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 0 2px;
  line-height: 1;
}

.custom-band-chip-remove:hover {
  color: #ef4444;
}

/* Center: Main Elemental Map Panel */
.mapping-main-panel {
  position: relative;
}

.mapping-canvas-container {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  background: var(--bg-canvas);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: crosshair;
  user-select: none;
}

.mapping-canvas-container.panning,
.mapping-canvas-container.panning * {
  cursor: grabbing !important;
}

.mapping-canvas-container.pan-mode,
.mapping-canvas-container.pan-mode * {
  cursor: grab !important;
}

.mapping-canvas-container.eraser-mode,
.mapping-canvas-container.eraser-mode * {
  cursor: crosshair !important;
}

/* In-Place Spectrum View Container */
.mapping-center-spectrum-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg-canvas);
  position: relative;
  overflow: hidden;
}

.mapping-center-spec-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  font-size: 11px;
  flex-wrap: wrap;
}

.mapping-center-spec-canvas-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-canvas);
}

#mappingCenterSpectrumCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.mapping-canvas-wrapper {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 56px;
  right: 56px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: #000000;
}

#mappingMainCanvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#mappingOverlayCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.mapping-hud {
  position: absolute;
  bottom: 12px;
  left: 14px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 7px;
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  user-select: none;
}

body.theme-light .mapping-hud,
[data-theme="light"] .mapping-hud {
  background: rgba(255, 255, 255, 0.94);
  color: #0f172a;
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.hud-sep {
  opacity: 0.4;
}

/* Floating Vertical Toolbox on Left of Center Canvas */
.mapping-floating-toolbox {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(15, 23, 42, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 5px 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  z-index: 10;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  user-select: none;
}

body.theme-light .mapping-floating-toolbox,
[data-theme="light"] .mapping-floating-toolbox {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
}

.toolbox-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.toolbox-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 2px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.toolbox-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.22);
}

body.theme-light .toolbox-btn:hover,
[data-theme="light"] .toolbox-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
  border-color: rgba(0, 0, 0, 0.12);
}

.toolbox-btn.active {
  background: var(--accent-primary);
  color: #ffffff !important;
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.45);
}

.toolbox-icon {
  font-size: 15px;
  line-height: 1;
}

.toolbox-label {
  display: none;
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  padding: 4px 8px;
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.toolbox-btn:hover .toolbox-label {
  display: block;
}

body.theme-light .toolbox-label,
[data-theme="light"] .toolbox-label {
  background: rgba(255, 255, 255, 0.97);
  border-color: rgba(0, 0, 0, 0.15);
  color: #0f172a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
}

.toolbox-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.toolbox-btn:disabled:hover {
  background: transparent;
  border-color: transparent;
}

.toolbox-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.15);
  margin: 3px 2px;
}

body.theme-light .toolbox-divider,
[data-theme="light"] .toolbox-divider {
  background: rgba(0, 0, 0, 0.12);
}

.toolbox-badge {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1;
  margin-top: 2px;
  opacity: 0.95;
}

.mapping-colorbar-container {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: rgba(15, 23, 42, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 7px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  z-index: 5;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  user-select: none;
  cursor: help;
  transition: border-color 0.15s ease;
}

body.theme-light .mapping-colorbar-container,
[data-theme="light"] .mapping-colorbar-container {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.mapping-colorbar-container:hover {
  border-color: var(--accent-primary);
}

.colorbar-metric {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.colorbar-sub {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

#mappingColorbarCanvas {
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
}

.colorbar-val {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Right: Spatial Regions & Features Panel */
.mapping-features-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.mapping-features-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.mapping-feature-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-panel-elevated);
  border: 1px solid var(--border-subtle);
  border-left: 3.5px solid #00ff66;
  border-radius: 6px;
  transition: all 0.15s ease;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  min-width: 0;
}

.mapping-feature-card:hover {
  border-color: #00ff66;
  background: var(--bg-card);
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.15);
}

.mapping-feature-card.active {
  border-color: #00ff66;
  background: rgba(0, 255, 102, 0.05);
  box-shadow: 0 0 14px rgba(0, 255, 102, 0.25);
}

.mapping-feature-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.mapping-feature-tag {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 255, 102, 0.15);
  color: #00ff66;
  border: 1px solid rgba(0, 255, 102, 0.45);
  flex-shrink: 0;
}

.mapping-feature-name-input {
  flex: 1 1 auto;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 5px;
  min-width: 0;
  transition: all 0.15s ease;
}

.mapping-feature-name-input:hover {
  border-color: var(--border-subtle);
  background: var(--bg-input);
}

.mapping-feature-name-input:focus {
  border-color: #00ff66;
  background: var(--bg-input);
  outline: none;
  box-shadow: 0 0 6px rgba(0, 255, 102, 0.35);
}

.mapping-feature-card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.feature-action-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.feature-action-btn svg {
  display: block;
  stroke: currentColor;
}

.feature-action-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.feature-action-btn.btn-toggle-vis:hover {
  color: #00ff66;
  background: rgba(0, 255, 102, 0.12);
}

.feature-action-btn.btn-delete:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

.mapping-metric-label {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mapping-metric-val {
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
}

.mapping-metric-sub {
  color: var(--text-muted);
  font-size: 9.5px;
  font-family: var(--font-mono);
}

.mapping-metric-sep {
  color: var(--border-medium);
  font-size: 9px;
  padding: 0 1px;
}

/* MAX diagnostic spectrum affordances */
.btn-max-spectrum {
  color: #f59e0b !important;
  border: 1px solid rgba(245, 158, 11, 0.55) !important;
  background: rgba(245, 158, 11, 0.1) !important;
  font-weight: 800 !important;
  letter-spacing: 0.2px;
}

.btn-max-spectrum:hover {
  color: #fbbf24 !important;
  border-color: rgba(251, 191, 36, 0.85) !important;
  background: rgba(245, 158, 11, 0.18) !important;
}

.btn-max-spectrum:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Full-dataset physical BCF rotation export */
.btn-save-rotated-bcf {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #22d3ee !important;
  border: 1px solid rgba(34, 211, 238, 0.5) !important;
  background: rgba(34, 211, 238, 0.09) !important;
  font-weight: 700 !important;
  white-space: nowrap;
}

.btn-save-rotated-bcf:hover:not(:disabled) {
  color: #67e8f9 !important;
  border-color: rgba(103, 232, 249, 0.9) !important;
  background: rgba(34, 211, 238, 0.17) !important;
}

.btn-save-rotated-bcf:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

@media (max-width: 900px) {
  .btn-save-rotated-bcf .btn-label-full {
    display: none;
  }

  .btn-save-rotated-bcf .btn-label-short {
    display: inline;
  }

  #mappingMapHeaderActions {
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 4px;
  }
}

#btnBcfMaxSpectrum {
  margin-left: auto;
  flex-shrink: 0;
}

.badge-max {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.5);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-feature-save-spx {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
}

.btn-feature-save-spx:hover {
  background: var(--bg-hover);
  border-color: #38bdf8;
  color: #38bdf8;
}

.btn-feature-save-bcf {
  background: rgba(0, 255, 102, 0.12);
  border: 1px solid rgba(0, 255, 102, 0.5);
  color: #00ff66;
  font-weight: 700;
}

.btn-feature-save-bcf:hover {
  background: rgba(0, 255, 102, 0.22);
  border-color: #00ff66;
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.3);
}

.mapping-feature-metrics {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
}

.mapping-feature-metrics-row {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mapping-feature-buttons {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.mapping-feature-buttons .btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 4px 6px;
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}

.mapping-feature-buttons .btn .xrf-icon {
  flex-shrink: 0;
}

/* Empty State */
.mapping-features-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 14px;
  gap: 8px;
  color: var(--text-muted);
}

.features-empty-icon {
  font-size: 28px;
  opacity: 0.6;
}

.features-empty-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.features-empty-desc {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-muted);
}

/* Vertical Splitter Handle */
.mapping-splitter {
  height: 8px;
  min-height: 8px;
  cursor: row-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: background 0.15s ease;
  user-select: none;
  margin: -2px 0;
  z-index: 20;
}

.mapping-splitter:hover,
.mapping-splitter.dragging {
  background: var(--accent-subtle);
}

.splitter-handle-bar {
  width: 44px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  transition: background 0.15s ease, width 0.15s ease;
}

.mapping-splitter:hover .splitter-handle-bar,
.mapping-splitter.dragging .splitter-handle-bar {
  background: var(--accent-primary);
  width: 58px;
}

/* Bottom: Element Thumbnail Carousel Tray */
.mapping-carousel-tray {
  height: 155px;
  min-height: 110px;
  max-height: 550px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  padding: 6px 12px;
  gap: 6px;
  flex-shrink: 0;
  transition: height 0.05s ease-out;
}

.carousel-tray-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.carousel-tray-title {
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10.5px;
}

.carousel-tray-sub {
  font-size: 10.5px;
  color: var(--text-muted);
}

.mapping-element-gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  align-items: center;
  padding: 2px 4px 6px 4px;
}

.mapping-element-gallery.multi-row-grid {
  flex-wrap: wrap;
  overflow-y: auto;
  overflow-x: hidden;
  align-content: flex-start;
  align-items: flex-start;
  padding-right: 4px;
}

.mapping-gallery-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 4px 6px 6px 6px;
  margin-top: 2px;
  margin-bottom: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 76px;
  flex-shrink: 0;
  user-select: none;
}

.mapping-gallery-card:hover {
  border-color: var(--accent-primary);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

.mapping-gallery-card.active {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-primary);
  background: var(--bg-card-hover);
}

.mapping-gallery-card.is-dragging {
  opacity: 0.45;
  outline: 2px dashed var(--accent-primary, #38bdf8);
}

.gallery-card-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.7);
  color: #f87171;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
  border: 1px solid rgba(255, 255, 255, 0.15);
  z-index: 5;
}

.mapping-gallery-card:hover .gallery-card-remove {
  opacity: 0.85;
}

.gallery-card-remove:hover {
  opacity: 1;
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

.gallery-card-thumb {
  max-width: 160px;
  max-height: 110px;
  border-radius: 4px;
  background: #000000;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  margin-bottom: 4px;
  border: 1px solid var(--border-subtle);
  transition: width 0.15s ease, height 0.15s ease;
}

/* Method Badge on Gallery Thumbnail */
.gallery-card-method-pill {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 8.5px;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  pointer-events: auto;
  cursor: help;
  z-index: 4;
}

.gallery-card-method-pill.pill-gross {
  background: rgba(16, 185, 129, 0.95);
  color: #ffffff;
  border: 1px solid rgba(110, 231, 183, 0.85);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.gallery-card-method-pill.pill-roi-net,
.gallery-card-method-pill.pill-line-net {
  background: rgba(234, 179, 8, 0.95);
  color: #1e293b;
  border: 1px solid rgba(254, 240, 138, 0.9);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.gallery-card-method-pill.pill-custom-roi,
.gallery-card-method-pill.pill-roi {
  background: rgba(139, 92, 246, 0.95);
  color: #ffffff;
  border: 1px solid rgba(196, 181, 253, 0.85);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.gallery-card-method-pill.pill-tic {
  background: rgba(56, 189, 248, 0.95);
  color: #0f172a;
  border: 1px solid rgba(186, 230, 253, 0.85);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.gallery-card-method-pill.pill-deconv {
  background: rgba(139, 92, 246, 0.95);
  color: #ffffff;
  border: 1px solid rgba(196, 181, 253, 0.85);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.gallery-card-method-pill.pill-element {
  background: rgba(100, 116, 139, 0.95);
  color: #ffffff;
  border: 1px solid rgba(203, 213, 225, 0.85);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

/* Inline Color Picker in Toolbar */
.color-picker-inline {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 26px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 4px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.color-picker-inline:hover {
  transform: scale(1.08);
  border-color: var(--accent-primary);
}

.color-picker-inline::-webkit-color-swatch-wrapper {
  padding: 1px;
}

.color-picker-inline::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

.gallery-card-info {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  font-size: 11.5px;
  padding-top: 3px;
  padding-left: 2px;
  padding-right: 2px;
}

.mapping-carousel-tray.multi-element-mode .gallery-card-info {
  justify-content: space-between;
}

.gallery-card-left {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  position: relative;
}

.gallery-card-color-btn {
  width: 13px;
  height: 13px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: #38bdf8;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.gallery-card-color-btn:hover {
  transform: scale(1.35);
  border-color: #ffffff;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.6);
}

/* Modern HSV color-wheel popover */
.color-palette-popover {
  position: fixed;
  display: block;
  width: 258px;
  max-height: min(82vh, 660px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  background: var(--bg-panel-elevated, #1e293b);
  border: 1px solid var(--border-strong, #475569);
  border-radius: 12px;
  padding: 10px 12px 9px;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.66), 0 3px 10px rgba(0, 0, 0, 0.42);
  z-index: 99999;
  user-select: none;
  transform-origin: center top;
}

.color-palette-popover.is-applying {
  animation: palette-pop-out 0.18s ease forwards;
  pointer-events: none;
}

@keyframes palette-pop-out {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-4px) scale(0.97); }
}

body.theme-light .color-palette-popover,
[data-theme="light"] .color-palette-popover {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.18), 0 3px 10px rgba(0, 0, 0, 0.08);
}

.palette-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: 17px;
  margin-bottom: 5px;
}

.palette-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-primary);
}

.palette-wheel-wrap {
  position: relative;
  width: 216px;
  height: 216px;
  margin: 0 auto 6px;
}

.palette-wheel-canvas {
  display: block;
  width: 216px;
  height: 216px;
  border-radius: 50%;
  cursor: crosshair;
  touch-action: none;
  outline: none;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.35));
}

.palette-wheel-canvas:focus-visible {
  box-shadow: 0 0 0 2px #0f172a, 0 0 0 4px #38bdf8;
}

.palette-wheel-marker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.55);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: left 0.12s ease-out, top 0.12s ease-out, background-color 0.12s ease-out;
}

.palette-wheel-canvas.is-dragging + .palette-wheel-marker {
  transition: none;
}

.palette-wheel-marker.is-pulsing {
  animation: palette-marker-pop 0.32s ease-out;
}

@keyframes palette-marker-pop {
  0% {
    transform: translate(-50%, -50%) scale(0.7);
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7), 0 2px 6px rgba(0, 0, 0, 0.55);
  }
  55% {
    transform: translate(-50%, -50%) scale(1.35);
    box-shadow: 0 0 0 7px rgba(56, 189, 248, 0.22), 0 2px 6px rgba(0, 0, 0, 0.55);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 0 0 transparent, 0 2px 6px rgba(0, 0, 0, 0.55);
  }
}

.palette-wheel-status {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 25px;
  margin-bottom: 3px;
}

.palette-wheel-preview {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.palette-wheel-preview.is-pulsing {
  animation: palette-preview-pop 0.32s ease-out;
}

@keyframes palette-preview-pop {
  0% { transform: scale(0.82); }
  55% { transform: scale(1.18); box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.18); }
  100% { transform: scale(1); }
}

.palette-wheel-hex {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.palette-wheel-apply {
  flex: 0 0 auto;
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid rgba(56, 189, 248, 0.55);
  background: rgba(14, 165, 233, 0.18);
  color: #7dd3fc;
  font: inherit;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}

.palette-wheel-apply:hover:not(:disabled) {
  background: rgba(14, 165, 233, 0.3);
  border-color: #38bdf8;
  transform: translateY(-1px);
}

.palette-wheel-apply:disabled {
  opacity: 0.55;
  cursor: wait;
}

.palette-wheel-brightness {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.35px;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
}

.palette-wheel-brightness input[type="range"] {
  flex: 1;
  min-width: 0;
  height: 4px;
  margin: 0;
  accent-color: #38bdf8;
  cursor: pointer;
}

.palette-wheel-value {
  width: 31px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0;
  color: var(--text-secondary);
}

.palette-preset-grid {
  display: grid;
  grid-template-columns: repeat(6, 26px);
  gap: 7px;
  justify-content: center;
  padding: 7px 0 8px;
  border-top: 1px solid var(--border-subtle);
}

.palette-color-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.palette-color-btn:hover {
  transform: scale(1.18);
  border-color: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.65);
}

.palette-color-btn.active {
  transform: scale(1.1);
  border-color: #ffffff;
  box-shadow: 0 0 0 2px var(--bg-panel-elevated, #1e293b), 0 0 0 4px #38bdf8;
}

body.theme-light .palette-color-btn.active,
[data-theme="light"] .palette-color-btn.active {
  border-color: #0f172a;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #0284c7;
}

body.theme-light .palette-wheel-preview,
[data-theme="light"] .palette-wheel-preview {
  border-color: rgba(15, 23, 42, 0.25);
}

body.theme-light .palette-wheel-hex,
[data-theme="light"] .palette-wheel-hex {
  color: #475569;
}

body.theme-light .palette-wheel-apply,
[data-theme="light"] .palette-wheel-apply {
  color: #0369a1;
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.4);
}

.palette-custom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding-top: 7px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-subtle);
}

.palette-custom-input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.palette-custom-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.palette-custom-input::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.mapping-gallery-add-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 82px;
  min-height: 58px;
  flex-shrink: 0;
  color: var(--text-secondary);
  font-size: 11px;
  gap: 4px;
}

.mapping-gallery-add-card:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

.gallery-card-symbol {
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-sans);
  /* Long editable ROI names stay on one line; cards grow to fit, with an
     ellipsis only for extreme labels. The full name remains in the tooltip. */
  white-space: nowrap;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-card-energy {
  display: none !important;
}

/* Empty State */
.mapping-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  background: var(--bg-panel);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  margin: 16px;
}

.mapping-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.8;
}

.mapping-empty-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.mapping-empty-text {
  max-width: 520px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Multi-Element Mode Toolbar Slot: Stable footprint to guarantee ZERO layout shift */
.mapping-mode-controls-slot {
  min-width: 440px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Phase 3: Multi-Element Composite Overlay & Modal Styles */
#compositeChannelsModal {
  border: 1.5px solid rgba(2, 132, 199, 0.55) !important;
  box-shadow: 0 0 20px rgba(2, 132, 199, 0.18), 0 12px 32px rgba(0, 0, 0, 0.45) !important;
}

.mapping-composite-legend {
  position: absolute;
  top: 12px;
  left: 56px;
  max-width: calc(100% - 76px);
  overflow-x: auto;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f8fafc;
  border: 1.5px solid rgba(2, 132, 199, 0.5);
  border-radius: 6px;
  padding: 5px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  z-index: 10;
  box-shadow: 0 0 14px rgba(2, 132, 199, 0.14), 0 4px 12px rgba(0, 0, 0, 0.25);
  user-select: none;
}

body.theme-light .mapping-composite-legend,
[data-theme="light"] .mapping-composite-legend {
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  border: 1.5px solid rgba(2, 132, 199, 0.5);
  box-shadow: 0 0 14px rgba(2, 132, 199, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Gallery Card Multi-Element Overlay Toggle & Active Perigram */
.mapping-gallery-card.in-overlay {
  border: 1.5px solid rgba(2, 132, 199, 0.7) !important;
  box-shadow: 0 0 12px rgba(2, 132, 199, 0.25) !important;
}

.gallery-card-overlay-toggle {
  display: none !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 0;
  padding: 0;
}

.mapping-carousel-tray.multi-element-mode .gallery-card-overlay-toggle {
  display: inline-flex !important;
}

.gallery-card-overlay-toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border-subtle);
  border-radius: 3px;
  background: var(--bg-canvas);
  cursor: pointer;
  position: relative;
  outline: none;
  transition: all 0.15s ease;
  margin: 0;
}

.gallery-card-overlay-toggle input[type="checkbox"]:hover {
  border-color: rgba(2, 132, 199, 0.8);
}

.gallery-card-overlay-toggle input[type="checkbox"]:checked {
  background: #0284c7;
  border-color: #0284c7;
}

.gallery-card-overlay-toggle input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 3.5px;
  top: 1px;
  width: 3.5px;
  height: 7px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.composite-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.composite-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.composite-channel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg-panel-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
}

.composite-channel-color-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

/* --- High-Resolution Fullscreen / Lightbox Modal --- */
.modal-backdrop,
#mappingLightboxModal {
  position: fixed !important;
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(10, 15, 29, 0.92) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
  z-index: 999999 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 1.5vh 1.5vw;
}

.modal-backdrop.modal-hidden,
#mappingLightboxModal.modal-hidden {
  display: none !important;
}

.mapping-lightbox-window {
  position: relative;
  width: 96vw;
  height: 94vh;
  max-width: 1800px;
  max-height: 96vh;
  background: var(--bg-panel, #0f172a);
  border: 1px solid var(--border-strong, #334155);
  border-radius: 12px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lightbox-canvas-container {
  flex: 1;
  width: 100%;
  height: 100%;
  position: relative;
  background: #000000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: crosshair;
  user-select: none;
  min-height: 250px;
}

.lightbox-canvas-container.panning {
  cursor: grabbing !important;
}

.lightbox-canvas-container canvas {
  display: block;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.9);
}

.modal-close-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary, #94a3b8);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: all 0.15s ease;
}

.modal-close-btn:hover {
  background: rgba(244, 63, 94, 0.2);
  border-color: rgba(244, 63, 94, 0.4);
  color: #fb7185;
}

/* Bundled Demo Files modal */
.demo-files-window {
  width: min(880px, 94vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel, #0f172a);
  border: 1px solid var(--border-strong, #334155);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.72);
  overflow: hidden;
}

.demo-files-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px 10px;
  background: var(--bg-panel-elevated);
  border-bottom: 1px solid var(--border-subtle);
}

.demo-files-title {
  margin: 0 0 3px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.demo-beta-pill {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.7px;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 999px;
  padding: 1px 6px;
}

.demo-files-subtitle {
  font-size: 10.5px;
  color: var(--text-secondary);
}

.demo-files-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px 10px;
}

.demo-files-intro {
  margin: 0 0 10px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.demo-files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 8px;
}

.demo-card {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-panel-elevated);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.demo-card:hover {
  border-color: rgba(56, 189, 248, 0.6);
}

.demo-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.demo-card-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.demo-card-kind {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 800;
  color: var(--accent-primary);
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 1px 5px;
  border-radius: 999px;
  flex-shrink: 0;
}

.demo-card-meta {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
}

.demo-card-desc {
  font-size: 9.5px;
  color: var(--text-secondary);
  line-height: 1.35;
  min-height: 26px;
}

.demo-card-load {
  align-self: flex-end;
  margin-top: 2px;
  min-width: 64px;
}

.demo-files-status {
  min-height: 18px;
  margin-top: 9px;
  font-size: 10px;
  color: var(--accent-primary);
  font-family: var(--font-mono);
}

.demo-files-note {
  margin: 6px 0 0;
  font-size: 9px;
  line-height: 1.45;
  color: var(--text-muted);
}

.demo-files-footer {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  padding: 9px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-panel-elevated);
}

body.theme-light .demo-files-window,
[data-theme="light"] .demo-files-window {
  background: var(--bg-panel);
  border-color: var(--border-strong);
}

/* Expand Fullscreen Button on Carousel Cards */
.gallery-card-expand {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.75);
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.15s ease;
  border: 1px solid rgba(255, 255, 255, 0.18);
  z-index: 5;
}

.mapping-gallery-card:hover .gallery-card-expand {
  opacity: 0.9;
}

.gallery-card-expand:hover {
  opacity: 1;
  background: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
  transform: scale(1.15);
}

/* =========================================================================
   X-Ray Physics & Constants Suite (xraylib v4.3.0) Modal Styles
   ========================================================================= */
.xray-physics-modal {
  min-width: 680px;
  min-height: 520px;
  max-height: 96vh;
  resize: both;
  overflow: hidden;
  border: 1.5px solid rgba(2, 132, 199, 0.45);
  box-shadow: 0 0 16px rgba(2, 132, 199, 0.08);
  transition: box-shadow 0.2s ease, width 0.15s ease, height 0.15s ease;
}

body.theme-dark .xray-physics-modal,
[data-theme="dark"] .xray-physics-modal {
  border-color: rgba(56, 189, 248, 0.45);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.1);
}

.xray-physics-modal.is-maximized {
  top: 10px !important;
  left: 10px !important;
  width: calc(100vw - 20px) !important;
  height: calc(100vh - 20px) !important;
  max-height: calc(100vh - 20px) !important;
  border-radius: 8px;
  resize: none;
}

.xray-physics-modal.is-maximized #xrayCsCanvas,
.xray-physics-modal.is-maximized #xrayTransCanvas {
  height: min(450px, 48vh) !important;
}

.xray-tabs-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--bg-panel-elevated);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  scrollbar-width: thin;
}

.xray-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 7px;
  border: 1.5px solid rgba(2, 132, 199, 0.28);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  user-select: none;
}

.xray-tab-btn:hover {
  color: #0284c7;
  border-color: #0284c7;
  background: rgba(2, 132, 199, 0.06);
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.16);
}

.xray-tab-btn.active {
  background: rgba(2, 132, 199, 0.12);
  color: #0284c7;
  border-color: #0284c7;
  box-shadow: 0 0 12px rgba(2, 132, 199, 0.3);
}

.xray-tab-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-block;
}

.xray-tab-icon-dark {
  display: none;
}

body.theme-dark .xray-tab-btn,
[data-theme="dark"] .xray-tab-btn {
  border: 1.5px solid rgba(56, 189, 248, 0.32);
  background: #111827;
  color: #94a3b8;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

body.theme-dark .xray-tab-btn:hover,
[data-theme="dark"] .xray-tab-btn:hover {
  color: #38bdf8;
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.22);
}

body.theme-dark .xray-tab-btn.active,
[data-theme="dark"] .xray-tab-btn.active {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border-color: #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.45);
}

body.theme-dark .xray-tab-icon-light,
[data-theme="dark"] .xray-tab-icon-light {
  display: none;
}

body.theme-dark .xray-tab-icon-dark,
[data-theme="dark"] .xray-tab-icon-dark {
  display: inline-block;
}

.xray-info-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-primary);
  font-size: 9.5px;
  font-weight: 800;
  font-family: var(--font-sans);
  cursor: help;
  vertical-align: middle;
  margin-left: 4px;
  border: 1px solid rgba(56, 189, 248, 0.3);
  transition: all 0.15s ease;
  user-select: none;
}

.xray-info-pill:hover {
  background: var(--accent-primary);
  color: #fff;
  transform: scale(1.15);
}

.xray-guide-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(840px, 94vw);
  max-height: min(780px, 90vh);
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
  z-index: 10005;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Isolated Graph & Parameter Inspector Modal (Optimal Rectangular Form) */
.xray-isolated-modal {
  position: fixed;
  width: min(1180px, 95vw);
  height: min(780px, 92vh);
  min-width: 760px;
  min-height: 520px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 25px 65px rgba(0, 0, 0, 0.48);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  resize: both;
  z-index: 10006;
}

.xray-isolated-modal.is-maximized {
  top: 10px !important;
  left: 10px !important;
  width: calc(100vw - 20px) !important;
  height: calc(100vh - 20px) !important;
  max-height: calc(100vh - 20px) !important;
  border-radius: 8px;
  resize: none;
}

.xray-isolated-header {
  padding: 8px 14px;
  background: var(--bg-panel-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  user-select: none;
  cursor: move;
  flex-shrink: 0;
}

.xray-isolated-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(360px, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  overflow: hidden;
  background: var(--bg-panel);
  min-height: 0;
  height: calc(100% - 46px);
  box-sizing: border-box;
}

.xray-isolated-graph-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.xray-isolated-canvas-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  height: 100%;
  background: var(--bg-canvas, #ffffff);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15);
}

.xray-isolated-canvas-wrapper canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.xray-isolated-params-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

@media (max-width: 900px) {
  .xray-isolated-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .xray-isolated-canvas-wrapper {
    min-height: 320px;
  }
}

/* X-Ray Periodic Table Grid & Cells (Rigid Non-Bouncing Layout) */
.xray-ptable-grid {
  display: grid !important;
  grid-template-columns: repeat(18, 1fr) !important;
  gap: 2.5px !important;
  user-select: none;
}

.xray-pt-cell {
  height: 28px !important;
  min-height: 28px !important;
  max-height: 28px !important;
  box-sizing: border-box !important;
  transform: none !important;
  transition: box-shadow 0.12s ease, filter 0.12s ease !important;
}

.xray-pt-cell:hover {
  filter: brightness(1.2) saturate(1.1);
  box-shadow: 0 0 7px var(--accent-primary) !important;
  z-index: 2;
  transform: none !important;
}

@media (max-width: 760px) {
  .xray-ptable-header-hint {
    display: none !important;
  }
}

/* =========================================================================
   FUNDAMENTAL PARAMETERS (FP) & TOOLS DROPDOWN STYLING
   ========================================================================= */

/* Top Navbar Tools & Settings Dropdown Menu */
.settings-tools-dropdown-wrapper {
  position: relative;
  display: inline-flex;
}

.settings-tools-menu {
  background: var(--bg-card) !important;
  border: 1.5px solid var(--border-strong) !important;
  border-radius: 8px !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35) !important;
  z-index: 99999 !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: fadeInDown 0.15s ease-out;
}

body.theme-light .settings-tools-menu,
[data-theme="light"] .settings-tools-menu {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.18) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

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

.settings-tools-menu .btn {
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.settings-tools-menu .btn:hover {
  background: var(--bg-hover) !important;
  transform: translateX(2px);
}

/* Interactive Educational Sherman Equation Banner (Static in Document Flow) */
.sherman-banner-card {
  position: relative;
  user-select: none;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.94), rgba(15, 23, 42, 0.97));
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  margin-bottom: 4px;
}

.sherman-formula-flex {
  line-height: 1.4;
}

.eq-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 5px 12px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
}

.eq-chip:hover {
  background: rgba(56, 189, 248, 0.16);
  border-color: #38bdf8;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.3);
}

.eq-chip.active-glow {
  background: rgba(56, 189, 248, 0.22);
  border-color: #38bdf8;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.5);
}

.eq-symbol {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 15px;
}

.eq-desc {
  font-family: var(--font-sans);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 2px;
}

.eq-chip:hover .eq-desc {
  color: #38bdf8;
}

/* FP Workspace Cards & Controls — Distinct Blue Borders for Clear Separation */
.fp-card {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: var(--bg-card);
  border: 1.5px solid #0284c7;
  border-radius: 8px;
  padding: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
}

.fp-card:hover {
  border-color: #0369a1;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.16);
}

/* Light Theme overrides for FP Suite */
body.theme-light .sherman-banner-card,
[data-theme="light"] .sherman-banner-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(241, 245, 249, 0.98)) !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08) !important;
  color: #0f172a !important;
}

body.theme-light .sherman-banner-card span,
[data-theme="light"] .sherman-banner-card span {
  color: inherit;
}

body.theme-light .eq-chip,
[data-theme="light"] .eq-chip {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body.theme-light .eq-chip:hover,
[data-theme="light"] .eq-chip:hover {
  background: rgba(2, 132, 199, 0.08) !important;
  border-color: #0284c7 !important;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.18) !important;
}

body.theme-light .eq-chip.active-glow,
[data-theme="light"] .eq-chip.active-glow {
  background: rgba(2, 132, 199, 0.14) !important;
  border-color: #0284c7 !important;
  box-shadow: 0 0 14px rgba(2, 132, 199, 0.35) !important;
}

body.theme-light .eq-symbol,
[data-theme="light"] .eq-symbol {
  color: #0f172a !important;
}

body.theme-light .eq-desc,
[data-theme="light"] .eq-desc {
  color: #64748b !important;
}

body.theme-light .fp-card,
body.theme-light .full-tab-header,
body.theme-light .full-table-wrapper,
body.theme-light .deconv-controls-strip,
body.theme-light .snip-bottom-dock,
body.theme-light .mapping-panel,
body.theme-light .mapping-toolbar,
body.theme-light .chart-toolbar,
body.theme-light .canvas-wrapper,
body.theme-light .canvas-hud-bottom-right,
body.theme-light #shellGroupingModalWin,
[data-theme="light"] .fp-card,
[data-theme="light"] .full-tab-header,
[data-theme="light"] .full-table-wrapper,
[data-theme="light"] .deconv-controls-strip,
[data-theme="light"] .snip-bottom-dock,
[data-theme="light"] .mapping-panel,
[data-theme="light"] .mapping-toolbar,
[data-theme="light"] .chart-toolbar,
[data-theme="light"] .canvas-wrapper,
[data-theme="light"] .canvas-hud-bottom-right,
[data-theme="light"] #shellGroupingModalWin {
  background: #ffffff !important;
  border: 1.5px solid #0284c7 !important;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

body.theme-light .fp-card:hover,
body.theme-light .full-tab-header:hover,
body.theme-light .full-table-wrapper:hover,
body.theme-light .deconv-controls-strip:hover,
body.theme-light .snip-bottom-dock:hover,
body.theme-light .mapping-panel:hover,
body.theme-light .mapping-toolbar:hover,
body.theme-light .chart-toolbar:hover,
body.theme-light .canvas-wrapper:hover,
body.theme-light .canvas-hud-bottom-right:hover,
[data-theme="light"] .fp-card:hover,
[data-theme="light"] .full-tab-header:hover,
[data-theme="light"] .full-table-wrapper:hover,
[data-theme="light"] .deconv-controls-strip:hover,
[data-theme="light"] .snip-bottom-dock:hover,
[data-theme="light"] .mapping-panel:hover,
[data-theme="light"] .mapping-toolbar:hover,
[data-theme="light"] .chart-toolbar:hover,
[data-theme="light"] .canvas-wrapper:hover,
[data-theme="light"] .canvas-hud-bottom-right:hover {
  border-color: #0369a1 !important;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.16) !important;
}

body.theme-light .data-table th,
[data-theme="light"] .data-table th {
  background: #f8fafc !important;
  border-bottom: 1.5px solid rgba(2, 132, 199, 0.3) !important;
  color: #1e293b !important;
}

body.theme-light .data-table td,
[data-theme="light"] .data-table td {
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
}

body.theme-light .data-table tbody tr:hover,
[data-theme="light"] .data-table tbody tr:hover {
  background: rgba(2, 132, 199, 0.05) !important;
}

body.theme-light .fp-top-bar,
[data-theme="light"] .fp-top-bar {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

body.theme-light .fp-card input,
body.theme-light .fp-card select,
body.theme-light .deconv-controls-strip input,
body.theme-light .deconv-controls-strip select,
[data-theme="light"] .fp-card input,
[data-theme="light"] .fp-card select,
[data-theme="light"] .deconv-controls-strip input,
[data-theme="light"] .deconv-controls-strip select {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #0f172a !important;
}

body.theme-light .fp-card input:focus,
body.theme-light .fp-card select:focus,
body.theme-light .deconv-controls-strip input:focus,
body.theme-light .deconv-controls-strip select:focus,
[data-theme="light"] .fp-card input:focus,
[data-theme="light"] .fp-card select:focus,
[data-theme="light"] .deconv-controls-strip input:focus,
[data-theme="light"] .deconv-controls-strip select:focus {
  border-color: #0284c7 !important;
  outline: none;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

body.theme-dark .fp-card,
body.theme-dark .full-tab-header,
body.theme-dark .full-table-wrapper,
body.theme-dark .deconv-controls-strip,
body.theme-dark .snip-bottom-dock,
body.theme-dark .mapping-panel,
body.theme-dark .mapping-toolbar,
body.theme-dark .chart-toolbar,
body.theme-dark .canvas-wrapper,
body.theme-dark .canvas-hud-bottom-right,
body.theme-dark #shellGroupingModalWin,
[data-theme="dark"] .fp-card,
[data-theme="dark"] .full-tab-header,
[data-theme="dark"] .full-table-wrapper,
[data-theme="dark"] .deconv-controls-strip,
[data-theme="dark"] .snip-bottom-dock,
[data-theme="dark"] .mapping-panel,
[data-theme="dark"] .mapping-toolbar,
[data-theme="dark"] .chart-toolbar,
[data-theme="dark"] .canvas-wrapper,
[data-theme="dark"] .canvas-hud-bottom-right,
[data-theme="dark"] #shellGroupingModalWin {
  background: #111827 !important;
  border: 1.5px solid rgba(56, 189, 248, 0.55) !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35), 0 0 10px rgba(56, 189, 248, 0.08) !important;
}

body.theme-dark .fp-card:hover,
body.theme-dark .full-tab-header:hover,
body.theme-dark .full-table-wrapper:hover,
body.theme-dark .deconv-controls-strip:hover,
body.theme-dark .snip-bottom-dock:hover,
body.theme-dark .mapping-panel:hover,
body.theme-dark .mapping-toolbar:hover,
body.theme-dark .chart-toolbar:hover,
body.theme-dark .canvas-wrapper:hover,
body.theme-dark .canvas-hud-bottom-right:hover,
[data-theme="dark"] .fp-card:hover,
[data-theme="dark"] .full-tab-header:hover,
[data-theme="dark"] .full-table-wrapper:hover,
[data-theme="dark"] .deconv-controls-strip:hover,
[data-theme="dark"] .snip-bottom-dock:hover,
[data-theme="dark"] .mapping-panel:hover,
[data-theme="dark"] .mapping-toolbar:hover,
[data-theme="dark"] .chart-toolbar:hover,
[data-theme="dark"] .canvas-wrapper:hover,
[data-theme="dark"] .canvas-hud-bottom-right:hover {
  border-color: #38bdf8 !important;
  box-shadow: 0 4px 18px rgba(56, 189, 248, 0.22) !important;
}

body.theme-dark .data-table th,
[data-theme="dark"] .data-table th {
  background: #1e293b !important;
  border-bottom: 1.5px solid rgba(56, 189, 248, 0.35) !important;
  color: #f1f5f9 !important;
}

body.theme-dark .data-table td,
[data-theme="dark"] .data-table td {
  border-bottom: 1px solid rgba(51, 65, 85, 0.85);
}

body.theme-dark .data-table tbody tr:hover,
[data-theme="dark"] .data-table tbody tr:hover {
  background: rgba(56, 189, 248, 0.08) !important;
}

body.theme-dark .fp-top-bar,
[data-theme="dark"] .fp-top-bar {
  background: #111827 !important;
  border: 1px solid #1f293d !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

body.theme-dark .fp-card input,
body.theme-dark .fp-card select,
body.theme-dark .deconv-controls-strip input,
body.theme-dark .deconv-controls-strip select,
[data-theme="dark"] .fp-card input,
[data-theme="dark"] .fp-card select,
[data-theme="dark"] .deconv-controls-strip input,
[data-theme="dark"] .deconv-controls-strip select {
  background: #1e293b !important;
  border: 1px solid #334155 !important;
  color: #f1f5f9 !important;
}

body.theme-dark .fp-card input:focus,
body.theme-dark .fp-card select:focus,
body.theme-dark .deconv-controls-strip input:focus,
body.theme-dark .deconv-controls-strip select:focus,
[data-theme="dark"] .fp-card input:focus,
[data-theme="dark"] .fp-card select:focus,
[data-theme="dark"] .deconv-controls-strip input:focus,
[data-theme="dark"] .deconv-controls-strip select:focus {
  border-color: #38bdf8 !important;
  outline: none;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

/* Modern Form Controls & Parameter Inputs */
.form-control,
.fp-param-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--text-primary, #0f172a);
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-subtle, #cbd5e1);
  border-radius: 6px;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus,
.fp-param-input:focus {
  border-color: var(--accent-primary, #0284c7);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
  outline: none;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .fp-param-input,
body.theme-dark .form-control,
body.theme-dark .fp-param-input {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .fp-param-input:focus,
body.theme-dark .form-control:focus,
body.theme-dark .fp-param-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

/* Modern Unified Parameter Cards matching Geometry */
.fp-param-card {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-subtle, #cbd5e1);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.fp-param-card:hover {
  border-color: var(--border-strong, #94a3b8);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .fp-param-card,
body.theme-dark .fp-param-card {
  background: #151c2c;
  border-color: #334155;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .fp-param-card:hover,
body.theme-dark .fp-param-card:hover {
  border-color: #475569;
  background: #192236;
}

.fp-param-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.fp-param-card-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary, #475569);
}

[data-theme="dark"] .fp-param-card-title,
body.theme-dark .fp-param-card-title {
  color: #cbd5e1;
}

.fp-param-card-desc {
  font-size: 10.5px;
  color: var(--text-secondary, #64748b);
  opacity: 0.85;
}

/* Fieldset styling matching Geometry across all sections */
.fp-fieldset {
  border: 1px solid var(--border-subtle, #cfd4da);
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--bg-card, #ffffff);
  margin-bottom: 12px;
}

[data-theme="dark"] .fp-fieldset,
body.theme-dark .fp-fieldset {
  border-color: #334155;
  background: #111827;
}

.fp-fieldset legend {
  padding: 0 8px;
  color: var(--text-primary, #333333);
  font-weight: 700;
  font-size: 12px;
  margin: 0 4px;
}

[data-theme="dark"] .fp-fieldset legend,
body.theme-dark .fp-fieldset legend {
  color: #e2e8f0;
}

body.theme-light .fp-table th,
[data-theme="light"] .fp-table th {
  background: #f8fafc !important;
  color: #475569 !important;
  border-color: #e2e8f0 !important;
}

body.theme-light .fp-table td,
[data-theme="light"] .fp-table td {
  border-color: #f1f5f9 !important;
  color: #1e293b !important;
}

body.theme-light #fpTubeCanvas,
[data-theme="light"] #fpTubeCanvas {
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
}

body.theme-light #fpEfficiencyCanvas,
[data-theme="light"] #fpEfficiencyCanvas {
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
}

body.theme-light #shermanRoadmapCard,
[data-theme="light"] #shermanRoadmapCard {
  background: linear-gradient(135deg, rgba(241, 245, 249, 0.95), rgba(255, 255, 255, 0.98)) !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06) !important;
}

/* ==========================================================================
   MODERN FUNDAMENTAL PARAMETERS (FP) SUITE — SPECTRA-X DMSE
   ========================================================================== */

/* 1. Workflow Stepper Bar */
.fp-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
}

.fp-container > * {
  flex-shrink: 0;
}

.fp-stepper-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  overflow: visible;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 12px;
  flex-shrink: 0;
  min-height: 48px;
  box-sizing: border-box;
}

.fp-stepper-bar::-webkit-scrollbar {
  display: none;
}

.fp-step-btn {
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  user-select: none;
  min-height: 36px;
  box-sizing: border-box;
}

.fp-step-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-panel-elevated);
}

.fp-step-btn.active {
  color: #0284c7;
  background: rgba(2, 132, 199, 0.1);
  border-color: #0284c7;
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.2);
}

.fp-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: #94a3b8;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.fp-status-dot.ready {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.fp-status-dot.active {
  background: #0284c7;
  box-shadow: 0 0 8px rgba(2, 132, 199, 0.6);
}

/* Subtle Validation Status Glows for FP Cards */
.fp-card {
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.fp-card.fp-section-valid {
  /* Retain crisp blue section border requested by user */
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.12), 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

.fp-card.fp-section-invalid {
  border-color: rgba(239, 68, 68, 0.7) !important;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.18), 0 2px 8px rgba(0, 0, 0, 0.04) !important;
}

/* Sherman (1955) Mathematical Display */
.sherman-math-card {
  background: var(--bg-card);
  border: 1.5px solid rgba(56, 189, 248, 0.35);
  border-radius: 10px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}

.sherman-math-formula-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 24px;
  background: var(--bg-panel-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow-x: auto;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
}

.sherman-math-formula {
  font-family: 'Cambria Math', 'STIX Two Math', 'Times New Roman', serif;
  font-size: 17.5px;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  user-select: text;
  line-height: 1;
}

.math-frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  align-items: center;
  margin: 0 3px;
  text-align: center;
}

.math-frac-num {
  padding: 0 5px 3px 5px;
  border-bottom: 1.5px solid currentColor;
  display: block;
  font-size: 0.95em;
  white-space: nowrap;
}

.math-frac-den {
  padding: 3px 5px 0 5px;
  display: block;
  font-size: 0.95em;
  white-space: nowrap;
}

.math-integral-block {
  display: inline-flex;
  align-items: center;
  margin: 0 4px;
  position: relative;
}

.math-int-sym {
  font-size: 2.4em;
  line-height: 0.85;
  font-style: normal;
  color: var(--text-primary);
  display: inline-block;
  margin-right: 2px;
}

.math-int-limits {
  display: inline-flex;
  flex-direction: column;
  justify-content: space-between;
  height: 2.2em;
  font-size: 0.65em;
  font-weight: 700;
  line-height: 1;
  margin-right: 4px;
}

.math-int-upper {
  color: var(--accent-amber, #f59e0b);
}

.math-int-lower {
  color: var(--accent-amber, #f59e0b);
}

.math-bracket {
  font-size: 1.8em;
  line-height: 0.85;
  font-weight: 300;
  color: var(--accent-violet, #8b5cf6);
  margin: 0 2px;
}

.math-paren {
  font-size: 1.35em;
  line-height: 0.85;
  font-weight: 300;
  color: var(--text-secondary);
  margin: 0 1px;
}

.sherman-glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.sherman-glossary-card {
  background: var(--bg-panel-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 11.5px;
  line-height: 1.5;
}

.sherman-glossary-card b {
  color: var(--text-primary);
}

.sherman-glossary-card i {
  font-family: 'Cambria Math', 'Times New Roman', serif;
}

/* 2. Interactive Animated Ray-Tracing Schematic Banner & Option 1B Physical Cross-Section */
.fp-schematic-card {
  position: relative;
  background: linear-gradient(135deg, rgba(248, 250, 252, 0.95), rgba(241, 245, 249, 0.98));
  border: 1.5px solid rgba(2, 132, 199, 0.3);
  border-radius: 12px;
  padding: 8px 12px;
  margin: 0 auto 14px auto;
  max-width: 1040px;
  width: 100%;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
  overflow: hidden;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-sizing: border-box;
}

.fp-cross-section-svg {
  width: 100%;
  height: auto;
  max-height: 350px;
  display: block;
}

.fp-cross-section-node {
  cursor: pointer;
}

.fp-cross-section-node rect,
.fp-cross-section-node polygon {
  transition: stroke 0.15s ease, stroke-width 0.15s ease, fill 0.15s ease, opacity 0.15s ease;
}

.fp-cross-section-node text {
  user-select: none;
}

.fp-cross-section-node:hover rect:first-of-type {
  stroke-width: 2.8px;
  stroke: #38bdf8;
}

.fp-cross-section-node.detector-node:hover rect:first-of-type {
  stroke-width: 2.8px;
  stroke: #f59e0b;
}

.fp-cross-section-node:active rect {
  opacity: 0.82;
}

/* 7. FP Scientific Modals (Matching Slide 4 & Slide 7) */
.fp-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fp-submodal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 100005;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fp-modal-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.25);
  width: 580px;
  max-width: 95vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #1e293b;
}

[data-theme="dark"] .fp-modal-card,
body.theme-dark .fp-modal-card {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

@keyframes densityPulse {
  0% { background-color: rgba(16, 185, 129, 0.45); border-color: #10b981; box-shadow: 0 0 8px rgba(16, 185, 129, 0.5); }
  100% { background-color: var(--bg-input, #ffffff); border-color: var(--border-subtle, #cbd5e1); box-shadow: none; }
}

.density-pulse {
  animation: densityPulse 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

.fp-modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

[data-theme="dark"] .fp-modal-header,
body.theme-dark .fp-modal-header {
  background: #1e293b;
  border-bottom-color: #334155;
}

.fp-modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fp-modal-footer {
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  background: #f8fafc;
}

[data-theme="dark"] .fp-modal-footer,
body.theme-dark .fp-modal-footer {
  background: #1e293b;
  border-top-color: #334155;
}

/* XMI-MSIM Style Layer & Absorber Dialogs */
.xmi-layer-dialog {
  width: 580px;
  max-width: 96vw;
  max-height: 90vh;
}

.xmi-dialog-layout {
  display: flex;
  gap: 16px;
  align-items: stretch;
}

.xmi-dialog-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.xmi-element-box {
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-card);
  height: 200px;
  overflow-y: auto;
}

[data-theme="dark"] .xmi-element-box,
body.theme-dark .xmi-element-box {
  background: #090d16;
  border-color: #334155;
}

.xmi-element-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: center;
}

.xmi-element-table th {
  position: sticky;
  top: 0;
  background: var(--bg-panel);
  padding: 6px 10px;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  text-align: center !important;
  vertical-align: middle;
  z-index: 1;
}

[data-theme="dark"] .xmi-element-table th,
body.theme-dark .xmi-element-table th {
  background: #1e293b;
}

.xmi-element-table td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
  text-align: center !important;
  vertical-align: middle;
}

.xmi-element-table td > div {
  justify-content: center !important;
}

[data-theme="dark"] .xmi-element-table td,
body.theme-dark .xmi-element-table td {
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

.xmi-element-table tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

.xmi-element-table tr:hover {
  background: rgba(2, 132, 199, 0.06);
}

.xmi-element-table tr.row-selected {
  background: rgba(2, 132, 199, 0.14) !important;
  color: #0284c7;
  font-weight: 700;
}

.xmi-btn-stack {
  width: 140px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.xmi-btn-stack .btn {
  width: 100%;
  justify-content: center;
  font-size: 12px;
  padding: 6px 10px;
}


[data-theme="dark"] .fp-schematic-card,
body.theme-dark .fp-schematic-card {
  background: #080d19;
  border-color: rgba(2, 132, 199, 0.45);
  box-shadow: 0 0 25px rgba(2, 132, 199, 0.12);
}

.fp-stage-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.fp-stage-item:hover {
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.3);
  transform: translateY(-1px);
}

.fp-stage-item.stage-active {
  background: rgba(2, 132, 199, 0.12);
  border-color: #0284c7;
  box-shadow: 0 0 14px rgba(2, 132, 199, 0.25);
}

/* 3. High-DPI Scientific Canvas Cards */
.fp-plot-box {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

[data-theme="dark"] .fp-plot-box,
body.theme-dark .fp-plot-box {
  background: #0f172a;
  border-color: #334155;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
}

.fp-canvas-scientific {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  display: block;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* 4. Stepper Buttons */
.fp-num-stepper {
  display: inline-flex;
  align-items: stretch;
  width: 100%;
  min-width: 0;
  height: 28px;
  box-sizing: border-box;
  border: 1px solid var(--border-subtle, #cbd5e1);
  border-radius: 6px;
  background: var(--bg-card, #ffffff);
  overflow: hidden;
}

[data-theme="dark"] .fp-num-stepper,
body.theme-dark .fp-num-stepper {
  border-color: #334155;
  background: #1e293b;
}

.fp-num-stepper input {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: none !important;
  background: transparent !important;
  text-align: center;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  padding: 2px 4px;
  font-size: 12px;
  color: var(--text-primary, #0f172a);
  outline: none;
}

[data-theme="dark"] .fp-num-stepper input,
body.theme-dark .fp-num-stepper input {
  color: #60a5fa;
}

.fp-stepper-btn {
  flex-shrink: 0;
  width: 28px;
  min-width: 28px;
  height: 100%;
  background: var(--bg-panel-elevated, #f1f5f9);
  color: var(--text-primary, #334155);
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
  transition: all 0.15s ease;
  user-select: none;
}

.fp-stepper-btn:hover {
  background: #e2e8f0;
  color: #0284c7;
}

[data-theme="dark"] .fp-stepper-btn,
body.theme-dark .fp-stepper-btn {
  background: #334155;
  color: #f1f5f9;
}

[data-theme="dark"] .fp-stepper-btn:hover,
body.theme-dark .fp-stepper-btn:hover {
  background: #475569;
  color: #38bdf8;
}

/* 5. 3D Viewport & Geometry Visualizer Parity */
.fp-geom-card {
  display: grid;
  grid-template-columns: 540px 1fr;
  gap: 16px;
  align-items: stretch;
  background: var(--bg-card);
  border-radius: 10px;
}
@media (max-width: 1280px) {
  .fp-geom-card {
    grid-template-columns: 1fr;
  }
}
.fp-geom-controls {
  width: 100%;
}
.fp-geom-controls fieldset {
  border: 1px solid #cfd4da;
  border-radius: 4px;
  padding: 8px 12px;
  background: #ffffff;
  margin-bottom: 12px;
}
[data-theme="dark"] .fp-geom-controls fieldset,
body.theme-dark .fp-geom-controls fieldset {
  border-color: #334155;
  background: #111827;
}
.fp-geom-controls legend {
  padding: 0 8px;
  color: #333333;
  font-weight: 600;
  font-size: 12px;
  margin: 0 auto;
}
[data-theme="dark"] .fp-geom-controls legend,
body.theme-dark .fp-geom-controls legend {
  color: #e2e8f0;
}
.fp-geom-controls .geom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  gap: 6px;
}
.fp-geom-controls .geom-row label.t {
  flex: 1;
  color: #222222;
  font-size: 12.5px;
}
[data-theme="dark"] .fp-geom-controls .geom-row label.t,
body.theme-dark .fp-geom-controls .geom-row label.t {
  color: #cbd5e1;
}
.fp-geom-controls input[type=number] {
  width: 78px;
  border: 1px solid #c8c8c8;
  border-radius: 4px;
  padding: 5px 7px;
  font-size: 12px;
  color: #1d3fae;
  background: #ffffff;
}
[data-theme="dark"] .fp-geom-controls input[type=number] {
  border-color: #475569;
  color: #60a5fa;
  background: #1e293b;
}
.fp-geom-controls input[type=number].w {
  width: 110px;
}
.fp-geom-controls .ax {
  color: #555555;
  font-size: 11px;
  margin-left: 6px;
}
[data-theme="dark"] .fp-geom-controls .ax {
  color: #94a3b8;
}
.fp-geom-controls input[type=range] {
  width: 100%;
  accent-color: #0284c7;
  margin: 2px 0 6px 0;
  cursor: pointer;
}
.fp-geom-controls .val {
  font-family: ui-monospace, monospace;
  font-weight: 700;
  color: #0284c7;
}
[data-theme="dark"] .fp-geom-controls .val,
body.theme-dark .fp-geom-controls .val {
  color: #38bdf8;
}
.fp-geom-controls .btn-geom-purple,
.fp-geom-controls .btn-geom-blue {
  background: #0284c7;
  color: #ffffff;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}
.fp-geom-controls .btn-geom-purple:hover,
.fp-geom-controls .btn-geom-blue:hover {
  background: #0369a1;
}
.fp-geom-controls .btn-geom-gray {
  background: #e5e7eb;
  color: #111111;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}
.fp-geom-controls .btn-geom-gray:hover {
  background: #d1d5db;
}
[data-theme="dark"] .fp-geom-controls .btn-geom-gray {
  background: #334155;
  color: #f1f5f9;
}
[data-theme="dark"] .fp-geom-controls .btn-geom-gray:hover {
  background: #475569;
}
.fp-3d-viewport {
  width: 100%;
  min-height: 640px;
  height: 100%;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
}
[data-theme="dark"] .fp-3d-viewport,
body.theme-dark .fp-3d-viewport {
  background: #090d16;
  border-color: #334155;
}

/* 6. Scientific Tables */
.fp-table-scientific {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: center;
}

.fp-table-scientific th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  padding: 6px 8px;
  border-bottom: 2px solid #cbd5e1;
  text-align: center !important;
  vertical-align: middle;
  white-space: nowrap;
  font-size: 11.5px;
  box-sizing: border-box;
}

.fp-table-scientific td {
  padding: 5px 8px;
  border-bottom: 1px solid #e2e8f0;
  color: #1e293b;
  text-align: center !important;
  vertical-align: middle;
  box-sizing: border-box;
}

.fp-table-scientific td > div {
  justify-content: center !important;
  align-items: center;
}

.fp-table-scientific tr:hover td {
  background: rgba(2, 132, 199, 0.04);
}

[data-theme="dark"] .fp-table-scientific th,
body.theme-dark .fp-table-scientific th {
  background: #1e293b;
  color: #cbd5e1;
  border-bottom-color: #475569;
}

[data-theme="dark"] .fp-table-scientific td,
body.theme-dark .fp-table-scientific td {
  border-bottom-color: #334155;
  color: #f1f5f9;
}

[data-theme="dark"] .fp-table-scientific tr:hover td,
body.theme-dark .fp-table-scientific tr:hover td {
  background: rgba(56, 189, 248, 0.07);
}

.fp-table-scientific input,
.fp-table-scientific select {
  border: 1px solid var(--border-subtle, #cbd5e1);
  border-radius: 4px;
  background: var(--bg-card, #ffffff);
  color: var(--text-primary, #0f172a);
  padding: 3px 6px;
  font-family: inherit;
  font-size: 11.5px;
  box-sizing: border-box;
  text-align: center;
  text-align-last: center;
  margin: 0 auto;
}

.fp-table-scientific input[type="radio"],
.fp-table-scientific input[type="checkbox"] {
  margin: 0 auto;
  display: inline-block;
  vertical-align: middle;
}

[data-theme="dark"] .fp-table-scientific input,
[data-theme="dark"] .fp-table-scientific select,
body.theme-dark .fp-table-scientific input,
body.theme-dark .fp-table-scientific select {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

.fp-table-scientific input:focus,
.fp-table-scientific select:focus {
  border-color: var(--accent-primary, #0284c7) !important;
  outline: none;
}







/* ==========================================================================
   CUSTOM SCIENTIFIC XRF ICON PACKAGE (LIGHT & DARK THEME PARITY)
   Assets located in: xrf-icons/png/ink-dark/256/ & xrf-icons/png/ink-white/256/
   ========================================================================== */
.xrf-icon {
  display: inline-block;
  vertical-align: -0.20em;
  width: 1.18em;
  height: 1.18em;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.xrf-icon-inline {
  margin-right: 5px;
}

/* Size utility classes */
.xrf-icon-xs { width: 12px; height: 12px; }
.xrf-icon-sm { width: 14px; height: 14px; }
.xrf-icon-md { width: 17px; height: 17px; }
.xrf-icon-lg { width: 22px; height: 22px; }
.xrf-icon-xl { width: 32px; height: 32px; }

/* Full-colour file-type icons (xrf-icons/excel.png, xrf-icons/CSV.png); white tile keeps them legible on coloured buttons */
.file-type-icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
  vertical-align: -2px;
  background: #fff;
  border-radius: 3px;
  padding: 1px;
  box-sizing: border-box;
}

/* 19 Icon Mappings for Light Theme (ink-dark: deep slate #1c2530 + accent #1f6feb) */
.xrf-icon-background { background-image: url('xrf-icons/png/ink-dark/256/background.png'); }
.xrf-icon-calibration { background-image: url('xrf-icons/png/ink-dark/256/calibration.png'); }
.xrf-icon-characteristic-lines { background-image: url('xrf-icons/png/ink-dark/256/characteristic-lines.png'); }
.xrf-icon-collimator { background-image: url('xrf-icons/png/ink-dark/256/collimator.png'); }
.xrf-icon-dead-time { background-image: url('xrf-icons/png/ink-dark/256/dead-time.png'); }
.xrf-icon-deconvolution { background-image: url('xrf-icons/png/ink-dark/256/deconvolution.png'); }
.xrf-icon-detector { background-image: url('xrf-icons/png/ink-dark/256/detector.png'); }
.xrf-icon-escape-peak { background-image: url('xrf-icons/png/ink-dark/256/escape-peak.png'); }
.xrf-icon-fit-residuals { background-image: url('xrf-icons/png/ink-dark/256/fit-residuals.png'); }
.xrf-icon-fluorescence { background-image: url('xrf-icons/png/ink-dark/256/fluorescence.png'); }
.xrf-icon-lod { background-image: url('xrf-icons/png/ink-dark/256/lod.png'); }
.xrf-icon-mca-channels { background-image: url('xrf-icons/png/ink-dark/256/mca-channels.png'); }
.xrf-icon-pile-up { background-image: url('xrf-icons/png/ink-dark/256/pile-up.png'); }
.xrf-icon-primary-filter { background-image: url('xrf-icons/png/ink-dark/256/primary-filter.png'); }
.xrf-icon-roi { background-image: url('xrf-icons/png/ink-dark/256/roi.png'); }
.xrf-icon-sample-filter { background-image: url('xrf-icons/png/ink-dark/256/sample-filter.png'); }
.xrf-icon-scatter { background-image: url('xrf-icons/png/ink-dark/256/scatter.png'); }
.xrf-icon-spectrum { background-image: url('xrf-icons/png/ink-dark/256/spectrum.png'); }
.xrf-icon-xray-tube { background-image: url('xrf-icons/png/ink-dark/256/xray-tube.png'); }
.xrf-icon-elemental-mapping { background-image: url('xrf-icons/png/ink-dark/256/elemental-mapping.png'); }
.xrf-icon-periodic-table { background-image: url('xrf-icons/png/ink-dark/256/periodic-table.png'); }
.xrf-icon-auto-ident { background-image: url('xrf-icons/png/ink-dark/256/auto-ident.png'); }

/* 22 Icon Mappings for Dark Theme (ink-white: crisp white #f2f5f8 + glow accent #58a6ff) */
body.theme-dark .xrf-icon-background, [data-theme="dark"] .xrf-icon-background { background-image: url('xrf-icons/png/ink-white/256/background.png'); }
body.theme-dark .xrf-icon-calibration, [data-theme="dark"] .xrf-icon-calibration { background-image: url('xrf-icons/png/ink-white/256/calibration.png'); }
body.theme-dark .xrf-icon-characteristic-lines, [data-theme="dark"] .xrf-icon-characteristic-lines { background-image: url('xrf-icons/png/ink-white/256/characteristic-lines.png'); }
body.theme-dark .xrf-icon-collimator, [data-theme="dark"] .xrf-icon-collimator { background-image: url('xrf-icons/png/ink-white/256/collimator.png'); }
body.theme-dark .xrf-icon-dead-time, [data-theme="dark"] .xrf-icon-dead-time { background-image: url('xrf-icons/png/ink-white/256/dead-time.png'); }
body.theme-dark .xrf-icon-deconvolution, [data-theme="dark"] .xrf-icon-deconvolution { background-image: url('xrf-icons/png/ink-white/256/deconvolution.png'); }
body.theme-dark .xrf-icon-detector, [data-theme="dark"] .xrf-icon-detector { background-image: url('xrf-icons/png/ink-white/256/detector.png'); }
body.theme-dark .xrf-icon-escape-peak, [data-theme="dark"] .xrf-icon-escape-peak { background-image: url('xrf-icons/png/ink-white/256/escape-peak.png'); }
body.theme-dark .xrf-icon-fit-residuals, [data-theme="dark"] .xrf-icon-fit-residuals { background-image: url('xrf-icons/png/ink-white/256/fit-residuals.png'); }
body.theme-dark .xrf-icon-fluorescence, [data-theme="dark"] .xrf-icon-fluorescence { background-image: url('xrf-icons/png/ink-white/256/fluorescence.png'); }
body.theme-dark .xrf-icon-lod, [data-theme="dark"] .xrf-icon-lod { background-image: url('xrf-icons/png/ink-white/256/lod.png'); }
body.theme-dark .xrf-icon-mca-channels, [data-theme="dark"] .xrf-icon-mca-channels { background-image: url('xrf-icons/png/ink-white/256/mca-channels.png'); }
body.theme-dark .xrf-icon-pile-up, [data-theme="dark"] .xrf-icon-pile-up { background-image: url('xrf-icons/png/ink-white/256/pile-up.png'); }
body.theme-dark .xrf-icon-primary-filter, [data-theme="dark"] .xrf-icon-primary-filter { background-image: url('xrf-icons/png/ink-white/256/primary-filter.png'); }
body.theme-dark .xrf-icon-roi, [data-theme="dark"] .xrf-icon-roi { background-image: url('xrf-icons/png/ink-white/256/roi.png'); }
body.theme-dark .xrf-icon-sample-filter, [data-theme="dark"] .xrf-icon-sample-filter { background-image: url('xrf-icons/png/ink-white/256/sample-filter.png'); }
body.theme-dark .xrf-icon-scatter, [data-theme="dark"] .xrf-icon-scatter { background-image: url('xrf-icons/png/ink-white/256/scatter.png'); }
body.theme-dark .xrf-icon-spectrum, [data-theme="dark"] .xrf-icon-spectrum { background-image: url('xrf-icons/png/ink-white/256/spectrum.png'); }
body.theme-dark .xrf-icon-xray-tube, [data-theme="dark"] .xrf-icon-xray-tube { background-image: url('xrf-icons/png/ink-white/256/xray-tube.png'); }
body.theme-dark .xrf-icon-elemental-mapping, [data-theme="dark"] .xrf-icon-elemental-mapping { background-image: url('xrf-icons/png/ink-white/256/elemental-mapping.png'); }
body.theme-dark .xrf-icon-periodic-table, [data-theme="dark"] .xrf-icon-periodic-table { background-image: url('xrf-icons/png/ink-white/256/periodic-table.png'); }
body.theme-dark .xrf-icon-auto-ident, [data-theme="dark"] .xrf-icon-auto-ident { background-image: url('xrf-icons/png/ink-white/256/auto-ident.png'); }

/* Buttons with solid dark / accent backgrounds always use ink-white icons */
.btn-primary .xrf-icon-background, .btn.active .xrf-icon-background { background-image: url('xrf-icons/png/ink-white/256/background.png') !important; }
.btn-primary .xrf-icon-calibration, .btn.active .xrf-icon-calibration { background-image: url('xrf-icons/png/ink-white/256/calibration.png') !important; }
.btn-primary .xrf-icon-characteristic-lines, .btn.active .xrf-icon-characteristic-lines { background-image: url('xrf-icons/png/ink-white/256/characteristic-lines.png') !important; }
.btn-primary .xrf-icon-collimator, .btn.active .xrf-icon-collimator { background-image: url('xrf-icons/png/ink-white/256/collimator.png') !important; }
.btn-primary .xrf-icon-dead-time, .btn.active .xrf-icon-dead-time { background-image: url('xrf-icons/png/ink-white/256/dead-time.png') !important; }
.btn-primary .xrf-icon-deconvolution, .btn.active .xrf-icon-deconvolution { background-image: url('xrf-icons/png/ink-white/256/deconvolution.png') !important; }
.btn-primary .xrf-icon-detector, .btn.active .xrf-icon-detector { background-image: url('xrf-icons/png/ink-white/256/detector.png') !important; }
.btn-primary .xrf-icon-escape-peak, .btn.active .xrf-icon-escape-peak { background-image: url('xrf-icons/png/ink-white/256/escape-peak.png') !important; }
.btn-primary .xrf-icon-fit-residuals, .btn.active .xrf-icon-fit-residuals { background-image: url('xrf-icons/png/ink-white/256/fit-residuals.png') !important; }
.btn-primary .xrf-icon-fluorescence, .btn.active .xrf-icon-fluorescence { background-image: url('xrf-icons/png/ink-white/256/fluorescence.png') !important; }
.btn-primary .xrf-icon-lod, .btn.active .xrf-icon-lod { background-image: url('xrf-icons/png/ink-white/256/lod.png') !important; }
.btn-primary .xrf-icon-mca-channels, .btn.active .xrf-icon-mca-channels { background-image: url('xrf-icons/png/ink-white/256/mca-channels.png') !important; }
.btn-primary .xrf-icon-pile-up, .btn.active .xrf-icon-pile-up { background-image: url('xrf-icons/png/ink-white/256/pile-up.png') !important; }
.btn-primary .xrf-icon-primary-filter, .btn.active .xrf-icon-primary-filter { background-image: url('xrf-icons/png/ink-white/256/primary-filter.png') !important; }
.btn-primary .xrf-icon-roi, .btn.active .xrf-icon-roi { background-image: url('xrf-icons/png/ink-white/256/roi.png') !important; }
.btn-primary .xrf-icon-sample-filter, .btn.active .xrf-icon-sample-filter { background-image: url('xrf-icons/png/ink-white/256/sample-filter.png') !important; }
.btn-primary .xrf-icon-scatter, .btn.active .xrf-icon-scatter { background-image: url('xrf-icons/png/ink-white/256/scatter.png') !important; }
.btn-primary .xrf-icon-spectrum, .btn.active .xrf-icon-spectrum { background-image: url('xrf-icons/png/ink-white/256/spectrum.png') !important; }
.btn-primary .xrf-icon-xray-tube, .btn.active .xrf-icon-xray-tube { background-image: url('xrf-icons/png/ink-white/256/xray-tube.png') !important; }
.btn-primary .xrf-icon-elemental-mapping, .btn.active .xrf-icon-elemental-mapping { background-image: url('xrf-icons/png/ink-white/256/elemental-mapping.png') !important; }
.btn-primary .xrf-icon-periodic-table, .btn.active .xrf-icon-periodic-table { background-image: url('xrf-icons/png/ink-white/256/periodic-table.png') !important; }
.btn-primary .xrf-icon-auto-ident, .btn.active .xrf-icon-auto-ident { background-image: url('xrf-icons/png/ink-white/256/auto-ident.png') !important; }

/* XMI-MSIM Excitation Dropdown & Tables (Exact XMI GUI Parity) */
.xmi-excitation-dropdown summary::-webkit-details-marker {
  display: none;
}
.xmi-energy-table {
  border-collapse: collapse;
}
.xmi-energy-table th {
  padding: 6px 10px;
  font-weight: 700;
  border-bottom: 2px solid var(--border-subtle);
  user-select: none;
}
.xmi-energy-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-subtle);
  user-select: none;
}
.xmi-energy-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}
.xmi-energy-table tbody tr:hover {
  background: rgba(2, 132, 199, 0.08);
}
.xmi-energy-table tbody tr.xmi-row-selected {
  background: rgba(2, 132, 199, 0.22) !important;
  color: var(--text-primary);
  font-weight: 700;
  outline: 1px solid #0284c7;
}

/* FP Bypassed Excitation Banner & Controls */
.fp-bypassed-banner {
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.15);
  animation: fadeInDown 0.2s ease;
}

.fp-controls-bypassed {
  opacity: 0.52;
  position: relative;
  pointer-events: none;
  user-select: none;
  filter: grayscale(0.5);
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.fp-controls-bypassed input,
.fp-controls-bypassed select,
.fp-controls-bypassed button {
  cursor: not-allowed !important;
}

/* --- Monte Carlo Matrix Simulation Activity Monitor & Terminal --- */
.fp-mc-monitor {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  transition: all 0.25s ease;
}

body.theme-dark .fp-mc-monitor,
[data-theme="dark"] .fp-mc-monitor {
  background: #111827 !important;
  border-color: rgba(56, 189, 248, 0.4) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

/* --- Iterative Monte Carlo Refinement (history, progress, status) --- */
.fp-iter-card {
  margin-top: 14px;
  border: 1.5px solid rgba(2, 132, 199, 0.45);
  border-radius: 10px;
  background: var(--bg-card);
  box-shadow: 0 0 16px rgba(2, 132, 199, 0.08);
  overflow: hidden;
}

.fp-iter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 9px 14px;
  background: rgba(2, 132, 199, 0.06);
  border-bottom: 1px solid var(--border-subtle);
}

.fp-iter-title-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.fp-iter-title {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.25;
}

.fp-iter-subtitle {
  font-size: 10.5px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.fp-iter-header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.fp-iter-spinner {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(2, 132, 199, 0.2);
  border-top-color: #0284c7;
  animation: fpIterSpin 0.8s linear infinite;
}

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

.fp-iter-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.fp-iter-pill.idle {
  background: rgba(100, 116, 139, 0.12);
  color: var(--text-secondary);
  border-color: rgba(100, 116, 139, 0.25);
}

.fp-iter-pill.run {
  background: rgba(2, 132, 199, 0.12);
  color: #0284c7;
  border-color: rgba(2, 132, 199, 0.3);
}

.fp-iter-pill.ok {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.3);
}

.fp-iter-pill.warn {
  background: rgba(234, 179, 8, 0.14);
  color: #b45309;
  border-color: rgba(234, 179, 8, 0.35);
}

.fp-iter-pill.err {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.3);
}

.fp-iter-progress {
  padding: 9px 14px 4px;
}

.fp-iter-progress-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

.fp-iter-progress-pct {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #0284c7;
}

.fp-iter-progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.18);
  overflow: hidden;
}

.fp-iter-progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #0284c7, #10b981);
  transition: width 0.25s ease;
}

.fp-iter-card.is-running .fp-iter-progress-bar {
  background-image: linear-gradient(90deg, #0284c7, #10b981, #0284c7);
  background-size: 200% 100%;
  animation: fpIterSheen 1.4s linear infinite;
}

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

.fp-iter-table-wrap {
  padding: 4px 10px 6px;
  overflow-x: auto;
}

.fp-iter-table-caption {
  padding: 4px 2px 5px;
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.fp-iter-table {
  font-size: 12px;
}

.fp-iter-num {
  text-align: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 600;
}

.fp-iter-summary-row td {
  background: rgba(2, 132, 199, 0.045);
  border-top: 1px solid rgba(2, 132, 199, 0.18);
  font-size: 11px;
}

.fp-iter-table td.fp-iter-summary-label {
  text-align: center !important;
  font-weight: 800;
  color: var(--text-secondary);
  white-space: nowrap;
}

.fp-iter-summary-row .fp-iter-pill {
  vertical-align: middle;
}

.fp-iter-empty {
  padding: 16px !important;
  text-align: center;
  color: var(--text-secondary);
}

.fp-iter-footnote {
  padding: 7px 14px 9px;
  border-top: 1px dashed var(--border-subtle);
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.5;
}

.fp-iter-footnote > div + div {
  margin-top: 2px;
}

body.theme-dark .fp-iter-card,
[data-theme="dark"] .fp-iter-card {
  background: #111827;
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

body.theme-dark .fp-iter-header,
[data-theme="dark"] .fp-iter-header {
  background: rgba(2, 132, 199, 0.12);
}

body.theme-dark .fp-iter-summary-row td,
[data-theme="dark"] .fp-iter-summary-row td {
  background: rgba(2, 132, 199, 0.14);
  border-top-color: rgba(56, 189, 248, 0.28);
}

body.theme-dark .fp-iter-table td.fp-iter-summary-label,
[data-theme="dark"] .fp-iter-table td.fp-iter-summary-label {
  color: #94a3b8;
}

body.theme-dark .fp-iter-pill.ok,
[data-theme="dark"] .fp-iter-pill.ok {
  color: #34d399;
}

body.theme-dark .fp-iter-pill.warn,
[data-theme="dark"] .fp-iter-pill.warn {
  color: #fbbf24;
}

body.theme-dark .fp-iter-pill.err,
[data-theme="dark"] .fp-iter-pill.err {
  color: #f87171;
}

body.theme-dark .fp-iter-progress-track,
[data-theme="dark"] .fp-iter-progress-track {
  background: rgba(148, 163, 184, 0.2);
}

/* Matrix Effects selector: compact glowing pane box with centred title and buttons */
.fp-matrix-effects-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 8px;
  border: 1.5px solid rgba(2, 132, 199, 0.45);
  border-radius: 10px;
  box-shadow: 0 0 16px rgba(2, 132, 199, 0.08);
  background: var(--bg-card);
}

.fp-matrix-effects-title {
  font-size: 10.5px;
  font-weight: 800;
  color: #0284c7;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
}

.fp-matrix-effects-buttons {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

body.theme-dark .fp-matrix-effects-box,
[data-theme="dark"] .fp-matrix-effects-box {
  border-color: rgba(56, 189, 248, 0.45);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.08);
}

body.theme-dark .fp-matrix-effects-title,
[data-theme="dark"] .fp-matrix-effects-title {
  color: #38bdf8;
}

.mc-factor-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  border: 1px solid rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

body.theme-dark .mc-terminal-drawer,
[data-theme="dark"] .mc-terminal-drawer {
  background: #090d16 !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

.mc-terminal-drawer {
  background: #0f172a;
  color: #94a3b8;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  font-family: var(--font-mono, Consolas, Monaco, "Courier New", monospace);
  font-size: 11px;
  line-height: 1.45;
  padding: 8px 12px;
  max-height: 160px;
  overflow-y: auto;
  white-space: pre-wrap;
  user-select: text;
}

/* ==========================================================================
   RESPONSIVE SHELL & ADAPTIVE WORKSPACE
   Desktop baseline (>=1600px) is intentionally unchanged. Rules below are
   progressively scoped so 1920x1080 keeps its exact current layout.
   ========================================================================== */

.sidebar-scrim,
.btn-viewer-toolbar-toggle {
  display: none;
}

.btn-label-short,
.tab-label-short {
  display: none;
}

/* Sidebar panels fill the (now flexible) sidebar column instead of forcing 316px. */
.sidebar-left > .panel-section {
  width: 100%;
  min-width: 0;
}

.sidebar-left .section-header {
  flex-wrap: wrap;
  gap: 4px 6px;
}

.sidebar-left .section-header > div:last-child {
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* --------------------------------------------------------------------------
   Compact desktop / 1080p at 125% and below: two-row masthead.
   This keeps every top-level control visible instead of clipping the right end.
   -------------------------------------------------------------------------- */
@media (max-width: 1599px) {
  .top-navbar {
    height: auto;
    min-height: 0;
    padding: 6px 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "tabs tabs";
    align-items: center;
    gap: 6px 12px;
  }

  .brand-group {
    grid-area: brand;
    min-width: 0;
  }

  .nav-right-group {
    grid-area: actions;
    justify-self: end;
  }

  .top-tabs-nav {
    grid-area: tabs;
    width: fit-content;
    max-width: 100%;
    min-width: 0;
    justify-self: center;
    justify-content: center;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
  }

  .top-tab-btn {
    flex: 0 0 auto;
  }

  .settings-tools-menu {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }

  .chart-toolbar {
    flex-wrap: wrap;
    overflow-x: visible;
    row-gap: 4px;
    margin: 6px 10px 0 10px;
  }

  .toolbar-actions-right {
    margin-left: auto;
  }
}

/* --------------------------------------------------------------------------
   Smaller desktop / 1280-class laptops: flexible sidebar width, compact gaps.
   -------------------------------------------------------------------------- */
@media (max-width: 1350px) {
  .workspace-grid {
    grid-template-columns: clamp(260px, 23vw, 316px) minmax(0, 1fr);
  }

  .workspace-grid.sidebar-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
  }

  .mapping-viewport-grid {
    grid-template-columns: 198px minmax(0, 1fr) 214px;
  }

  .mapping-toolbar {
    gap: 6px;
  }
}

/* --------------------------------------------------------------------------
   Tablet landscape / small laptop: wrap full-tab headers, expose table scroll,
   and prevent action buttons from spilling past the right edge.
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .full-tab-view {
    padding: 14px 16px 14px 28px;
  }

  .full-tab-header {
    align-items: flex-start;
  }

  .full-tab-title-group {
    width: 100%;
    flex-wrap: wrap;
    flex-shrink: 1;
    min-width: 0;
  }

  .full-tab-title {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .full-tab-subtitle {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .full-tab-actions {
    width: 100%;
    flex-wrap: wrap;
    flex-shrink: 1;
    justify-content: flex-start;
  }

  .deconv-display-options {
    flex-wrap: wrap;
    gap: 6px 10px;
  }

  .full-table-wrapper {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* Empty tables are wider than the viewport: keep their guidance message
     anchored to the visible left edge instead of centering it off-screen. */
  .roi-management-table .table-empty-row td,
  .deconv-full-table .table-empty-row td {
    text-align: left !important;
    white-space: normal;
    padding-left: 20px !important;
    background: var(--bg-card);
  }

  .roi-management-table {
    min-width: 980px;
  }

  .deconv-full-table {
    min-width: 1000px;
  }

  .data-table th,
  .data-table td {
    padding-left: 10px;
    padding-right: 10px;
  }

  .roi-management-table th:first-child,
  .roi-management-table td:first-child,
  .deconv-full-table th:first-child,
  .deconv-full-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
  }

  .roi-management-table td:first-child,
  .deconv-full-table td:first-child {
    background: var(--bg-card);
  }

  .roi-management-table th:first-child,
  .deconv-full-table th:first-child {
    z-index: 4;
  }

  .mapping-toolbar-section {
    max-width: 100%;
  }

  .mapping-viewport-grid {
    grid-template-columns: 190px minmax(0, 1fr) 205px;
  }
}

/* --------------------------------------------------------------------------
   Tablet portrait / narrow window: drawer sidebar, collapsible plot toolbar,
   and a two-column mapping workspace (map + regions, camera/intensity below).
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
    position: relative;
  }

  .workspace-grid.sidebar-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar-left {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 90;
    width: min(320px, 86vw);
    min-width: 0;
    max-width: 86vw;
    box-shadow: 12px 0 34px rgba(15, 23, 42, 0.28);
  }

  .workspace-grid.sidebar-collapsed .sidebar-left {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    box-shadow: none;
  }

  .sidebar-scrim {
    position: absolute;
    inset: 0;
    z-index: 80;
    display: block;
    background: rgba(15, 23, 42, 0.38);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
  }

  .workspace-grid:not(.sidebar-collapsed) .sidebar-scrim {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .sidebar-edge-toggle {
    z-index: 95;
  }

  /* All five tabs stay visible with compact labels. */
  .top-tab-btn .tab-label-full {
    display: none;
  }

  .top-tab-btn .tab-label-short {
    display: inline;
  }

  .btn-viewer-toolbar-toggle {
    display: inline-flex;
    flex-shrink: 0;
  }

  .chart-toolbar {
    flex-wrap: nowrap;
    overflow: hidden;
  }

  .chart-toolbar > .toolbar-group {
    display: none;
  }

  .chart-toolbar.toolbar-expanded {
    flex-wrap: wrap;
    align-content: flex-start;
    max-height: 44vh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .chart-toolbar.toolbar-expanded > .toolbar-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    max-width: 100%;
    row-gap: 4px;
  }

  .chart-toolbar.toolbar-expanded .toolbar-divider {
    display: none;
  }

  .chart-toolbar > .toolbar-actions-right {
    margin-left: auto;
  }

  .toolbar-toggle-caret {
    display: inline-block;
    transition: transform 0.2s ease;
  }

  .chart-toolbar.toolbar-expanded .toolbar-toggle-caret {
    transform: rotate(180deg);
  }

  .canvas-wrapper {
    margin: 5px 8px;
  }

  .canvas-bottom-bar {
    padding-left: 8px;
    padding-right: 8px;
  }

  .full-tab-view {
    padding: 12px 12px 12px 28px;
    overflow-y: auto;
  }

  .full-tab-header {
    padding: 8px 10px;
  }

  .full-tab-actions {
    gap: 5px;
  }

  .full-tab-actions .btn {
    font-size: 11px;
    padding: 5px 8px;
  }

  .full-table-wrapper {
    flex: 0 0 auto;
    min-height: 280px;
    max-height: 64vh;
  }

  .deconv-controls-strip {
    gap: 8px;
  }

  /* Mapping page becomes vertically scrollable; toolbar stays reachable. */
  .mapping-container {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 8px 8px 22px;
  }

  .mapping-toolbar {
    position: sticky;
    top: 0;
    z-index: 30;
  }

  .mapping-viewport-grid {
    grid-template-columns: minmax(0, 1fr) 238px;
    grid-template-areas:
      "main features"
      "left left";
    grid-template-rows: minmax(430px, 56vh) auto;
    flex: 0 0 auto;
    overflow: visible;
  }

  .mapping-main-panel {
    grid-area: main;
    min-height: 430px;
    height: 56vh;
  }

  .mapping-features-panel {
    grid-area: features;
    min-height: 430px;
    height: 56vh;
  }

  .mapping-left-column {
    grid-area: left;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    height: auto;
    overflow: visible;
  }

  .mapping-camera-panel,
  .mapping-intensity-panel {
    height: auto;
    min-height: 300px;
  }

  .mapping-splitter {
    display: none;
  }

  .mapping-carousel-tray {
    height: auto;
    min-height: 150px;
    flex-shrink: 0;
  }

  .carousel-tray-header {
    flex-wrap: wrap;
    gap: 6px 10px;
  }

  .mapping-features-panel .mapping-panel-header {
    flex-wrap: wrap;
    gap: 6px;
  }

  .mapping-canvas-wrapper {
    left: 50px;
    right: 50px;
  }

  /* FP workspace: reflow its two-column control grids and let wide scientific
     tables scroll inside their card instead of clipping buttons off-screen. */
  .fp-excitation-layout,
  .fp-absorbers-grid {
    grid-template-columns: 1fr !important;
  }

  .fp-excitation-layout > div,
  .fp-absorbers-grid > div {
    min-width: 0;
  }

  .fp-table-scroll {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .fp-table-scroll > table {
    min-width: 560px;
  }

  .fp-excitation-actions {
    flex-wrap: wrap;
  }

  .fp-flux-row {
    flex-wrap: wrap;
    align-items: flex-start !important;
    row-gap: 6px;
  }

  .fp-geom-controls .geom-row,
  #secGeometry .geom-row {
    flex-wrap: wrap;
  }

  #secGeometry .geom-row input[type="text"] {
    flex: 1 1 160px;
    min-width: 0;
  }

  .fp-3d-viewport {
    min-height: 420px;
  }
}

/* --------------------------------------------------------------------------
   Narrow tablet / large phone: icon-first header actions; keep the brand and
   every tab visible without horizontal clipping.
   -------------------------------------------------------------------------- */
@media (max-width: 760px) {
  .top-navbar {
    padding: 5px 8px;
    gap: 5px 8px;
  }

  .brand-group {
    gap: 7px;
  }

  #btnOpenFiles .btn-label,
  #btnTogglePeriodicTable .btn-label,
  #btnSettingsToolsDropdown .btn-label {
    display: none;
  }

  #btnOpenFiles,
  #btnTogglePeriodicTable,
  #btnSettingsToolsDropdown {
    padding: 6px 9px;
  }

  #btnDemoFiles .btn-label-full {
    display: none;
  }

  #btnDemoFiles .btn-label-short {
    display: inline;
  }

  .settings-tools-menu {
    min-width: min(320px, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px) !important;
  }

  .chart-toolbar {
    margin: 5px 7px 0 7px;
    padding: 3px 6px;
    gap: 3px;
  }

  .chart-toolbar .btn-sm {
    padding: 3px 5px;
    font-size: 10.5px;
  }

  .chart-toolbar .btn-deconv-run {
    padding: 4px 8px;
    font-size: 11px;
  }

  .chart-toolbar .line-width-input {
    width: 30px;
  }

  .canvas-wrapper {
    margin: 4px 7px;
  }

  .canvas-bottom-bar {
    padding-left: 7px;
    padding-right: 7px;
  }

  .mapping-toolbar {
    gap: 5px;
    padding: 4px 6px;
  }

  .mapping-toolbar-section {
    flex-wrap: wrap;
    min-width: 0;
  }
}

/* --------------------------------------------------------------------------
   Phone: icon-only top-level tabs and actions, single-column mapping, compact
   data chrome. Every control remains rendered and reachable.
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
  html,
  body {
    font-size: 12px;
  }

  .top-navbar {
    padding: 5px 7px;
  }

  .brand-logo-img {
    width: 30px;
    height: 30px;
    border-radius: 7px;
  }

  .brand-title {
    font-size: 15px;
  }

  .brand-group {
    gap: 6px;
  }

  .nav-right-group {
    gap: 5px;
  }

  .top-tabs-nav {
    gap: 2px;
    padding: 2px;
    overflow: hidden;
  }

  .top-tab-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 7px;
    gap: 4px;
  }

  .top-tab-btn .tab-label-short {
    display: none;
  }

  .top-tab-btn .xrf-icon {
    width: 17px;
    height: 17px;
  }

  .deconv-unread-dot {
    width: 6px;
    height: 6px;
  }

  .top-tab-btn .brand-badge {
    font-size: 8px;
    padding: 1px 4px;
  }

  .settings-tools-menu {
    right: 0;
    left: auto;
  }

  .btn-viewer-toolbar-toggle .btn-label {
    font-size: 10.5px;
  }

  .chart-toolbar .btn-accent {
    padding: 3px 5px;
    font-size: 10.5px;
  }

  .chart-toolbar .btn-deconv-run span:not(.xrf-icon) {
    display: none;
  }

  .chart-toolbar.toolbar-expanded {
    max-height: 48vh;
  }

  .canvas-wrapper {
    margin: 4px 6px;
    border-radius: 6px;
  }

  .canvas-bottom-bar {
    padding: 0 6px 3px 6px;
    gap: 4px;
  }

  .snip-bottom-dock {
    padding: 3px 5px;
  }

  .snip-dock-body,
  .snip-options-group {
    gap: 5px;
  }

  .snip-range-slider {
    width: 100px;
  }

  .canvas-hud-top-right-legend {
    top: 12px;
    right: 12px;
    padding: 5px 8px;
    max-height: calc(100% - 40px);
  }

  .hud-legend-item {
    font-size: 10px;
  }

  .full-tab-view {
    padding: 8px 8px 8px 26px;
  }

  .full-tab-header {
    padding: 8px;
    gap: 8px;
  }

  .full-tab-title {
    font-size: 14px;
    line-height: 1.25;
  }

  .full-tab-actions {
    gap: 4px;
  }

  .full-tab-actions .btn {
    font-size: 10.5px;
    padding: 5px 7px;
  }

  .full-tab-actions .toolbar-divider {
    display: none;
  }

  .full-table-wrapper {
    min-height: 240px;
    max-height: 58vh;
  }

  .data-table th {
    padding: 7px 8px;
    font-size: 10px;
  }

  .data-table td {
    padding: 7px 8px;
    font-size: 12px;
  }

  .roi-management-table {
    min-width: 940px;
  }

  .deconv-full-table {
    min-width: 960px;
  }

  .alert-banner {
    padding: 8px 10px !important;
    font-size: 11.5px !important;
  }

  .pileup-bar {
    flex-wrap: wrap;
  }

  .mapping-container {
    padding: 6px 6px 6px 18px;
    gap: 6px;
  }

  /* Phone mapping toolbar: one full-width capsule per control family.
     Sub-controls wrap internally so no select or button is clipped. */
  .mapping-toolbar {
    position: static;
    width: 100%;
    align-items: flex-start;
    row-gap: 5px;
  }

  .mapping-toolbar-section {
    width: 100%;
    height: auto;
    min-height: 28px;
    flex-wrap: wrap;
    row-gap: 3px;
    padding: 3px 7px;
    box-sizing: border-box;
  }

  .mapping-mode-controls-slot {
    min-width: 0;
    width: 100%;
  }

  .mapping-subgroup {
    width: 100%;
    flex-wrap: wrap;
    row-gap: 5px;
  }

  .mapping-toolbar-section .mapping-select {
    flex: 1 1 150px;
    min-width: 0;
    max-width: 100%;
  }

  .mapping-toolbar-section .toolbar-label {
    flex: 0 0 auto;
  }

  .mapping-section-method .btn-group-toggle {
    flex-wrap: wrap;
  }

  .fp-stepper-bar {
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    min-height: 0;
    padding: 4px 2px;
  }

  .fp-step-btn {
    flex: 0 0 calc(33.333% - 6px);
    min-height: 32px;
    padding: 5px 4px;
    font-size: 10.5px;
    gap: 3px;
  }

  .fp-step-btn .xrf-icon {
    width: 12px;
    height: 12px;
  }

  .fp-step-btn .fp-status-dot {
    width: 6px;
    height: 6px;
  }

  .mapping-viewport-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "main"
      "features"
      "left";
    grid-template-rows: auto auto auto;
    gap: 6px;
  }

  .mapping-main-panel {
    height: clamp(360px, 54vh, 520px);
    min-height: 360px;
  }

  .mapping-features-panel {
    height: 320px;
    min-height: 280px;
  }

  .mapping-left-column {
    grid-template-columns: minmax(0, 1fr);
  }

  .mapping-camera-panel,
  .mapping-intensity-panel {
    min-height: 280px;
  }

  .mapping-canvas-wrapper {
    left: 32px;
    right: 34px;
    top: 5px;
    bottom: 5px;
  }

  .mapping-floating-toolbox {
    left: 4px;
    padding: 4px 3px;
  }

  .mapping-colorbar-container {
    right: 4px;
    padding: 5px 4px;
  }

  .mapping-hud {
    left: 6px;
    right: 44px;
    bottom: 6px;
    max-width: calc(100% - 52px);
    font-size: 10px;
    gap: 4px;
  }

  .mapping-toolbar-section {
    width: auto;
  }

  .mapping-toolbar-section .mapping-select {
    max-width: 100%;
  }

  .mapping-carousel-tray {
    padding: 6px 8px;
  }

  .mapping-element-gallery {
    gap: 6px;
  }

  .mapping-gallery-card {
    min-width: 72px;
  }

  .mapping-panel-header {
    padding: 5px 8px;
    font-size: 11.5px;
  }

  .fp-top-bar,
  .fp-card,
  .fp-stepper-bar {
    max-width: 100%;
  }

  .fp-container {
    padding: 10px 8px 10px 24px;
  }

  .fp-card {
    padding: 10px;
  }

  .fp-plot-box {
    height: 320px !important;
  }

  .fp-3d-viewport {
    min-height: 360px;
  }

  .fp-table-scroll > table {
    min-width: 520px;
  }

  .fp-excitation-actions .btn {
    flex: 1 1 100%;
    justify-content: center;
  }

  .fp-flux-row {
    gap: 6px;
  }

  .fp-flux-row > label {
    flex: 1 1 100%;
  }

  .fp-flux-row #inpResultsFlux {
    flex: 0 1 110px;
    width: 110px !important;
  }

  .fp-flux-row > div {
    flex-wrap: wrap;
  }

  .fp-geom-controls .geom-row label.t {
    flex: 1 1 100%;
  }

  .fp-geom-controls .geom-row {
    gap: 4px;
  }

  .fp-geom-controls input[type="number"] {
    width: 66px;
  }

  .fp-geom-controls .ax {
    margin-left: 2px;
  }

  /* Card headers: title and actions stack instead of colliding or clipping. */
  .fp-card > div:first-child {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .fp-card > div:first-child > div {
    min-width: 0;
  }

  .fp-detector-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  .fp-matrix-effects-box,
  #fpMatrixModeSubControls {
    width: 100%;
    box-sizing: border-box;
  }

  .fp-matrix-effects-buttons {
    flex-wrap: wrap;
  }

  .fp-matrix-effects-buttons .btn {
    flex: 1 1 100%;
  }

  .xmi-excitation-dropdown summary {
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .xmi-excitation-dropdown summary > span:last-child {
    display: none;
  }
}

@media (max-width: 420px) {
  .brand-title {
    font-size: 14px;
  }

  #btnDemoFiles {
    padding-left: 7px;
    padding-right: 7px;
  }

  .btn-viewer-toolbar-toggle {
    padding-left: 7px;
    padding-right: 7px;
  }

  .btn-viewer-toolbar-toggle .btn-label {
    display: inline;
    font-size: 10px;
  }

  .chart-toolbar .btn-deconv-run {
    padding-left: 6px;
    padding-right: 6px;
  }

  .mapping-canvas-wrapper {
    left: 28px;
    right: 30px;
  }
}

/* --------------------------------------------------------------------------
   Large screens (2K/QHD, 4K at native scaling): improve physical density
   without applying transform/zoom. Strictly above 1920 so 1080p is untouched.
   -------------------------------------------------------------------------- */
@media (min-width: 2000px) {
  .top-navbar {
    height: 60px;
    min-height: 60px;
    padding: 0 22px;
  }

  .brand-logo-img {
    width: 38px;
    height: 38px;
  }

  .brand-title {
    font-size: 19px;
  }

  .btn {
    font-size: 13px;
    padding: 7px 13px;
  }

  .top-tab-btn {
    font-size: 13.5px;
    padding: 7px 15px;
  }

  .workspace-grid {
    grid-template-columns: clamp(340px, 18vw, 390px) minmax(0, 1fr);
  }

  .panel-section {
    padding: 12px;
  }

  .section-title {
    font-size: 12px;
  }

  .chart-toolbar {
    padding: 5px 10px;
    margin: 8px 16px 0 16px;
  }

  .chart-toolbar .btn-sm {
    padding: 4px 8px;
    font-size: 12px;
  }

  .canvas-wrapper {
    margin: 8px 16px;
  }

  .data-table {
    font-size: 14px;
  }

  .data-table th {
    font-size: 12px;
    padding: 11px 16px;
  }

  .data-table td {
    font-size: 14px;
    padding: 10px 16px;
  }

  .full-tab-view {
    padding: 22px 30px;
  }

  .full-tab-title {
    font-size: 18px;
  }

  .mapping-viewport-grid {
    grid-template-columns: 260px minmax(0, 1fr) 300px;
  }

  .mapping-panel-header {
    padding: 8px 12px;
    font-size: 13px;
  }

  .mapping-toolbar {
    padding: 6px 12px;
    gap: 10px;
    font-size: 12px;
  }

  .mapping-canvas-wrapper {
    left: 68px;
    right: 68px;
  }

  .mapping-carousel-tray {
    height: 172px;
    padding: 8px 14px;
  }
}

@media (min-width: 3200px) {
  .btn {
    font-size: 14px;
    padding: 8px 15px;
  }

  .top-tab-btn {
    font-size: 14.5px;
    padding: 8px 17px;
  }

  .data-table {
    font-size: 15px;
  }

  .data-table th {
    font-size: 12.5px;
  }

  .data-table td {
    font-size: 15px;
  }

  .mapping-viewport-grid {
    grid-template-columns: 300px minmax(0, 1fr) 340px;
  }
}


