/* ==========================================================================
   CIRCUIT LAB — ULTRA-PREMIUM ELECTRONICS & SCHEMATICS SIMULATOR
   ATT-25 Sxemotexnika, Mikroelektronika va Sxema Quruvchi Laboratoriyasi
   ========================================================================== */

:root {
  --bg-deep: #070B12;
  --bg-canvas: #0D131F;
  --bg-card: rgba(15, 23, 42, 0.82);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --bg-glass: rgba(13, 19, 31, 0.85);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(0, 255, 135, 0.4);
  --border-focus: #00FF87;
  
  --accent: #00FF87;
  --accent-glow: rgba(0, 255, 135, 0.25);
  --cyan: #38BDF8;
  --cyan-glow: rgba(56, 189, 248, 0.25);
  --gold: #FBBF24;
  --gold-glow: rgba(251, 191, 36, 0.25);
  --danger: #EF4444;
  --danger-glow: rgba(239, 68, 68, 0.35);
  --purple: #A855F7;
  
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  
  --wire-red: #EF4444;
  --wire-black: #1E293B;
  --wire-blue: #38BDF8;
  --wire-green: #10B981;
  --wire-yellow: #FBBF24;
  
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-display: 'Oswald', sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ==========================================================================
   APP LAYOUT
   ========================================================================== */
#app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* TOP TOOLBAR */
#topBar {
  height: 56px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
}

.brand-logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #00FF87, #0284C7);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px var(--accent-glow);
}

.brand-logo-icon svg {
  width: 20px;
  height: 20px;
  stroke: #070B12;
  fill: none;
  stroke-width: 2.2;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.5px;
  font-weight: 700;
  text-transform: uppercase;
}

.brand-title span {
  color: var(--accent);
}

.brand-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  display: block;
  margin-top: -3px;
}

/* MODE TOGGLE SWITCH (Schematic <-> Breadboard) */
.mode-toggle-box {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.7);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  gap: 4px;
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.mode-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.mode-btn:hover {
  color: var(--text-primary);
}

.mode-btn.active {
  background: linear-gradient(135deg, rgba(0,255,135,0.15), rgba(56,189,248,0.15));
  color: var(--accent);
  border: 1px solid var(--border-active);
  box-shadow: 0 0 10px var(--accent-glow);
}

/* TOP ACTIONS */
.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 1;
}
.top-actions::-webkit-scrollbar { display: none; }

.btn-action {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 1280px) {
  .top-actions .btn-action span { display: none; }
  .btn-action { padding: 6px 9px; }
  .brand-subtitle { display: none; }
}

@media (max-width: 768px) {
  #topBar { padding: 0 8px; height: 50px; }
  .brand-title { font-size: 0.95rem; }
  .mode-btn { padding: 5px 8px; font-size: 0.75rem; }
}

.btn-action svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.btn-action:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--bg-card-hover);
}

.btn-action.active-pulse {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.btn-action.sim-play {
  background: rgba(0, 255, 135, 0.12);
  color: var(--accent);
  border-color: rgba(0, 255, 135, 0.35);
}

.btn-action.sim-play.running {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-action.gold-badge {
  color: var(--gold);
  border-color: rgba(251, 191, 36, 0.35);
}

/* MAIN WORKSPACE BODY (Palette + Canvas + Inspector) */
#workspace {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* LEFT PALETTE (Component Drawer) */
#palette {
  width: 260px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform 0.3s ease;
}

.palette-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.palette-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: 600;
}

.palette-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.palette-search input {
  width: 100%;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: var(--font-sans);
  outline: none;
}

.palette-search input:focus {
  border-color: var(--cyan);
}

.palette-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.palette-category {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cat-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--cyan);
  font-family: var(--font-mono);
  padding: 2px 4px;
}

.comp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  cursor: grab;
  transition: all 0.2s ease;
}

.comp-item:hover {
  border-color: var(--border-active);
  background: var(--bg-card-hover);
  transform: translateX(3px);
}

.comp-item:active {
  cursor: grabbing;
}

.comp-icon {
  width: 32px;
  height: 32px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
}

.comp-icon svg {
  width: 22px;
  height: 22px;
  stroke: var(--text-primary);
  fill: none;
  stroke-width: 1.8;
}

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

