#ld-loader {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: #06091A;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.9s cubic-bezier(0.22,1,0.36,1), visibility 0.9s;
  overflow: hidden;
}

#ld-loader.ld-fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* subtle grid */
#ld-loader::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,212,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
}

/* central radial glow */
#ld-loader::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 340px;
  height: 340px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(74,108,247,0.13) 0%, transparent 70%);
  pointer-events: none;
}

/* ---- Rings ---- */
.ld-loader-rings {
  position: relative;
  width: 220px;
  height: 220px;
}

.ld-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  border: 1.5px solid transparent;
  box-sizing: border-box;
}

.ld-r1 {
  width: 220px; height: 220px;
  border-color: rgba(0,212,255,0.65) rgba(0,212,255,0.08) rgba(0,212,255,0.08) rgba(0,212,255,0.08);
  animation: ldSpin 2s linear infinite;
  box-shadow: inset 0 0 18px rgba(0,212,255,0.12);
}

.ld-r2 {
  width: 174px; height: 174px;
  border-color: rgba(74,108,247,0.75) rgba(74,108,247,0.08) rgba(74,108,247,0.08) rgba(74,108,247,0.08);
  animation: ldSpin 2.8s linear infinite reverse;
}

.ld-r3 {
  width: 128px; height: 128px;
  border-color: rgba(0,212,255,0.5) rgba(0,212,255,0.08) rgba(0,212,255,0.3) rgba(0,212,255,0.08);
  animation: ldSpin 3.6s linear infinite;
}

.ld-r4 {
  width: 82px; height: 82px;
  border-color: rgba(74,108,247,0.45) rgba(74,108,247,0.45) rgba(74,108,247,0.08) rgba(74,108,247,0.08);
  animation: ldSpin 1.7s linear infinite reverse;
}

@keyframes ldSpin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to   { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ---- Glowing dots on outer ring ---- */
.ld-loader-dots {
  position: absolute;
  width: 220px;
  height: 220px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.ld-loader-dots span {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #00D4FF;
  top: 50%;
  left: 50%;
  margin: -2.5px 0 0 -2.5px;
  box-shadow: 0 0 8px #00D4FF, 0 0 18px rgba(0,212,255,0.45);
}

.ld-loader-dots span:nth-child(1) { transform: rotate(0deg)   translateX(110px); animation: ldDotPulse 2s ease-in-out infinite 0.00s; }
.ld-loader-dots span:nth-child(2) { transform: rotate(45deg)  translateX(110px); animation: ldDotPulse 2s ease-in-out infinite 0.25s; }
.ld-loader-dots span:nth-child(3) { transform: rotate(90deg)  translateX(110px); animation: ldDotPulse 2s ease-in-out infinite 0.50s; }
.ld-loader-dots span:nth-child(4) { transform: rotate(135deg) translateX(110px); animation: ldDotPulse 2s ease-in-out infinite 0.75s; }
.ld-loader-dots span:nth-child(5) { transform: rotate(180deg) translateX(110px); animation: ldDotPulse 2s ease-in-out infinite 1.00s; }
.ld-loader-dots span:nth-child(6) { transform: rotate(225deg) translateX(110px); animation: ldDotPulse 2s ease-in-out infinite 1.25s; }
.ld-loader-dots span:nth-child(7) { transform: rotate(270deg) translateX(110px); animation: ldDotPulse 2s ease-in-out infinite 1.50s; }
.ld-loader-dots span:nth-child(8) { transform: rotate(315deg) translateX(110px); animation: ldDotPulse 2s ease-in-out infinite 1.75s; }

@keyframes ldDotPulse {
  0%, 100% { opacity: 0.25; }
  50%       { opacity: 1;    }
}

/* ---- Center text ---- */
.ld-loader-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
}

.ld-loader-brand {
  display: block;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 5px;
  color: rgba(255,255,255,0.85);
  animation: ldBreath 3s ease-in-out infinite;
}

.ld-loader-ai {
  display: block;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 3px;
  background: linear-gradient(135deg, #00D4FF 0%, #4A6CF7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 14px rgba(0,212,255,0.55));
  animation: ldBreath 3s ease-in-out infinite 0.4s;
}

@keyframes ldBreath {
  0%, 100% { opacity: 0.75; }
  50%       { opacity: 1;    }
}

/* ---- Horizontal scan line ---- */
.ld-loader-scan {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0,212,255,0.025) 50%,
    transparent 100%
  );
  background-size: 100% 200%;
  animation: ldScanLine 2.2s linear infinite;
  pointer-events: none;
}

@keyframes ldScanLine {
  from { background-position: 0 -100%; }
  to   { background-position: 0 200%;  }
}

@media (prefers-reduced-motion: reduce) {
  #ld-loader * { animation: none !important; }
}
