/* ==========================================================================
   rp2040.css — the board Board Visual Dashboard & RP2040 Styling
   ========================================================================== */

.rp-dash {
  display: flex;
  flex-direction: column;
  background: #0f172a;
  color: #f8fafc;
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
  font-family: var(--font, 'Inter', sans-serif);
}

/* Header */
.rp-dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #1e293b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.rp-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rp-badge {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.rp-title {
  font-size: 13px;
  font-weight: 600;
  color: #f1f5f9;
}

.rp-dot.live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: rpPulse 1.8s infinite;
}

@keyframes rpPulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.rp-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-dash {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #334155;
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-dash:hover {
  background: #475569;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-dash.accent {
  background: #0284c7;
  color: #fff;
  border-color: #38bdf8;
}

.btn-dash.accent:hover {
  background: #0369a1;
}

.btn-led-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 4px #22c55e;
}

/* Pico Board Visualization Container */
.rp-pico-wrap {
  padding: 14px 10px;
  display: flex;
  justify-content: center;
  background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
  overflow-x: auto;
}

.rp-pico-board {
  display: flex;
  align-items: stretch;
  background: #0d4a34; /* Official the board maker Green PCB */
  border: 2px solid #166534;
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.25), inset 0 -2px 0 rgba(0, 0, 0, 0.5);
  position: relative;
  min-width: 380px;
  max-width: 440px;
}

/* Pin Columns (Left & Right) */
.pico-col {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px 4px;
  width: 100px;
  z-index: 2;
}

.pico-col.left-col {
  border-right: 1px dashed rgba(255, 255, 255, 0.12);
}

.pico-col.right-col {
  border-left: 1px dashed rgba(255, 255, 255, 0.12);
}

.pico-pin-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 4px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.pico-pin-row:hover {
  background: rgba(255, 255, 255, 0.12);
}

.pico-pin-row.right {
  flex-direction: row-reverse;
  text-align: right;
}

.pin-num {
  font-family: var(--mono, monospace);
  font-size: 9.5px;
  color: #94a3b8;
  width: 14px;
  text-align: center;
  flex: none;
}

.pin-pad {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFF0A8 0%, #D4AF37 50%, #8C6D15 100%);
  border: 1px solid #7A5F12;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.5);
  flex: none;
}

.pad-hole {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #061f15;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.8);
}

.pin-info {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.pico-pin-row.right .pin-info {
  justify-content: flex-end;
}

.pin-name {
  font-size: 10px;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
}

.pin-tag {
  font-family: var(--mono, monospace);
  font-size: 8.5px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.4);
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.pin-tag.pwr {
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.06);
}

/* Active Pin States */
.pico-pin-row.val-hi .pin-tag {
  background: #166534;
  color: #4ade80;
  border-color: #22c55e;
  font-weight: 700;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
}

.pico-pin-row.val-hi .pin-pad {
  background: #4ade80;
  box-shadow: 0 0 8px #22c55e;
}

.pico-pin-row.mode-pwm .pin-tag {
  background: #9a3412;
  color: #fb923c;
  border-color: #f97316;
  font-weight: 700;
}

.pico-pin-row.mode-in .pin-tag {
  background: #1e3a8a;
  color: #60a5fa;
  border-color: #3b82f6;
}

.pico-pin-row.mode-adc .pin-tag {
  background: #581c87;
  color: #c084fc;
  border-color: #a855f7;
}

/* Center PCB Body */
.pico-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px;
  position: relative;
}

.pico-usb {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: -6px;
}

.usb-metal {
  width: 44px;
  height: 22px;
  background: linear-gradient(180deg, #E2E7ED 0%, #A8B2BD 35%, #767F8A 70%, #CBD2DA 100%);
  border: 1px solid #5D6672;
  border-radius: 3px 3px 6px 6px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5), inset 0 1px 1px #fff;
}

.usb-label {
  font-size: 8px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 2px;
}

.pico-led-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 0, 0, 0.3);
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin: 6px 0;
}

.pico-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #27272a;
  border: 1px solid #52525b;
  transition: all 0.1s ease;
}

