.product-dialog {
  --product-paper: #fff4de;
  --product-ink: #28163d;
  --product-muted: #604c70;
  --product-rule: #28163d30;
  --product-lavender: #eaddfa;
  --product-selection: #c5a8f1;
  --product-inset: clamp(14px, 4vw, 26px);
  width: min(640px, 100% - 28px);
  max-height: min(880px, 100dvh - 28px);
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--product-ink);
  border-radius: 18px;
  background: var(--product-paper);
  color: var(--product-ink);
  box-shadow: 0 6px 0 var(--product-ink);
}

.product-dialog[open],
#productForm {
  display: flex;
  flex-direction: column;
}

html:has(.product-dialog[open]) {
  overflow: hidden;
}

.product-dialog::backdrop {
  background: #28163d91;
  backdrop-filter: blur(4px);
}

.product-header,
.product-actions {
  flex: none;
  display: grid;
  align-items: center;
}

.product-header {
  grid-template-columns: 52px minmax(0, 1fr) 44px;
  gap: 12px;
  padding: 16px var(--product-inset);
}

.product-platform-sticker .picker-sticker-art {
  min-height: 50px;
  margin: 0;
  border: 1.5px solid var(--product-ink);
  background-color: var(--sticker-paper);
  box-shadow: 1px 2px 0 var(--product-ink);
  transform: rotate(-5deg);
}

.product-platform-sticker .picker-sticker-plate {
  max-width: 29px;
}

.product-platform-sticker .picker-sticker-spark {
  inset: 3px 3px auto auto;
  width: 9px;
  height: 9px;
}

.product-header h2 {
  margin: 0;
  font: italic 700 clamp(21px, 4.8vw, 34px) / 1.05 "Space Grotesk", sans-serif;
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
}

.product-close {
  justify-self: end;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--product-ink);
  border-radius: 10px;
  background: #fffdf6;
  box-shadow: 0 2px 0 var(--product-ink);
  font: 700 24px / 1 sans-serif;
}

.product-dialog button:focus-visible,
.product-dialog input:focus-visible {
  outline: 2px solid #6944a2;
  outline-offset: 2px;
}

#productForm,
.product-body {
  min-height: 0;
}

.product-body {
  overflow: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 12px;
  padding: 0 var(--product-inset) 16px;
}

.delivery-counter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  margin-bottom: 15px;
  padding: 10px 12px;
  border: 1px solid var(--product-rule);
  border-radius: 12px;
  background: var(--product-lavender);
}

.delivery-counter > p {
  margin: 0;
  color: var(--product-ink);
  font-size: clamp(15px, 2.4vw, 17px);
  font-weight: 700;
}

.counter-digit {
  display: grid;
  width: clamp(23px, 5.4vw, 28px);
  height: clamp(31px, 6.5vw, 36px);
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--product-ink);
  border-radius: 5px;
  background: #fffdf6;
  box-shadow: 0 1px 0 var(--product-ink);
  font: 700 clamp(19px, 3.6vw, 22px) / 1 "Space Grotesk", sans-serif;
}

#packageTitle {
  margin: 2px 0 9px;
  font: italic 700 16px / 1.2 "Space Grotesk", sans-serif;
}

.package-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.package-card {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-height: 62px;
  padding: 6px;
  border: 2px solid var(--product-ink);
  border-radius: 12px;
  background: #f6edff;
  box-shadow: 0 3px 0 var(--product-ink);
  transition: background-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.package-card strong {
  font: italic 700 22px / 1.1 "Space Grotesk", sans-serif;
}

.package-card > span {
  font-size: 13px;
  font-weight: 700;
}

.package-card.fixed-package {
  grid-column: 1 / -1;
  padding: 12px;
  text-align: center;
  background: var(--product-lavender);
}

.package-quote {
  color: var(--product-muted);
  font-size: 11px;
}

.package-card[aria-pressed="true"] {
  background: var(--product-selection);
}

.package-card[aria-pressed="true"]::after {
  position: absolute;
  top: 5px;
  right: 6px;
  content: "✓";
  font-size: 11px;
  font-weight: 700;
}

@media (hover: hover) {
  .package-card[aria-pressed="false"]:hover {
    background: var(--product-lavender);
  }
}

.package-card:active,
.product-actions .primary:not(:disabled):active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--product-ink);
}

.product-body label {
  margin: 14px 0 6px;
  color: var(--product-ink);
  font-size: 13px;
  font-weight: 700;
}

.quantity-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px;
  border: 1.5px solid var(--product-ink);
  border-radius: 10px;
  background: #fffdf6;
}

.quantity-stepper button {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--product-ink);
  border-radius: 7px;
  background: var(--product-lavender);
  font: 700 22px / 1 "Space Grotesk", sans-serif;
}

.quantity-stepper button:disabled {
  opacity: .4;
  cursor: default;
}

.quantity-stepper input,
.product-dialog #target {
  margin: 0;
  color: var(--product-ink);
}

.quantity-stepper input {
  flex: 1;
  min-width: 0;
  padding: 7px 2px;
  border: 0;
  background: transparent;
  appearance: textfield;
  text-align: center;
  font: 700 18px / 1 "Space Grotesk", sans-serif;
}

.quantity-stepper input::-webkit-inner-spin-button,
.quantity-stepper input::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

.quantity-hint {
  display: block;
  margin-top: 5px;
  color: var(--product-muted);
  font-size: 11px;
}

.quantity-hint[hidden] {
  display: none;
}

.product-dialog #target {
  padding: 10px 12px;
  border: 1.5px solid var(--product-ink);
  border-radius: 10px;
  background: #fffdf6;
  font-size: 16px;
}

.product-dialog #target::placeholder {
  color: var(--product-muted);
  opacity: 1;
}

.product-actions {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 11px var(--product-inset) 14px;
  border-top: 1px solid var(--product-ink);
  background: var(--product-paper);
}

.product-price {
  display: grid;
  gap: 2px;
}

.product-price > span {
  color: var(--product-muted);
  font-size: 11px;
}

.product-price b {
  font: 700 clamp(20px, 5vw, 27px) / 1 "Space Grotesk", sans-serif;
}

.product-price .order-minimum {
  margin: 0;
  color: var(--product-muted);
  font-size: 11px;
}

.product-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.product-actions .primary {
  justify-content: center;
  min-height: 46px;
  padding: 8px clamp(12px, 3vw, 24px);
  border: 2px solid var(--product-ink);
  border-radius: 10px;
  background: var(--product-selection);
  color: var(--product-ink);
  box-shadow: 0 3px 0 var(--product-ink);
  font: italic 700 16px / 1.2 "Space Grotesk", sans-serif;
  white-space: nowrap;
}

.product-actions #addToBag {
  background: #fffdf6;
}

.product-actions .primary:hover {
  transform: none;
}

@media (max-width: 550px) {
  .product-header {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 8px;
  }

  .product-platform-sticker .picker-sticker-art {
    min-height: 44px;
  }

  .delivery-counter {
    justify-content: center;
    text-align: center;
  }

  .delivery-counter > p {
    flex-basis: 100%;
  }

  .package-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-actions {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .product-price {
    grid-template-columns: auto 1fr;
    align-items: baseline;
    column-gap: 8px;
  }

  .product-price .order-minimum {
    grid-column: 1 / -1;
  }
}
