:root {
  --vs-bg-0: #0b0e14;
  --vs-bg-1: #111622;
  --vs-bg-2: #171e2e;
  --vs-bg-3: #1e273b;
  --vs-border: #263147;
  --vs-border-hi: #3a4a6b;
  --vs-text-0: #f1f5f9;
  --vs-text-1: #cbd5e1;
  --vs-text-muted: #94a3b8;
  --vs-accent: #38bdf8;
  --vs-emerald: #10b981;
  --vs-emerald-bg: rgba(16, 185, 129, 0.14);
  --vs-amber: #f59e0b;
  --vs-amber-bg: rgba(245, 158, 11, 0.14);
  --vs-coral: #f43f5e;
  --vs-coral-bg: rgba(244, 63, 94, 0.16);
  --vs-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --vs-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--vs-bg-0);
  color: var(--vs-text-0);
  font-family: var(--vs-sans);
  font-size: 12px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.vs-shell {
  display: grid;
  grid-template-rows: 40px 1fr 26px;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
  background: var(--vs-bg-0);
  color: var(--vs-text-0);
}

.vs-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 40px;
  padding: 0 10px;
  background: var(--vs-bg-1);
  border-bottom: 1px solid var(--vs-border);
  white-space: nowrap;
  overflow: hidden;
}

.vs-topbar-left,
.vs-topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.vs-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--vs-text-0);
  letter-spacing: -0.01em;
}

.vs-trust-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--vs-emerald-bg);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.vs-trust-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--vs-emerald);
  flex-shrink: 0;
}

.vs-body {
  display: flex;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.vs-rail-left,
.vs-rail-right {
  width: var(--vs-rail-width, 240px);
  flex-shrink: 0;
  background: var(--vs-bg-1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  gap: 8px;
}

.vs-rail-left {
  border-right: 1px solid var(--vs-border);
}

.vs-rail-right {
  border-left: 1px solid var(--vs-border);
}

.vs-collapsed {
  display: none !important;
}

.vs-stage {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--vs-bg-0);
}

/* Keep the stage visible when two desktop rails cannot fit beside it. */
@media (max-width: 640px) {
  .vs-shell .vs-topbar,
  .vs-shell .vs-footer {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .vs-topbar-left,
  .vs-topbar-right,
  .vs-footer-left,
  .vs-footer-right {
    flex: none;
  }

  .vs-body {
    flex-direction: column;
    overflow-y: auto;
  }

  .vs-stage {
    order: -1;
    flex: 1 0 65%;
  }

  .vs-rail-left,
  .vs-rail-right {
    width: 100%;
    flex: none;
    border-inline: 0;
    border-top: 1px solid var(--vs-border);
  }
}

.vs-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 26px;
  padding: 0 10px;
  background: var(--vs-bg-1);
  border-top: 1px solid var(--vs-border);
  color: var(--vs-text-muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
}

.vs-footer-left,
.vs-footer-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.vs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px;
  border-radius: 5px;
  border: 1px solid var(--vs-border);
  background: var(--vs-bg-2);
  color: var(--vs-text-1);
  font-family: var(--vs-sans);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.vs-btn:hover {
  border-color: var(--vs-border-hi);
  background: var(--vs-bg-3);
  color: var(--vs-text-0);
}

.vs-btn-primary {
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(56, 189, 248, 0.16);
  color: #e0f2fe;
}

.vs-btn-primary:hover {
  border-color: var(--vs-accent);
  background: rgba(56, 189, 248, 0.25);
}

.vs-dropzone {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(11, 14, 20, 0.84);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.vs-dropzone.vs-active {
  display: flex;
}

.vs-dropzone-box {
  padding: 28px 36px;
  border-radius: 10px;
  border: 2px dashed var(--vs-accent);
  background: var(--vs-bg-1);
  color: var(--vs-text-0);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vs-fallback-card {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(11, 14, 20, 0.92);
  z-index: 20;
}

.vs-fallback-inner {
  max-width: 440px;
  width: 100%;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--vs-border-hi);
  background: var(--vs-bg-1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vs-fallback-inner h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--vs-text-0);
}

.vs-fallback-inner p {
  font-size: 12px;
  color: var(--vs-text-1);
  line-height: 1.5;
}


.cae-stage-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0e1118;
}

.cae-viewport {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

.cae-hover-pill {
  position: absolute;
  display: none;
  pointer-events: none;
  z-index: 6;
  padding: 4px 8px;
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.55);
  color: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.cae-fallback {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: rgba(14, 17, 24, 0.92);
  color: #f8fafc;
  font-size: 13px;
  z-index: 5;
}

.cae-error {
  display: none;
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(153, 27, 27, 0.92);
  border: 1px solid #f87171;
  color: #fef2f2;
  font-size: 12px;
  z-index: 10;
}

.vs-rail-left,
.vs-rail-right {
  padding: 0;
}

.cae-sec {
  padding: 6px 8px;
  border-bottom: 1px solid var(--vs-border, rgba(148, 163, 184, 0.16));
}

.cae-sec-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--vs-text-muted, #94a3b8);
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.cae-sec-title > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cae-sec-title .cae-btn-group {
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.cae-stat-revb {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px dashed rgba(148, 163, 184, 0.22);
}

.cae-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
}

.cae-row:last-child {
  margin-bottom: 0;
}

.cae-topbar-groups {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.cae-btn-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.cae-btn {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.24);
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
  flex-shrink: 0;
}

.cae-btn:hover {
  border-color: #38bdf8;
}

.cae-btn.active {
  background: #0284c7;
  border-color: #38bdf8;
  color: #f8fafc;
}

.cae-btn.sm {
  padding: 2px 6px;
  font-size: 10px;
}

.cae-btn.cae-btn-primary {
  background: #0284c7;
  border-color: #38bdf8;
  color: #f8fafc;
}

.cae-btn.cae-btn-primary:hover {
  background: #0369a1;
  border-color: #7dd3fc;
}

.cae-btn-quiet {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.16);
  color: #94a3b8;
  font-weight: 500;
}

.cae-btn-quiet:hover {
  background: rgba(30, 41, 59, 0.55);
  color: #e2e8f0;
}

.cae-input,
.cae-select {
  background: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: #f1f5f9;
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 5px;
  width: 100%;
  box-sizing: border-box;
}

.cae-num {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.cae-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.24);
  outline: none;
  cursor: pointer;
}

.cae-slider:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cae-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #38bdf8;
  border: 1.5px solid #0f172a;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.45);
  transition:
    transform 0.1s ease,
    background 0.1s ease;
}

