.product-config-heading {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin: 0;
  font-size: var(--text-h3);
  line-height: var(--leading-h3);
}

.product-config-heading .product-badge {
  font-family: var(--font-body);
  font-size: var(--text-caption);
  line-height: var(--leading-caption);
}

.size-picker-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.size-picker-options > .choice-chip:has(input:disabled) { display: none; }

.engraving-field, .engraving-suggestions-group {
  display: grid;
}

.engraving-field {
  gap: 0.375rem;
}

.engraving-field label {
  font-size: var(--text-caption);
}

.engraving-field .form-control {
  padding: 0.75rem 0.875rem;
  border-radius: 0.375rem;
}

.engraving-suggestions-group {
  gap: 0.5rem;
}

.engraving-suggestions {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.product-config-card, .size-picker, .size-quantity-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
}

.product-config-card, .size-picker {
  display: grid;
  gap: 1rem;
  min-width: 0;
  padding: 1rem;
}

.size-quantity-card {
  display: contents;
}

.size-picker {
  grid-area: size;
  gap: 0.75rem;
}

@media (min-width: 64rem) {
  .product-config-card, .size-quantity-card {
    padding: 1.25rem;
  }

  .size-quantity-card {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
  }

  .size-picker {
    flex: 1;
    padding: 0;
    border: 0;
  }
}

.editing-card {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.editing-card .product-config-heading {
  font-family: var(--font-body);
  font-size: var(--text-small);
  line-height: var(--leading-small);
  gap: 0.5rem;
}

.editing-card p {
  margin: 0;
}

.photo-position {
  display: grid;
  gap: 0.5rem;
}

.position-row, .position-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.position-row {
  justify-content: space-between;
}

.position-controls {
  margin-left: auto;
}

.position-controls .secondary-link {
  width: 40px;
  height: 40px;
  min-height: 0;
  padding: 0;
  border-color: var(--color-border);
  border-radius: 0.375rem;
}

.customize-entry {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.customize-entry > img:first-child {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 0.375rem;
  background: var(--surface-tint);
}

.customize-entry-copy { display: grid; gap: 0.25rem; }
.customize-entry-copy strong { font-weight: 500; }
.customize-entry-copy .text-caption { font-weight: 400; }
.customize-entry-arrow { width: 24px; height: 24px; }
.customize-entry:disabled { background: var(--surface-muted); cursor: default; }

.background-removal {
  border-top: 1px solid var(--color-border);
  padding-top: 1rem;
}

.background-removal label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  cursor: pointer;
}

.background-removal input {
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  accent-color: var(--link-color);
}

.engraving {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
  border-top: 1px solid var(--color-border);
  padding-top: 1rem;
}

.engraving-suggestions .choice-chip {
  flex-shrink: 0;
}

@media (min-width: 64rem) {
  .customize-entry { display: none; }
}

@media (max-width: 63.999rem) {
  .size-picker-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .size-picker-options > .choice-chip > span {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    height: 100%;
    padding: 0.75rem;
    border-radius: var(--radius-control);
  }
  .size-name { font-size: var(--text-small); font-weight: 500; overflow-wrap: anywhere; }

  .position-hint, .editing-card .position-row, .editing-card:has(.customize-entry) > .engraving { display: none; }
}

.photo-editor {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  border: 0;
  background: var(--surface);
  color: var(--text-color);
}

.photo-editor[open] {
  display: grid;
  grid-template-rows: auto minmax(8rem, 1fr) auto;
  gap: 0.75rem;
}

.photo-editor[data-layer="engraving"][open] { grid-template-rows: auto minmax(8rem, 1fr) auto auto; }

.photo-editor-heading { display: flex; align-items: center; gap: 0.5rem; }
.photo-editor-header-copy { flex: 1; min-width: 0; }
.photo-editor p { margin: 0; }

.editor-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  padding: 10px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--surface);
  cursor: pointer;
}
.editor-icon:not([hidden]) { display: grid; place-items: center; }
.editor-icon:disabled { opacity: 0.45; cursor: default; }

.photo-editor-workspace {
  display: grid;
  place-items: center;
  min-height: 0;
  min-width: 0;
  container-type: size;
}

.photo-editor-figure {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  width: min(100cqw, calc(100cqh - 6rem));
}
.photo-editor[data-layer="engraving"] .photo-editor-figure {
  width: 100%;
  height: 100%;
  grid-template-rows: minmax(0, 1fr) auto;
}
.photo-editor[data-layer="engraving"] .photo-editor-stage {
  width: min(100cqw, calc(100cqh - 3.5rem));
  align-self: center;
  justify-self: center;
}
.photo-editor[data-layer="engraving"] .photo-editor-caption { min-height: 44px; }
.photo-editor-stage { position: relative; aspect-ratio: 1; }
.photo-editor-stage .product-gallery-stage { width: 100%; touch-action: none; user-select: none; }
.photo-editor-caption { display: flex; align-items: center; gap: 0.5rem; }
.photo-editor-caption p { flex: 1; }
.photo-editor-zoom:not([hidden]) { display: grid; grid-template-columns: auto minmax(0, 1fr) auto 44px; align-items: center; gap: 0.5rem; }
.photo-editor-zoom output { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }
.photo-editor input[type="range"] { width: 100%; height: 44px; margin: 0; accent-color: var(--link-color); }
.photo-editor-footer .primary-link { width: 100%; }
.photo-editor .product-preview-guides:not([hidden]) { display: block; }
html:has(.photo-editor[open]) { overflow: hidden; }