.comp-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

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

/* CENTER CANVAS WORKSPACE */
#canvasContainer {
  flex: 1;
  position: relative;
  background-color: var(--bg-canvas);
  background-image: 
    radial-gradient(rgba(255, 255, 255, 0.07) 1.2px, transparent 1.2px),
    radial-gradient(rgba(0, 255, 135, 0.03) 1.2px, transparent 1.2px);
  background-size: 24px 24px, 120px 120px;
  background-position: 0 0, 0 0;
  overflow: hidden;
  cursor: crosshair;
}

#circuitCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* FLOATING CANVAS CONTROLS (Zoom, Pan, Wire Color) */
.canvas-floating-controls {
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 4px 8px;
  gap: 8px;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.wire-color-picker {
  display: flex;
  align-items: center;
  gap: 4px;
  border-right: 1px solid var(--border-subtle);
  padding-right: 8px;
}

.color-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.color-dot:hover {
  transform: scale(1.25);
}

.color-dot.active {
  border-color: #FFF;
  box-shadow: 0 0 6px rgba(255,255,255,0.8);
}

.zoom-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.zoom-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.08);
}

.zoom-level {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 42px;
  text-align: center;
}

/* RIGHT INSPECTOR PANEL (Component Properties) */
#inspector {
  width: 280px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
}

#inspector.show {
  transform: translateX(0);
}

.inspector-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.inspector-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.btn-close-panel {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-close-panel:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.08);
}

.inspector-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.prop-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prop-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
}

.prop-label span {
  color: var(--accent);
}

.prop-input {
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  outline: none;
}

.prop-input:focus {
  border-color: var(--accent);
}

.resistor-bands-preview {
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #C4A482;
  padding: 0 10px;
  border: 1px solid rgba(0,0,0,0.3);
}

.color-band {
  width: 8px;
  height: 100%;
}

.live-metrics-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.metric-row .k {
  color: var(--text-muted);
}

.metric-row .v {
  font-weight: 700;
  color: var(--cyan);
}

/* FLOATING MULTIMETER & OSCILLOSCOPE HUD */
.instrument-window {
  position: absolute;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(0,0,0,0.6);
  z-index: 60;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.instrument-window.show {
  display: flex;
}

.instrument-header {
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: move;
}

.instrument-title {
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* MULTIMETER HUD SPECIFICS */
#dmmWindow {
  width: 240px;
  top: 70px;
  right: 20px;
}

.dmm-screen {
  background: #111D15;
  border: 2px solid #1E3A2B;
  border-radius: 6px;
  margin: 12px;
  padding: 10px;
  text-align: right;
  font-family: var(--font-mono);
}

.dmm-val {
  font-size: 1.6rem;
  font-weight: 700;
  color: #00FF87;
  letter-spacing: 1px;
}

.dmm-unit {
  font-size: 0.8rem;
  color: #38BDF8;
  margin-top: 2px;
}

.dmm-dial {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 0 12px 12px;
}

.dial-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 0;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
}

.dial-btn.active {
  background: rgba(251, 191, 36, 0.15);
  color: var(--gold);
  border-color: var(--gold);
}

/* OSCILLOSCOPE HUD */
#scopeWindow {
  width: 380px;
  height: 250px;
  bottom: 20px;
  right: 20px;
}

#scopeCanvas {
  flex: 1;
  background: #061019;
  width: 100%;
}

.scope-controls {
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* GUIDED LABS MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 18, 0.8);
  backdrop-filter: blur(12px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.show {
  display: flex;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.8);
}

.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lab-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lab-card:hover {
  border-color: var(--border-active);
  background: var(--bg-card-hover);
}

.lab-card.completed {
  border-color: rgba(0, 255, 135, 0.4);
}

.lab-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lab-badge {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
}

.lab-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.lab-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.lab-status-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.05);
}

