@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* Core Palette */
  --bg:            #05080f;
  --bg-2:          #080d1a;
  --bg-3:          #0c1225;

  /* Glass Surfaces */
  --surface-1:     rgba(10, 16, 35, 0.70);
  --surface-2:     rgba(14, 22, 48, 0.80);
  --surface-3:     rgba(18, 28, 60, 0.90);

  /* Accent — Electric Blue-Violet */
  --accent:        #6366f1;
  --accent-2:      #818cf8;
  --accent-glow:   rgba(99, 102, 241, 0.35);
  --accent-hover:  #4f46e5;
  --accent-soft:   rgba(99, 102, 241, 0.12);

  /* Cyan secondary */
  --cyan:          #22d3ee;
  --cyan-glow:     rgba(34, 211, 238, 0.25);

  /* Status */
  --success:       #10b981;
  --success-glow:  rgba(16, 185, 129, 0.30);
  --danger:        #f43f5e;
  --danger-glow:   rgba(244, 63, 94, 0.30);
  --warning:       #f59e0b;

  /* Text */
  --txt:           #e2e8f0;
  --txt-2:         #94a3b8;
  --txt-3:         #64748b;

  /* Borders */
  --stroke:        rgba(255, 255, 255, 0.08);
  --stroke-2:      rgba(255, 255, 255, 0.14);
  --stroke-accent: rgba(99, 102, 241, 0.35);

  /* Shadows */
  --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md:  0 8px 24px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg:  0 20px 48px rgba(0, 0, 0, 0.6), 0 8px 16px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 24px var(--accent-glow), 0 8px 24px rgba(0, 0, 0, 0.5);

  /* Radius */
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  16px;
  --r-xl:  22px;
  --r-full: 9999px;

  /* Transitions */
  --t-fast:   0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --t-base:   0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --t-spring: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Legacy aliases (for backwards compat) */
  --glass: var(--surface-1);
  --panel: var(--surface-1);
  --muted: var(--txt-2);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html, body, #c {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--txt);
  font: 14px/1.5 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Hide Cesium branding */
.cesium-credit-container,
.cesium-widget-credits { display: none !important; }

/* ============================================================
   SPLASH SCREEN
   ============================================================ */
.splash-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 60%, #0c1a3a 0%, var(--bg) 70%);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.9s ease, visibility 0.9s;
  overflow: hidden;
}

/* Star field */
.splash-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 25% 40%, rgba(255,255,255,0.35) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 40% 8%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 55% 70%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 22%, rgba(255,255,255,0.45) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 80% 55%, rgba(255,255,255,0.35) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 85%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 15% 80%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 65% 45%, rgba(255,255,255,0.25) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 35% 60%, rgba(200,200,255,0.3) 0%, transparent 100%);
  pointer-events: none;
}

/* Ambient glow */
.splash-screen::after {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, transparent 70%);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: splashGlow 3s ease-in-out infinite alternate;
}

@keyframes splashGlow {
  from { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
  to   { opacity: 1;   transform: translate(-50%, -50%) scale(1.15); }
}

.splash-screen.fade-out {
  opacity: 0;
  visibility: hidden;
}

.splash-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  position: relative;
  z-index: 1;
  animation: splashEnter 0.8s var(--t-spring) both;
}

@keyframes splashEnter {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.splash-title {
  font-family: 'Outfit', sans-serif;
  font-size: 36px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 0%, var(--accent-2) 50%, var(--cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px var(--accent-glow));
}

.splash-subtitle {
  font-size: 13px;
  color: var(--txt-3);
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.splash-boot-msg {
  font-size: 12px;
  color: var(--txt-2);
  margin: 0;
  letter-spacing: 0.05em;
  min-height: 18px;
  transition: opacity 0.3s ease;
}

.splash-progress-wrap {
  width: 260px;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--r-full);
  overflow: hidden;
  position: relative;
}

.splash-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--cyan));
  border-radius: var(--r-full);
  transition: width 0.4s ease;
  position: relative;
}

.splash-progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6));
  border-radius: var(--r-full);
  animation: progressShine 1.5s ease-in-out infinite;
}

