/* ============================================================
   Flip-Flop Virtual Laboratory — Style Sheet
   Virtual Instrumentation Labs Interactive Learning Platform
   Aesthetic: Premium Engineering Virtual Laboratory
   ============================================================ */

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

:root {
  /* Laboratory Palette */
  --lab-bg:           #f8fafc;
  --panel-bg:         #ffffff;
  --panel-border:     #e2e8f0;
  --header-bg:        rgba(255, 255, 255, 0.88);
  --header-text:      #0f172a;
  
  /* Accent & State Colors */
  --accent:           #2563eb;
  --accent-hover:     #1d4ed8;
  --accent-light:     #eff6ff;
  --accent-border:    #bfdbfe;
  
  --text-primary:     #0f172a;
  --text-secondary:   #475569;
  --text-muted:       #64748b;
  
  /* Signal & Wire Colors */
  --wire-off:         #cbd5e1;
  --wire-on:          #2563eb;
  --wire-on-glow:     rgba(37, 99, 235, 0.35);
  --clk-signal:       #10b981;
  --clk-glow:         rgba(16, 185, 129, 0.35);
  
  /* State Colors */
  --invalid-color:    #dc2626;
  --invalid-bg:       #fef2f2;
  --invalid-border:   #fca5a5;
  --warning-amber:    #f59e0b;

  /* LED Colors */
  --led-off-bg:       #94a3b8;
  --led-off-border:   #64748b;
  --led-on-bg:        #10b981;
  --led-on-border:    #059669;
  --led-on-glow:      0 0 16px rgba(16, 185, 129, 0.7);

  /* Shadows & Radius */
  --shadow-sm:        0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md:        0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg:        0 10px 25px rgba(15, 23, 42, 0.08);
  
  --radius-sm:        6px;
  --radius-md:        10px;
  --radius-lg:        14px;
  
  --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-color: var(--lab-bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Laboratory Glassmorphic Header ────────────────────────── */
.lab-title-bar {
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--header-text);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.lab-title-container {
  display: flex;
  flex-direction: column;
}

.lab-title-container h1 {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.2px;
}

.lab-title-bar .lab-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.lab-active-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: rgba(241, 245, 249, 0.8);
  border: 1px solid var(--panel-border);
  padding: 6px 14px;
  border-radius: 20px;
}

.lab-active-indicator .indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(37, 99, 235, 0.6);
}

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

/* ── Experiment Navigation Tabs ────────────────────────────── */
.experiment-nav-bar {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  gap: 12px;
  flex-wrap: wrap;
}

.nav-tabs-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.nav-tab-btn {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  position: relative;
}

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

.nav-tab-btn.active {
  background: var(--accent-light);
  border-color: var(--accent-border);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.nav-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 18px;
  right: 18px;
  height: 2.5px;
  background: var(--accent);
  border-radius: 2px;
}

/* ── Control Bar & Action Hierarchy ───────────────────────── */
.lab-toolbar {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 10px 18px;
  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: 8px;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--panel-border);
  margin: 0 4px;
}

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

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

.btn--clk-pulse {
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}
.btn--clk-pulse:hover:not(:disabled) {
  background: #059669;
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.35);
}

/* Secondary Action Buttons */
.btn--secondary {
  background: #ffffff;
  border-color: var(--panel-border);
  color: var(--text-secondary);
}
.btn--secondary:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--text-primary);
}

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

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

/* Advanced Action Button */
.btn--accent {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}
.btn--accent:hover {
  background: #1e293b;
}

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

/* ── 3-Column Main Laboratory Layout ──────────────────────── */
.lab-top-grid {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 18px;
  align-items: stretch;
}

@media (max-width: 1200px) {
  .lab-top-grid {
    grid-template-columns: 260px 1fr 280px;
    gap: 14px;
  }
}

@media (max-width: 992px) {
  .lab-top-grid {
    grid-template-columns: 1fr 1fr;
  }
  .lab-top-grid > section:nth-child(2) {
    grid-column: 1 / -1;
    order: -1;
  }
}

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

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

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

.lab-panel__body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

/* ── Left Panel: Input Controls ────────────────────────────── */
.input-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.input-controls-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.input-control-card.active-high {
  border-color: var(--accent);
  background: var(--accent-light);
}

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

