/* ============================================================
   1:4 Demultiplexer Virtual Laboratory — Style Sheet
   Virtual Instrumentation Labs Interactive Learning Platform
   ============================================================ */

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

:root {
  /* Laboratory Colour Palette */
  --lab-bg:           #ffffff;
  --panel-bg:         #f8fafc;
  --panel-border:     #cbd5e1;
  --header-bg:        #0f172a;
  --header-text:      #ffffff;
  --accent:           #2563eb;
  --accent-hover:     #1d4ed8;
  --accent-light:     #dbeafe;
  --text-primary:     #0f172a;
  --text-secondary:   #475569;
  --text-muted:       #94a3b8;
  
  /* Signal & Wire Colors */
  --wire-off:         #94a3b8;
  --wire-on:          #2563eb;
  --signal-high:      #2563eb;
  --signal-low:       #64748b;
  
  /* Select line purple accent distinction */
  --select-line-bg:   #f1f5f9;
  --select-accent:    #8b5cf6;
  --select-accent-bg: #f3e8ff;

  /* Output / LED Colors */
  --led-off-bg:       #475569;
  --led-off-border:   #334155;
  --led-on-bg:        #10b981;
  --led-on-border:    #059669;
  --led-on-glow:      0 0 14px rgba(16, 185, 129, 0.7);

  --success:          #16a34a;
  --success-bg:       #dcfce7;
  --success-border:   #86efac;
  
  --gate-fill:        #f1f5f9;
  --gate-stroke:      #1e293b;
  --gate-active-fill: #eff6ff;
  --gate-active-stroke:#2563eb;
  
  --shadow-sm:        0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md:        0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg:        0 10px 25px rgba(0, 0, 0, 0.1);
  
  --radius-sm:        4px;
  --radius-md:        8px;
  --radius-lg:        12px;
  
  --font-sans:        'Segoe UI', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:        'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--lab-bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Laboratory Title Bar ──────────────────────────────────── */
.lab-title-bar {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}

.lab-title-container h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.lab-title-bar .lab-subtitle {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 400;
  display: block;
}

.lab-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ── Main Layout Container ─────────────────────────────────── */
.lab-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  flex: 1;
}

/* ── Toolbar & Control Bar ─────────────────────────────────── */
.lab-toolbar {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.toolbar-divider {
  width: 1px;
  height: 28px;
  background: var(--panel-border);
}

/* Button Component Styles */
.btn {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  user-select: none;
}

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

.btn--mode {
  background: #ffffff;
  border-color: var(--panel-border);
  color: var(--text-secondary);
}

.btn--mode:hover {
  background: #f1f5f9;
  color: var(--text-primary);
}

.btn--mode.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.btn--secondary {
  background: #ffffff;
  border-color: var(--panel-border);
  color: var(--text-primary);
}

.btn--secondary:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn--secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--outline {
  background: transparent;
  border-color: #cbd5e1;
  color: var(--text-secondary);
}

.btn--outline:hover {
  background: #fee2e2;
  border-color: #f87171;
  color: #dc2626;
}

.btn--accent {
  background: #0f172a;
  color: #ffffff;
}

.btn--accent:hover {
  background: #1e293b;
}

/* ── Generic Panel Container ────────────────────────────────── */
.lab-panel {
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.lab-panel__header {
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  padding: 12px 20px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lab-panel__body {
  padding: 20px;
}

/* ── Top Grid: Input Controls & Output Monitor ───────────────── */
.lab-top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .lab-top-grid {
    grid-template-columns: 1fr;
  }
}

.input-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.input-controls-group, .select-controls-group {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.input-control-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  min-width: 140px;
  transition: all 0.2s ease;
}

.input-card-d {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.select-card {
  background: var(--select-accent-bg);
  border-color: #ddd6fe;
}

.input-meta {
  display: flex;
  flex-direction: column;
}

.input-symbol {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.select-card .input-symbol {
  color: #6d28d9;
}

.input-role {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Toggle Switch Component */
.toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border-radius: 20px;
  transition: all 0.2s ease;
}

.toggle-btn__track {
  width: 44px;
  height: 24px;
  background: #cbd5e1;
  border-radius: 12px;
  position: relative;
  transition: background-color 0.2s ease;
}

.toggle-btn__knob {
  width: 18px;
  height: 18px;
  background: #ffffff;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-btn__state {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 800;
  min-width: 16px;
}

.toggle-btn.high .toggle-btn__track {
  background: var(--accent);
}

.toggle-btn.high .toggle-btn__knob {
  transform: translateX(20px);
}

.toggle-btn.high .toggle-btn__state {
  color: var(--accent);
}

.toggle-btn.select-high .toggle-btn__track {
  background: var(--select-accent);
}

.toggle-btn.select-high .toggle-btn__knob {
  transform: translateX(20px);
}

.toggle-btn.select-high .toggle-btn__state {
  color: var(--select-accent);
}

.toggle-btn.low .toggle-btn__state {
  color: var(--text-secondary);
}

/* ── Selected Output Banner & Output LEDs ────────────────────── */
.output-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.selected-output-banner {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.selected-output-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent);
}

.banner-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.banner-value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 900;
  color: #38bdf8;
  margin: 2px 0;
  letter-spacing: 1px;
}

.banner-subtext {
  font-size: 0.8rem;
  color: #cbd5e1;
}

/* 4 LED Grid */
.outputs-led-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (max-width: 500px) {
  .outputs-led-grid {
    grid-template-columns: 1fr;
  }
}

.led-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.25s ease;
}

.led-card.active-route {
  border-color: #60a5fa;
  background: #eff6ff;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.1);
}

.led-indicator-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

.led-light {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--led-off-bg);
  border: 2px solid var(--led-off-border);
  transition: all 0.3s ease;
}

