/* ============================================================================
   SchemCAD — 1-Click Hardware Power Rail Solutions & Startup Sequence Bar
   ("Типовухи и Цепи Питания" — Borneo-Style Quick Rail Bar + Neon Pad Overlay)
   ============================================================================ */

#railSolutionsBar {
  height: 28px;
  min-height: 28px;
  max-height: 28px;
  padding: 0 8px;
  background: linear-gradient(180deg, #101622 0%, #0c111b 100%);
  border-bottom: 1px solid #1f293b;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  position: relative;
  z-index: 18;
  user-select: none;
  font-family: var(--sans, "Inter", "Segoe UI", system-ui, sans-serif);
}

#railSolutionsBar.hidden {
  display: none !important;
}

#railSolutionsBar.is-collapsed {
  height: 24px;
  min-height: 24px;
  max-height: 24px;
  background: #0d121b;
}

/* Left Brand / Collapse Toggle */
.rs-bar-toggle {
  height: 20px;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid rgba(220, 160, 58, 0.34);
  background: rgba(220, 160, 58, 0.1);
  color: #f6ce7b;
  font-family: var(--sans, sans-serif);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.rs-bar-toggle:hover {
  background: rgba(220, 160, 58, 0.2);
  border-color: rgba(220, 160, 58, 0.62);
  color: #fde68a;
}

.rs-bar-caret {
  font-size: 9px;
  opacity: 0.82;
  line-height: 1;
  transition: transform 0.14s ease;
}

#railSolutionsBar.is-collapsed .rs-bar-caret {
  transform: rotate(-90deg);
}

