:root {
  --panel: #1f2124;
  --panel-edge: #33363b;
  --text: #c9ccd1;
  --text-dim: #7f848c;
  --select: #2f65a8;
}

* { box-sizing: border-box; }

/* Dark scrollbars everywhere: a slim, dim thumb on a clear track, brighter when pointed at. */
* { scrollbar-width: thin; scrollbar-color: #4b4165 transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track, *::-webkit-scrollbar-corner { background: transparent; }
*::-webkit-scrollbar-thumb { background: #4b4165; border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background-color: #6d5f92; }
/* (the lists that ordinary drop-downs open are drawn by the system: ask it for its dark ones) */
select { color-scheme: dark; }

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

body {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 28px;
  background: #2b2d31;
  color: var(--text);
  font: 12px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  user-select: none;
}

/* ---- Scene Explorer: a floating panel over the viewport ---- */
#explorer {
  position: fixed;
  left: var(--explorer-left, 12px);
  top: var(--explorer-top, 34px);
  width: var(--explorer-width, 220px);
  max-height: calc(100vh - 34px - 28px - 24px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: #160726; /* dark purple */
  border: 1px solid #3a2060;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
#explorer h1 {
  flex: none;
  margin: 0;
  padding: 10px 12px 9px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #22103a;
  border-bottom: 1px solid #3a2060;
  cursor: move;
  touch-action: none;
}
#explorer h1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#explorer-fold {
  flex: none;
  padding: 0 4px;
  border: 0;
  background: none;
  color: #a893c7;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
#explorer-fold:hover { color: #fff; }
/* Folded: only the title bar shows. */
#explorer.folded #explorer-body, #explorer.folded #explorer-resize { display: none; }
#explorer.folded h1 { border-bottom: 0; }
#explorer-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
/* Its stacks, one under the other: the Scene Explorer takes the room there is and scrolls;
   Display is as tall as what is in it. Each folds away under its heading. */
.stack { flex: none; display: flex; flex-direction: column; min-height: 0; }
.stack + .stack { border-top: 1px solid #3a2060; }
#stack-explorer:not(.folded) { flex: 1 1 auto; }
#stack-explorer .stack-body { flex: 1; min-height: 60px; overflow-y: auto; padding-bottom: 6px; }
#stack-display .stack-body { overflow-y: auto; }
.stack.folded .stack-body, .stack.folded #collapse-all { display: none; }
.stack h2 { cursor: pointer; }
.stack h2 .stack-name { flex: 1; }
.stack-fold { flex: none; padding: 0 2px 0 0; border: 0; background: none; color: #a893c7; font-size: 10px; line-height: 1; cursor: pointer; }
.stack h2:hover .stack-fold { color: #fff; }
#explorer h2 {
  margin: 0;
  padding: 10px 12px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a893c7;
}
#explorer h2 { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
#collapse-all {
  font: inherit;
  letter-spacing: 0.04em;
  text-transform: none;
  color: #d9cdee;
  background: none;
  border: 1px solid #3a2060;
  border-radius: 3px;
  padding: 1px 7px;
  cursor: pointer;
}
#collapse-all:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
#object-list { list-style: none; margin: 0; padding: 0; }
#object-list li {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
}
#object-list .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#object-list input.rename { flex: 1; min-width: 0; width: auto; padding: 0 4px; background: #0d0418; border-color: #8f5fe0; }
#object-list .arrow {
  flex: none;
  width: 12px;
  margin-right: -3px;
  text-align: center;
  font-size: 10px;
  color: #a893c7;
  cursor: pointer;
}
#object-list .arrow:hover { color: #fff; }
#object-list li.selected .arrow { color: #fff; }
#object-list li:hover { background: rgba(255, 255, 255, 0.07); }
#object-list li.selected { background: #6f3cc4; color: #fff; }
#object-list li.locked { color: #a893c7; }
#object-list li.locked:hover { background: none; }
#object-list .tag { margin-left: auto; font-size: 10px; }
/* Show / hide, lock and wireframe switches at the end of a row: faint until the row is
   pointed at, bright when switched on. */
#object-list .switches { display: flex; flex: none; gap: 3px; margin-left: auto; padding-left: 4px; }
#object-list .switch { display: flex; align-items: center; opacity: 0.18; cursor: pointer; }
#object-list li:hover .switch { opacity: 0.55; }
#object-list .switch:hover { opacity: 1 !important; }
#object-list .switch.on { opacity: 1; color: #ffd166; }
#object-list li.hidden-object .name { opacity: 0.45; font-style: italic; }
#object-list li.frozen .name { opacity: 0.7; }

#object-list .swatch {
  flex: none;
  width: 9px;
  height: 9px;
  border: 1px solid rgba(0, 0, 0, 0.5);
}
#explorer-empty { margin: 0; padding: 4px 12px; color: #a893c7; font-style: italic; }
/* The search field above the list, and (while searching) what each match is linked to. */
#explorer-search {
  box-sizing: border-box;
  display: block;
  width: calc(100% - 20px);
  margin: 0 10px 6px;
  padding: 4px 7px;
  font: inherit;
  color: #fff;
  background: #0d0418;
  border: 1px solid #3a2060;
  border-radius: 4px;
  outline: none;
}
#explorer-search:focus { border-color: #8f5fe0; }
#explorer-search::placeholder { color: #8d7ab0; }
#object-list .where { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: #8d7ab0; font-size: 10px; }
#object-list li.selected .where { color: #e3d8f5; }
/* The draggable right edge of the panel. */
#explorer-resize {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  touch-action: none;
}
#explorer-resize:hover, #explorer-resize.dragging { background: #8f5fe0; opacity: 0.6; }

