/* Pixel character maker */
#avatar-maker.section-block {
  padding: var(--space-section) 0;
}
.am-band {
  max-width: 920px;
  margin: 0 auto;
}

.am-head {
  text-align: center;
  margin: 0 0 32px;
}
.am-title {
  margin: 0;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: clamp(24px, 4vw, 38px);
  letter-spacing: -1px;
  color: var(--ink);
}

.am-workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  column-gap: 20px;
  align-items: start;
}
@media (max-width: 640px) {
  .am-workspace { grid-template-columns: 1fr; row-gap: 16px; }
}

/* Left column: stage + footer stacked */
.am-stage-col {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Right column: picker only */
.am-right {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Footer: directly below character rectangle */
.am-footer {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
}

/* Preview box — folder gray, rounded like folders */
.am-stage {
  border-radius: var(--r-lg);
  background: var(--folder-bg);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}
.am-stage-floor {
  position: relative;
  flex: 1;
  min-height: 200px;
  padding: 14px;
  box-sizing: border-box;
}
/* Solid floor at the very base of the preview rectangle */
.am-stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22px;
  background: rgba(26, 26, 26, 0.07);
  z-index: 0;
  pointer-events: none;
}
[data-theme="dark"] .am-stage::after {
  background: rgba(240, 237, 232, 0.09);
}

/* Fixed slot — character sits at bottom, space above head auto-adjusts */
.am-preview-slot {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 0;     /* stage grows so top-space is natural */
  bottom: 22px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1;
}
.am-figure {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}
.am-figure--built {
  width: auto;
  height: 160px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.am-figure--built svg,
.am-figure--built img {
  display: block;
  height: 160px;
  width: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
/* The figure wrapper is pointer-events:none, but the rendered <img> needs events
   back on so a long-press (iOS) / right-click (desktop) brings up the native image
   menu — "Save to Photos" / "Save Image As…". */
.am-figure--built img {
  pointer-events: auto;
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
}

/* "done building?" label + Download link — plain text, no container */
.am-dl-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--steel);
}
.am-dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--pink);
  text-underline-offset: 3px;
  transition: color 160ms ease;
}
.am-dl-btn:hover { color: var(--pink); }
.am-dl-btn svg {
  display: block;
  width: 13px;
  height: 13px;
  flex: none;
  stroke: currentColor;
}

.am-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.am-cats {
  display: flex;
  gap: 6px;
  padding: 0;
  background: none;
  overflow-x: auto;
  scrollbar-width: none;
}
.am-cats::-webkit-scrollbar {
  display: none;
}
.am-cat-btn {
  flex: 1 1 0;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: var(--r-md);
  background: none;
  color: var(--stone);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 160ms ease, background 160ms ease;
}
.am-cat-btn svg {
  width: 24px;
  height: 24px;
  display: block;
  flex: none;
}
.am-cat-btn:hover {
  color: var(--charcoal);
  background: var(--surface);
}
.am-cat-btn.is-active {
  color: var(--ink);
  background: var(--surface);
}

.am-cat-head {
  margin: 2px 0 0;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.am-options-wrap {
  min-height: 176px;
}
.am-grid {
  display: flex;
  gap: 8px;
}
.am-grid > * {
  flex: 1 1 0;
  min-width: 0;
}

.am-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  padding: 8px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--canvas);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}
.am-cell:hover {
  border-color: var(--hairline-strong);
}
.am-cell.is-active {
  border-color: var(--ink);
  border-width: 2px;
  padding: 7px;
  background: var(--surface);
}
.am-cell-thumb {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
}
.am-cell-thumb svg {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.am-colors-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
}
.am-colors-row[hidden] {
  display: none;
}
.am-swatch-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  transition: box-shadow 160ms ease, transform 160ms ease;
}
.am-swatch-btn.is-active {
  transform: scale(1.05);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12),
    0 0 0 2px var(--canvas),
    0 0 0 4px var(--ink);
}
