/* ══════════════════════════════════════════════════════
   LogicBench — Digital Logic Simulator
   Designed for DLD University Students
   Color scheme: Deep navy + Teal accent + Amber highlight
   ══════════════════════════════════════════════════════ */

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

:root {
  /* Canvas & backgrounds */
  --bg-canvas: #0b0f14;
  --bg-chrome: #0f1520;
  --bg-panel: #131b27;
  --bg-raised: #1a2336;
  --bg-hover: #1e2a3e;
  --bg-active: #243048;
  --bg-input: #0f1520;
  --bg-tooltip: #1a2336;
  --bg-ctx-menu: #141e2e;

  /* Teal accent (primary)  */
  --teal-100: #b2f5ea;
  --teal-300: #4fd1c5;
  --teal-400: #38b2ac;
  --teal-500: #2c9e98;
  --teal-600: #20736e;
  --teal-700: #145450;

  /* Amber accent (secondary / highlight) */
  --amber-300: #fbd38d;
  --amber-400: #f6ad55;
  --amber-500: #ed8936;

  /* Status colors */
  --green-400: #48bb78;
  --green-sim: #38a169;
  --red-400: #fc8181;
  --red-500: #e53e3e;
  --blue-400: #63b3ed;
  --purple-400: #b794f4;

  /* Borders */
  --border-hard: #0a0e14;
  --border-soft: #1e2a3e;
  --border-mid: #263348;

  /* Text */
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --text-accent: #4fd1c5;
  --text-warn: #f6ad55;

  /* Shadows */
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);

  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  color-scheme: dark;
}

/* ──── SCROLLBAR ──────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-chrome);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-active);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--teal-700);
}

/* ──── BODY ───────────────────────────────────────── */
body {
  background: var(--bg-canvas);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ──── APP HEADER / BRAND BAR ─────────────────────── */
#app-header {
  display: flex;
  align-items: center;
  height: 44px;
  background: var(--bg-chrome);
  border-bottom: 1px solid var(--border-hard);
  flex-shrink: 0;
  position: relative;
  z-index: 200;
  overflow: visible;
  /* Three-column layout: left | center | right */
  gap: 0;
}

/* LEFT column: brand only — auto width */
.hdr-left {
  display: flex;
  align-items: center;
  height: 100%;
  flex-shrink: 1;
}

/* CENTER column: all action buttons — grows to fill space */
.hdr-center {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 100%;
  flex: 1;
  min-width: 0;
  padding: 0 8px;
  overflow: hidden;
}

/* RIGHT column: settings + kbd hints — fixed, flush to right edge */
.hdr-right {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
  flex-shrink: 0;
  padding: 0 16px 0 8px;
  /* 16px right padding keeps last element off border */
  border-left: 1px solid var(--border-soft);
}

/* Vertical separator inside header */
.hdr-sep-v {
  width: 1px;
  height: 20px;
  background: var(--border-soft);
  flex-shrink: 0;
  margin: 0 4px;
}

/* Mode buttons group — keep together */
.hdr-pill-group {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* Export Combos — subtle highlight so it stands out as a special action */
.hdr-export-btn {
  color: var(--amber-300) !important;
  border-color: rgba(246, 173, 85, 0.2) !important;
}

.hdr-export-btn:hover {
  background: rgba(246, 173, 85, 0.08) !important;
  border-color: rgba(246, 173, 85, 0.4) !important;
  color: var(--amber-400) !important;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 100%;
  flex-shrink: 0;
  width: 177px;
  box-sizing: border-box;
  border-right: 1px solid var(--border-soft);
  border-radius: 0;
  transition: background 0.15s ease;
  user-select: none;
}

.brand:hover {
  background: var(--bg-hover);
}

.brand:hover .brand-name {
  color: var(--teal-300);
}

.brand.brand-active {
  background: var(--bg-raised);
}

.brand.brand-active .brand-name {
  color: var(--teal-300);
}

.brand-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  letter-spacing: 0.3px;
  transition: color 0.15s;
}

.brand-version {
  font-size: 9px;
  color: var(--text-muted);
  padding: 1px 4px;
  background: var(--bg-raised);
  border-radius: 3px;
  border: 1px solid var(--border-soft);
}

/* Circuit name */
#circuit-name-wrap {
  display: flex;
  align-items: center;
  padding: 0 8px 0 14px;
  height: 100%;
  flex-shrink: 0;
}

#circuit-name {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 3px 6px;
  width: 110px;
  outline: none;
  transition: border-color .15s, background .15s, color .15s;
}

#circuit-name:hover {
  border-color: var(--border-mid);
  background: var(--bg-raised);
}

#circuit-name:focus {
  border-color: var(--teal-500);
  background: var(--bg-raised);
  color: var(--text-primary);
}

/* Mode buttons */
.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: all .15s;
  height: 28px;
  flex-shrink: 0;
}

.mode-btn .btn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background .15s;
}

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

.mode-btn.active.draw {
  background: linear-gradient(135deg, #1a3a5c, #163248);
  border-color: var(--blue-400);
  color: var(--blue-400);
}

.mode-btn.active.draw .btn-dot {
  background: var(--blue-400);
}

.mode-btn.active.simulate {
  background: linear-gradient(135deg, #1a3a2a, #143220);
  border-color: var(--green-400);
  color: var(--green-400);
}

.mode-btn.active.simulate .btn-dot {
  background: var(--green-400);
  box-shadow: 0 0 6px var(--green-400);
}

/* Toolbar buttons */
.tb-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  height: 28px;
  transition: all .12s;
  white-space: nowrap;
  flex-shrink: 0;
}

.tb-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-soft);
}

.tb-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.tb-btn .tb-icon {
  font-size: 13px;
  opacity: 0.8;
}

.tb-icon-btn {
  width: 28px;
  padding: 0;
  justify-content: center;
}