/* ---- Properties: a floating panel for the selected shop, person, group or the dome ---- */
#props {
  position: fixed;
  right: 12px;
  top: 34px;
  width: 400px;
  max-height: calc(100vh - 34px - 28px - 60px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: #160726;
  border: 1px solid #3a2060;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
#props h1 {
  flex: none;
  margin: 0;
  padding: 10px 12px 9px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #22103a;
  border-bottom: 1px solid #3a2060;
  cursor: move;
  touch-action: none;
}
#props-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px 12px; }
#p-name { color: #fff; font-size: 14px; font-weight: 600; }
#p-kind { color: #a893c7; margin-bottom: 10px; }
#props label {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  color: #d9cdee;
}
#props label.tall { align-items: start; }
#props label.check { display: flex; margin-top: 14px; color: #a893c7; }
#props select, #props input:not([type]), #props textarea {
  font: inherit;
  color: #fff;
  background: #0d0418;
  border: 1px solid #3a2060;
  border-radius: 3px;
  padding: 3px 5px;
  width: 100%;
  min-width: 0;
  user-select: text;
}
#props textarea { resize: vertical; }
#props select:focus, #props input:focus, #props textarea:focus { outline: 1px solid #8f5fe0; outline-offset: 0; }
#props input[type="checkbox"] { width: auto; margin: 0; accent-color: #8f5fe0; }
#props .slider { display: flex; align-items: center; gap: 8px; }
#props input[type="range"] { flex: 1; width: auto; min-width: 0; padding: 0; border: 0; background: none; accent-color: #8f5fe0; }
#p-capacity-out { width: 36px; text-align: right; color: #fff; font-variant-numeric: tabular-nums; }
#p-chain { margin: -2px 0 6px 100px; color: #a893c7; font-size: 11px; }
#p-chain:empty { display: none; }
#props h2 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 16px 0 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a893c7;
}
#props .key { width: 16px; height: 3px; border-radius: 2px; }
#props .key.out { background: #ffd23f; }
#props .key.in { background: #39c5ff; }
#props ul { list-style: none; margin: 0 0 6px; padding: 0; }
#props li { display: flex; align-items: center; gap: 6px; padding: 2px 0; color: #fff; }
#props li .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
#props li .who:hover { text-decoration: underline; }
#props li select { width: 78px; flex: none; }
#props li button {
  flex: none;
  font: inherit;
  color: #d9cdee;
  background: none;
  border: 0;
  border-radius: 3px;
  padding: 0 5px;
  cursor: pointer;
}
#props li button:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
#props li.none { color: #a893c7; font-style: italic; }

/* ---- Material Editor: a floating panel of sample slots and material values ---- */
#mats {
  position: fixed;
  right: 294px;
  top: 34px;
  width: 262px;
  max-height: calc(100vh - 34px - 28px - 60px);
  z-index: 21;
  display: flex;
  flex-direction: column;
  background: #160726;
  border: 1px solid #3a2060;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
