:root {
  color: #241c16;
  background: #f3efe8;
  font-family: "Avenir Next", "PingFang SC", "Noto Sans SC", sans-serif;
  line-height: 1.4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
}

button, input, select, textarea { font: inherit; }

a { color: #8d3b32; }

.app {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 460px);
  gap: 28px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.stage {
  position: sticky;
  top: 18px;
  align-self: start;
}

.canvas-frame {
  background: linear-gradient(#f7f5f2, #e7e1d8);
  border: 1px solid #e4dcd1;
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 18px 40px rgba(70, 48, 28, 0.08);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 10px 24px rgba(40, 30, 20, 0.16);
  cursor: default;
}

.admin-grid canvas { cursor: grab; }

.stage-note, .result {
  margin-top: 14px;
  color: #6d6258;
  font-size: 13px;
}

.panel {
  background: #fff;
  border-radius: 18px;
  padding: 18px 18px 22px;
  border: 1px solid #eadfd3;
}

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
  color: #8d3b32;
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 650;
}

.lead { margin: 0 0 18px; color: #6d6258; }

.option {
  padding: 12px 0;
  border-top: 1px solid #f0e7de;
}

.option h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.step {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: 6px;
  border-radius: 50%;
  background: #241c16;
  color: #fff;
  font-size: 12px;
}

.swatches, .counts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swatch, .count {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  border: 2px solid transparent;
  background: #f6f3ef;
  cursor: pointer;
  padding: 0;
}

.swatch[aria-checked="true"], .count[aria-checked="true"] {
  border-color: #241c16;
}

.swatch { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); }

.count {
  display: grid;
  place-items: center;
  color: #4a3728;
  font-size: 13px;
}

.count canvas { width: 58px; height: 58px; box-shadow: none; background: transparent; }

label.field {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: #6d6258;
}

input[type="text"], select, textarea, input[type="number"] {
  width: 100%;
  margin-top: 4px;
  border: 1px solid #e4d8cc;
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
}

.names { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.actions { display: flex; gap: 8px; margin-top: 16px; }

button.primary, button.ghost {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  cursor: pointer;
}

button.primary { background: #8d3b32; color: white; }

button.ghost { background: #f3ece4; color: #241c16; }

button:disabled { opacity: 0.55; cursor: wait; }

.result pre {
  max-height: 180px;
  overflow: auto;
  background: #241c16;
  color: #f7f1e8;
  border-radius: 12px;
  padding: 12px;
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(28, 22, 16, 0.62);
  padding: 24px;
}

.modal.open { display: grid; }

.modal figure {
  margin: 0;
  max-width: min(1100px, 100%);
  background: white;
  border-radius: 16px;
  padding: 16px;
}

.modal img { width: 100%; height: auto; display: block; }

.modal header { display: flex; justify-content: space-between; align-items: center; }

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  padding: 24px;
}

.handles { position: relative; }

.handle {
  position: absolute;
  border: 1.5px dashed transparent;
  pointer-events: none;
}

.handle.on { border-color: #8d3b32; }

.layers { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.layers button[aria-pressed="true"] { background: #241c16; color: white; }

.designs { display: grid; gap: 10px; }

.designs article {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  align-items: center;
}

.designs img { width: 120px; border-radius: 6px; }

.row { display: grid; grid-template-columns: 1fr 90px 90px auto; gap: 6px; margin-bottom: 6px; }

.color-row { display: grid; grid-template-columns: 1fr 42px 42px 42px auto; gap: 6px; align-items: center; margin-bottom: 6px; }

.color-row input[type="color"] { padding: 0; height: 36px; }

.error { color: #8d3b32; font-size: 13px; min-height: 1.2em; }

@media (max-width: 980px) {
  .app, .admin-grid { grid-template-columns: 1fr; }
  .stage { position: static; }
}
