/* ==========================================================================
   4-Bit PISO Shift Register - Professional Engineering Design System
   Digital Electronics Virtual Laboratory
   ========================================================================== */

:root {
  /* Core Engineering Palette */
  --bg-dark: #090d16;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --border-color: rgba(51, 65, 85, 0.6);
  --border-glow: rgba(0, 240, 255, 0.3);

  --primary-cyan: #00f0ff;
  --primary-blue: #3b82f6;
  --accent-purple: #a855f7;
  --status-green: #10b981;
  --status-amber: #f59e0b;
  --status-red: #ef4444;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Code', monospace;

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(0, 240, 255, 0.15);
  --shadow-purple-glow: 0 0 20px rgba(168, 85, 247, 0.25);
  --shadow-amber-glow: 0 0 20px rgba(245, 158, 11, 0.25);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

/* Reset & Global Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
  background-image: none !important;
}

.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Card Component (Glassmorphism) */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  border-color: rgba(0, 240, 255, 0.25);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.card-header h2,
.card-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-header h2 svg,
.card-header h3 svg {
  color: var(--primary-cyan);
}

/* Badges */
.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge.blue {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary-blue);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge.purple {
  background: rgba(168, 85, 247, 0.15);
  color: var(--accent-purple);
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.mono-badge {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--primary-cyan);
  background: rgba(0, 240, 255, 0.1);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

/* App Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.lab-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--primary-cyan);
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

.app-header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 0%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.app-header .subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.status-summary-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: 30px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.status-summary-pill.loading {
  border-color: rgba(168, 85, 247, 0.6);
  box-shadow: var(--shadow-purple-glow);
}

.status-summary-pill.shifting {
  border-color: rgba(0, 240, 255, 0.6);
  box-shadow: var(--shadow-glow);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--status-green);
  box-shadow: 0 0 8px var(--status-green);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.status-dot.green {
  background-color: var(--status-green);
  box-shadow: 0 0 8px var(--status-green);
}

.status-dot.amber {
  background-color: var(--status-amber);
  box-shadow: 0 0 8px var(--status-amber);
  animation: pulseAmber 1s infinite alternate;
}

.status-dot.purple {
  background-color: var(--accent-purple);
  box-shadow: 0 0 8px var(--accent-purple);
  animation: pulsePurple 1s infinite alternate;
}

@keyframes pulseAmber {
  from {
    opacity: 0.6;
    box-shadow: 0 0 4px var(--status-amber);
  }

  to {
    opacity: 1;
    box-shadow: 0 0 12px var(--status-amber);
  }
}

@keyframes pulsePurple {
  from {
    opacity: 0.6;
    box-shadow: 0 0 4px var(--accent-purple);
  }

  to {
    opacity: 1;
    box-shadow: 0 0 14px var(--accent-purple);
  }
}

/* Toolbar Controls */
.toolbar-section {
  padding: 1rem 1.25rem;
}

.toolbar-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.button-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  user-select: none;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(80%);
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  border-color: rgba(96, 165, 250, 0.3);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.8);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(51, 65, 85, 0.8);
  border-color: rgba(148, 163, 184, 0.4);
}

.btn-accent {
  background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
  color: #fff;
  border-color: rgba(6, 182, 212, 0.4);
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.btn-accent:hover:not(:disabled) {
  background: linear-gradient(135deg, #0e7490 0%, #155e75 100%);
  box-shadow: 0 4px 16px rgba(6, 182, 212, 0.5);
  transform: translateY(-1px);
}

.btn-load {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: #fff;
  border-color: rgba(168, 85, 247, 0.5);
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.4);
  position: relative;
  overflow: hidden;
}

.btn-load:hover:not(:disabled) {
  background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.6);
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
}