/* TOAST NOTIFICATIONS */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-active);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 0.85rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  z-index: 300;
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* CURRENT FLOW DOTS ANIMATION (SVG or Canvas) */
@keyframes flowGlow {
  0% { opacity: 0.4; }
  50% { opacity: 1.0; filter: drop-shadow(0 0 6px #00FF87); }
  100% { opacity: 0.4; }
}

.short-circuit-warning {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(239, 68, 68, 0.95);
  color: #FFF;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 18px;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.6);
  display: none;
  align-items: center;
  gap: 8px;
  z-index: 100;
  animation: pulseWarning 0.8s infinite alternate;
}

@keyframes pulseWarning {
  0% { transform: translateX(-50%) scale(1); }
  100% { transform: translateX(-50%) scale(1.05); }
}

/* ==========================================================================
   3D BREADBOARD CONTAINER & HINTS
   ========================================================================== */
#breadboard3dContainer {
  position: absolute;
  inset: 0;
  background: #0A0F1D;
  z-index: 25;
  display: none;
}

#breadboard3dContainer.show {
  display: block;
}

.bb3d-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding: 8px 18px;
  border-radius: 20px;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  white-space: nowrap;
}

.bb3d-hint b {
  color: var(--accent);
}

/* ==========================================================================
   QUICK PRESETS DROPDOWN
   ========================================================================== */
.presets-dropdown-box {
  position: relative;
}

.presets-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  min-width: 260px;
  box-shadow: 0 16px 36px rgba(0,0,0,0.6);
  z-index: 150;
  display: none;
  flex-direction: column;
  overflow: hidden;
  padding: 4px;
}

.presets-menu.show {
  display: flex;
}

.preset-opt {
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-opt:hover {
  background: var(--bg-card-hover);
  color: var(--accent);
  transform: translateX(4px);
}

/* ==========================================================================
   ON-CANVAS QUICK ACTION BUBBLE FOR SELECTED COMPONENT
   ========================================================================== */
.quick-action-bubble {
  position: absolute;
  display: none;
  align-items: center;
  gap: 4px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-active);
  border-radius: 24px;
  padding: 4px 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  z-index: 40;
  transform: translate(-50%, -130%);
  pointer-events: auto;
}

.quick-action-bubble.show {
  display: flex;
}

.bubble-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.85rem;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.bubble-btn:hover {
  background: var(--bg-card-hover);
  transform: scale(1.15);
  border-color: var(--accent);
}

.bubble-btn.danger:hover {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.2);
}

/* ==========================================================================
   SPLIT VIEW LAYOUT (50% 2D SCHEMATIC + 50% 3D BREADBOARD)
   ========================================================================== */
#workspace.split-view-active #canvasContainer {
  flex: 1 1 50% !important;
  width: 50% !important;
  display: block !important;
  position: relative !important;
  border-right: 2px solid var(--border-active) !important;
}

#workspace.split-view-active #breadboard3dContainer {
  flex: 1 1 50% !important;
  width: 50% !important;
  display: block !important;
  position: relative !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
}

/* ==========================================================================
   TROUBLESHOOTING CHALLENGES MODAL
   ========================================================================== */
.trouble-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.trouble-card:hover {
  border-color: var(--danger);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.15);
}

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

.trouble-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.trouble-badge {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.trouble-badge.easy {
  background: rgba(0, 255, 135, 0.15);
  color: var(--accent);
  border-color: rgba(0, 255, 135, 0.35);
}

.trouble-badge.medium {
  background: rgba(251, 191, 36, 0.15);
  color: var(--gold);
  border-color: rgba(251, 191, 36, 0.35);
}

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

.trouble-action {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--cyan);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   LAB REPORT STYLES & PRINT MEDIA
   ========================================================================== */
.report-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--text-primary);
}

.report-header-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  font-size: 0.85rem;
}

.report-header-box .f-label {
  color: var(--text-muted);
  font-weight: 500;
}

.report-header-box .f-val {
  color: var(--text-primary);
  font-weight: 600;
  font-family: var(--font-mono);
}

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

.report-table th, .report-table td {
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  text-align: left;
}

.report-table th {
  background: rgba(15, 23, 42, 0.9);
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 600;
}

