:root { --panel-width: 90%; --panel-height: 80dvh; }
#product-dialog, #cart-dialog {
  inset: 0;
  margin: auto;
  width: min(var(--panel-width), var(--panel-cap));
  height: var(--panel-height);
  max-width: calc(100% - 2 * max(10px, env(safe-area-inset-left), env(safe-area-inset-right)));
  max-height: calc(100dvh - 2 * max(12px, env(safe-area-inset-top), env(safe-area-inset-bottom)));
  border: 0;
  border-radius: 14px;
  box-shadow: 0 12px 44px #0009;
}
#cart-dialog { --panel-cap: 490px; }
#product-dialog { --panel-cap: 1080px; }
#product-dialog::backdrop, #cart-dialog::backdrop { background: rgb(0 0 0 / 43%); }
#cart-dialog .bag-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
#cart-dialog .bag-body:has(#bag-empty:not([hidden])) { display: grid; align-content: center; text-align: center; }
@media (max-width: 650px) and (orientation: portrait) {
  #product-dialog .dialog-body { grid-template-rows: minmax(96px, 1fr) auto; gap: 10px; }
}
@media (min-width: 651px) and (min-height: 501px) {
  #product-dialog #buy { flex: 1; min-height: 0; max-height: 100%; }
  #product-dialog .gallery-stage { height: 100%; }
}
@media (max-height: 440px) {
  #cart-dialog .bag-body { flex: none; overflow: visible; }
}
