/* ═══════════════════════════════════════════════════════════════════════════
   ChemForge — Editorial Overhaul
   Mirrors the marketing site (chemforge.net) inside the working app.
   Layered on top of Bootstrap + dashboard.css; no JS contract changes.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design tokens ────────────────────────────────────────────────────────── */
:root {
  --cf-blue-900: #1e3a5f;
  --cf-blue-800: #1e40af;
  --cf-blue-700: #1d4ed8;
  --cf-blue-600: #2563eb;
  --cf-blue-500: #3b82f6;
  --cf-blue-400: #60a5fa;
  --cf-blue-300: #93c5fd;
  --cf-blue-100: #dbeafe;

  --cf-navy:   #0a0f1e;
  --cf-navy-2: #0d1526;
  --cf-card:   #1a2235;
  --cf-card-2: #1f2d44;
  --cf-border: rgba(30, 58, 95, 0.55);
  --cf-border-strong: rgba(96, 165, 250, 0.30);
  --cf-text:   #f1f5f9;
  --cf-muted:  #94a3b8;
  --cf-dimmed: #64748b;

  --cf-shadow-glow: 0 0 24px rgba(37, 99, 235, 0.22);
  --cf-shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.35);
  --cf-radius:    10px;
  --cf-radius-lg: 14px;

  --cf-font-sans:    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                     "Helvetica Neue", Arial, sans-serif;
  --cf-font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                     "Helvetica Neue", Arial, sans-serif;
  --cf-font-mono:    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* Sync Bootstrap dark-theme tokens with the site palette so cards, modals,
   form controls and tables inherit the navy aesthetic for free. */
[data-bs-theme="dark"] {
  --bs-body-bg:        var(--cf-navy);
  --bs-body-color:     var(--cf-text);
  --bs-secondary-bg:   var(--cf-card);
  --bs-tertiary-bg:    var(--cf-card-2);
  --bs-border-color:   var(--cf-border);
  --bs-primary:        var(--cf-blue-600);
  --bs-primary-rgb:    37, 99, 235;
  --bs-link-color:     var(--cf-blue-400);
  --bs-link-hover-color: var(--cf-blue-300);
  --bs-link-color-rgb: 96, 165, 250;
}

