.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  padding: 18px;
  background: rgba(0, 0, 0, 0.64);
  overflow-y: auto;
}

.modal-backdrop.open {
  display: grid;
  place-items: start center;
}

.modal-backdrop.open .modal-panel {
  animation: modalIn 0.26s var(--ease) both;
}

.modal-panel {
  position: relative;
  width: min(100%, 1040px);
  margin: 24px 0;
  border-radius: var(--radius-md);
  background: var(--color-white);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.28);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.product-modal {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  margin: 0;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
}

.modal-gallery {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 14px;
  background:
    linear-gradient(180deg, #fbfaf7, #f4efe4);
}

.modal-main-image {
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--color-white);
  border: 1px solid rgba(201, 169, 97, 0.16);
}

.modal-main-image img {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.modal-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.modal-thumb {
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: var(--color-white);
  overflow: hidden;
}

.modal-thumb.active {
  border-color: var(--color-gold);
}

.modal-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-info {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 18px;
}

.modal-title {
  margin: 0;
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 6vw, 2.25rem);
  line-height: 1.08;
}

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

.modal-copy {
  margin: 0;
  color: var(--color-muted);
  max-width: 58ch;
  font-size: 1rem;
}

.modal-meta-grid {
  display: grid;
  gap: 10px;
}

.modal-meta {
  padding: 12px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-ivory);
}

.modal-meta strong {
  display: block;
  margin-bottom: 4px;
  color: var(--color-ink);
}

.modal-quantity {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  overflow: hidden;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-round);
  background: var(--color-white);
  box-shadow: 0 10px 28px rgba(25, 20, 13, 0.06);
}

.modal-quantity button,
.modal-quantity input {
  min-height: 48px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-ink);
  text-align: center;
  font: inherit;
  font-weight: 900;
}

.modal-quantity button {
  cursor: pointer;
}

.modal-quantity button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.modal-quantity input {
  border-right: 1px solid var(--color-line);
  border-left: 1px solid var(--color-line);
  padding: 0;
  appearance: textfield;
}

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

.modal-actions {
  display: grid;
  gap: 9px;
}

@media (min-width: 860px) {
  .modal-backdrop.open {
    place-items: center;
  }

  .product-modal {
    width: min(1120px, calc(100vw - 44px));
    max-height: min(760px, calc(100dvh - 44px));
    grid-template-columns: minmax(360px, 0.92fr) minmax(420px, 1.08fr);
    overflow: hidden;
  }

  .modal-gallery {
    min-height: 100%;
    padding: 22px;
    border-right: 1px solid var(--color-line);
    overflow-y: auto;
  }

  .modal-main-image img {
    height: min(56vh, 520px);
    aspect-ratio: auto;
    object-fit: contain;
  }

  .modal-info {
    max-height: min(760px, calc(100dvh - 44px));
    padding: 34px;
    overflow-y: auto;
  }

  .modal-meta-grid {
    grid-template-columns: 1fr 1fr;
  }

  .modal-actions {
    grid-template-columns: 1fr 1fr;
  }
}