/* Keyboard hints in header right */
#kbd-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}

.kbd-pair {
  display: flex;
  align-items: center;
  gap: 3px;
}

.kbd-lbl {
  font-size: 10px;
  color: var(--text-muted);
}

kbd {
  font-family: monospace;
  font-size: 9px;
  padding: 1px 4px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 3px;
  color: var(--text-secondary);
}

/* Settings button with gear icon */
.settings-btn {
  gap: 5px;
  color: var(--text-secondary);
}

.settings-btn:hover {
  color: var(--teal-400);
}

.settings-gear {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.75;
  transition: transform 0.3s ease, opacity 0.15s;
}

.settings-btn:hover .settings-gear {
  transform: rotate(45deg);
  opacity: 1;
}

/* Settings wrap — relative anchor for the dropdown */
.settings-wrap {
  position: relative;
  flex-shrink: 0;
  z-index: 3000;
}

/* ─── SETTINGS MAIN MENU ──────────────────────────── */
.settings-menu {
  display: none;
  position: fixed;
  /* fixed so it always renders above canvas */
  min-width: 175px;
  background: var(--bg-ctx-menu);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.05);
  z-index: 99999;
  padding: 6px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.settings-menu.show {
  display: block;
  animation: menuFadeIn 0.12s ease;
}

@keyframes menuFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.settings-sep {
  height: 1px;
  background: var(--border-soft);
  margin: 4px 4px;
}

.settings-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: 7px;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  user-select: none;
}

.settings-item-icon {
  font-size: 12px;
  flex-shrink: 0;
}

.settings-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.settings-arrow {
  color: var(--text-muted);
  margin-left: auto;
  font-size: 13px;
  font-weight: 300;
  transition: transform 0.15s;
}

.settings-item:hover .settings-arrow {
  transform: translateX(2px);
  color: var(--teal-400);
}

/* ─── SETTINGS SUBMENUS ───────────────────────────── */
/* Submenus live at body level in the HTML so they're never clipped.
   They're controlled purely by JS (add/remove .sub-visible). */
.settings-submenu {
  position: fixed;
  display: none;
  /* hidden by default */
  min-width: 180px;
  background: var(--bg-ctx-menu);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.05);
  padding: 6px;
  z-index: 100000;
  /* above everything */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.settings-submenu.sub-visible {
  display: block;
  animation: menuFadeIn 0.1s ease;
}

/* A transparent "bridge" that connects the menu-item to the submenu
   so the mouse can travel between them without triggering mouseleave */
.settings-submenu::before {
  content: '';
  position: fixed;
  /* will be set by JS per submenu open */
  top: 0;
  left: -20px;
  width: 24px;
  height: 100%;
  background: transparent;
}

.submenu-title {
  padding: 3px 8px 5px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 4px;
}

.settings-subitem {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  padding: 6px 8px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.settings-subitem:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-soft);
}

.settings-subitem.active {
  color: var(--teal-300);
  border-color: rgba(79, 209, 197, 0.25);
  background: rgba(79, 209, 197, 0.07);
}

.bg-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
  background-clip: padding-box;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Legacy tb-group (still used in some places) */
.tb-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 6px;
  height: 100%;
  border-right: 1px solid var(--border-soft);
  flex-shrink: 0;
}


/* ──── MAIN AREA ──────────────────────────────────── */
#main {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

/* ──── SIDEBAR / TOOLBOX ──────────────────────────── */
#sidebar {
  width: 176px;
  min-width: 176px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-hard);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

/* Search bar */
#tool-search-wrap {
  padding: 8px 8px 6px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

#tool-search {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 11px;
  padding: 5px 8px 5px 26px;
  outline: none;
  transition: border-color .15s;
}

#tool-search:focus {
  border-color: var(--teal-500);
}

.search-icon {
  position: absolute;
  left: 17px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

#tool-search-wrap {
  position: relative;
}

/* Scrollable tool list */
#toolbox {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 6px 12px;
}

/* Category header */
.cat-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 6px 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  border-radius: 4px;
  transition: color .1s;
}

.cat-header:hover {
  color: var(--text-secondary);
}

.cat-header .arrow {
  font-size: 8px;
  transition: transform .15s;
}

.cat-header .cat-icon {
  font-size: 12px;
  opacity: 0.7;
}

.cat-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 2px;
  padding-left: 2px;
}

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

.tool-hidden {
  display: none !important;
}

/* Tool button */
.tool-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all .1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 30px;
}

.tool-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-soft);
}

.tool-btn.active {
  background: linear-gradient(135deg, #0d2d2b, #0a2422);
  color: var(--teal-300);
  border-color: var(--teal-600);
  font-weight: 600;
}

.tool-btn .tool-icon {
  font-size: 14px;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

/* Wire color swatch */
.wire-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ──── CANVAS AREA ────────────────────────────────── */
#canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-canvas);
  min-width: 0;
}

#sim-canvas {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  cursor: default;
}

/* ──── PROPERTIES PANEL ───────────────────────────── */
#props-panel {
  width: 210px;
  min-width: 210px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-hard);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

#props-panel.collapsed {
  width: 28px;
  min-width: 28px;
}

#props-panel.collapsed #props-body {
  opacity: 0;
  pointer-events: none;
}

#props-panel.collapsed .props-title {
  display: none;
}

#props-header {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#props-panel.collapsed #props-header {
  padding: 10px 0;
  justify-content: center;
  border-bottom-color: transparent;
}

#inspector-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s, transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  line-height: 1;
  padding: 0;
  margin-left: 4px;
}

#inspector-toggle:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.07);
}

#props-panel.collapsed #inspector-toggle {
  transform: rotate(180deg);
  margin-left: 0;
  color: var(--text-secondary);
}

#props-panel.collapsed #inspector-toggle:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.07);
}

.props-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