body {
  font-family: var(--cf-font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01", "ss03";
  letter-spacing: 0;
}

/* Ambient cosmic backdrop (dark mode). A pair of soft radial blooms
   give the empty canvas the same "deep space" feel as the hero section. */
[data-bs-theme="dark"] body {
  background:
    radial-gradient(ellipse 60% 40% at 78% -10%, rgba(37, 99, 235, 0.18) 0%, transparent 60%),
    radial-gradient(ellipse 50% 35% at 12% 110%, rgba(29, 78, 216, 0.14) 0%, transparent 65%),
    var(--cf-navy);
  background-attachment: fixed;
}

/* Light-mode equivalent — pale ice blue with the same atmospheric grading */
:root:not([data-bs-theme="dark"]) body,
[data-bs-theme="light"] body {
  background:
    radial-gradient(ellipse 60% 40% at 82% -8%, rgba(37, 99, 235, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 50% 35% at 8% 108%, rgba(96, 165, 250, 0.07) 0%, transparent 65%),
    #f8fafc;
  background-attachment: fixed;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
[data-bs-theme="dark"] nav.sidebar {
  background: linear-gradient(180deg,
              rgba(13, 21, 38, 0.92),
              rgba(10, 15, 30, 0.96)) !important;
  border-right: 1px solid var(--cf-border);
  box-shadow: inset -1px 0 0 rgba(96, 165, 250, 0.04),
              4px 0 24px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* Accordion headers — pill-style, with a gradient indicator bar on active */
.cf-accordion-item {
  border-bottom: none;
  padding: 1px 8px;
}
.cf-accordion-btn {
  position: relative;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}
.cf-accordion-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--cf-blue-500), var(--cf-blue-700));
  opacity: 0;
  transform: scaleY(0.4);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.cf-accordion-btn[aria-expanded="true"]::before,
.cf-accordion-btn:hover::before {
  opacity: 1;
  transform: scaleY(1);
}
[data-bs-theme="dark"] .cf-accordion-btn {
  color: #e2e8f0;
}
[data-bs-theme="dark"] .cf-accordion-btn .cf-acc-icon svg {
  color: #cbd5e1 !important;
}
[data-bs-theme="dark"] .cf-accordion-btn:hover {
  background: rgba(96, 165, 250, 0.08);
  color: #ffffff;
}
[data-bs-theme="dark"] .cf-accordion-btn[aria-expanded="true"] {
  background: linear-gradient(90deg,
              rgba(37, 99, 235, 0.22) 0%,
              rgba(37, 99, 235, 0.04) 100%);
  color: var(--cf-blue-300);
}
[data-bs-theme="dark"] .cf-accordion-btn[aria-expanded="true"] .cf-acc-icon svg {
  color: var(--cf-blue-300) !important;
  filter: drop-shadow(0 0 6px rgba(96, 165, 250, 0.45));
}
.cf-acc-icon svg { transition: transform 0.18s ease, filter 0.18s ease; }
.cf-accordion-btn:hover .cf-acc-icon svg { transform: scale(1.08); }

/* Sub-menu nav links — brighten in dark mode for legibility on navy */
[data-bs-theme="dark"] .cf-accordion-body .nav-link,
[data-bs-theme="dark"] .sidebar .nav-link {
  color: #e6edf3 !important;
}
[data-bs-theme="dark"] .cf-accordion-body .nav-link:hover,
[data-bs-theme="dark"] .sidebar .nav-link:hover {
  color: #ffffff !important;
  background: rgba(96, 165, 250, 0.07);
}
[data-bs-theme="dark"] .cf-accordion-body .nav-link svg,
[data-bs-theme="dark"] .sidebar .nav-link svg {
  color: #93a4b8 !important;
  transition: color 0.15s ease;
}
[data-bs-theme="dark"] .cf-accordion-body .nav-link:hover svg,
[data-bs-theme="dark"] .sidebar .nav-link:hover svg {
  color: var(--cf-blue-300) !important;
}

/* Section sub-headers (e.g. "CODES" inside Setup) */
[data-bs-theme="dark"] .sidebar-heading {
  color: var(--cf-blue-300) !important;
  letter-spacing: 0.08em;
  opacity: 0.85;
}

/* ── Unit-op menu icons (hardcoded SVGs with light fills) ─────────────────
   Many unit configs ship a menuSvg literal with fill="#fff"/#f5f5f5 etc.,
   which renders as a white blob on the dark sidebar. The wrapper is the
   inline-styled span generated in UnitRegistry.buildMenu(). Frame it in a
   small blue-tinted chip and invert the SVG's baked-in tones so equipment
   strokes appear as light lines on a near-transparent body. */
[data-bs-theme="dark"] .cf-accordion-body .nav-link > span[style*="display:inline-block"] {
  background: rgba(96, 165, 250, 0.08);
  border: 1px solid rgba(96, 165, 250, 0.18);
  border-radius: 5px;
  padding: 1px;
  box-sizing: border-box;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
[data-bs-theme="dark"] .cf-accordion-body .nav-link:hover > span[style*="display:inline-block"] {
  background: rgba(96, 165, 250, 0.16);
  border-color: rgba(96, 165, 250, 0.45);
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.30);
}
[data-bs-theme="dark"] .cf-accordion-body .nav-link > span[style*="display:inline-block"] > svg {
  filter: invert(0.92) hue-rotate(180deg) saturate(0.6) brightness(1.05);
}

/* Drag-ghost preview that follows the cursor — its inline bg is white,
   so re-skin it in dark mode to match the chip palette */
[data-bs-theme="dark"] body > div[style*="position:fixed"][style*="border:2px dashed"] {
  background: rgba(13, 21, 38, 0.92) !important;
  border-color: rgba(96, 165, 250, 0.55) !important;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45),
              0 0 20px rgba(37, 99, 235, 0.35) !important;
}
[data-bs-theme="dark"] body > div[style*="position:fixed"][style*="border:2px dashed"] svg {
  filter: invert(0.92) hue-rotate(180deg) saturate(0.6) brightness(1.05);
}

/* Sheet list — refined active state with blue glow rail */
.sheet-list .nav-link {
  border-radius: 6px;
  margin: 1px 8px;
  padding: 5px 10px !important;
  font-size: 0.78rem;
  transition: background 0.15s ease, color 0.15s ease;
}
[data-bs-theme="dark"] .sheet-list .nav-link.active {
  background: linear-gradient(90deg,
              rgba(37, 99, 235, 0.22),
              rgba(37, 99, 235, 0.05)) !important;
  border-left-color: var(--cf-blue-400) !important;
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.12);
  color: #dbeafe !important;
}
[data-bs-theme="dark"] .sheet-list .nav-link.active::after {
  background: rgba(96, 165, 250, 0.18) !important;
  color: var(--cf-blue-300) !important;
  border: 1px solid rgba(96, 165, 250, 0.25);
  text-transform: lowercase;
  letter-spacing: 0.04em;
}

