*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: "basic-sans", "Helvetica Neue", Arial, sans-serif;
  background: #f0ebe3;
  margin: 0;
  min-height: 100vh;
  color: #1a1a1a;
}

/* ── Top bar ── */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
}

h1 {
  font-family: "p22-folk-art-cross", sans-serif;
  font-weight: 400;
  font-style: normal;
  font-size: 38px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #1a1a1a;
  margin: 0;
  flex-shrink: 0;
  line-height: 1;
}

/* ── Toolbar ── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Buttons (outline style) ── */

button {
  font-family: "basic-sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 20px;
  border: 1.5px solid #1a1a1a;
  background: transparent;
  color: #1a1a1a;
  cursor: pointer;
  border-radius: 999px;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

button:hover {
  background: #1a1a1a;
  color: #fff;
}

button:disabled {
  border-color: #bbb;
  color: #bbb;
  cursor: not-allowed;
}

button:disabled:hover {
  background: transparent;
  color: #bbb;
}

/* ── Zoom controls (single pill) ── */

.zoom-controls {
  display: flex;
  align-items: center;
  border: 1.5px solid #1a1a1a;
  border-radius: 999px;
  overflow: hidden;
}

.zoom-controls button {
  border: none;
  border-radius: 0;
  padding: 10px 14px;
  font-size: 16px;
}

.zoom-controls button:hover {
  background: #1a1a1a;
  color: #fff;
}

.zoom-label {
  font-family: "basic-sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  min-width: 48px;
  text-align: center;
  padding: 0 4px;
  color: #1a1a1a;
}

/* ── Ajustar grilla (filled dark button + dropdown) ── */

.controls-panel {
  position: relative;
}

.controls-panel summary {
  font-family: "basic-sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  list-style: none;
  padding: 10px 20px;
  background: #1a1a1a;
  color: #fff;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  line-height: 1;
  transition: background 0.15s ease;
}

.controls-panel summary::-webkit-details-marker { display: none; }

.controls-panel summary::after {
  content: " +";
}

.controls-panel[open] summary::after {
  content: " −";
}

.controls-panel summary:hover {
  background: #333;
}

/* ── Controls dropdown panel ── */

.controls {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: min(480px, calc(100vw - 48px));
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  background: #fff;
  border: 1.5px solid rgba(26, 26, 26, 0.12);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  z-index: 100;
  text-align: left;
}

.control-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.control-row label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #666;
}

.control-row input[type="number"],
.control-row input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
  color: #1a1a1a;
  font-size: 15px;
  font-family: inherit;
}

.control-row input[type="color"] {
  width: 100%;
  padding: 4px;
  min-height: 42px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
  cursor: pointer;
}

.control-row input[type="range"] {
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  accent-color: #1a1a1a;
  height: 24px;
  cursor: pointer;
}

.control-row--full {
  grid-column: 1 / -1;
}

.control-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

.control-actions button {
  font-size: 12px;
  padding: 8px 18px;
}

/* ── Shape picker ── */

.shape-picker {
  display: flex;
  gap: 6px;
}

.btn-shape {
  width: 36px;
  height: 36px;
  padding: 6px;
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-shape svg {
  width: 100%;
  height: 100%;
  fill: #aaa;
  stroke: none;
}

.btn-shape svg line {
  fill: none;
  stroke: #aaa;
}

.btn-shape:hover svg {
  fill: #555;
}

.btn-shape:hover svg line {
  stroke: #555;
}

.btn-shape--active {
  border-color: #1a1a1a;
  background: #1a1a1a;
}

.btn-shape--active svg {
  fill: #fff !important;
}

.btn-shape--active svg line {
  stroke: #fff !important;
}

/* ── Reference image controls ── */

.ref-image-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.ref-image-label {
  display: inline-flex;
  align-items: center;
  font-family: "basic-sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 16px;
  border: 1.5px solid #1a1a1a;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.ref-image-label:hover {
  background: #1a1a1a;
  color: #fff;
}

#refImage {
  display: none;
}

.btn-remove {
  font-size: 12px;
  padding: 8px 14px;
  border-color: #bbb;
  color: #666;
}

.btn-remove:hover {
  background: #666;
  border-color: #666;
  color: #fff;
}

.btn-mode {
  width: 100%;
  font-size: 12px;
  padding: 8px 14px;
  border-color: #bbb;
  color: #666;
}

.btn-mode:hover {
  background: #666;
  border-color: #666;
  color: #fff;
}

.btn-mode--active {
  background: #1a1a1a;
  border-color: #1a1a1a;
  color: #fff;
}

.btn-mode--active:hover {
  background: #444;
  border-color: #444;
}

/* ── Canvas wrapper ── */

#canvas-wrapper {
  width: calc(100% - 48px);
  margin: 0 auto 32px;
  overflow: auto;
}

#canvas-stage {
  width: max-content;
  min-width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

canvas {
  display: block;
  border: 1.5px solid rgba(26, 26, 26, 0.2);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── Responsive ── */

@media (max-width: 640px) {
  h1 { font-size: 28px; }
  .top-bar { padding: 14px 16px; }
  #canvas-wrapper { width: calc(100% - 32px); }
}
