/* assets/css/lab.css - MicroLab Virtual Electronics Laboratory Workspace */

/* Lock Full Viewport on Virtual Lab & Lesson Workspaces */
html:has(.lab-container),
body:has(.lab-container),
body.page-lab,
body.page-lab-fullscreen {
  height: 100vh !important;
  max-height: 100vh !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  padding-bottom: 0 !important;
}

body:has(.lab-container) footer,
body.page-lab footer,
body.page-lab-fullscreen footer,
body:has(.lab-container) .mobile-bottom-nav,
body.page-lab .mobile-bottom-nav,
body.page-lab-fullscreen .mobile-bottom-nav {
  display: none !important;
}

.navbar {
  position: sticky !important;
  top: 0 !important;
  z-index: 1000 !important;
  flex-shrink: 0 !important;
}

.lab-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 65px);
  max-height: calc(100vh - 65px);
  overflow: hidden;
  background-color: #060911;
  flex: 1;
}

/* Lab Top Toolbar (Sticky Header) */
.lab-toolbar {
  position: sticky !important;
  top: 0 !important;
  z-index: 500 !important;
  flex-shrink: 0 !important;
  height: 52px !important;
  min-height: 52px !important;
  background: #090e1a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.lab-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 1;
  min-width: 0;
}

.project-title-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 1;
  min-width: 0;
}

.project-title-input {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.32rem 1.6rem 0.32rem 0.6rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  max-width: 170px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-title-input:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.18);
}

.project-title-input:focus {
  background: rgba(15, 23, 42, 0.95);
  border-color: #38bdf8;
  outline: none;
  max-width: 240px;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.project-title-edit-hint {
  position: absolute;
  right: 6px;
  pointer-events: none;
  font-size: 0.7rem;
  opacity: 0.45;
}

.board-badge-select {
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.28);
  color: #38bdf8;
  padding: 0.32rem 0.65rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.board-badge-select:hover, .board-badge-select:focus {
  background: rgba(6, 182, 212, 0.2);
  border-color: #38bdf8;
  outline: none;
}

/* Simulation Controls (Center) */
.lab-toolbar-center {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  justify-content: center;
}

.sim-btn-group {
  display: flex;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.sim-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 0.32rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.18s ease;
}

.sim-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.sim-btn-run {
  color: #34d399;
}

.sim-btn-run.active {
  background: #059669 !important;
  color: #ffffff !important;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.6);
}

.sim-btn-pause.active {
  background: #d97706 !important;
  color: #ffffff !important;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.6);
}

.sim-btn-stop.active {
  background: #e11d48 !important;
  color: #ffffff !important;
  box-shadow: 0 0 14px rgba(244, 63, 94, 0.6);
}

.sim-btn-reset:hover {
  color: #38bdf8;
}

.speed-select {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  padding: 0.32rem 0.55rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

/* Wire Color Picker */
.wire-color-picker {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(15, 23, 42, 0.85);
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.wire-picker-label {
  font-size: 0.7rem;
  color: #64748b;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-right: 1px;
}

.wire-dots-container {
  display: flex;
  align-items: center;
  gap: 4px;
}

.color-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  cursor: pointer;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  flex-shrink: 0;
}

.color-dot:hover {
  transform: scale(1.35);
  border-color: #ffffff;
}

.color-dot.active {
  transform: scale(1.4);
  border-color: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

.color-custom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  margin-left: 2px;
  background: rgba(255, 255, 255, 0.06);
  transition: all 0.15s ease;
}

.color-custom-btn input[type="color"] {
  display: none;
}

.color-custom-icon {
  font-size: 0.75rem;
  line-height: 1;
}

.color-custom-btn:hover {
  transform: scale(1.2);
  background: rgba(255, 255, 255, 0.15);
}

/* Toolbar Right & Action Buttons */
.lab-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
  margin-left: auto;
}

.toolbar-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(30, 41, 59, 0.7);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 0.32rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
}

.toolbar-action-btn:hover {
  background: rgba(51, 65, 85, 0.9);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.toolbar-btn-iot {
  background: rgba(6, 182, 212, 0.12);
  border-color: rgba(6, 182, 212, 0.28);
  color: #22d3ee;
}

.toolbar-btn-iot:hover {
  background: rgba(6, 182, 212, 0.25);
  color: #67e8f9;
  border-color: #22d3ee;
}

.toolbar-btn-group {
  display: inline-flex;
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.toolbar-btn-group .toolbar-action-btn {
  background: transparent;
  border: none;
  padding: 0.22rem 0.5rem;
  border-radius: 4px;
}

.toolbar-btn-group .toolbar-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* Dedicated Save & Auto-save Area */
.toolbar-save-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.autosave-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #94a3b8;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  user-select: none;
  transition: all 0.25s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.autosave-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #64748b;
  display: inline-block;
  flex-shrink: 0;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.autosave-status.saved {
  color: #a7f3d0;
  background: rgba(6, 78, 59, 0.35);
  border-color: rgba(16, 185, 129, 0.3);
}

.autosave-status.saved .autosave-dot {
  background-color: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
}

.autosave-status.dirty {
  color: #fde68a;
  background: rgba(120, 53, 15, 0.35);
  border-color: rgba(245, 158, 11, 0.3);
}

.autosave-status.dirty .autosave-dot {
  background-color: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.8);
}

.autosave-status.saving {
  color: #bae6fd;
  background: rgba(12, 74, 110, 0.35);
  border-color: rgba(56, 189, 248, 0.3);
}

.autosave-status.saving .autosave-dot {
  background-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.9);
  animation: autosave-pulse 0.7s infinite alternate;
}

.autosave-status.error {
  color: #fecdd3;
  background: rgba(136, 19, 55, 0.35);
  border-color: rgba(244, 63, 94, 0.3);
}

.autosave-status.error .autosave-dot {
  background-color: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}

@keyframes autosave-pulse {
  from {
    transform: scale(0.85);
    opacity: 0.6;
  }
  to {
    transform: scale(1.3);
    opacity: 1;
  }
}

.toolbar-btn-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  color: #ffffff !important;
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 6px;
  padding: 0.35rem 0.95rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0 !important;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.4);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.toolbar-btn-save:hover {
  background: linear-gradient(135deg, #0ea5e9 0%, #1d4ed8 100%);
  box-shadow: 0 0 16px rgba(14, 165, 233, 0.65);
  transform: translateY(-1px);
}

.toolbar-btn-save:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(14, 165, 233, 0.3);
}

.toolbar-btn-save:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* Workspace Layout */
.lab-workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Left Palette */
.palette-sidebar {
  width: 240px;
  background: #090e1a;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.palette-search {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.palette-categories {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.category-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.palette-item {
  background: rgba(18, 27, 47, 0.6);
  border: 1px solid rgba(56, 189, 248, 0.12);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: grab;
  user-select: none;
  transition: all 0.2s;
  text-align: center;
  position: relative;
}

.palette-item.is-pro-component {
  border-color: rgba(255, 90, 0, 0.25);
}