/* Sidebar collapse rail buttons get the website's button feel */
#sidebar-collapse-btn,
.banner-toggle-btn {
  border-radius: 6px !important;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.12s;
}
[data-bs-theme="dark"] #sidebar-collapse-btn,
[data-bs-theme="dark"] .banner-toggle-btn {
  background: rgba(255, 255, 255, 0.04) !important;
  border-color: var(--cf-border) !important;
  color: var(--cf-muted) !important;
}
[data-bs-theme="dark"] #sidebar-collapse-btn:hover,
[data-bs-theme="dark"] .banner-toggle-btn:hover {
  background: rgba(37, 99, 235, 0.18) !important;
  border-color: rgba(96, 165, 250, 0.35) !important;
  color: var(--cf-text) !important;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.28);
}

/* Autosave status footer — typographic refinement */
#sidebar-autosave-status {
  font-family: var(--cf-font-mono) !important;
  font-size: 0.68rem !important;
  letter-spacing: 0.02em;
  padding: 10px 16px !important;
}
[data-bs-theme="dark"] #sidebar-autosave-status {
  color: var(--cf-dimmed) !important;
  border-top-color: var(--cf-border) !important;
  background: rgba(10, 15, 30, 0.6) !important;
}

/* ── Compact banner (top strip) ──────────────────────────────────────────── */
.banner-compact {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 8px 0 8px;
  margin-bottom: 8px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--cf-border);
}
[data-bs-theme="dark"] .banner-compact {
  background: linear-gradient(180deg,
              rgba(13, 21, 38, 0.88),
              rgba(13, 21, 38, 0.72));
}
:root:not([data-bs-theme="dark"]) .banner-compact,
[data-bs-theme="light"] .banner-compact {
  background: linear-gradient(180deg,
              rgba(248, 250, 252, 0.92),
              rgba(241, 245, 249, 0.78));
  border-bottom-color: rgba(30, 58, 95, 0.12);
}
.banner-compact-logo {
  height: 26px;
  filter: drop-shadow(0 0 8px rgba(96, 165, 250, 0.25));
}
.banner-compact-title {
  font-family: var(--cf-font-display) !important;
  font-weight: 800 !important;
  font-size: 1.15rem !important;
  letter-spacing: -0.02em !important;
  text-transform: none !important;
  text-shadow: none !important;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent !important;
}
[data-bs-theme="dark"] .banner-compact-title {
  background-image: linear-gradient(135deg, #f1f5f9 20%, var(--cf-blue-300) 90%);
}
:root:not([data-bs-theme="dark"]) .banner-compact-title,
[data-bs-theme="light"] .banner-compact-title {
  background-image: linear-gradient(135deg, #0f172a 10%, var(--cf-blue-600) 95%);
}

/* Edit toolbar — refined buttons, blue-hover glow */
.edit-toolbar-btn {
  border-radius: 7px !important;
  width: 30px !important;
  height: 26px !important;
  transition: background 0.15s, color 0.15s, border-color 0.15s,
              box-shadow 0.15s, transform 0.1s;
}
.edit-toolbar-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}
.edit-toolbar-btn:active:not(:disabled) {
  transform: translateY(0);
}
[data-bs-theme="dark"] .edit-toolbar-btn {
  background: rgba(26, 34, 53, 0.6) !important;
  border-color: var(--cf-border) !important;
  color: #c9d1d9 !important;
}
[data-bs-theme="dark"] .edit-toolbar-btn:hover:not(:disabled) {
  background: rgba(37, 99, 235, 0.18) !important;
  border-color: rgba(96, 165, 250, 0.45) !important;
  color: var(--cf-blue-300) !important;
  box-shadow: 0 0 14px rgba(37, 99, 235, 0.30);
}
.edit-toolbar-sep {
  background: linear-gradient(180deg, transparent, rgba(96, 165, 250, 0.35), transparent) !important;
  height: 18px !important;
  margin: 0 6px !important;
}

/* Expanded banner — bigger gradient title */
[data-bs-theme="dark"] .banner-text-title {
  font-family: var(--cf-font-display);
  color: transparent !important;
  background: linear-gradient(135deg, #ffffff 0%, var(--cf-blue-400) 80%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none !important;
  letter-spacing: -0.025em !important;
  font-weight: 800 !important;
}

/* ── Buttons (Bootstrap) ──────────────────────────────────────────────────── */
[data-bs-theme="dark"] .btn-primary {
  background: var(--cf-blue-600);
  border-color: var(--cf-blue-600);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 0.15s, box-shadow 0.18s, transform 0.1s;
}
[data-bs-theme="dark"] .btn-primary:hover {
  background: var(--cf-blue-700);
  border-color: var(--cf-blue-700);
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.45);
}
[data-bs-theme="dark"] .btn-primary:active {
  transform: translateY(1px);
}

[data-bs-theme="dark"] .btn-outline-primary {
  color: var(--cf-blue-300);
  border-color: rgba(96, 165, 250, 0.45);
}
[data-bs-theme="dark"] .btn-outline-primary:hover {
  background: rgba(37, 99, 235, 0.15);
  border-color: var(--cf-blue-400);
  color: var(--cf-blue-300);
  box-shadow: 0 0 14px rgba(37, 99, 235, 0.25);
}
[data-bs-theme="dark"] .btn-secondary {
  background: var(--cf-card-2);
  border-color: var(--cf-border);
  color: var(--cf-text);
}
[data-bs-theme="dark"] .btn-secondary:hover {
  background: #2a3b56;
  border-color: rgba(96, 165, 250, 0.35);
}
[data-bs-theme="dark"] .btn-success {
  background: #16a34a;
  border-color: #16a34a;
}
[data-bs-theme="dark"] .btn-danger  { background: #dc2626; border-color: #dc2626; }
[data-bs-theme="dark"] .btn-warning { background: #d97706; border-color: #d97706; color: #fff; }

/* ── Modals — soft card with glow ─────────────────────────────────────────── */
[data-bs-theme="dark"] .modal-content {
  background: linear-gradient(180deg, var(--cf-card), #161e30);
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-radius-lg);
  box-shadow: var(--cf-shadow-soft),
              0 0 60px rgba(37, 99, 235, 0.10);
  overflow: hidden;
}
[data-bs-theme="dark"] .modal-header {
  background: rgba(31, 45, 68, 0.65);
  border-bottom: 1px solid var(--cf-border);
  padding: 14px 20px;
}
[data-bs-theme="dark"] .modal-header .modal-title {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--cf-text);
}
[data-bs-theme="dark"] .modal-footer {
  background: rgba(13, 21, 38, 0.45);
  border-top: 1px solid var(--cf-border);
}
[data-bs-theme="dark"] .modal-backdrop.show {
  opacity: 0.7;
  background: radial-gradient(ellipse at center,
              rgba(10, 15, 30, 0.85), rgba(0, 0, 0, 0.95));
}

/* ── Form controls — refined focus ring ───────────────────────────────────── */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: rgba(13, 21, 38, 0.55);
  border-color: var(--cf-border);
  color: var(--cf-text);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: rgba(13, 21, 38, 0.85);
  border-color: var(--cf-blue-500);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
}
[data-bs-theme="dark"] .form-control::placeholder { color: var(--cf-dimmed); }

[data-bs-theme="dark"] .form-check-input:checked {
  background-color: var(--cf-blue-500);
  border-color: var(--cf-blue-500);
  box-shadow: 0 0 8px rgba(96, 165, 250, 0.4);
}

/* ── Tabs (nav-tabs) — underline-style highlight ──────────────────────────── */
[data-bs-theme="dark"] .nav-tabs {
  border-bottom: 1px solid var(--cf-border);
}
[data-bs-theme="dark"] .nav-tabs .nav-link {
  color: var(--cf-muted);
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
[data-bs-theme="dark"] .nav-tabs .nav-link:hover {
  color: var(--cf-text);
  border-bottom-color: rgba(96, 165, 250, 0.3);
  background: rgba(255, 255, 255, 0.02);
}
[data-bs-theme="dark"] .nav-tabs .nav-link.active {
  color: var(--cf-blue-300);
  background: transparent;
  border-bottom: 2px solid var(--cf-blue-400);
  box-shadow: 0 4px 14px -10px rgba(96, 165, 250, 0.8);
}

/* ── Tables — quieter, classier ──────────────────────────────────────────── */
[data-bs-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--cf-text);
  --bs-table-border-color: var(--cf-border);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
  --bs-table-hover-bg: rgba(37, 99, 235, 0.07);
}

/* ── Toast notifications — match modal card style ─────────────────────────── */
[data-bs-theme="dark"] .cf-toast {
  border-radius: 10px !important;
  border: 1px solid var(--cf-border) !important;
  background: linear-gradient(180deg, var(--cf-card), #151c2c) !important;
  box-shadow: var(--cf-shadow-soft),
              0 0 20px rgba(37, 99, 235, 0.12) !important;
}

/* ── Dropdowns ────────────────────────────────────────────────────────────── */
[data-bs-theme="dark"] .dropdown-menu {
  background: var(--cf-card);
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-radius);
  box-shadow: var(--cf-shadow-soft);
  padding: 6px;
}
[data-bs-theme="dark"] .dropdown-item {
  border-radius: 6px;
  color: var(--cf-text);
  padding: 6px 10px;
  font-size: 0.85rem;
}
[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
  background: rgba(37, 99, 235, 0.18);
  color: var(--cf-blue-300);
}
[data-bs-theme="dark"] .dropdown-divider { border-color: var(--cf-border); }

/* ── Scrollbars (WebKit) ─────────────────────────────────────────────────── */
[data-bs-theme="dark"] ::-webkit-scrollbar { width: 10px; height: 10px; }
[data-bs-theme="dark"] ::-webkit-scrollbar-track { background: var(--cf-navy); }
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--cf-card-2);
  border-radius: 10px;
  border: 2px solid var(--cf-navy);
}
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: var(--cf-blue-700);
}