/* Mode Switch Group */
.mode-switch-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mode-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.mode-btn-group {
  display: flex;
  background: rgba(9, 13, 22, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.btn-mode {
  padding: 0.35rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-mode.active {
  background: rgba(0, 240, 255, 0.2);
  color: var(--primary-cyan);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
}

.btn-mode.load-active {
  background: rgba(168, 85, 247, 0.25);
  color: var(--accent-purple);
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.4);
}

/* Sliders */
.sliders-group {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.slider-control {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 170px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.slider-control input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(30, 41, 59, 0.9);
  outline: none;
}

.slider-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-cyan);
  cursor: pointer;
  box-shadow: 0 0 8px var(--primary-cyan);
  transition: transform 0.15s ease;
}

.slider-control input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Banner Section (Cards Grid) */
.banner-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

/* Input Display Card */
.input-display-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.08) 0%, rgba(15, 23, 42, 0.85) 100%);
  border-color: rgba(168, 85, 247, 0.3);
}

.display-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.75rem;
  text-align: center;
}

.input-toggles-wrapper {
  display: flex;
  gap: 0.6rem;
}

.input-bit-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.bit-name {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--accent-purple);
  font-weight: 600;
}

.bit-toggle-btn {
  width: 44px;
  height: 48px;
  background: rgba(30, 41, 59, 0.9);
  border: 2px solid rgba(168, 85, 247, 0.4);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.bit-toggle-btn.high {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.3) 0%, rgba(124, 58, 237, 0.5) 100%);
  border-color: var(--accent-purple);
  color: #fff;
  box-shadow: var(--shadow-purple-glow);
  transform: translateY(-1px);
}

.bit-toggle-btn:hover {
  border-color: var(--primary-cyan);
}

/* Register Display Card */
.counter-display-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.binary-display-wrapper {
  display: flex;
  gap: 0.6rem;
}

.bit-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(9, 13, 22, 0.9);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  min-width: 44px;
  transition: all 0.2s ease;
}

.bit-box.high {
  border-color: var(--primary-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.25);
  background: rgba(0, 240, 255, 0.06);
}

.bit-box.shift-flash {
  animation: bitShiftFlash 0.35s ease-out;
}

@keyframes bitShiftFlash {
  0% {
    transform: scale(1.15);
    border-color: var(--primary-cyan);
    box-shadow: 0 0 20px var(--primary-cyan);
  }

  100% {
    transform: scale(1);
  }
}

.bit-label {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.bit-val {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.bit-box.high .bit-val {
  color: var(--primary-cyan);
}

/* Serial Output Card */
.serial-output-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(15, 23, 42, 0.85) 100%);
  border-color: rgba(16, 185, 129, 0.3);
}

.serial-out-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.serial-tag {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--status-green);
  letter-spacing: 0.5px;
}

.serial-val {
  font-family: var(--font-mono);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.serial-out-box.high .serial-val {
  color: var(--status-green);
  text-shadow: 0 0 16px var(--status-green);
}

.voltage-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.voltage-tag.low {
  background: rgba(100, 116, 139, 0.2);
  color: var(--text-dim);
}

.voltage-tag.high {
  background: rgba(16, 185, 129, 0.2);
  color: var(--status-green);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

/* Status Card */
.ripple-state-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.status-indicator-box {
  background: rgba(9, 13, 22, 0.8);
  border-left: 4px solid var(--status-green);
  padding: 0.6rem 0.85rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: all 0.3s ease;
}

.status-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--status-green);
  margin-bottom: 0.15rem;
}

.status-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Workspace Grid Layout */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.25rem;
}

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

/* Schematic Column & SVG Container */
.schematic-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.circuit-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex-grow: 1;
}

