:root {
  --bg: #121110;
  --panel: #1a1917;
  --line: #2e2c29;
  --text: #e8e4dc;
  --dim: #8a857c;
  --accent: #ff5a0a;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 12px/1.4 var(--mono);
}

body {
  display: grid;
  grid-template-columns: 300px 1fr;
}

#panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px;
  overflow-y: auto;
  height: 100vh;
}

header h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.04em;
}
header h1 span { color: var(--accent); }
header p { margin: 4px 0 16px; color: var(--dim); }

section {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

h2 {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}

/* Section headings double as collapse toggles. */
section > h2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
section > h2::after {
  content: "▾";
  font-size: 12px;
  transition: transform 0.15s;
}
section > h2:hover,
section > h2:focus-visible { color: var(--text); outline: none; }
section.collapsed > h2 { margin-bottom: 0; }
section.collapsed > h2::after { transform: rotate(-90deg); }
section.collapsed > :not(h2) { display: none; }

label {
  display: block;
  margin-bottom: 10px;
  color: var(--text);
}
label output { float: right; color: var(--accent); }

label.check {
  display: flex;
  gap: 8px;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  margin-top: 4px;
  accent-color: var(--accent);
}
input[type="checkbox"] { accent-color: var(--accent); }

textarea, input[type="text"], select {
  width: 100%;
  margin-top: 4px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
  font: inherit;
  resize: vertical;
}
textarea:focus, input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

.drop {
  display: grid;
  place-items: center;
  min-height: 72px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px dashed var(--dim);
  border-radius: 6px;
  text-align: center;
  color: var(--dim);
  cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--accent); color: var(--text); }

.seg { display: flex; gap: 4px; }

button {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 8px;
  font: inherit;
  cursor: pointer;
}
button:hover { border-color: var(--dim); }
button.on, .actions button:first-child {
  background: var(--accent);
  border-color: var(--accent);
  color: #111;
}

.presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 10px;
}
.presets button {
  height: 28px;
  padding: 0;
  font-weight: 700;
}

.colors { display: flex; gap: 12px; }
.colors label { display: flex; align-items: center; gap: 6px; }
input[type="color"] {
  width: 32px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  background: none;
  cursor: pointer;
}

.actions { display: grid; gap: 6px; }

#stage {
  position: relative;
  display: grid;
  place-items: center;
  height: 100vh;
  padding: 24px;
  overflow: hidden;
}

#stage canvas {
  max-width: 100%;
  max-height: calc(100vh - 64px);
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
#stage canvas.pixelated { image-rendering: pixelated; }

#info {
  position: absolute;
  bottom: 10px;
  right: 16px;
  color: var(--dim);
}

[hidden] { display: none !important; }

@media (max-width: 760px) {
  body { grid-template-columns: 1fr; }
  #panel { height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  #stage { height: auto; min-height: 60vh; padding: 16px; }
  #stage canvas { max-height: none; }
}
