/* ============================================================
   1×2 Demultiplexer Virtual Laboratory — Style Sheet
   Virtual Instrumentation Labs Interactive Learning Platform
   ============================================================ */

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

:root {
  /* Laboratory Colour Palette */
  --lab-bg:           #f8fafc;
  --panel-bg:         #ffffff;
  --panel-border:     #cbd5e1;
  --header-bg:        #1a2744;
  --header-text:      #ffffff;
  --accent:           #2563eb;
  --accent-hover:     #1d4ed8;
  --accent-light:     #dbeafe;
  --text-primary:     #0f172a;
  --text-secondary:   #475569;
  --text-muted:       #94a3b8;
  
  --success:          #16a34a;
  --success-bg:       #dcfce7;
  --danger:           #dc2626;
  --danger-bg:        #fee2e2;
  --warning:          #d97706;
  --warning-bg:       #fef3c7;
  
  --wire-off:         #94a3b8;
  --wire-on:          #22c55e;
  --wire-glow:        rgba(34, 197, 94, 0.4);
  --wire-selected:    #3b82f6;
  
  --led-off:          #64748b;
  --led-on:           #22c55e;
  --led-glow:         rgba(34, 197, 94, 0.6);
  
  --switch-track-off: #cbd5e1;
  --switch-track-on:  #22c55e;
  --switch-knob:      #ffffff;
  
  --gate-fill:        #f1f5f9;
  --gate-stroke:      #1a2744;
  
  --shadow-sm:        0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:        0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:        0 10px 25px rgba(0,0,0,0.10);
  
  --radius-sm:        4px;
  --radius-md:        8px;
  --radius-lg:        12px;
  
  --font-sans:        'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  --font-mono:        'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

html { 
  font-size: 15px;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  background-color: var(--lab-bg);
  background-image: none !important;
  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: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
  border-bottom: 2px solid rgba(255,255,255,0.1);
}

.lab-title-container h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.lab-title-container .lab-subtitle {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 400;
  margin-top: 2px;
  display: block;
}

.lab-badge {
  background: var(--accent);
  color: #ffffff;
  font-size: 0.72rem;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(37,99,235,0.3);
}

/* ── Module Navigation Bar ─────────────────────────────────── */
.gate-nav-bar {
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  padding: 8px 24px;
  position: sticky;
  top: 60px;
  z-index: 99;
}

.gate-nav-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #334155 #0f172a;
  padding-bottom: 2px;
}

.gate-nav-label {
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-right: 8px;
  white-space: nowrap;
}

.gate-nav-link {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.gate-nav-link:hover {
  color: #ffffff;
  background: rgba(37, 99, 235, 0.25);
  border-color: rgba(37, 99, 235, 0.5);
}

.gate-nav-link.active {
  color: #ffffff;
  background: var(--accent);
  border-color: #3b82f6;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

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

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

.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;
  text-transform: uppercase;
}

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

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

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

.btn--primary {
  background: var(--accent);
  color: #ffffff;
}
.btn--primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.btn--secondary {
  background: #0f172a;
  color: #ffffff;
}
.btn--secondary:hover {
  background: #1e293b;
}

.btn--outline {
  background: transparent;
  border-color: var(--panel-border);
  color: var(--text-primary);
}
.btn--outline:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn--accent {
  background: #4f46e5;
  color: #ffffff;
}
.btn--accent:hover {
  background: #4338ca;
  box-shadow: 0 2px 8px rgba(79,70,229,0.3);
}

.btn--danger {
  background: var(--danger);
  color: #ffffff;
}
.btn--danger:hover {
  background: #b91c1c;
}

.btn--mode {
  background: #e2e8f0;
  color: var(--text-secondary);
  border: 1px solid #cbd5e1;
}
.btn--mode:hover {
  background: #cbd5e1;
}
.btn--mode.active {
  background: var(--header-bg);
  color: #ffffff;
  border-color: var(--header-bg);
  box-shadow: 0 2px 6px rgba(26,39,68,0.25);
}

/* ── Panel Components ──────────────────────────────────────── */
.lab-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

.lab-panel__header .header-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lab-panel__body {
  padding: 18px;
  flex: 1;
}

/* ── Top Grid (Controls + Workspace + Monitor) ─────────────── */
.lab-workspace-grid {
  display: grid;
  grid-template-columns: 320px 1fr 300px;
  gap: 20px;
  align-items: stretch;
}

@media (max-width: 1200px) {
  .lab-workspace-grid {
    grid-template-columns: 300px 1fr;
  }
  .lab-workspace-grid #monitor-panel {
    grid-column: 1 / -1;
  }
}

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

