:root {
  --bg: #020307;
  --glass: rgba(7, 9, 15, 0.56);
  --glass-strong: rgba(7, 9, 15, 0.78);
  --line: rgba(255, 255, 255, 0.10);
  --line-hi: rgba(255, 255, 255, 0.24);
  --fg: rgba(242, 245, 252, 0.92);
  --fg-dim: rgba(182, 192, 212, 0.58);
  --accent: #7be8ff;
  --accent-warm: #ffb36b;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#gl-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: grab;
  touch-action: none;
}

#gl-canvas:active {
  cursor: grabbing;
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  z-index: 10;
}

.hud.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Top-Left Plaque */
.plaque {
  position: fixed;
  top: 20px;
  left: 22px;
  pointer-events: auto;
  padding: 10px 14px;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(135%);
  -webkit-backdrop-filter: blur(16px) saturate(135%);
  border: 1px solid var(--line);
  border-radius: 6px;
  max-width: 440px;
}

.plaque-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
}

.brand {
  font-weight: 700;
  color: #ffffff;
}

.sep {
  color: var(--fg-dim);
}

.regime-code {
  color: var(--accent);
  font-weight: 600;
}

.plaque-sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.telemetry {
  margin-top: 7px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
}

.telemetry em {
  font-style: normal;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.dot {
  opacity: 0.35;
}

.mode-pill {
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid rgba(123, 232, 255, 0.32);
  background: rgba(123, 232, 255, 0.09);
  color: var(--accent);
  font-size: 9px;
  letter-spacing: 0.14em;
}

.mode-pill.refining {
  border-color: rgba(255, 179, 107, 0.45);
  background: rgba(255, 179, 107, 0.14);
  color: var(--accent-warm);
}

/* Top-Right PDE Monitor & Inspector Toggle */
.top-right {
  position: fixed;
  top: 20px;
  right: 22px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: auto;
}

.pde-card {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #04050a;
  cursor: crosshair;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.pde-card:hover {
  border-color: var(--line-hi);
  transform: scale(1.04);
}

#pde-preview {
  width: 100%;
  height: 100%;
  display: block;
}

.pde-meta {
  position: absolute;
  inset: auto 0 0 0;
  padding: 3px 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  background: linear-gradient(to top, rgba(2, 3, 7, 0.90), rgba(2, 3, 7, 0));
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.78);
  pointer-events: none;
}

.pde-val {
  color: var(--accent);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.icon-btn:hover,
.icon-btn.active {
  border-color: rgba(123, 232, 255, 0.45);
  background: rgba(12, 18, 30, 0.78);
  color: #fff;
}

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

/* Right Collapsible Inspector */
.inspector {
  position: fixed;
  top: 108px;
  right: 22px;
  bottom: 84px;
  width: 274px;
  pointer-events: auto;
  background: var(--glass-strong);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.24s ease;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.inspector.collapsed {
  transform: translateX(310px);
  opacity: 0;
  pointer-events: none;
}

.inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}

.inspector-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--accent);
}

.tiny-btn {
  background: transparent;
  border: none;
  color: var(--fg-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 5px;
}

.tiny-btn:hover {
  color: #fff;
}

.inspector-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

.group {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.group:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.group-title {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--fg-dim);
  margin-bottom: 10px;
}

.slider-row {
  display: block;
  margin-bottom: 10px;
}

.s-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: rgba(235, 240, 250, 0.84);
  margin-bottom: 4px;
}

.s-head em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

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

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 8px rgba(123, 232, 255, 0.65);
  transition: transform 0.12s ease;
}

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

.btn-row {
  display: flex;
  gap: 7px;
  margin-top: 8px;
}

.mini-btn {
  flex: 1;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.mini-btn:hover {
  background: rgba(123, 232, 255, 0.12);
  border-color: rgba(123, 232, 255, 0.4);
}

.hints {
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.65;
  color: var(--fg-dim);
}

.hints b {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
}

/* Bottom Dock */
.dock {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: calc(100vw - 28px);
  overflow-x: auto;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

.specimens, .actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dock-divider {
  width: 1px;
  height: 22px;
  background: var(--line);
  flex-shrink: 0;
}

.spec-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-dim);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
}

.spec-btn .num {
  opacity: 0.55;
  font-size: 9px;
}

.spec-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.spec-btn.active {
  color: #ffffff;
  background: rgba(123, 232, 255, 0.12);
  border-color: rgba(123, 232, 255, 0.42);
}

.spec-btn.active .num {
  color: var(--accent);
  opacity: 1;
}

.act-btn {
  height: 30px;
  padding: 0 9px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(226, 234, 248, 0.78);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.13em;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
}

.act-btn:hover {
  color: #fff;
  border-color: var(--line-hi);
  background: rgba(255, 255, 255, 0.09);
}

.act-btn.active {
  color: var(--accent);
  border-color: rgba(123, 232, 255, 0.45);
  background: rgba(123, 232, 255, 0.13);
}

.act-btn.refining {
  color: var(--accent-warm);
  border-color: rgba(255, 179, 107, 0.55);
  background: rgba(255, 179, 107, 0.15);
}

/* Hidden HUD restore pill */
.restore-hud {
  position: fixed;
  bottom: 16px;
  right: 18px;
  z-index: 20;
  padding: 6px 11px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(12px);
  color: var(--fg-dim);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  cursor: pointer;
  transition: opacity 0.25s ease, color 0.2s;
}

.restore-hud:hover {
  color: #fff;
  border-color: var(--line-hi);
}

.restore-hud.hidden {
  opacity: 0;
  pointer-events: none;
}

/* 3D PDE Injection Reticle */
.inject-reticle {
  position: fixed;
  width: 38px;
  height: 38px;
  margin-left: -19px;
  margin-top: -19px;
  border-radius: 50%;
  border: 1.5px solid rgba(123, 232, 255, 0.85);
  box-shadow: 0 0 18px rgba(123, 232, 255, 0.6), inset 0 0 10px rgba(255, 145, 210, 0.45);
  pointer-events: none;
  opacity: 0;
  transform: scale(0.35);
  z-index: 15;
}

.inject-reticle.pulse {
  animation: reticlePulse 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes reticlePulse {
  0% { opacity: 0.95; transform: scale(0.3); }
  60% { opacity: 0.7; transform: scale(1.25); }
  100% { opacity: 0; transform: scale(1.9); }
}

/* Ephemeral Toast */
.toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 7px 14px;
  border-radius: 5px;
  border: 1px solid rgba(123, 232, 255, 0.32);
  background: rgba(6, 9, 16, 0.82);
  backdrop-filter: blur(14px);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--fg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