@keyframes progressShine {
  0%   { opacity: 0; }
  50%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 32px;
  width: 300px;
  background: var(--surface-1);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-right: 1px solid var(--stroke);
  box-shadow: 4px 0 40px rgba(0, 0, 0, 0.4), inset -1px 0 0 var(--stroke-accent);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--t-base), width var(--t-base);
  overflow: hidden;
}

/* Left accent line */
.sidebar::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 2px;
  background: linear-gradient(180deg, transparent, var(--accent), var(--cyan), transparent);
  border-radius: var(--r-full);
  opacity: 0.6;
  z-index: 1;
}

.sidebar.collapsed { width: 52px; }

.sidebar.collapsed .sidebar-logo span,
.sidebar.collapsed .section-title,
.sidebar.collapsed .control-group label,
.sidebar.collapsed .flat-btn,
.sidebar.collapsed .modern-select,
.sidebar.collapsed .select-wrapper::after,
.sidebar.collapsed .tool-btn span,
.sidebar.collapsed .action-btn,
.sidebar.collapsed .sidebar-section { display: none; }

.sidebar.collapsed .sidebar-logo { justify-content: center; width: 100%; }

.sidebar.collapsed .sidebar-header {
  padding: 16px 0;
  flex-direction: column;
  gap: 16px;
  border-bottom: none;
}

.sidebar.collapsed .sidebar-toggle {
  transform: rotate(180deg);
  margin-top: 20px;
  background: var(--accent-soft);
  border: 1px solid var(--stroke-accent);
  padding: 8px;
}

/* Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(99,102,241,0.06) 0%, transparent 100%);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.2px;
}

.sidebar-logo svg {
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--txt-2);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  transition: color var(--t-fast), background var(--t-fast);
}

.sidebar-toggle:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

/* Content */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 20px;
}

.sidebar-content::-webkit-scrollbar { width: 4px; }
.sidebar-content::-webkit-scrollbar-track { background: transparent; }
.sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.25);
  border-radius: var(--r-full);
}

.sidebar-section {
  padding: 20px;
  border-bottom: 1px solid var(--stroke);
}

.section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 0 0 14px 0;
  font-weight: 600;
  background: linear-gradient(90deg, var(--accent-2), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.control-group {
  margin-bottom: 16px;
}
.control-group:last-child { margin-bottom: 0; }

.control-group label {
  display: block;
  font-size: 12px;
  color: var(--txt-2);
  margin-bottom: 8px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Buttons */
.flat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
  color: var(--txt);
  padding: 9px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.flat-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(34,211,238,0.04));
  opacity: 0;
  transition: opacity var(--t-fast);
}

.flat-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--stroke-2);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.15), var(--shadow-sm);
  transform: translateY(-1px);
  color: #fff;
}

.flat-btn:hover::before { opacity: 1; }

.flat-btn.active {
  background: var(--accent-soft);
  border-color: var(--stroke-accent);
  color: var(--accent-2);
  box-shadow: 0 0 16px var(--accent-glow);
}

.w-full { width: 100%; }

.btn-group {
  display: flex;
  gap: 8px;
}
.btn-group .flat-btn { flex: 1; }

/* Select */
.select-wrapper { position: relative; }

.modern-select {
  width: 100%;
  appearance: none;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--stroke);
  color: #fff;
  padding: 9px 36px 9px 12px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.modern-select:hover,
.modern-select:focus {
  border-color: var(--stroke-accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  outline: none;
}

.modern-select option {
  background: var(--bg-3);
  color: #fff;
}

.select-wrapper::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--txt-3);
  pointer-events: none;
}

/* Tools Grid */
.tools-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  padding: 14px 8px;
  color: var(--txt-2);
  cursor: pointer;
  transition: all var(--t-fast);
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.tool-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  opacity: 0;
  transition: opacity var(--t-fast);
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  border-color: var(--stroke-accent);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.2), var(--shadow-sm);
  transform: translateY(-1px);
}

.tool-btn:hover::after { opacity: 1; }

.tool-btn.active {
  background: var(--accent-soft);
  color: var(--accent-2);
  border-color: var(--stroke-accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.tool-btn span {
  font-size: 11px;
  font-weight: 500;
  position: relative;
  z-index: 1;
}

.tool-btn svg { position: relative; z-index: 1; }

/* Dynamic Actions */
.sidebar-dynamic {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mosque-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: transform var(--t-fast), box-shadow var(--t-fast), filter var(--t-fast);
  font-family: inherit;
}

.action-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.12);
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  border: 1px solid var(--stroke-2);
}

