/* ==========================================================================
   Excamar Circuit & Breadboard Studio (Wokwi & Tinkercad Style)
   - Real-time Microcontroller Simulation (Arduino Uno / ESP32)
   - 50+ Photorealistic Wokwi SVG Elements & Full-Size Breadboard MB-102
   - Pin-to-Pin Interactive Wiring with Auto Curved Bezier Wire Routing
   - Live C++ Code Editor, Serial Monitor & Logic Waveform Scope
   - One-Click Export PNG + Netlist for Client Presentation
   ========================================================================== */

#excamar-circuit-btn {
  position: fixed;
  bottom: 242px;
  right: 20px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4), 0 2px 6px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}
#excamar-circuit-btn:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.6), 0 4px 10px rgba(0, 0, 0, 0.25);
  border-color: #6ee7b7;
}
#excamar-circuit-btn:active { transform: scale(0.96) translateY(0); }
#excamar-circuit-btn svg { width: 22px; height: 22px; }

#excamar-circuit-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 15, 29, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 99999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color: #f8fafc;
  user-select: none;
}
#excamar-circuit-overlay.open { display: flex; }

.circuit-header {
  height: 52px;
  background: #0f172a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.circuit-header-left { display: flex; align-items: center; gap: 12px; }
.circuit-brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.2px;
  color: #34d399;
}
.circuit-brand-badge svg { width: 20px; height: 20px; }
.circuit-sub-badge {
  font-size: 11px;
  font-weight: 500;
  background: rgba(52, 211, 153, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.3);
  padding: 2px 8px;
  border-radius: 999px;
}
.circuit-header-center { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.circuit-header-right { display: flex; align-items: center; gap: 10px; }

.circuit-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  background: #1e293b;
  color: #e2e8f0;
}
.circuit-btn:hover { background: #334155; border-color: rgba(255, 255, 255, 0.15); }
.circuit-btn.primary { background: #059669; color: #ffffff; border-color: #10b981; }
.circuit-btn.primary:hover { background: #10b981; }
.circuit-btn.danger { background: #dc2626; color: #ffffff; border-color: #ef4444; }
.circuit-btn.sim-running {
  background: #dc2626 !important;
  color: #ffffff !important;
  border-color: #ef4444 !important;
  animation: pulse-sim 1.5s infinite;
}
@keyframes pulse-sim {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.circuit-btn.active { background: #3b82f6; color: #ffffff; border-color: #60a5fa; }
.circuit-btn.close-btn { background: transparent; border: none; font-size: 20px; color: #94a3b8; padding: 4px 8px; }
.circuit-btn.close-btn:hover { color: #ef4444; background: rgba(239, 68, 68, 0.1); }

.wire-color-picker {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #1e293b;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11px;
  color: #94a3b8;
}
.wire-color-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s, border-color 0.1s;
}
.wire-color-swatch:hover { transform: scale(1.2); }
.wire-color-swatch.active { border-color: #ffffff; transform: scale(1.15); box-shadow: 0 0 6px currentColor; }

.circuit-body { display: flex; flex: 1; overflow: hidden; position: relative; }

.circuit-sidebar-left {
  width: 320px;
  max-width: 90vw;
  background: #0f172a;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
  overflow: hidden;
}
.circuit-search-bar { padding: 10px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); flex-shrink: 0; }
.circuit-search-input {
  width: 100%;
  padding: 8px 12px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #f8fafc;
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
}
.circuit-search-input:focus { border-color: #34d399; }
.circuit-category-tabs {
  display: flex;
  padding: 6px 8px;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.circuit-category-tabs::-webkit-scrollbar { height: 4px; }
.circuit-category-tabs::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }
.circuit-cat-tab {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 4px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
  flex-shrink: 0;
}
.circuit-cat-tab:hover { color: #e2e8f0; background: rgba(255,255,255,0.03); }
.circuit-cat-tab.active {
  background: #1e293b;
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.4);
  font-weight: 600;
}
.circuit-component-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
}
.circuit-item-card {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: grab;
  transition: all 0.15s ease;
  position: relative;
}
.circuit-item-card:hover {
  background: #334155;
  border-color: #34d399;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.circuit-item-card:active { cursor: grabbing; }
.circuit-item-card .item-preview {
  width: 100%;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  overflow: hidden;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 6px;
  padding: 4px;
}
.circuit-item-card .item-preview svg,
.circuit-item-card .item-preview > * {
  max-width: 90%;
  max-height: 56px;
  object-fit: contain;
}
.circuit-item-card .item-preview wokwi-arduino-uno,
.circuit-item-card .item-preview wokwi-arduino-mega,
.circuit-item-card .item-preview wokwi-arduino-nano,
.circuit-item-card .item-preview wokwi-esp32-devkit-v1,
.circuit-item-card .item-preview wokwi-nano-rp2040-connect,
.circuit-item-card .item-preview wokwi-breadboard,
.circuit-item-card .item-preview wokwi-lcd1602,
.circuit-item-card .item-preview wokwi-lcd2004,
.circuit-item-card .item-preview wokwi-ssd1306,
.circuit-item-card .item-preview wokwi-hc-sr04,
.circuit-item-card .item-preview wokwi-servo,
.circuit-item-card .item-preview wokwi-membrane-keypad {
  max-width: 85px !important;
  max-height: 54px !important;
  transform: scale(0.42);
  transform-origin: center center;
}
.circuit-item-card .item-name {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  color: #e2e8f0;
  line-height: 1.25;
}

/* Inspector panel (bottom of left sidebar) */
.circuit-inspector {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: #0b1220;
  max-height: 260px;
  overflow-y: auto;
  padding: 10px 12px;
  flex-shrink: 0;
  padding-bottom: 80px;
}
.circuit-inspector h4 { margin: 0 0 8px 0; font-size: 12px; color: #34d399; }
.circuit-inspector .insp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  color: #cbd5e1;
}
.circuit-inspector .insp-row input,
.circuit-inspector .insp-row select {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 12px;
  width: 120px;
  outline: none;
}
.circuit-inspector .insp-hint { font-size: 11px; color: #64748b; margin-top: 4px; }

.circuit-viewport {
  flex: 1;
  background-color: #0b1120;
  background-image: radial-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 24px 24px;
  position: relative;
  overflow: hidden;
  cursor: default;
}
.circuit-svg-wire-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}
.circuit-svg-wire-layer path {
  pointer-events: stroke;
  cursor: pointer;
  transition: stroke-width 0.15s;
}
.circuit-svg-wire-layer path:hover {
  stroke-width: 5px !important;
  stroke: #f59e0b !important;
}
.circuit-canvas-workspace {
  position: absolute;
  top: 0;
  left: 0;
  width: 5000px;
  height: 5000px;
  transform-origin: 0 0;
}

.placed-component {
  position: absolute;
  cursor: move;
  border: 1px dashed transparent;
  border-radius: 4px;
  user-select: none;
  touch-action: none;
  z-index: 2;
  transition: border-color 0.15s;
}
.placed-component:hover { border-color: rgba(52, 211, 153, 0.4); }
.placed-component.selected {
  border-color: #34d399 !important;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.3);
}
.placed-component .comp-visual { position: relative; pointer-events: none; }
.placed-component .comp-visual > * { display: block; }

.pin-hotspot {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.85);
  border: 1px solid #ffffff;
  transform: translate(-50%, -50%);
  cursor: crosshair;
  z-index: 15;
  transition: transform 0.1s, background 0.1s;
}
.pin-hotspot:hover { transform: translate(-50%, -50%) scale(1.6); background: #f59e0b; }
.pin-hotspot.connected { background: #10b981; }
.pin-hotspot.pending { background: #f59e0b; animation: pulse-sim 1s infinite; }
.pin-label {
  position: absolute;
  font-size: 8.5px;
  font-family: monospace;
  color: #fbbf24;
  background: rgba(0, 0, 0, 0.65);
  padding: 0 3px;
  border-radius: 3px;
  transform: translate(-50%, -130%);
  white-space: nowrap;
  pointer-events: none;
  z-index: 16;
}

.circuit-sidebar-right {
  width: 420px;
  background: #0f172a;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}
.circuit-sidebar-right.collapsed { width: 0; overflow: hidden; border-left: none; }
.circuit-code-header {
  height: 40px;
  background: #1e293b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}
.circuit-code-title { font-size: 12px; font-weight: 700; color: #94a3b8; display: flex; align-items: center; gap: 6px; }
.circuit-code-textarea {
  flex: 1;
  background: #0a0f1d;
  color: #38bdf8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  padding: 12px;
  border: none;
  outline: none;
  resize: none;
  box-sizing: border-box;
  min-height: 200px;
}

.circuit-terminal-panel {
  height: 190px;
  background: #050811;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.circuit-terminal-tabs { display: flex; background: #0f172a; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.circuit-term-tab {
  padding: 6px 12px;
  font-size: 11px;
  color: #94a3b8;
  background: transparent;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.circuit-term-tab.active {
  color: #34d399;
  border-bottom-color: #34d399;
  background: rgba(52, 211, 153, 0.05);
}
.circuit-term-output {
  flex: 1;
  padding: 8px 12px;
  font-family: monospace;
  font-size: 11.5px;
  color: #4ade80;
  overflow-y: auto;
  white-space: pre-wrap;
}
.circuit-term-input-row { display: flex; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.circuit-term-input {
  flex: 1;
  background: #0f172a;
  border: none;
  padding: 6px 10px;
  color: #f8fafc;
  font-family: monospace;
  font-size: 11.5px;
  outline: none;
}
.circuit-scope-canvas { width: 100%; height: 100%; background: #000000; display: block; }

.circuit-toast {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(50px);
  background: #1e293b;
  border: 1px solid #34d399;
  color: #f8fafc;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
  max-width: 80%;
  text-align: center;
}
.circuit-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.circuit-toast.error { border-color: #ef4444; }

/* Wokwi element sizing inside canvas */
.placed-component wokwi-arduino-uno { width: 220px; height: auto; display: block; }
.placed-component wokwi-arduino-mega { width: 240px; height: auto; display: block; }
.placed-component wokwi-arduino-nano { width: 130px; height: auto; display: block; }
.placed-component wokwi-esp32-devkit-v1 { width: 150px; height: auto; display: block; }
.placed-component wokwi-nano-rp2040-connect { width: 130px; height: auto; display: block; }
.placed-component wokwi-franzininho { width: 130px; height: auto; display: block; }
.placed-component wokwi-breadboard { display: block; }

/* Custom dark scrollbars */
.circuit-sidebar-left ::-webkit-scrollbar,
.circuit-terminal-panel ::-webkit-scrollbar,
.circuit-inspector ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.circuit-sidebar-left ::-webkit-scrollbar-track,
.circuit-terminal-panel ::-webkit-scrollbar-track,
.circuit-inspector ::-webkit-scrollbar-track {
  background: #0f172a;
}
.circuit-sidebar-left ::-webkit-scrollbar-thumb,
.circuit-terminal-panel ::-webkit-scrollbar-thumb,
.circuit-inspector ::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 3px;
}
.circuit-sidebar-left ::-webkit-scrollbar-thumb:hover,
.circuit-terminal-panel ::-webkit-scrollbar-thumb:hover,
.circuit-inspector ::-webkit-scrollbar-thumb:hover {
  background: #475569;
}
.circuit-component-grid {
  overflow-x: hidden;
}

/* === SPLIT VIEW & DIAGRAM.JSON EDITOR === */
.cs-split { display: flex !important; gap: 8px; }
.cs-editor-pane { width: 340px; min-width: 280px; display: flex; flex-direction: column; background: #0b1220; border: 1px solid #1e293b; border-radius: 8px; overflow: hidden; }
.cs-editor-bar { display: flex; gap: 6px; align-items: center; padding: 6px 8px; color: #e2e8f0; font-size: 12px; background: #0f172a; border-bottom: 1px solid #1e293b; }
.cs-editor-bar span { font-weight: bold; margin-right: auto; }
.cs-editor-bar button { background: #1e293b; color: #e2e8f0; border: 1px solid #334155; border-radius: 4px; padding: 2px 8px; cursor: pointer; font-size: 11px; }
.cs-editor-bar button:hover { background: #334155; }
#cs-json-editor { flex: 1; min-height: 300px; background: #020617; color: #a5f3fc; border: 0; font-family: monospace; font-size: 12px; padding: 8px; resize: vertical; line-height: 1.4; outline: none; }
.cs-err { display: none; white-space: pre-wrap; color: #fca5a5; background: #1c0a0a; font-size: 11px; padding: 6px 8px; max-height: 120px; overflow: auto; border-top: 1px solid #7f1d1d; }

/* === CANVAS & PART RENDERING === */
.cs-canvas { position: relative; flex: 1; min-height: 480px; background: #020617; border: 1px solid #1e293b; border-radius: 8px; overflow: hidden; }
.cs-part { position: absolute; cursor: move; }
.cs-part-body { width: 100%; height: 100%; pointer-events: none; }
.cs-pin { position: absolute; width: 8px; height: 8px; margin: -4px; border-radius: 50%; background: #22d3ee; border: 1px solid #083344; cursor: crosshair; }
.cs-pin:hover { background: #38bdf8; transform: scale(1.3); }

/* === WIRES === */
.cs-wires { position: absolute; inset: 0; z-index: 0; pointer-events: stroke; }
.cs-part { z-index: 1; }
.cs-wire { fill: none; stroke: #f59e0b; stroke-width: 2.5; cursor: pointer; pointer-events: stroke; }
.cs-wire:hover { stroke: #fbbf24; stroke-width: 3.5; }
.cs-wire.sel { stroke: #ef4444; stroke-width: 4; stroke-dasharray: 4,4; }

/* === TOOLBAR === */
.cs-toolbar { display: flex; gap: 6px; margin-bottom: 6px; }
.cs-toolbar button { background: #0b1220; color: #e2e8f0; border: 1px solid #334155; border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.cs-toolbar button:hover { background: #1e293b; }

/* === SENSOR META TOOLTIP === */
.circuit-item-card[data-meta]:hover::after {
  content: attr(data-meta);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #94a3b8;
  font-size: 10px;
  padding: 4px 7px;
  border-radius: 5px;
  border: 1px solid #334155;
  white-space: nowrap;
  pointer-events: none;
  z-index: 999;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* === SENSOR CATEGORY CHIPS === */
.circuit-cat-tab[data-cat^="Sensor"] { color: #7dd3fc; }
.circuit-cat-tab[data-cat^="Sensor"].active { color: #38bdf8; border-color: rgba(56,189,248,.5); background: #0c2a3d; }
.circuit-cat-tab[data-cat="Komunikasi"] { color: #c084fc; }
.circuit-cat-tab[data-cat="Komunikasi"].active { color: #a855f7; border-color: rgba(168,85,247,.5); background: #1e1030; }
/* === ITEM CARD: sensor-module preview === */
.circuit-item-card .item-preview > span { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.circuit-item-card .item-preview > span > svg { width: 90%; height: 90%; }
/* === CIRCUIT BODY RESPONSIVE === */
@media (max-width: 640px) {
  .circuit-sidebar-left { width: 100%; max-width: 100%; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.08); max-height: 55vh; }
  .circuit-body { flex-direction: column; }
  .circuit-sidebar-right { min-width: 0 !important; }
}

/* === INSPECTOR METADATA TABLE === */
.insp-meta { width: 100%; border-collapse: collapse; margin-bottom: 8px; font-size: 11px; }
.insp-meta td { padding: 3px 4px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.insp-meta td:first-child { color: #94a3b8; width: 65px; font-weight: 500; }
.insp-meta td:last-child { color: #f1f5f9; word-break: break-all; }
.insp-meta code { background: #0f172a; padding: 1px 4px; border-radius: 3px; color: #38bdf8; font-family: monospace; font-size: 10.5px; }

/* === SENSOR SIM SLIDERS (Inspector) === */
.insp-sim-title { font-size: 11px; font-weight: 700; color: #fbbf24; text-transform: uppercase; letter-spacing: .04em; margin: 8px 0 4px; }
.insp-sensor-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; border-bottom: 1px dashed rgba(255,255,255,.06); }
.insp-sensor-label { color: #94a3b8; font-size: 11px; flex: 1; min-width: 70px; }
.insp-sensor-val { color: #4ade80; font-size: 10.5px; font-family: monospace; min-width: 70px; text-align: right; }
.insp-sensor-slider { flex: 2; accent-color: #34d399; height: 18px; cursor: pointer; }
.insp-toggle { position: relative; display: inline-block; width: 38px; height: 20px; flex-shrink: 0; }
.insp-toggle input { opacity: 0; width: 0; height: 0; }
.insp-toggle-track { position: absolute; inset: 0; background: #334155; border-radius: 999px; transition: .2s; cursor: pointer; }
.insp-toggle-track::before { content: ''; position: absolute; height: 14px; width: 14px; left: 3px; top: 3px; background: #94a3b8; border-radius: 50%; transition: .2s; }
.insp-toggle input:checked + .insp-toggle-track { background: #047857; }
.insp-toggle input:checked + .insp-toggle-track::before { transform: translateX(18px); background: #6ee7b7; }

/* === BOARD COMPAT & WIRE PICKER === */
.insp-compat-title { font-size: 10.5px; font-weight: 700; color: #94a3b8; text-transform: uppercase; margin: 8px 0 4px; letter-spacing: .04em; }
.insp-compat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 8px; }
.compat-chip { font-size: 10px; padding: 3px 4px; text-align: center; border-radius: 4px; cursor: help; border: 1px solid transparent; }
.compat-chip.compat-ok { background: rgba(52, 211, 153, 0.12); color: #34d399; border-color: rgba(52, 211, 153, 0.3); }
.compat-chip.compat-warn { background: rgba(251, 191, 36, 0.12); color: #fbbf24; border-color: rgba(251, 191, 36, 0.3); }
.wire-color-palette { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; background: #0f172a; border-radius: 6px; border: 1px solid rgba(255,255,255,.08); vertical-align: middle; margin-left: 8px; }
.wire-color-dot { width: 14px; height: 14px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: transform .15s; }
.wire-color-dot:hover { transform: scale(1.2); }
.wire-color-dot.active { border-color: #fff; box-shadow: 0 0 6px currentColor; }
.cs-snap-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: #94a3b8; cursor: pointer; user-select: none; margin-left: 8px; vertical-align: middle; }
.cs-snap-toggle input { accent-color: #34d399; cursor: pointer; }

/* === CONTEXT MENU + WIRE HANDLES === */
.cs-context-menu { position: fixed; z-index: 99999; background: #0f172a; border: 1px solid #334155; border-radius: 8px; padding: 4px; min-width: 160px; max-width: 240px; box-shadow: 0 8px 30px rgba(0,0,0,.7); font-size: 12px; }
.ctx-item { padding: 7px 10px; color: #e2e8f0; cursor: pointer; border-radius: 5px; white-space: nowrap; }
.ctx-item:hover { background: #1e293b; color: #34d399; }
.ctx-sep { padding: 5px 10px 3px; color: #64748b; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.ctx-color-strip { display: flex; gap: 4px; padding: 4px 8px 6px; flex-wrap: wrap; }
.ctx-color-dot { width: 18px; height: 18px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.ctx-color-dot:hover { border-color: #fff; transform: scale(1.15); }
.wire-hit { cursor: pointer; }
.wire-vis { pointer-events: none !important; }
.wp-handle { cursor: grab; filter: drop-shadow(0 0 3px currentColor); }
.wp-add { cursor: cell; }
.comp-visual { transition: transform .18s ease; transform-origin: center center; }

/* === PROFESSIONAL CONTEXT MENU (.cs-ctx) === */
.cs-ctx {
  position: fixed;
  z-index: 999999;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 5px;
  min-width: 190px;
  max-width: 250px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.85), 0 0 0 1px rgba(255,255,255,0.06);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 12px;
  user-select: none;
  animation: csCtxPop 0.1s ease-out;
}
@keyframes csCtxPop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.cs-ctx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  color: #e2e8f0;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  gap: 8px;
}
.cs-ctx-item:hover {
  background: #1e293b;
  color: #34d399;
}
.cs-ctx-item.active {
  color: #34d399;
  font-weight: 600;
}
.cs-ctx-item.danger {
  color: #f87171;
}
.cs-ctx-item.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}
.cs-ctx-item kbd {
  background: #1e293b;
  color: #94a3b8;
  font-family: monospace;
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.08);
}
.cs-ctx-sep {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 4px 6px;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  padding-top: 3px;
}
.cs-ctx-colors {
  display: flex;
  gap: 5px;
  padding: 4px 8px 6px;
  justify-content: space-between;
}
.cs-ctx-color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s;
}
.cs-ctx-color-dot:hover {
  border-color: #fff;
  transform: scale(1.2);
}

/* === WIRE FLOATING TOOLBAR === */
.cs-wire-toolbar {
  position: fixed;
  z-index: 999998;
  display: flex;
  align-items: center;
  gap: 4px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 999px;
  padding: 5px 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.8);
  animation: csCtxPop 0.12s ease-out;
  user-select: none;
}
.cs-wire-tb-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  color: #e2e8f0;
  font-size: 13px;
  transition: background 0.12s, transform 0.1s;
}
.cs-wire-tb-btn:hover { background: #1e293b; transform: scale(1.15); }
.cs-wire-tb-btn.danger { color: #f87171; }
.cs-wire-tb-btn.danger:hover { background: rgba(239,68,68,0.15); }
.cs-wire-tb-sep {
  width: 1px; height: 20px;
  background: rgba(255,255,255,0.12);
  margin: 0 2px;
}
.cs-wire-tb-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s, border-color 0.12s;
  flex-shrink: 0;
}
.cs-wire-tb-dot:hover { transform: scale(1.25); border-color: #fff; }
.cs-wire-tb-dot.active { border-color: #34d399; }

/* === SIDEBAR COLLAPSE TOGGLE === */
.cs-sidebar-toggle-btn {
  position: absolute;
  left: 320px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 120;
  background: #1e293b;
  border: 1px solid #334155;
  color: #94a3b8;
  width: 18px; height: 48px;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  transition: background 0.15s, color 0.15s, left 0.25s;
  padding: 0;
}
.cs-sidebar-toggle-btn:hover { background: #0f172a; color: #34d399; }
.cs-sidebar-toggle-btn.collapsed { left: 0; }
.circuit-sidebar-left {
  transition: width 0.25s, padding 0.25s, min-width 0.25s;
}

/* === EDITOR MINIMIZE TOGGLE === */
.cs-editor-toggle-btn {
  width: 100%;
  background: #0f172a;
  border: none;
  border-top: 1px solid #1e293b;
  border-bottom: 1px solid #1e293b;
  color: #64748b;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  text-align: left;
  transition: color 0.12s, background 0.12s;
}
.cs-editor-toggle-btn:hover { background: #1e293b; color: #34d399; }

/* === SEG HANDLE cursor override === */
.seg-handle { cursor: ns-resize; }
