:root {
  --bg: #f4f1e8;
  --ink: #17211d;
  --muted: #64716b;
  --panel: #fffdf8;
  --line: #d7d0c2;
  --green: #214a35;
  --green-soft: #e8efe8;
  --ochre: #a56f2b;
  --blue: #173d58;
  --rust: #a9432b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(165, 111, 43, 0.16), transparent 34rem),
    linear-gradient(135deg, #f7f4ea 0%, var(--bg) 48%, #ece7da 100%);
  color: var(--ink);
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
}

.page {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.hero {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0;
  color: var(--ochre);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 5vw, 58px);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.lede {
  max-width: 820px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.stage-panel,
.control-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.9);
  box-shadow: 0 18px 60px rgba(57, 45, 27, 0.12);
}

.stage-panel {
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.phase {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--green);
  color: #fffaf0;
  font-size: 13px;
  font-weight: 700;
}

.stats {
  display: inline-block;
  margin-left: 8px;
  color: var(--muted);
  font-size: 13px;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

button,
select,
input {
  font: inherit;
}

button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #b9b09f;
  border-radius: 999px;
  background: #f6efe1;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

button:hover {
  border-color: var(--ochre);
  background: #efe3cf;
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  image-rendering: pixelated;
  background: #1c241f;
  cursor: crosshair;
}

.caption {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 14px 14px;
  color: var(--muted);
  font-size: 12px;
}

.caption span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip {
  width: 16px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.chip.low {
  background: #f7ead1;
}

.chip.mid {
  background: #c57a32;
}

.chip.high {
  background: #18252c;
}

.control-panel {
  display: grid;
  gap: 15px;
  padding: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffaf0;
  color: var(--ink);
}

.param-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

output {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.explain,
.equations {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(232, 239, 232, 0.55);
}

h2 {
  margin-bottom: 8px;
  color: var(--green);
  font-size: 16px;
}

ol {
  margin: 0 0 10px 19px;
  padding: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.explain p,
.equations p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

pre {
  margin: 10px 0 0;
  white-space: pre-wrap;
  color: var(--blue);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
}

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

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .buttons {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .page {
    width: min(100vw - 16px, 1180px);
    padding-top: 12px;
  }

  .param-grid {
    grid-template-columns: 1fr;
  }
}