.danger-btn {
  background: rgba(244, 63, 94, 0.15);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.25);
}
.danger-btn:hover { background: rgba(244, 63, 94, 0.25); }

.success-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 14px var(--success-glow);
}

/* Hide legacy elements */
.mosque-btn-container, .topbar, .model-select-container,
.color-select-container, .fab { display: none !important; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: absolute;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface-3);
  backdrop-filter: blur(16px);
  border: 1px solid var(--stroke-2);
  border-radius: var(--r-lg);
  padding: 10px 18px;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity var(--t-base), transform var(--t-base);
  z-index: 5000;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
}

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

/* ============================================================
   STATUS BAR (Bottom)
   ============================================================ */
.status-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: rgba(5, 8, 15, 0.88);
  backdrop-filter: blur(16px) saturate(1.5);
  border-top: 1px solid var(--stroke);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
  color: var(--txt-2);
  font-size: 11.5px;
  user-select: none;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px;
  height: 100%;
}

.monospace {
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
  font-size: 11px;
}

.status-left {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 8px;
}

.projection-switch {
  cursor: pointer;
  color: var(--accent-2);
  transition: color var(--t-fast);
  border-right: 1px solid var(--stroke);
  padding-right: 12px;
  position: relative;
}

.projection-switch:hover { color: var(--cyan); }

.proj-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 8px;
  background: var(--surface-3);
  backdrop-filter: blur(20px);
  border: 1px solid var(--stroke-2);
  border-radius: var(--r-md);
  padding: 4px;
  display: none;
  flex-direction: column;
  min-width: 165px;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
}

.proj-menu.show { display: flex; }

.proj-option {
  padding: 8px 12px;
  color: var(--txt);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 12px;
  transition: background var(--t-fast), color var(--t-fast);
}

.proj-option:hover {
  background: var(--accent-soft);
  color: var(--accent-2);
}

.coords { display: flex; gap: 12px; }

.coord-val {
  color: var(--txt);
  min-width: 86px;
  font-size: 11px;
}

.highlight-z { color: var(--success); }

.status-center {
  display: flex;
  align-items: center;
  gap: 20px;
}

.model-name {
  color: #fff;
  font-weight: 600;
  font-size: 12px;
}

.scale-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scale-bar {
  width: 50px;
  height: 3px;
  border-left: 1px solid var(--txt-3);
  border-right: 1px solid var(--txt-3);
  border-bottom: 1px solid var(--txt-3);
}

.scale-label {
  min-width: 28px;
  text-align: left;
  font-size: 11px;
}

.status-right {
  display: flex;
  align-items: center;
  height: 100%;
}

.status-right .status-item { border-left: 1px solid var(--stroke); }

.health { color: #fff; }

.signal-dot {
  width: 7px;
  height: 7px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success-glow);
  animation: pulseDot 2.5s ease-in-out infinite;
}

@keyframes pulseDot {
  0%   { opacity: 1; box-shadow: 0 0 6px var(--success-glow); }
  50%  { opacity: 0.55; box-shadow: 0 0 2px var(--success-glow); }
  100% { opacity: 1; box-shadow: 0 0 6px var(--success-glow); }
}

.point-count { color: var(--cyan); }

/* ============================================================
   CURSOR
   ============================================================ */
.cesium-widget canvas {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path d='M12 3v18M3 12h18' stroke='%230b1220' stroke-width='7' stroke-linecap='round'/><path d='M12 3v18M3 12h18' stroke='%23FFFFFF' stroke-width='3.5' stroke-linecap='round'/></svg>") 12 12, crosshair !important;
}

/* ============================================================
   WASD HINT OVERLAY
   ============================================================ */
.wasd-hint {
  position: absolute;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base), transform var(--t-spring);
}

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

.wasd-hint-inner {
  background: rgba(8, 13, 26, 0.88);
  backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--r-xl);
  padding: 16px 22px 14px;
  box-shadow: var(--shadow-lg), 0 0 40px rgba(99, 102, 241, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 240px;
}

.wasd-hint-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--txt-3);
  text-transform: uppercase;
}

