body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  margin: 24px;
  background: #0b0f17;
  color: #e5e7eb;
}

.wrap {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.panel {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 14px;
  padding: 16px;
  width: 420px;
  min-width: 360px;
  max-width: 460px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.panel h2 {
  font-size: 16px;
  margin: 0 0 12px;
}

label {
  display: block;
  font-size: 13px;
  color: #cbd5e1;
  margin: 10px 0 4px;
}

input[type="text"],
input[type="file"],
input[type="number"],
select {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #374151;
  background: #0f172a;
  color: #e5e7eb;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: #2563eb;
  color: white;
  font-weight: 600;
}

button.secondary {
  background: #334155;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 160px;
  background: #0f172a;
  border: 1px solid #374151;
  border-radius: 10px;
  color: #e5e7eb;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.4;
  resize: vertical;
}

#baseAreasInput {
  min-height: 120px;
}

#out {
  min-height: 260px;
  white-space: pre;
}

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

.row.three {
  grid-template-columns: 1fr 1fr 1fr;
}

.row + .row,
.row + label,
.toolbar + label {
  margin-top: 12px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.small {
  font-size: 12px;
  color: #cbd5e1;
}

.hint {
  font-size: 12px;
  color: #93c5fd;
  margin-top: 6px;
}

.section-divider {
  border: none;
  border-top: 1px solid #1f2937;
  margin: 16px 0;
}

.panel h3 {
  font-size: 14px;
  margin: 12px 0 8px;
  color: #e2e8f0;
}

.footer {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 12px;
}

.stage {
  position: relative;
  display: inline-block;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #1f2937;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.stage img {
  display: block;
  max-width: 100%;
  height: auto;
}

svg.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.shape-base {
  fill: rgba(16, 185, 129, 0.25);
  stroke: #10b981;
  stroke-width: 2;
  pointer-events: auto;
}

.shape-clone {
  fill: rgba(59, 130, 246, 0.25);
  stroke: #3b82f6;
  stroke-width: 2;
  pointer-events: auto;
}

.shape-draft {
  fill: rgba(250, 204, 21, 0.25);
  stroke: #facc15;
  stroke-width: 2;
  pointer-events: auto;
}

.shape-committed {
  fill: rgba(168, 85, 247, 0.2);
  stroke: #a855f7;
  stroke-width: 2;
  pointer-events: auto;
}

.mapped-list {
  max-height: 220px;
  overflow: auto;
  border: 1px solid #374151;
  border-radius: 10px;
  background: #0f172a;
  padding: 8px;
  margin-top: 8px;
  font-size: 12px;
}

.mapped-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid #1f2937;
}

.mapped-item:last-child {
  border-bottom: 0;
}

.mapped-item button {
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 11px;
  background: #475569;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-top: 10px;
}

@media (max-width: 900px) {
  body {
    margin: 12px;
  }

  .wrap {
    flex-direction: column;
  }

  .panel {
    width: 100%;
    min-width: 0;
    max-width: none;
    box-sizing: border-box;
  }

  .row,
  .row.three {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1200px) {
  .stage {
    max-width: calc(100vw - 520px);
  }
}
