/* ─── MOBILE BLOCK OVERLAY ───────────────────────────────── */
#mobile-block {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #1c1917;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 36px 28px;
  text-align: center;
}
#mobile-block .mb-logo {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  line-height: 1;
}
#mobile-block .mb-logo .mb-rgx {
  font-size: 52px;
  font-weight: 900;
  color: #EB5F4F;
  letter-spacing: -1px;
}
#mobile-block .mb-logo .mb-emu {
  font-size: 26px;
  font-weight: 700;
  color: rgba(255,255,255,.85);
}
#mobile-block h2 {
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -.3px;
}
#mobile-block p {
  color: rgba(255,255,255,.6);
  font-size: 14px;
  line-height: 1.65;
  max-width: 300px;
  margin: 0;
}
#mobile-block .mb-devices {
  display: flex;
  gap: 24px;
  margin-top: 6px;
}
#mobile-block .mb-dev {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  color: rgba(255,255,255,.75);
  font-size: 12px;
  font-weight: 700;
}
#mobile-block .mb-dev svg {
  width: 36px;
  height: 36px;
  stroke: #EB5F4F;
}
#mobile-block .mb-note {
  font-size: 12px;
  color: rgba(255,255,255,.35);
  margin-top: 4px;
}
@media (max-width: 767px) {
  #mobile-block { display: flex; }
  /* Hide app content so it doesn't force the page wider than the viewport */
  #toolbar, #main, #bottom { display: none !important; }
  body { overflow: hidden; width: 100vw; max-width: 100vw; }
}

/* ─── DESIGN TOKENS ─────────────────────────────────────── */
:root {
  /* Brand */
  --brand:       #EB5F4F;
  --brand-dark:  #C94B3B;
  --brand-light: #FFF0EE;
  --brand-mid:   #FDE8E5;

  /* Neutrals — light theme */
  --bg:          #F7F8FA;
  --bg2:         #FFFFFF;
  --bg3:         #F0F2F5;
  --bg4:         #E8EAED;
  --panel:       #FFFFFF;
  --sidebar:     #FFFFFF;

  /* Borders */
  --border:      #E4E7EC;
  --border2:     #D0D5DD;

  /* Text */
  --text:        #1A1D23;
  --text2:       #4B5563;
  --text3:       #9CA3AF;
  --text4:       #C9D0D8;

  /* Signals */
  --green:       #16A34A;
  --green-light: #DCFCE7;
  --yellow:      #D97706;
  --yellow-light:#FEF3C7;
  --red:         #DC2626;
  --red-light:   #FEE2E2;
  --orange:      #EA580C;
  --orange-light:#FFEDD5;
  --blue:        #2563EB;
  --blue-light:  #DBEAFE;
  --purple:      #7C3AED;
  --purple-light:#EDE9FE;

  /* Typography */
  --font:  'Nunito', sans-serif;
  --mono:  'JetBrains Mono', monospace;

  /* Sizing */
  --r:    8px;
  --r2:   12px;
  --r3:   16px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:  0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);
}

/* ─── RESET ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  line-height: 1.5;
}

/* ─── TOOLBAR ────────────────────────────────────────────── */
#toolbar {
  height: 88px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 8px;
  flex-shrink: 0;
  z-index: 200;
}
.toolbar-logo {
  height: 81px;
  display: flex;
  align-items: center;
  margin-right: 20px;
}
.toolbar-logo img {
  height: 81px;
  width: auto;
  display: block;
}
.tsep {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 6px;
  flex-shrink: 0;
}

