/* ==================== GL Background (feat/gl-background) ====================
   Generativer WebGL-Hintergrund: Domain-warped Fluid-Filamente, Blüte des
   Lebens als SDF im Feld, Hex-Lattice-Flüstern. Fixed hinter allem Content,
   respektiert prefers-reduced-motion, Fallback auf statisches Gradient. */

#glbg {
  position: fixed;
  inset: 0;
  z-index: -2;
  display: block;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

/* Fallback-Layer (sichtbar wenn body.nogl) */
#glbg-fallback {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 20% 0%, rgba(58, 228, 255, 0.10), transparent 50%),
    radial-gradient(circle at 85% 100%, rgba(148, 87, 255, 0.10), transparent 55%),
    linear-gradient(to bottom, #05060a 0%, #020309 100%);
  pointer-events: none;
  opacity: 0;
}

body.nogl #glbg { display: none; }
body.nogl #glbg-fallback { opacity: 1; }

/* Auf schwacher Hardware/ohne GPU: statisches Gradient statt Canvas */
body.glbg-lowfi #glbg { display: none; }
body.glbg-lowfi #glbg-fallback { opacity: 1; }

/* Reduced motion: Canvas komplett aus, statischer Look */
@media (prefers-reduced-motion: reduce) {
  #glbg { display: none; }
  #glbg-fallback { opacity: 1; }
}

/* ==================== GL-BG Tweaks Panel ==================== */
#glbg-tweaks {
  position: fixed;
  right: 0.9rem;
  bottom: 0.9rem;
  z-index: 60;
  width: 220px;
  padding: 0.75rem 0.85rem 0.85rem;
  background: rgba(8, 10, 20, 0.92);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-strip);
  font-family: var(--font);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
}
#glbg-tweaks.glbt-hidden { display: none; }
.glbt-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  color: var(--accent);
  font-weight: 700;
}
.glbt-x {
  background: none;
  border: none;
  color: var(--muted-soft);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
.glbt-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0;
}
.glbt-row span { width: 64px; flex: none; }
.glbt-row output {
  width: 22px;
  flex: none;
  text-align: right;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}
.glbt-copy {
  width: 100%;
  margin-top: 0.55rem;
  padding: 0.38rem 0;
  background: rgba(58, 228, 255, 0.10);
  border: 1px solid var(--accent-soft);
  border-radius: 3px;
  color: var(--accent);
  font: inherit;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.glbt-copy:active { background: rgba(58, 228, 255, 0.22); }
.glbt-row input[type="range"] {
  flex: 1;
  height: 2px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--border-strong);
  border-radius: 1px;
  outline: none;
}
.glbt-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  cursor: ew-resize;
  box-shadow: 0 0 6px var(--accent-soft);
}
.glbt-presets {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.6rem;
}
.glbt-presets button {
  flex: 1;
  padding: 0.3rem 0;
  background: rgba(58, 228, 255, 0.07);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  color: var(--muted);
  font: inherit;
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.glbt-presets button:hover {
  border-color: var(--accent-soft);
  color: var(--accent);
}

@media (max-width: 760px) {
  #glbg-tweaks { width: 190px; right: 0.6rem; bottom: 0.6rem; }
}

/* ==================== GL-LAB (großes Panel auf lab.php) ==================== */
#glbg-tweaks.glbt-lab {
  top: 0.9rem;
  right: 0.9rem;
  bottom: auto;
  width: 300px;
  max-height: calc(100vh - 1.8rem);
  overflow-y: auto;
  padding: 0.85rem 0.95rem 0.95rem;
  font-size: 0.66rem;
}
#glbg-tweaks.glbt-lab .glbt-row span { width: 78px; }
#glbg-tweaks.glbt-lab .glbt-row output { width: 34px; }
.glbt-sec {
  margin: 0.7rem 0 0.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-subtle);
  color: var(--accent);
  opacity: 0.75;
  font-weight: 700;
}
.glbt-sec:first-of-type { margin-top: 0.2rem; padding-top: 0; border-top: none; }
.glbt-actions {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.6rem;
}
.glbt-actions button {
  flex: 1;
  padding: 0.35rem 0;
  background: rgba(58, 228, 255, 0.07);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  color: var(--muted);
  font: inherit;
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.glbt-actions button:hover {
  border-color: var(--accent-soft);
  color: var(--accent);
}
.glbt-lablink {
  display: block;
  margin-top: 0.45rem;
  color: var(--accent);
  opacity: 0.8;
  text-decoration: none;
  font-size: 0.58rem;
}
.glbt-lablink:hover { opacity: 1; text-decoration: underline; }

@media (max-width: 760px) {
  #glbg-tweaks.glbt-lab {
    width: min(300px, calc(100vw - 1.2rem));
    top: 0.6rem;
    right: 0.6rem;
  }
}