.report-table td {
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.report-summary-box {
  background: rgba(0, 255, 135, 0.08);
  border: 1px solid var(--border-active);
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 8px;
  font-size: 0.85rem;
  line-height: 1.5;
}

@media print {
  body * {
    visibility: hidden !important;
  }
  #reportModal, #reportModal * {
    visibility: visible !important;
  }
  #reportModal {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: auto !important;
    background: #FFF !important;
    color: #000 !important;
    padding: 0 !important;
    display: block !important;
  }
  .modal-dialog {
    background: #FFF !important;
    color: #000 !important;
    border: none !important;
    box-shadow: none !important;
    max-width: 100% !important;
  }
  .modal-head button, #btnPrintReport, #closeReportModal {
    display: none !important;
  }
  .report-header-box {
    background: #F8FAFC !important;
    border-color: #CBD5E1 !important;
    color: #000 !important;
  }
  .report-header-box .f-val {
    color: #000 !important;
  }
  .report-table th, .report-table td {
    border-color: #CBD5E1 !important;
    color: #000 !important;
  }
  .report-table th {
    background: #F1F5F9 !important;
  }
  .report-summary-box {
    background: #F0FDF4 !important;
    border-color: #86EFAC !important;
    color: #000 !important;
  }
}

/* ==========================================================================
   3D FLOATING WIRE COLOR PICKER TOOLBAR
   ========================================================================== */
.wire-color-toolbar-3d {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65), 0 0 15px rgba(56, 189, 248, 0.2);
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px;
  z-index: 50;
  pointer-events: auto;
}

.wire-color-toolbar-3d .toolbar-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #38BDF8;
}

.color-options-3d {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-dot-3d {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.color-dot-3d:hover {
  transform: scale(1.2);
}

.color-dot-3d.active {
  transform: scale(1.25);
  border-color: #FFFFFF;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
}

.hint-3d-wire {
  font-size: 0.75rem;
  color: var(--text-muted);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  padding-left: 10px;
}

/* ==========================================================================
   ARDUINO CODE EDITOR MODAL ENHANCEMENTS
   ========================================================================== */
#arduinoCodeModal .modal-dialog {
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 135, 143, 0.3);
  border: 1px solid rgba(0, 135, 143, 0.4);
}

#arduinoCodeTextarea:focus {
  border-color: #00FF87 !important;
  box-shadow: 0 0 15px rgba(0, 255, 135, 0.25) !important;
}

#arduinoSerialOutput::-webkit-scrollbar {
  width: 6px;
}
#arduinoSerialOutput::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.3);
  border-radius: 3px;
}

/* ==========================================================================
   200 READY-MADE CIRCUIT TEMPLATES MODAL & CARDS
   ========================================================================== */
.tmpl-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 7, 18, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, backdrop-filter 0.25s ease;
}