.pico-led.lit {
  background: #22c55e;
  border-color: #86efac;
  box-shadow: 0 0 14px #22c55e, 0 0 4px #86efac;
}

.led-lbl {
  font-size: 9.5px;
  font-weight: 600;
  color: #e2e8f0;
}

/* RP2040 Processor Chip */
.pico-chip {
  width: 72px;
  height: 72px;
  background: linear-gradient(145deg, #24282E 0%, #16181B 100%);
  border: 1px solid #3F4752;
  border-radius: 6px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.65), inset 0 1px 1px rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 10px 0;
}

.chip-notch {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #27272a;
}

.chip-text {
  font-family: var(--mono, monospace);
  font-size: 10px;
  font-weight: 700;
  color: #e4e4e7;
  letter-spacing: 0.05em;
}

.chip-sub {
  font-family: var(--mono, monospace);
  font-size: 8px;
  color: #a1a1aa;
}

.pico-bootsel {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 8.5px;
  color: #d1d5db;
  margin: 6px 0;
}

.btn-bootsel {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: #e2e8f0;
  box-shadow: inset 0 -1px 2px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.5);
}

.pico-branding {
  text-align: center;
  color: #fff;
}

.pico-branding b {
  display: block;
  font-size: 11px;
  color: #f8fafc;
}

.pico-branding small {
  font-size: 9px;
  color: #94a3b8;
}

/* Pin Legend */
.rp-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 12px;
  background: #111827;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.leg-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  color: #94a3b8;
}