/* Toolbar buttons */
.tbtn {
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r);
  border: 1.5px solid var(--border2);
  background: var(--bg2);
  color: var(--text2);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all .15s;
  white-space: nowrap;
}
.tbtn:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}
.tbtn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Action buttons */
.tbtn-run {
  height: 34px; padding: 0 16px;
  border-radius: var(--r);
  border: none;
  background: var(--green);
  color: #fff;
  font-family: var(--font);
  font-size: 13px; font-weight: 800;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: all .15s;
  box-shadow: 0 2px 8px rgba(22,163,74,.3);
}
.tbtn-run:hover { background: #15803d; box-shadow: 0 4px 12px rgba(22,163,74,.4); transform: translateY(-1px); }
.tbtn-run:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.tbtn-stop {
  height: 34px; padding: 0 16px;
  border-radius: var(--r);
  border: none;
  background: var(--red);
  color: #fff;
  font-family: var(--font);
  font-size: 13px; font-weight: 800;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: all .15s;
  box-shadow: 0 2px 8px rgba(220,38,38,.3);
}
.tbtn-stop:hover { background: #b91c1c; box-shadow: 0 4px 12px rgba(220,38,38,.4); transform: translateY(-1px); }
.tbtn-stop:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.tbtn-reset {
  height: 34px; padding: 0 14px;
  border-radius: var(--r);
  border: 1.5px solid var(--orange);
  background: var(--orange-light);
  color: var(--orange);
  font-family: var(--font);
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: all .15s;
}
.tbtn-reset:hover { background: var(--orange); color: #fff; }

/* Sim status pill */
#simstatus {
  margin-left: auto;
  font-size: 12px;
  font-family: var(--font);
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 20px;
  background: var(--bg3);
  border: 1.5px solid var(--border2);
  color: var(--text3);
  letter-spacing: .01em;
}
#simstatus.running {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green);
}
#simstatus.error {
  background: var(--red-light);
  border-color: var(--red);
  color: var(--red);
}

/* ─── MAIN LAYOUT ────────────────────────────────────────── */
#main { flex: 1; display: flex; overflow: hidden; min-height: 0; }

/* ─── LEFT SIDEBAR ───────────────────────────────────────── */
#sidebar-l {
  width: 210px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: 2px 0 8px rgba(0,0,0,.04);
}
.sidebar-brand {
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--brand-light);
}
.sidebar-brand img {
  width: 80px;
  height: auto;
}
.sidebar-brand-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--brand);
}
.sec-hdr {
  padding: 10px 14px 7px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sec-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--bg3);
  color: var(--text3);
  text-transform: none;
  letter-spacing: 0;
}

/* Component cards in library */
.comp-card {
  margin: 8px 10px;
  border-radius: var(--r2);
  border: 1.5px solid var(--border);
  background: var(--bg2);
  cursor: grab;
  transition: all .18s;
  box-shadow: var(--shadow-sm);
}
.comp-card:hover {
  border-color: var(--brand);
  box-shadow: 0 4px 16px rgba(235,95,79,.2);
  transform: translateY(-2px);
}
.comp-card:active { cursor: grabbing; transform: translateY(0); }
.comp-thumb {
  width: 100%;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  padding: 6px;
}
.comp-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.comp-info { padding: 8px 10px 10px; }
.comp-name { font-size: 13px; font-weight: 800; color: var(--text); }
.comp-sub { font-size: 11px; color: var(--text3); margin-top: 1px; font-weight: 500; }
.comp-badges {
  display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap;
}
.badge {
  font-size: 9px; padding: 2px 7px;
  border-radius: 20px; font-weight: 800;
  letter-spacing: .05em; text-transform: uppercase;
}
.badge-dig { background: var(--yellow-light); color: var(--yellow); border: 1px solid #fde68a; }
.badge-ana { background: var(--red-light); color: var(--red); border: 1px solid #fca5a5; }
.badge-pwm { background: var(--orange-light); color: var(--orange); border: 1px solid #fdba74; }
.badge-i2c { background: var(--purple-light); color: var(--purple); border: 1px solid #c4b5fd; }

/* Legend */
.legend-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
}
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(0,0,0,.1);
}

/* Controls hint */
.hint-item {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 14px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
}
.hint-key {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text2);
  font-family: var(--mono);
  flex-shrink: 0;
}

/* ─── CANVAS ─────────────────────────────────────────────── */
#canvas-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #FFFFFF;
  background-image:
    linear-gradient(rgba(180,190,210,.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(180,190,210,.18) 1px, transparent 1px);
  background-size: 24px 24px;
  cursor: default;
}
#canvas-vp { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
#wire-svg {
  position: absolute; top: 0; left: 0;
  width: 4000px; height: 3000px;
  pointer-events: none; overflow: visible;
}
#wire-svg-hit {
  position: absolute; top: 0; left: 0;
  width: 4000px; height: 3000px; overflow: visible;
  pointer-events: none;
}
#comp-layer { position: absolute; top: 0; left: 0; }
#wire-wp-svg {
  position: absolute; top: 0; left: 0;
  width: 4000px; height: 3000px; overflow: visible;
  pointer-events: none;
}
#temp-wire-svg {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; overflow: visible;
}