.tmpl-modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.tmpl-modal-container {
  width: 100%;
  max-width: 1240px;
  height: 90vh;
  max-height: 900px;
  background: rgba(13, 19, 31, 0.95);
  border: 1px solid rgba(0, 255, 135, 0.3);
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 35px rgba(0, 255, 135, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: tmplModalZoom 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tmplModalZoom {
  from { transform: scale(0.96) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

/* Modal Header */
.tmpl-modal-header {
  padding: 16px 24px;
  background: rgba(15, 23, 42, 0.7);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tmpl-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tmpl-modal-icon {
  font-size: 1.8rem;
  width: 44px;
  height: 44px;
  background: rgba(0, 255, 135, 0.12);
  border: 1px solid rgba(0, 255, 135, 0.3);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tmpl-modal-title {
  font-size: 1.35rem;
  font-weight: 800;
  background: linear-gradient(135deg, #F8FAFC 30%, #00FF87 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 2px;
}

.tmpl-modal-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.tmpl-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tmpl-count-badge {
  background: rgba(56, 189, 248, 0.12);
  color: #38BDF8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.tmpl-close-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.tmpl-close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--danger);
  color: #FFFFFF;
  transform: rotate(90deg);
}

/* Toolbar: Search + Difficulty Filters */
.tmpl-toolbar {
  padding: 12px 24px;
  background: rgba(10, 15, 26, 0.6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tmpl-search-box {
  flex: 1;
  min-width: 280px;
  position: relative;
  display: flex;
  align-items: center;
}

.tmpl-search-box svg {
  position: absolute;
  left: 14px;
  stroke: #38BDF8;
  fill: none;
  stroke-width: 2;
  pointer-events: none;
}

.tmpl-search-box input {
  width: 100%;
  padding: 10px 14px 10px 42px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 24px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  outline: none;
  transition: all 0.2s ease;
}

.tmpl-search-box input:focus {
  border-color: #00FF87;
  box-shadow: 0 0 15px rgba(0, 255, 135, 0.25);
  background: rgba(15, 23, 42, 1);
}

.tmpl-diff-filter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tmpl-diff-filter .filter-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.diff-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.diff-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.diff-btn.active {
  background: rgba(0, 255, 135, 0.15);
  border-color: var(--accent);
  color: #00FF87;
  box-shadow: 0 0 12px rgba(0, 255, 135, 0.2);
}

/* Category Pills Bar */
.tmpl-category-bar {
  padding: 10px 24px;
  background: rgba(15, 23, 42, 0.4);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
}

.tmpl-category-bar::-webkit-scrollbar {
  height: 4px;
}
.tmpl-category-bar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.cat-tab-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.cat-tab-btn .cat-badge {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
}

.cat-tab-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.cat-tab-btn.active {
  background: linear-gradient(135deg, rgba(0, 255, 135, 0.2), rgba(56, 189, 248, 0.2));
  border-color: #00FF87;
  color: #FFFFFF;
  box-shadow: 0 0 15px rgba(0, 255, 135, 0.2);
}

.cat-tab-btn.active .cat-badge {
  background: #00FF87;
  color: #020617;
  font-weight: 700;
}

/* Templates Grid */
.tmpl-grid-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  align-content: start;
}

.tmpl-grid-container::-webkit-scrollbar {
  width: 8px;
}
.tmpl-grid-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
.tmpl-grid-container::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.25);
  border-radius: 4px;
}
.tmpl-grid-container::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 255, 135, 0.4);
}

/* Template Card */
.tmpl-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.tmpl-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, #00FF87, #38BDF8);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tmpl-card:hover {
  transform: translateY(-3px);
  border-color: rgba(0, 255, 135, 0.4);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 255, 135, 0.12);
  background: rgba(20, 30, 52, 0.85);
}

.tmpl-card:hover::before {
  opacity: 1;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.card-num {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: #38BDF8;
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 8px;
  border-radius: 6px;
}

.card-category {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-diff {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}

.diff-easy {
  background: rgba(0, 255, 135, 0.12);
  color: #00FF87;
  border: 1px solid rgba(0, 255, 135, 0.25);
}

.diff-med {
  background: rgba(251, 191, 36, 0.12);
  color: #FBBF24;
  border: 1px solid rgba(251, 191, 36, 0.25);
}

.diff-hard {
  background: rgba(239, 68, 68, 0.12);
  color: #EF4444;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.card-title {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
}

.card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.meta-item {
  font-size: 0.74rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn-card-load {
  flex: 1;
  background: linear-gradient(135deg, #00FF87, #0284C7);
  color: #020617;
  font-weight: 700;
  font-size: 0.82rem;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-card-load svg {
  fill: #020617;
}

.btn-card-load:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 255, 135, 0.4);
  filter: brightness(1.1);
}

.btn-card-detail {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-card-detail svg {
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.btn-card-detail:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Empty State */
.tmpl-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.tmpl-empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}
.tmpl-empty-state h3 {
  font-size: 1.15rem;
  color: var(--text-primary);
  margin-bottom: 6px;
}

/* Detail / Theory Modal */
.tmpl-detail-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(16px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.tmpl-detail-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.tmpl-detail-container {
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  background: #0B111E;
  border: 1px solid rgba(0, 255, 135, 0.4);
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9), 0 0 30px rgba(0, 255, 135, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: tmplModalZoom 0.2s ease;
}

.tmpl-detail-header {
  padding: 18px 24px;
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.detail-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  display: inline-block;
  margin-bottom: 6px;
}

.detail-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
}

.tmpl-detail-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.detail-section h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #00FF87;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-section p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.detail-steps {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-steps li {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.tmpl-detail-footer {
  padding: 16px 24px;
  background: rgba(15, 23, 42, 0.8);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
}

/* ==========================================================================
   AMBIENT LIGHT (DAY/NIGHT) & LIVE CIRCUIT CONTROLS HUD
   ========================================================================== */
.ambient-light-control {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 10px rgba(56, 189, 248, 0.15);
  border-radius: 20px;
  padding: 4px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ambient-btn {
  background: transparent;
  border: none;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 12px;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ambient-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.ambient-btn.active#btnAmbientDay {
  background: rgba(251, 191, 36, 0.22);
  color: #FBBF24;
  border: 1px solid rgba(251, 191, 36, 0.4);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
}

.ambient-btn.active#btnAmbientNight {
  background: rgba(56, 189, 248, 0.22);
  color: #38BDF8;
  border: 1px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.ambient-slider {
  width: 90px;
  height: 6px;
  accent-color: #FBBF24;
  cursor: pointer;
  border-radius: 3px;
}

.ambient-val-badge {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #FBBF24;
  font-weight: 700;
  min-width: 34px;
  text-align: right;
}

/* LIVE CONTROLS HUD (FLOATING ON CANVAS) */
.live-controls-hud {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 85;
  width: 300px;
  background: rgba(13, 19, 31, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 255, 135, 0.35);
  border-radius: 14px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.75), 0 0 25px rgba(0, 255, 135, 0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: tmplModalZoom 0.2s ease;
}

.live-controls-hud.has-items {
  display: flex;
}

.hud-header {
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hud-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #00FF87;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-toggle-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: all 0.15s ease;
}

.hud-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
}

.hud-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 380px;
}

.hud-body::-webkit-scrollbar {
  width: 6px;
}
.hud-body::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.25);
  border-radius: 3px;
}

.hud-body.collapsed {
  display: none;
}

.hud-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.hud-item-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.hud-val-tag {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: #38BDF8;
  font-weight: 700;
}

.hud-status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
}

.status-on {
  background: rgba(0, 255, 135, 0.15);
  color: #00FF87;
  border: 1px solid rgba(0, 255, 135, 0.3);
}

.status-off {
  background: rgba(239, 68, 68, 0.15);
  color: #EF4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.hud-action-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.hud-action-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.hud-action-btn.btn-active {
  background: rgba(0, 255, 135, 0.2);
  border-color: #00FF87;
  color: #00FF87;
  box-shadow: 0 0 10px rgba(0, 255, 135, 0.2);
}

.hud-slider {
  width: 100%;
  height: 6px;
  accent-color: #00FF87;
  cursor: pointer;
  border-radius: 3px;
}

.hud-ambient-box {
  background: rgba(251, 191, 36, 0.06);
  border-color: rgba(251, 191, 36, 0.25);
}

.hud-ambient-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.hud-btn-day, .hud-btn-night {
  flex: 1;
  padding: 5px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.hud-btn-day:hover, .hud-btn-night:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.hud-btn-day.active {
  background: rgba(251, 191, 36, 0.25);
  color: #FBBF24;
  border-color: #FBBF24;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.3);
}

.hud-btn-night.active {
  background: rgba(56, 189, 248, 0.25);
  color: #38BDF8;
  border-color: #38BDF8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.hud-meter-bar {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.hud-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #00FF87, #FBBF24, #EF4444);
  width: 0%;
  transition: width 0.15s ease;
}

/* =========================================================================
   ANALYSIS WINDOW STYLES — Bode / DC Sweep / Transient
   ========================================================================= */
#analysisWindow {
  overflow-y: auto;
}

.analysis-tabs {
  display: flex;
  gap: 2px;
  background: rgba(2, 6, 23, 0.6);
  padding: 6px 8px 0;
  border-bottom: 1px solid rgba(56, 189, 248, 0.12);
}

.analysis-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #64748B;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: 'Plus Jakarta Sans', sans-serif;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 6px 6px 0 0;
}