.palette-item .palette-pro-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  background: linear-gradient(135deg, #ff5a00, #ff8a00);
  color: #ffffff;
  font-size: 0.55rem;
  font-weight: 900;
  padding: 1px 4px;
  border-radius: 4px;
  line-height: 1;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.palette-item:hover {
  background: rgba(30, 45, 78, 0.8);
  border-color: var(--cyan-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-cyan);
}

.palette-item svg {
  width: 28px;
  height: 28px;
}

.palette-item-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Center Circuit Canvas */
.circuit-viewport {
  flex: 1;
  position: relative;
  background-color: #070b14;
  background-image: 
    radial-gradient(circle, rgba(56, 189, 248, 0.12) 1px, transparent 1px);
  background-size: 20px 20px;
  overflow: hidden;
  cursor: default;
}

.circuit-canvas-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 5000px;
  height: 5000px;
  transform-origin: 0 0;
}

/* Component Visuals in SVG / DOM */
.circuit-component {
  position: absolute;
  cursor: move;
  user-select: none;
  transition: filter 0.2s;
}

.circuit-component.selected {
  outline: 2px dashed var(--cyan-accent);
  outline-offset: 4px;
}

/* Pin Ports & Magnetic Snap System */
.component-pin-group {
  cursor: crosshair;
  transition: transform 0.12s ease;
}

.component-pin-group .pin-hitbox {
  cursor: crosshair;
}

.component-pin-group .pin-collar {
  transition: fill 0.15s ease, stroke 0.15s ease, r 0.15s ease;
}

.component-pin-group .pin-core {
  transition: fill 0.15s ease, stroke 0.15s ease, r 0.15s ease, filter 0.15s ease;
}

