/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-dark:   #0f0f1a;
  --bg-panel:  #1a1a2e;
  --bg-input:  #16213e;
  --accent:    #0f9b8e;
  --accent-hi: #14d4c4;
  --text:      #e0e0e0;
  --text-dim:  #8888aa;
  --sidebar-w: 280px;
  --radius:    6px;
}

html, body {
  height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  overflow: hidden;
}

/* ── Loading overlay ─────────────────────────────────────── */
#loading-overlay {
  position: fixed; inset: 0;
  z-index: 9999;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: rgba(15, 15, 26, 0.92);
  transition: opacity 0.4s;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; }

.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--bg-input);
  border-top-color: var(--accent-hi);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#loading-text {
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-dim);
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100%;
  background: var(--bg-panel);
  padding: 20px 16px;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
  display: flex; flex-direction: column; gap: 14px;
  border-right: 1px solid rgba(255,255,255,0.06);
}
.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-header h1 {
  font-size: 18px; font-weight: 600;
  background: linear-gradient(135deg, var(--accent-hi), #7b68ee);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.sidebar-toggle, .sidebar-expand {
  background: none; border: none; color: var(--text-dim);
  font-size: 20px; cursor: pointer; padding: 4px 8px;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}
.sidebar-toggle:hover, .sidebar-expand:hover {
  background: var(--bg-input); color: var(--text);
}

.sidebar-expand {
  position: fixed; top: 12px; left: 12px; z-index: 101;
  display: none; font-size: 22px;
  background: var(--bg-panel); border: 1px solid rgba(255,255,255,0.08);
}
.sidebar.collapsed ~ .sidebar-expand { display: block; }

/* ── Controls ────────────────────────────────────────────── */
.control-group { display: flex; flex-direction: column; gap: 4px; }
.control-group label {
  font-size: 12px; font-weight: 500; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.04em;
}

select, input[type="range"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
select { padding: 7px 8px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238888aa'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
select:hover, select:focus { border-color: var(--accent); }

input[type="range"] {
  -webkit-appearance: none; height: 6px; border-radius: 3px;
  border: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: var(--accent-hi);
  border: 2px solid var(--bg-panel); cursor: pointer;
}

.checkbox-group label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text); cursor: pointer;
  text-transform: none; letter-spacing: 0;
}
.checkbox-group input[type="checkbox"] {
  accent-color: var(--accent-hi); width: 15px; height: 15px;
}

/* ── Info panel ──────────────────────────────────────────── */
.info-panel {
  background: rgba(0,0,0,0.25);
  border-radius: var(--radius);
  padding: 10px 12px;
  gap: 6px;
}
.info-panel h3 {
  font-size: 12px; text-transform: uppercase;
  color: var(--text-dim); letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.info-row {
  display: flex; gap: 6px; font-size: 12px;
  font-family: "SF Mono", "Fira Code", monospace;
}
.info-label { color: var(--text-dim); white-space: nowrap; }

/* ── Viewer ──────────────────────────────────────────────── */
#viewer-container {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0; bottom: 0;
  transition: left 0.3s ease;
}
.sidebar.collapsed ~ #viewer-container { left: 0; }

#gl-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  background: #000;
}

/* ── Scrollbar ───────────────────────────────────────────── */
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
