:root {
  --bg: #0b0b0d;
  --panel: #141417;
  --line: #2a2a30;
  --text: #e8e6e3;
  --dim: #8b8a90;
  --accent: #ff3d9a;
  --control: 30px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 46px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
header .sub { color: var(--dim); }
header nav { margin-left: auto; display: flex; gap: 4px; }
header nav button.on, .seg button.on { background: var(--text); color: var(--bg); }

main { flex: 1; display: flex; min-height: 0; }

.panel {
  width: 280px;
  flex: none;
  overflow-y: auto;
  padding: 12px 16px 24px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.panel h2 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--dim);
  margin: 18px 0 8px;
}
.panel h2:first-child { margin-top: 4px; }
.panel label { display: block; margin: 8px 0; color: var(--dim); }
.panel label input:not([type=checkbox]), .panel label select { display: block; width: 100%; margin-top: 4px; }
.panel label.check { display: flex; align-items: center; gap: 6px; }

button, input, select {
  height: var(--control);
  font: inherit;
  color: var(--text);
  background: #1f1f24;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
}
input[type=checkbox] { height: auto; }
input[type=range] { padding: 0; border: 0; background: none; accent-color: var(--accent); }
button { cursor: pointer; white-space: nowrap; }
button:hover { border-color: #444; }

.row { display: flex; gap: 6px; margin: 8px 0; align-items: flex-end; }
.row > * { flex: 1; margin: 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.list li:hover { background: #1c1c21; }
.list li.on { background: #26262c; }
.list li svg { width: 34px; height: 34px; flex: none; }
.list li .meta { color: var(--dim); margin-left: auto; font-variant-numeric: tabular-nums; }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.swatches button {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
}
.swatches button.on { border-color: var(--text); }
.swatches input[type=color] { width: 26px; height: 26px; padding: 0; border-radius: 50%; }

.readout { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 10px 0; font-variant-numeric: tabular-nums; }
.readout dt { color: var(--dim); }
.readout dd { margin: 0; }

.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; cursor: pointer; opacity: .55; border: 2px solid transparent; }
.thumbs img.on { opacity: 1; border-color: var(--text); }

.help { color: var(--dim); font-size: 12px; margin-top: 14px; }

.stage { flex: 1; position: relative; min-width: 0; overflow: hidden; }
.stage canvas { position: absolute; inset: 0; display: block; }
#design-svg { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#design-svg .minor { stroke: #1b1b20; }
#design-svg .major { stroke: #2b2b33; }
#design-svg .axis { stroke: #3a3a44; }
#design-svg .bbox { stroke: #55555f; stroke-dasharray: 4 4; fill: none; }
#design-svg .spine { stroke: #ffffff30; fill: none; }
#design-svg .pt { fill: #0b0b0d; stroke: #fff; cursor: grab; }
#design-svg .pt.sel { fill: var(--accent); stroke: var(--accent); }
#design-svg text { fill: var(--dim); font-family: inherit; }

#stage-space { display: flex; align-items: center; justify-content: center; }
#space-frame { position: relative; }
#space-frame canvas { position: absolute; inset: 0; }
#space-svg { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#space-svg .sel { fill: none; stroke: #fff; stroke-dasharray: 5 4; }

@media (max-width: 720px) {
  main { flex-direction: column-reverse; }
  .panel { width: 100%; border-right: 0; border-top: 1px solid var(--line); max-height: 45vh; }
  .stage { min-height: 55vh; }
  header .sub { display: none; }
}

.readout .warn { color: #ff6b5b; }
header .power { margin-left: auto; }
header .power + nav { margin-left: 8px; }
header .power.on { border-color: #ffb347; color: #ffcf7a; box-shadow: 0 0 10px #ffb34755; }

.stage-tools { position: absolute; top: 12px; right: 12px; display: flex; gap: 4px; z-index: 2; }
.stage canvas[hidden] { display: none; }
