: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;
}


:root {
  --mcad-accent: #38bdf8;
  --mcad-emerald: #10b981;
  --mcad-coral: #f43f5e;
  --mcad-amber: #f59e0b;
  --mcad-surface: #1b202c;
  --mcad-border: #262d3d;
  --mcad-muted: #94a3b8;
}

.mcad-btn {
  appearance: none;
  background: var(--mcad-surface);
  color: var(--vs-text, #f1f5f9);
  border: 1px solid var(--mcad-border);
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.mcad-btn:hover {
  border-color: #475569;
  background: #232a3a;
}
.mcad-btn.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--mcad-accent);
  color: #e0f2fe;
}
.mcad-btn.emerald {
  background: rgba(16, 185, 129, 0.18);
  border-color: var(--mcad-emerald);
  color: #a7f3d0;
}
.mcad-select {
  background: var(--mcad-surface);
  color: var(--vs-text, #f1f5f9);
  border: 1px solid var(--mcad-border);
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 11px;
  outline: none;
  width: 100%;
}
.mcad-select:focus {
  border-color: var(--mcad-accent);
}
.mcad-seg-group {
  display: inline-flex;
  align-items: center;
  background: #131720;
  border: 1px solid var(--mcad-border);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}
.mcad-seg-group .mcad-btn,
.mcad-seg-group .mcad-select {
  border-color: transparent;
  background: transparent;
  border-radius: 4px;
  width: auto;
}
.mcad-seg-group .mcad-btn:hover {
  background: rgba(148, 163, 184, 0.12);
}
.mcad-seg-group .mcad-btn.active {
  background: rgba(56, 189, 248, 0.22);
  border-color: rgba(56, 189, 248, 0.55);
  color: #e0f2fe;
}
.measure-hover-pill {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  display: none;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(11, 15, 24, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.55);
  color: #e0f2fe;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
}

.rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--mcad-border);
  font-size: 11px;
  font-weight: 600;
  color: var(--mcad-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.search-box {
  padding: 6px 8px;
  border-bottom: 1px solid var(--mcad-border);
}
.search-input {
  width: 100%;
  background: #0e1117;
  color: #f1f5f9;
  border: 1px solid var(--mcad-border);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 11px;
  outline: none;
}
.search-input:focus {
  border-color: var(--mcad-accent);
}
.bom-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.bom-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  cursor: pointer;
  user-select: none;
  font-size: 11px;
  color: #cbd5e1;
}
.bom-row:hover {
  background: rgba(148, 163, 184, 0.08);
}
.bom-row.selected {
  background: rgba(56, 189, 248, 0.16);
  color: #f8fafc;
}
.bom-row.hidden-part {
  opacity: 0.45;
}
.bom-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bom-qty {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  padding: 1px 5px;
  border-radius: 3px;
  background: #1e2536;
  color: var(--mcad-muted);
  white-space: nowrap;
}
.bom-qty.multi {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
  font-weight: 600;
}
.bom-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.bom-row:hover .bom-actions,
.bom-row.selected .bom-actions,
.bom-row.hidden-part .bom-actions {
  opacity: 1;
}
.bom-act {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--mcad-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.bom-act:hover {
  color: #f8fafc;
  background: rgba(148, 163, 184, 0.18);
}

.viewport-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0e14;
}
.viewport-host {
  position: absolute;
  inset: 0;
}

.viewcube {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(15, 23, 42, 0.84);
  border: 1px solid var(--mcad-border);
  border-radius: 7px;
  padding: 5px;
  backdrop-filter: blur(6px);
}
.viewcube-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}
.vc-btn {
  appearance: none;
  background: #1b202c;
  color: #cbd5e1;
  border: 1px solid #2c3548;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}
.vc-btn:hover {
  border-color: var(--mcad-accent);
  color: #fff;
}

.stage-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--mcad-border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 11px;
  color: #e2e8f0;
  backdrop-filter: blur(6px);
  white-space: nowrap;
}
.stage-bar input[type="range"] {
  width: 100px;
  accent-color: var(--mcad-accent);
}
.stage-bar .kv-val {
  flex-shrink: 0;
  white-space: nowrap;
  overflow-wrap: normal;
}
.seg-group {
  display: inline-flex;
  align-items: center;
  background: #0f131d;
  border: 1px solid var(--mcad-border);
  border-radius: 5px;
  padding: 1px;
  gap: 1px;
}
.seg-btn {
  appearance: none;
  background: transparent;
  color: var(--mcad-muted);
  border: none;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}
.seg-btn:hover {
  color: #f8fafc;
}
.seg-btn.active {
  background: rgba(56, 189, 248, 0.22);
  color: #e0f2fe;
}

.mcad-input {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid #334155;
  border-radius: 5px;
  color: #e2e8f0;
  font-size: 11px;
  padding: 4px 8px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.mcad-input:focus {
  border-color: #38bdf8;
}

.webgpu-fallback[hidden] {
  display: none;
}
.webgpu-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 14, 20, 0.92);
  padding: 20px;
}
.fallback-card {
  max-width: 380px;
  background: #141720;
  border: 1px solid var(--mcad-border);
  border-radius: 10px;
  padding: 16px;
}

/* Zone 4 single contextual inspector */
.z4-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.kv-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}
.kv-key {
  font-size: 10px;
  color: var(--mcad-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.kv-val {
  font-size: 12px;
  color: #f8fafc;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
}
.kv-note {
  font-size: 11px;
  color: var(--mcad-muted);
  line-height: 1.4;
}
.z4-section {
  background: #151924;
  border: 1px solid var(--mcad-border);
  border-radius: 7px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.z4-title {
  font-size: 11px;
  font-weight: 600;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.z4-btn-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.diff-blend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--mcad-muted);
}
.diff-blend-row input[type="range"] {
  flex: 1;
  accent-color: var(--mcad-accent);
}
.diff-item {
  border: 1px solid var(--mcad-border);
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  background: #11151e;
}
.diff-item:hover {
  border-color: #475569;
}
.diff-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}
.diff-badge.added {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}
.diff-badge.removed {
  background: rgba(244, 63, 94, 0.2);
  color: #fda4af;
}
.diff-badge.modified {
  background: rgba(245, 158, 11, 0.2);
  color: #fde68a;
}
.pin-card {
  border: 1px solid var(--mcad-border);
  border-radius: 6px;
  padding: 8px 9px;
  background: #11151e;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pin-card.active {
  border-color: var(--mcad-accent);
}
.pin-reply-form {
  display: flex;
  gap: 5px;
  margin-top: 2px;
}
.pin-signoff-box {
  border-top: 1px solid var(--mcad-border);
  padding-top: 7px;
  margin-top: 2px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
