:root {
  --font-sans: 'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --glass-bg: rgba(18, 18, 20, 0.78);
  --glass-bg-elevated: rgba(28, 28, 32, 0.88);
  --glass-border: rgba(255, 255, 255, 0.11);
  --glass-highlight: rgba(255, 255, 255, 0.08);

  --text-primary: #f6f4ef;
  --text-secondary: rgba(246, 244, 239, 0.65);
  --text-muted: rgba(246, 244, 239, 0.42);

  --accent-emerald: #44e438;
  --accent-warm: #ffbe55;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

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

/* FULL-BLEED 3D VIEWPORT */
.canvas-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  cursor: grab;
}

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

/* LOADING SCREEN */
.loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(circle at 50% 42%, #192217 0%, #090b08 75%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.6s;
}

.loader-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-card {
  text-align: center;
  width: min(360px, 88vw);
  padding: 32px 28px;
  border-radius: 22px;
  background: rgba(18, 20, 18, 0.82);
  border: 1px solid var(--glass-border);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(20px);
}

.loader-brand {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.loader-brand span {
  font-size: 0.85rem;
  vertical-align: super;
  color: var(--accent-emerald);
}

.loader-title {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 22px;
}

.loader-progress-track {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}

.loader-progress-bar {
  width: 18%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-emerald), #c8ff8c);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.loader-status {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* 3D INLINE CORD SWITCH HOTSPOT */
.hotspot-pill {
  position: fixed;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(18, 19, 21, 0.84);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text-primary);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transform: translate(-50%, -135%);
  transition: transform 0.2s ease, opacity 0.25s ease, border-color 0.2s ease, background 0.2s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
}

.hotspot-pill:hover {
  transform: translate(-50%, -142%) scale(1.05);
  border-color: rgba(68, 228, 56, 0.55);
  background: rgba(24, 28, 24, 0.94);
}

.hotspot-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

/* TOP MINIMAL BAR (Brand Identity + LDT Trigger & View Actions) */
.top-bar {
  position: fixed;
  top: 18px;
  left: 20px;
  right: 20px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.brand-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow:
    inset 0 1px 0 var(--glass-highlight),
    0 12px 32px rgba(0, 0, 0, 0.38);
}

.brand-logo {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #ffffff;
}

.back-config-link {
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(246, 244, 239, 0.78);
  text-decoration: none;
  transition: color 0.18s ease;
  white-space: nowrap;
}

.back-config-link:hover {
  color: #ffffff;
}

.brand-logo span {
  font-size: 0.65rem;
  vertical-align: super;
  color: var(--accent-emerald);
}

.brand-sep {
  width: 1px;
  height: 15px;
  background: rgba(255, 255, 255, 0.14);
}

.brand-product {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
}

.brand-meta {
  font-size: 0.78rem;
  font-weight: 500;
  color: #84f57a;
  background: rgba(68, 228, 56, 0.12);
  border: 1px solid rgba(68, 228, 56, 0.24);
  padding: 3px 9px;
  border-radius: 999px;
}

.brand-sku {
  font-family: var(--font-mono);
  font-size: 0.71rem;
  color: var(--text-secondary);
}

.top-actions {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-pill {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 15px;
  border-radius: 999px;
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 var(--glass-highlight),
    0 12px 32px rgba(0, 0, 0, 0.38);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.15s ease;
}

.action-pill:hover {
  background: rgba(32, 33, 38, 0.90);
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.action-pill.icon-only {
  width: 42px;
  padding: 0;
  justify-content: center;
}

.action-pill[aria-expanded="true"] {
  background: rgba(36, 42, 36, 0.94);
  border-color: rgba(82, 255, 122, 0.45);
}

.pulse-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #52ff7a;
  box-shadow: 0 0 8px #52ff7a;
}

.pulse-indicator.off {
  background: #ef4444;
  box-shadow: none;
}

.ldt-live-readout {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ldt-live-readout strong {
  font-weight: 600;
}

.dot-sep {
  color: var(--text-muted);
}

.ldt-badge-tag {
  font-size: 0.68rem;
  font-weight: 600;
  color: #ffda72;
  background: rgba(255, 218, 114, 0.14);
  padding: 2px 7px;
  border-radius: 999px;
}

.chevron-icon {
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}

.action-pill[aria-expanded="true"] .chevron-icon {
  transform: rotate(180deg);
}

/* EXPANDABLE EULUMDAT (.LDT) PHOTOMETRIC POPOVER */
.ldt-popover {
  position: fixed;
  top: 68px;
  right: 20px;
  z-index: 25;
  width: 292px;
  background: rgba(16, 17, 19, 0.92);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 15px;
  color: var(--text-primary);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  animation: popIn 0.18s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.ldt-popover[hidden] {
  display: none !important;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ldt-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.telemetry-title {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.ldt-tag-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: #ffda72;
  background: rgba(255, 218, 114, 0.13);
  padding: 2px 7px;
  border-radius: 6px;
}

.ldt-polar-box {
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 7px 8px 8px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#ldt-polar-canvas {
  width: 256px;
  height: 150px;
  display: block;
}

.ldt-polar-meta {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-secondary);
}

#ldt-file-label {
  color: #65ff8a;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ldt-metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.ldt-metric {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 9px;
  padding: 6px 4px;
  text-align: center;
}

.m-label {
  display: block;
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.m-val {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: #ffffff;
}

/* UNIFIED BOTTOM CONTROL DOCK (All Primary & Context Controls in ONE Place) */
.bottom-dock-wrapper {
  position: fixed;
  inset: auto 0 18px 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

/* Secondary Context Row (Camera Views + Ambience + LDT Overlays) */
.context-bar {
  pointer-events: auto;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(16, 16, 18, 0.70);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}

.context-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.context-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-right: 2px;
}

.context-divider {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.11);
}

.context-pills {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.cam-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
  white-space: nowrap;
}

.cam-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.07);
}