/* ── Control Card Styles ───────────────────────────────────── */
.control-group-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.control-card {
  background: #f8fafc;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 14px;
  transition: border-color 0.2s;
}

.control-card:hover {
  border-color: var(--accent);
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.control-info {
  display: flex;
  flex-direction: column;
}

.control-symbol {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.control-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Toggle Switch Widget */
.toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logic-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  min-width: 64px;
  text-anchor: middle;
  text-align: center;
  transition: all 0.2s;
}

.logic-badge.low {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(220,38,38,0.2);
}

.logic-badge.high {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(22,163,74,0.2);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--switch-track-off);
  transition: .25s ease;
  border-radius: 26px;
  border: 1px solid #94a3b8;
}

.toggle-track:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .25s ease;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

input:checked + .toggle-track {
  background-color: var(--switch-track-on);
  border-color: #16a34a;
}

input:checked + .toggle-track:before {
  transform: translateX(22px);
}

/* ── Current Operation Panel ───────────────────────────────── */
.operation-card {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-top: 10px;
}

.operation-header {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.operation-status {
  font-size: 0.9rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  width: 100%;
}

.operation-status.y0-active {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

.operation-status.y1-active {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #a5b4fc;
}

.operation-status.inactive {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.operation-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ── Circuit SVG Workspace ─────────────────────────────────── */
.circuit-workspace {
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.circuit-toolbar {
  background: #f8fafc;
  border-bottom: 1px solid var(--panel-border);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.view-indicator {
  font-weight: 700;
  color: var(--text-primary);
  background: #e2e8f0;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.svg-container {
  width: 100%;
  height: 100%;
  min-height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: auto;
  padding: 10px;
}

#circuit-svg {
  width: 100%;
  height: 100%;
  max-height: 440px;
  user-select: none;
}

/* SVG Circuit Element Styles */
.svg-label {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 14px;
  fill: #0f172a;
}

.svg-label-sub {
  font-family: var(--font-sans);
  font-size: 11px;
  fill: #64748b;
}

.svg-pin-label {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  fill: #1e293b;
}

.svg-gate-box {
  fill: var(--gate-fill);
  stroke: var(--gate-stroke);
  stroke-width: 2.2;
  rx: 8px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.06));
}

.wire {
  fill: none;
  stroke: var(--wire-off);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.25s ease, stroke-width 0.25s ease;
}

.wire.active-high {
  stroke: var(--wire-on);
  stroke-width: 3.5;
  filter: drop-shadow(0 0 4px var(--wire-glow));
}

.wire.active-route {
  stroke: var(--wire-selected);
  stroke-width: 3.5;
  stroke-dasharray: 6 3;
  animation: dash 1s linear infinite;
}

@keyframes dash {
  to { stroke-dashoffset: -18; }
}

.wire-junction {
  fill: var(--header-bg);
}

/* Animated Signal Pulses */
.signal-particle {
  fill: #22c55e;
  filter: drop-shadow(0 0 6px #22c55e);
  opacity: 0;
  transition: opacity 0.2s;
}

.signal-particle.active {
  opacity: 1;
}

/* ── Output Monitor Panel ──────────────────────────────────── */
.monitor-card {
  background: #f8fafc;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.25s ease;
}

.monitor-card.active {
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(37,99,235,0.12);
}

.monitor-header {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* LED Styling */
.led-indicator {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--led-off);
  border: 3px solid #cbd5e1;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.3);
  margin: 10px 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.led-indicator::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 10px;
  width: 14px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
}

.led-indicator.on {
  background: radial-gradient(circle at 35% 35%, #4ade80, #16a34a);
  border-color: #22c55e;
  box-shadow: 
    0 0 16px var(--led-glow),
    0 0 30px rgba(34, 197, 94, 0.3),
    inset 0 -2px 6px rgba(0,0,0,0.2);
}

.monitor-val-tag {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 12px;
  margin-top: 4px;
}

.monitor-val-tag.low {
  background: #e2e8f0;
  color: #475569;
}

.monitor-val-tag.high {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(22,163,74,0.3);
}

/* Selected Output Indicator */
.selected-output-banner {
  background: var(--header-bg);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}

.selected-output-banner .banner-label {
  font-size: 0.7rem;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #94a3b8;
  display: block;
}

.selected-output-banner .banner-value {
  font-size: 1.2rem;
  font-weight: 800;
  color: #60a5fa;
  font-family: var(--font-mono);
  margin-top: 2px;
}

/* ── Observation & Educational Panels ─────────────────────── */
.tab-nav {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab-btn {
  padding: 9px 16px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  border-top-left-radius: var(--radius-sm);
  border-top-right-radius: var(--radius-sm);
}

.tab-btn:hover {
  color: var(--accent);
  background: #f1f5f9;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--accent-light);
  font-weight: 700;
}

.tab-content {
  display: none;
  animation: fadeIn 0.25s ease;
}

.tab-content.active {
  display: block;
}

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

/* Info Cards & Content Blocks */
.info-card {
  background: #f8fafc;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.info-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--header-bg);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.info-card ul {
  padding-left: 20px;
  margin-top: 8px;
}

.info-card li {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

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

.truth-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: #ffffff;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--panel-border);
}

.truth-table th, .truth-table td {
  padding: 10px 16px;
  text-align: center;
  border-bottom: 1px solid #e2e8f0;
}

.truth-table th {
  background: #f1f5f9;
  color: var(--header-bg);
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.truth-table tbody tr {
  transition: background-color 0.2s ease;
}

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

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

.truth-table tbody tr.active-row td {
  color: #1e40af;
  border-bottom-color: #93c5fd;
}

.active-row-badge {
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* Comparison Matrix (MUX vs DEMUX) */
.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 12px;
}

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

.comp-box {
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 14px;
  border-top: 4px solid var(--accent);
}

.comp-box.demux {
  border-top-color: #16a34a;
}

.comp-box h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--header-bg);
  margin-bottom: 8px;
}

.comp-box p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* Formula Box */
.formula-box {
  background: #1e293b;
  color: #ffffff;
  padding: 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  text-align: center;
  font-size: 1.05rem;
  margin: 12px 0;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.formula-box span {
  color: #60a5fa;
  font-weight: 700;
}

/* Interactive Quiz Styles */
.quiz-score-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f1f5f9;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-weight: 700;
  margin-bottom: 16px;
  font-size: 0.88rem;
}

.quiz-card {
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
}

.quiz-question {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--header-bg);
  margin-bottom: 12px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-option-btn {
  padding: 10px 14px;
  text-align: left;
  border: 1px solid var(--panel-border);
  background: #f8fafc;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  transition: all 0.2s;
}

.quiz-option-btn:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.quiz-option-btn.correct {
  background: var(--success-bg) !important;
  border-color: var(--success) !important;
  color: var(--success) !important;
  font-weight: 700;
}

.quiz-option-btn.wrong {
  background: var(--danger-bg) !important;
  border-color: var(--danger) !important;
  color: var(--danger) !important;
}

/* Utility Animations */
.pulse-highlight {
  animation: highlightPulse 0.5s ease-out;
}

@keyframes highlightPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* ============================================================
   DARK & LIGHT THEME OVERRIDES — 1x2 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;
  --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;
}

/* Toolbar & Panels */
html[data-theme="dark"] .lab-toolbar,
html.dark .lab-toolbar {
  background: #111827 !important;
  border-color: #263550 !important;
}

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

html[data-theme="dark"] .toolbar-divider,
html.dark .toolbar-divider {
  background: #263550 !important;
}

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

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

/* Controls & Operation Panel */
html[data-theme="dark"] .control-group-title,
html.dark .control-group-title {
  color: #94a3b8 !important;
  border-bottom-color: #263550 !important;
}

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

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

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

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

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

html[data-theme="dark"] .operation-status.inactive,
html.dark .operation-status.inactive {
  background: #1e293b !important;
  color: #94a3b8 !important;
  border-color: #334155 !important;
}

/* Circuit Workspace & SVG Canvas */
html[data-theme="dark"] .circuit-workspace,
html.dark .circuit-workspace {
  background: #111827 !important;
  border-color: #263550 !important;
}

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

html[data-theme="dark"] .circuit-toolbar strong,
html.dark .circuit-toolbar strong {
  color: #f8fafc !important;
}

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

html[data-theme="dark"] #circuit-svg,
html.dark #circuit-svg {
  background: #080d18 !important;
}

html[data-theme="dark"] pattern#svg-grid path,
html.dark pattern#svg-grid path {
  stroke: transparent !important;
}

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

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

html[data-theme="dark"] .svg-pin-label,
html.dark .svg-pin-label {
  fill: #cbd5e1 !important;
}

html[data-theme="dark"] .svg-gate-box,
html.dark .svg-gate-box {
  fill: #162036 !important;
  stroke: #38bdf8 !important;
}

html[data-theme="dark"] .wire-junction,
html.dark .wire-junction {
  fill: #38bdf8 !important;
}

/* Output Monitor Panel */
html[data-theme="dark"] .monitor-card,
html.dark .monitor-card {
  background: #172033 !important;
  border-color: #263550 !important;
  color: #f8fafc !important;
}

html[data-theme="dark"] .monitor-card.active,
html.dark .monitor-card.active {
  background: #1e293b !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.15) !important;
}

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

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

html[data-theme="dark"] .selected-output-banner,
html.dark .selected-output-banner {
  background: #0f172a !important;
  color: #f8fafc !important;
  border: 1px solid #263550 !important;
}

/* Theory & Educational Tabs */
html[data-theme="dark"] .tab-nav,
html.dark .tab-nav {
  border-bottom-color: #263550 !important;
}

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

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

html[data-theme="dark"] .tab-btn.active,
html.dark .tab-btn.active {
  color: #38bdf8 !important;
  border-bottom-color: #38bdf8 !important;
  background: rgba(56, 189, 248, 0.15) !important;
}

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

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

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

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

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

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

html[data-theme="dark"] .truth-table tbody tr:hover,
html.dark .truth-table tbody tr:hover {
  background-color: #1e293b !important;
}

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

html[data-theme="dark"] .comp-box h4,
html[data-theme="dark"] .quiz-question,
html.dark .comp-box h4,
html.dark .quiz-question {
  color: #f8fafc !important;
}

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

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

html[data-theme="dark"] .quiz-option-btn:hover,
html.dark .quiz-option-btn:hover {
  background: #1e293b !important;
}

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

html[data-theme="dark"] .btn--mode.active,
html.dark .btn--mode.active {
  background: #2563eb !important;
  color: #ffffff !important;
  border-color: #2563eb !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-toolbar,
html[data-theme="light"] .lab-toolbar {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}

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

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

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

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

html:not(.dark) .circuit-toolbar,
html[data-theme="light"] .circuit-toolbar {
  background: #f8fafc !important;
  border-bottom-color: #cbd5e1 !important;
  color: #475569 !important;
}

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

html:not(.dark) .view-indicator,
html[data-theme="light"] .view-indicator {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}

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

html:not(.dark) pattern#svg-grid path,
html[data-theme="light"] pattern#svg-grid path {
  stroke: transparent !important;
}

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

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

html:not(.dark) .svg-pin-label,
html[data-theme="light"] .svg-pin-label {
  fill: #1e293b !important;
}

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

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

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

html:not(.dark):not([data-theme="dark"]) .info-card h3,
html:not(.dark):not([data-theme="dark"]) .truth-table th,
html:not(.dark):not([data-theme="dark"]) .comp-box h4,
html:not(.dark):not([data-theme="dark"]) .quiz-question,
html[data-theme="light"] .info-card h3,
html[data-theme="light"] .truth-table th,
html[data-theme="light"] .comp-box h4,
html[data-theme="light"] .quiz-question {
  color: #0f172a !important;
}

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

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