.circuit-legend {
  display: flex;
  gap: 1.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.color-dot.line-high {
  background-color: var(--primary-cyan);
  box-shadow: 0 0 6px var(--primary-cyan);
}

.color-dot.line-low {
  background-color: #334155;
}

.color-dot.line-load {
  background-color: var(--accent-purple);
  box-shadow: 0 0 6px var(--accent-purple);
}

.color-dot.line-shift {
  background-color: var(--status-green);
  box-shadow: 0 0 6px var(--status-green);
}

.svg-scroll-wrapper {
  width: 100%;
  background: rgba(9, 13, 22, 0.95);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  overflow-x: auto;
  min-height: 440px;
}

.schematic-footnote {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  background: rgba(30, 41, 59, 0.4);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
}

.schematic-footnote code {
  font-family: var(--font-mono);
  color: var(--accent-purple);
  background: rgba(168, 85, 247, 0.1);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

/* Monitors Column & Probes */
.monitors-column {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.clock-probes-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.probe-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(9, 13, 22, 0.8);
  border: 1px solid rgba(51, 65, 85, 0.4);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
}

.probe-name {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.probe-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.probe-badge.low {
  background: rgba(51, 65, 85, 0.5);
  color: var(--text-dim);
}

.probe-badge.high {
  background: rgba(0, 240, 255, 0.15);
  color: var(--primary-cyan);
  border: 1px solid rgba(0, 240, 255, 0.4);
}

.probe-badge.load-active {
  background: rgba(168, 85, 247, 0.2);
  color: var(--accent-purple);
  border: 1px solid rgba(168, 85, 247, 0.5);
}

/* Flip-Flop Hardware Cards Grid */
.ff-cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.ff-status-card {
  background: rgba(9, 13, 22, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  transition: all 0.2s ease;
}

.ff-status-card.active-flip {
  border-color: var(--primary-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
}

.ff-status-card.active-load {
  border-color: var(--accent-purple);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.25);
}

.ff-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ff-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-cyan);
}

.ff-state-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: rgba(51, 65, 85, 0.5);
  color: var(--text-dim);
}

.ff-state-tag.active {
  background: rgba(0, 240, 255, 0.2);
  color: var(--primary-cyan);
}

.ff-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
}

.ff-row {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
}

.ff-row strong,
.ff-row .mono {
  font-family: var(--font-mono);
  color: var(--text-main);
}

.val-mono {
  font-family: var(--font-mono);
  color: var(--accent-purple);
}

/* State & History Section */
.analysis-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.25rem;
}

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

.state-blocks-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.state-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(9, 13, 22, 0.8);
  border: 1px solid var(--border-color);
  padding: 0.6rem 0.4rem;
  border-radius: var(--radius-sm);
}

.state-block.active {
  border-color: var(--primary-cyan);
  background: rgba(0, 240, 255, 0.05);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
}

.state-block-title {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 0.2rem;
  text-align: center;
}

.state-block-val {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.state-block.active .state-block-val {
  color: var(--primary-cyan);
}

.state-arrow {
  color: var(--text-dim);
  font-size: 1.1rem;
}

.operation-status-details {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.8rem;
  background: rgba(9, 13, 22, 0.6);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(51, 65, 85, 0.4);
}

.op-detail-item {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
}

.op-detail-item strong {
  font-family: var(--font-mono);
}

.tag-ready {
  color: var(--status-green);
}

.tag-idle {
  color: var(--text-dim);
}

.tag-out {
  color: var(--status-green);
}

/* Shift History Table */
.table-scroll-wrapper {
  overflow-x: auto;
  max-height: 250px;
  overflow-y: auto;
}

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

.history-table th {
  background: rgba(9, 13, 22, 0.9);
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 2;
}

.history-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-family: var(--font-mono);
  color: var(--text-main);
}

.history-table tbody tr.active-row {
  background: rgba(0, 240, 255, 0.08);
  border-left: 3px solid var(--primary-cyan);
}

.history-table tbody tr.load-row {
  background: rgba(168, 85, 247, 0.1);
  border-left: 3px solid var(--accent-purple);
}

.badge-load-op {
  background: rgba(168, 85, 247, 0.2);
  color: var(--accent-purple);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
}

.badge-shift-op {
  background: rgba(0, 240, 255, 0.15);
  color: var(--primary-cyan);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
}

/* Waveform Section */
.timing-canvas-wrapper {
  background: rgba(9, 13, 22, 0.95);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  overflow-x: auto;
}

/* Educational Section */
.educational-section {
  margin-top: 0.5rem;
}