#props-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
}

.props-section {
  margin-bottom: 10px;
}

.props-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--teal-400);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-soft);
}

/* ── Inline row: short key=value pairs (Type, Position, Part, VCC…) ── */
.props-row {
  display: flex;
  align-items: flex-start;
  margin-bottom: 5px;
  font-size: 11px;
  gap: 0;
}

.props-lbl {
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 78px;
  padding-right: 6px;
  font-size: 10px;
  padding-top: 1px;
}

.props-val {
  color: var(--text-primary);
  text-align: left;
  word-break: break-word;
  flex: 1;
  line-height: 1.4;
}

.props-val.high {
  color: var(--green-400);
  font-weight: 600;
}

.props-val.low {
  color: var(--blue-400);
  font-weight: 600;
}

.props-val.float {
  color: var(--text-muted);
}

/* ── Block field: full-width stacked label + value for long text ── */
.props-field {
  margin-bottom: 7px;
}

.props-field-lbl {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.props-field-lbl.warn  { color: #fc8181; }
.props-field-lbl.info  { color: #76e4f7; }
.props-field-lbl.hint  { color: #68d391; }

.props-field-val {
  font-size: 10px;
  color: var(--text-secondary);
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  padding: 5px 7px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.props-field-val.warn  { color: #fbd38d; border-color: #744210; background: #1a1000; }
.props-field-val.info  { color: #76e4f7; border-color: #0d4a52; background: #001217; }
.props-field-val.hint  { color: #68d391; border-color: #1a4731; background: #001209; }
.props-field-val.mono  { font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 10px; overflow-x: auto; background: rgba(0,0,0,0.25); }

/* ── Fixed-value badge ── */
.props-fixed-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: #68d391;
  background: #001209;
  border: 1px solid #1a4731;
  border-radius: 4px;
  padding: 2px 6px;
  margin-top: 2px;
}

.props-sep {
  height: 1px;
  background: var(--border-soft);
  margin: 8px 0;
}

.props-gate-list {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.6;
  font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', ui-monospace, monospace;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
}

.props-btn {
  width: 100%;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11px;
  cursor: pointer;
  margin-top: 5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: filter .12s;
}

.props-btn:hover {
  filter: brightness(1.15);
}

.props-btn.danger {
  background: #3d1515;
  color: var(--red-400);
  border: 1px solid #5a2020;
}

.props-btn.secondary {
  background: var(--bg-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border-soft);
}

.props-btn.primary {
  background: #0d2d2b;
  color: var(--teal-300);
  border: 1px solid var(--teal-700);
}

/* ──── ARDUINO INSPECTOR ──────────────────────────── */
#arduino-sketch-editor {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  line-height: 1.5;
  tab-size: 2;
  caret-color: #48bb78;
  transition: border-color 0.15s;
}
#arduino-sketch-editor:focus {
  outline: none;
  border-color: var(--teal-500) !important;
  box-shadow: 0 0 0 2px rgba(56,178,172,0.18);
}
#arduino-serial-out {
  scrollbar-width: thin;
  scrollbar-color: #2d3748 transparent;
}
#arduino-serial-out::-webkit-scrollbar { width: 4px; }
#arduino-serial-out::-webkit-scrollbar-track { background: transparent; }
#arduino-serial-out::-webkit-scrollbar-thumb { background: #2d3748; border-radius: 2px; }

/* Arduino run-state badge */
.arduino-running-badge {
  display: inline-block;
  padding: 1px 5px;
  background: rgba(72,187,120,0.15);
  border: 1px solid #276749;
  border-radius: 3px;
  color: #48bb78;
  font-size: 9px;
  font-weight: 600;
  animation: ard-pulse 1.2s ease-in-out infinite;
}
@keyframes ard-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Arduino pin state mini-grid */
.ard-pin-cell {
  background: #0b0f14;
  border: 1px solid var(--border-mid);
  border-radius: 3px;
  padding: 2px 3px;
  text-align: center;
  transition: border-color 0.1s;
}
.ard-pin-cell.active { border-color: #48bb78; }



#statusbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: linear-gradient(180deg, var(--bg-chrome) 0%, color-mix(in srgb, var(--bg-chrome) 85%, #000) 100%);
  border-top: 1px solid var(--border-hard);
  font-size: 11.5px;
  flex-shrink: 0;
  height: 30px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

#status-msg {
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.25s ease;
  letter-spacing: 0.01em;
}

#status-msg.hint-wire {
  color: var(--text-primary);
}

#status-msg.hint-idle {
  color: var(--text-muted);
  font-style: italic;
}

#status-msg.hint-welcome {
  color: var(--text-secondary);
}

#status-msg .st-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 5px;
  margin-bottom: 1px;
  box-shadow: 0 0 4px currentColor;
}

#status-msg kbd {
  display: inline-block;
  padding: 2px 4px;
  height: auto;
  line-height: 1;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  font-family: monospace;
  font-size: 10px;
  color: var(--text-primary);
  letter-spacing: 0;
  margin: 0 1px;
  vertical-align: text-bottom;
  transform: translateY(1px);
}

#status-msg .st-sep {
  color: var(--text-muted);
  margin: 0 4px;
}

#status-msg strong {
  color: var(--text-primary);
  font-weight: 600;
}

#status-warn {
  color: var(--amber-400);
  flex-shrink: 0;
  font-size: 10px;
}

#status-coords {
  color: var(--text-muted);
  flex-shrink: 0;
  font-family: monospace;
  font-size: 10px;
}

.status-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  height: 16px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.status-chip.draw {
  background: rgba(99, 179, 237, 0.1);
  color: var(--blue-400);
  border: 1px solid rgba(99, 179, 237, 0.2);
}

.status-chip.simulate {
  background: rgba(72, 187, 120, 0.1);
  color: var(--green-400);
  border: 1px solid rgba(72, 187, 120, 0.2);
  animation: pulse-sim 2s ease-in-out infinite;
}