.analysis-tab:hover {
  color: #94A3B8;
  background: rgba(56, 189, 248, 0.05);
}

.analysis-tab.active {
  color: #38BDF8;
  border-bottom-color: #38BDF8;
  background: rgba(56, 189, 248, 0.08);
}

.analysis-pane {
  padding: 10px 10px 6px;
}

.analysis-pane.hidden {
  display: none;
}

.analysis-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: rgba(2, 6, 23, 0.4);
  border-radius: 8px;
  margin-bottom: 10px;
  border: 1px solid rgba(56, 189, 248, 0.08);
}

.analysis-controls label {
  font-size: 0.72rem;
  color: #64748B;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'JetBrains Mono', monospace;
}

.analysis-input {
  background: rgba(2, 6, 23, 0.8);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 6px;
  color: #F8FAFC;
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  padding: 4px 6px;
  width: 90px;
  transition: border-color 0.2s;
}

.analysis-input:focus {
  outline: none;
  border-color: #38BDF8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

.analysis-canvas {
  display: block;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.12);
  width: 100%;
  max-width: 100%;
}

.analysis-result {
  font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
  color: #64748B;
  padding: 6px 4px 2px;
  border-top: 1px solid rgba(56, 189, 248, 0.08);
  margin-top: 6px;
}

