:root {
  color-scheme: light;
  --bg: #f3f1ec;
  --panel: #fffcf7;
  --ink: #1c1915;
  --muted: #6d655c;
  --line: #e4ddd2;
  --accent: #0f6e56;
  --accent-ink: #fff;
  --stage: #d9d3c8;
  --danger: #9f2d2d;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  padding: 1.25rem 1.5rem 0.75rem;
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.subtitle {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.92rem;
}

code {
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 0.92em;
}

.status {
  margin: 0;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 0.85rem;
}

.status.is-error {
  color: var(--danger);
  border-color: #e7c4c4;
  background: #fff6f6;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1rem;
  padding: 0.75rem 1.5rem 1.5rem;
  align-items: start;
}

.stage {
  background:
    linear-gradient(45deg, #cfc8bc 25%, transparent 25%),
    linear-gradient(-45deg, #cfc8bc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #cfc8bc 75%),
    linear-gradient(-45deg, transparent 75%, #cfc8bc 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-color: var(--stage);
  border-radius: 16px;
  min-height: 70vh;
  display: grid;
  place-items: center;
  overflow: hidden;
}

canvas {
  width: min(100%, 820px);
  height: auto;
  aspect-ratio: 1;
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

button {
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

.params {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.9rem;
}

.param {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  align-items: center;
  gap: 0.5rem;
}

.param label,
.param-label {
  font-size: 0.92rem;
  font-weight: 600;
}

.param-state {
  grid-template-columns: 1fr;
  align-items: stretch;
}

.triggers {
  display: grid;
  gap: 0.35rem;
}

.trigger-row {
  display: grid;
  grid-template-columns: 1.25rem minmax(0, 1fr);
  align-items: center;
  gap: 0.4rem;
}

.trigger-index {
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

button.trigger {
  width: 100%;
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 0.45rem 0.65rem;
}

button.trigger.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.param input[type="number"],
.color-field input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  font: inherit;
  background: #fff;
}

.color-field {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: 0.4rem;
  align-items: center;
}

.color-field input[type="color"] {
  width: 2.25rem;
  height: 2rem;
  padding: 0.15rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.color-field input[type="text"] {
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 0.82rem;
}

.empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
