.hardware :is(.product-dialog, #photo-viewer) {
  width: min(1260px, calc(100% - 40px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  border-radius: 18px;
}

.hardware :is(.product-dialog, #photo-viewer) .dialog-heading {
  padding: 14px clamp(16px, 2.5vw, 30px);
}

.product-dialog .dialog-heading h2 {
  font-size: clamp(21px, 3vw, 34px);
  line-height: 1.16;
  overflow-wrap: anywhere;
}

.product-dialog #dialog-body {
  padding: clamp(14px, 2.5vw, 30px);
}

.product-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: clamp(16px, 3vw, 32px);
}

.product-stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--hardware-image);
}

.product-photo {
  display: grid;
  place-items: center;
  width: 100%;
  height: clamp(340px, 56dvh, 630px);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.product-photo img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.photo-expand {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid #ffffff50;
  border-radius: 8px;
  color: white;
  background: #111927ed;
  font-size: 12px;
  font-weight: 650;
}

.photo-expand svg { width: 15px; height: 15px; }
.product-stage .icon-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  background: #111927ed;
  border-color: #ffffff50;
}
.product-stage .photo-prev { left: 10px; }
.product-stage .photo-next { right: 10px; }
.photo-prev svg { transform: rotate(180deg); }
.product-photo:focus-visible { outline-offset: -4px; }

.product-photo-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.thumbnails { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.thumbnail {
  display: block;
  min-width: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.thumbnail img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; border-radius: 5px; }
.hardware .thumbnail:hover { border-color: var(--hardware-accent); }
.hardware .thumbnail[aria-pressed="true"] {
  border-color: var(--hardware-accent);
  box-shadow: 0 0 0 1px var(--hardware-accent), var(--hardware-glow);
}

.product-detail-info { display: grid; align-content: start; gap: 20px; }
.product-purchase,
.product-specs {
  padding: clamp(14px, 2vw, 22px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--hardware-panel);
}
.product-purchase { display: grid; gap: 10px; }
.product-purchase strong { font-size: clamp(16px, 2vw, 21px); line-height: 1.3; }
.product-purchase .price-amount {
  color: var(--ink);
  font-size: clamp(21px, 2.2vw, 26px);
  font-weight: 730;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.product-purchase .btn { justify-content: center; min-height: 46px; }
.product-purchase small { color: var(--muted); font-size: 13px; }
.product-detail h3 { margin: 0 0 8px; font-size: clamp(18px, 2vw, 22px); }
.product-specs dl { margin: 0; }
.product-specs dl > div {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.product-specs dl > div:last-child { border-bottom: 0; padding-bottom: 0; }
.product-specs dt { color: var(--muted); }
.product-specs dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.product-description {
  grid-column: 1 / -1;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.product-description p { max-width: 74ch; margin: 9px 0 0; font-size: 15px; }

.hardware #photo-viewer {
  width: calc(100% - 28px);
  height: calc(100dvh - 28px);
  max-height: none;
  overflow: hidden;
}
#photo-viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
#photo-viewer .dialog-heading { position: static; }
#photo-viewer .dialog-heading h2 { font-size: clamp(15px, 2vw, 23px); overflow-wrap: anywhere; line-height: 1.2; }
.photo-viewer-actions { display: flex; align-items: center; gap: 8px; }
#photo-scale { padding: 9px 12px; font-size: 13px; }
#viewer-caption { color: var(--muted); margin: 4px 0 0; font-size: 13px; }
#photo-scroll { overflow: auto; background: var(--hardware-image); }
#viewer-image { display: block; width: 100%; height: 100%; object-fit: contain; }
#photo-scroll.photo-zoomed #viewer-image { width: max(165%, 1100px); height: auto; max-width: none; }
.photo-viewer-nav { display: flex; justify-content: center; align-items: center; gap: 16px; padding: 8px; }
#viewer-count { min-width: 5ch; text-align: center; font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
  .hardware :is(.product-dialog, #photo-viewer) {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
  .product-detail { grid-template-columns: minmax(0, 1fr); }
  .product-photo { height: clamp(220px, 86vw, 49dvh); }
  .product-detail-info { gap: 14px; }
  .thumbnails { gap: 5px; }
  #photo-viewer .dialog-heading { gap: 6px; padding-inline: 10px; }
}

.product-stage, #photo-scroll:not(.photo-zoomed) { touch-action: pan-y pinch-zoom; }

@media (max-width: 760px) {
  .product-dialog .icon-button, #photo-viewer .icon-button { width: 44px; height: 44px; }
  .product-dialog .thumbnail, #photo-scale { min-height: 44px; }
  .photo-viewer-nav { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}