.component-pin-group:hover .pin-core,
.component-pin-group.snap-highlight .pin-core {
  fill: #38bdf8;
  stroke: #ffffff;
  r: 5.5px;
  filter: drop-shadow(0 0 6px #38bdf8);
}

.component-pin-group:hover .pin-collar,
.component-pin-group.snap-highlight .pin-collar {
  stroke: #38bdf8;
  fill: rgba(56, 189, 248, 0.25);
  r: 7.5px;
}

/* Magnetic Snap Animations */
@keyframes snapPulse {
  0% {
    r: 8px;
    opacity: 1;
    stroke-width: 3px;
  }
  50% {
    r: 20px;
    opacity: 0.75;
    stroke-width: 2px;
  }
  100% {
    r: 28px;
    opacity: 0;
    stroke-width: 1px;
  }
}

.snap-pulse-ring {
  animation: snapPulse 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
  transform-origin: center;
}

.snap-target-dot {
  animation: snapGlow 1.2s ease-in-out infinite alternate;
}

@keyframes snapGlow {
  from {
    filter: drop-shadow(0 0 4px #38bdf8);
    stroke-width: 2px;
  }
  to {
    filter: drop-shadow(0 0 12px #38bdf8) drop-shadow(0 0 20px #0284c7);
    stroke-width: 3px;
  }
}

/* Wire Paths */
.wire-path {
  fill: none;
  stroke-width: 3.5px;
  stroke-linecap: round;
  stroke-linejoin: round;
  cursor: pointer;
  filter: drop-shadow(0 0 3px rgba(0,0,0,0.5));
  transition: stroke-width 0.15s;
}

.wire-path:hover {
  stroke-width: 6px;
  filter: drop-shadow(0 0 6px currentColor);
}

.wire-path.selected {
  stroke-width: 5.5px;
  stroke-dasharray: 6 3;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 8px #ffffff);
  animation: dash 1s linear infinite;
}

.wire-path.wire-drawing-temp {
  stroke-width: 3.5px;
  stroke-dasharray: 6 4;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 6px currentColor);
  animation: dash 0.6s linear infinite;
}

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

/* Wire Hitbox for easy dragging and bend creation */
.wire-hitbox {
  fill: none;
  stroke: transparent;
  stroke-width: 16px;
  stroke-linecap: round;
  stroke-linejoin: round;
  cursor: grab;
}

.wire-hitbox:active {
  cursor: grabbing;
}

/* Wire Waypoint Handles (Fritzing Bend Points) */
.wire-waypoint-handle {
  cursor: move;
  fill: #ffffff;
  stroke: #0284c7;
  stroke-width: 2.5px;
  transition: r 0.15s ease, stroke-width 0.15s ease, filter 0.15s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.wire-waypoint-handle:hover {
  r: 6.5px;
  fill: #38bdf8;
  stroke: #ffffff;
  stroke-width: 3px;
  filter: drop-shadow(0 0 8px #38bdf8);
}

.wire-waypoint-handle.dragging {
  cursor: grabbing;
  r: 7px;
  fill: #f59e0b;
  stroke: #ffffff;
  stroke-width: 3px;
  filter: drop-shadow(0 0 10px #f59e0b);
}

/* Canvas Floating Tools (Zoom / Pan / Center) */
.canvas-float-tools {
  position: absolute;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 0 15px rgba(59, 130, 246, 0.15);
  z-index: 30;
  user-select: none;
}

.canvas-zoom-btn {
  height: 30px;
  min-width: 30px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  color: #94a3b8;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.canvas-zoom-btn:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(59, 130, 246, 0.5);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.canvas-zoom-btn:active {
  transform: translateY(0);
}

.canvas-zoom-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
  background: rgba(30, 41, 59, 0.4);
  border-color: rgba(255, 255, 255, 0.04);
  color: #64748b;
  transform: none !important;
  box-shadow: none !important;
}

.canvas-tool-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0 3px;
}

.canvas-zoom-btn.btn-zoom-val {
  min-width: 54px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: #38bdf8;
  background: rgba(15, 23, 42, 0.6);
}

.canvas-zoom-btn.btn-zoom-val:hover {
  background: rgba(56, 189, 248, 0.15);
  color: #fff;
}

/* Resizable Divider between Canvas and Right Panel */
.workspace-resizer {
  width: 6px;
  background: rgba(15, 23, 42, 0.9);
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  border-right: 1px solid var(--border-color);
  cursor: col-resize;
  position: relative;
  z-index: 30;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.workspace-resizer::after {
  content: '';
  width: 2px;
  height: 24px;
  border-radius: 2px;
  background: rgba(148, 163, 184, 0.4);
  transition: background 0.2s, height 0.2s;
}

.workspace-resizer:hover, .workspace-resizer.is-dragging {
  background: var(--cyan-accent);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.6);
}

.workspace-resizer:hover::after, .workspace-resizer.is-dragging::after {
  background: #ffffff;
  height: 38px;
}

/* Right Tabbed Panel (Code Editor & Inspector) */
.right-sidebar {
  width: 480px;
  min-width: 320px;
  max-width: 85vw;
  background: #090e1a;
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 20;
  position: relative;
  flex-shrink: 0;
}

.right-tabs {
  display: flex;
  background: #0b1120;
  border-bottom: 1px solid var(--border-color);
}

.right-tab-btn {
  flex: 1;
  padding: 0.65rem 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s;
}

.right-tab-btn.active {
  color: #fff;
  border-bottom-color: var(--cyan-accent);
  background: rgba(6, 182, 212, 0.05);
}

.right-tab-content {
  flex: 1 1 0%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Code Editor */
.code-editor-wrapper {
  flex: 1 1 0%;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.code-editor-toolbar {
  padding: 0.4rem 0.75rem;
  background: #0d1527;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 5;
}

.code-textarea {
  flex: 1;
  width: 100%;
  background: #1e1e1e;
  color: #e2e8f0;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace;
  font-size: 13.5px;
  line-height: 22px;
  padding: 12px 16px 200px 16px;
  border: none;
  resize: none;
  outline: none;
  tab-size: 2;
  -moz-tab-size: 2;
  white-space: pre;
  word-wrap: normal;
  overflow-x: auto;
  letter-spacing: 0px;
}

.code-textarea:focus {
  outline: none;
}

/* Arduino IDE Code Editor Component & Live Syntax Highlight */
#ide-modal-editor-wrapper {
  display: flex !important;
  flex: 1 1 auto !important;
  height: 480px !important;
  min-height: 380px !important;
  max-height: calc(88vh - 220px) !important;
  background: #1e1e1e !important;
  overflow: hidden !important;
  position: relative !important;
}

.arduino-editor-container {
  display: flex !important;
  flex-direction: row !important;
  flex: 1 1 0% !important;
  position: relative !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  background: #1e1e1e !important;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace !important;
  font-size: 13.5px !important;
  line-height: 22px !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
  align-items: stretch !important;
}

.arduino-gutter {
  width: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  height: 100% !important;
  min-height: 100% !important;
  background: #161616 !important;
  border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
  color: #52525b !important;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace !important;
  font-size: 12px !important;
  line-height: 22px !important;
  padding: 12px 6px 200px 0 !important;
  text-align: right !important;
  user-select: none !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  box-sizing: border-box !important;
  flex-shrink: 0 !important;
}

.arduino-gutter .gutter-line-number {
  height: 22px !important;
  min-height: 22px !important;
  max-height: 22px !important;
  line-height: 22px !important;
  font-size: 12px !important;
  color: #52525b !important;
  display: block !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  padding: 0 !important;
}

.arduino-editor-viewport {
  position: relative !important;
  flex: 1 1 auto !important;
  width: calc(100% - 48px) !important;
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
  background: #1e1e1e !important;
  align-self: stretch !important;
}

.arduino-highlight-layer {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 12px 16px 200px 16px !important;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace !important;
  font-size: 13.5px !important;
  line-height: 22px !important;
  letter-spacing: 0px !important;
  white-space: pre !important;
  word-wrap: normal !important;
  overflow: hidden !important;
  pointer-events: none !important;
  box-sizing: border-box !important;
  tab-size: 2 !important;
  -moz-tab-size: 2 !important;
  z-index: 1 !important;
  background: transparent !important;
  background-color: transparent !important;
  color: #e2e8f0 !important;
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.arduino-code-highlight {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  min-height: 100% !important;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace !important;
  font-size: 13.5px !important;
  line-height: 22px !important;
  letter-spacing: 0px !important;
  white-space: inherit !important;
  background: transparent !important;
  color: #e2e8f0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.arduino-input-textarea,
.arduino-input-textarea:focus,
.arduino-input-textarea:hover,
.arduino-input-textarea:active,
#code-editor-textarea.arduino-input-textarea,
#ide-modal-textarea.arduino-input-textarea,
#code-editor-textarea.arduino-input-textarea:focus,
#ide-modal-textarea.arduino-input-textarea:focus {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 12px 16px 200px 16px !important;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace !important;
  font-size: 13.5px !important;
  line-height: 22px !important;
  letter-spacing: 0px !important;
  white-space: pre !important;
  word-wrap: normal !important;
  overflow: auto !important;
  box-sizing: border-box !important;
  tab-size: 2 !important;
  -moz-tab-size: 2 !important;
  z-index: 2 !important;
  background: transparent !important;
  background-color: transparent !important;
  color: transparent !important;
  -webkit-text-fill-color: transparent !important;
  caret-color: #38bdf8 !important;
  border: none !important;
  outline: none !important;
  resize: none !important;
  box-shadow: none !important;
}

.arduino-input-textarea::selection,
#code-editor-textarea.arduino-input-textarea::selection,
#ide-modal-textarea.arduino-input-textarea::selection {
  background: rgba(56, 189, 248, 0.3) !important;
  color: transparent !important;
  -webkit-text-fill-color: transparent !important;
}

/* Arduino IDE 2.0 Syntax Highlight Colors */
.ard-tok-function {
  color: #d35400 !important; /* Iconic Arduino Orange */
  font-weight: 600;
}

.ard-tok-object {
  color: #00979c !important; /* Arduino Teal */
  font-weight: 600;
}

.ard-tok-constant {
  color: #00979c !important; /* Arduino Cyan / Constant Teal */
  font-weight: 600;
}

.ard-tok-keyword {
  color: #4ec9b0 !important; /* Dark Teal / Keyword */
  font-weight: 500;
}

.ard-tok-preprocessor {
  color: #c586c0 !important; /* Preprocessor purple */
  font-weight: 500;
}

.ard-tok-string {
  color: #7ee787 !important; /* String green */
}

.ard-tok-number {
  color: #b48ead !important; /* Number purple */
}

.ard-tok-comment {
  color: #718096 !important; /* Comment muted gray/green */
  font-style: italic;
}

.ard-tok-symbol {
  color: #94a3b8 !important;
}

.ard-tok-ident {
  color: #e2e8f0 !important;
}

/* IntelliSense Autocomplete Floating Popup */
.arduino-autocomplete-popup {
  position: fixed;
  z-index: 999999;
  width: 360px;
  max-height: 260px;
  background: #181818;
  border: 1px solid #00979c;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.9), 0 0 20px rgba(0, 151, 156, 0.35);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
  backdrop-filter: blur(12px);
  user-select: none;
}

.arduino-autocomplete-item {
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.arduino-autocomplete-item:last-child {
  border-bottom: none;
}

.arduino-autocomplete-item:hover,
.arduino-autocomplete-item.selected {
  background: #005f63 !important;
  color: #ffffff !important;
}

.arduino-autocomplete-item .item-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.arduino-autocomplete-item .type-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.arduino-autocomplete-item .type-badge.badge-fn {
  background: #d35400;
  color: #fff;
}

.arduino-autocomplete-item .type-badge.badge-type {
  background: #00979c;
  color: #fff;
}

.arduino-autocomplete-item .type-badge.badge-const {
  background: #0891b2;
  color: #fff;
}

.arduino-autocomplete-item .type-badge.badge-kw {
  background: #2563eb;
  color: #fff;
}

.arduino-autocomplete-item .type-badge.badge-prep {
  background: #7c3aed;
  color: #fff;
}

.arduino-autocomplete-item .item-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #f1f5f9;
}

.arduino-autocomplete-item .item-label .match-highlight {
  color: #38bdf8;
  text-decoration: underline;
  font-weight: 800;
}

.arduino-autocomplete-item .item-detail {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-left: auto;
  font-style: italic;
}

.arduino-autocomplete-item .item-doc {
  font-size: 0.7rem;
  color: #cbd5e1;
  padding-left: 28px;
  line-height: 1.3;
  opacity: 0.85;
}

/* Property Inspector */
.property-inspector {
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.inspector-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

/* Diagnostics & Warning Alert */
.diagnostics-box {
  margin-top: auto;
  padding: 0.65rem 0.85rem;
  background: rgba(245, 158, 11, 0.1);
  border-top: 1px solid rgba(245, 158, 11, 0.3);
  font-size: 0.8rem;
  color: #fbbf24;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Resizable Divider between Workspace Canvas and Bottom Serial Monitor */
.serial-monitor-resizer {
  height: 6px;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid var(--border-color);
  cursor: row-resize;
  position: relative;
  z-index: 28;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.serial-monitor-resizer::after {
  content: '';
  width: 42px;
  height: 2px;
  border-radius: 2px;
  background: rgba(148, 163, 184, 0.45);
  transition: background 0.2s, width 0.2s;
}

.serial-monitor-resizer:hover, .serial-monitor-resizer.is-dragging {
  background: var(--cyan-accent);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.6);
}

.serial-monitor-resizer:hover::after, .serial-monitor-resizer.is-dragging::after {
  background: #ffffff;
  width: 64px;
}

/* Bottom Serial Monitor */
.serial-monitor-panel {
  height: 160px;
  min-height: 40px;
  max-height: 85vh;
  background: #050811;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 25;
  transition: height 0.2s ease;
  position: relative;
}

.serial-monitor-panel.is-resizing {
  transition: none !important;
}

.serial-monitor-panel.collapsed {
  height: 34px !important;
  min-height: 34px !important;
  overflow: hidden;
}

.serial-header {
  padding: 0.35rem 0.85rem;
  background: #090e1a;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.serial-logs {
  flex: 1;
  padding: 0.75rem 1rem;
  overflow-y: auto;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace;
  font-size: 0.85rem;
  color: #34d399;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.serial-log-line {
  display: flex !important;
  flex-direction: row !important;
  align-items: baseline !important;
  gap: 8px;
  word-break: break-all;
  white-space: pre-wrap;
  min-height: 1.45em;
  line-height: 1.55;
}

.serial-log-line .serial-timestamp {
  color: #64748b !important;
  font-size: 0.78rem !important;
  font-weight: 500 !important;
  font-variant-numeric: tabular-nums !important;
  user-select: none !important;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
}

.serial-log-line .serial-content {
  flex: 1 1 auto !important;
  word-break: break-all;
  white-space: pre-wrap;
  color: inherit;
}

.serial-log-line.log-input {
  color: #38bdf8 !important;
}

.serial-log-line.log-input .serial-content {
  color: #38bdf8 !important;
  font-weight: 600;
}

.serial-input-bar {
  padding: 0.35rem 0.75rem;
  background: #090e1a;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  gap: 0.5rem;
}

/* Custom Context Menu */
.microlab-context-menu {
  position: fixed;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 0 15px rgba(56, 189, 248, 0.15);
  border-radius: 8px;
  padding: 6px;
  min-width: 210px;
  font-family: var(--font-sans);
  font-size: 0.825rem;
  color: #e2e8f0;
  user-select: none;
  animation: contextMenuPop 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes contextMenuPop {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.context-menu-header {
  padding: 6px 10px 4px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--cyan-accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 4px;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.context-menu-item:hover {
  background: rgba(56, 189, 248, 0.18);
  color: #fff;
}

.context-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.context-menu-item .item-icon {
  font-size: 1rem;
  width: 18px;
  text-align: center;
}

.context-menu-item .item-badge {
  margin-left: auto;
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  font-weight: 600;
}

.context-menu-separator {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 4px 0;
}

/* Floating Quick Sensor HUD Overlay */
.microlab-quick-hud {
  position: absolute;
  z-index: 50;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 16px rgba(56, 189, 248, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 220px;
  max-width: 280px;
  color: #fff;
  font-size: 0.8rem;
  pointer-events: auto;
  transform: translate(-50%, -115%);
  transition: opacity 0.2s ease, transform 0.2s ease;
  animation: hudFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes hudFadeIn {
  from { opacity: 0; transform: translate(-50%, -105%) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, -115%) scale(1); }
}

.microlab-quick-hud::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: rgba(15, 23, 42, 0.95) transparent transparent;
}

.hud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.hud-title {
  font-weight: 700;
  color: var(--cyan-accent);
  display: flex;
  align-items: center;
  gap: 5px;
}

.hud-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 4px;
  border-radius: 4px;
}
.hud-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.hud-control-group {
  margin-bottom: 8px;
}

.hud-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.hud-value-badge {
  color: #38bdf8;
  font-weight: 700;
  font-family: var(--font-mono);
}

.hud-slider {
  width: 100%;
  accent-color: #06b6d4;
  height: 5px;
  cursor: pointer;
}

.hud-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.75rem;
}

.random-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(168, 85, 247, 0.25);
  border: 1px solid rgba(168, 85, 247, 0.5);
  color: #d8b4fe;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 5px rgba(168, 85, 247, 0.3); }
  50% { box-shadow: 0 0 12px rgba(168, 85, 247, 0.7); }
}

/* Large Serial Monitor Popup Styles */
.serial-preview-btn {
  background: rgba(59, 130, 246, 0.15) !important;
  color: #60a5fa !important;
  border-color: rgba(59, 130, 246, 0.3) !important;
  transition: all 0.2s ease;
}

.serial-preview-btn:hover {
  background: rgba(59, 130, 246, 0.3) !important;
  color: #fff !important;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

.serial-modal-dialog {
  animation: modalPopIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPopIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

#modal-serial-logs {
  scrollbar-width: thin;
  scrollbar-color: rgba(59, 130, 246, 0.4) #030712;
}

#modal-serial-logs::-webkit-scrollbar {
  width: 8px;
}

#modal-serial-logs::-webkit-scrollbar-track {
  background: #030712;
}

#modal-serial-logs::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.3);
  border-radius: 4px;
}

#modal-serial-logs::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 130, 246, 0.6);
}

.modal-log-line {
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.modal-log-line:hover {
  background: rgba(255, 255, 255, 0.04);
}

.modal-log-line.log-input {
  color: #38bdf8;
  font-weight: 600;
}

/* Arduino IDE Modal Styles */
.arduino-ide-modal-dialog {
  animation: modalPopIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.ide-action-btn {
  height: 28px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 151, 156, 0.3);
  border: 1px solid rgba(0, 151, 156, 0.6);
  border-radius: var(--radius-sm);
  color: #e0f2fe;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.ide-action-btn:hover {
  background: #00979d;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(0, 151, 156, 0.5);
  transform: translateY(-1px);
}

.ide-action-btn:active {
  transform: translateY(0);
}

.ide-action-btn.ide-upload-btn {
  background: rgba(245, 158, 11, 0.3);
  border-color: rgba(245, 158, 11, 0.6);
  color: #fef3c7;
}

.ide-action-btn.ide-upload-btn:hover {
  background: #f59e0b;
  color: #111827;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.6);
}

.ide-code-area::-webkit-scrollbar,
.ide-gutter::-webkit-scrollbar,
#ide-console-output::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.ide-code-area::-webkit-scrollbar-track,
#ide-console-output::-webkit-scrollbar-track {
  background: #181818;
}

.ide-code-area::-webkit-scrollbar-thumb,
#ide-console-output::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.ide-code-area::-webkit-scrollbar-thumb:hover,
#ide-console-output::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Web Serial Device Manager Modal Styles */
.webserial-modal-dialog {
  animation: modalPopIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.device-paired-item:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: rgba(56, 189, 248, 0.3) !important;
}

#device-paired-list::-webkit-scrollbar {
  width: 6px;
}

#device-paired-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

#device-paired-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* Component Wiring & Code Guide Panel Styles */
.guide-pane {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #080d19;
  width: 100%;
  box-sizing: border-box;
}

.guide-content-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.guide-pane::-webkit-scrollbar {
  width: 6px;
}

.guide-pane::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

.guide-pane::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.guide-card-header {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  box-shadow: 0 4px 15px -2px rgba(0, 0, 0, 0.3);
}

.guide-board-switcher {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.35);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.guide-board-chip {
  flex: 1;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  border: none;
  background: transparent;
  color: #94a3b8;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.guide-board-chip:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.guide-board-chip.active {
  color: #fff;
  background: #0284c7;
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.4);
}

.guide-board-chip.active.chip-uno {
  background: #0d9488;
  box-shadow: 0 0 10px rgba(13, 148, 136, 0.4);
}

.guide-board-chip.active.chip-esp32 {
  background: #e11d48;
  box-shadow: 0 0 10px rgba(225, 29, 72, 0.4);
}

.guide-board-chip.active.chip-esp8266 {
  background: #d97706;
  box-shadow: 0 0 10px rgba(217, 119, 6, 0.4);
}

.guide-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
}