@keyframes pulse-sim {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(72, 187, 120, 0);
  }

  50% {
    box-shadow: 0 0 6px 2px rgba(72, 187, 120, 0.2);
  }
}

.status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* ──── CONTEXT MENU ───────────────────────────────── */
#ctx-menu {
  position: fixed;
  background: var(--bg-ctx-menu);
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  padding: 4px;
  min-width: 180px;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  display: none;
}

#ctx-menu.show {
  display: block;
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background .08s;
}

.ctx-item:hover {
  background: var(--bg-hover);
}

.ctx-item .ctx-icon {
  font-size: 13px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.ctx-item .ctx-kbd {
  margin-left: auto;
  font-size: 9px;
  color: var(--text-muted);
  font-family: monospace;
  padding: 1px 4px;
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: 3px;
}

.ctx-sep {
  height: 1px;
  background: var(--border-soft);
  margin: 4px 2px;
}

.ctx-item.danger {
  color: var(--red-400);
}

.ctx-item.danger:hover {
  background: rgba(252, 129, 129, 0.08);
}

.ctx-header {
  padding: 4px 10px 2px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 700;
}

/* ──── MODAL ──────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(3px);
}

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-mid);
  border-radius: 12px;
  padding: 24px;
  min-width: 340px;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

.modal-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  margin-bottom: 16px;
  transition: border-color .15s;
}

.modal-input:focus {
  border-color: var(--teal-500);
}

.modal-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 7px 16px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter .12s;
}

.modal-btn:hover {
  filter: brightness(1.1);
}

.modal-btn.cancel {
  background: var(--bg-raised);
  color: var(--text-secondary);
  border-color: var(--border-soft);
}

.modal-btn.ok {
  background: linear-gradient(135deg, var(--teal-600), var(--teal-700));
  color: #fff;
}

/* ──── WIRE PROPERTIES DIALOG ─────────────────────── */
.wire-color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.wcp-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .12s, transform .1s;
}

.wcp-swatch:hover {
  transform: scale(1.1);
}

.wcp-swatch.selected {
  border-color: #fff;
}

/* ──── EXPORT PROGRESS ────────────────────────────── */
#export-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000;
  display: none;
  backdrop-filter: blur(4px);
}

#export-overlay.show {
  display: flex;
}

.export-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-mid);
  border-radius: 14px;
  padding: 32px 40px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  min-width: 320px;
}

.export-card h3 {
  font-size: 18px;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.export-card p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.export-progress-bar {
  height: 6px;
  background: var(--bg-raised);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}

.export-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal-500), var(--amber-400));
  border-radius: 3px;
  transition: width .2s ease;
  width: 0%;
}

.export-progress-text {
  font-size: 11px;
  color: var(--text-muted);
}

/* ──── ANNOTATION / NOTE ──────────────────────────── */
.note-textarea {
  resize: none;
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 12px;
  padding: 8px;
  outline: none;
  font-family: 'Segoe UI', sans-serif;
  margin-bottom: 12px;
}

.note-textarea:focus {
  border-color: var(--teal-500);
}

/* ──── TOOLTIP ────────────────────────────────────── */
.lb-tooltip {
  position: fixed;
  background: var(--bg-tooltip);
  border: 1px solid var(--border-mid);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text-primary);
  pointer-events: none;
  z-index: 9998;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

/* zoom-indicator replaced by #zoom-panel */

/* ──── MINI CHIP BADGE ────────────────────────────── */
.chip-type-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.4px;
}

.badge-ic {
  background: rgba(79, 209, 197, 0.15);
  color: var(--teal-300);
  border: 1px solid rgba(79, 209, 197, 0.25);
}

.badge-input {
  background: rgba(246, 173, 85, 0.12);
  color: var(--amber-300);
  border: 1px solid rgba(246, 173, 85, 0.2);
}

.badge-out {
  background: rgba(252, 129, 129, 0.12);
  color: var(--red-400);
  border: 1px solid rgba(252, 129, 129, 0.2);
}

.badge-power {
  background: rgba(252, 129, 129, 0.12);
  color: #fc8181;
  border: 1px solid rgba(252, 129, 129, 0.15);
}

/* ──── MISC ───────────────────────────────────────── */
.no-select-msg {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 20px 0;
}

.no-select-icon {
  font-size: 28px;
  opacity: 0.3;
}

/* ──── OVERVOLTAGE WARNING ANIMATION ─────────────── */
@keyframes overvoltage-appear {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ──── MODAL STYLES ──────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}

.modal {
  background: rgba(19, 27, 39, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 24px 28px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-primary);
}

.modal-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
}

.modal-input:focus {
  outline: none;
  border-color: var(--teal-500);
}

.modal-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 7px 18px;
  border-radius: 6px;
  border: 1px solid var(--border-mid);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}

.modal-btn.cancel {
  background: var(--bg-raised);
  color: var(--text-secondary);
}

.modal-btn.cancel:hover {
  background: var(--bg-hover);
}

.modal-btn.ok {
  background: var(--teal-500);
  color: #0a0f14;
  border-color: var(--teal-500);
}

.modal-btn.ok:hover {
  opacity: 0.88;
}

.modal select,
.modal input[type=number] {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-mid);
}

.modal label {
  color: var(--text-secondary);
}

/* ═══════════════ DEVELOPER INFO PANEL ═══════════════ */

.dev-info-wrap {
  position: relative;
  flex-shrink: 0;
  z-index: 3000;
}

.dev-info-btn {
  position: relative;
}

.dev-info-btn::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: var(--teal-400);
  border-radius: 2px;
  transition: width 0.2s ease;
}

.dev-info-btn.active::after,
.dev-info-btn:hover::after {
  width: 70%;
}