.theory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.theory-card {
  background: rgba(9, 13, 22, 0.6);
  border: 1px solid rgba(51, 65, 85, 0.4);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.theory-card h3 {
  font-size: 0.95rem;
  color: var(--primary-cyan);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.theory-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.theory-card ul {
  padding-left: 1.2rem;
  font-size: 0.83rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.theory-card strong {
  color: var(--text-main);
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(9, 13, 22, 0.5);
}

::-webkit-scrollbar-thumb {
  background: rgba(51, 65, 85, 0.8);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-cyan);
}

/* ==========================================================================
   LIGHT THEME DESIGN SYSTEM OVERRIDES (4-BIT PISO SHIFT REGISTER)
   ========================================================================== */
[data-theme="light"],
html[data-theme="light"],
html:not(.dark) {
  --bg-dark: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: rgba(241, 245, 249, 0.95);
  --border-color: rgba(203, 213, 225, 0.8);
  --border-glow: rgba(2, 132, 199, 0.3);

  --primary-cyan: #0284c7;
  --primary-blue: #2563eb;
  --accent-purple: #9333ea;
  --status-green: #059669;
  --status-amber: #d97706;
  --status-red: #dc2626;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --shadow-sm: 0 4px 12px -2px rgba(0, 0, 0, 0.06);
}

/* Header Text Visibility */
[data-theme="light"] .app-header h1,
html[data-theme="light"] .app-header h1 {
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}

[data-theme="light"] .app-header .subtitle,
html[data-theme="light"] .app-header .subtitle {
  color: #475569 !important;
}

[data-theme="light"] .lab-badge,
html[data-theme="light"] .lab-badge {
  color: #0284c7 !important;
}

/* Status Summary Pill */
[data-theme="light"] .status-summary-pill,
html[data-theme="light"] .status-summary-pill {
  background: rgba(255, 255, 255, 0.9) !important;
  border-color: rgba(203, 213, 225, 0.8) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
}

[data-theme="light"] .status-text,
html[data-theme="light"] .status-text {
  color: #0f172a !important;
}

/* Controls & Buttons */
[data-theme="light"] .btn-secondary,
html[data-theme="light"] .btn-secondary {
  background: #e2e8f0 !important;
  color: #1e293b !important;
  border-color: #cbd5e1 !important;
}

[data-theme="light"] .btn-secondary:hover:not(:disabled),
html[data-theme="light"] .btn-secondary:hover:not(:disabled) {
  background: #cbd5e1 !important;
}

[data-theme="light"] .btn-danger,
html[data-theme="light"] .btn-danger {
  background: rgba(220, 38, 38, 0.1) !important;
  color: #dc2626 !important;
  border-color: rgba(220, 38, 38, 0.3) !important;
}

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

[data-theme="light"] .btn-mode,
html[data-theme="light"] .btn-mode {
  color: #475569 !important;
}

[data-theme="light"] .btn-mode.active,
html[data-theme="light"] .btn-mode.active {
  background: rgba(2, 132, 199, 0.15) !important;
  color: #0284c7 !important;
}

[data-theme="light"] .btn-mode.load-active,
html[data-theme="light"] .btn-mode.load-active {
  background: rgba(147, 51, 234, 0.15) !important;
  color: #9333ea !important;
}

[data-theme="light"] input[type="range"],
html[data-theme="light"] input[type="range"] {
  background: #cbd5e1 !important;
}

/* Banner Cards (Input, Current Register, Serial Out, Status Card) */
[data-theme="light"] .input-display-card,
html[data-theme="light"] .input-display-card {
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.05) 0%, rgba(255, 255, 255, 0.95) 100%) !important;
  border-color: rgba(147, 51, 234, 0.3) !important;
}

[data-theme="light"] .bit-toggle-btn,
html[data-theme="light"] .bit-toggle-btn {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #475569 !important;
  box-shadow: none !important;
}

[data-theme="light"] .bit-toggle-btn.high,
html[data-theme="light"] .bit-toggle-btn.high {
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.2) 0%, rgba(147, 51, 234, 0.3) 100%) !important;
  border-color: #9333ea !important;
  color: #9333ea !important;
}

[data-theme="light"] .bit-box,
html[data-theme="light"] .bit-box {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
}

[data-theme="light"] .bit-box.high,
html[data-theme="light"] .bit-box.high {
  background: rgba(2, 132, 199, 0.1) !important;
  border-color: #0284c7 !important;
}