/* ── SVG canvas — subtle grid + atmospheric gradient ─────────────────────── */
[data-bs-theme="dark"] .svg-content-responsive {
  background-color: #0e1726 !important;
  background-image:
    radial-gradient(circle at 25% 0%, rgba(37, 99, 235, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 90% 100%, rgba(29, 78, 216, 0.05) 0%, transparent 50%),
    linear-gradient(rgba(96, 165, 250, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(96, 165, 250, 0.04) 1px, transparent 1px) !important;
  background-size: auto, auto, 24px 24px, 24px 24px !important;
  border-radius: var(--cf-radius);
  border: 1px solid var(--cf-border);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.45);
}

/* Light-mode SVG canvas — softer paper feel */
.svg-content-responsive {
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ── Progress overlay — frosted card ──────────────────────────────────────── */
[data-bs-theme="dark"] #cf-progress-box {
  background: linear-gradient(180deg, var(--cf-card), #161e30) !important;
  border: 1px solid var(--cf-border) !important;
  border-radius: var(--cf-radius-lg) !important;
  box-shadow: var(--cf-shadow-soft),
              0 0 50px rgba(37, 99, 235, 0.18) !important;
  padding: 22px 28px !important;
}
[data-bs-theme="dark"] #cf-progress-overlay {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ═══════════════════════════════════════════════════════════════════════════
   LIGHT MODE — equivalent polish so the GUI feels editorial in both modes
   ═══════════════════════════════════════════════════════════════════════════ */

:root:not([data-bs-theme="dark"]) nav.sidebar,
[data-bs-theme="light"] nav.sidebar {
  background: linear-gradient(180deg,
              rgba(255, 255, 255, 0.92),
              rgba(248, 250, 252, 0.94)) !important;
  border-right: 1px solid rgba(30, 58, 95, 0.10);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 4px 0 20px rgba(30, 58, 95, 0.04);
}

:root:not([data-bs-theme="dark"]) .cf-accordion-btn[aria-expanded="true"],
[data-bs-theme="light"] .cf-accordion-btn[aria-expanded="true"] {
  background: linear-gradient(90deg,
              rgba(37, 99, 235, 0.10) 0%,
              rgba(37, 99, 235, 0.00) 100%);
  color: var(--cf-blue-700);
}
:root:not([data-bs-theme="dark"]) .cf-accordion-btn[aria-expanded="true"] .cf-acc-icon svg,
[data-bs-theme="light"] .cf-accordion-btn[aria-expanded="true"] .cf-acc-icon svg {
  color: var(--cf-blue-700) !important;
  filter: drop-shadow(0 0 4px rgba(37, 99, 235, 0.30));
}
:root:not([data-bs-theme="dark"]) .cf-accordion-btn:hover,
[data-bs-theme="light"] .cf-accordion-btn:hover {
  background: rgba(37, 99, 235, 0.06);
}

:root:not([data-bs-theme="dark"]) .sheet-list .nav-link.active,
[data-bs-theme="light"] .sheet-list .nav-link.active {
  background: linear-gradient(90deg,
              rgba(37, 99, 235, 0.12),
              rgba(37, 99, 235, 0.02)) !important;
  border-left-color: var(--cf-blue-600) !important;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.10);
  color: var(--cf-blue-700) !important;
}

:root:not([data-bs-theme="dark"]) .edit-toolbar-btn,
[data-bs-theme="light"] .edit-toolbar-btn {
  background: #ffffff !important;
  border-color: rgba(30, 58, 95, 0.14) !important;
  color: #475569 !important;
  box-shadow: 0 1px 0 rgba(30, 58, 95, 0.04);
}
:root:not([data-bs-theme="dark"]) .edit-toolbar-btn:hover:not(:disabled),
[data-bs-theme="light"] .edit-toolbar-btn:hover:not(:disabled) {
  background: rgba(37, 99, 235, 0.08) !important;
  border-color: rgba(37, 99, 235, 0.35) !important;
  color: var(--cf-blue-700) !important;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.18);
}

