:root {
  --bg: #12151b;
  --panel: #1a1e26;
  --panel-2: #212631;
  --line: #2b3240;
  --text: #e6ebf3;
  --dim: #8c97aa;
  --accent: #8b5cf6;
  --accent-hi: #a78bfa;
  --accent-bg: #2a2150; /* a quiet purple wash behind selected things */
  --blue: #7fd1ff;
  --danger: #e0525b;
  --radius: 6px;
  font: 13px/1.4 system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: grid;
  grid-template-columns: 46px var(--hier-w, 250px) minmax(0, 1fr) var(--insp-w, 350px);
  grid-template-rows: 44px minmax(0, 1fr) var(--project-h, 230px) var(--debug-h, 26px);
  grid-template-areas:
    'tb tb tb tb'
    'ra hi vp in'
    'pj pj pj pj'
    'sb sb sb sb';
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 10px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: #3d4759; background: #272d3a; }
button:disabled { opacity: 0.4; cursor: default; }
button.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-hi); border-color: var(--accent-hi); }
button.danger { color: #ff8a92; }

/* toolbar */
#toolbar {
  grid-area: tb;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 0.02em; color: var(--accent-hi); white-space: nowrap; }
.brand img { display: block; height: 24px; width: auto; }
.group { display: flex; gap: 4px; padding-left: 14px; border-left: 1px solid var(--line); }
.spacer { flex: 1; }
.file-name { align-self: center; font-size: 12px; color: var(--dim); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; padding-left: 6px; }
.file-name.dirty { color: #f5b942; }
.file-name.ok { color: #6ee7a8; }

/* panels */
#hierarchy, #inspector {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
}
#hierarchy { grid-area: hi; border-right: 1px solid var(--line); }
#inspector { grid-area: in; border-left: 1px solid var(--line); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
}
.panel-head button { padding: 0 8px; font-size: 16px; line-height: 22px; }