.leg-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.leg-dot.out-hi { background: #22c55e; box-shadow: 0 0 4px #22c55e; }
.leg-dot.out-lo { background: #475569; }
.leg-dot.pwm { background: #f97316; }
.leg-dot.in { background: #3b82f6; }
.leg-dot.adc { background: #a855f7; }
.leg-dot.pwr { background: #e2e8f0; }

/* Instances Section */
.rp-instances-section {
  padding: 10px 14px;
  background: #0f172a;
}

.rp-inst-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.rp-inst-head b {
  font-size: 12px;
  color: #f1f5f9;
}

.rp-inst-head small {
  font-size: 11px;
  color: #64748b;
}

.rp-inst-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.inst-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px 8px;
  transition: all 0.15s ease;
}

.inst-pill:hover {
  background: #334155;
  border-color: rgba(255, 255, 255, 0.15);
}

.inst-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.inst-name {
  font-size: 11px;
  font-weight: 600;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inst-pin-chip {
  font-family: var(--mono, monospace);
  font-size: 9.5px;
  color: #38bdf8;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.inst-pin-chip:hover {
  color: #7dd3fc;
}

.inst-btn {
  background: #0f172a;
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  font-size: 10px;
  padding: 2px 6px;
  cursor: pointer;
}

.inst-btn:hover {
  background: #0284c7;
  color: #fff;
  border-color: #38bdf8;
}

/* Code Language Switcher in Code pane */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
  margin-right: 8px;
}

.lang-btn {
  border: 0;
  background: transparent;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 4px;
  color: var(--text-2, #64748b);
  cursor: pointer;
}

.lang-btn.active {
  background: #fff;
  color: var(--accent, #0284c7);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Topbar Main Mode Tabs */
.main-mode-tabs {
  display: inline-flex;
  align-items: center;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.mode-tab:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.06);
}

.mode-tab.active {
  background: #0284c7;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.mode-tab .live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
}

/* ==========================================================================
   Simulator Canvas Workbench View (Dedicated Main Tab)
   ========================================================================== */

.simulator-canvas-view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: #090d13;
  z-index: 100;
  overflow: hidden;
}

.app[data-panel="simulator"] .simulator-canvas-view {
  display: flex;
}

.codetable-view,
.pinmap-view,
.wiring-view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg, #f4f6f8);
  z-index: 100;
  overflow: hidden;
}

.app[data-panel="codetable"] .codetable-view,
.app[data-panel="pinmap"] .pinmap-view,
.app[data-panel="wiring"] .wiring-view {
  display: flex !important;
}

/* When in Simulator, CodeTable, PinMap, or Wiring, expand across the full width and height */
.app[data-panel="simulator"] .right-panel,
.app[data-panel="simulator"] #splitRight,
.app[data-panel="simulator"] .side-panel,
.app[data-panel="simulator"] #splitLeft,
.app[data-panel="simulator"] #dock,
.app[data-panel="simulator"] #btnRevealRight,
.app[data-panel="codetable"] .right-panel,
.app[data-panel="codetable"] #splitRight,
.app[data-panel="codetable"] .side-panel,
.app[data-panel="codetable"] #splitLeft,
.app[data-panel="codetable"] #dock,
.app[data-panel="codetable"] #btnRevealRight,
.app[data-panel="pinmap"] .right-panel,
.app[data-panel="pinmap"] #splitRight,
.app[data-panel="pinmap"] .side-panel,
.app[data-panel="pinmap"] #splitLeft,
.app[data-panel="pinmap"] #dock,
.app[data-panel="pinmap"] #btnRevealRight,
.app[data-panel="wiring"] .right-panel,
.app[data-panel="wiring"] #splitRight,
.app[data-panel="wiring"] .side-panel,
.app[data-panel="wiring"] #splitLeft,
.app[data-panel="wiring"] #dock,
.app[data-panel="wiring"] #btnRevealRight {
  display: none !important;
}

.sim-canvas-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* Canvas Toolbar */
.sim-canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #111823;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 12px;
  flex-shrink: 0;
}

.sc-tb-left, .sc-tb-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sc-badge {
  background: linear-gradient(135deg, #0284c7, #06b6d4);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.06em;
  margin-right: 4px;
}

.btn-canvas-run {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #10b981;
  color: #fff;
  border: 1px solid #34d399;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-canvas-run:hover {
  background: #059669;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.btn-canvas-run.running {
  background: #f59e0b;
  border-color: #fbbf24;
}

.btn-canvas-pause, .btn-canvas-stop, .btn-canvas-step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-canvas-pause:hover, .btn-canvas-stop:hover:not(:disabled), .btn-canvas-step:hover {
  background: #334155;
  color: #fff;
}

.btn-canvas-stop:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sc-sep {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0 4px;
}

.btn-canvas-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1f2937;
  color: #f3f4f6;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-canvas-action:hover {
  background: #374151;
  border-color: rgba(255, 255, 255, 0.2);
}

.sc-check-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: #94a3b8;
  cursor: pointer;
  margin-left: 6px;
}

.sc-dropdown-wrap {
  position: relative;
}

.sc-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  width: 290px;
  max-height: 440px;
  overflow-y: auto;
  background: #161f2e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
  padding: 8px;
  z-index: 200;
}

.sc-menu-cat {
  margin-bottom: 8px;
}

.sc-cat-title {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 6px 2px;
}

.sc-cat-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sc-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 6px 8px;
  color: #e2e8f0;
  font-size: 11.5px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.12s ease;
}

.sc-menu-item:hover {
  background: #0284c7;
  color: #fff;
}

.sc-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
}

