:root {
  --ink: #111; --paper: #fff; --line: #d3d9e3; --accent: #2563eb; --red: #e11d48; --mute: #667085;
  font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; height: 100vh; display: flex; flex-direction: column; background: var(--paper); }
header { display: flex; gap: 6px; align-items: center; padding: 8px 10px; border-bottom: 2px solid var(--ink); flex-wrap: wrap; }
.logo { font-size: 15px; margin-right: 8px; }
.grow { flex: 1; }
.sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
button, select, input, textarea { font: inherit; color: inherit; }
button, select { border: 1.5px solid var(--ink); background: #fff; padding: 4px 9px; border-radius: 6px; cursor: pointer; }
button:hover { background: #eef1f6; }
button.on, button.primary { background: var(--ink); color: #fff; }
button.primary:hover { background: #333; }
.tabs { display: flex; }
.tabs button:first-child { border-radius: 6px 0 0 6px; }
.tabs button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }

main { flex: 1; display: flex; min-height: 0; }
aside { width: 210px; flex: none; overflow: auto; padding: 10px; border-right: 2px solid var(--ink); }
#props { width: 290px; border-right: 0; border-left: 2px solid var(--ink); }
aside h3 { margin: 0 0 8px; font-size: 14px; word-break: break-word; }
aside h4 { margin: 12px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); }
aside h4:first-child { margin-top: 0; }
.pal { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.pal button { padding: 6px 4px; font-size: 12px; text-align: left; }
.hint { color: var(--mute); font-size: 11px; margin: 14px 0 0; }
aside h4 small { text-transform: none; letter-spacing: 0; font-weight: 400; }
#layers { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow: auto; }
#layers button { flex: none; text-align: left; font-size: 11px; padding: 3px 6px; border-width: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#stage { flex: 1; position: relative; min-width: 0; overflow: hidden; }
#view2d, #view3d { position: absolute; inset: 0; width: 100%; height: 100%; }
#view2d { background: #fff; touch-action: none; user-select: none; }
#view3d canvas { display: block; }
body[data-mode="2d"] #view3d, body[data-mode="3d"] #view2d { display: none; }
.labels3 { position: absolute; top: 0; left: 0; pointer-events: none; }
.lbl3 { font: 600 11px ui-monospace, monospace; background: var(--ink); color: #fff; padding: 2px 8px; border-radius: 9px; white-space: nowrap; }
.lbl3 b { margin-right: 6px; }
#toolbar { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 4px; flex-wrap: wrap; pointer-events: none; }
#toolbar > * { pointer-events: auto; }
#toolbar button { font-size: 12px; padding: 3px 8px; }
#toolbar .tb-gap { width: 8px; }
#toolbar .swatch { width: 24px; padding: 0; background: var(--c); }
#toolbar .swatch.on { outline: 2px solid var(--accent); outline-offset: 2px; }

.fields { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px 6px; }
.fields > * { grid-column: span 6; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fields > .half { grid-column: span 3; }
.fields > .third { grid-column: span 2; }
.fields span { font-size: 11px; color: var(--mute); }
.fields input, .fields select, .fields textarea { width: 100%; border: 1.5px solid var(--ink); border-radius: 5px; padding: 4px 6px; background: #fff; }
.fields input[type="range"] { border: 0; padding: 0; accent-color: var(--ink); }
.fields textarea { min-height: 54px; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips button { font-size: 11px; padding: 2px 7px; }
.actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 14px; }
.actions .danger { border-color: var(--red); color: var(--red); }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
dialog { border: 2px solid var(--ink); border-radius: 10px; max-width: 560px; padding: 18px 22px; }
dialog::backdrop { background: rgba(0, 0, 0, .25); }
dialog h2 { margin-top: 0; }
dialog h3 { margin-bottom: 4px; }
dialog p, dialog li { margin: 4px 0; }

@media (max-width: 900px) {
  aside { width: 150px; }
  #props { width: 220px; }
}