.wasd-keys {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.wasd-row { display: flex; gap: 5px; }

.wasd-key {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.03) 100%);
  border: 1px solid var(--stroke-accent);
  border-bottom: 2px solid rgba(99, 102, 241, 0.5);
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--txt);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.wasd-key-desc {
  font-size: 11px;
  color: var(--txt-3);
  text-align: center;
  line-height: 1.5;
}

.wasd-progress-wrap {
  width: 100%;
  height: 2px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--r-full);
  overflow: hidden;
  margin-top: 2px;
}

.wasd-progress-bar {
  height: 100%;
  width: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  transform-origin: left;
  animation: wasdCountdown 5s linear forwards;
}

@keyframes wasdCountdown {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ============================================================
   MOSQUE PILL ACTION BAR (Top Center HUD)
   ============================================================ */
.mosque-pill-container {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 13, 26, 0.80);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--r-xl);
  display: flex;
  flex-direction: column;
  padding: 0;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(99, 102, 241, 0.12) inset,
    0 1px 0 rgba(255, 255, 255, 0.06) inset;
  z-index: 2000;
  color: #fff;
  overflow: visible;
  transition: all var(--t-base);
  animation: pillEnter 0.4s var(--t-spring) both;
}

@keyframes pillEnter {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(0.96); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.mosque-pill-row {
  display: flex;
  align-items: center;
  padding: 7px 14px;
  gap: 10px;
}

.pill-row-sub {
  padding: 5px 14px 8px;
  gap: 10px;
  justify-content: center;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  animation: subRowSlide 0.25s var(--t-spring) both;
}

.pill-row-sub-divider { display: none; }

@keyframes subRowSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mosque-pill-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 4px;
}

.mosque-pill-info svg {
  opacity: 0.7;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

#mosqueBtnText {
  font-family: 'Outfit', sans-serif !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  background: linear-gradient(90deg, #fff, var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.1px;
}

.mosque-pill-divider {
  width: 1px;
  height: 22px;
  background: linear-gradient(180deg, transparent, var(--stroke-2), transparent);
  flex-shrink: 0;
}

.mosque-pill-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pill-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  color: var(--txt);
  padding: 6px 13px;
  border-radius: var(--r-full);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--t-fast);
  font-family: inherit;
  white-space: nowrap;
}

.pill-btn:hover {
  background: var(--accent-soft);
  border-color: var(--stroke-accent);
  color: var(--accent-2);
  box-shadow: 0 0 12px var(--accent-glow);
  transform: translateY(-1px);
}

.pill-btn.danger:hover {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.35);
  color: #fda4af;
}

.pill-divider {
  width: 1px;
  height: 18px;
  background: linear-gradient(180deg, transparent, var(--stroke-2), transparent);
  flex-shrink: 0;
}

/* ============================================================
   RIGHT NAV CAPSULE
   ============================================================ */
.nav-capsule {
  position: absolute;
  right: 16px;
  top: calc(50% - 16px);
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0;
  background: rgba(8, 13, 26, 0.80);
  backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid var(--stroke);
  border-radius: var(--r-full);
  box-shadow:
    var(--shadow-md),
    0 0 0 1px rgba(99, 102, 241, 0.08) inset;
  z-index: 1200;
}

.nav-cap-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  color: var(--txt-2);
  cursor: pointer;
  border-radius: 50%;
  transition: all var(--t-fast);
  font-size: 18px;
}

.nav-cap-btn:hover {
  color: #fff;
  background: var(--accent-soft);
  box-shadow: 0 0 14px var(--accent-glow);
}

.nav-cap-btn.active {
  color: var(--accent-2);
  background: var(--accent-soft);
}

.nav-cap-divider {
  width: 20px;
  height: 1px;
  background: var(--stroke);
  margin: 2px 0;
}

#compassNeedle { transition: transform 0.12s linear; }

/* ============================================================
   LANG TOGGLE
   ============================================================ */
.lang-toggle {
  flex-direction: row !important;
  gap: 4px;
  width: auto !important;
  padding: 0 12px !important;
  font-weight: 700 !important;
  font-size: 12px !important;
  color: var(--accent-2) !important;
}

/* ============================================================
   LEGEND PANEL
   ============================================================ */
