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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a14;
  font-family: 'Courier New', monospace;
}

#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#title-badge {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(180, 200, 255, 0.4);
  font-size: clamp(0.55rem, 1.2vw, 0.75rem);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

#toggle-panel {
  position: fixed;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 100;
  background: rgba(30, 20, 60, 0.7);
  border: 1px solid rgba(140, 120, 255, 0.3);
  color: rgba(200, 190, 255, 0.9);
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  border-radius: 3px;
  backdrop-filter: blur(6px);
}
#toggle-panel:hover { background: rgba(60, 40, 120, 0.8); }

#panel {
  position: fixed;
  top: 2.4rem;
  right: 0.6rem;
  z-index: 99;
  width: min(20rem, 90vw);
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  background: rgba(12, 8, 28, 0.9);
  border: 1px solid rgba(140, 120, 255, 0.25);
  border-radius: 5px;
  backdrop-filter: blur(10px);
  color: rgba(210, 200, 255, 0.92);
  font-size: 0.72rem;
  padding: 0.6rem;
  display: none;
}
#panel.open { display: block; }

#panel::-webkit-scrollbar { width: 4px; }
#panel::-webkit-scrollbar-track { background: transparent; }
#panel::-webkit-scrollbar-thumb { background: rgba(140, 120, 255, 0.3); border-radius: 2px; }

#layers-container {
  margin-bottom: 0.5rem;
}

.layer-card {
  background: rgba(30, 22, 60, 0.6);
  border: 1px solid rgba(120, 100, 220, 0.2);
  border-radius: 4px;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
}

.layer-card.circular { border-left: 3px solid rgba(100, 180, 255, 0.6); }
.layer-card.plane { border-left: 3px solid rgba(255, 160, 100, 0.6); }
.layer-card.spiral { border-left: 3px solid rgba(160, 255, 120, 0.6); }

.layer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.layer-title {
  font-weight: bold;
  font-size: 0.78rem;
  color: rgba(180, 170, 255, 0.95);
}

.layer-controls {
  display: flex;
  gap: 0.3rem;
}

.btn-vis, .btn-remove {
  background: rgba(35, 28, 72, 0.5);
  border: 1px solid rgba(115, 95, 215, 0.22);
  color: rgba(168, 155, 238, 0.82);
  font-size: 0.62rem;
  padding: 0.1rem 0.28rem;
  cursor: pointer;
  border-radius: 2px;
  font-family: 'Courier New', monospace;
  line-height: 1;
}
.btn-vis:hover, .btn-remove:hover { background: rgba(62, 50, 138, 0.65); }
.btn-vis.hidden { color: rgba(95, 80, 165, 0.42); }
.btn-remove {
  background: rgba(100, 30, 30, 0.5);
  border-color: rgba(200, 80, 80, 0.3);
  color: rgba(255, 160, 160, 0.85);
}
.btn-remove:hover { background: rgba(140, 40, 40, 0.6); }

.ctrl-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}

.ctrl-row label {
  flex: 0 0 5.5rem;
  font-size: 0.65rem;
  color: rgba(170, 160, 240, 0.75);
}

.ctrl-row input[type="range"] {
  flex: 1;
  height: 3px;
  accent-color: #8b7aff;
}

.ctrl-row .val {
  flex: 0 0 2.5rem;
  text-align: right;
  font-size: 0.62rem;
  color: rgba(160, 150, 230, 0.65);
}

.ctrl-row select {
  flex: 1;
  background: rgba(20, 15, 40, 0.7);
  border: 1px solid rgba(140, 120, 255, 0.25);
  color: rgba(210, 200, 255, 0.9);
  font-family: 'Courier New', monospace;
  font-size: 0.65rem;
  padding: 0.2rem 0.3rem;
  border-radius: 3px;
  outline: none;
}

.ctrl-row input[type="color"] {
  flex: 1;
  height: 1.3rem;
  border: 1px solid rgba(140, 120, 255, 0.25);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.pos-pad {
  position: relative;
  width: 100%;
  height: 4rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(120, 100, 220, 0.2);
  border-radius: 3px;
  margin-top: 0.2rem;
  margin-bottom: 0.3rem;
  cursor: crosshair;
}
.pos-pad::before,
.pos-pad::after {
  content: '';
  position: absolute;
  background: rgba(120, 100, 220, 0.12);
  pointer-events: none;
}
.pos-pad::before { left: 50%; top: 0; width: 1px; height: 100%; }
.pos-pad::after { top: 50%; left: 0; width: 100%; height: 1px; }

.pos-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #8b7aff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 6px rgba(139, 122, 255, 0.6);
}

.add-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
}

.btn-add {
  flex: 1;
  padding: 0.4rem 0.2rem;
  background: rgba(60, 50, 120, 0.5);
  border: 1px dashed rgba(140, 120, 255, 0.35);
  color: rgba(180, 170, 255, 0.85);
  font-family: 'Courier New', monospace;
  font-size: 0.7rem;
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
}
.btn-add:hover { background: rgba(80, 65, 160, 0.6); }

.global-section, .preset-section {
  background: rgba(25, 18, 50, 0.5);
  border: 1px solid rgba(100, 80, 180, 0.2);
  border-radius: 4px;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
}

.section-title {
  font-weight: bold;
  font-size: 0.72rem;
  color: rgba(150, 140, 220, 0.85);
  margin-bottom: 0.4rem;
  letter-spacing: 0.05em;
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.preset-btn {
  flex: 1;
  min-width: 4rem;
  padding: 0.3rem 0.4rem;
  background: rgba(50, 40, 100, 0.5);
  border: 1px solid rgba(120, 100, 220, 0.25);
  color: rgba(180, 170, 255, 0.8);
  font-family: 'Courier New', monospace;
  font-size: 0.65rem;
  cursor: pointer;
  border-radius: 3px;
  white-space: nowrap;
}
.preset-btn:hover { background: rgba(70, 55, 140, 0.6); }

#btn-clear {
  width: 100%;
  padding: 0.4rem;
  background: rgba(80, 25, 25, 0.5);
  border: 1px dashed rgba(220, 80, 80, 0.35);
  color: rgba(255, 180, 180, 0.85);
  font-family: 'Courier New', monospace;
  font-size: 0.7rem;
  cursor: pointer;
  border-radius: 4px;
  margin-top: 0.3rem;
}
#btn-clear:hover { background: rgba(120, 35, 35, 0.6); }