#mats[hidden] { display: none; }
#mats h1 {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  padding: 8px 8px 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #22103a;
  border-bottom: 1px solid #3a2060;
  cursor: move;
  touch-action: none;
}
#mats-close { font: inherit; font-size: 16px; line-height: 1; color: #d9cdee; background: none; border: 0; border-radius: 3px; padding: 1px 6px; cursor: pointer; }
#mats-close:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
#mats-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px 12px; }
#m-slots { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-bottom: 10px; }
#m-slots button { padding: 0; border: 2px solid transparent; border-radius: 4px; background: #0d0418; cursor: pointer; line-height: 0; }
#m-slots button.custom { border-color: #3a2060; }
#m-slots button:hover { border-color: #6b47a8; }
#m-slots button.active { border-color: #fff; }
#m-slots canvas { width: 100%; aspect-ratio: 1; border-radius: 2px; }
#m-head { display: flex; gap: 10px; margin-bottom: 8px; }
#m-preview { width: 96px; height: 96px; flex: none; border-radius: 4px; border: 1px solid #3a2060; }
#m-head > div { flex: 1; min-width: 0; }
#mats label {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  color: #d9cdee;
}
#m-head label { grid-template-columns: auto minmax(0, 1fr); }
#mats label.check { display: flex; }
#m-name {
  font: inherit;
  color: #fff;
  background: #0d0418;
  border: 1px solid #3a2060;
  border-radius: 3px;
  padding: 3px 5px;
  width: 100%;
  min-width: 0;
  text-align: left;
  user-select: text;
}
#m-name:focus { outline: 1px solid #8f5fe0; outline-offset: 0; }
#mats label[hidden] { display: none; }
#m-tex[hidden] { display: none; }
#m-load { width: 100%; margin-top: 4px; }
#mats output { width: 34px; }
#m-texture { font: inherit; color: #fff; background: #0d0418; border: 1px solid #3a2060; border-radius: 3px; padding: 3px 5px; width: 100%; min-width: 0; }
#m-color, #m-side { width: 100%; height: 22px; padding: 0; border: 1px solid #3a2060; border-radius: 3px; background: none; cursor: pointer; }
#mats input[type="checkbox"] { width: auto; margin: 0; accent-color: #8f5fe0; }
#mats .slider { display: flex; align-items: center; gap: 8px; }
#mats input[type="range"] { flex: 1; width: auto; min-width: 0; padding: 0; border: 0; background: none; accent-color: #8f5fe0; }
#mats output { width: 30px; text-align: right; color: #fff; font-variant-numeric: tabular-nums; }
#mats-body > button, #m-row button {
  font: inherit;
  color: #fff;
  background: #2b1548;
  border: 1px solid #3a2060;
  border-radius: 4px;
  padding: 5px 6px;
  cursor: pointer;
}
#mats-body > button:hover:not(:disabled), #m-row button:hover:not(:disabled) { background: #3a2060; }
#mats-body button:disabled { opacity: 0.4; cursor: default; }
#m-assign { width: 100%; margin-top: 8px; background: #8f5fe0 !important; border-color: #8f5fe0 !important; font-weight: 600 !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#m-target { margin: 5px 0 10px; color: #a893c7; font-size: 11px; }
#m-row { display: flex; gap: 4px; }
#m-row button { flex: 1; padding: 4px 2px; font-size: 11px; }
#m-row #m-remove { flex: none; padding: 4px 8px; }

/* ---- Surface Tools: Hair and Fur, Scatter, Assets ---- */
#surf {
  position: fixed;
  right: 12px;
  top: 34px;
  width: 280px;
  max-height: calc(100vh - 34px - 28px - 60px);
  z-index: 22;
  display: flex;
  flex-direction: column;
  background: #160726;
  border: 1px solid #3a2060;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
