:root {
  --bg: #0f1318;
  --panel-bg: rgba(18, 22, 28, 0.78);
  --panel-border: rgba(255, 255, 255, 0.11);
  --panel-hover: rgba(255, 255, 255, 0.08);
  --text-primary: #f4f5f7;
  --text-secondary: #9aa4b2;
  --text-muted: #6c7686;
  --accent: #d97757; /* Le Corbusier burnt sienna / terracotta */
  --accent-soft: rgba(217, 119, 87, 0.18);
  --accent-border: rgba(217, 119, 87, 0.55);
  --sage: #5d7b63;
  --sky: #5a90b8;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#canvas-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  touch-action: none;
}

#canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Loading overlay */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #12161c;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-mark {
  width: 44px;
  height: 44px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.loader-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.loader-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Glass Panel Base */
.hud-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* Top-Left Title Plaque */
.title-plaque {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 20;
  padding: 14px 18px;
  max-width: 320px;
}

.plaque-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.plaque-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.plaque-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.plaque-meta span.dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
}

/* Top-Right Quick Toolbar */
.top-toolbar {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
}

.tool-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.16s ease;
  white-space: nowrap;
}

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

.tool-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: #fff;
}

.tool-divider {
  width: 1px;
  height: 18px;
  background: var(--panel-border);
  margin: 0 2px;
}

/* Right Architectural Control Drawer */
.control-drawer {
  position: fixed;
  top: 72px;
  right: 18px;
  bottom: 84px;
  width: 288px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.control-drawer.collapsed {
  transform: translateX(316px);
  opacity: 0;
  pointer-events: none;
}

.drawer-scroll {
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.18) transparent;
}

.section-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.section-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
}

/* Segmented Controls / Grids */
.pill-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}

.pill-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.pill-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.ctrl-btn {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.ctrl-btn:hover {
  background: var(--panel-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.22);
}

.ctrl-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: #ffffff;
}

/* Range Sliders */
.slider-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.divider-line {
  height: 1px;
  background: var(--panel-border);
  margin: 2px 0;
}

/* Toggle Switch Row */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 0;
}

.toggle-row:hover {
  color: var(--text-primary);
}

.switch {
  position: relative;
  width: 34px;
  height: 18px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.toggle-row input {
  display: none;
}

.toggle-row input:checked + .switch {
  background: var(--accent);
}

.toggle-row input:checked + .switch::after {
  transform: translateX(16px);
}

/* Bottom Camera Preset Dock */
.camera-dock {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  max-width: calc(100vw - 36px);
  overflow-x: auto;
}

.cam-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.cam-btn:hover {
  background: var(--panel-hover);
  color: var(--text-primary);
}

.cam-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: #fff;
}

/* Reference Drawings Floating Card */
.blueprint-card {
  position: fixed;
  bottom: 78px;
  left: 18px;
  z-index: 25;
  width: 248px;
  overflow: hidden;
  transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease, transform 0.2s ease;
}

.blueprint-card.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
}

.blueprint-card.expanded {
  width: min(520px, calc(100vw - 340px));
}

.blueprint-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--panel-border);
}

.blueprint-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.icon-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
}

.icon-btn:hover {
  background: var(--panel-hover);
  color: #fff;
}

.blueprint-img-wrap {
  background: #ffffff;
  padding: 8px;
  max-height: 70vh;
  overflow: auto;
}

.blueprint-img-wrap img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}

/* 3D Annotations / Hotspots */
#hotspots-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  overflow: hidden;
}

.hotspot-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.hotspot-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(18, 22, 28, 0.85);
  border: 2px solid var(--accent);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease, background 0.15s ease;
}

.hotspot-pin:hover .hotspot-dot,
.hotspot-pin.selected .hotspot-dot {
  transform: scale(1.18);
  background: var(--accent);
}

.hotspot-label {
  background: rgba(18, 22, 28, 0.86);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f4f5f7;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  opacity: 0.92;
}

/* Info Callout Popover */
.info-popover {
  position: fixed;
  left: 18px;
  top: 112px;
  z-index: 25;
  width: 300px;
  padding: 14px 16px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.info-popover.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}

.info-popover-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.info-popover-tag {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 3px;
}

.info-popover-title {
  font-size: 15px;
  font-weight: 600;
}

.info-popover-body {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Controls Hint */
.nav-hint {
  position: fixed;
  bottom: 22px;
  left: 18px;
  z-index: 15;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(18, 22, 28, 0.55);
  backdrop-filter: blur(8px);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

@media (max-width: 900px) {
  .control-drawer {
    width: 248px;
  }
  .nav-hint {
    display: none;
  }
  .blueprint-card {
    width: 180px;
  }
}

@media (max-width: 768px) {
  .title-plaque {
    top: 10px;
    left: 10px;
    padding: 9px 12px;
    max-width: calc(100vw - 180px);
  }
  .plaque-kicker {
    display: none;
  }
  .plaque-title {
    font-size: 16px;
  }
  .plaque-meta {
    font-size: 10.5px;
    gap: 5px;
  }
  .top-toolbar {
    top: 10px;
    right: 10px;
    padding: 4px;
    gap: 3px;
  }
  .tool-btn {
    font-size: 11px;
    padding: 6px 8px;
  }
  .tool-divider {
    display: none;
  }
  .control-drawer {
    top: 62px;
    right: 10px;
    bottom: 72px;
    width: min(290px, calc(100vw - 20px));
  }
  .blueprint-card {
    left: 10px;
    bottom: 72px;
    width: min(300px, calc(100vw - 20px));
  }
  .blueprint-card.expanded {
    width: calc(100vw - 20px);
  }
  .camera-dock {
    bottom: 10px;
    padding: 5px;
    max-width: calc(100vw - 20px);
  }
  .cam-btn {
    font-size: 11.5px;
    padding: 7px 10px;
  }
  .info-popover {
    left: 10px;
    top: 72px;
    width: calc(100vw - 20px);
  }
  .hotspot-label {
    display: none;
  }
}