.legend-panel {
  position: absolute;
  right: 68px;
  bottom: 40px;
  width: 58px;
  background: var(--surface-2);
  backdrop-filter: blur(16px);
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  padding: 10px 8px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity var(--t-base), transform var(--t-base);
  box-shadow: var(--shadow-md);
}

.legend-panel.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.legend-title {
  font-size: 9px;
  font-weight: 700;
  color: var(--txt-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  line-height: 1.3;
}

.legend-scale {
  display: flex;
  gap: 4px;
  align-items: stretch;
}

.legend-gradient {
  width: 13px;
  height: 120px;
  border-radius: var(--r-sm);
  background: linear-gradient(to bottom, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff);
  border: 1px solid var(--stroke);
}

.legend-ticks {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 8.5px;
  font-family: 'SF Mono', Consolas, monospace;
  color: var(--txt-3);
}

/* ============================================================
   MESH LED
   ============================================================ */
.mesh-pill-btn { gap: 7px; }

.mesh-led {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.35);
  border: 1px solid rgba(148, 163, 184, 0.3);
  flex-shrink: 0;
  transition: background var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
}

.mesh-led.active {
  background: var(--success);
  border-color: rgba(16, 185, 129, 0.6);
  box-shadow: 0 0 8px var(--success-glow), 0 0 2px rgba(16, 185, 129, 0.9);
  animation: ledPulse 2s ease-in-out infinite;
}

@keyframes ledPulse {
  0%   { box-shadow: 0 0 5px var(--success-glow), 0 0 2px rgba(16, 185, 129, 0.9); }
  50%  { box-shadow: 0 0 14px var(--success-glow), 0 0 4px rgba(16, 185, 129, 1); }
  100% { box-shadow: 0 0 5px var(--success-glow), 0 0 2px rgba(16, 185, 129, 0.9); }
}

.mesh-pill-btn.mesh-on {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  color: #34d399;
}

.mesh-pill-btn.mesh-on:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.55);
  color: #6ee7b7;
}

/* ============================================================
   POINT CLOUD LED
   ============================================================ */
.pc-pill-btn { gap: 7px; }

.pc-led {
  background: var(--success);
  border-color: rgba(16, 185, 129, 0.6);
  box-shadow: 0 0 8px var(--success-glow);
  animation: ledPulse 2s ease-in-out infinite;
}

.pc-led.pc-hidden {
  background: var(--danger);
  border-color: rgba(244, 63, 94, 0.6);
  box-shadow: 0 0 8px var(--danger-glow);
  animation: ledPulseRed 2s ease-in-out infinite;
}

@keyframes ledPulseRed {
  0%   { box-shadow: 0 0 5px var(--danger-glow); }
  50%  { box-shadow: 0 0 14px var(--danger-glow); }
  100% { box-shadow: 0 0 5px var(--danger-glow); }
}

.pc-pill-btn.pc-visible {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  color: #34d399;
}
.pc-pill-btn.pc-visible:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.55);
  color: #6ee7b7;
}

.pc-pill-btn.pc-hidden-state {
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.35);
  color: #fb7185;
}
.pc-pill-btn.pc-hidden-state:hover {
  background: rgba(244, 63, 94, 0.2);
  border-color: rgba(244, 63, 94, 0.55);
  color: #fda4af;
}

/* ============================================================
   HTML OVERLAY MARKERS
   ============================================================ */
#html-markers {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

.smart-tag-marker {
  position: absolute;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transform-origin: bottom left;
  pointer-events: auto;
  transition: opacity 0.2s ease, transform 0.05s linear;
  will-change: transform, opacity;
  opacity: 0;
  outline: none;
  user-select: none;
  cursor: pointer;
}

.smart-tag-marker.visible { opacity: 1; }

.smart-tag-marker:focus-visible .smart-tag-bubble {
  width: calc(42px + var(--smart-tag-label-width, 120px));
  background: rgba(8, 13, 26, 0.92);
  border-color: var(--stroke-accent);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), var(--shadow-lg);
}

.smart-tag-bubble {
  display: inline-flex;
  align-items: center;
  width: 42px;
  min-height: 42px;
  margin-left: -21px;
  padding: 0;
  background: rgba(8, 13, 26, 0.82);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(2, 6, 23, 0.4);
  transition:
    width 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.22s ease,
    border-color 0.22s ease,
    box-shadow 0.22s ease,
    transform 0.22s ease;
}

