html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: #0b0d10;
  color: #e8eef2;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, 'Apple Color Emoji', 'Segoe UI Emoji';
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#glcanvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

#hud {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(15, 20, 26, 0.85);
  backdrop-filter: blur(12px);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  font-weight: 500;
  letter-spacing: 0.3px;
}

#perf-info {
  margin-top: 6px;
  font-size: 11px;
  color: #a7d2ff;
  line-height: 1.4;
  letter-spacing: 0.2px;
}

#uploader {
  position: absolute;
  right: 16px;
  top: 72px; /* drop below the toggle button so icons aren't hidden */
  bottom: 16px;
  width: 340px;
  max-height: calc(100vh - 88px);
  background: rgba(15, 20, 26, 0.92);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  padding: 0;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Hidden by default, toggled via .visible class */
  transform: translateX(calc(100% + 16px));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#uploader.visible {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* Panel toggle button */
#panel-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 100;
  background: rgba(15, 20, 26, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  color: #cfe3f7;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#panel-toggle:hover {
  background: rgba(59, 180, 255, 0.2);
  border-color: rgba(59, 180, 255, 0.5);
  color: #3ab4ff;
  transform: scale(1.05);
}

#panel-toggle.active {
  background: rgba(59, 180, 255, 0.25);
  border-color: rgba(59, 180, 255, 0.6);
  color: #3ab4ff;
}

.hidden { display: none; }

/* Uploader header */
.uploader-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 0 16px;
  gap: 8px;
}

.header-title {
  font-size: 16px;
  font-weight: 600;
  color: #e8eef2;
  letter-spacing: 0.3px;
}

.icon-btn {
  background: rgba(59, 180, 255, 0.1);
  border: 1px solid rgba(59, 180, 255, 0.3);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  color: #3ab4ff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(59, 180, 255, 0.2);
  border-color: rgba(59, 180, 255, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 180, 255, 0.3);
}

.icon-btn:active {
  transform: translateY(0);
}

.icon-btn svg {
  display: block;
}

/* Server file browser modal */
#server-file-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

#server-file-modal.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

.modal-content {
  background: rgba(15, 20, 26, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 24px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #e8eef2;
}

.modal-close {
  background: rgba(255, 100, 100, 0.1);
  border: 1px solid rgba(255, 100, 100, 0.3);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  color: #ff6464;
  font-size: 18px;
  line-height: 1;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: rgba(255, 100, 100, 0.2);
  border-color: rgba(255, 100, 100, 0.5);
}

.file-list {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-list::-webkit-scrollbar {
  width: 8px;
}

.file-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
}

.file-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.file-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.file-item {
  padding: 12px 16px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-item:hover {
  background: rgba(59, 180, 255, 0.1);
  border-color: rgba(59, 180, 255, 0.3);
  transform: translateX(4px);
}

.file-item-icon {
  color: #3ab4ff;
  font-size: 20px;
}

.file-item-name {
  flex: 1;
  color: #e8eef2;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-loading {
  text-align: center;
  padding: 40px;
  color: #afc6db;
}

.modal-error {
  text-align: center;
  padding: 40px;
  color: #ff6464;
}

.dropzone {
  border: 2px dashed rgba(59, 180, 255, 0.3);
  padding: 20px;
  margin: 16px;
  border-radius: 12px;
  text-align: center;
  color: #cfe3f7;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.02);
}

.dropzone:hover {
  background: rgba(59, 180, 255, 0.05);
  border-color: rgba(59, 180, 255, 0.5);
  transform: translateY(-1px);
}

.dropzone.dragover {
  background: rgba(59, 180, 255, 0.12);
  border-color: rgba(59, 180, 255, 0.8);
  box-shadow: 0 0 20px rgba(59, 180, 255, 0.2);
}

.dropzone input[type="file"] {
  display: none;
}

.dropzone strong {
  color: #3ab4ff;
  font-weight: 600;
}

#file-info {
  margin: 0 16px 12px 16px;
  font-size: 12px;
  color: #afc6db;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

#progress {
  margin: 0 16px 12px 16px;
}

#progress-bar {
  height: 4px;
  width: 0%;
  background: linear-gradient(90deg, #3ab4ff, #5ac8ff);
  border-radius: 3px;
  transition: width 120ms ease;
  box-shadow: 0 0 10px rgba(58, 180, 255, 0.5);
}

#progress-text {
  margin-top: 8px;
  font-size: 11px;
  color: #cfe3f7;
  opacity: 0.9;
}

