/* Shared control geometry; scene framing and exported artwork stay independent. */
.primary,
.secondary,
.workflow-actions > .primary,
.workflow-actions > .secondary,
.dialog-actions .primary,
.dialog-actions .secondary,
#contact-form .dialog-actions .primary,
#contact-form .dialog-actions .secondary,
#export-dialog .export-actions > .primary,
#export-dialog .export-actions > .secondary,
#sad-priced-link,
.editor.is-building .build-empty + .secondary {
  min-height: var(--ui-button-height);
  padding: 12px 18px;
  border-radius: var(--ui-radius);
  font-size: var(--ui-action);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: .7px;
  gap: 16px;
}

.text-btn,
.dialog-actions .text-btn,
#contact-form .dialog-actions .text-btn {
  min-height: var(--ui-target);
  font-size: var(--ui-compact);
  font-weight: 500;
  line-height: 1.4;
}

.final-title .final-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 0;
}

.final-workspace .final-start-over {
  margin-top: 8px;
}

#payment-proof::file-selector-button {
  min-height: var(--ui-target);
  border-radius: var(--ui-radius);
  font-size: var(--ui-action);
  font-weight: 500;
  padding: 10px 12px;
}

body :is(button, a, summary, input, textarea, select):focus-visible,
body .composition-tool:focus-visible,
body .final-stage .final-light-button:focus-visible,
body .design-signature input:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

.composition-tool,
.build-step {
  min-height: var(--ui-target);
  border-radius: var(--ui-radius);
  font-size: var(--ui-compact);
  font-weight: 500;
  line-height: 1.3;
}

.category,
.shape-option,
.add-part,
.body-row.active,
input,
textarea,
select {
  border-radius: var(--ui-radius);
}

.add-part {
  min-height: var(--ui-target);
  font-size: var(--ui-compact);
}

.summary-panel,
.design-card,
dialog {
  border-radius: var(--ui-panel-radius);
}

.toggle,
.preview-workspace .preview-navigation .toggle {
  border-radius: var(--ui-radius);
}

.toggle button,
.preview-workspace .toggle button,
.preview-workspace .preview-navigation .toggle button {
  min-height: var(--ui-target);
  padding: 9px 10px;
  border-radius: 4px;
  font-size: var(--ui-compact);
  font-weight: 500;
  line-height: 1.3;
}

.step {
  min-height: var(--ui-target);
}

.step-dot {
  flex: 0 0 var(--ui-step-circle);
  width: var(--ui-step-circle);
  height: var(--ui-step-circle);
  font-size: var(--ui-fine);
  line-height: 1;
}

/* A 32px ring sits inside each 44px zoom target on every device. */
.preview-workspace .zoom-controls .icon-btn,
.final-stage .final-framing-tools .icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 var(--ui-target);
  width: var(--ui-target);
  height: var(--ui-target);
  min-width: var(--ui-target);
  min-height: var(--ui-target);
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
}

.preview-workspace .zoom-controls .icon-btn::before,
.final-stage .final-framing-tools .icon-btn::before {
  content: '';
  position: absolute;
  inset: calc((var(--ui-target) - var(--ui-circle)) / 2);
  border: 1px solid var(--line);
  border-radius: 50%;
  pointer-events: none;
  transition: border-color 180ms var(--ease-settle),
    background-color 180ms var(--ease-settle);
}

.preview-workspace .zoom-controls .icon-btn::before {
  border-color: currentColor;
}

.reset-view,
.all-colours,
.workflow-column .editor .all-colours,
.workflow-links > .text-btn,
.preview-workspace .reset-view,
.preview-workspace .preview-back,
.final-stage .final-framing-tools .reset-view {
  min-height: var(--ui-target);
  font-size: var(--ui-compact);
  line-height: 1.4;
}

dialog .close.icon-btn {
  display: grid;
  place-items: center;
  width: var(--ui-target);
  height: var(--ui-target);
  min-width: var(--ui-target);
  min-height: var(--ui-target);
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
}

/* Browse controls stay visually small while their targets remain generous. */
.browse-arrow {
  width: var(--ui-target);
  height: var(--ui-target);
  min-width: var(--ui-target);
  min-height: var(--ui-target);
  flex-basis: var(--ui-target);
}

.browse-arrow::before {
  inset: calc((var(--ui-target) - var(--ui-browse-circle)) / 2);
}

.browse-arrow svg {
  width: 14px;
  height: 14px;
}

.browse-controls {
  gap: 0;
}