.sc-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.sc-dot.idle { background: #64748b; }
.sc-dot.run { background: #10b981; box-shadow: 0 0 6px #10b981; }
.sc-dot.warn { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }

.sc-board-info {
  font-size: 11px;
  color: #94a3b8;
}

/* Canvas Body & Surface */
.sim-canvas-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.sim-canvas-surface {
  flex: 1;
  position: relative;
  overflow: auto;
  background-color: #0b0f14;
  background-image: radial-gradient(circle, #21262d 1.5px, transparent 1.5px);
  background-size: 24px 24px;
}

.sim-canvas-board {
  min-width: 1400px;
  min-height: 1000px;
  position: relative;
  padding: 24px;
}

/* Draggable Module Cards on Canvas */
.sim-canvas-card {
  position: absolute;
  width: 200px;
  border-radius: 10px;
  background: #161b22;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.08);
  user-select: none;
  cursor: default;
  transition: box-shadow 0.15s ease;
  z-index: 10;
}

.sim-canvas-card.wide {
  width: 320px;
}

.sim-canvas-card.dragging {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 0 2px #38bdf8;
  opacity: 0.95;
}

.cv-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #1e2633;
  border-top-left-radius: 9px;
  border-top-right-radius: 9px;
  cursor: grab;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.cv-card-header:active {
  cursor: grabbing;
}

.cv-drag-grip {
  color: #64748b;
  font-size: 12px;
  letter-spacing: -1px;
}

.cv-card-title {
  font-size: 11px;
  font-weight: 700;
  color: #f1f5f9;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cv-pin-badge {
  font-family: var(--mono, monospace);
  font-size: 10px;
  font-weight: 700;
  background: #0284c7;
  color: #fff;
  padding: 2px 7px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.cv-pin-badge:hover {
  background: #0369a1;
  transform: scale(1.05);
}

.cv-btn-close {
  border: 0;
  background: transparent;
  color: #64748b;
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
}

.cv-btn-close:hover {
  color: #ef4444;
}

/* Empty Canvas Message */
.sc-empty-canvas {
  position: absolute;
  top: 40%;
  left: 35%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #64748b;
  max-width: 360px;
}

.sc-empty-canvas svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  color: #3b82f6;
  opacity: 0.8;
}

.sc-empty-canvas h3 {
  font-size: 16px;
  color: #f1f5f9;
  margin: 0 0 6px;
}

.sc-empty-canvas p {
  font-size: 12.5px;
  line-height: 1.5;
  margin: 0;
}

/* Right Side Pico IC Panel */
.sim-canvas-pico-panel {
  width: 380px;
  background: #0e141e;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.sc-pico-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #141c2b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sc-pico-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: #f8fafc;
}

.sc-pico-actions {
  display: flex;
  gap: 6px;
}

.sc-pico-mount {
  padding: 12px 10px;
}

/* Pin Selector Popup Modal */
.cv-pin-popup {
  position: fixed;
  width: 260px;
  background: #1a2232;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.65);
  padding: 10px;
  z-index: 9999;
  font-family: var(--font, sans-serif);
}

.cv-popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: #e2e8f0;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.cv-popup-close {
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
}

.cv-popup-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
}

.cv-pin-btn {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  padding: 4px 6px;
  color: #cbd5e1;
  font-size: 10px;
  font-family: var(--mono, monospace);
  cursor: pointer;
  text-align: center;
  transition: all 0.12s ease;
}

.cv-pin-btn:hover {
  background: #0284c7;
  color: #fff;
  border-color: #38bdf8;
}

.cv-pin-btn.selected {
  background: #059669;
  color: #fff;
  border-color: #10b981;
  font-weight: 700;
}

/* Highlight Linking */
.pico-highlight {
  box-shadow: 0 0 12px #38bdf8 !important;
  border-color: #38bdf8 !important;
  background: rgba(56, 189, 248, 0.15) !important;
  transform: scale(1.04);
}

/* ==========================================================================
   Code & Hardware Pin Table Platform
   ========================================================================== */

.code-table-platform {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #0d1117;
  color: #f0f6fc;
  overflow: hidden;
}

.ct-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #161b22;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 10px;
}

.ct-tool-left, .ct-tool-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ct-badge {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.ct-search {
  background: #0d1117;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11.5px;
  color: #f0f6fc;
  width: 220px;
}

.ct-search:focus {
  outline: none;
  border-color: #38bdf8;
}

.ct-stats-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: #121820;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px;
  overflow-x: auto;
}

.ct-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #1c2431;
  padding: 2px 8px;
  border-radius: 4px;
  color: #94a3b8;
}

.ct-stat-pill b {
  color: #38bdf8;
}