/* Canvas overlay UI */
#zoom-badge {
  position: absolute; bottom: 14px; left: 14px;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--text2);
  pointer-events: none;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
#wire-banner {
  position: absolute; top: 14px; left: 50%;
  transform: translateX(-50%);
  background: var(--brand);
  border-radius: 24px;
  padding: 7px 20px;
  font-size: 12px;
  color: #fff;
  font-weight: 800;
  z-index: 100;
  display: none;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(235,95,79,.4);
  letter-spacing: .02em;
  animation: bannerPop .2s ease;
}
#wire-banner.show { display: block; }
@keyframes bannerPop {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Empty canvas hint */
#canvas-hint {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
  z-index: 1;
}
#canvas-hint.hidden { display: none; }
.hint-icon { font-size: 56px; margin-bottom: 12px; opacity: .25; }
.hint-title {
  font-size: 18px; font-weight: 800;
  color: var(--text3); margin-bottom: 6px;
}
.hint-sub { font-size: 13px; color: var(--text4); font-weight: 600; }

/* ─── COMPONENT NODES ────────────────────────────────────── */
.cnode {
  position: absolute;
  cursor: move;
  user-select: none;
  transition: filter .15s;
  /* No background — SVGs render transparently */
}
.cnode:hover { filter: drop-shadow(0 2px 8px rgba(0,0,0,.25)); }
.cnode.selected { filter: drop-shadow(0 0 0 2px var(--brand)) drop-shadow(0 4px 14px rgba(235,95,79,.3)); }

/* Port handle dots on RGX board */
.port-handle {
  position: absolute;
  border-radius: 3px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, box-shadow .15s;
  z-index: 10;
  border: 2px solid;
}
/* Horizontal (top/bottom ports): wide rectangle centered on outer edge */
.port-handle[data-side="top"],
.port-handle[data-side="bottom"] { width: 20px; height: 13px; transform: translate(-50%, -50%); }
/* Vertical (left/right ports): tall rectangle centered on outer edge */
.port-handle[data-side="left"],
.port-handle[data-side="right"]  { width: 13px; height: 20px; transform: translate(-50%, -50%); }
.port-handle.dig {
  background: rgba(217,119,6,.15);
  border-color: var(--yellow);
  color: var(--yellow);
}
.port-handle.ana {
  background: rgba(220,38,38,.12);
  border-color: var(--red);
  color: var(--red);
}
.port-handle.mix {
  background: rgba(234,88,12,.12);
  border-color: var(--orange);
  color: var(--orange);
}
.port-handle:hover { transform: translate(-50%, -50%) scale(1.4); box-shadow: 0 0 0 4px rgba(235,95,79,.25); }
.port-handle.connected {
  background: rgba(37,99,235,.15);
  border-color: var(--blue);
}
.port-handle.wiring-target {
  background: rgba(22,163,74,.2);
  border-color: var(--green);
  animation: portPulse .6s ease-in-out infinite;
}
.port-handle.active {
  background: rgba(22,163,74,.2);
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(22,163,74,.2);
  animation: portPulse .9s ease-in-out infinite;
}
@keyframes portPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(22,163,74,.2); }
  50%       { box-shadow: 0 0 0 7px rgba(22,163,74,.08); }
}
.port-glow {
  position: absolute;
  transform: translate(-50%, -50%); /* always centered on anchor for glow effect */
  width: 30px; height: 30px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(22,163,74,.5) 0%, transparent 70%);
  animation: glowPulse 1s ease-in-out infinite;
  opacity: 0; transition: opacity .25s;
}
.port-glow.active { opacity: 1; }
@keyframes glowPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%       { transform: translate(-50%, -50%) scale(1.7); }
}

