:root {
  --panel: rgba(18, 12, 30, 0.86);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #ece6f7;
  --muted: #a99cc2;
  --accent: #9be33a;
  --accent-2: #b26bff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  color: var(--text);
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; overflow: hidden; background: #111; }

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

#loading {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: #14101f; color: var(--muted); font-size: 16px; z-index: 50;
  transition: opacity 0.4s;
}
#loading.hidden { opacity: 0; pointer-events: none; }

/* ---------- label studio (left) ---------- */
#studio {
  position: fixed; top: 12px; left: 12px; bottom: 12px; width: 320px;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 12px; backdrop-filter: blur(14px);
  display: flex; flex-direction: column; z-index: 10;
  transition: transform 0.25s ease;
}
#studio.collapsed { transform: translateX(calc(-100% - 2px)); }
#studio.collapsed #studio-toggle { transform: translateX(calc(100% + 24px)) rotate(180deg); }
#studio header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--panel-border);
}
#studio h1 { margin: 0; font-size: 15px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
#studio-toggle {
  background: transparent; color: var(--muted); border: 1px solid var(--panel-border);
  border-radius: 6px; width: 28px; height: 28px; cursor: pointer; transition: transform 0.25s;
}
#studio-body { overflow-y: auto; padding: 10px 14px 20px; flex: 1; }

.studio-section { margin-bottom: 14px; }
.studio-section h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin: 14px 0 8px;
}
.field { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 6px; margin: 5px 0; }
.field label { color: var(--muted); font-size: 12px; }
.field input[type="text"], .field select, .field textarea {
  width: 100%; background: rgba(255, 255, 255, 0.06); color: var(--text);
  border: 1px solid var(--panel-border); border-radius: 6px; padding: 5px 7px; font: inherit;
}
.field input[type="color"] { width: 100%; height: 26px; border: 1px solid var(--panel-border); border-radius: 6px; background: transparent; padding: 0; }
.field input[type="range"] { width: 100%; }
.field .value { color: var(--muted); font-size: 11px; text-align: right; }

.slot {
  border: 1px solid var(--panel-border); border-radius: 8px; padding: 8px 10px; margin: 8px 0;
  background: rgba(255, 255, 255, 0.03);
}
.slot-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.slot-head strong { font-size: 12.5px; }
.slot-head .actions button {
  background: transparent; color: var(--muted); border: 1px solid var(--panel-border);
  border-radius: 5px; font-size: 11px; padding: 2px 7px; cursor: pointer;
}
.slot-head .actions button:hover { color: var(--text); border-color: var(--accent-2); }
.slot .preview {
  width: 100%; height: 56px; object-fit: contain; border-radius: 4px; margin-top: 6px;
  background: repeating-conic-gradient(#2a2238 0 25%, #1c1627 0 50%) 0 0 / 12px 12px;
}
.slot input[type="file"] { width: 100%; font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ---------- hud (bottom) ---------- */
#hud {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 10;
}
#hud .row { display: flex; gap: 8px; }
#hud button {
  background: var(--panel); color: var(--text); border: 1px solid var(--panel-border);
  border-radius: 999px; padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer;
  backdrop-filter: blur(10px); transition: border-color 0.15s, color 0.15s;
}
#hud button:hover { border-color: var(--accent); color: var(--accent); }
#hud button:disabled { opacity: 0.4; cursor: default; }
#hud .toggles button { padding: 5px 12px; font-size: 12px; font-weight: 500; color: var(--muted); }
#hud .toggles button::before {
  content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.25); margin-right: 7px; vertical-align: 1px; transition: background 0.15s, box-shadow 0.15s;
}
#hud .toggles button.on { color: var(--text); border-color: var(--accent); }
#hud .toggles button.on::before { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
#stats { color: rgba(255, 255, 255, 0.55); font-size: 11px; text-shadow: 0 1px 2px #000; font-variant-numeric: tabular-nums; }

/* lil-gui tweaks */
.lil-gui { --background-color: rgba(18, 12, 30, 0.86) !important; --widget-color: rgba(255,255,255,0.08) !important; --focus-color: #6b3fa0 !important; --hover-color: rgba(255,255,255,0.14) !important; --text-color: #ece6f7 !important; --title-background-color: rgba(0,0,0,0.3) !important; --number-color: #9be33a !important; --string-color: #b26bff !important; backdrop-filter: blur(14px); border-radius: 12px; border: 1px solid rgba(255,255,255,0.12); }
.lil-gui.root { top: 12px !important; right: 12px !important; max-height: calc(100vh - 24px); }
.lil-gui.root > .title { border-radius: 12px 12px 0 0; }

@media (max-width: 900px) {
  #studio { width: 280px; }
}