:root:not([data-bs-theme="dark"]) #sidebar-collapse-btn,
:root:not([data-bs-theme="dark"]) .banner-toggle-btn,
[data-bs-theme="light"] #sidebar-collapse-btn,
[data-bs-theme="light"] .banner-toggle-btn {
  background: #ffffff !important;
  border-color: rgba(30, 58, 95, 0.14) !important;
  color: #64748b !important;
  box-shadow: 0 1px 2px rgba(30, 58, 95, 0.06);
}
:root:not([data-bs-theme="dark"]) #sidebar-collapse-btn:hover,
:root:not([data-bs-theme="dark"]) .banner-toggle-btn:hover,
[data-bs-theme="light"] #sidebar-collapse-btn:hover,
[data-bs-theme="light"] .banner-toggle-btn:hover {
  background: rgba(37, 99, 235, 0.08) !important;
  border-color: rgba(37, 99, 235, 0.35) !important;
  color: var(--cf-blue-700) !important;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.18);
}

/* Light-mode buttons */
:root:not([data-bs-theme="dark"]) .btn-primary,
[data-bs-theme="light"] .btn-primary {
  background: var(--cf-blue-600);
  border-color: var(--cf-blue-600);
  font-weight: 600;
  transition: background 0.15s, box-shadow 0.18s, transform 0.1s;
}
:root:not([data-bs-theme="dark"]) .btn-primary:hover,
[data-bs-theme="light"] .btn-primary:hover {
  background: var(--cf-blue-700);
  border-color: var(--cf-blue-700);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.32);
}
:root:not([data-bs-theme="dark"]) .btn-primary:active,
[data-bs-theme="light"] .btn-primary:active {
  transform: translateY(1px);
}