.led-light.active {
  background: var(--led-on-bg);
  border-color: var(--led-on-border);
  box-shadow: var(--led-on-glow);
}

.led-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.led-name {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1rem;
  color: var(--text-primary);
}

.led-expr {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.led-state-badge {
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 6px;
  width: fit-content;
  margin-top: 2px;
}

.led-state-badge.high {
  background: var(--success-bg);
  color: var(--success);
}

.led-state-badge.low {
  background: #f1f5f9;
  color: var(--text-secondary);
}

.badge-row-active {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
}

/* ── Schematic Viewport & SVG Styling ────────────────────────── */
.schematic-panel__body {
  padding: 16px;
  background: #f8fafc;
}

.schematic-viewport {
  width: 100%;
  overflow-x: auto;
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  justify-content: center;
}

.circuit-svg {
  width: 100%;
  max-width: 960px;
  height: auto;
  min-width: 760px;
  display: block;
}

/* SVG Circuit Wires & Gate Styling (Clean High-Contrast, No Filter Dependencies) */
.wire {
  fill: none;
  stroke: #94a3b8;
  stroke-width: 2.5px;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.2s ease, stroke-width 0.2s ease;
}

.wire.high {
  stroke: #2563eb !important;
  stroke-width: 3.5px !important;
}

.wire.select-high {
  stroke: #8b5cf6 !important;
  stroke-width: 3.5px !important;
}

.wire.active-route {
  stroke: #10b981 !important;
  stroke-width: 4px !important;
}

.junction-dot {
  fill: #94a3b8;
  transition: fill 0.2s ease, r 0.2s ease;
}

.junction-dot.high {
  fill: #2563eb !important;
  r: 5.5px !important;
}

.junction-dot.select-high {
  fill: #8b5cf6 !important;
  r: 5.5px !important;
}

.gate-body {
  fill: #f1f5f9;
  stroke: #1e293b;
  stroke-width: 2px;
  transition: all 0.25s ease;
}

.gate-body.active {
  fill: #eff6ff;
  stroke: #2563eb;
  stroke-width: 2.5px;
}

.gate-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  fill: var(--text-primary);
  text-anchor: middle;
  dominant-baseline: middle;
  user-select: none;
}

.gate-sublabel {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  fill: var(--text-secondary);
  text-anchor: middle;
  dominant-baseline: middle;
  user-select: none;
}

.clickable-svg {
  cursor: pointer;
}

.clickable-svg:hover rect {
  filter: brightness(0.96);
}

/* ── Live Boolean Expression Evaluation Panel ───────────────── */
.eval-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .eval-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  .eval-grid {
    grid-template-columns: 1fr;
  }
}

.eval-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.25s ease;
}