#surf[hidden] { display: none; }
#surf h1 {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  padding: 8px 8px 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #22103a;
  cursor: move;
  touch-action: none;
}
#surf-close { font: inherit; font-size: 16px; line-height: 1; color: #d9cdee; background: none; border: 0; border-radius: 3px; padding: 1px 6px; cursor: pointer; }
#surf-close:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
#surf-tabs { flex: none; display: flex; background: #22103a; border-bottom: 1px solid #3a2060; padding: 0 8px; gap: 2px; }
#surf-tabs button { flex: 1; font: inherit; color: #a893c7; background: none; border: 0; border-bottom: 2px solid transparent; padding: 5px 4px 6px; cursor: pointer; }
#surf-tabs button:hover { color: #fff; }
#surf-tabs button.active { color: #fff; border-bottom-color: #8f5fe0; }
#surf-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px 12px; }
#surf-body .note { margin: 0 0 8px; color: #a893c7; font-size: 11px; }
#surf-body h2 { margin: 14px 0 6px; font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #a893c7; }
#surf-body label { display: grid; grid-template-columns: 74px minmax(0, 1fr); align-items: center; gap: 8px; margin: 5px 0; color: #d9cdee; }
#surf-body label.check { display: flex; gap: 6px; }
#surf-body .slider { display: flex; align-items: center; gap: 8px; }
#surf-body input[type="range"] { flex: 1; width: auto; min-width: 0; padding: 0; border: 0; background: none; accent-color: #8f5fe0; }
#surf-body input[type="checkbox"] { width: auto; margin: 0; accent-color: #8f5fe0; }
#surf-body input[type="color"] { width: 100%; height: 22px; padding: 0; border: 1px solid #3a2060; border-radius: 3px; background: none; cursor: pointer; }
#surf-body output { width: 48px; text-align: right; color: #fff; font-variant-numeric: tabular-nums; }
#surf-body select { font: inherit; color: #fff; background: #0d0418; border: 1px solid #3a2060; border-radius: 3px; padding: 3px 5px; width: 100%; min-width: 0; }
#surf-body button { font: inherit; color: #fff; background: #2b1548; border: 1px solid #3a2060; border-radius: 4px; padding: 4px 8px; cursor: pointer; white-space: nowrap; }
#surf-body button:hover { background: #3a2060; }
#surf-body button.main { width: 100%; padding: 6px; background: #8f5fe0; border-color: #8f5fe0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
#surf-body .row { display: flex; gap: 6px; margin-top: 10px; }
#surf-body .row button { flex: 1; }
#surf-body .row select { flex: 1; }
#surf-body .layers { list-style: none; margin: 0 0 6px; padding: 0; }
#surf-body .layers li { display: flex; align-items: center; gap: 6px; padding: 3px 4px 3px 8px; border-radius: 4px; color: #d9cdee; cursor: pointer; }
#surf-body .layers li:hover { background: rgba(255, 255, 255, 0.06); }
#surf-body .layers li.active { background: #3a2060; color: #fff; }
#surf-body .layers button { background: none; border: 0; padding: 0 5px; color: #d9cdee; }
#surf-body .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#surf-body .asset { display: flex; align-items: center; gap: 7px; padding: 3px 0; color: #fff; }
#surf-body .asset .swatch { flex: none; width: 10px; height: 10px; border-radius: 2px; }
#surf-body .asset .dim { color: #a893c7; font-size: 11px; white-space: nowrap; }
#surf-body .asset button { padding: 2px 8px; }

/* ---- Relationship: how the two things picked in the bar at the bottom are related ---- */
#rel {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 24px));
  max-height: min(52vh, 520px);
  z-index: 23;
  display: flex;
  flex-direction: column;
  background: #160726;
  border: 1px solid #3a2060;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
#rel[hidden] { display: none; }
#rel h1 {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 8px 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #22103a;
  border-bottom: 1px solid #3a2060;
}
#rel-title-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: pre; }
#rel-close { font: inherit; font-size: 16px; line-height: 1; color: #d9cdee; background: none; border: 0; border-radius: 3px; padding: 1px 6px; cursor: pointer; }
#rel-close:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
#rel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px 12px; color: #d9cdee; }
#rel-body h2 { margin: 12px 0 5px; font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #a893c7; }
#rel-body .cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#rel-body .card { min-width: 0; padding: 8px 10px; background: #0d0418; border: 1px solid #3a2060; border-radius: 6px; }
#rel-body .card .name { color: #fff; font-weight: 600; font-size: 13px; }
#rel-body .card .fact { display: flex; justify-content: space-between; gap: 8px; margin-top: 3px; }
#rel-body .card .fact b { color: #fff; font-weight: 500; text-align: right; }
#rel-body .card p { margin: 6px 0 0; }
#rel-body .dim { color: #a893c7; font-size: 11px; }
#rel-body .none { margin: 0; color: #a893c7; font-style: italic; }
#rel-body .verdict { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; padding: 8px 10px; background: #22103a; border-radius: 6px; }
#rel-body .verdict b { color: #fff; font-size: 13px; }
#rel-body .row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; padding: 2px 0; color: #fff; }
#rel-body .way { min-width: 0; }
#rel-body .count { font-size: 18px; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
#rel-body .who { cursor: pointer; }
#rel-body .who:hover { text-decoration: underline; }
#rel-body .chip { padding: 1px 7px; border-radius: 9px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: #160726; }
#rel-body .chip.high { background: #ffd23f; }
#rel-body .chip.medium { background: #d9b84a; opacity: 0.85; }
#rel-body .chip.low { background: #a893c7; }