/* Module connector handle */
.mod-handle {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 22px; height: 14px;
  border-radius: 4px;
  cursor: pointer;
  z-index: 10;
  border: 2px solid var(--brand);
  background: var(--brand-light);
  transition: all .15s;
  box-shadow: 0 2px 6px rgba(235,95,79,.3);
}
.mod-handle:hover {
  background: var(--brand);
  transform: translate(-50%, -50%) scale(1.3);
  box-shadow: 0 4px 12px rgba(235,95,79,.5);
}
.mod-handle.connected {
  border-color: var(--green);
  background: var(--green-light);
  box-shadow: 0 2px 6px rgba(22,163,74,.3);
}
.mod-handle.wiring {
  border-color: var(--brand);
  background: var(--brand);
  animation: wiringPulse .7s ease-in-out infinite;
}
@keyframes wiringPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(235,95,79,.3); transform: translate(-50%,-50%) scale(1.1); }
  50%       { box-shadow: 0 0 0 8px rgba(235,95,79,.1); transform: translate(-50%,-50%) scale(1.3); }
}

/* Node delete button */
.node-del {
  position: absolute; top: -10px; right: -10px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid #fff;
  color: #fff;
  font-size: 12px; font-weight: 800;
  cursor: pointer;
  display: none; align-items: center; justify-content: center;
  z-index: 25;
  box-shadow: 0 2px 8px rgba(220,38,38,.4);
  line-height: 1;
  transition: all .1s;
}
.cnode:hover .node-del { display: flex; }
.node-del:hover { background: #b91c1c; transform: scale(1.15); }

/* Connection chip label on module */
.conn-chip {
  position: absolute;
  background: var(--blue);
  border-radius: 12px;
  padding: 3px 9px;
  font-size: 9px;
  font-family: var(--mono);
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 2px 6px rgba(37,99,235,.3);
}

/* ─── RIGHT SIDEBAR ──────────────────────────────────────── */
#sidebar-r {
  width: 226px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: -2px 0 8px rgba(0,0,0,.04);
}
.prop-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
}
.prop-empty .icon { font-size: 36px; margin-bottom: 10px; opacity: .4; display: block; }
.prop-group { padding: 12px 14px; }
.prop-title {
  font-size: 13px; font-weight: 800;
  color: var(--text); margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.prop-title-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand);
  flex-shrink: 0;
}
.prop-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.prop-row:last-child { border: none; }
.pk { color: var(--text3); font-weight: 600; }
.pv { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--text); }
.pv.hi { color: var(--green); }
.pv.lo { color: var(--red); }
.pv.pw { color: var(--orange); }
.pv.conn { color: var(--blue); }

/* Pin state grid */
.pin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px 12px 12px;
}
.pin-chip {
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  display: flex; align-items: center; gap: 5px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
}
.pin-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text4); flex-shrink: 0;
}
.pin-dot.hi { background: var(--green); box-shadow: 0 0 5px rgba(22,163,74,.5); }
.pin-dot.pw { background: var(--orange); box-shadow: 0 0 5px rgba(234,88,12,.5); }
.pin-name { color: var(--text2); }
.pin-val { margin-left: auto; color: var(--text3); }