.smart-tag-marker:is(:hover, :focus-visible, :focus-within) .smart-tag-bubble {
  width: calc(42px + var(--smart-tag-label-width, 120px));
  background: rgba(10, 16, 35, 0.92);
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow: 0 16px 36px rgba(2, 6, 23, 0.45);
  transform: translateY(-1px);
}

.smart-tag-icon {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.smart-tag-icon svg {
  width: 20px;
  height: 20px;
  fill: var(--success);
  filter: drop-shadow(0 0 8px var(--success-glow));
}

.smart-tag-label {
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-8px);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 11.5px;
  line-height: 1;
  letter-spacing: 0.01em;
  padding: 0;
  transition:
    width 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.18s ease,
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    padding-right 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.smart-tag-marker:is(:hover, :focus-visible, :focus-within) .smart-tag-label {
  width: var(--smart-tag-label-width, 120px);
  opacity: 1;
  transform: translateX(0);
  padding-right: 14px;
}

.smart-tag-leader {
  position: relative;
  width: 1px;
  height: var(--smart-tag-leader-height, 38px);
  margin-top: 6px;
  margin-left: -0.5px;
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.7) 0%, rgba(148, 163, 184, 0.18) 100%);
}

.smart-tag-leader::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: -3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.75);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.14);
}

/* ============================================================
   DOWNLOAD DROPDOWN
   ============================================================ */
.dropdown-wrapper {
  position: relative;
  display: inline-block;
  padding-bottom: 20px;
  margin-bottom: -20px;
}

.dropdown-hover-btn {
  justify-content: center;
}

.dropdown-menu-mosque {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  background: var(--surface-3);
  backdrop-filter: blur(20px);
  border: 1px solid var(--stroke-2);
  border-radius: var(--r-md);
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  margin-top: -2px;
  overflow: hidden;
}

.dropdown-wrapper:hover .dropdown-menu-mosque { display: block; }

.dropdown-item-mosque {
  display: block;
  padding: 11px 16px;
  color: var(--txt);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  transition: background var(--t-fast), color var(--t-fast);
  border-bottom: 1px solid var(--stroke);
}

.dropdown-item-mosque:last-child { border-bottom: none; }

.dropdown-item-mosque:hover {
  background: var(--accent-soft);
  color: var(--accent-2);
}

/* ============================================================
   DOWNLOAD MODAL
   ============================================================ */
.dl-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 12, 0.88);
  backdrop-filter: blur(12px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}

.dl-modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.dl-modal-box {
  background: var(--surface-2);
  border: 1px solid var(--stroke-2);
  border-radius: var(--r-xl);
  padding: 36px 32px 28px;
  width: 90%;
  max-width: 440px;
  text-align: center;
  box-shadow:
    var(--shadow-lg),
    0 0 0 1px rgba(99, 102, 241, 0.08) inset,
    0 1px 0 rgba(255,255,255,0.06) inset;
  transform: translateY(24px) scale(0.97);
  transition: transform var(--t-spring);
  position: relative;
  overflow: hidden;
}

/* Top accent line on modal */
.dl-modal-box::before {
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--cyan), transparent);
  border-radius: var(--r-full);
}

.dl-modal-overlay.show .dl-modal-box {
  transform: translateY(0) scale(1);
}

.dl-modal-title {
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 14px 0;
  letter-spacing: -0.3px;
}

.dl-modal-desc {
  color: var(--txt-2);
  font-size: 14.5px;
  margin-bottom: 26px;
  line-height: 1.6;
}

.dl-modal-desc strong { color: var(--cyan); }

.dl-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ============================================================
   DOWNLOAD PROGRESS WIDGET
   ============================================================ */
.dl-widget {
  position: fixed;
  bottom: 44px;
  right: 18px;
  width: 310px;
  background: var(--surface-2);
  backdrop-filter: blur(16px);
  border: 1px solid var(--stroke-2);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-lg), 0 0 20px var(--accent-glow);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) translateX(10px);
  transition: all var(--t-spring);
}

.dl-widget.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) translateX(0);
}

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

.dl-w-title {
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  font-family: 'Outfit', sans-serif;
}

