:root {
  --bg1: #04121e;
  --bg2: #0a2536;
  --accent: #00e5ff;
  --accent2: #3affc4;
  --panel: rgba(9, 30, 45, 0.72);
  --border: rgba(0, 229, 255, 0.28);
  --text: #dff3fb;
}

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

html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: 'Vazirmatn', 'Space Grotesk', sans-serif;
  background: radial-gradient(circle at 50% 20%, var(--bg2), var(--bg1) 70%);
  color: var(--text);
}

#scene-container, #label-layer {
  position: fixed; inset: 0;
}
#label-layer { pointer-events: none; }

/* ---------- Header ---------- */
#app-header {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 14px 20px;
  background: linear-gradient(180deg, rgba(4,18,30,0.85), rgba(4,18,30,0));
  z-index: 20;
  animation: dropIn 0.8s cubic-bezier(.2,.9,.3,1);
}
#app-header h1 {
  font-size: clamp(15px, 4vw, 24px);
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 18px rgba(0,229,255,0.35);
}
.hx-icon { font-size: 22px; filter: drop-shadow(0 0 8px var(--accent)); }

/* ---------- Panel ---------- */
#panel {
  position: fixed; top: 78px; right: 16px;
  width: 240px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  z-index: 25;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), inset 0 0 20px rgba(0,229,255,0.05);
  animation: dropIn 1s 0.15s backwards cubic-bezier(.2,.9,.3,1);
}
.panel-title {
  font-weight: 800; font-size: 14px; margin-bottom: 12px;
  color: var(--accent2); letter-spacing: 0.5px;
}

.layer-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  font-family: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all 0.22s ease;
}
.layer-btn .lb-emoji { font-size: 18px; }
.layer-btn .lb-text { flex: 1; text-align: right; }
.layer-btn .lb-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #445; transition: all 0.22s;
}
.layer-btn:hover { border-color: var(--border); transform: translateX(-3px); }
.layer-btn.active {
  background: linear-gradient(90deg, rgba(0,229,255,0.14), rgba(58,255,196,0.08));
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(0,229,255,0.25);
}
.layer-btn.active .lb-dot {
  background: var(--accent2);
  box-shadow: 0 0 10px var(--accent2);
}
.layer-btn:not(.active) { opacity: 0.55; }

.slider-row { margin: 14px 0 10px; }
.slider-row label { font-size: 12px; opacity: 0.8; display: block; margin-bottom: 6px; }
input[type=range] {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 5px; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.toggle-row { display: flex; gap: 8px; margin-bottom: 8px; }
.mini-btn {
  flex: 1;
  padding: 9px 6px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  font-family: inherit; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.2s;
}
.mini-btn.wide { width: 100%; margin-top: 2px; }
.mini-btn:hover { border-color: var(--border); }
.mini-btn.active {
  background: linear-gradient(90deg, rgba(0,229,255,0.16), rgba(58,255,196,0.1));
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Mobile toggle ---------- */
.mobile-toggle {
  display: none;
  position: fixed; top: 66px; right: 16px; z-index: 30;
  width: 46px; height: 46px; border-radius: 12px;
  background: var(--panel); backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  color: var(--accent); font-size: 22px;
  align-items: center; justify-content: center;
  cursor: pointer;
}

/* ---------- Labels ---------- */
.part-label {
  font-family: 'Vazirmatn', sans-serif;
  font-size: 12px; font-weight: 500;
  color: #eaffff;
  background: rgba(4,18,30,0.75);
  border: 1px solid var(--border);
  padding: 3px 9px; border-radius: 20px;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  box-shadow: 0 0 10px rgba(0,229,255,0.2);
  transform: translate(-50%, -50%);
}
.part-label::before {
  content: ''; position: absolute;
  right: -6px; top: 50%;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 6px var(--accent2);
}

/* ---------- Tooltip ---------- */
.tooltip {
  position: fixed; display: none; z-index: 40;
  max-width: 200px;
  background: var(--panel); backdrop-filter: blur(12px);
  border: 1px solid var(--accent);
  border-radius: 12px; padding: 10px 14px;
  font-size: 13px; line-height: 1.6;
  color: var(--text);
  box-shadow: 0 6px 24px rgba(0,0,0,0.6), 0 0 16px rgba(0,229,255,0.3);
  pointer-events: none;
}
.tooltip b { color: var(--accent2); font-size: 15px; }

/* ---------- Hint ---------- */
.hint {
  position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%);
  background: var(--panel); backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  padding: 10px 18px; border-radius: 30px;
  font-size: 13px; z-index: 22;
  box-shadow: 0 0 20px rgba(0,229,255,0.2);
  animation: pulseHint 2.2s ease-in-out infinite;
}
.hint.fade { opacity: 0; transition: opacity 0.8s; }

/* ---------- Footer ---------- */
#footer {
  position: fixed; bottom: 8px; left: 14px; z-index: 22;
  font-size: 11px;
}
#footer a {
  color: rgba(223,243,251,0.55); text-decoration: none;
  transition: color 0.2s;
}
#footer a:hover { color: var(--accent); }

/* ---------- Animations ---------- */
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-18px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulseHint {
  0%,100% { box-shadow: 0 0 12px rgba(0,229,255,0.15); }
  50%     { box-shadow: 0 0 26px rgba(0,229,255,0.4); }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .mobile-toggle { display: flex; }
  #panel {
    top: 62px; right: 10px; left: 10px; width: auto;
    transform: translateY(-130%); opacity: 0;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(.2,.9,.3,1), opacity 0.3s;
  }
  #panel.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .hint { bottom: 40px; font-size: 11px; padding: 8px 14px; width: 88%; text-align: center; }
}