/* Random creates a new lamp, independently of the curated Studio Picks. */
.lamp-inspiration {
  margin-top: auto;
  min-width: 0;
}
.random-start {
  display: flex;
  align-items: center;
  gap: 10px;
}
.random-start p {
  margin: 0;
  color: var(--muted);
  font-size: var(--ui-compact);
  line-height: 1.4;
}
.lamp-inspiration > .studio-picks {
  margin-top: 12px;
  padding-top: 12px;
}
@media (max-width: 720px) {
  .lamp-inspiration {
    grid-row: 5;
    margin-top: 25px;
  }
}

/* A narrow Studio Picks heading gives its count a separate line. */
.studio-picks #pick-browser .browse-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 8px;
}

.studio-picks #pick-browser .browse-heading h3 {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  max-width: none;
  margin-bottom: 0;
}

.studio-picks #pick-browser .browse-meta {
  display: contents;
}

.studio-picks #pick-browser .browse-count {
  grid-column: 1;
  grid-row: 2;
}

.studio-picks #pick-browser .browse-controls {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
}

.random-start .studio-random {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--ui-target);
  padding: 7px 10px;
  border: 1px solid var(--red);
  border-radius: var(--ui-radius);
  background: transparent;
  color: var(--red);
  font-size: var(--ui-compact);
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  transition: background-color 180ms var(--ease-settle),
    transform 160ms var(--ease-press);
}
.random-start .studio-random .ui-icon {
  width: 14px;
  height: 14px;
}
.random-start .studio-random:active { transform: translateY(1px); }
@media (hover: hover) and (pointer: fine) {
  .random-start .studio-random:hover { background: var(--control-wash); }
}
@media (prefers-reduced-motion: reduce) {
  .random-start .studio-random { transition: none; }
  .random-start .studio-random:active { transform: none; }
}

/* Inline module actions keep compact mouse widths in the narrow parts list. */
.body-controls .mini-btn {
  width: 32px;
  height: var(--ui-target);
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.body-controls .mini-btn .ui-icon {
  width: 14px;
  height: 14px;
}

.body-select {
  min-height: var(--ui-target);
}

.body-edge-add,
.body-edge-delete {
  width: var(--ui-target);
  height: var(--ui-target);
  border: 0;
  background: transparent;
  font-size: 18px;
  isolation: isolate;
}

.body-edge-add::before,
.body-edge-delete::before {
  content: '';
  position: absolute;
  inset: calc((var(--ui-target) - var(--ui-circle)) / 2);
  z-index: 0;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: var(--cream);
  pointer-events: none;
  transition: border-color 180ms var(--ease-settle),
    background-color 180ms var(--ease-settle);
}

.body-edge-add > span {
  position: relative;
  z-index: 1;
}

.swatch,
.workflow-column .editor .swatch {
  width: var(--ui-circle);
  height: var(--ui-circle);
  max-width: var(--ui-circle);
}

.summary-swatches span,
.detail-swatch {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
}

@media (hover: hover) and (pointer: fine) {
  .preview-workspace .zoom-controls .icon-btn:hover,
  .final-stage .final-framing-tools .icon-btn:hover,
  .body-edge-add:not(.body-edge-delete):hover {
    background: transparent;
  }
  .preview-workspace .zoom-controls .icon-btn:hover::before,
  .final-stage .final-framing-tools .icon-btn:hover::before,
  .body-edge-add:hover::before {
    background: var(--control-wash);
  }
  .body-edge-add:hover::before {
    background: #f1ecdf;
  }
}

@media (max-width: 720px), (pointer: coarse) {
  .body-controls .mini-btn {
    width: var(--ui-target);
  }
}

@media (max-width: 720px) {
  /* A compact control row must not force the whole page wider than its frame. */
  .workspace { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px), (pointer: coarse) {
  /* Six columns where space allows; narrow palettes wrap without hit overlap. */
  .colour-grid,
  .workflow-column .editor .colour-grid {
    width: 100%;
    max-width: 284px;
    grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
    column-gap: 4px;
    row-gap: 12px;
  }
  .swatch::before,
  .workflow-column .editor .swatch::before {
    content: '';
    position: absolute;
    width: var(--ui-target);
    height: var(--ui-target);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .preview-workspace .zoom-controls .icon-btn::before,
  .final-stage .final-framing-tools .icon-btn::before,
  .body-edge-add::before,
  .body-edge-delete::before {
    transition: none;
  }
}