.dl-w-speed {
  color: var(--cyan);
  font-weight: 600;
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 12px;
}

.dl-widget-bar-bg {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--r-full);
  overflow: hidden;
  margin-bottom: 10px;
}

.dl-widget-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--cyan));
  border-radius: var(--r-full);
  transition: width 0.25s linear;
  position: relative;
}

.dl-widget-fill::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 30px; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5));
  border-radius: var(--r-full);
  animation: progressShine 1.2s ease-in-out infinite;
}

.dl-widget-footer {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--txt-2);
  font-family: 'SF Mono', Consolas, monospace;
  margin-bottom: 12px;
}

.dl-w-percent {
  font-weight: 700;
  color: var(--txt);
}

/* Download action buttons (in widget) */
.dl-widget-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.dl-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--stroke-2);
  background: rgba(255, 255, 255, 0.06);
  color: var(--txt);
  transition: all var(--t-fast);
  font-family: inherit;
}

.dl-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--stroke-accent);
  color: #fff;
  transform: translateY(-1px);
}

.dl-btn-danger {
  background: rgba(244, 63, 94, 0.10);
  border-color: rgba(244, 63, 94, 0.25);
  color: #fb7185;
}

.dl-btn-danger:hover {
  background: rgba(244, 63, 94, 0.20);
  border-color: rgba(244, 63, 94, 0.45);
  color: #fda4af;
}

.dl-btn.resume {
  background: rgba(16, 185, 129, 0.10);
  border-color: rgba(16, 185, 129, 0.25);
  color: #34d399;
}

.dl-btn.resume:hover {
  background: rgba(16, 185, 129, 0.20);
  border-color: rgba(16, 185, 129, 0.45);
  color: #6ee7b7;
}

/* Modal cancel/confirm buttons */
.dl-cancel {
  background: rgba(255, 255, 255, 0.07);
  color: var(--txt);
  border: 1px solid var(--stroke-2);
  padding: 11px 22px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  font-family: inherit;
}

.dl-cancel:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--stroke-accent);
  color: #fff;
}

.dl-confirm {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  border: none;
  padding: 11px 22px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  font-family: inherit;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.dl-confirm:hover {
  background: linear-gradient(135deg, var(--accent-hover), #3730a3);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

/* ============================================================
   EXPORT POPUP
   ============================================================ */
.export-popup {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface-2);
  backdrop-filter: blur(20px);
  border: 1px solid var(--stroke-2);
  border-radius: var(--r-xl);
  width: 90%; max-width: 480px;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
}

.export-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(99, 102, 241, 0.06);
}

.export-header h3 {
  margin: 0;
  font-size: 15px;
  font-family: 'Outfit', sans-serif;
  color: #fff;
}

.export-close {
  background: none; border: none; color: var(--txt-2);
  font-size: 22px; cursor: pointer; padding: 0; line-height: 1;
  transition: color var(--t-fast);
}
.export-close:hover { color: #fff; }

.export-content { padding: 16px; font-size: 14px; color: var(--txt-2); }

.export-footer {
  padding: 12px 16px; border-top: 1px solid var(--stroke);
  display: flex; justify-content: flex-end;
  background: rgba(5, 8, 15, 0.4);
}

/* ============================================================
   SEGMENTED CONTROL
   ============================================================ */
.seg {
  display: flex;
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: rgba(0,0,0,0.2);
}

.seg button {
  flex: 1;
  padding: 8px 10px;
  color: var(--txt-2);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: all var(--t-fast);
}

.seg button.active {
  background: var(--accent-soft);
  color: var(--accent-2);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .sidebar { width: 100%; }
}

@media (max-width: 768px) {
  body { font-size: 13.5px; }

  .seg { flex-direction: column; border-radius: var(--r-md); }
  .seg button { padding: 9px 10px; text-align: left; }
  .seg button + button { border-top: 1px solid var(--stroke); }
}

@media (max-width: 420px) {
  .sidebar-header { padding: 14px 16px; }
}

/* ============================================================
   LOW UI MODE
   ============================================================ */
body.lowui .sidebar,
body.lowui .nav-capsule,
body.lowui .mosque-pill-container,
body.lowui .status-bar {
  backdrop-filter: none;
  background: var(--bg-3);
}