/* Wire list */
.wire-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  font-size: 11px; font-weight: 700;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.wire-item:hover { background: var(--bg3); }
.wire-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--blue);
  flex-shrink: 0;
  border: 1.5px solid rgba(37,99,235,.3);
}
.wire-dot.active {
  background: var(--green);
  border-color: rgba(22,163,74,.3);
  box-shadow: 0 0 5px rgba(22,163,74,.5);
}
.wire-lbl { font-family: var(--mono); font-size: 10px; color: var(--text2); }

/* ─── BOTTOM PANEL ───────────────────────────────────────── */
#bottom {
  height: 300px;
  min-height: 80px;
  background: var(--panel);
  border-top: 2px solid var(--border);
  display: flex;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 -4px 16px rgba(0,0,0,.06);
}
#resize-bar {
  position: absolute; top: -3px; left: 0; right: 0;
  height: 7px; cursor: ns-resize; z-index: 10;
  border-radius: 4px;
}
#resize-bar:hover { background: var(--brand-mid); }

#btabs {
  display: flex;
  flex-direction: column;
  width: 36px;
  background: var(--bg3);
  border-right: 1px solid var(--border);
  align-items: center;
  padding-top: 10px;
  gap: 4px;
}
.btab {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  padding: 10px 5px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text3);
  cursor: pointer;
  border-radius: 4px;
  transition: all .15s;
  border: none; background: transparent;
}
.btab.active { color: var(--brand); }
.btab:hover { color: var(--text2); background: var(--bg4); }

#bcontent { flex: 1; display: flex; min-width: 0; }

/* Code editor */
#editor-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#editor-bar {
  height: 38px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 12px; gap: 6px; flex-shrink: 0;
}
.eb-lbl {
  font-size: 10px; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text3); margin-right: 4px;
}
.eb-filename {
  font-size: 11px; font-weight: 700;
  color: var(--text2);
  font-family: var(--mono);
  padding: 2px 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 5px;
}
.ebtn {
  height: 26px; padding: 0 10px;
  border-radius: 6px;
  border: 1.5px solid var(--border2);
  background: var(--bg2);
  color: var(--text2);
  font-family: var(--font);
  font-size: 11px; font-weight: 700;
  cursor: pointer; transition: all .12s;
}
.ebtn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }
.ebtn.erun { background: var(--green-light); border-color: var(--green); color: var(--green); }
.ebtn.estop { background: var(--red-light); border-color: var(--red); color: var(--red); }
.ex-label {
  font-size: 10px; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text3); margin-left: 8px;
}
#code-ed {
  flex: 1;
  background: #1E1E2E;
  color: #CDD6F4;
  font-family: var(--mono);
  font-size: 12.5px; line-height: 1.7;
  padding: 12px 16px;
  border: none; outline: none;
  resize: none; overflow: auto;
  tab-size: 2;
}