[data-theme="light"] .bit-label,
html[data-theme="light"] .bit-label {
  color: #64748b !important;
}

[data-theme="light"] .bit-val,
html[data-theme="light"] .bit-val {
  color: #0f172a !important;
}

[data-theme="light"] .bit-box.high .bit-val,
html[data-theme="light"] .bit-box.high .bit-val {
  color: #0284c7 !important;
}

[data-theme="light"] .serial-output-card,
html[data-theme="light"] .serial-output-card {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.05) 0%, rgba(255, 255, 255, 0.95) 100%) !important;
  border-color: rgba(5, 150, 105, 0.3) !important;
}

[data-theme="light"] .serial-val,
html[data-theme="light"] .serial-val {
  color: #0f172a !important;
  text-shadow: none !important;
}

[data-theme="light"] .serial-out-box.high .serial-val,
html[data-theme="light"] .serial-out-box.high .serial-val {
  color: #059669 !important;
}

[data-theme="light"] .voltage-tag.low,
html[data-theme="light"] .voltage-tag.low {
  background: #e2e8f0 !important;
  color: #475569 !important;
}

[data-theme="light"] .status-indicator-box,
html[data-theme="light"] .status-indicator-box {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
}

[data-theme="light"] .status-title,
html[data-theme="light"] .status-title {
  color: #0f172a !important;
}

[data-theme="light"] .status-sub,
html[data-theme="light"] .status-sub {
  color: #475569 !important;
}

/* Schematic Area & Footnote & SVG */
[data-theme="light"] .circuit-container,
[data-theme="light"] .svg-scroll-wrapper,
html[data-theme="light"] .circuit-container,
html[data-theme="light"] .svg-scroll-wrapper {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
}

[data-theme="light"] .schematic-footnote,
html[data-theme="light"] .schematic-footnote {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #475569 !important;
}

/* SVG Circuit Diagram Light Mode Overrides */
[data-theme="light"] #circuitSvg,
html[data-theme="light"] #circuitSvg {
  background: #ffffff !important;
}

[data-theme="light"] #circuitSvg rect,
html[data-theme="light"] #circuitSvg rect {
  fill: #ffffff;
  stroke: #cbd5e1;
}

/* Flip-Flop Boxes (FF3, FF2, FF1, FF0) */
[data-theme="light"] #circuitSvg #svgFfBox3,
[data-theme="light"] #circuitSvg #svgFfBox2,
[data-theme="light"] #circuitSvg #svgFfBox1,
html[data-theme="light"] #circuitSvg #svgFfBox3,
html[data-theme="light"] #circuitSvg #svgFfBox2,
html[data-theme="light"] #circuitSvg #svgFfBox1 {
  fill: #f8fafc !important;
  stroke: #0284c7 !important;
  stroke-width: 2 !important;
}

[data-theme="light"] #circuitSvg #svgFfBox0,
html[data-theme="light"] #circuitSvg #svgFfBox0 {
  fill: #f8fafc !important;
  stroke: #10b981 !important;
  stroke-width: 2 !important;
}

/* MUX Trapezoid Polygons */
[data-theme="light"] #circuitSvg polygon[points*="40,0"],
html[data-theme="light"] #circuitSvg polygon[points*="40,0"] {
  fill: #f5f3ff !important;
  stroke: #a855f7 !important;
  stroke-width: 2 !important;
}

/* MUX Labels & Sublabels */
[data-theme="light"] #circuitSvg text[fill="#c084fc"],
html[data-theme="light"] #circuitSvg text[fill="#c084fc"] {
  fill: #7e22ce !important;
  font-weight: 800 !important;
}

[data-theme="light"] #circuitSvg g[transform*="170"] text,
html[data-theme="light"] #circuitSvg g[transform*="170"] text {
  fill: #7e22ce !important;
}

[data-theme="light"] #circuitSvg g[transform*="170"] text[font-size="9"],
html[data-theme="light"] #circuitSvg g[transform*="170"] text[font-size="9"] {
  fill: #9333ea !important;
  font-weight: 600 !important;
}