.guide-wiring-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.guide-wiring-table th {
  background: rgba(30, 41, 59, 0.6);
  color: #94a3b8;
  padding: 0.45rem 0.65rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.72rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.guide-wiring-table td {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #e2e8f0;
  vertical-align: middle;
}

.guide-wiring-table tr:last-child td {
  border-bottom: none;
}

.guide-wiring-table tr:hover td {
  background: rgba(56, 189, 248, 0.04);
}

.guide-tips-box {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font-size: 0.76rem;
  color: #fde68a;
  line-height: 1.45;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.guide-code-box {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #050811;
  display: flex;
  flex-direction: column;
}

.guide-code-toolbar {
  padding: 0.45rem 0.85rem;
  background: #0d1527;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.guide-code-pre {
  margin: 0;
  padding: 0.85rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.5;
  color: #38bdf8;
  overflow: auto;
  max-height: 480px;
  background: #03060d;
}

.guide-code-pre::-webkit-scrollbar {
  height: 5px;
  width: 5px;
}

.guide-code-pre::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.guide-empty-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.guide-empty-item {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  color: #cbd5e1;
  font-size: 0.78rem;
  font-weight: 500;
}

.guide-empty-item:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: #38bdf8;
  color: #fff;
  transform: translateY(-1px);
}

/* Light Theme Workspace Styling for Lab Simulator */
[data-theme="light"] .lab-container {
  background-color: #e2e8f0;
}

[data-theme="light"] .lab-toolbar {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .project-title-input {
  color: #0f172a;
  font-weight: 700;
}

[data-theme="light"] .project-title-input:hover,
[data-theme="light"] .project-title-input:focus {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

[data-theme="light"] .board-badge-select {
  background: #f0f9ff;
  border-color: #bae6fd;
  color: #0284c7;
}

[data-theme="light"] .sim-btn-group,
[data-theme="light"] .speed-select,
[data-theme="light"] .wire-color-picker {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .sim-btn {
  color: #475569;
}

[data-theme="light"] .sim-btn:hover {
  color: #0f172a;
  background: #e2e8f0;
}

[data-theme="light"] .sim-btn-run {
  color: #059669;
}

[data-theme="light"] .sim-btn-run:hover {
  background: #ecfdf5;
  color: #047857;
}

[data-theme="light"] .sim-btn-run.active {
  background: #d1fae5;
  color: #065f46;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

[data-theme="light"] .sim-btn-pause {
  color: #d97706;
}

[data-theme="light"] .sim-btn-pause.active {
  background: #fef3c7;
  color: #92400e;
}

[data-theme="light"] .sim-btn-stop {
  color: #e11d48;
}

[data-theme="light"] .sim-btn-stop.active {
  background: #ffe4e6;
  color: #9f1239;
}

/* Palette Sidebar */
[data-theme="light"] .palette-sidebar {
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
  box-shadow: 1px 0 3px rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .palette-search {
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

[data-theme="light"] .palette-search input {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
}

[data-theme="light"] .category-title {
  color: #64748b;
  font-weight: 700;
}

[data-theme="light"] .palette-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .palette-item:hover {
  background: #f0f9ff;
  border-color: #38bdf8;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.16);
  transform: translateY(-2px);
}

[data-theme="light"] .palette-item-name {
  color: #334155;
}

/* Technical Circuit Workbench Canvas (CAD / EDA Matte Light Canvas) */
[data-theme="light"] .circuit-viewport {
  background-color: #e8ecf2;
  background-image: 
    radial-gradient(circle, rgba(71, 85, 105, 0.32) 1.2px, transparent 1.2px);
  background-size: 20px 20px;
}

[data-theme="light"] .canvas-float-tools {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #cbd5e1;
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .canvas-zoom-btn {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #475569;
}

[data-theme="light"] .canvas-zoom-btn:hover {
  background: #f0f9ff;
  border-color: #0284c7;
  color: #0284c7;
  box-shadow: 0 0 8px rgba(2, 132, 199, 0.2);
}

[data-theme="light"] .canvas-zoom-btn.btn-zoom-val {
  background: #ffffff;
  color: #0284c7;
  border-color: #bae6fd;
}

[data-theme="light"] .workspace-resizer {
  background: #cbd5e1;
  border-left: 1px solid #cbd5e1;
  border-right: 1px solid #cbd5e1;
}

[data-theme="light"] .workspace-resizer::after {
  background: #64748b;
}

[data-theme="light"] .workspace-resizer:hover,
[data-theme="light"] .workspace-resizer.is-dragging {
  background: #0284c7;
}

/* Right Sidebar & Editor */
[data-theme="light"] .right-sidebar {
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  box-shadow: -1px 0 3px rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .right-tabs {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

[data-theme="light"] .right-tab-btn {
  color: #64748b;
}

[data-theme="light"] .right-tab-btn:hover {
  color: #0f172a;
}

[data-theme="light"] .right-tab-btn.active {
  color: #0284c7;
  background: #ffffff;
  border-bottom: 2px solid #0284c7;
}

[data-theme="light"] .code-editor-toolbar {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

[data-theme="light"] .code-textarea {
  background: #ffffff;
  color: #0f172a;
}

[data-theme="light"] .code-textarea:focus {
  background: #ffffff;
}

/* Property Inspector */
[data-theme="light"] .property-inspector {
  background: #ffffff;
}

[data-theme="light"] .property-inspector .form-label {
  color: #475569;
}

[data-theme="light"] .diagnostics-box {
  background: #fffbeb;
  border-top: 1px solid #fde68a;
  color: #b45309;
}

/* Serial Monitor */
[data-theme="light"] .serial-monitor-resizer {
  background: #e2e8f0;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  border-bottom: 1px solid #cbd5e1;
}

[data-theme="light"] .serial-monitor-resizer::after {
  background: #94a3b8;
}

[data-theme="light"] .serial-monitor-resizer:hover,
[data-theme="light"] .serial-monitor-resizer.is-dragging {
  background: #0ea5e9;
  box-shadow: 0 0 12px rgba(14, 165, 233, 0.5);
}

[data-theme="light"] .serial-monitor-resizer:hover::after,
[data-theme="light"] .serial-monitor-resizer.is-dragging::after {
  background: #ffffff;
}

[data-theme="light"] .serial-monitor-panel {
  background: #0f172a;
  border-top: 1px solid #334155;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .serial-header {
  background: #1e293b;
  border-bottom: 1px solid #334155;
  color: #f8fafc;
}

[data-theme="light"] .serial-input-bar {
  background: #1e293b;
  border-top: 1px solid #334155;
}

[data-theme="light"] .serial-input-bar input {
  background: #0f172a;
  border: 1px solid #334155;
  color: #f8fafc;
}

/* Context Menu & Quick HUD */
[data-theme="light"] .microlab-context-menu {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .context-menu-header {
  color: #0284c7;
  border-bottom-color: #e2e8f0;
}

[data-theme="light"] .context-menu-item:hover {
  background: #f0f9ff;
  color: #0284c7;
}

[data-theme="light"] .context-menu-separator {
  background: #e2e8f0;
}

[data-theme="light"] .microlab-quick-hud {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .microlab-quick-hud .hud-title {
  color: #0f172a;
}

[data-theme="light"] .microlab-quick-hud .hud-close-btn {
  color: #64748b;
}

[data-theme="light"] .hud-value-badge {
  background: #f0f9ff;
  color: #0284c7;
  border: 1px solid #bae6fd;
}

/* Guide Section */
[data-theme="light"] .guide-card-header {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

[data-theme="light"] .guide-card-header h3 {
  color: #0f172a !important;
}

[data-theme="light"] .guide-board-chip {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
}

[data-theme="light"] .guide-board-chip.active {
  background: #f0f9ff;
  border-color: #0284c7;
  color: #0284c7;
}

[data-theme="light"] .guide-wiring-table {
  border: 1px solid #e2e8f0;
}

[data-theme="light"] .guide-wiring-table th {
  background: #f8fafc;
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
}

[data-theme="light"] .guide-wiring-table td {
  border-bottom: 1px solid #f1f5f9;
  color: #0f172a;
}

[data-theme="light"] .guide-wiring-table td:first-child {
  color: #0f172a !important;
}

[data-theme="light"] .guide-tips-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

[data-theme="light"] .guide-code-box {
  border: 1px solid #cbd5e1;
}

[data-theme="light"] .guide-code-toolbar {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

[data-theme="light"] .guide-code-pre {
  background: #0f172a;
  color: #38bdf8;
}

[data-theme="light"] .guide-empty-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #1e293b;
}

[data-theme="light"] .guide-empty-item:hover {
  background: #f0f9ff;
  border-color: #0284c7;
  color: #0284c7;
}

[data-theme="light"] .guide-empty-item span {
  color: #1e293b;
}

/* --- Interactive Rotational Animations for DC Motor & Fan --- */
@keyframes microlab-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes microlab-spin-reverse {
  from {
    transform: rotate(360deg);
  }
  to {
    transform: rotate(0deg);
  }
}

.dcmotor-rotor-spinning,
.dcmotor-rotor-spinning-cw {
  transform-origin: 45px 40px;
  animation: microlab-spin 0.22s linear infinite;
}

.dcmotor-rotor-spinning-ccw {
  transform-origin: 45px 40px;
  animation: microlab-spin-reverse 0.22s linear infinite;
}

.fan-rotor-spinning {
  transform-origin: 42.5px 40px;
  animation: microlab-spin 0.18s linear infinite;
}

/* --- Auto-Save Toolbar Status Indicator --- */
.autosave-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.73rem;
  font-weight: 500;
  color: #94a3b8;
  padding: 3px 8px;
  border-radius: var(--radius-sm, 6px);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  user-select: none;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.autosave-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #64748b;
  display: inline-block;
  flex-shrink: 0;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.autosave-status.saved .autosave-dot {
  background-color: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.autosave-status.dirty .autosave-dot {
  background-color: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}

.autosave-status.saving .autosave-dot {
  background-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.8);
  animation: autosave-pulse 0.8s infinite alternate;
}

.autosave-status.error .autosave-dot {
  background-color: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

@keyframes autosave-pulse {
  from {
    transform: scale(0.85);
    opacity: 0.6;
  }
  to {
    transform: scale(1.3);
    opacity: 1;
  }
}

[data-theme="light"] .autosave-status {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #64748b;
}

/* =========================================================
   COMPONENTS UPWARD BURNING FLAME & SMOKE VISUALS
   ========================================================= */

.comp-blown-overlay {
  pointer-events: none;
}

.comp-ember-pulsing {
  animation: emberPulse 1.1s ease-in-out infinite alternate;
}

@keyframes emberPulse {
  0% {
    opacity: 0.5;
  }
  100% {
    opacity: 0.9;
  }
}

.flame-lick-outer {
  transform-origin: 0px 2px;
  animation: flameFlickerOuter 0.32s ease-in-out infinite;
}

.flame-lick-inner {
  transform-origin: 0px 2px;
  animation: flameFlickerInner 0.22s ease-in-out infinite;
}

@keyframes flameFlickerOuter {
  0% {
    transform: scaleY(0.9) scaleX(0.95) rotate(-1deg);
    opacity: 0.88;
  }
  25% {
    transform: scaleY(1.14) scaleX(1.05) rotate(2deg);
    opacity: 0.98;
  }
  50% {
    transform: scaleY(0.86) scaleX(0.92) rotate(-2deg);
    opacity: 0.82;
  }
  75% {
    transform: scaleY(1.2) scaleX(1.06) rotate(1.5deg);
    opacity: 1;
  }
  100% {
    transform: scaleY(0.9) scaleX(0.95) rotate(-1deg);
    opacity: 0.88;
  }
}

@keyframes flameFlickerInner {
  0% {
    transform: scaleY(0.85) scaleX(0.9) rotate(1deg);
    opacity: 0.9;
  }
  50% {
    transform: scaleY(1.22) scaleX(1.08) rotate(-2deg);
    opacity: 1;
  }
  100% {
    transform: scaleY(0.85) scaleX(0.9) rotate(1deg);
    opacity: 0.9;
  }
}

/* Centered Screen Explosion Information Modal Dialog */
.explosion-toast-container {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 7, 18, 0.65);
  backdrop-filter: blur(5px);
  padding: 1.5rem;
  pointer-events: auto;
  animation: modalBackdropFadeIn 0.25s ease;
  box-sizing: border-box;
}

.explosion-toast-container.toast-fade-out {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

@keyframes modalBackdropFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.explosion-toast-banner {
  background: linear-gradient(145deg, #220e0e 0%, #0f172a 100%);
  border: 1.5px solid #ef4444;
  border-radius: var(--radius-lg, 12px);
  padding: 1.25rem 1.45rem;
  color: #f8fafc;
  box-shadow: 0 24px 55px -6px rgba(0, 0, 0, 0.75), 0 0 35px rgba(239, 68, 68, 0.45);
  max-width: 520px;
  width: 100%;
  animation: centerModalPopIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-sizing: border-box;
}

@keyframes centerModalPopIn {
  from {
    opacity: 0;
    transform: scale(0.88) translateY(24px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.explosion-toast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(239, 68, 68, 0.3);
  padding-bottom: 8px;
}

.explosion-toast-icon {
  font-size: 1.6rem;
  animation: bounce 1s infinite;
}

.explosion-toast-title {
  flex: 1;
  font-size: 1rem;
  font-weight: 800;
  color: #fca5a5;
  letter-spacing: 0.01em;
}

.explosion-toast-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.explosion-toast-close:hover {
  color: #ffffff;
  background: rgba(239, 68, 68, 0.3);
}

.explosion-toast-body {
  font-size: 0.84rem;
  line-height: 1.55;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.explosion-toast-reason {
  margin: 0;
  color: #fecaca;
}

.explosion-toast-solution {
  margin: 0;
  color: #86efac;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 8px;
  padding: 8px 12px;
  line-height: 1.5;
}

.explosion-toast-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.explosion-toast-dismiss-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.explosion-toast-dismiss-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.explosion-toast-repair-btn {
  background: #059669;
  border: 1px solid #10b981;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.35);
}

.explosion-toast-repair-btn:hover {
  background: #10b981;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.6);
  transform: translateY(-1px);
}

/* Light theme support */
[data-theme="light"] .explosion-toast-container {
  background: rgba(15, 23, 42, 0.45);
}

[data-theme="light"] .explosion-toast-banner {
  background: linear-gradient(145deg, #ffffff 0%, #fef2f2 100%);
  border-color: #f87171;
  color: #0f172a;
  box-shadow: 0 24px 50px rgba(220, 38, 38, 0.2), 0 4px 16px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .explosion-toast-title {
  color: #dc2626;
}

[data-theme="light"] .explosion-toast-reason {
  color: #991b1b;
}

[data-theme="light"] .explosion-toast-solution {
  color: #15803d;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

[data-theme="light"] .explosion-toast-dismiss-btn {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #475569;
}

[data-theme="light"] .explosion-toast-dismiss-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* =========================================================
   COMPONENTS UNDERVOLTAGE / LOW POWER SAD CRYING VISUALS
   ========================================================= */

.comp-underpower-overlay {
  pointer-events: none;
}

.comp-sad-pulse {
  animation: sadPulseGlow 1.4s ease-in-out infinite alternate;
}

@keyframes sadPulseGlow {
  0% {
    stroke-opacity: 0.45;
    fill-opacity: 0.06;
  }
  100% {
    stroke-opacity: 0.95;
    fill-opacity: 0.22;
  }
}

.comp-sad-tear {
  animation: sadTearFall 1.2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.comp-sad-tear-right {
  animation-delay: 0.45s;
}

@keyframes sadTearFall {
  0% {
    transform: translateY(0) scale(0.7);
    opacity: 0;
  }
  30% {
    opacity: 0.95;
    transform: translateY(2px) scale(1);
  }
  85% {
    opacity: 0.8;
    transform: translateY(9px) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translateY(13px) scale(0.85);
  }
}

/* Centered Screen Underpower / Low Voltage Toast Modal Dialog */
.underpower-toast-container {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 7, 18, 0.65);
  backdrop-filter: blur(5px);
  padding: 1.5rem;
  pointer-events: auto;
  animation: modalBackdropFadeIn 0.25s ease;
  box-sizing: border-box;
}

.underpower-toast-banner {
  background: linear-gradient(145deg, #0c2340 0%, #0f172a 100%);
  border: 1.5px solid #0284c7;
  border-radius: var(--radius-lg, 12px);
  padding: 1.25rem 1.45rem;
  color: #f8fafc;
  box-shadow: 0 24px 55px -6px rgba(0, 0, 0, 0.75), 0 0 35px rgba(2, 132, 199, 0.4);
  max-width: 520px;
  width: 100%;
  animation: centerModalPopIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-sizing: border-box;
}

.underpower-toast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(2, 132, 199, 0.3);
  padding-bottom: 8px;
}

.underpower-toast-icon {
  font-size: 1.6rem;
  animation: bounce 1.4s infinite;
}

.underpower-toast-title {
  flex: 1;
  font-size: 1rem;
  font-weight: 800;
  color: #7dd3fc;
  letter-spacing: 0.01em;
}

.underpower-toast-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.underpower-toast-close:hover {
  color: #ffffff;
  background: rgba(2, 132, 199, 0.3);
}

.underpower-toast-body {
  font-size: 0.84rem;
  line-height: 1.55;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.underpower-voltage-compare {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 8px;
  padding: 8px 12px;
}

.voltage-badge-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.voltage-badge-item .v-label {
  font-size: 0.72rem;
  color: #94a3b8;
}

.voltage-badge-item.voltage-received .v-val {
  color: #f87171;
  font-weight: 800;
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.voltage-badge-item.voltage-required .v-val {
  color: #4ade80;
  font-weight: 800;
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.v-arrow {
  color: #38bdf8;
  font-size: 1.1rem;
  font-weight: bold;
}

.underpower-toast-reason {
  margin: 0;
  color: #bae6fd;
}

.underpower-toast-solution {
  margin: 0;
  color: #fef08a;
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: 8px;
  padding: 8px 12px;
  line-height: 1.5;
}

.underpower-toast-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.underpower-toast-dismiss-btn {
  background: #0284c7;
  border: 1px solid #38bdf8;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 12px rgba(2, 132, 199, 0.35);
}

.underpower-toast-dismiss-btn:hover {
  background: #0369a1;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.5);
  transform: translateY(-1px);
}

/* Light theme support */
[data-theme="light"] .underpower-toast-container {
  background: rgba(15, 23, 42, 0.45);
}

[data-theme="light"] .underpower-toast-banner {
  background: linear-gradient(145deg, #ffffff 0%, #f0f9ff 100%);
  border-color: #38bdf8;
  color: #0f172a;
  box-shadow: 0 24px 50px rgba(2, 132, 199, 0.2), 0 4px 16px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .underpower-toast-title {
  color: #0284c7;
}

[data-theme="light"] .underpower-toast-reason {
  color: #0369a1;
}

[data-theme="light"] .underpower-toast-solution {
  color: #854d0e;
  background: #fefce8;
  border-color: #fef08a;
}

/* =========================================================
   ARDUINO LIBRARY MANAGER MODAL & CARD STYLING
   ========================================================= */

.lib-manager-dialog {
  max-width: 980px;
  width: 95%;
  max-height: 90vh;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0f172a;
  border: 1px solid rgba(52, 211, 153, 0.35);
  box-shadow: 0 25px 70px -10px rgba(0, 0, 0, 0.9), 0 0 35px rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-lg, 12px);
}

.lib-manager-header {
  padding: 0.85rem 1.25rem;
  background: #0b1329;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lib-manager-header .lib-title {
  font-size: 1rem;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lib-manager-header .lib-subtitle {
  font-size: 0.74rem;
  color: #94a3b8;
  margin-top: 2px;
}

.lib-nav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #070d19;
  padding: 0 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.lib-nav-tab {
  padding: 0.65rem 1.1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #94a3b8;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.lib-nav-tab:hover {
  color: #e2e8f0;
}

.lib-nav-tab.active {
  color: #34d399;
  border-bottom-color: #34d399;
}

.lib-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

.lib-panel.active {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Search Bar & Categories */
.lib-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.6);
  padding: 0.9rem;
  border-radius: var(--radius-md, 8px);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.lib-search-box {
  position: relative;
  width: 100%;
}

.lib-search-box input {
  width: 100%;
  background: #030712;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  padding: 0.55rem 1rem 0.55rem 2.4rem;
  border-radius: var(--radius-sm, 6px);
  font-size: 0.84rem;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.lib-search-box input:focus {
  border-color: #34d399;
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.2);
}

.lib-search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  font-size: 0.85rem;
}

.lib-cat-pills-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.lib-cat-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.lib-cat-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.lib-cat-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.lib-cat-pill.active {
  background: #059669;
  border-color: #10b981;
  color: #fff;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.lib-count-badge {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 600;
}

/* Library Cards Grid */
.lib-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 1rem;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.lib-card {
  background: #131d31;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md, 8px);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  transition: all 0.2s ease;
  position: relative;
}

.lib-card:hover {
  border-color: rgba(52, 211, 153, 0.4);
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
}

.lib-card.is-included {
  border-color: rgba(16, 185, 129, 0.5);
  background: linear-gradient(145deg, #13242e 0%, #131d31 100%);
}

.lib-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.lib-card-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.lib-card-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #f8fafc;
}

.lib-version-badge {
  font-size: 0.68rem;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-weight: 600;
}

.lib-cat-badge {
  font-size: 0.68rem;
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.lib-card-author {
  font-size: 0.72rem;
  color: #64748b;
  white-space: nowrap;
}

.lib-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.lib-card-desc {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #cbd5e1;
}

.lib-card-headers {
  font-size: 0.72rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.lib-header-label {
  font-weight: 600;
  color: #64748b;
}

.lib-header-tag {
  background: rgba(0, 0, 0, 0.35);
  color: #34d399;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.lib-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.lib-card-actions .btn {
  padding: 4px 10px;
  font-size: 0.74rem;
  font-weight: 600;
}

.lib-empty-state, .lib-loading-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.lib-empty-state i, .lib-loading-state i {
  font-size: 2.2rem;
  color: #64748b;
}

/* Upload Dropzone */
.lib-dropzone {
  border: 2px dashed rgba(52, 211, 153, 0.4);
  border-radius: var(--radius-lg, 12px);
  padding: 3rem 2rem;
  text-align: center;
  background: rgba(15, 23, 42, 0.5);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lib-dropzone:hover, .lib-dropzone.drag-active {
  border-color: #34d399;
  background: rgba(52, 211, 153, 0.08);
  transform: scale(1.01);
}

.lib-dropzone-text {
  color: #e2e8f0;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Source Code Viewer */
.lib-source-box {
  background: #030712;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.lib-source-header {
  padding: 0.6rem 1rem;
  background: #0b1329;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lib-source-header .source-title {
  color: #34d399;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.lib-source-header .source-file {
  color: #94a3b8;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.lib-source-pre {
  margin: 0;
  padding: 1rem 1.25rem;
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
  font-size: 0.8rem;
  line-height: 1.55;
  color: #38bdf8;
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* DexMicro Global Toasts */
.dex-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10005;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.dex-toast {
  pointer-events: auto;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md, 8px);
  padding: 0.75rem 1rem;
  color: #fff;
  font-size: 0.82rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 420px;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.3s, transform 0.3s;
}

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

.dex-toast.fade-out {
  opacity: 0;
  transform: translateY(-10px);
}

.dex-toast-success {
  border-color: #10b981;
  background: linear-gradient(135deg, #064e3b 0%, #0f172a 100%);
}

.dex-toast-info {
  border-color: #38bdf8;
  background: linear-gradient(135deg, #0c4a6e 0%, #0f172a 100%);
}

.dex-toast-danger {
  border-color: #ef4444;
  background: linear-gradient(135deg, #7f1d1d 0%, #0f172a 100%);
}

.dex-toast-content {
  flex: 1;
  line-height: 1.4;
}

.dex-toast-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.dex-toast-close:hover {
  color: #fff;
}

/* =========================================================
   KEYBOARD SHORTCUTS & CONTEXT MENU STYLING
   ========================================================= */

.microlab-context-menu .item-shortcut {
  margin-left: auto;
  font-size: 0.68rem;
  font-family: var(--font-mono, monospace);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.shortcuts-dialog {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0f172a;
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 25px 70px -10px rgba(0, 0, 0, 0.9), 0 0 35px rgba(56, 189, 248, 0.2);
  border-radius: var(--radius-lg, 12px);
}

.shortcuts-modal-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.shortcut-category-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md, 8px);
  padding: 0.85rem 1rem;
}

.shortcut-category-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.shortcut-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  transition: background 0.15s;
}

.shortcut-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.shortcut-desc {
  font-size: 0.8rem;
  color: #cbd5e1;
}

.shortcut-keys {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: #94a3b8;
}

.shortcut-keys kbd {
  display: inline-block;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  line-height: 1.2;
  color: #38bdf8;
  background: #070d19;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-bottom: 2px solid rgba(56, 189, 248, 0.6);
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* --- Responsive Toolbar Adaptations --- */
@media (max-width: 1280px) {
  .project-title-input {
    max-width: 130px;
  }
  .wire-dots-container .color-dot:nth-child(n+8) {
    display: none;
  }
}

@media (max-width: 1024px) {
  .lab-toolbar {
    padding: 0 0.5rem;
    gap: 0.4rem;
  }
  .wire-color-picker {
    padding: 2px 5px;
  }
  .wire-picker-label {
    display: none;
  }
  .toolbar-action-btn span:not(.btn-icon) {
    display: none;
  }
  .toolbar-btn-group .toolbar-action-btn span {
    display: inline;
  }
}

/* --- TFT Touch Screen & Stylus Pen Cursor Styles --- */
.tft-touch-surface,
[data-touch-surface="true"],
.circuit-component[data-type="tft_touch_xpt2046"] .tft-glass-layer {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32' fill='none'%3E%3Cpath d='M4 28l5-1.5L25 10.5a3 3 0 00-4.24-4.24L4.76 22.26 4 28z' fill='%2338bdf8' stroke='%230369a1' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M19 8l4 4' stroke='%23ffffff' stroke-width='1.5' stroke-linecap='round'/%3E%3Cpath d='M7 25l3 1' stroke='%230284c7' stroke-width='1'/%3E%3Ccircle cx='4' cy='28' r='2' fill='%23ef4444' stroke='%23ffffff' stroke-width='1'/%3E%3C/svg%3E") 4 28, crosshair !important;
}

.tft-touch-surface:hover {
  filter: brightness(1.04);
}