.eval-card.active-term {
  background: #eff6ff;
  border-color: #3b82f6;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

.eval-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eval-card__title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
}

.eval-card__badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #e2e8f0;
  color: var(--text-secondary);
}

.eval-card__badge.active {
  background: var(--accent);
  color: #ffffff;
}

.eval-card__formula {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.eval-card__calc {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.eval-card.active-term .eval-card__calc {
  color: var(--accent);
}

.eval-summary-box {
  background: #f1f5f9;
  border-left: 4px solid var(--accent);
  padding: 10px 16px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 0.85rem;
  color: var(--text-primary);
}

/* ── Truth Table Panel ───────────────────────────────────────── */
.table-responsive {
  overflow-x: auto;
}

.truth-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: center;
}

.truth-table th, .truth-table td {
  padding: 10px 14px;
  border: 1px solid var(--panel-border);
}

.truth-table th {
  background: #0f172a;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
}

.th-group-inputs {
  background: #1e293b !important;
}

.th-group-outputs {
  background: #0284c7 !important;
}

.th-selected {
  background: #475569 !important;
}

.truth-row {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.truth-row:hover {
  background: #f1f5f9;
}

.truth-row.active-row {
  background: #dbeafe !important;
  font-weight: 700;
}

.truth-row.active-row td {
  border-color: #93c5fd;
}

.col-input, .col-select, .col-out {
  font-family: var(--font-mono);
}

.col-select {
  color: #6d28d9;
}

.highlight-d {
  color: #2563eb;
  font-weight: 800;
}

.highlight-out {
  color: #16a34a;
  font-weight: 800;
  background: #dcfce7;
}

.highlight-sel {
  color: #0369a1;
  font-weight: 800;
}

/* ── Educational Guide & Reference ──────────────────────────── */
.edu-body {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.edu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

@media (max-width: 900px) {
  .edu-grid {
    grid-template-columns: 1fr;
  }
}

.edu-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}

.edu-card h3 {
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.edu-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.edu-card ul {
  padding-left: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.edu-card li {
  margin-bottom: 4px;
}

.edu-note {
  font-size: 0.8rem !important;
  background: #fffbe6;
  border: 1px solid #ffe58f;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: #d48806 !important;
}

.formula-box {
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  text-align: center;
  margin: 10px 0;
  color: #0f172a;
}

/* MUX vs DEMUX Comparison Card */
.comparison-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}

@media (max-width: 500px) {
  .comparison-container {
    grid-template-columns: 1fr;
  }
}

.comp-box {
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.comp-mux {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.comp-demux {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.comp-box h4 {
  font-size: 0.85rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.comp-mux h4 {
  color: #15803d;
}

.comp-demux h4 {
  color: #1d4ed8;
}

.comp-arrow {
  font-weight: 800;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.comp-box p {
  font-size: 0.75rem;
  margin-bottom: 4px;
}

/* Applications Box */
.edu-applications-box {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.edu-applications-box h3 {
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

@media (max-width: 900px) {
  .app-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  .app-cards-grid {
    grid-template-columns: 1fr;
  }
}

.app-card {
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.app-icon {
  font-size: 1.5rem;
}

.app-card h4 {
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 700;
}

.app-card p {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ── Footer ──────────────────────────────────────────────────── */
.lab-footer {
  background: var(--header-bg);
  color: #94a3b8;
  text-align: center;
  padding: 16px;
  font-size: 0.78rem;
  margin-top: auto;
}

/* ── Math / Formula Helpers ──────────────────────────────────── */
.overline {
  text-decoration: overline;
}

.formula-box {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px 16px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.95rem;
  line-height: 2;
  margin: 10px 0;
  color: #0f172a;
}

/* ============================================================
   DARK & LIGHT THEME OVERRIDES — 1:4 Demultiplexer
   ============================================================ */

html[data-theme="dark"],
html.dark {
  --lab-bg: #080d18;
  --panel-bg: #111827;
  --panel-border: #263550;
  --header-bg: #0b1120;
  --header-text: #f8fafc;
  --accent: #38bdf8;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --select-line-bg: #172033;
  --select-accent-bg: #1e1b4b;
  --gate-fill: #162036;
  --gate-stroke: #38bdf8;
}

html[data-theme="dark"] body,
html.dark body {
  background-color: #080d18 !important;
  background-image: none !important;
  color: #f8fafc !important;
}

/* SVG Schematic Canvas Background Overrides */
html[data-theme="dark"] #circuit-svg rect[width="960"],
html.dark #circuit-svg rect[width="960"],
html[data-theme="dark"] #view-gate-level > rect:first-child,
html[data-theme="dark"] #view-functional > rect:first-child,
html.dark #view-gate-level > rect:first-child,
html.dark #view-functional > rect:first-child {
  fill: #0b1120 !important;
}

/* Functional View IC Block */
html[data-theme="dark"] #view-functional rect[x="340"][y="80"],
html.dark #view-functional rect[x="340"][y="80"] {
  fill: #172033 !important;
  stroke: #38bdf8 !important;
}

html[data-theme="dark"] .schematic-panel__body,
html.dark .schematic-panel__body {
  background: #111827 !important;
}

html[data-theme="dark"] .schematic-viewport,
html.dark .schematic-viewport {
  background: #0b1120 !important;
  border-color: #263550 !important;
}

html[data-theme="dark"] .input-card-d,
html.dark .input-card-d {
  background: #172033 !important;
  border-color: #263550 !important;
}

html[data-theme="dark"] .select-card,
html.dark .select-card {
  background: #1e1b4b !important;
  border-color: #312e81 !important;
}

html[data-theme="dark"] .input-symbol,
html.dark .input-symbol,
html[data-theme="dark"] .select-card .input-symbol,
html.dark .select-card .input-symbol {
  color: #f8fafc !important;
}

/* SVG Switches in Gate/Functional View */
html[data-theme="dark"] .svg-switch rect,
html.dark .svg-switch rect {
  fill: #1e293b !important;
  stroke: #3b82f6 !important;
}

html[data-theme="dark"] .svg-switch text,
html[data-theme="dark"] .svg-switch tspan,
html.dark .svg-switch text,
html.dark .svg-switch tspan {
  fill: #f8fafc !important;
}

html[data-theme="dark"] .gate-body,
html.dark .gate-body {
  fill: #1a2744 !important;
  stroke: #38bdf8 !important;
}

html[data-theme="dark"] .gate-label,
html[data-theme="dark"] .gate-sublabel,
html.dark .gate-label,
html.dark .gate-sublabel {
  fill: #f8fafc !important;
}

html[data-theme="dark"] .pin-text,
html.dark .pin-text {
  fill: #94a3b8 !important;
}

/* Live Evaluation Panel & Summary Box */
html[data-theme="dark"] .eval-card,
html.dark .eval-card {
  background: #172033 !important;
  border-color: #263550 !important;
  color: #f8fafc !important;
}

html[data-theme="dark"] .eval-card.active-term,
html.dark .eval-card.active-term {
  background: rgba(37, 99, 235, 0.18) !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.25) !important;
}

html[data-theme="dark"] .eval-card__title,
html[data-theme="dark"] .eval-card__calc,
html.dark .eval-card__title,
html.dark .eval-card__calc {
  color: #f8fafc !important;
}

html[data-theme="dark"] .eval-card__formula,
html.dark .eval-card__formula {
  color: #94a3b8 !important;
}

html[data-theme="dark"] .eval-card__badge,
html.dark .eval-card__badge {
  background: #1e293b !important;
  color: #94a3b8 !important;
}

html[data-theme="dark"] .eval-card__badge.active,
html.dark .eval-card__badge.active {
  background: #2563eb !important;
  color: #ffffff !important;
}

html[data-theme="dark"] .eval-summary-box,
html.dark .eval-summary-box {
  background: #172033 !important;
  color: #f8fafc !important;
  border-left-color: #38bdf8 !important;
  border-color: #263550 !important;
}

html[data-theme="dark"] .app-card,
html[data-theme="dark"] .formula-box,
html.dark .app-card,
html.dark .formula-box {
  background: #172033 !important;
  color: #f8fafc !important;
  border-color: #263550 !important;
}

html[data-theme="dark"] .app-card h4,
html.dark .app-card h4 {
  color: #f8fafc !important;
}

html:not(.dark) body,
html[data-theme="light"] body {
  background-color: #f8fafc !important;
  background-image: none !important;
  color: #0f172a !important;
}