/* Light-mode modal — softer card with subtle blue tinted shadow */
:root:not([data-bs-theme="dark"]) .modal-content,
[data-bs-theme="light"] .modal-content {
  border-radius: var(--cf-radius-lg);
  border: 1px solid rgba(30, 58, 95, 0.10);
  box-shadow: 0 12px 48px rgba(15, 23, 42, 0.15),
              0 0 40px rgba(37, 99, 235, 0.06);
  overflow: hidden;
}
:root:not([data-bs-theme="dark"]) .modal-header,
[data-bs-theme="light"] .modal-header {
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border-bottom: 1px solid rgba(30, 58, 95, 0.08);
}

/* Light-mode form-control focus ring */
:root:not([data-bs-theme="dark"]) .form-control:focus,
:root:not([data-bs-theme="dark"]) .form-select:focus,
[data-bs-theme="light"] .form-control:focus,
[data-bs-theme="light"] .form-select:focus {
  border-color: var(--cf-blue-500);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Light-mode nav-tabs */
:root:not([data-bs-theme="dark"]) .nav-tabs .nav-link,
[data-bs-theme="light"] .nav-tabs .nav-link {
  color: #64748b;
  border: none;
  border-bottom: 2px solid transparent;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
:root:not([data-bs-theme="dark"]) .nav-tabs .nav-link:hover,
[data-bs-theme="light"] .nav-tabs .nav-link:hover {
  color: #1e293b;
  border-bottom-color: rgba(37, 99, 235, 0.25);
}
:root:not([data-bs-theme="dark"]) .nav-tabs .nav-link.active,
[data-bs-theme="light"] .nav-tabs .nav-link.active {
  color: var(--cf-blue-700);
  background: transparent;
  border-bottom: 2px solid var(--cf-blue-600);
}

/* Light-mode autosave status */
:root:not([data-bs-theme="dark"]) #sidebar-autosave-status,
[data-bs-theme="light"] #sidebar-autosave-status {
  background: rgba(248, 250, 252, 0.75) !important;
  border-top-color: rgba(30, 58, 95, 0.08) !important;
  color: #64748b !important;
}

/* ── Helpers — small pill badge utility matching website ─────────────────── */
.cf-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(37, 99, 235, 0.15);
  border: 1px solid rgba(96, 165, 250, 0.30);
  color: var(--cf-blue-300);
}