/* Parallel Input D Pin Badges (D3, D2, D1, D0) */
[data-theme="light"] #circuitSvg g[transform*="60"] rect,
html[data-theme="light"] #circuitSvg g[transform*="60"] rect {
  fill: #f5f3ff !important;
  stroke: #a855f7 !important;
}

[data-theme="light"] #circuitSvg text[id^="svgTextD"],
html[data-theme="light"] #circuitSvg text[id^="svgTextD"] {
  fill: #7e22ce !important;
  font-weight: 700 !important;
}

/* Flip-Flop Inner State Circles */
[data-theme="light"] #circuitSvg g[transform*="200, 240"] circle,
[data-theme="light"] #circuitSvg g[transform*="420, 240"] circle,
[data-theme="light"] #circuitSvg g[transform*="640, 240"] circle,
html[data-theme="light"] #circuitSvg g[transform*="200, 240"] circle,
html[data-theme="light"] #circuitSvg g[transform*="420, 240"] circle,
html[data-theme="light"] #circuitSvg g[transform*="640, 240"] circle {
  fill: #e0f2fe !important;
  stroke: #0284c7 !important;
}

[data-theme="light"] #circuitSvg g[transform*="860, 240"] circle,
html[data-theme="light"] #circuitSvg g[transform*="860, 240"] circle {
  fill: #d1fae5 !important;
  stroke: #10b981 !important;
}

/* State Values inside Circles */
[data-theme="light"] #circuitSvg text#svgQ3Val,
[data-theme="light"] #circuitSvg text#svgQ2Val,
[data-theme="light"] #circuitSvg text#svgQ1Val,
html[data-theme="light"] #circuitSvg text#svgQ3Val,
html[data-theme="light"] #circuitSvg text#svgQ2Val,
html[data-theme="light"] #circuitSvg text#svgQ1Val {
  fill: #0369a1 !important;
  font-weight: 800 !important;
}

[data-theme="light"] #circuitSvg text#svgQ0Val,
html[data-theme="light"] #circuitSvg text#svgQ0Val {
  fill: #047857 !important;
  font-weight: 800 !important;
}

/* Flip-Flop Text Labels */
[data-theme="light"] #circuitSvg text[font-size="14"][fill="#00f0ff"],
html[data-theme="light"] #circuitSvg text[font-size="14"][fill="#00f0ff"] {
  fill: #0284c7 !important;
  font-weight: 800 !important;
}

[data-theme="light"] #circuitSvg text[font-size="14"][fill="#10b981"],
html[data-theme="light"] #circuitSvg text[font-size="14"][fill="#10b981"] {
  fill: #059669 !important;
  font-weight: 800 !important;
}

[data-theme="light"] #circuitSvg text[font-size="12"][fill="#00f0ff"],
html[data-theme="light"] #circuitSvg text[font-size="12"][fill="#00f0ff"] {
  fill: #0284c7 !important;
}

[data-theme="light"] #circuitSvg text[font-size="12"][fill="#10b981"],
html[data-theme="light"] #circuitSvg text[font-size="12"][fill="#10b981"] {
  fill: #059669 !important;
}

[data-theme="light"] #circuitSvg text[fill="#94a3b8"],
[data-theme="light"] #circuitSvg text[fill="#64748b"],
html[data-theme="light"] #circuitSvg text[fill="#94a3b8"],
html[data-theme="light"] #circuitSvg text[fill="#64748b"] {
  fill: #64748b !important;
}

/* Clock Triangle in FFs */
[data-theme="light"] #circuitSvg polygon[points*="0,85"],
html[data-theme="light"] #circuitSvg polygon[points*="0,85"] {
  fill: none !important;
  stroke: #0284c7 !important;
}

/* Serial OUT Indicator Badge */
[data-theme="light"] #circuitSvg g[transform*="975"] rect,
html[data-theme="light"] #circuitSvg g[transform*="975"] rect {
  fill: #d1fae5 !important;
  stroke: #10b981 !important;
}

[data-theme="light"] #circuitSvg g[transform*="975"] text,
html[data-theme="light"] #circuitSvg g[transform*="975"] text {
  fill: #059669 !important;
}