#viewport {
  grid-area: vp;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  /* Editor backdrop; the canvas on top is transparent. */
  background: linear-gradient(180deg, #46536a 0%, #7f8ea6 50%, #9fadc2 100%);
}
#viewport canvas { display: block; width: 100%; height: 100%; outline: none; }
/* Small icon buttons floating in the corner of the 3D view: white when off, purple when on. */
.vp-tool { position: absolute; top: 10px; left: 10px; z-index: 5; width: 34px; height: 34px; padding: 0; display: grid; place-items: center; background: rgba(20, 24, 32, 0.55); border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 8px; color: #fff; backdrop-filter: blur(4px); }
#btn-bounds.vp-tool { left: 52px; }
#btn-scenebg.vp-tool { left: 94px; }
#vp-tools { position: absolute; top: 54px; left: 10px; z-index: 5; display: flex; flex-direction: column; gap: 6px; }
#vp-tools .vp-tool { position: static; }
.vp-sep { height: 1px; margin: 2px 6px; background: rgba(255, 255, 255, 0.18); }
.vp-tool:hover:not(:disabled) { background: rgba(20, 24, 32, 0.8); border-color: rgba(255, 255, 255, 0.4); }
.vp-tool.active { background: rgba(58, 46, 18, 0.75); border-color: var(--accent); color: var(--accent); }

/* hierarchy */
#hier-list { flex: 1; overflow-y: auto; padding: 4px; }
.row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 8px;
  min-height: 24px;
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
}
.row:hover { background: var(--panel-2); }
.row.selected { background: var(--accent-bg); outline: 1px solid rgba(139, 92, 246, 0.5); }
.row .icon { width: 16px; text-align: center; color: var(--dim); font-size: 12px; }
.row .icon.t-hotspot { color: var(--accent); }
.row .icon.t-model { color: var(--blue); }
.row .icon.t-rig { color: #4cc38a; font-size: 14px; }
.row .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .eye { flex: none; width: 22px; height: 20px; padding: 0; display: grid; place-items: center; border: 0; background: transparent; color: var(--accent); cursor: pointer; }
.row .eye:hover { background: rgba(255, 255, 255, 0.1); }
.row .eye.off { color: #fff; }
.row.hid .label, .row.hid .icon { opacity: 0.45; }
.row.inactive .label, .row.inactive .icon { opacity: 0.4; text-decoration: line-through; }
.row .hint { font-size: 11px; color: var(--dim); }
.row.root { margin-bottom: 2px; font-weight: 600; }
.row input.rename { flex: 1; min-width: 0; }
.empty { padding: 14px 10px; color: var(--dim); }

/* inspector */
#insp-body, #light-body, #sys-body { flex: 1; overflow-y: auto; padding-bottom: 24px; }
#light-body[hidden], #sys-body[hidden] { display: none; }
/* Folder-style tabs: the active one is raised and joins the panel below. Add more buttons with class "tab" to get more tabs. */
.panel-head.tabs { padding: 6px 8px 0; gap: 4px; justify-content: flex-start; align-items: flex-end; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab { flex: 0 0 auto; padding: 7px 14px; margin-bottom: -1px; border: 1px solid transparent; border-bottom: 0; border-radius: 7px 7px 0 0; background: transparent; color: var(--dim); font: inherit; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; }
.tab:hover { color: var(--text, #e6ebf3); background: rgba(255, 255, 255, 0.05); }
.tab.on { color: var(--accent); background: var(--panel); border-color: var(--line); box-shadow: inset 0 2px 0 var(--accent); }
.note.warn { color: #fbbf24; }
.bake-progress { display: flex; flex-direction: column; gap: 4px; padding-top: 6px; font-size: 12px; color: var(--dim); }
.bake-progress progress { width: 100%; height: 8px; }
.btn.primary { background: var(--accent); color: #101319; border-color: var(--accent); }
.obj-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 2px; }
.chip {
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
}
.chip.t-hotspot { color: var(--accent); border-color: rgba(139, 92, 246, 0.4); }
.chip.t-model { color: var(--blue); border-color: rgba(127, 209, 255, 0.4); }
.chip.t-rig { color: #4cc38a; border-color: rgba(76, 195, 138, 0.4); }
.obj-head .id { color: var(--dim); font-size: 11px; }

.section { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.section h3 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
}
.field { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; align-items: center; margin: 6px 0; }
.field:has(textarea) { align-items: start; }
.field .lab { color: var(--dim); overflow-wrap: anywhere; }
.note { margin: 6px 0 0; font-size: 12px; color: var(--dim); }
.readonly { display: block; overflow: hidden; text-overflow: ellipsis; color: var(--dim); font-size: 12px; }

input[type='text'], input[type='number'], textarea, select {
  width: 100%;
  min-width: 0;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 6px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }
input[type='color'] { width: 44px; height: 26px; padding: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
input[type='checkbox'] { width: 16px; height: 16px; accent-color: var(--accent); }
input[type='range'] { width: 100%; accent-color: var(--accent); }

.seed-row { display: flex; gap: 4px; min-width: 0; }
.seed-row .num { flex: 1; min-width: 0; }
.vec3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.axis { display: flex; align-items: center; gap: 3px; min-width: 0; }
.axis i { font-style: normal; font-size: 10px; font-weight: 700; width: 9px; }
.axis-x i { color: #ff6b75; }
.axis-y i { color: #6bdc9c; }
.axis-z i { color: #6bb5ff; }
.axis input { padding: 4px 3px; }

.slider { display: grid; grid-template-columns: minmax(0, 1fr) 62px; gap: 6px; align-items: center; }
.area { position: relative; }
.area .count { position: absolute; right: 6px; bottom: 6px; font-size: 10px; color: var(--dim); pointer-events: none; }
.area .count.over { color: var(--danger); font-weight: 700; }

.actions { display: flex; gap: 6px; padding: 12px; flex-wrap: wrap; }
.section .actions { padding: 8px 0 0; }

/* add menu */
.menu {
  position: fixed;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 150px;
  padding: 4px;
  background: var(--panel-2);
  border: 1px solid #3d4759;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.menu button { text-align: left; border: 0; background: transparent; }
.menu button:hover { background: #303747 !important; }

/* status bar */
#statusbar {
  grid-area: sb;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 12px;
  overflow: hidden;
}
#dbg-bar { flex: 0 0 26px; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 4px; white-space: nowrap; overflow: hidden; }
.dbg-spacer { flex: 1; }
#dbg-toggle { height: 22px; padding: 0 8px; font-size: 12px; background: transparent; border: 1px solid transparent; color: var(--text); border-radius: 5px; }
#dbg-toggle:hover { border-color: var(--line); background: rgba(255, 255, 255, 0.06); }
.dbg-arrow { display: inline-block; width: 10px; color: var(--accent); }
.dbg-badge { padding: 0 7px; border-radius: 9px; font-size: 11px; line-height: 17px; }
.dbg-err { background: #5a2229; color: #ff9aa5; }
.dbg-warn { background: #4a3a12; color: #ffc65a; }
#dbg-body { flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
#dbg-body[hidden] { display: none; }
.dbg-tools { display: flex; gap: 8px; padding: 4px 8px; align-items: center; }
.dbg-tools select, .dbg-tools button { height: 22px; font-size: 12px; padding: 0 8px; }
#dbg-list { flex: 1; min-height: 0; overflow: auto; padding: 0 8px 6px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; user-select: text; }
.dbg-row { display: flex; gap: 10px; padding: 1px 0; align-items: baseline; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.dbg-row[hidden] { display: none; }
.dbg-time { color: #6b7385; flex: none; }
.dbg-lvl { flex: none; width: 38px; text-transform: uppercase; font-size: 10px; color: #6b7385; }
.dbg-msg { flex: 1; white-space: pre-wrap; word-break: break-word; color: var(--text); }
.dbg-row.lv-warn .dbg-msg, .dbg-row.lv-warn .dbg-lvl { color: #ffc65a; }
.dbg-row.lv-error .dbg-msg, .dbg-row.lv-error .dbg-lvl { color: #ff9aa5; }
.dbg-count { flex: none; color: #6b7385; }
#vp-hint { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); z-index: 4; padding: 2px 10px; border-radius: 10px; background: rgba(20, 24, 32, 0.5); color: rgba(255, 255, 255, 0.6); font-size: 11px; pointer-events: none; white-space: nowrap; }
#st-right { color: #6bdc9c; }
#st-right.bad { color: #ffb020; }

/* project window */
#project {
  grid-area: pj;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--panel);
  border-top: 1px solid var(--line);
  outline: none;
}
.pj-splitter {
  position: absolute;
  left: 0;
  right: 0;
  top: -3px;
  height: 7px;
  cursor: ns-resize;
  z-index: 5;
}
.pj-splitter:hover, .pj-splitter:active { background: rgba(139, 92, 246, 0.45); }

.pj-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
  overflow-x: auto;
}
.pj-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
}
.pj-head .spacer { flex: 1; }
.pj-head button, .pj-head select, .pj-head input { flex: none; }
.pj-search { width: 150px; padding: 3px 8px; }
.pj-units { width: auto; padding: 3px 6px; }
button.primary-ish { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
button.primary-ish:hover:not(:disabled) { background: #4a3a14 !important; }

.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; white-space: nowrap; }
.crumb { border: 0; background: transparent; padding: 2px 6px; color: var(--text); }
.crumb:hover:not(:disabled) { background: var(--panel-2) !important; }
.crumbs .sep { color: var(--dim); }
.busy { display: none; color: var(--accent); font-size: 12px; white-space: nowrap; }
.busy.on { display: inline; }

.pj-body { flex: 1; display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: 0; }
.pj-tree { overflow: auto; padding: 6px 0; border-right: 1px solid var(--line); }
.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.tree-row:hover { background: var(--panel-2); }
.tree-row.current { background: var(--accent-bg); }
.tree-row .label { overflow: hidden; text-overflow: ellipsis; }
.tree-row input.rename { min-width: 0; flex: 1; }

.svg { display: inline-flex; width: 16px; height: 16px; flex: none; }
.svg svg { width: 100%; height: 100%; }
.folder-icon { color: #d7a84a; }

.pj-grid {
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  grid-auto-rows: max-content;
  gap: 8px;
  padding: 10px;
  align-content: start;
}
.pj-empty { grid-column: 1 / -1; color: var(--dim); padding: 18px 6px; }
.tile {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  min-width: 0;
}
.tile:hover { background: var(--panel-2); }
.tile.selected { background: var(--accent-bg); border-color: rgba(139, 92, 246, 0.6); }
.tile .thumb {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #11141a;
  color: var(--blue);
  overflow: hidden;
}
.tile.folder .thumb { background: transparent; color: #d7a84a; }
.tile .thumb .svg { width: 40%; height: 40%; }
.tile .thumb-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: none; }
.tile .thumb-img.loaded { display: block; }
.tile .thumb-img.loaded ~ .svg, .tile .thumb:has(.thumb-img.loaded) .svg { visibility: hidden; }
.tile .badge {
  position: absolute;
  right: 4px;
  top: 4px;
  padding: 0 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: var(--dim);
  font-size: 9px;
  letter-spacing: 0.05em;
}
.tile .name { text-align: center; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .where { text-align: center; font-size: 10px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile input.rename { width: 100%; text-align: center; padding: 1px 3px; }
.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; background: rgba(139, 92, 246, 0.12) !important; }
.menu button.danger { color: #ff8a92; }

/* startup failure notice */
#boot-error {
  position: fixed;
  left: 50%;
  top: 30%;
  transform: translateX(-50%);
  width: min(92vw, 540px);
  padding: 16px 20px;
  background: #4a1d22;
  border: 1px solid #8a3038;
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  z-index: 50;
}
#boot-error[hidden] { display: none; }
#boot-error strong { font-size: 15px; }
#boot-error p { margin: 8px 0 0; }
#boot-error .detail { color: #ffb4ba; font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-word; }
#boot-error .detail:empty { display: none; }
#boot-error code { background: rgba(0, 0, 0, 0.3); padding: 1px 5px; border-radius: 4px; }

/* toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 44px;
  transform: translate(-50%, 12px);
  max-width: min(90vw, 620px);
  padding: 10px 16px;
  border-radius: 8px;
  background: #272d3a;
  border: 1px solid #3d4759;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 30;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: #4a1d22; border-color: #8a3038; }

@media (max-width: 900px) {
  body { grid-template-columns: 46px var(--hier-w, 200px) minmax(0, 1fr) var(--insp-w, 300px); }
  #vp-hint { display: none; }
}

/* UI panel objects */
.row .icon.t-ui { color: #4ade80; }
.chip.t-ui { color: #4ade80; border-color: rgba(74, 222, 128, 0.4); }
.item-card { margin: 8px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, 0.03); }
.item-head { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.item-head .spacer { flex: 1; }
.btn.mini { padding: 1px 8px; min-width: 0; }
.btn.mini.off { opacity: 0.35; pointer-events: none; }

/* Model parts in the hierarchy */
.row .arrow { display: inline-block; width: 14px; text-align: center; color: var(--dim); cursor: pointer; flex: none; user-select: none; }
.row .arrow.none { cursor: default; }
.row .arrow:not(.none):hover { color: var(--text, #fff); }
.row.part { font-size: 12px; }
.row.part .icon { color: var(--dim); }
.row.part.hidden .label, .row.part.hidden .icon { opacity: 0.4; text-decoration: line-through; }
.row .eye { margin-left: auto; padding: 0 6px; color: var(--dim); cursor: pointer; font-size: 10px; }
.row.part.hidden .eye { opacity: 0.6; }
.row .dot { color: var(--accent); font-size: 8px; margin-left: 4px; }
.chip.t-part { color: var(--blue); border-color: rgba(127, 209, 255, 0.4); }

/* Lights */
.row .icon.t-light { color: #ffd166; }
.chip.t-light { color: #ffd166; border-color: rgba(255, 209, 102, 0.4); }

/* Groups and drag-and-drop in the hierarchy */
.row .icon.t-group { color: #c4b5fd; }
.chip.t-group { color: #c4b5fd; border-color: rgba(196, 181, 253, 0.4); }
.row.group .label { font-weight: 600; }
.row { position: relative; }
.row.drop-into { background: rgba(139, 92, 246, 0.18); outline: 1px solid var(--accent); outline-offset: -1px; }
.row.drop-before::before, .row.drop-after::after {
  content: ''; position: absolute; left: 6px; right: 6px; height: 2px; background: var(--accent); pointer-events: none;
}
.row.drop-before::before { top: -1px; }
.row.drop-after::after { bottom: -1px; }

/* Materials */
.row.drop-material { background: rgba(74, 222, 128, 0.2); outline: 1px solid #4ade80; outline-offset: -1px; }
.mat-swatch { width: 64%; aspect-ratio: 1; border-radius: 50%; margin: auto; }
.thumb:has(.mat-swatch) { display: grid; place-items: center; }
.chip.t-material, .chip.t-image { color: #4ade80; border-color: rgba(74, 222, 128, 0.4); }
.slot { display: flex; align-items: center; gap: 8px; padding: 6px; border: 1px dashed var(--line); border-radius: 8px; margin: 6px 0; }
.slot.drop-material { border-color: #4ade80; background: rgba(74, 222, 128, 0.12); }
.slot .mat-swatch { width: 28px; margin: 0; flex: none; }
.slot .slot-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .slot-name.dim { color: var(--dim); }
.sub-head { margin: 10px 0 2px; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--dim); }
.tex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px 8px; margin: 6px 0 8px; }
.tex-slot { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 4px; min-width: 0; }
.tex-label { font-size: 11px; color: #9aa6b8; }
.tex-box { position: relative; aspect-ratio: 1; width: 100%; padding: 0; border: 1px dashed var(--line); border-radius: 8px; background: repeating-conic-gradient(#2a303c 0 25%, #1c212b 0 50%) 0 0 / 12px 12px; overflow: hidden; cursor: pointer; color: #8a96a8; }
.tex-box:hover { border-color: var(--accent); }
.tex-pic { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.tex-slot.has .tex-pic[src] { display: block; }
.tex-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.tex-slot.has .tex-empty { display: none; }
.tex-slot.has .tex-box { border-style: solid; }
.tex-slot.missing .tex-box { border-color: #ef4444; }
.tex-slot.drop .tex-box { border-color: #4ade80; background: rgba(74, 222, 128, 0.18); }
.tex-clear { position: absolute; top: 18px; right: 3px; width: 18px; height: 18px; padding: 0; line-height: 16px; border: 0; border-radius: 9px; background: rgba(10, 12, 16, 0.75); color: #e6ebf3; cursor: pointer; display: none; font-size: 13px; }
.tex-slot.has .tex-clear { display: block; }
.tex-name { font-size: 10px; color: #8a96a8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tex-pop { position: fixed; z-index: 1000; width: 280px; max-height: 340px; display: flex; flex-direction: column; gap: 6px; padding: 8px; background: #1c212b; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
.tex-search { width: 100%; box-sizing: border-box; }
.tex-grid-pop { overflow: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tex-choice span { display: block; font-size: 10px; color: #9aa6b8; padding: 2px 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tex-choice { padding: 0; text-align: left; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #11151c; cursor: pointer; }
.tex-choice:hover { border-color: var(--accent); }
.tex-choice img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.asset-preview { max-width: 100%; max-height: 360px; border-radius: 6px; display: block; margin: 6px auto; background: repeating-conic-gradient(#2a303c 0 25%, #1c212b 0 50%) 0 0 / 14px 14px; object-fit: contain; }
.tex-preview { max-width: 100%; max-height: 160px; border-radius: 6px; display: block; margin: 6px 0; background: repeating-conic-gradient(#2a303c 0 25%, #1c212b 0 50%) 0 0 / 14px 14px; }
.user-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

/* headset dialog */
dialog.dlg { max-width: 560px; width: calc(100vw - 32px); padding: 18px 20px; border: 1px solid #3a4252; border-radius: 12px; background: #1b2029; color: #e6ebf3; }
dialog.dlg::backdrop { background: rgba(0,0,0,.55); }
dialog.dlg h3 { margin: 0 0 8px; }
dialog.dlg ol { padding-left: 20px; line-height: 1.5; }
dialog.dlg li { margin: 8px 0; }
.dlg-link { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.dlg-link code { flex: 1; overflow-wrap: anywhere; padding: 6px 8px; background: #11151c; border-radius: 6px; font-size: 12px; }
dialog.dlg .actions { display: flex; gap: 8px; margin-top: 12px; }

dialog.ask-dlg { max-width: 460px; }
dialog.ask-dlg h3 { color: var(--accent); }
.ask-msg { margin: 0 0 4px; line-height: 1.5; white-space: pre-line; }
.ask-copy { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 12px; }
dialog.ask-dlg .actions { justify-content: flex-end; margin-top: 16px; }
dialog.ask-dlg button.danger { background: #5b1d22; border-color: #ff8a92; color: #ffd5d8; }
dialog.ask-dlg button.danger:hover:not(:disabled) { background: #7a2630; }
dialog.dlg.wide { max-width: 720px; }
.perf-verdict { margin: 0 0 10px; padding: 8px 12px; border-radius: 8px; font-weight: 600; }
.perf-verdict.ok { background: #12301f; color: #6ee7a0; } .perf-verdict.warn { background: #3a2f10; color: #fbbf24; } .perf-verdict.bad { background: #3b1717; color: #fca5a5; }
.perf-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 10px; }
.perf-tile { padding: 8px 10px; border-radius: 8px; background: #11151c; border-left: 4px solid #4ade80; display: flex; flex-direction: column; }
.perf-tile.warn { border-color: #fbbf24; } .perf-tile.bad { border-color: #f87171; }
.perf-tile b { font-size: 18px; } .perf-tile span { font-size: 12px; color: #c3cbd8; } .perf-tile small { font-size: 11px; color: #7d889a; }
.perf-advice { padding-left: 18px; line-height: 1.45; } .perf-advice li { margin: 4px 0; }
.perf-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; }
.perf-table th { text-align: left; color: #9aa6b8; font-weight: 500; padding: 4px 6px; }
.perf-table td { padding: 4px 6px; border-top: 1px solid #2a3140; }
.perf-table tr.clickable:hover td { background: #232a37; cursor: pointer; }

/* click actions */
.act { padding: 8px; margin: 6px 0; border-radius: 8px; background: #11151c; }
.act-head { display: flex; gap: 6px; margin-bottom: 4px; }
.act-head .select { flex: 1; }
.btn-x { width: 30px; border: 0; border-radius: 6px; background: #2a3140; color: #e6ebf3; cursor: pointer; font-size: 16px; }
.btn-x:hover { background: #7a2a2a; }

.chip.t-audio { color: #38bdf8; border-color: rgba(56, 189, 248, 0.4); }
.chip.t-image { color: #c4b5fd; }
.slot-label { font-size: 12px; color: #9aa6b8; margin: 2px 0 4px; }

/* add menu: icon rail with flyouts */
#rail { grid-area: ra; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; background: #161a22; border-right: 1px solid var(--line); }
#rail button { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border-radius: 8px; border: 1px solid transparent; background: transparent; color: #aab4c4; cursor: pointer; }
#rail button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#rail button:hover { background: #232a37; color: #fff; }
#rail button.open { background: #2a2414; border-color: var(--accent); color: var(--accent); }
#rail .rail-gap { flex: 1; }
.flyout { position: fixed; z-index: 40; width: 250px; max-height: calc(100vh - 120px); overflow-y: auto; padding: 10px; border: 1px solid #3a4252; border-radius: 10px; background: #1b2029; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.flyout h4 { margin: 0 0 8px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: #9aa6b8; }
.flyout h5 { margin: 10px 0 4px; font-size: 11px; color: #7d889a; font-weight: 500; }
.flyout .items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.flyout .item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border-radius: 8px; border: 1px solid #2a3140; background: #11151c; color: #e6ebf3; cursor: pointer; font-size: 12px; text-align: center; }
.flyout .item:hover { border-color: var(--accent); background: #1a1f29; }
.flyout .item .glyph { font-size: 22px; line-height: 1; color: #aab4c4; }
/* Colour emoji (fire, sparkles) would stand out from the plain symbols: draw every symbol as a one-colour shape in the text colour. */
.flyout .item .glyph, .row .icon { -webkit-text-fill-color: transparent; text-shadow: 0 0 0 currentColor; }
.flyout .item small { color: #7d889a; font-size: 10px; line-height: 1.2; }
.flyout .item.wide { grid-column: 1 / -1; flex-direction: row; justify-content: flex-start; gap: 8px; padding: 8px 10px; text-align: left; }
.flyout .note { margin: 10px 0 0; font-size: 11px; color: #7d889a; }

/* Toolbar buttons that are just an icon. */
.icon-btn { width: 36px; padding: 0; display: inline-grid; place-items: center; }
.icon-btn svg { display: block; }
.pj-head .plus { width: 36px; background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.pj-head .plus:hover:not(:disabled) { background: #4a3a14; }

.modifier-add { padding: 10px 12px 16px; }
.modifier-add .btn { width: 100%; padding: 9px; border-style: dashed; color: var(--accent); }

/* import settings dialog */
dialog.import-dlg { max-width: 640px; }
.import-body { display: flex; gap: 16px; align-items: flex-start; margin: 10px 0; }
.import-thumb { flex: none; width: 150px; height: 150px; border-radius: 10px; background: #12161d; object-fit: contain; display: grid; place-items: center; color: var(--dim); font-size: 12px; }
.import-fields { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.import-row { display: grid; grid-template-columns: 120px 1fr; gap: 8px; align-items: center; }
.import-label { color: var(--dim); font-size: 13px; }
.import-control { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.import-control small { color: var(--dim); font-size: 11px; }
.import-control input.text, .import-control input.num, .import-control select { width: 100%; box-sizing: border-box; }
.import-check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.import-size { font-size: 13px; color: var(--accent); margin: 4px 0; }
.import-all { display: flex; gap: 8px; align-items: center; font-size: 13px; margin-top: 6px; }
@media (max-width: 560px) { .import-body { flex-direction: column; } }

/* Modifiers: one clearly framed group right under Transform */
.modifier-group { margin: 10px 8px; border: 1px solid var(--accent); border-radius: 8px; background: rgba(139, 92, 246, 0.06); overflow: hidden; }
.modifier-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; background: rgba(139, 92, 246, 0.14); }
.modifier-title { font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-size: 12px; color: var(--accent); }
.modifier-count { display: inline-block; margin-left: 8px; min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; text-align: center; }
.modifier-head .add-modifier { margin: 0; width: auto; padding: 5px 10px; }
.modifier-group > .note { padding: 0 10px 8px; margin: 6px 0 0; }
.modifier-group .modifier-section { border-left: 3px solid var(--accent); }

.vec3.has-reset { grid-template-columns: 24px repeat(3, minmax(0, 1fr)); }
.reset-btn { margin: 0; width: 22px; height: 22px; padding: 0; line-height: 1; border-radius: 5px; font-size: 14px; color: var(--muted, #9aa3b2); background: transparent; border: 1px solid transparent; cursor: pointer; vertical-align: middle; }
.reset-btn:hover { color: var(--accent); border-color: var(--accent); background: rgba(139, 92, 246, 0.12); }

#hierarchy, #inspector { position: relative; }
.col-splitter { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; z-index: 6; }
.col-splitter-right { right: -3px; }
.col-splitter-left { left: -3px; }
.col-splitter:hover, .col-splitter:active { background: rgba(139, 92, 246, 0.45); }

#st-right.bad { cursor: pointer; text-decoration: underline dotted; }

/* Add modifier menu: searchable, grouped by category */
.menu.modifier-menu { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.mod-search { margin: 8px; width: calc(100% - 16px); }
.mod-list { overflow-y: auto; padding: 0 6px 8px; }
.mod-cat { padding: 8px 8px 4px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.menu .mod-item { display: flex; flex-direction: column; gap: 1px; width: 100%; padding: 6px 8px; border-radius: 6px; }
.mod-name { color: var(--text); }
.mod-hint { color: var(--dim); font-size: 11px; line-height: 1.3; white-space: normal; }
.mod-empty { padding: 8px; }

#vp-stop-anim { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 6; padding: 6px 14px; border-radius: 16px; background: #5a2229; border: 1px solid #a8434d; color: #ffd5d9; font-weight: 600; }
#vp-stop-anim[hidden] { display: none; }
#vp-stop-anim:hover { background: #7a2d36; }

/* Play mode: the real player runs in a frame over the viewport */
#play-layer { position: absolute; inset: 0; z-index: 12; background: #000; }
#play-layer[hidden] { display: none; }
#play-layer iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: #000; }
#btn-stop-play { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 13; height: 34px; padding: 0 16px; border-radius: 17px; background: #5a2229; border: 1px solid #a8434d; color: #ffd5d9; font-weight: 600; }
#btn-stop-play:hover { background: #7a2d36; }
/* Play mode is obvious: a purple line round the player, and everything else dimmed (it still works: edits reload the player) */
#play-layer::after { content: ''; position: absolute; inset: 0; z-index: 14; pointer-events: none; border: 3px solid var(--accent); box-shadow: inset 0 0 18px rgba(139, 92, 246, .55); }
body.play-mode::before { content: ''; position: fixed; inset: 0; z-index: 500; pointer-events: none; background: rgba(8, 6, 16, .68); }
body.play-mode #viewport { z-index: 600; box-shadow: 0 0 0 1px var(--accent), 0 0 28px 4px rgba(139, 92, 246, .6); }
#btn-play.playing { background: #5a2229; border-color: #a8434d; color: #ffd5d9; }

#vp-play { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 6; display: flex; gap: 6px; }
#vp-play[hidden] { display: none; }
#vp-play button { height: 34px; padding: 0 14px; border-radius: 17px; background: rgba(20, 24, 32, 0.6); border: 1px solid rgba(255, 255, 255, 0.22); color: #fff; backdrop-filter: blur(4px); font-weight: 600; }
#vp-play #btn-play { background: rgba(43, 140, 90, 0.75); border-color: rgba(120, 230, 170, 0.6); }
#vp-play #btn-play:hover { background: rgba(52, 168, 108, 0.9); }
#vp-stop-anim { top: 54px; }

/* Debugger tabs and the Performance tab */
.dbg-tabs { display: flex; align-items: center; gap: 2px; padding: 0 8px; flex: none; border-bottom: 1px solid var(--line); }
.dbg-tab { height: 26px; padding: 0 12px; font-size: 12px; background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--dim); }
.dbg-tab:hover { color: var(--text); }
.dbg-tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.dbg-tools[hidden] { display: none; }
.dbg-link { height: 22px; padding: 0 8px; font-size: 12px; background: transparent; border: 1px solid transparent; color: var(--dim); border-radius: 5px; }
.dbg-link:hover { color: var(--text); border-color: var(--line); }
#dbg-perf { flex: 1; min-height: 0; overflow: auto; padding: 8px 12px 10px; }
#dbg-perf[hidden], #dbg-list[hidden] { display: none; }
#dbg-perf .perf-tiles { margin-bottom: 8px; }

/* Tabs: the generic panel-head button size (16px) was winning over the tab's own, so they looked oversized */
.panel-head.tabs .tab { font-size: 11px; line-height: 16px; padding: 6px 12px; letter-spacing: 0.08em; }

/* Loose notes at the top of a tab (not inside a section) need the same side padding the sections have */
#light-body > .note, #sys-body > .note, #insp-body > .note { margin: 0; padding: 14px 16px 6px; }

.row-actions { display: flex; gap: 6px; padding: 4px 0 2px; }
.row-actions .btn { flex: 1; }

/* a field that names another object: drag one in from the Hierarchy */
.ref-list { display: flex; flex-direction: column; gap: 4px; }
.ref-slot { display: flex; align-items: center; gap: 6px; min-height: 30px; padding: 3px 6px 3px 10px; border: 1px dashed #4a5568; border-radius: 6px; background: #11151c; color: #7d889a; font-size: 13px; }
.ref-slot.filled { border-style: solid; border-color: #3a4252; color: #e6ebf3; }
.ref-slot.filled .ref-name { cursor: pointer; }
.ref-slot.filled .ref-name:hover { color: var(--accent); }
.ref-slot.missing { border-color: #a8434d; color: #ff8a92; }
.ref-slot.over { border-color: var(--accent); border-style: solid; background: rgba(139, 92, 246, 0.14); color: #e6ebf3; }
.ref-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-clear { width: 24px; height: 24px; font-size: 14px; padding: 0; flex: none; }
.ref-clear[hidden] { display: none; }

/* Path mover: a point's X Y Z with a remove button beside it */
.path-point { display: flex; align-items: center; gap: 4px; min-width: 0; }
.path-point .vec3 { flex: 1; min-width: 0; }

/* Spline: the list of points, the picked one lit */
.chip.t-spline { color: #a78bfa; border-color: rgba(167, 139, 250, 0.4); }
.spline-pts { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 8px; }
.spline-pt { display: flex; flex-direction: column; align-items: flex-start; gap: 0; min-width: 64px; padding: 4px 8px; border: 1px solid #3a4252; border-radius: 6px; background: #11151c; color: #e6ebf3; font-size: 12px; cursor: pointer; }
.spline-pt small { color: #7d889a; font-size: 10px; }
.spline-pt:hover { border-color: #a78bfa; }
.spline-pt.first { border-left: 3px solid #4cc38a; }
.spline-pt.last { border-left: 3px solid #ff5566; }
.spline-pt.on { border-color: var(--accent); background: rgba(139, 92, 246, 0.14); }

/* The scene list in the toolbar: the name of the scene being edited, with a menu of the others. */
#scene-pick { align-self: center; display: inline-flex; align-items: center; gap: 8px; width: 210px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 5px 8px; font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
#scene-pick:hover, #scene-pick:focus-visible, #scene-pick[aria-expanded="true"] { border-color: var(--accent); }
#scene-pick .sp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#scene-pick .sp-chev { display: inline-grid; place-items: center; color: var(--dim); }
.start-badge { height: 18px; width: 18px; flex: none; object-fit: contain; vertical-align: middle; }
.scene-menu { position: fixed; z-index: 3000; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); display: grid; gap: 1px; }
.scene-menu .sm-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: transparent; border: 0; border-radius: 4px; padding: 6px 8px; font-weight: 400; }
.scene-menu .sm-item:hover { background: var(--panel-2); }
.scene-menu .sm-item.current { background: var(--accent-bg); font-weight: 600; }
.scene-menu .sm-act { color: var(--dim); }
.scene-menu .sm-act:hover { color: var(--text); }
.scene-menu .sm-act.danger:hover { color: var(--danger); }
.scene-menu .sm-pad { width: 18px; flex: none; }
.scene-menu .sm-sep { height: 1px; background: var(--line); margin: 4px 2px; }
#toolbar button { white-space: nowrap; }
#btn-projects { display: inline-flex; align-items: center; gap: 4px; }
.tile.scene-tile.current .thumb { outline: 2px solid var(--accent); border-radius: var(--radius); }
.projects-dlg { min-width: 360px; max-width: 460px; }
.projects-dlg .note { margin: 0 0 12px; color: var(--dim); font-size: 13px; line-height: 1.45; }
.projects-dlg .big { display: block; width: 100%; text-align: left; margin-bottom: 6px; padding: 9px 12px; }
.projects-dlg h4 { margin: 14px 0 6px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.projects-dlg .templates { max-height: 240px; overflow: auto; display: grid; gap: 4px; }
.projects-dlg .templates button { text-align: left; }
.tile.scene-tile .thumb { background: transparent; }
.tile.scene-tile .thumb .scene-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 10px; box-sizing: border-box; }
.tile.scene-tile .name .start-badge { height: 18px; width: 18px; vertical-align: -4px; margin-right: 4px; }