.dev-info-btn.active {
  color: var(--teal-300) !important;
  border-color: var(--teal-600) !important;
}

/* ── The floating panel ─────────────────────────────── */
.dev-info-panel {
  display: none;
  position: fixed;
  width: 300px;
  background: var(--bg-ctx-menu);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.06);
  z-index: 99999;
  overflow: hidden;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.dev-info-panel.show {
  display: block;
  animation: devPanelIn 0.18s cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes devPanelIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Header with avatar ─────────────────────────────── */
.dev-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px;
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.12), rgba(56, 178, 172, 0.05));
  border-bottom: 1px solid var(--border-soft);
  position: relative;
}

.dev-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(45, 212, 191, 0.3);
  border: 2px solid rgba(45, 212, 191, 0.4);
}

.dev-title-block {
  flex: 1;
  min-width: 0;
}

.dev-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dev-role {
  font-size: 11px;
  color: var(--teal-400);
  margin-top: 2px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.dev-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.dev-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ── Body ───────────────────────────────────────────── */
.dev-panel-body {
  padding: 14px 16px;
}

.dev-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}

.dev-info-icon {
  font-size: 14px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.dev-link {
  font-size: 12px;
  color: var(--teal-300);
  text-decoration: none;
  transition: color 0.15s;
  word-break: break-all;
}

.dev-link:hover {
  color: var(--teal-200);
  text-decoration: underline;
}

.dev-sep {
  height: 1px;
  background: var(--border-soft);
  margin: 10px 0;
}

.dev-project-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.dev-project-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.dev-bug-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(239, 68, 68, 0.07);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
}

.dev-bug-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.dev-bug-title {
  font-size: 12px;
  font-weight: 600;
  color: #fca5a5;
  margin-bottom: 2px;
}

.dev-bug-sub {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Footer ─────────────────────────────────────────── */
.dev-panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border-soft);
}

.dev-footer-badge {
  font-size: 10.5px;
  color: var(--teal-400);
  font-weight: 500;
}

.dev-version-tag {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-raised);
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  font-family: monospace;
}
/* ══════════════════════════════════════════════════════
   WELCOME MODAL — First-visit onboarding
   ══════════════════════════════════════════════════════ */

/* Backdrop overlay */
#welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 10, 16, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  animation: wb-fade-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.25s forwards;
}

@keyframes wb-fade-in {
  to { opacity: 1; }
}

/* Modal card */
#welcome-modal {
  position: relative;
  width: min(400px, 92vw);
  background: linear-gradient(145deg, #131b27 0%, #0f1826 60%, #0b1520 100%);
  border: 1px solid rgba(56, 178, 172, 0.28);
  border-radius: 20px;
  padding: 22px 24px 18px;
  max-height: min(92vh, 700px);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow:
    0 0 0 1px rgba(56,178,172,0.08),
    0 24px 64px rgba(0,0,0,0.7),
    0 0 80px rgba(56,178,172,0.06) inset;
  transform: translateY(28px) scale(0.96);
  animation: wb-slide-up 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.35s forwards;
  overflow: hidden;
}

@keyframes wb-slide-up {
  to { transform: translateY(0) scale(1); }
}

/* Decorative circuit-line SVG background */
#welcome-modal::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 80% 15%, rgba(56,178,172,0.08) 0%, transparent 55%),
    radial-gradient(circle at 15% 85%, rgba(246,173,85,0.05) 0%, transparent 50%);
  pointer-events: none;
  border-radius: inherit;
}

/* Animated teal top-border glow */
#welcome-modal::after {
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--teal-400), var(--teal-300), var(--teal-400), transparent);
  border-radius: 2px;
  animation: wb-glow-slide 3s ease-in-out infinite;
}

@keyframes wb-glow-slide {
  0%, 100% { opacity: 0.5; left: 10%; right: 10%; }
  50%       { opacity: 1;   left: 5%;  right: 5%;  }
}

/* Icon badge */
.wb-icon-badge {
  display: block;
  width: 280px;
  max-width: 80%;
  height: auto;
  margin: 0 auto 18px;
  position: relative;
  filter: drop-shadow(0 0 14px rgba(56,178,172,0.25));
  animation: wb-pulse-ring 2.5s ease-in-out infinite;
}

@keyframes wb-pulse-ring {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(56,178,172,0.18)); }
  50%       { filter: drop-shadow(0 0 18px rgba(56,178,172,0.32)); }
}

/* Subtitle */
.wb-subtitle {
  font-size: 12.5px;
  color: var(--teal-400);
  text-align: center;
  margin-top: -6px;
  margin-bottom: 18px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 600;
  opacity: 0.85;
}

/* Thin divider */
.wb-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(56,178,172,0.2), transparent);
  margin-bottom: 18px;
}

/* Action list */
.wb-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin-bottom: 20px;
}

.wb-list-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  font-size: 12.5px;
  color: #7a8da8;
  line-height: 1.55;
}

.wb-list-item strong {
  color: #c8d6ee;
  font-weight: 700;
}

/* Colored icon bubble per item */
.wb-li-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  margin-top: 0px;
}

.wb-li-bug   { background: rgba(246,173,85,0.13);  }
.wb-li-idea  { background: rgba(183,148,244,0.13); }
.wb-li-reach { background: rgba(56,178,172,0.13);  }

.wb-li-text {
  padding-top: 4px;
}

/* Headline */
.wb-title {
  font-size: 20px;
  font-weight: 800;
  color: #e2e8f0;
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: -0.4px;
}



/* Highlight chip — for the ⚡ LogicBench reference */
.wb-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(56,178,172,0.12);
  border: 1px solid rgba(56,178,172,0.25);
  border-radius: 6px;
  color: var(--teal-300);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
}