/* ---- Viewport ---- */
#viewport-wrap { grid-row: 1; grid-column: 1; position: relative; min-width: 0; min-height: 0; }
#viewport { display: block; width: 100%; height: 100%; outline: none; touch-action: none; }
#view-label {
  position: absolute;
  top: 8px;
  left: 10px;
  color: var(--text);
  font-size: 11px;
  pointer-events: none;
}

#lod-legend {
  position: absolute;
  top: 46px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  white-space: nowrap;
  padding: 5px 10px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text);
  pointer-events: none;
}
#lod-legend[hidden] { display: none; }
#lod-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
#quality { font: inherit; color: var(--text); background: #131416; border: 1px solid var(--panel-edge); border-radius: 4px; padding: 3px 4px; }

/* ---- Toolbar (top of viewport) ---- */
#toolbar {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 6px;
  white-space: nowrap;
}
#toolbar button {
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 4px;
  padding: 4px 9px;
  cursor: pointer;
}
#toolbar button:hover:not(:disabled) { background: #2d3035; }
#toolbar button.active { background: var(--select); color: #fff; }
#toolbar button:disabled { opacity: 0.35; cursor: default; }
#toolbar kbd { font: inherit; font-size: 10px; opacity: 0.55; margin-left: 3px; }
#toolbar .sep { width: 1px; height: 16px; background: var(--panel-edge); margin: 0 3px; }

input {
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: #131416;
  border: 1px solid var(--panel-edge);
  border-radius: 3px;
  padding: 1px 5px;
  width: 62px;
  user-select: text;
}
input:disabled { opacity: 0.4; }
input:focus { outline: 1px solid var(--select); outline-offset: 0; }
#snap-step { width: 36px; padding: 3px 4px; text-align: center; }

#toolbar label { display: flex; align-items: center; gap: 6px; padding: 0 5px 0 9px; }
#toolbar label:has(input:disabled) { opacity: 0.4; }
input[type="color"] { width: 28px; height: 20px; padding: 0; background: none; cursor: pointer; }
input[type="color"]:disabled { opacity: 1; cursor: default; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 2px; }

/* ---- The Display stack (in the left panel): Map relationship, what is shown, traffic ---- */
#walk-bar { padding: 0 10px 8px; }
#walk-bar .display-part { margin: 8px 0 4px; color: #d9cdee; font-weight: 600; }
#walk-bar .display-part:first-child { margin-top: 2px; }
/* Map relationship: from, to and Go in one row; the two menus share the width left over. */
#walk-bar .relation { flex-wrap: nowrap; }
#walk-bar .relation .picker { flex: 1 1 0; width: auto; }
#walk-bar .relation span { flex: none; color: #a893c7; }
#walk-bar .relation #walk-go { flex: none; }
#walk-bar .display-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 4px 0; }
#walk-bar button:not(.picker) {
  font: inherit;
  color: #fff;
  background: var(--select);
  border: 1px solid var(--select);
  border-radius: 3px;
  padding: 2px 10px;
  cursor: pointer;
}
#walk-bar .switch:not(.active) { background: #0d0418; border-color: #3a2060; color: #d9cdee; }
#walk-bar .switch:disabled { opacity: 0.45; cursor: default; }
/* All and None, at the right of the "Show" heading: small and plain, not switches themselves. */
#walk-bar .display-part { display: flex; align-items: center; justify-content: space-between; }
#walk-bar .both { display: flex; gap: 4px; }
#walk-bar .both button { background: none; border-color: #3a2060; color: #d9cdee; font-weight: 400; padding: 1px 7px; }
#walk-bar .both button:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
#walk-info { color: var(--text-dim); }
#walk-info:empty { display: none; }