[data-theme="light"] #circuitSvg text#svgSerialOutVal,
html[data-theme="light"] #circuitSvg text#svgSerialOutVal {
  fill: #047857 !important;
  font-weight: 800 !important;
}

/* Top Control and Clock Lines */
[data-theme="light"] #circuitSvg text[fill="#a855f7"],
html[data-theme="light"] #circuitSvg text[fill="#a855f7"] {
  fill: #7e22ce !important;
}

[data-theme="light"] #circuitSvg text[fill="#00f0ff"],
html[data-theme="light"] #circuitSvg text[fill="#00f0ff"] {
  fill: #0284c7 !important;
}

[data-theme="light"] #circuitSvg stop,
html[data-theme="light"] #circuitSvg stop {
  stop-color: #ffffff !important;
}

/* Signal Lines, Probes & FF Hardware Monitor */
[data-theme="light"] .probe-item,
[data-theme="light"] .ff-status-card,
[data-theme="light"] .state-block,
[data-theme="light"] .operation-status-details,
html[data-theme="light"] .probe-item,
html[data-theme="light"] .ff-status-card,
html[data-theme="light"] .state-block,
html[data-theme="light"] .operation-status-details {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
}

[data-theme="light"] .probe-name,
[data-theme="light"] .ff-row,
[data-theme="light"] .op-detail-item,
html[data-theme="light"] .probe-name,
html[data-theme="light"] .ff-row,
html[data-theme="light"] .op-detail-item {
  color: #475569 !important;
}

[data-theme="light"] .ff-title,
html[data-theme="light"] .ff-title {
  color: #0284c7 !important;
}

[data-theme="light"] .ff-row strong,
[data-theme="light"] .ff-row .mono,
[data-theme="light"] .op-detail-item strong,
html[data-theme="light"] .ff-row strong,
html[data-theme="light"] .ff-row .mono,
html[data-theme="light"] .op-detail-item strong {
  color: #0f172a !important;
}

[data-theme="light"] .ff-card-head,
html[data-theme="light"] .ff-card-head {
  border-bottom-color: #cbd5e1 !important;
}

[data-theme="light"] .probe-badge.low,
[data-theme="light"] .ff-state-tag,
html[data-theme="light"] .probe-badge.low,
html[data-theme="light"] .ff-state-tag {
  background: #e2e8f0 !important;
  color: #475569 !important;
}

[data-theme="light"] .state-block-title,
html[data-theme="light"] .state-block-title {
  color: #64748b !important;
}

[data-theme="light"] .state-block-val,
html[data-theme="light"] .state-block-val {
  color: #0f172a !important;
}

[data-theme="light"] .state-block.active,
html[data-theme="light"] .state-block.active {
  background: rgba(2, 132, 199, 0.1) !important;
  border-color: #0284c7 !important;
}

[data-theme="light"] .state-arrow,
html[data-theme="light"] .state-arrow {
  color: #0284c7 !important;
}

/* History Table & Waveforms & Theory */
[data-theme="light"] .history-table th,
html[data-theme="light"] .history-table th {
  background: #f1f5f9 !important;
  color: #0284c7 !important;
  border-bottom-color: #cbd5e1 !important;
}

[data-theme="light"] .history-table td,
html[data-theme="light"] .history-table td {
  border-bottom-color: #e2e8f0 !important;
  color: #334155 !important;
}

[data-theme="light"] .timing-canvas-wrapper,
html[data-theme="light"] .timing-canvas-wrapper {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
}

[data-theme="light"] #timingSvg text,
html[data-theme="light"] #timingSvg text {
  fill: #0f172a !important;
}

[data-theme="light"] .theory-card,
html[data-theme="light"] .theory-card {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
}

[data-theme="light"] .theory-card p,
[data-theme="light"] .theory-card ul,
[data-theme="light"] .theory-card li,
html[data-theme="light"] .theory-card p,
html[data-theme="light"] .theory-card ul,
html[data-theme="light"] .theory-card li {
  color: #334155 !important;
}

[data-theme="light"] .theory-card strong,
html[data-theme="light"] .theory-card strong {
  color: #0f172a !important;
}