/* Digital Electronics Virtual Laboratory - 1x16 Demultiplexer Design System */
:root {
  --bg-main: #f8fafc;
  --bg-grid: #e2e8f0;
  --card-bg: #ffffff;
  --card-border: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dark: #1e293b;

  --primary-blue: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;

  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-purple: #8b5cf6;

  --logic-high: #10b981;
  --logic-high-glow: rgba(16, 185, 129, 0.4);
  --logic-low: #94a3b8;
  --logic-low-bg: #f1f5f9;

  --active-wire: #0284c7;
  --active-wire-glow: #38bdf8;
  --inactive-wire: #cbd5e1;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-main);
  background-image: none !important;
  color: var(--text-main);
  line-height: 1.45;
  min-height: 100vh;
  padding: 16px;
}

.container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Compact Lab Header */
.lab-header {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.header-title h1 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-title p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 1px;
}

.lab-badge {
  background: var(--primary-light);
  color: var(--primary-blue);
  border: 1px solid rgba(37, 99, 235, 0.2);
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lab-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  background-color: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent-green);
}

/* Layout Grid System */
.top-dashboard-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
}

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

.cards-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 8px;
}

/* Control Panel Controls */
.control-group {
  margin-bottom: 12px;
}

.control-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.switch-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.toggle-btn {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  user-select: none;
}

.toggle-btn:hover {
  border-color: var(--primary-blue);
  background: var(--primary-light);
}