/* ---- Status bar (bottom) ---- */
#status {
  grid-row: 2;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 12px;
  background: var(--panel);
  border-top: 1px solid var(--panel-edge);
  white-space: pre;
  overflow: hidden;
}
#sel-name { color: #fff; font-weight: 600; }
#sel-info { font-variant-numeric: tabular-nums; }
#type-in { display: flex; align-items: center; gap: 8px; }
[hidden] { display: none !important; }
#field-text { width: 220px; }
#field-label, #save-state { color: var(--text-dim); }
#stats { color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.view-only #stats { display: none; }
#status > span { flex: none; }
#status > #hints {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  color: var(--text-dim);
}

/* ---- View-only mode (the hosted copy): no building tools, properties are read-only ---- */
.view-only #toolbar > :not(#music-toggle), .view-only #mats, .view-only #surf, .view-only #type-in, .view-only #text-edit, .view-only #save-state { display: none; }
/* (The toolbar itself stays, holding only the Music button: the client can open the player.) */
.view-only #props select:disabled, .view-only #props input:disabled, .view-only #props textarea:disabled {
  opacity: 1;
  color: #fff;
  -webkit-text-fill-color: #fff;
  background: none;
  border-color: transparent;
  appearance: none;
  padding-left: 0;
  resize: none;
}
.view-only #props input[type="range"]:disabled { appearance: auto; }

/* Small screens: viewport only */
@media (max-width: 760px) {
  #explorer, #props, #mats, #surf, #music, #rel, #toolbar, #walk-bar, #type-in { display: none; }
  #hints { display: none; }
}

/* The hover callout: the name of what the mouse is over, beside the pointer. */
#callout {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 50;
  max-width: 320px;
  padding: 4px 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(22, 8, 40, 0.94);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

/* Properties panel: the Focus button under the name. */
#p-actions { display: flex; gap: 6px; margin: 0 0 10px; }
#p-actions button {
  padding: 4px 14px;
  font: inherit;
  color: #fff;
  background: #3a2060;
  border: 1px solid #5a3a8a;
  border-radius: 4px;
  cursor: pointer;
}
#p-actions button:hover { background: #4a2a7a; }
#p-actions button.active { background: #6f3cc4; border-color: #8f5fe0; }
/* The single-object report in the relationship panel (Analyze). */
#rel-body .figures { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
#rel-body .figure { padding: 6px 8px; background: #0d0418; border: 1px solid #3a2060; border-radius: 6px; }
#rel-body .figure b { display: block; font-size: 18px; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
#rel-body .flag { display: flex; gap: 7px; align-items: baseline; padding: 2px 0; color: #fff; }
#rel-body .flag::before { content: ''; flex: none; width: 7px; height: 7px; border-radius: 50%; background: #f2b233; transform: translateY(-1px); }
#rel-body .flag.bad::before { background: #e5484d; }