#cancel-btn {
  margin-top: 8px;
  font-size: 12px;
  padding: 6px 12px;
  background: rgba(100, 40, 40, 0.4);
  border: 1px solid rgba(200, 80, 80, 0.3);
  border-radius: 6px;
  color: #ffb3b3;
  cursor: pointer;
  transition: all 0.2s ease;
}

#cancel-btn:hover {
  background: rgba(120, 40, 40, 0.6);
  border-color: rgba(220, 80, 80, 0.5);
}

#url-loader {
  display: flex;
  gap: 8px;
  margin: 0 16px 16px 16px;
  flex-wrap: wrap;
}

#url-input {
  flex: 1 1 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  color: #e8eef2;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-size: 12px;
  transition: all 0.2s ease;
}

#url-input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(59, 180, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(59, 180, 255, 0.1);
}

#load-url-btn {
  flex: 1 1 auto;
  padding: 8px 16px;
  background: linear-gradient(135deg, rgba(32, 48, 64, 0.8), rgba(40, 60, 80, 0.8));
  border: 1px solid rgba(59, 180, 255, 0.3);
  border-radius: 8px;
  color: #cfe3f7;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

#load-url-btn:hover {
  background: linear-gradient(135deg, rgba(59, 180, 255, 0.2), rgba(70, 190, 255, 0.25));
  border-color: rgba(59, 180, 255, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 180, 255, 0.2);
}

#clear-btn {
  flex: 0 0 auto;
  padding: 8px 16px;
  background: rgba(80, 40, 40, 0.4);
  border: 1px solid rgba(120, 60, 60, 0.4);
  border-radius: 8px;
  color: #ffb3b3;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

#clear-btn:hover {
  background: rgba(100, 40, 40, 0.6);
  border-color: rgba(160, 60, 60, 0.6);
  transform: translateY(-1px);
}

/* Scrollable controls container */
#controls {
  margin: 0;
  padding: 0 16px 16px 16px;
  display: grid;
  gap: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
}

/* Custom scrollbar */
#controls::-webkit-scrollbar {
  width: 8px;
}

#controls::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
}

#controls::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

#controls::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Section styling */
#controls .row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all 0.2s ease;
}

#controls .row.camera-row {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

#controls .row.camera-row > label {
  margin-bottom: 4px;
}

/* Camera controls container */
.camera-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Icon action buttons */
.icon-action-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(59, 180, 255, 0.15), rgba(70, 190, 255, 0.2));
  border: 1px solid rgba(59, 180, 255, 0.4);
  color: #cfe3f7;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-action-btn:hover {
  background: linear-gradient(135deg, rgba(59, 180, 255, 0.25), rgba(70, 190, 255, 0.3));
  border-color: rgba(59, 180, 255, 0.7);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 180, 255, 0.3);
}

.icon-action-btn:active {
  transform: translateY(0);
}

.icon-action-btn svg {
  display: block;
}

#controls .row:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

#controls label {
  min-width: 95px;
  font-size: 12px;
  color: #cfe3f7;
  font-weight: 500;
}

/* Range inputs */
#controls input[type="range"] {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
}

#controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: linear-gradient(135deg, #3ab4ff, #5ac8ff);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(58, 180, 255, 0.4);
  transition: all 0.2s ease;
}

#controls input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 10px rgba(58, 180, 255, 0.6);
}

#controls input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: linear-gradient(135deg, #3ab4ff, #5ac8ff);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(58, 180, 255, 0.4);
}

#controls input[type="range"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#controls input[type="range"]:disabled::-webkit-slider-thumb {
  background: #666;
  cursor: not-allowed;
  box-shadow: none;
}

#controls input[type="range"]:disabled::-moz-range-thumb {
  background: #666;
  cursor: not-allowed;
  box-shadow: none;
}

/* Select inputs */
#controls select {
  flex: 1;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #e8eef2;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

#controls select:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

#controls select:focus {
  border-color: rgba(59, 180, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(59, 180, 255, 0.1);
}

/* Select options */
#controls select option {
  background: #1a2530;
  color: #e8eef2;
  padding: 6px 10px;
}

#controls select option:hover,
#controls select option:checked {
  background: rgba(59, 180, 255, 0.2);
  color: #fff;
}