/* ── Mobile Warning Banner ─────────────────────────── */
.wb-mobile-warning {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 4px 0 16px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(237, 137, 54, 0.15) 0%, rgba(246, 173, 85, 0.08) 100%);
  border: 1.5px solid var(--amber-500);
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  animation: wb-warning-pulse 2.5s ease-in-out infinite;
}

.wb-mobile-warning::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(246, 173, 85, 0.07) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: wb-warning-shimmer 2.5s linear infinite;
}

@keyframes wb-warning-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes wb-warning-pulse {
  0%, 100% { border-color: var(--amber-500); box-shadow: 0 0 0 0 rgba(237, 137, 54, 0); }
  50%       { border-color: var(--amber-300); box-shadow: 0 0 10px 2px rgba(246, 173, 85, 0.2); }
}

.wb-mobile-warning-icon {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px rgba(246, 173, 85, 0.6));
}

.wb-mobile-warning-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wb-mobile-warning-text strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--amber-300);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.wb-mobile-warning-text span {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.wb-mobile-warning-text em {
  color: var(--amber-400);
  font-style: normal;
  font-weight: 600;
}

/* CTA button */
.wb-btn-primary {
  display: block;
  width: 100%;
  padding: 11px 20px;
  background: linear-gradient(135deg, var(--teal-500) 0%, var(--teal-400) 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 18px rgba(56,178,172,0.3);
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}

.wb-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(56,178,172,0.45);
  filter: brightness(1.08);
}

.wb-btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(56,178,172,0.25);
}

/* "Don't show again" checkbox row */
.wb-footer-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 14px;
  font-size: 11.5px;
  color: #4a5a78;
  cursor: pointer;
  user-select: none;
}

.wb-footer-row input[type="checkbox"] {
  accent-color: var(--teal-400);
  width: 13px;
  height: 13px;
  cursor: pointer;
}

/* Modal exit animation */
#welcome-overlay.wb-closing {
  animation: wb-fade-out 0.35s cubic-bezier(0.4, 0, 1, 1) forwards;
}

#welcome-overlay.wb-closing #welcome-modal {
  animation: wb-slide-down 0.35s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes wb-fade-out  { to { opacity: 0; } }
@keyframes wb-slide-down { to { transform: translateY(20px) scale(0.97); opacity: 0; } }

/* ── Brand running border light (shown after modal dismiss) ── */

/* Animatable custom property for the conic sweep angle */
@property --wb-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

@keyframes wb-spin-border {
  to { --wb-angle: 360deg; }
}

.brand-running-light {
  position: relative;
  isolation: isolate;
}

/* The spinning conic gradient, masked to only show as a 2px border */
.brand-running-light::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  background:
    conic-gradient(
      from var(--wb-angle) at 50% 50%,
      transparent    0deg,
      rgba(56,178,172,0.15) 30deg,
      var(--teal-300) 55deg,
      #fff           65deg,
      var(--teal-300) 75deg,
      rgba(56,178,172,0.15) 100deg,
      transparent    130deg
    ) border-box;
  -webkit-mask:
    linear-gradient(#fff 0 0) padding-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: destination-out;
  mask:
    linear-gradient(#fff 0 0) padding-box,
    linear-gradient(#fff 0 0);
  mask-composite: exclude;
  animation: wb-spin-border 1.4s linear infinite;
  pointer-events: none;
  z-index: 2;
}

/* ── Compact modal on short viewports ───────────────── */
@media (max-height: 750px) {
  #welcome-modal {
    padding: 16px 20px 14px;
  }
  .wb-icon-badge {
    width: 190px;
    margin-bottom: 10px;
  }
  .wb-title {
    font-size: 20px !important;
    margin-bottom: 4px !important;
  }
  .wb-subtitle {
    font-size: 11px;
    margin-bottom: 12px;
  }
  .wb-divider {
    margin-bottom: 12px;
  }
  .wb-list {
    gap: 8px;
    margin-bottom: 14px;
  }
  .wb-list-item {
    font-size: 11.5px;
  }
  .wb-li-icon {
    width: 24px;
    height: 24px;
    font-size: 13px;
  }
  .wb-mobile-warning {
    padding: 10px 12px;
    margin: 0 0 12px;
    gap: 10px;
  }
  .wb-mobile-warning-icon {
    font-size: 20px;
  }
  .wb-mobile-warning-text strong {
    font-size: 11.5px;
  }
  .wb-mobile-warning-text span {
    font-size: 11px;
  }
  .wb-btn-primary {
    padding: 9px 16px;
    font-size: 13px;
  }
  .wb-footer-row {
    margin-top: 10px;
    font-size: 11px;
  }
}

/* ─── LOAD SPLIT-BUTTON ─────────────────────────────── */
.load-split-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
}

.load-main-btn {
  display: flex;
  align-items: center;
  gap: 0;
  border-radius: 6px 0 0 6px !important;
  border-right: none !important;
}

.load-arrow-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px !important;
  font-size: 9px;
  border-radius: 0 6px 6px 0 !important;
  border-left: 1px solid rgba(255,255,255,0.15) !important;
  min-width: unset;
  color: var(--text-secondary);
}

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

/* ─── LOAD DROPDOWN ─────────────────────────────────── */
.load-dropdown {
  display: none;
  position: fixed;
  min-width: 220px;
  background: var(--bg-ctx-menu);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.75), 0 0 0 1px rgba(255,255,255,0.05);
  z-index: 99999;
  padding: 6px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: menuFadeIn 0.12s ease;
}

.load-dropdown.show {
  display: block;
}

.load-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.1s;
}

.load-dropdown-item:hover {
  background: var(--bg-hover);
}

.load-dd-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.load-dd-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.load-dd-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.load-dd-desc {
  font-size: 10px;
  color: var(--text-muted);
}

.load-dropdown-sep {
  height: 1px;
  background: var(--border-soft);
  margin: 4px 4px;
}