/* Searchable drop-downs (picker.js): a button in place of the <select>, and its list. */
.picker-source { display: none !important; }
.picker {
  font: inherit;
  color: #fff;
  background: #0d0418;
  border: 1px solid #3a2060;
  border-radius: 3px;
  padding: 3px 20px 3px 6px;
  width: 100%;
  min-width: 0;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  position: relative;
}
.picker::after { content: '▾'; position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font-size: 9px; color: #a893c7; }
.picker.unset { color: #a893c7; }
.picker:focus { outline: 1px solid #8f5fe0; outline-offset: 0; }
.picker:disabled { opacity: 0.5; cursor: default; }
.picker-list {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: #160726;
  border: 1px solid #5a3a8a;
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  overflow: hidden;
}
.picker-list input {
  flex: none;
  box-sizing: border-box;
  width: calc(100% - 12px); /* the full width of the list, less its margins */
  margin: 6px;
  padding: 4px 7px;
  font: inherit;
  color: #fff;
  background: #0d0418;
  border: 1px solid #3a2060;
  border-radius: 4px;
  outline: none;
}
.picker-list input:focus { border-color: #8f5fe0; }
.picker-items { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 4px; }
.picker-heading { padding: 7px 10px 3px; font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #a893c7; }
.picker-item { padding: 3px 10px 3px 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.picker-item:first-child { padding-left: 10px; color: #a893c7; }
.picker-item:hover { background: rgba(255, 255, 255, 0.08); }
.picker-item.at { background: #3a2060; }
.picker-item.chosen { color: #ffd23f; }
.picker-item:has(.picker-note) { display: flex; gap: 10px; }
.picker-note { margin-left: auto; color: #a893c7; font-size: 11px; }
.picker-add { margin-top: 4px; padding: 6px 10px; border-top: 1px solid rgba(255, 255, 255, 0.1); color: #c9a8ff; }
.picker-add:first-child { margin-top: 0; border-top: 0; color: #c9a8ff; }
.picker-none { padding: 8px 10px; color: #a893c7; font-style: italic; }

/* The Analyze report: the relationship panel in dark green. */
#rel.analysis { background: #06140c; border-color: #173d28; }
#rel.analysis h1 { background: #0b2216; border-bottom-color: #173d28; }
#rel.analysis #rel-body { color: #cfe6d7; }
#rel.analysis #rel-body h2, #rel.analysis #rel-body .dim, #rel.analysis #rel-body .none { color: #8fbf9f; }
#rel.analysis #rel-body .card, #rel.analysis #rel-body .figure { background: #030c07; border-color: #173d28; }
#rel.analysis #rel-body .verdict { background: #0b2216; }
#rel.analysis #rel-close { color: #cfe6d7; }
#rel-body .summary { margin: 10px 2px 0; color: #e6f2ea; font-size: 12.5px; line-height: 1.55; }
#rel h1 { cursor: move; touch-action: none; user-select: none; }
#rel-close { cursor: pointer; }

/* Sliders whose number can be typed (slider.js): the number is clicked and typed over. */
.slider > output { cursor: text; border-radius: 3px; }
.slider > output:hover { background: rgba(255, 255, 255, 0.1); }
.slider > output.editing { background: none; }
.slider > output > input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 1px 3px;
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: #fff;
  background: #0d0418;
  border: 1px solid #8f5fe0;
  border-radius: 3px;
  outline: none;
}

/* The DOF button while the quality is below High: depth of field is not shown then. */
#dof-toggle.idle { opacity: 0.45; }

/* ---- The Music panel (opened from the toolbar): see music.js ---- */
#music {
  position: fixed;
  left: 50%;
  top: 34px;
  width: 280px;
  margin-left: -140px;
  max-height: calc(100vh - 34px - 28px - 60px);
  z-index: 22;
  display: flex;
  flex-direction: column;
  background: #160726;
  border: 1px solid #3a2060;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
#music[hidden] { display: none; }
#music h1 {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  padding: 8px 8px 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #22103a;
  cursor: move;
  touch-action: none;
}
#music-close { font: inherit; font-size: 16px; line-height: 1; color: #d9cdee; background: none; border: 0; border-radius: 3px; padding: 1px 6px; cursor: pointer; }
#music-close:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
#music-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px 12px; }
#music select { font: inherit; color: #fff; background: #0d0418; border: 1px solid #3a2060; border-radius: 3px; padding: 3px 5px; width: 100%; min-width: 0; }
#music .music-row { display: flex; align-items: center; gap: 5px; margin: 6px 0 4px; }
#music .music-row button {
  flex: none;
  font: inherit;
  color: #fff;
  background: #0d0418;
  border: 1px solid #3a2060;
  border-radius: 3px;
  padding: 2px 8px;
  cursor: pointer;
}
#music .music-row button.active { background: var(--select); border-color: var(--select); }
#music .music-row button:disabled { opacity: 0.45; cursor: default; }
#music-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; }
#music-time { flex: none; color: #a893c7; font-variant-numeric: tabular-nums; font-size: 11px; }
#music label { display: grid; grid-template-columns: 46px minmax(0, 1fr); align-items: center; gap: 6px; margin: 4px 0; color: #d9cdee; }
#music .slider { display: flex; align-items: center; gap: 8px; }
#music input[type="range"] { flex: 1; width: auto; min-width: 0; padding: 0; border: 0; background: none; accent-color: #8f5fe0; }
#music output { width: 26px; text-align: right; color: #fff; font-variant-numeric: tabular-nums; }
#music-tracks { list-style: none; margin: 4px 0 0; padding: 0; max-height: 220px; overflow-y: auto; }
#music-tracks li { padding: 2px 6px; border-radius: 3px; color: #d9cdee; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#music-tracks li:hover { background: rgba(255, 255, 255, 0.08); }
#music-tracks li.playing { color: #ffd23f; }
#music-empty { margin: 4px 0 0; color: #a893c7; font-style: italic; }