/* Checkboxes */
#controls input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #3ab4ff;
}

/* Value indicators */
#controls span[id$="-value"],
#attr-value,
#point-size-value {
  min-width: 32px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #3ab4ff;
  background: rgba(59, 180, 255, 0.15);
  padding: 2px 8px;
  border-radius: 6px;
}

/* Button groups */
#controls .buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

#controls .preset {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cfe3f7;
  border-radius: 7px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  transition: all 0.2s ease;
}

#controls .preset:hover {
  background: rgba(59, 180, 255, 0.15);
  border-color: rgba(59, 180, 255, 0.4);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(59, 180, 255, 0.2);
}

#controls .preset:active {
  transform: translateY(0);
}

/* Action buttons */
#controls .action-btn {
  padding: 8px 16px;
  background: linear-gradient(135deg, rgba(59, 180, 255, 0.15), rgba(70, 190, 255, 0.2));
  border: 1px solid rgba(59, 180, 255, 0.4);
  color: #cfe3f7;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}

#controls .action-btn:hover {
  background: linear-gradient(135deg, rgba(59, 180, 255, 0.25), rgba(70, 190, 255, 0.3));
  border-color: rgba(59, 180, 255, 0.7);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 180, 255, 0.3);
}

#controls .action-btn:active {
  transform: translateY(0);
}

.view-cube {
  position: relative;
  flex: 0 0 70px;
  width: 70px;
  height: 70px;
  margin-left: auto;
  perspective: 500px;
  cursor: grab;
}

.view-cube:active {
  cursor: grabbing;
}

.view-cube .cube {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateX(var(--cube-rot-x, -20deg)) rotateY(var(--cube-rot-y, -30deg));
  transition: transform 0.15s ease;
}

.view-cube .cube-face {
  position: absolute;
  width: 46px;
  height: 46px;
  top: 12px;
  left: 12px;
  padding: 0;
  --face-transform: translateZ(23px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(135deg, rgba(59, 180, 255, 0.15), rgba(70, 190, 255, 0.25));
  color: #e8eef2;
  font-weight: 700;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  transition: box-shadow 0.1s ease, border-color 0.1s ease;
  backface-visibility: hidden;
  pointer-events: auto;
  transform: var(--face-transform);
}

.view-cube .cube-face:hover,
.view-cube .cube-face:active {
  transform: var(--face-transform); /* override preset hover translate */
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.view-cube .cube-face::after {
  content: "";
  position: absolute;
  inset: -2px;
  border: 2px solid transparent;
  border-radius: 8px;
  pointer-events: none;
  transition: border-color 0.1s ease;
}

.view-cube .cube-face:hover::after {
  border-color: rgba(255, 80, 80, 0.8);
}

.view-cube .cube-face:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  transform: var(--face-transform);
}

.view-cube .cube-face.front { --face-transform: translateZ(23px); }
.view-cube .cube-face.back { --face-transform: rotateY(180deg) translateZ(23px); }
.view-cube .cube-face.left { --face-transform: rotateY(-90deg) translateZ(23px); }
.view-cube .cube-face.right { --face-transform: rotateY(90deg) translateZ(23px); }
.view-cube .cube-face.top { --face-transform: rotateX(90deg) translateZ(23px); }
.view-cube .cube-face.bottom { --face-transform: rotateX(-90deg) translateZ(23px); }

.view-cube .cube-face:hover::after,
.view-cube .cube-face:active::after {
  border-color: rgba(255, 80, 80, 0.8);
}

/* Override generic preset hover/active transform for cube faces */
#controls .view-cube .cube-face,
#controls .view-cube .cube-face:hover,
#controls .view-cube .cube-face:active {
  transform: var(--face-transform) !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.view-cube .cube-face:hover::after,
.view-cube .cube-face:active::after {
  border-color: rgba(255, 80, 80, 0.8);
}

/* Stats section */
#controls .stats {
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: #afc6db;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
}

#controls .stats div {
  padding: 4px 0;
  font-family: 'Courier New', monospace;
}

/* Timing info */
#timing-info {
  font-family: 'Courier New', monospace;
  opacity: 0.8;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  #uploader {
    width: calc(100vw - 32px);
    left: 16px;
    right: 16px;
    max-height: 50vh;
  }

  #controls label {
    min-width: 80px;
    font-size: 11px;
  }
}