.ct-stat-pill.ok { color: #10b981; }
.ct-stat-pill.warn { color: #f59e0b; }

.ct-table-wrap {
  flex: 1;
  overflow: auto;
}

.ct-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  text-align: left;
}

.ct-table th {
  position: sticky;
  top: 0;
  background: #161b22;
  color: #8b949e;
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 2;
}

.ct-table td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

.ct-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.ct-comp-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ct-comp-icon {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: #21262d;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #38bdf8;
}

.ct-comp-info b {
  display: block;
  font-size: 11.5px;
  color: #f0f6fc;
}

.ct-comp-info small {
  color: #8b949e;
  font-size: 10px;
}

.ct-pin-select {
  background: #21262d;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  color: #38bdf8;
  font-family: var(--mono, monospace);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 6px;
  cursor: pointer;
}

.ct-pin-select:hover {
  border-color: #38bdf8;
}

.ct-iface-tag {
  background: #1f2937;
  color: #cbd5e1;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
}

.ct-code-cell {
  position: relative;
  font-family: var(--mono, monospace);
  font-size: 10.5px;
  color: #7ee787;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ct-code-cell code {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ct-code-copy {
  display: none;
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: #30363d;
  color: #f0f6fc;
  border: 0;
  border-radius: 3px;
  padding: 2px 5px;
  font-size: 11px;
  cursor: pointer;
}

.ct-code-cell:hover .ct-code-copy {
  display: inline-block;
}

.ct-state-cell {
  text-align: right;
  font-family: var(--mono, monospace);
  font-size: 10.5px;
  color: #38bdf8;
}

.ct-empty {
  text-align: center;
  padding: 30px;
  color: #64748b;
}

/* Code View Mode Toggle (Editor vs Pin & Code Table) */
.code-mode-toggle {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
  margin-right: 8px;
}

.code-mode-btn {
  border: 0;
  background: transparent;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  color: var(--text-2, #64748b);
  cursor: pointer;
}

.code-mode-btn.active {
  background: #fff;
  color: var(--accent, #0284c7);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* =====================================================================
 * PIN MAP PLATFORM STYLING (Light Theme matching Raiiotronix Design System)
 * ===================================================================== */
.pinmap-platform {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: var(--bg, #f4f6f8);
  color: var(--text, #1e2329);
  overflow: hidden;
  font-family: var(--font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
}

.pm-header {
  padding: 16px 24px;
  background: var(--surface, #ffffff);
  border-bottom: 1px solid var(--border, #e5e8ec);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.pm-badge {
  display: inline-block;
  background: var(--accent-50, #fff3eb);
  color: var(--accent-600, #e2651d);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2.5px 8px;
  border-radius: 6px;
  border: 1px solid var(--accent-100, #fee3d1);
  margin-bottom: 4px;
}

.pm-title-block h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text, #1e2329);
}

.pm-title-block p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-2, #4a515b);
}

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

.pm-board-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-3, #f1f3f6);
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong, #d5dae0);
}

.pm-board-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2, #4a515b);
}

.pm-board-select {
  background: var(--surface, #ffffff);
  color: var(--text, #1e2329);
  border: 1px solid var(--border-strong, #d5dae0);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  height: 28px;
  padding: 0 8px;
}

.pm-header-actions {
  display: flex;
  gap: 8px;
}

.pm-stats-strip {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 24px;
  background: var(--surface-2, #f8f9fb);
  border-bottom: 1px solid var(--border, #e5e8ec);
  flex-wrap: wrap;
}

.pm-stat-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.pm-stat-num {
  font-size: 15px;
  font-weight: 700;
  color: var(--text, #1e2329);
  font-family: var(--mono, monospace);
}

.pm-stat-num small {
  font-size: 11px;
  color: var(--muted, #8a919b);
}

.pm-stat-txt {
  font-size: 12px;
  color: var(--text-2, #4a515b);
}

.pm-stat-badge {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 999px;
}

.pm-stat-badge.ok {
  background: #eafaf1;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.pm-stat-badge.conflict {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.pm-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: var(--surface, #ffffff);
  border-bottom: 1px solid var(--border, #e5e8ec);
  gap: 16px;
  flex-wrap: wrap;
}

.pm-search-box {
  flex: 1;
  max-width: 400px;
}

.pm-search-box input {
  width: 100%;
  background: var(--surface-2, #f8f9fb);
  color: var(--text, #1e2329);
  border: 1px solid var(--border-strong, #d5dae0);
  border-radius: 8px;
  padding: 6px 12px;
}

.pm-search-box input:focus {
  border-color: var(--accent, #f37a33);
  background: #ffffff;
  outline: none;
}

.pm-cat-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pm-cat-btn {
  background: var(--surface-3, #f1f3f6);
  color: var(--text-2, #4a515b);
  border: 1px solid var(--border, #e5e8ec);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pm-cat-btn:hover {
  background: var(--accent-50, #fff3eb);
  color: var(--accent-600, #e2651d);
}

.pm-cat-btn.active {
  background: var(--accent, #f37a33);
  color: #ffffff;
  border-color: var(--accent);
  font-weight: 600;
}

.pm-table-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px 24px;
}

.pm-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e5e8ec);
  border-radius: 12px;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.06));
  overflow: hidden;
}

.pm-table th {
  text-align: left;
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2, #4a515b);
  border-bottom: 1px solid var(--border, #e5e8ec);
  background: var(--surface-2, #f8f9fb);
  position: sticky;
  top: 0;
  z-index: 10;
}

.pm-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border, #e5e8ec);
  vertical-align: middle;
  background: var(--surface, #ffffff);
  color: var(--text, #1e2329);
}

.pm-table tr:hover td {
  background: var(--surface-2, #f8f9fb);
}

.pm-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pm-mod-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.pm-inst-name {
  background: var(--surface-2, #f8f9fb);
  color: var(--text, #1e2329);
  border: 1px solid var(--border, #e5e8ec);
  font-weight: 600;
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 6px;
  width: 100%;
}

.pm-inst-name:focus {
  border-color: var(--accent, #f37a33);
  background: #ffffff;
  outline: none;
}

.pm-type-badge {
  padding-left: 8px;
  display: flex;
  flex-direction: column;
}

.pm-type-badge b {
  font-size: 12.5px;
  color: var(--text, #1e2329);
}

.pm-type-badge small {
  font-size: 11px;
  color: var(--muted, #8a919b);
}

.pm-pins-cell {
  display: flex;
  align-items: center;
}

.pm-role-pins {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pm-pin-slot {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-3, #f1f3f6);
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong, #d5dae0);
}

.pm-pin-slot.conflict-slot {
  border-color: #ef4444;
  background: #fef2f2;
}

.pm-slot-role {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2, #4a515b);
  font-family: var(--mono, monospace);
}

.pm-pin-select {
  background: var(--surface, #ffffff);
  color: var(--accent-600, #e2651d);
  border: 1px solid var(--border-strong, #d5dae0);
  border-radius: 6px;
  font-size: 11.5px;
  font-family: var(--mono, monospace);
  font-weight: 700;
  height: 26px;
  padding: 0 6px;
}

.pm-conflict-icon {
  color: #dc2626;
  font-weight: 700;
}

.pm-bus-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pm-pin-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2, #4a515b);
}

.pm-bus-select {
  background: var(--surface, #ffffff);
  color: #7c3aed;
  border: 1px solid var(--border-strong, #d5dae0);
  border-radius: 6px;
  font-size: 11.5px;
  font-family: var(--mono, monospace);
  font-weight: 600;
  height: 26px;
  padding: 0 6px;
}

.pm-addr-tag {
  font-size: 10.5px;
  background: #f3e8ff;
  color: #7c3aed;
  padding: 2px 7px;
  border-radius: 5px;
  font-family: var(--mono, monospace);
  font-weight: 600;
}

/* =====================================================================
 * CIRCUIT DIAGRAM PLATFORM STYLING (Light Canvas & Draggable Cards)
 * ===================================================================== */
.circuit-platform {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background-color: #F7F8FA;
  background-image: radial-gradient(circle, #D6DBE1 1px, transparent 1.2px);
  background-size: 24px 24px;
  color: var(--text, #1e2329);
  overflow: hidden;
  position: relative;
  font-family: var(--font, sans-serif);
}

.cd-toolbar {
  padding: 10px 20px;
  background: var(--surface, #ffffff);
  border-bottom: 1px solid var(--border, #e5e8ec);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  z-index: 20;
  flex-wrap: wrap;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.cd-tool-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cd-badge {
  background: var(--accent-50, #fff3eb);
  color: var(--accent-600, #e2651d);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2.5px 8px;
  border-radius: 6px;
  border: 1px solid var(--accent-100, #fee3d1);
}

.cd-title {
  display: flex;
  flex-direction: column;
}

.cd-title b {
  font-size: 14px;
  font-weight: 700;
  color: var(--text, #1e2329);
}

.cd-title small {
  font-size: 11.5px;
  color: var(--text-2, #4a515b);
}

.cd-tool-center {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cd-btn-group {
  display: flex;
  align-items: center;
  background: var(--surface-3, #f1f3f6);
  border: 1px solid var(--border-strong, #d5dae0);
  border-radius: 8px;
  padding: 2px;
}

.cd-btn-group .zoom-label {
  background: transparent;
  border: 0;
  color: var(--text-2, #4a515b);
  font-size: 11.5px;
  font-family: var(--mono, monospace);
  font-weight: 600;
  padding: 0 8px;
}

.cd-filter-group {
  display: flex;
  gap: 2px;
  background: var(--surface-3, #f1f3f6);
  padding: 2px;
  border-radius: 8px;
  border: 1px solid var(--border-strong, #d5dae0);
}

.cd-filter-btn {
  background: transparent;
  border: 0;
  color: var(--text-2, #4a515b);
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.cd-filter-btn:hover {
  color: var(--text, #1e2329);
}

.cd-filter-btn.active {
  background: var(--surface, #ffffff);
  color: var(--accent, #f37a33);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

.cd-tool-right {
  display: flex;
  gap: 8px;
}

.cd-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: default;
  user-select: none;
}

/* Wires in Circuit View */
.cd-wire-path {
  transition: stroke-width 0.15s ease, opacity 0.15s ease;
  cursor: pointer;
}

.cd-wire-path:hover,
.wire-highlight {
  stroke-width: 3.8px !important;
  opacity: 1 !important;
  filter: drop-shadow(0 0 4px currentColor);
}

.wire-dimmed {
  opacity: 0.12 !important;
}

/* Draggable Canvas-Card Module Styling */
.cd-card-node {
  cursor: grab;
  user-select: none;
  transition: filter 0.15s ease;
}

.cd-card-node:hover {
  filter: drop-shadow(0 10px 24px rgba(15, 23, 42, 0.18));
}

.cd-card-node.dragging {
  cursor: grabbing !important;
  filter: drop-shadow(0 16px 36px rgba(243, 122, 51, 0.35)) !important;
}

.cd-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent, #f37a33);
  color: #f8fafc;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 11.5px;
  font-family: var(--mono, monospace);
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
  z-index: 50;
  white-space: nowrap;
}

/* Selected Row in Pin Map */
.pm-table tr.pm-row-selected td {
  background: rgba(243, 122, 51, 0.08) !important;
  border-top: 1px solid rgba(243, 122, 51, 0.4);
  border-bottom: 1px solid rgba(243, 122, 51, 0.4);
}

.pm-table tr.pm-row-selected td:first-child {
  border-left: 3px solid var(--accent, #f37a33);
}

/* Module selector controls in Pin Map & Wiring */
.pm-module-select,
.cd-module-select {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border-strong, #d5dae0);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  color: var(--text, #1e2329);
  font-weight: 500;
  cursor: pointer;
  outline: none;
}

.pm-module-select:focus,
.cd-module-select:focus {
  border-color: var(--accent, #f37a33);
  box-shadow: 0 0 0 2px rgba(243, 122, 51, 0.2);
}

.pm-filter-btn.active,
.cd-filter-btn.active {
  background: var(--accent, #f37a33) !important;
  color: #ffffff !important;
  border-color: var(--accent, #f37a33) !important;
  font-weight: 600;
}