.cam-btn.active {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-weight: 600;
}

/* Sliding Ambience Toggle Pill (Evening Study vs Darkroom) */
.sliding-toggle-pill {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  height: 28px;
  width: 176px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 2px;
}

.sliding-pill-indicator {
  position: absolute;
  inset: 2px auto 2px 2px;
  width: calc(50% - 2px);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  transform: translateX(0%);
  transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sliding-toggle-pill.right .sliding-pill-indicator {
  transform: translateX(100%);
}

.sliding-pill-btn {
  position: relative;
  z-index: 2;
  appearance: none;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s ease;
  white-space: nowrap;
}

.sliding-pill-btn.active {
  color: #ffffff;
  font-weight: 600;
}

/* Overlay Toggle Chips (Isolux Contours & 3D LDT Web) */
.overlay-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.73rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.18s ease;
}

.overlay-chip:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.overlay-chip input {
  display: none;
}

.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.overlay-chip:has(input:checked) {
  background: rgba(68, 228, 56, 0.14);
  border-color: rgba(68, 228, 56, 0.42);
  color: #ffffff;
}

.overlay-chip:has(input:checked) .chip-dot {
  background: #52ff7a;
  box-shadow: 0 0 8px #52ff7a;
}

/* PRIMARY MAIN CONFIGURATOR DOCK (Power + Brightness | Finish | Size) */
.main-dock {
  pointer-events: auto;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 16px;
  border-radius: 22px;
  background: var(--glass-bg);
  backdrop-filter: blur(26px) saturate(170%);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
  border: 1px solid var(--glass-border);
  box-shadow:
    inset 0 1px 0 var(--glass-highlight),
    0 20px 50px rgba(0, 0, 0, 0.55);
}

.dock-module {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.power-dimmer-module {
  flex-direction: row;
  align-items: center;
  gap: 14px;
}

.dock-divider {
  width: 1px;
  height: 40px;
  background: rgba(255, 255, 255, 0.10);
}

.module-caption {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

/* 1. Tactile Lamp Power Button & Dimmer Slider */
.power-pill-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 16px 0 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.power-pill-btn.on {
  background: linear-gradient(135deg, rgba(255, 190, 85, 0.22) 0%, rgba(68, 228, 56, 0.16) 100%);
  border-color: rgba(255, 205, 110, 0.48);
  color: #ffffff;
  box-shadow: 0 4px 18px rgba(255, 185, 75, 0.18);
}

.power-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(1);
  transition: transform 240ms cubic-bezier(0.34, 1.56, 0.64, 1), background 0.25s ease, color 0.25s ease;
}

.power-pill-btn.on .power-icon-wrap {
  background: #ffbe55;
  color: #16120b;
  box-shadow: 0 0 14px rgba(255, 190, 85, 0.65);
}

.power-icon-wrap.squish {
  transform: scale(0.80);
  transition: transform 90ms cubic-bezier(0.4, 0, 0.2, 1);
}

.dimmer-control {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 132px;
}

.dimmer-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dimmer-pct {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-primary);
}

.dock-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,0.12) 0%, rgba(255, 200, 100, 0.75) 100%);
  outline: none;
  cursor: pointer;
}

.dock-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #18181b;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.dock-slider::-webkit-slider-thumb:hover {
  transform: scale(1.16);
}

/* 2. Finish Swatch Pills (Green Glass & White Glass) */
.finish-pills {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.swatch-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 13px 0 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
}

.swatch-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.swatch-btn.active {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.42);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.swatch-orb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.4), 0 2px 6px rgba(0, 0, 0, 0.35);
}

.orb-green {
  background: radial-gradient(circle at 35% 30%, #58ff47 0%, #248a1c 58%, #0e3b0a 100%);
}

.orb-white {
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #ebe6dc 62%, #b8b2a6 100%);
}

/* 3. Size Selector (Ø150 / Ø200 / Ø300 with Live Lumens) */
.size-segmented {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.32);
  padding: 3px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  padding: 5px 12px;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  transition: all 0.18s ease;
}

.seg-btn:hover {
  color: #ffffff;
}

.seg-btn.active {
  background: #ffffff;
  color: #111111;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.s-dia {
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.1;
}

.s-lm {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  opacity: 0.72;
}

/* CLEAN CINEMA MODE */
body.cinema-mode .top-bar .brand-pill,
body.cinema-mode .top-bar #btn-ldt-popover,
body.cinema-mode .top-bar #btn-reset-cam,
body.cinema-mode .bottom-dock-wrapper,
body.cinema-mode .ldt-popover {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 820px) {
  .hide-mobile {
    display: none !important;
  }
  .main-dock {
    gap: 10px;
    padding: 10px 12px;
  }
  .dock-divider {
    display: none;
  }
}