.toggle-btn.active {
  background: var(--primary-blue);
  color: #ffffff;
  border-color: var(--primary-hover);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-data-toggle {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.toggle-btn .state-text {
  font-size: 0.72rem;
  font-weight: 800;
}

.btn-data-toggle .state-text {
  font-size: 0.8rem;
}

.toggle-btn.active .state-text {
  color: #93c5fd;
}

.preset-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.preset-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-btn:hover {
  background: var(--primary-light);
  color: var(--primary-blue);
  border-color: var(--primary-blue);
}

/* Output Monitor Card */
.monitor-card {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-md);
  border: 1px solid #334155;
  position: relative;
  overflow: hidden;
}

.monitor-header {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  font-weight: 700;
  margin-bottom: 8px;
}

.monitor-display {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.monitor-output-name {
  font-size: 2rem;
  font-weight: 900;
  color: #38bdf8;
  line-height: 1;
  font-family: 'Courier New', Courier, monospace;
}

.monitor-output-state {
  font-size: 1rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 4px;
}

.state-high {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.state-low {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.monitor-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: rgba(15, 23, 42, 0.6);
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #334155;
  font-size: 0.8rem;
}

.monitor-item {
  display: flex;
  flex-direction: column;
}

.monitor-item .lbl {
  font-size: 0.65rem;
  color: #94a3b8;
  font-weight: 600;
}

.monitor-item .val {
  font-weight: 700;
  color: #f8fafc;
  font-family: monospace;
}

/* Routing Status & Dynamic Operation */
.status-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.status-pill {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.status-pill.completed {
  background: #ecfdf5;
  color: #059669;
  border-color: #a7f3d0;
}

.operation-box {
  background: #f8fafc;
  border-left: 3px solid var(--primary-blue);
  padding: 10px 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.82rem;
  color: var(--text-dark);
}

.operation-box .op-title {
  font-weight: 800;
  color: var(--primary-blue);
  margin-bottom: 2px;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

/* Auto Controls */
.auto-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn-primary {
  background: var(--primary-blue);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

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

.btn-secondary:hover {
  background: #e2e8f0;
}

.speed-slider-container {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.speed-slider-container input[type="range"] {
  flex: 1;
  accent-color: var(--primary-blue);
}

/* Main Schematic Workspace */
.circuit-workspace {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.workspace-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
}

.legend {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.svg-wrapper {
  width: 100%;
  overflow-x: auto;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 8px;
  transition: all 0.3s ease;
}

.svg-wrapper.collapsed {
  display: none;
}

/* SVG Elements */
svg.demux-svg {
  width: 100%;
  height: auto;
  min-width: 960px;
  display: block;
}

.svg-stage-header {
  font-size: 12px;
  font-weight: 800;
  fill: #334155;
  text-anchor: middle;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.svg-stage-sub {
  font-size: 10px;
  font-weight: 600;
  fill: #64748b;
  text-anchor: middle;
}

.demux-box {
  fill: #f8fafc;
  stroke: #94a3b8;
  stroke-width: 1.5;
  rx: 5;
  transition: all 0.25s ease;
}

.demux-box.active-box {
  fill: #eff6ff;
  stroke: #2563eb;
  stroke-width: 2.2;
  filter: drop-shadow(0 0 5px rgba(37, 99, 235, 0.25));
}

.demux-label {
  font-size: 10px;
  font-weight: 800;
  fill: #1e293b;
  text-anchor: middle;
}

.demux-sublabel {
  font-size: 8.5px;
  font-weight: 600;
  fill: #64748b;
  text-anchor: middle;
}

.wire {
  stroke: #cbd5e1;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.25s ease, stroke-width 0.25s ease;
}

.wire.wire-active-path {
  stroke: #2563eb;
  stroke-width: 2.8;
}

.wire.wire-active-high {
  stroke: #10b981;
  stroke-width: 3.2;
  stroke-dasharray: 7 3.5;
  animation: wirePulse 0.8s linear infinite;
  filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.5));
}

@keyframes wirePulse {
  to {
    stroke-dashoffset: -10.5;
  }
}

.wire-select {
  stroke: #c084fc;
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
}

.wire-select.active {
  stroke: #9333ea;
  stroke-width: 2.2;
}

.svg-led {
  r: 6;
  fill: #cbd5e1;
  stroke: #64748b;
  stroke-width: 1.5;
  transition: all 0.25s ease;
}

.svg-led.high {
  fill: #10b981;
  stroke: #059669;
  stroke-width: 2;
  filter: drop-shadow(0 0 7px #10b981);
}

.svg-led.selected-low {
  fill: #38bdf8;
  stroke: #0284c7;
  stroke-width: 2;
  filter: drop-shadow(0 0 5px #38bdf8);
}

.svg-text-pin {
  font-size: 10px;
  font-weight: 800;
  font-family: monospace;
  fill: #475569;
}

.svg-text-pin.active {
  fill: #2563eb;
  font-weight: 900;
}

/* 16-Bit Output Vector & Output Chips */
.output-vector-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
}

.vector-display {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  background: #0f172a;
  padding: 10px 16px;
  border-radius: 6px;
  overflow-x: auto;
}

.vector-bit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.vector-bit .bit-name {
  font-size: 0.6rem;
  font-weight: 700;
  color: #94a3b8;
  font-family: monospace;
}

.vector-bit .bit-val {
  font-size: 1.1rem;
  font-weight: 800;
  color: #64748b;
  font-family: monospace;
  width: 26px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e293b;
  border-radius: 4px;
  border: 1px solid #334155;
  transition: all 0.15s ease;
}

.vector-bit.active .bit-val {
  color: #34d399;
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.vector-bit.selected-zero .bit-val {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  border-color: #0284c7;
}

.outputs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.output-chip {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s ease;
}

.output-chip.active-high {
  background: #ecfdf5;
  border-color: #10b981;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.2);
}

.output-chip.selected-low {
  background: #eff6ff;
  border-color: #3b82f6;
}

.chip-name {
  font-weight: 800;
  font-size: 0.85rem;
  font-family: monospace;
  color: var(--text-dark);
}

.chip-led {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #cbd5e1;
  border: 1px solid #94a3b8;
}

.output-chip.active-high .chip-led {
  background: #10b981;
  border-color: #059669;
  box-shadow: 0 0 5px #10b981;
}

.chip-val {
  font-weight: 700;
  font-size: 0.8rem;
  font-family: monospace;
  color: var(--text-muted);
}

.output-chip.active-high .chip-val {
  color: #047857;
}

/* Truth Table */
.truth-table-container {
  overflow-x: auto;
}

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

.truth-table th {
  background: #f1f5f9;
  color: #334155;
  font-weight: 700;
  padding: 8px 10px;
  border: 1px solid var(--card-border);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.truth-table td {
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  font-family: monospace;

}

.truth-table tr:hover {
  background-color: #f8fafc;
  cursor: pointer;
}

.truth-table tr.active-row {
  background-color: #eff6ff !important;
  font-weight: 800;
}

.truth-table tr.active-row td {
  border-top: 1.5px solid #2563eb;
  border-bottom: 1.5px solid #2563eb;
  color: #1e40af;
}

.badge-active {
  background: #2563eb;
  color: #ffffff;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 0.72rem;
}

/* Educational Cards Grid */
.edu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
}

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

.edu-card p, .edu-card ul {
  font-size: 0.85rem;
  color: var(--text-dark);
  margin-bottom: 10px;
}

.edu-card ul {
  padding-left: 18px;
}

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

.math-expr {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 6px 10px;
  border-radius: 4px;
  font-family: 'Courier New', Courier, monospace;
  font-weight: 700;
  color: #1e293b;
  margin: 4px 0;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-top: 8px;
}

.comparison-table th, .comparison-table td {
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
}

.comparison-table th {
  background: #f1f5f9;
  font-weight: 700;
}

footer {
  text-align: center;
  padding: 14px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid #e2e8f0;
  margin-top: 10px;
}

/* ============================================================
   DARK & LIGHT THEME OVERRIDES — 1x16 Demultiplexer
   ============================================================ */

/* ── DARK THEME OVERRIDES ─────────────────────────────────── */
html[data-theme="dark"],
html.dark {
  --bg-main: #080d18;
  --bg-grid: transparent;
  --card-bg: #111827;
  --card-border: #263550;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dark: #f8fafc;
  --primary-light: #1e3a5f;
  --logic-low-bg: #172033;
  --inactive-wire: #334155;
}

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

html[data-theme="dark"] .lab-header,
html[data-theme="dark"] .card,
html[data-theme="dark"] .circuit-workspace,
html.dark .lab-header,
html.dark .card,
html.dark .circuit-workspace {
  background: #111827 !important;
  border-color: #263550 !important;
  color: #f8fafc !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
}

html[data-theme="dark"] .header-title h1,
html[data-theme="dark"] .workspace-title,
html[data-theme="dark"] .card h2,
html[data-theme="dark"] .card h3,
html.dark .header-title h1,
html.dark .workspace-title,
html.dark .card h2,
html.dark .card h3 {
  color: #f8fafc !important;
}

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

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

html[data-theme="dark"] .toggle-btn.active,
html.dark .toggle-btn.active {
  background: #2563eb !important;
  color: #ffffff !important;
  border-color: #3b82f6 !important;
}

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

html[data-theme="dark"] .preset-btn:hover,
html.dark .preset-btn:hover {
  background: #1e293b !important;
  border-color: #38bdf8 !important;
  color: #38bdf8 !important;
}

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

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

html[data-theme="dark"] .monitor-output-name,
html.dark .monitor-output-name {
  color: #38bdf8 !important;
}

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

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

html[data-theme="dark"] .monitor-item .val,
html.dark .monitor-item .val {
  color: #f8fafc !important;
}

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

html[data-theme="dark"] .operation-box .op-title,
html.dark .operation-box .op-title {
  color: #38bdf8 !important;
}

html[data-theme="dark"] .status-pill,
html.dark .status-pill {
  background: #172033 !important;
  color: #94a3b8 !important;
  border-color: #263550 !important;
}

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

html[data-theme="dark"] .demux-box,
html.dark .demux-box {
  fill: #172033 !important;
  stroke: #263550 !important;
}

html[data-theme="dark"] .demux-box.active-box,
html.dark .demux-box.active-box {
  fill: rgba(37, 99, 235, 0.25) !important;
  stroke: #38bdf8 !important;
}

html[data-theme="dark"] .demux-label,
html[data-theme="dark"] .svg-stage-header,
html.dark .demux-label,
html.dark .svg-stage-header {
  fill: #f8fafc !important;
}

html[data-theme="dark"] .demux-sublabel,
html[data-theme="dark"] .svg-stage-sub,
html.dark .demux-sublabel,
html.dark .svg-stage-sub {
  fill: #94a3b8 !important;
}

html[data-theme="dark"] .wire,
html.dark .wire {
  stroke: #334155;
}

html[data-theme="dark"] .truth-table th,
html[data-theme="dark"] .comparison-table th,
html.dark .truth-table th,
html.dark .comparison-table th {
  background: #172033 !important;
  color: #38bdf8 !important;
  border-color: #263550 !important;
}

html[data-theme="dark"] .truth-table td,
html[data-theme="dark"] .comparison-table td,
html.dark .truth-table td,
html.dark .comparison-table td {
  color: #94a3b8 !important;
  border-color: #263550 !important;
}

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

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

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

html:not(.dark) .lab-header,
html:not(.dark) .card,
html:not(.dark) .circuit-workspace,
html[data-theme="light"] .lab-header,
html[data-theme="light"] .card,
html[data-theme="light"] .circuit-workspace {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08) !important;
}

html:not(.dark) .header-title h1,
html:not(.dark) .workspace-title,
html:not(.dark) .card h2,
html:not(.dark) .card h3,
html[data-theme="light"] .header-title h1,
html[data-theme="light"] .workspace-title,
html[data-theme="light"] .card h2,
html[data-theme="light"] .card h3 {
  color: #0f172a !important;
}

html:not(.dark) .header-title p,
html[data-theme="light"] .header-title p {
  color: #475569 !important;
}

html:not(.dark) .toggle-btn,
html[data-theme="light"] .toggle-btn {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

html:not(.dark) .toggle-btn.active,
html[data-theme="light"] .toggle-btn.active {
  background: #2563eb !important;
  color: #ffffff !important;
  border-color: #1d4ed8 !important;
}

html:not(.dark) .preset-btn,
html[data-theme="light"] .preset-btn {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #334155 !important;
}

html:not(.dark) .preset-btn:hover,
html[data-theme="light"] .preset-btn:hover {
  background: #e0f2fe !important;
  border-color: #2563eb !important;
  color: #1d4ed8 !important;
}

html:not(.dark) .monitor-card,
html[data-theme="light"] .monitor-card {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08) !important;
}

html:not(.dark) .monitor-header,
html[data-theme="light"] .monitor-header {
  color: #475569 !important;
}

html:not(.dark) .monitor-output-name,
html[data-theme="light"] .monitor-output-name {
  color: #0284c7 !important;
}

html:not(.dark) .monitor-grid,
html[data-theme="light"] .monitor-grid {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

html:not(.dark) .monitor-item .lbl,
html[data-theme="light"] .monitor-item .lbl {
  color: #64748b !important;
}

html:not(.dark) .monitor-item .val,
html[data-theme="light"] .monitor-item .val {
  color: #0f172a !important;
}

html:not(.dark) .operation-box,
html[data-theme="light"] .operation-box {
  background: #f8fafc !important;
  border-left-color: #2563eb !important;
  border-color: #e2e8f0 !important;
  color: #1e293b !important;
}

html:not(.dark) .operation-box .op-title,
html[data-theme="light"] .operation-box .op-title {
  color: #2563eb !important;
}

html:not(.dark) .status-pill,
html[data-theme="light"] .status-pill {
  background: #f1f5f9 !important;
  color: #475569 !important;
  border-color: #cbd5e1 !important;
}

html:not(.dark) .svg-wrapper,
html[data-theme="light"] .svg-wrapper {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}

html:not(.dark) .demux-box,
html[data-theme="light"] .demux-box {
  fill: #f8fafc !important;
  stroke: #cbd5e1 !important;
}

html:not(.dark) .demux-box.active-box,
html[data-theme="light"] .demux-box.active-box {
  fill: #eff6ff !important;
  stroke: #2563eb !important;
}

html:not(.dark) .demux-label,
html:not(.dark) .svg-stage-header,
html[data-theme="light"] .demux-label,
html[data-theme="light"] .svg-stage-header {
  fill: #0f172a !important;
}

html:not(.dark) .demux-sublabel,
html:not(.dark) .svg-stage-sub,
html[data-theme="light"] .demux-sublabel,
html[data-theme="light"] .svg-stage-sub {
  fill: #64748b !important;
}