/* ─── GHOST SUB-CIRCUIT OVERLAY ─────────────────────── */
/* The ghost is rendered purely on-canvas via globalAlpha, no extra CSS needed */



/* ── Zoom Panel ─────────────────────────────────────────────── */
#zoom-panel {
  position: fixed;
  bottom: 40px;
  right: 230px;
  z-index: 999;
  display: flex;
  align-items: center;
  height: 22px;
  background: #1a2336;
  border: 1px solid #263348;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  overflow: hidden;
  pointer-events: all;
  user-select: none;
}

.zoom-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.zoom-btn:hover  { background: #1e2a3e; color: #4fd1c5; }
.zoom-btn:active { background: #243048; color: #38b2ac; }

#zoom-out-btn { border-right: 1px solid #1e2a3e; }
#zoom-in-btn  { border-left:  1px solid #1e2a3e; }

.zoom-input {
  width: 42px;
  height: 22px;
  background: none;
  border: none;
  color: #e2e8f0;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  outline: none;
  cursor: default;
  padding: 0;
}
.zoom-input:focus {
  color: #4fd1c5;
  background: rgba(79,209,197,0.07);
  cursor: text;
}
.zoom-input::selection { background: rgba(79,209,197,0.28); }

/* ══════════════════════════════════════════════════════════════════
   LOGIC ANALYZER
   ══════════════════════════════════════════════════════════════════ */

.hdr-analyzer-btn {
  color: var(--text-secondary);
}
.hdr-analyzer-btn.sim-active {
  color: var(--green-400) !important;
  border-color: rgba(72, 187, 120, 0.35) !important;
  animation: pulse-sim 2s ease-in-out infinite;
}
.hdr-analyzer-btn.active {
  background: var(--bg-active) !important;
  color: var(--text-accent) !important;
  border-color: rgba(79, 209, 197, 0.4) !important;
}

/* K-Map / Boolean minimizer entry point — distinct amber accent so it reads
   as a separate tool from the teal-accented Logic Analyzer at a glance. */
.hdr-kmap-btn {
  color: var(--text-secondary);
}
.hdr-kmap-btn:hover {
  color: #f6c453;
  border-color: rgba(246, 196, 83, 0.35) !important;
}

#analyzer-panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 270px;
  min-height: 160px;
  max-height: 70vh;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-mid);
  box-shadow: 0 -8px 24px rgba(0,0,0,0.35);
  z-index: 9500;
  display: none;
  flex-direction: column;
  font-family: inherit;
  color: var(--text-primary);
}
#analyzer-panel.show { display: flex; }

#analyzer-resize-handle {
  height: 6px;
  cursor: ns-resize;
  flex-shrink: 0;
  background: transparent;
  position: relative;
}
#analyzer-resize-handle::after {
  content: '';
  position: absolute; left: 50%; top: 2px;
  width: 40px; height: 3px; margin-left: -20px;
  border-radius: 2px;
  background: var(--border-mid);
}
#analyzer-resize-handle:hover::after { background: var(--text-accent); }

#analyzer-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  background: var(--bg-chrome);
  flex-wrap: wrap;
  row-gap: 4px;
}

/* Visually clusters related controls into one chip so the toolbar reads as
   a handful of groups instead of a long flat row of buttons. */
.an-btn-group {
  display: flex;
  align-items: center;
  gap: 1px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 7px;
  padding: 2px;
  flex-shrink: 0;
}
.an-btn-group .an-btn {
  border: none;
  background: transparent;
  border-radius: 5px;
}
.an-btn-group .an-btn:hover { background: var(--bg-hover); }
.an-btn-group .an-btn.active {
  background: rgba(72, 187, 120, 0.15);
  color: var(--green-400);
}
.an-zoom-group { padding: 2px 4px; }

/* Overflow "⋯" menu — keeps rarely-used tools (screenshot export) out of
   the always-visible row without cluttering it. */