/* ── Unit symbols on canvas ──────────────────────────────────────────────
   The 24 SVG files under svg/ ship hardcoded fill="#fff" / "#f8f8f8" etc.
   on equipment bodies (distillation column, vessels, valves, inlet/outlet
   arrows). They render as bright white blobs on the dark canvas.

   Filter-invert the entire <use> instance so:
     - light fills (#fff, #f8f8f8) → near-black (blends with navy bg)
     - dark strokes (#333, #555)   → light grey (visible equipment lines)
   Combined with hue-rotate so any incidental colors (e.g. terminal
   highlight reds) come back to roughly the right hue. */
[data-bs-theme="dark"] .svg-content-responsive use {
  filter: invert(0.90) hue-rotate(180deg) saturate(0.85);
  transition: filter 0.15s ease;
}
[data-bs-theme="dark"] .svg-content-responsive use:hover {
  filter: invert(0.90) hue-rotate(180deg) saturate(0.85)
          drop-shadow(0 0 4px rgba(96, 165, 250, 0.55));
}
[data-bs-theme="dark"] .unit-selected > use {
  filter: invert(0.90) hue-rotate(180deg) saturate(0.85)
          drop-shadow(0 0 4px var(--cf-blue-400))
          drop-shadow(0 0 2px var(--cf-blue-300)) !important;
}
/* Note shapes (sticky-note rectangles) are not inverted — they should
   keep their authored colors so the user-chosen background remains
   meaningful. They get only the selection halo. */
[data-bs-theme="dark"] .unit-selected .cf-note-shape {
  filter: drop-shadow(0 0 5px var(--cf-blue-400))
          drop-shadow(0 0 2px var(--cf-blue-300)) !important;
}
[data-bs-theme="dark"] .unit-selected > text {
  fill: var(--cf-blue-300) !important;
}

/* Stream properties box — dark mode recolor.
   The SVG attribute fills are the light-mode defaults; CSS overrides
   them in dark mode so no re-render is needed on theme switch. */
[data-bs-theme="dark"] .cf-propsbox-bg {
  fill: #2a2d31;
  stroke: #555;
}
[data-bs-theme="dark"] .cf-propsbox-header {
  fill: #353a40;
}
[data-bs-theme="dark"] .cf-propsbox-altrow {
  fill: #30343a;
}
[data-bs-theme="dark"] .cf-propsbox-header-text,
[data-bs-theme="dark"] .cf-propsbox-label,
[data-bs-theme="dark"] .cf-propsbox-value {
  fill: #e4e6eb;
}
[data-bs-theme="dark"] .cf-propsbox-divider {
  stroke: #4a4e55;
}
[data-bs-theme="dark"] .cf-propsbox-border {
  stroke: #555;
}
[data-bs-theme="dark"] .cf-propsbox-unit {
  fill: #9aa0a6;
}
[data-bs-theme="dark"] .cf-propsbox-unit-clickable {
  fill: #66b3ff;
}

/* Reduce motion preference — respect user OS setting */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