.cae-slider::-webkit-slider-thumb:hover {
  transform: scale(1.12);
  background: #7dd3fc;
}

.cae-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #38bdf8;
  border: 1.5px solid #0f172a;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.45);
}

.cae-sec input[type="checkbox"],
.cae-zone-item input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 3px;
  border: 1px solid rgba(148, 163, 184, 0.42);
  background: #0f172a;
  display: inline-grid;
  place-content: center;
  vertical-align: middle;
  margin: 0 5px 0 0;
  cursor: pointer;
  flex-shrink: 0;
}

.cae-sec input[type="checkbox"]:hover,
.cae-zone-item input[type="checkbox"]:hover {
  border-color: #38bdf8;
}

.cae-sec input[type="checkbox"]:checked,
.cae-zone-item input[type="checkbox"]:checked {
  background: #0284c7;
  border-color: #38bdf8;
}

.cae-sec input[type="checkbox"]:checked::after,
.cae-zone-item input[type="checkbox"]:checked::after {
  content: "";
  width: 6px;
  height: 3.5px;
  border-left: 1.5px solid #f8fafc;
  border-bottom: 1.5px solid #f8fafc;
  transform: rotate(-45deg) translateY(-0.5px);
}

.cae-segmented {
  display: inline-flex;
  background: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.cae-segmented .cae-btn {
  border: none;
  background: transparent;
  padding: 2px 7px;
  border-radius: 4px;
  color: #94a3b8;
}

.cae-segmented .cae-btn.active {
  background: #0284c7;
  color: #f8fafc;
}

.cae-mono {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
}

.cae-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  font-size: 11px;
}

#stat-mesh,
#stat-b-mesh {
  grid-column: 1 / -1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cae-signoff-details {
  width: 100%;
}

.cae-signoff-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--vs-text-muted, #94a3b8);
}

.cae-signoff-summary::-webkit-details-marker {
  display: none;
}

.cae-signoff-body {
  margin-top: 6px;
}

.cae-zone-item,
.cae-pin-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 3px 0;
  font-size: 11px;
}

.cae-pin-item {
  flex-direction: column;
  align-items: stretch;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  padding: 4px 0;
}

.cae-xy-canvas {
  width: 100%;
  height: 110px;
  background: #090d16;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 5px;
  display: block;
}

.cae-signoff-badge {
  margin-top: 6px;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 11px;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #a7f3d0;
  display: none;
}

.cae-shortcut-legend {
  margin-top: auto;
  padding: 8px 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  font-size: 10px;
  color: #94a3b8;
  line-height: 1.65;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: center;
}

.cae-shortcut-legend kbd {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 9.5px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: #cbd5e1;
}