.rs-collapsed-hint {
  display: none;
  font-size: 10.5px;
  color: var(--text-muted, #657287);
  font-family: var(--mono, monospace);
  white-space: nowrap;
  cursor: pointer;
}

.rs-collapsed-hint:hover {
  color: var(--text-dim, #9aa6b8);
}

#railSolutionsBar.is-collapsed .rs-collapsed-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#railSolutionsBar.is-collapsed .rs-pills-track {
  display: none !important;
}

/* Horizontal Scrollable Category Pills Strip */
.rs-pills-track {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  padding: 1px 0;
}

.rs-pills-track::-webkit-scrollbar {
  display: none;
}

.rs-cat-pill {
  --rs-cat: #38bdf8;
  --rs-cat-bg: rgba(56, 189, 248, 0.12);
  --rs-cat-bd: rgba(56, 189, 248, 0.38);
  height: 21px;
  padding: 0 7px;
  border-radius: 4px;
  border: 1px solid #243044;
  background: #151c29;
  color: #cbd5e1;
  font-family: var(--sans, sans-serif);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.rs-cat-pill:hover {
  background: #1c2536;
  border-color: var(--rs-cat-bd);
  color: #f8fafc;
}

.rs-cat-pill.active {
  background: var(--rs-cat-bg);
  border-color: var(--rs-cat);
  color: #ffffff;
  box-shadow: 0 0 10px -2px var(--rs-cat-bd), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.rs-pill-ico {
  font-size: 11px;
  line-height: 1;
}

.rs-pill-cnt {
  font-family: var(--mono, "JetBrains Mono", Consolas, monospace);
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

.rs-cat-pill.active .rs-pill-cnt {
  color: var(--rs-cat);
}

/* Right Reset Overlay Button */
.rs-clear-btn {
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  border: 1px solid rgba(239, 68, 68, 0.48);
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  font-family: var(--sans, sans-serif);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  margin-left: auto;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.rs-clear-btn:hover {
  background: rgba(239, 68, 68, 0.26);
  border-color: #f87171;
  color: #ffffff;
}

.rs-clear-btn.hidden {
  display: none !important;
}

/* ============================================================================
   Floating / Pinned Compact Category Popover Drawer
   ============================================================================ */

#railSolutionsPopover {
  position: absolute;
  top: calc(100% + 3px);
  left: 8px;
  width: min(400px, calc(100% - 16px));
  max-height: min(410px, calc(100vh - 164px));
  background: rgba(15, 20, 30, 0.97);
  backdrop-filter: blur(8px);
  border: 1px solid #334155;
  border-radius: 7px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.68), 0 0 0 1px rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 32;
  user-select: text;
}

#railSolutionsPopover.hidden {
  display: none !important;
}

.rs-pop-head {
  padding: 7px 9px;
  background: linear-gradient(180deg, #182132 0%, #131a27 100%);
  border-bottom: 1px solid #263246;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  user-select: none;
}

.rs-pop-title-wrap {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.rs-pop-title {
  font-size: 12px;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 5px;
}

.rs-pop-sub {
  font-size: 10px;
  font-family: var(--mono, monospace);
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rs-pop-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.rs-icon-btn {
  height: 22px;
  min-width: 22px;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid #2c3950;
  background: #1a2333;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.rs-icon-btn:hover {
  background: #253147;
  border-color: #475569;
  color: #f8fafc;
}

.rs-icon-btn.active {
  background: rgba(220, 160, 58, 0.18);
  border-color: rgba(220, 160, 58, 0.58);
  color: #fde68a;
}

/* Quick In-Category Filter Input */
.rs-pop-search-wrap {
  padding: 5px 8px;
  border-bottom: 1px solid #1f293a;
  background: #101622;
  flex-shrink: 0;
}

.rs-pop-search-wrap.hidden {
  display: none !important;
}

.rs-pop-search {
  width: 100%;
  height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  border: 1px solid #28354a;
  background: #0a0e16;
  color: #e2e8f0;
  font-family: var(--mono, monospace);
  font-size: 11px;
  outline: none;
}

.rs-pop-search:focus {
  border-color: var(--accent, #dca03a);
}

/* Scrollable Popover Body */
.rs-pop-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.rs-pop-body::-webkit-scrollbar {
  width: 6px;
}

.rs-pop-body::-webkit-scrollbar-thumb {
  background: #2c3a50;
  border-radius: 3px;
}

/* ============================================================================
   Power-On Sequence Stepper ("Step 1 -> Step 2 -> ...")
   ============================================================================ */

.rs-seq-section {
  padding: 7px 8px 8px;
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.08) 0%, rgba(15, 23, 36, 0.45) 100%);
  border-bottom: 1px solid #263549;
}

.rs-seq-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
  user-select: none;
}

.rs-seq-kicker {
  font-family: var(--mono, monospace);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4ade80;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.rs-seq-nav {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.rs-seq-nav-btn {
  height: 20px;
  padding: 0 6px;
  border-radius: 3px;
  border: 1px solid rgba(74, 222, 128, 0.36);
  background: rgba(22, 163, 74, 0.14);
  color: #bbf7d0;
  font-family: var(--mono, monospace);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.rs-seq-nav-btn:hover {
  background: rgba(22, 163, 74, 0.28);
  border-color: #4ade80;
  color: #ffffff;
}

.rs-seq-steps {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.rs-seq-step {
  width: 100%;
  text-align: left;
  padding: 5px 7px;
  border-radius: 5px;
  border: 1px solid #233246;
  background: #121926;
  color: #e2e8f0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: background 0.1s ease, border-color 0.1s ease;
}

.rs-seq-step:hover {
  background: #192436;
  border-color: rgba(74, 222, 128, 0.5);
}

.rs-seq-step.active {
  background: rgba(34, 197, 94, 0.16);
  border-color: #4ade80;
  box-shadow: inset 2px 0 0 #4ade80;
}

.rs-step-num {
  width: 19px;
  height: 19px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.18);
  border: 1px solid rgba(74, 222, 128, 0.55);
  color: #86efac;
  font-family: var(--mono, monospace);
  font-size: 10px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rs-seq-step.active .rs-step-num {
  background: #22c55e;
  border-color: #86efac;
  color: #052e16;
}

.rs-step-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.rs-step-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.rs-step-stage {
  font-size: 11px;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rs-step-expect {
  font-family: var(--mono, monospace);
  font-size: 9.5px;
  color: #fde68a;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 3px;
  padding: 0 4px;
  flex-shrink: 0;
}

.rs-step-bot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono, monospace);
  font-size: 10px;
  color: #86efac;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rs-step-ics {
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================================
   Matched Category Nets List
   ============================================================================ */

.rs-list-sec-label {
  padding: 5px 9px 3px;
  font-family: var(--mono, monospace);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  background: #0e141f;
  border-bottom: 1px solid #192232;
}

.rs-net-list {
  display: flex;
  flex-direction: column;
}

.rs-net-row {
  width: 100%;
  text-align: left;
  padding: 6px 9px;
  border: none;
  border-bottom: 1px solid rgba(38, 50, 70, 0.65);
  border-left: 2px solid transparent;
  background: transparent;
  color: #e2e8f0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.1s ease, border-left-color 0.1s ease;
}

.rs-net-row:hover {
  background: #182234;
}

.rs-net-row.active {
  background: rgba(220, 160, 58, 0.14);
  border-left-color: var(--accent, #dca03a);
}

.rs-net-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rs-net-title-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.rs-net-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  flex-shrink: 0;
  background: #475569;
}

.rs-net-dot.is-glow {
  box-shadow: 0 0 7px currentColor;
}

.rs-net-name {
  font-family: var(--mono, "JetBrains Mono", Consolas, monospace);
  font-size: 11.5px;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rs-net-tier-tag {
  font-family: var(--mono, monospace);
  font-size: 9px;
  font-weight: 700;
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.36);
  color: #fcd34d;
  flex-shrink: 0;
}

.rs-net-meta-line {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rs-net-ics {
  font-family: var(--mono, monospace);
  font-size: 10px;
  color: #7dd3fc;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rs-net-right {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.rs-net-pins {
  font-family: var(--mono, monospace);
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 1px 5px;
  border-radius: 3px;
  background: #192231;
  border: 1px solid #2b384e;
  color: #cbd5e1;
}

.rs-net-side {
  font-family: var(--mono, monospace);
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(59, 130, 246, 0.13);
  border: 1px solid rgba(59, 130, 246, 0.34);
  color: #93c5fd;
}

.rs-empty-filter {
  padding: 14px 10px;
  text-align: center;
  font-size: 11px;
  color: #64748b;
}

/* ============================================================================
   Transparent Pointer-Events-None Canvas Overlay (#railSolutionsOverlay)
   ============================================================================ */

.canvas-stage #railSolutionsOverlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none !important;
  touch-action: none;
  z-index: 3;
}

.canvas-stage #railSolutionsOverlay.hidden {
  display: none !important;
}

/* Mobile & Responsive Adaptations */
@media (max-width: 900px) {
  body:not([data-mob-has-board="1"]) #railSolutionsBar,
  body[data-mob-home-open="1"] #railSolutionsBar {
    display: none !important;
  }

  #railSolutionsPopover {
    left: 6px !important;
    right: 6px !important;
    width: auto !important;
    max-height: min(56vh, 360px);
  }

  .rs-bar-toggle-txt {
    display: none;
  }
}