.photo-editor-text { max-height: min(22rem, 45dvh); overflow: auto; min-width: 0; padding: 0.25rem; }
.photo-editor .engraving { padding: 0; border: 0; }
.photo-editor .engraving .product-config-heading { display: none; }
/* Keep every suggested phrase readable instead of hiding choices offscreen. */
.photo-editor .engraving-suggestions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: visible;
  padding-bottom: 0;
}
.photo-editor .engraving-suggestions .choice-chip { min-width: 0; }
.photo-editor .engraving-suggestions .choice-chip span {
  display: grid;
  align-items: center;
  box-sizing: border-box;
  height: 100%;
  min-height: 44px;
  border-radius: var(--radius-control);
  padding: 0.5rem 0.75rem;
  text-align: left;
  white-space: normal;
}
.photo-editor .engraving-field { grid-template-columns: 1fr auto; }
.photo-editor .engraving-field .form-control { grid-column: 1 / -1; }
.photo-editor .engraving-field [data-engraving-target="count"] { grid-column: 2; grid-row: 1; align-self: center; font-size: 0.75rem; }

.photo-editor-hand {
  display: none;
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 2;
  padding: 10px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 2px 10px #102b4233;
  pointer-events: none;
  will-change: left, top, opacity;
}
.photo-editor .photo-editor-hand:not([hidden]) { display: grid; }
@media (min-width: 64rem) {
  .photo-editor-hand:not([hidden]) { display: grid; }
}
.photo-editor-hand[data-gripping="true"] img { transform: scale(0.88); }
@media (prefers-reduced-motion: reduce) { .photo-editor-hand { display: none !important; } }

@media (orientation: landscape) and (max-height: 32rem) {
  .photo-editor[open] {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .photo-editor-heading { grid-column: 1 / -1; }
  .photo-editor-workspace { grid-column: 1; grid-row: 2; }
  .photo-editor[data-layer="photo"] .photo-editor-workspace { grid-column: 1 / -1; }
  .photo-editor-text { grid-column: 2; grid-row: 2; max-height: 100%; }
  .photo-editor-footer { grid-column: 1 / -1; }
  .photo-editor[data-layer="engraving"][open] { grid-template-rows: auto minmax(0, 1fr) auto; }
  .photo-editor[data-layer="photo"] .photo-editor-figure {
    width: 100%;
    height: 100%;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: 1fr 1fr;
    column-gap: 1rem;
  }
  .photo-editor[data-layer="photo"] .photo-editor-stage {
    grid-column: 1;
    grid-row: 1 / 3;
    width: min(calc(50cqw - 0.5rem), 100cqh);
    align-self: center;
    justify-self: center;
  }
  .photo-editor[data-layer="photo"] .photo-editor-caption { grid-column: 2; align-self: end; }
  .photo-editor-zoom { grid-column: 2; align-self: start; }
}
.product-purchase-block { grid-area: purchase; min-width: 0; }
.product-combo-offers { margin-top: .5rem; font-size: .875rem; line-height: 1.5; color: var(--color-slate); }
.product-combo-offers table { width: 100%; border-collapse: collapse; font: inherit; }
.product-combo-offers caption { padding-bottom: 4px; text-align: left; font-weight: 600; }
.product-combo-offers th, .product-combo-offers td { padding: 4px 0; border-bottom: 1px solid var(--color-border); }
.product-combo-offers th { text-align: left; font-weight: 400; }
.product-combo-offers td { padding-left: 12px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.product-combo-offers .product-combo-note { margin: 8px 0 0; }
.keychain-offer { position: fixed; right: 24px; bottom: 24px; z-index: 25; box-sizing: border-box; width: min(400px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto; border: 1px solid var(--color-border); border-radius: var(--radius-control); padding: 24px; background: var(--surface); color: var(--text-color); box-shadow: 0 8px 32px #0002; }
.keychain-offer h2 { font-size: 1.25rem; line-height: 1.5; margin: 0 28px 0 0; }
.keychain-offer p { font-size: .875rem; line-height: 1.5; }
.keychain-offer-actions { display: flex; gap: 12px; margin-top: 20px; }
.keychain-offer-option { display: flex; align-items: center; gap: 12px; margin: 20px 0; }
.keychain-offer-option img { flex: 0 0 64px; object-fit: contain; border-radius: var(--radius-control); }
.keychain-offer-option p { margin: 0 0 8px; }
.keychain-offer-dismiss { position: absolute; right: 8px; top: 8px; width: 44px; height: 44px; border: 0; border-radius: var(--radius-control); background: transparent; color: inherit; font-size: 28px; cursor: pointer; }
@media (max-width: 600px) { .keychain-offer { right: 16px; bottom: 16px; padding: 20px; } }