/* =========================================================================
   FUNCTION GENERATOR PANEL STYLES
   ========================================================================= */
.fg-panel {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.fg-title {
  font-size: 0.7rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: #38BDF8;
  display: flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.05em;
}

.fg-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.fg-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #00FF87;
}

.fg-toggle-label {
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  color: #64748B;
  cursor: pointer;
}

.fg-display {
  background: #060E1A;
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 8px;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  padding: 8px 14px 6px;
  gap: 6px;
}

.fg-display-val {
  font-size: 1.8rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: #00FF87;
  text-shadow: 0 0 8px rgba(0, 255, 135, 0.5);
  letter-spacing: -1px;
}

.fg-display-unit {
  font-size: 0.9rem;
  font-family: 'JetBrains Mono', monospace;
  color: #64748B;
}

.fg-waveform-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.fg-wave-btn {
  background: rgba(2, 6, 23, 0.7);
  border: 1px solid rgba(56, 189, 248, 0.15);
  border-radius: 8px;
  color: #64748B;
  font-size: 1.2rem;
  width: 50px;
  height: 38px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: sans-serif;
}

.fg-wave-btn:hover {
  border-color: rgba(56, 189, 248, 0.4);
  color: #94A3B8;
}

.fg-wave-btn.active {
  background: rgba(0, 255, 135, 0.1);
  border-color: #00FF87;
  color: #00FF87;
  box-shadow: 0 0 8px rgba(0, 255, 135, 0.2);
}

.fg-params {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fg-param-row {
  display: grid;
  grid-template-columns: 100px 1fr 72px;
  align-items: center;
  gap: 8px;
}

.fg-param-row label {
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  color: #64748B;
}

.fg-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(56, 189, 248, 0.2);
  border-radius: 2px;
  cursor: pointer;
}

.fg-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #00FF87;
  box-shadow: 0 0 6px rgba(0, 255, 135, 0.5);
  cursor: pointer;
}

.fg-num-input {
  background: rgba(2, 6, 23, 0.8);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 6px;
  color: #F8FAFC;
  font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
  padding: 4px 6px;
  width: 100%;
  text-align: right;
}

.fg-num-input:focus {
  outline: none;
  border-color: #00FF87;
}

.fg-preview {
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.12);
  background: #060E1A;
  width: 100%;
  display: block;
}

.fg-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  font-family: 'JetBrains Mono', monospace;
  color: #475569;
  padding: 4px 2px 2px;
  border-top: 1px solid rgba(56, 189, 248, 0.08);
}

/* Close button for instrument windows */
.inst-close-btn {
  background: transparent;
  border: none;
  color: #64748B;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
  line-height: 1;
}

.inst-close-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #EF4444;
}

/* Utility */
.hidden {
  display: none !important;
}

/* ATT-25 Animated Crest */
@keyframes attLogoSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes attCorePulse { 0%, 100% { transform: scale(1); filter: drop-shadow(0 0 4px #00FF87); } 50% { transform: scale(1.18); filter: drop-shadow(0 0 10px #00F0FF); } }
@keyframes attPhotonFlow { 0% { stroke-dashoffset: 24; } 100% { stroke-dashoffset: 0; } }
.att-animated-logo .logo-radar-ring { transform-origin: 32px 36px; animation: attLogoSpin 12s linear infinite; }
.att-animated-logo .logo-core-pulse { transform-origin: 32px 35.5px; animation: attCorePulse 2.4s ease-in-out infinite; }
.att-animated-logo .logo-photon-track { stroke-dasharray: 4 6; animation: attPhotonFlow 1.8s linear infinite; }