.an-more-wrap { position: relative; flex-shrink: 0; }
.an-more-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 210px;
  background: var(--bg-panel);
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.4);
  padding: 4px;
  z-index: 9600;
  flex-direction: column;
  gap: 2px;
}
.an-more-menu.show { display: flex; }
.an-more-item {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 12px;
  text-align: left;
  padding: 7px 9px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.an-more-item:hover { background: var(--bg-hover); }
.analyzer-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  margin-right: 6px;
  white-space: nowrap;
}
.an-btn {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  color: var(--text-primary);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.an-btn:hover { background: var(--bg-hover); }
.an-btn.active {
  background: rgba(72, 187, 120, 0.15);
  color: var(--green-400);
  border-color: rgba(72, 187, 120, 0.4);
}
.an-icon-btn { padding: 5px 10px; font-weight: 700; }
.an-close-btn { margin-left: auto; }
.an-sep {
  width: 1px; height: 20px;
  background: var(--border-soft);
  margin: 0 2px;
}
.an-timediv {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 62px;
  text-align: center;
}
.analyzer-cursor-readout {
  font-size: 11px;
  color: var(--text-accent);
  font-family: 'SF Mono', Consolas, monospace;
  margin-left: 8px;
  white-space: nowrap;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

#analyzer-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}
#analyzer-channel-list {
  width: 196px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-soft);
  overflow-y: auto;
  background: var(--bg-chrome);
}
.an-chan-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
}
.an-chan-row-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
.an-chan-row-bottom {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-left: 16px; /* aligns under the label, past the swatch */
}
.an-chan-swatch {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.an-chan-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}
.an-chan-val {
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  min-width: 16px;
  text-align: center;
  border-radius: 3px;
  flex-shrink: 0;
}
.an-chan-val.v1 { color: var(--green-400); }
.an-chan-val.v0 { color: var(--text-muted); }
.an-chan-val.vz { color: var(--amber-300); }
.an-chan-val.va { color: var(--text-accent, #4fd1c5); min-width: 40px; }
.an-chan-val.vi { color: #f6ad55; min-width: 40px; }
.an-chan-remove {
  cursor: pointer;
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 13px;
  line-height: 1;
}
.an-chan-remove:hover { color: #f56565; }
.an-chan-rename {
  cursor: pointer;
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 12px;
  line-height: 1;
}
.an-chan-rename:hover { color: var(--text-primary); }

/* Per-channel display-mode toggle: cycles Auto → Digital → Analog.
   Kept small and secondary so it doesn't compete with the label/value. */
.an-chan-mode {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border-mid);
  color: var(--text-secondary);
  background: var(--bg-raised);
  cursor: pointer;
  flex-shrink: 0;
}
.an-chan-mode:hover { border-color: var(--text-accent); color: var(--text-primary); }
.an-chan-mode.mode-analog { color: var(--text-accent, #4fd1c5); border-color: rgba(79,209,197,0.4); }
.an-chan-mode.mode-current { color: #f6ad55; border-color: rgba(246,173,85,0.4); }
.an-chan-mode.mode-digital { color: var(--text-secondary); }
.an-chan-range {
  font-size: 10px;
  color: var(--text-muted);
  font-family: 'SF Mono', Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Measured/exact frequency badge — shown so high-frequency signals (RTC
   SQW/32K, etc.) can be verified numerically when they're too dense to
   read visually at the current s/div zoom. */
.an-chan-freq {
  font-size: 10px;
  font-weight: 600;
  font-family: 'SF Mono', Consolas, monospace;
  color: var(--text-accent, #4fd1c5);
  background: rgba(79,209,197,0.12);
  border: 1px solid rgba(79,209,197,0.35);
  border-radius: 4px;
  padding: 0 5px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
  cursor: help;
}
/* Frequency at/beyond this capture's Nyquist limit — a specific Hz number
   would be a confident-looking alias, not a real measurement, so this is
   flagged distinctly (amber) rather than styled like a trustworthy reading. */
.an-chan-freq-warn {
  color: #f6ad55;
  background: rgba(246,173,85,0.12);
  border-color: rgba(246,173,85,0.4);
}
.an-chan-label-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-panel, #1a1f26);
  color: var(--text-primary);
  border: 1px solid var(--accent, #4fd1c5);
  border-radius: 3px;
  font-size: 12px;
  padding: 1px 4px;
}

#analyzer-wave-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#analyzer-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}
#analyzer-empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 30px;
  color: var(--text-secondary);
  font-size: 13px;
  pointer-events: none;
}
#analyzer-empty-hint strong { color: var(--text-accent); }

#analyzer-scrollbar {
  height: 16px;
  flex-shrink: 0;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-chrome);
  position: relative;
  cursor: pointer;
  padding: 3px 6px;
  box-sizing: border-box;
}
#analyzer-scrollbar-track {
  position: relative;
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.05);
  border-radius: 4px;
}
#analyzer-scrollbar-thumb {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  min-width: 14px;
  background: var(--text-accent, #4fd1c5);
  opacity: 0.55;
  border-radius: 4px;
  cursor: grab;
}
#analyzer-scrollbar-thumb:hover, #analyzer-scrollbar-thumb.dragging { opacity: 0.85; }
#analyzer-scrollbar-thumb.dragging { cursor: grabbing; }

/* ── Screenshot time-range modal ─────────────────────────────── */
.an-modal-backdrop {
  position: fixed; inset: 0; z-index: 9700;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
}
.an-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-mid);
  border-radius: 10px;
  padding: 18px 20px;
  width: 320px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  color: var(--text-primary);
  font-family: inherit;
}
.an-modal h3 { margin: 0 0 4px; font-size: 15px; }
.an-modal p { margin: 0 0 14px; font-size: 12px; color: var(--text-secondary); }
.an-modal-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.an-modal-row label { width: 46px; font-size: 12px; color: var(--text-secondary); flex-shrink: 0; }
.an-modal-row input[type="number"] {
  flex: 1;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  color: var(--text-primary);
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12px;
  font-family: 'SF Mono', Consolas, monospace;
}
.an-modal-warn {
  font-size: 11px;
  color: var(--amber-300, #f6ad55);
  background: rgba(246,173,85,0.1);
  border: 1px solid rgba(246,173,85,0.3);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 12px;
  line-height: 1.4;
}
.an-modal-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.an-modal-btns button {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  color: var(--text-primary);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.an-modal-btns button:hover { background: var(--bg-hover); }
.an-modal-btns button.primary {
  background: rgba(79,209,197,0.18);
  border-color: rgba(79,209,197,0.5);
  color: var(--text-accent, #4fd1c5);
}

body.analyzer-picking, body.analyzer-picking #sim-canvas {
  /* The probe glyph is drawn upright then rotated 45° via the inner <g>,
     which also rotates where its visual tip (the cyan dot) ends up. The
     hotspot below is expressed in POST-rotation pixel coordinates (~6,26)
     to match — previously it used the pre-rotation coordinates (16,29),
     so clicks registered several pixels off from the drawn tip and made
     probe-picking on tightly-spaced pins/wires feel imprecise. */
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><g transform="rotate(45 16 16)"><rect x="14" y="2" width="4" height="14" rx="1.5" fill="%23f6ad55" stroke="%237b341e" stroke-width="1"/><rect x="12.5" y="14" width="7" height="6" rx="1" fill="%232d3748" stroke="%23000" stroke-width="1"/><polygon points="16,20 12.5,20 16,30 19.5,20" fill="%23e2e8f0" stroke="%231a202c" stroke-width="1"/><circle cx="16" cy="29" r="1.4" fill="%2300e5ff" stroke="%23003c40" stroke-width="0.6"/></g></svg>') 6 26, crosshair !important;
}