.input-symbol {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

/* Toggle Switch Button */
.toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

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

.toggle-btn__state {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  min-width: 14px;
  text-align: center;
  color: var(--text-secondary);
}

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

.toggle-btn.on .toggle-btn__knob {
  transform: translateX(22px);
}

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

/* Clock Generator Card */
.clock-display-card {
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.clock-status-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: #f1f5f9;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.clock-status-badge.running {
  background: #dcfce7;
  color: #15803d;
}

.clock-waveform-container {
  width: 100%;
  height: 85px;
  background: #0f172a;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.clock-waveform-svg {
  width: 100%;
  height: 100%;
}

.clock-freq-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.clock-freq-slider {
  flex: 1;
  accent-color: var(--accent);
}

/* ── Center Panel: Internal Circuit Area ───────────────────── */
.schematic-wrapper {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  position: relative;
  overflow: auto;
  min-height: 400px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.schematic-svg {
  width: 100%;
  height: 100%;
  min-width: 620px;
  max-height: 440px;
}

/* SVG Schematics Styling */
.svg-wire {
  stroke: var(--wire-off);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  transition: stroke 0.25s ease, filter 0.25s ease;
}

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

.svg-wire.active-clk {
  stroke: var(--clk-signal);
  filter: drop-shadow(0 0 3px var(--clk-glow));
}

.svg-wire.active-invalid {
  stroke: var(--invalid-color);
  filter: drop-shadow(0 0 3px rgba(220, 38, 38, 0.4));
}

.svg-gate-body {
  fill: #f8fafc;
  stroke: #1e293b;
  stroke-width: 2;
  transition: fill 0.25s ease, stroke 0.25s ease;
}

.svg-gate-body.active {
  fill: #eff6ff;
  stroke: var(--accent);
}

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

.svg-text-label {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  fill: var(--text-primary);
}

.svg-junction {
  fill: var(--text-primary);
}

/* ── Right Panel: State & Output Monitor ────────────────────── */
.state-readout-card {
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.state-readout-card.primary {
  border-color: var(--accent-border);
  background: var(--accent-light);
}

.state-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.state-readout-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
}

.state-sub-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.op-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.op-badge.op-hold {
  background: #e2e8f0;
  color: #334155;
}

.op-badge.op-set {
  background: #dbeafe;
  color: #1d4ed8;
}

.op-badge.op-reset {
  background: #ffedd5;
  color: #c2410c;
}

.op-badge.op-toggle {
  background: #f3e8ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.op-badge.op-invalid {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fca5a5;
}

.op-badge.op-store0 {
  background: #ffedd5;
  color: #c2410c;
}

.op-badge.op-store1 {
  background: #dbeafe;
  color: #1d4ed8;
}

/* ── Live Educational Explanation Card ────────────────────── */
.op-explanation-card {
  background: #f8fafc;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.op-explanation-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.op-explanation-text {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.4;
  font-weight: 500;
}

/* State Flow Breadcrumb */
.op-flow-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  overflow-x: auto;
}

.flow-step {
  padding: 2px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  color: var(--text-primary);
  font-weight: 700;
  white-space: nowrap;
}

.flow-step.highlight {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.flow-arrow {
  color: var(--text-muted);
  font-weight: 700;
}

/* Dynamic "What is Happening?" Summary Card */
.state-summary-card {
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.state-summary-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.state-summary-content h4 {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.state-summary-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* LED Output Grid */
.led-outputs-group {
  display: flex;
  gap: 10px;
}

.led-card {
  flex: 1;
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

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

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

.led-card.invalid .led-indicator {
  background: var(--invalid-color);
  border-color: #b91c1c;
  box-shadow: 0 0 12px rgba(220, 38, 38, 0.7);
}

.led-title {
  font-size: 0.85rem;
  font-weight: 800;
}

.led-val {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

/* Warnings & Banners */
.warning-alert-card {
  background: var(--invalid-bg);
  border: 1px solid var(--invalid-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: none;
  align-items: flex-start;
  gap: 8px;
  color: #991b1b;
}

.warning-alert-card.show {
  display: flex;
}

.warning-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.warning-text h4 {
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.warning-text p {
  font-size: 0.72rem;
  line-height: 1.35;
  color: #b91c1c;
}

.toggle-info-card {
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: none;
  align-items: flex-start;
  gap: 8px;
  color: #5b21b6;
}

.toggle-info-card.show {
  display: flex;
}

.toggle-info-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.toggle-info-text h4 {
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.toggle-info-text p {
  font-size: 0.72rem;
  line-height: 1.35;
  color: #6d28d9;
}

/* ── Middle Grid: Truth Table & History ─────────────────────── */
.lab-middle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

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

.table-container {
  overflow-x: auto;
  background: #ffffff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
}

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

.truth-table th {
  background: #0f172a;
  color: #ffffff;
  padding: 9px;
  font-weight: 600;
  border-bottom: 1px solid var(--panel-border);
}

.truth-table td {
  padding: 8px;
  border-bottom: 1px solid var(--panel-border);
  color: var(--text-primary);
  font-family: var(--font-mono);
}

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

.truth-table tr.active-row td {
  color: var(--accent);
}

.history-container {
  max-height: 200px;
  overflow-y: auto;
  background: #ffffff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
}

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

.history-table th {
  background: #f1f5f9;
  color: var(--text-secondary);
  padding: 8px;
  font-weight: 700;
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--panel-border);
}

.history-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--panel-border);
  font-family: var(--font-mono);
}

.history-table tr:nth-child(even) {
  background: #f8fafc;
}

/* ── Selection Cards Section ───────────────────────────────── */
.ff-select-section {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ff-select-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.ff-select-title h2 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ff-select-title p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.ff-select-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

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

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

.ff-select-card {
  background: #ffffff;
  border: 1.5px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.2s ease;
  user-select: none;
}

.ff-select-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.ff-select-card.active {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 0 1px var(--accent);
}

.ff-card-code {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ff-select-card.active .ff-card-code {
  color: var(--accent);
}

.ff-card-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.ff-card-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ── Educational Section: Learn the Concept ──────────────── */
.theory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

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

.theory-card h3 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--header-text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.theory-card p, .theory-card ul {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.theory-card ul {
  padding-left: 16px;
}

/* Comparison Matrix */
.comp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  text-align: center;
}

.comp-table th {
  background: #0f172a;
  color: #ffffff;
  padding: 9px;
  font-weight: 600;
}

.comp-table td {
  padding: 8px;
  border-bottom: 1px solid var(--panel-border);
  font-family: var(--font-mono);
}

.comp-table tr:nth-child(even) td {
  background: #f8fafc;
}

/* Simulator Container Transitions */
.sim-container {
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease-in-out;
}

.sim-container.active {
  display: flex;
  flex-direction: column;
  gap: 20px;
  opacity: 1;
}

/* Footer Styling */
.lab-footer {
  background: #0f172a;
  color: #94a3b8;
  padding: 14px;
  text-align: center;
  font-size: 0.78rem;
  margin-top: auto;
}
