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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #070b10;
  color: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

/* Ultra-slim 36px top bar */
.demo-topbar {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  background: #090d14;
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
}

.demo-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.demo-title {
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.02em;
  color: #f8fafc;
}

.demo-badge {
  background: rgba(14, 165, 233, 0.16);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.38);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.demo-status {
  color: #64748b;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.demo-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.demo-link {
  font-size: 11.5px;
  font-weight: 600;
  color: #cbd5e1;
  background: #111827;
  border: 1px solid #263346;
  border-radius: 4px;
  padding: 3px 9px;
  transition: all 0.15s ease;
}

.demo-link:hover {
  background: #1e293b;
  color: #ffffff;
  border-color: #475569;
}

.demo-link-primary {
  background: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
}

.demo-link-primary:hover {
  background: #0369a1;
}

/* Edge-to-edge split stage filling 100% of remaining viewport height */
.demo-stage {
  flex: 1;
  display: grid;
  grid-template-columns: clamp(280px, 25.5vw, 390px) 1fr;
  min-height: 0;
  width: 100%;
  background: #070b10;
}

/* Left Strip: 4 vertically stacked 16:9 cameras with zero wasted space */
.cam-strip {
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  gap: 4px;
  padding: 4px;
  background: #080c12;
  border-right: 1px solid #1e293b;
  min-height: 0;
}

.cam-tile {
  position: relative;
  width: 100%;
  height: 100%;
  background: #05080c;
  border: 1px solid #1e293b;
  border-radius: 6px;
  overflow: hidden;
}

.cam-tile canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cam-overlay-pill {
  position: absolute;
  top: 6px;
  left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(7, 11, 16, 0.72);
  border: 1px solid rgba(56, 189, 248, 0.32);
  backdrop-filter: blur(4px);
  font-size: 10.5px;
  line-height: 1.2;
  pointer-events: none;
}

.cam-overlay-pill strong {
  color: #f8fafc;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.cam-overlay-pill span {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #34d399;
  font-size: 10px;
}

.cam-overlay-ctx {
  border-color: rgba(148, 163, 184, 0.28);
}

/* Right Pane: Full-bleed 3D WebGL viewport with floating overlays inside */
.viewport-pane {
  position: relative;
  width: 100%;
  height: 100%;
  background: #0c1015;
  overflow: hidden;
  user-select: none;
}

.scene3d-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

.scene3d-canvas:active {
  cursor: grabbing;
}

/* Bottom-Left Compact Pour Alignment HUD (above timeline dock) */
.scene3d-assist-hud {
  position: absolute;
  bottom: 50px;
  left: 12px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(9, 13, 18, 0.76);
  border: 1px solid rgba(56, 189, 248, 0.36);
  border-radius: 8px;
  padding: 5px 10px;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.scene3d-reticle-svg {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.scene3d-assist-body {
  font-size: 11px;
  line-height: 1.35;
  color: #cbd5e1;
}

.scene3d-assist-title {
  font-weight: 700;
  font-size: 11.5px;
  color: #34d399;
  margin-bottom: 1px;
}

.scene3d-assist-title[data-state="approaching"] {
  color: #fbbf24;
}

.scene3d-assist-title[data-state="transport"] {
  color: #38bdf8;
}

.scene3d-assist-title[data-state="standby"] {
  color: #cbd5e1;
}

/* Top Bar Inside 3D Viewport: Viewpoint + Layer Dock (left) & XYZ Triad (right) */
.viewport-top-right {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.floating-dock {
  pointer-events: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(9, 13, 18, 0.76);
  border: 1px solid rgba(51, 65, 85, 0.75);
  border-radius: 8px;
  backdrop-filter: blur(8px);
}

.dock-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dock-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-right: 2px;
}

.dock-sep {
  width: 1px;
  height: 16px;
  background: #334155;
  margin: 0 2px;
}

.scene3d-chip {
  background: rgba(30, 41, 59, 0.85);
  color: #cbd5e1;
  border: 1px solid #334155;
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}

.scene3d-chip:hover {
  background: #334155;
  color: #ffffff;
}

.scene3d-chip.is-active,
.scene3d-chip[aria-pressed="true"] {
  background: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
}

.scene3d-orient-svg {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  pointer-events: none;
  background: rgba(9, 13, 18, 0.76);
  border: 1px solid rgba(51, 65, 85, 0.75);
  border-radius: 50%;
  backdrop-filter: blur(8px);
}

.scene3d-orient-svg text {
  font-size: 10px;
  font-weight: 700;
}

/* Bottom Floating Timeline Scrubber Inside the 3D Viewport */
.viewport-bottom-dock {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: rgba(9, 13, 18, 0.78);
  border: 1px solid rgba(51, 65, 85, 0.78);
  border-radius: 8px;
  backdrop-filter: blur(8px);
  font-size: 11.5px;
}

.scene3d-play-btn {
  background: #0284c7;
  color: #ffffff;
  border: 1px solid #38bdf8;
  border-radius: 5px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.scene3d-play-btn:hover {
  background: #0369a1;
}

.scene3d-scrubber {
  flex: 1;
  accent-color: #38bdf8;
  cursor: pointer;
  height: 4px;
}

.dock-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  white-space: nowrap;
}

.dock-muted {
  color: #94a3b8;
}

.dock-accent {
  color: #34d399;
}

@media (max-width: 960px) {
  html, body {
    overflow: auto;
  }
  .demo-stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto 70vh;
  }
  .cam-strip {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    border-right: none;
    border-bottom: 1px solid #1e293b;
  }
}