/* Console */
#console-wrap {
  width: 340px; flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
}
#cons-hdr {
  height: 38px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 12px; gap: 7px; flex-shrink: 0;
}
.chdr-lbl {
  font-size: 10px; font-weight: 800;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text3);
}
#cons-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text4);
  flex-shrink: 0;
}
.clr-btn {
  margin-left: auto;
  font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 5px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text3); cursor: pointer;
  font-family: var(--font);
  transition: all .12s;
}
.clr-btn:hover { color: var(--red); border-color: var(--red); background: var(--red-light); }
#cons-out {
  flex: 1; overflow-y: auto;
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 11px; line-height: 1.7;
  background: #1E1E2E;
  color: #CDD6F4;
}
.ll { color: #A6ADC8; margin-bottom: 1px; }
.ll.info { color: #89DCEB; }
.ll.warn { color: #F9E2AF; }
.ll.err  { color: #F38BA8; }
.ll.ok   { color: #A6E3A1; }
.lts { color: #6C7086; margin-right: 7px; font-size: 9px; }

/* Serial */
#serial-wrap {
  width: 280px; flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: none; flex-direction: column;
}
#serial-wrap.vis { display: flex; }
#serial-out {
  flex: 1; overflow-y: auto;
  padding: 8px 12px;
  font-family: var(--mono); font-size: 11px; line-height: 1.7;
  background: #1E1E2E;
  color: #A6E3A1;
}
#serial-inp-row {
  display: flex; border-top: 1px solid var(--border); height: 34px;
}
#serial-inp {
  flex: 1; background: var(--bg3);
  border: none; outline: none;
  padding: 0 10px;
  font-family: var(--mono); font-size: 11px;
  color: var(--text);
}
#serial-inp::placeholder { color: var(--text4); }
#serial-send {
  width: 34px; background: var(--brand);
  border: none; color: #fff; cursor: pointer;
  font-size: 15px; font-weight: 700;
  transition: background .12s;
}
#serial-send:hover { background: var(--brand-dark); }

/* ─── TOOLTIP ────────────────────────────────────────────── */
#tt {
  position: fixed;
  background: var(--text);
  border-radius: var(--r);
  padding: 8px 12px;
  font-size: 12px; pointer-events: none;
  z-index: 3000; display: none;
  max-width: 180px;
  box-shadow: var(--shadow-lg);
}
#tt.show { display: block; }
.tt-port {
  font-weight: 800; color: #fff;
  font-family: var(--mono); margin-bottom: 4px;
  font-size: 13px;
}
.tt-pins { font-family: var(--mono); font-size: 11px; }
.tt-pin {
  display: flex; align-items: center; gap: 6px;
  padding: 1px 0;
}
.ttpd { color: #FCD34D; font-weight: 700; }
.ttpa { color: #FCA5A5; font-weight: 700; }
.ttpp {
  color: #FED7AA; font-size: 9px; font-weight: 800;
  background: rgba(255,255,255,.1);
  padding: 1px 5px; border-radius: 4px;
}
.tt-note { font-size: 10px; color: #A6E3A1; margin-top: 3px; font-weight: 700; }

/* ─── CONTEXT MENU ───────────────────────────────────────── */
#ctx {
  position: fixed;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--r2);
  padding: 5px 0;
  z-index: 3000; display: none;
  min-width: 160px;
  box-shadow: var(--shadow-lg);
}
#ctx.show { display: block; }
.ci {
  padding: 8px 14px; font-size: 12px; font-weight: 700;
  cursor: pointer; color: var(--text2);
  display: flex; align-items: center; gap: 8px;
  transition: background .1s;
  border-radius: 6px; margin: 2px 4px;
}
.ci:hover { background: var(--bg3); color: var(--text); }
.ci.dng:hover { background: var(--red-light); color: var(--red); }

/* ─── SCROLLBARS ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ─── POTENTIOMETER HALF-CIRCLE SLIDER ────────────────────── */
.pot-slider-wrap {
  position:relative; margin:0 auto;
}
.pot-knob {
  width:14px; height:14px; border-radius:50%;
  background:#EF4444; border:2.5px solid #fff;
  box-shadow:0 1px 4px rgba(0,0,0,.25);
  cursor:grab; z-index:5;
  margin:-7px 0 0 -7px;
}
.pot-knob:active { cursor:grabbing; box-shadow:0 0 0 3px rgba(239,68,68,.3); }
.pot-val {
  font-size:10px; font-weight:800; font-family:var(--mono);
  color:var(--text); pointer-events:none; white-space:nowrap;
}
.pot-deg {
  font-size:8px; font-weight:600; font-family:var(--font);
  color:var(--text3); pointer-events:none; white-space:nowrap;
}

/* ─── RESPONSIVE TOUCH ───────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar-l { width: 180px; }
  #sidebar-r { width: 190px; }
}
