.modal#productModal {
  --product-modal-gutter: clamp(8px, 1.8dvh, 16px);
  padding: var(--product-modal-gutter);
  overflow: hidden;
}

.product-detail {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(580px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - var(--product-modal-gutter) - var(--product-modal-gutter));
  overflow: hidden;
  background: #fff;
  border-radius: 26px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .28);
}

.product-detail-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 16px;
  padding: 25px 66px 20px 24px;
  color: #fff;
  background: linear-gradient(115deg, #117fe9, #19bdd6);
}

.product-detail-header > div { min-width: 0; }
.product-detail-header .close { color: #fff; background: rgba(255, 255, 255, .18); }
.detail-product-icon { width: 62px; height: 62px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 18px; color: #fff; font-size: 22px; font-weight: 900; background: var(--detail-color, #7c5cff); box-shadow: 0 12px 25px rgba(0, 35, 90, .18); }
.detail-product-icon img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; background: #fff; }
.detail-category { display: inline-block; margin-bottom: 4px; font-size: 10px; font-weight: 800; letter-spacing: 1px; opacity: .78; }
.product-detail-header h2 { margin: 0 0 5px; font-size: 21px; overflow-wrap: anywhere; }
.product-detail-header p { margin: 0; font-size: 12px; opacity: .82; }
.product-detail-body { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; overflow: hidden; padding: 18px 22px 22px; }
.detail-badges { display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: 8px; }
.detail-badges span { padding: 7px 10px; color: #238361; font-size: 11px; background: #ecfbf5; border-radius: 8px; }
.detail-description { display: flex; flex: 1 1 320px; flex-direction: column; min-height: 140px; margin-top: 15px; overflow: hidden; padding: 17px; background: #f7f9fc; border: 1px solid var(--line); border-radius: 14px; }
.detail-description h3 { margin: 0 0 11px; font-size: 14px; }
.detail-description > div { flex: 1 1 auto; min-height: 0; max-height: none; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; color: #44536b; font-size: 13px; line-height: 1.85; overflow-wrap: anywhere; }
.detail-description > div[aria-busy="true"] { color: var(--muted); background: linear-gradient(100deg, transparent 20%, rgba(22, 141, 242, .08) 45%, transparent 70%); background-size: 220% 100%; animation: detail-loading-shimmer 1.25s ease-in-out infinite; }
.plain-product-detail { white-space: pre-wrap; }
.rich-product-detail { white-space: normal; }
.rich-product-detail > :first-child { margin-top: 0; }
.rich-product-detail > :last-child { margin-bottom: 0; }
.rich-product-detail p, .rich-product-detail div { margin: .55em 0; }
.rich-product-detail h1, .rich-product-detail h2, .rich-product-detail h3,
.rich-product-detail h4, .rich-product-detail h5, .rich-product-detail h6 { margin: .8em 0 .4em; color: #27364d; line-height: 1.45; }
.rich-product-detail ul, .rich-product-detail ol { margin: .55em 0; padding-left: 1.6em; }
.rich-product-detail img { display: block; width: auto; max-width: 100%; height: auto; margin: 10px auto; border-radius: 8px; }
.rich-product-detail a { color: var(--blue); text-decoration: underline; overflow-wrap: anywhere; }
.rich-product-detail blockquote { margin: .7em 0; padding: .5em .8em; border-left: 3px solid #8abdf2; background: #edf6ff; }
.rich-product-detail table { width: 100%; border-collapse: collapse; }
.rich-product-detail th, .rich-product-detail td { padding: 6px 8px; border: 1px solid #dbe3ee; text-align: left; }
.rich-product-detail pre { max-width: 100%; overflow: auto; padding: 9px; background: #edf1f6; border-radius: 7px; white-space: pre-wrap; }
@keyframes detail-loading-shimmer { to { background-position: -220% 0; } }
@media (prefers-reduced-motion: reduce) { .detail-description > div[aria-busy="true"] { animation: none; } }
.detail-purchase { display: flex; flex: 0 0 auto; align-items: end; justify-content: space-between; gap: 20px; margin-top: 16px; padding: 14px 2px; border-bottom: 1px solid var(--line); }
.detail-purchase small { display: block; margin-bottom: 3px; color: var(--muted); font-size: 10px; }
.detail-purchase strong { color: var(--blue); font-size: 24px; }
.detail-purchase label { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; }
.quantity-control { display: grid; grid-template-columns: 35px 48px 35px; height: 36px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; }
.quantity-control button, .quantity-control input { min-width: 0; border: 0; color: var(--ink); text-align: center; background: #fff; }
.quantity-control button { color: var(--blue); font-size: 17px; cursor: pointer; }
.quantity-control input { width: 48px; outline: 0; border-right: 1px solid var(--line); border-left: 1px solid var(--line); -moz-appearance: textfield; }
.quantity-control input::-webkit-inner-spin-button { display: none; }
.buyer-fields { display: grid; flex: 0 0 auto; gap: 10px; padding: 15px 2px 3px; }
.buyer-fields label { display: grid; grid-template-columns: 88px 1fr; align-items: center; gap: 8px; }
.buyer-fields label > span { color: #68768b; font-size: 12px; }
.buyer-fields label > span b { color: #f04b3c; }
.buyer-fields input { width: 100%; height: 40px; padding: 0 12px; color: var(--ink); outline: 0; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; }
.buyer-fields input:focus { border-color: #70aef8; box-shadow: 0 0 0 3px rgba(22, 141, 242, .09); }
.buyer-fields p { min-height: 16px; margin: 0 0 0 96px; color: #e34c3e; font-size: 11px; }
.buyer-fields p:empty { display: none; }
.detail-total { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; padding: 15px 2px; }
.detail-total span { color: var(--muted); font-size: 13px; }
.detail-total b { color: var(--blue); font-size: 25px; }
.detail-buy-button { flex: 0 0 auto; width: 100%; padding: 14px; border: 0; border-radius: 12px; color: #fff; font-weight: 800; background: linear-gradient(90deg, var(--blue), var(--cyan)); cursor: pointer; box-shadow: 0 9px 22px rgba(22, 141, 242, .2); }
.detail-buy-button:disabled { cursor: not-allowed; opacity: .48; box-shadow: none; }
.product { cursor: pointer; }

@media (max-width: 600px) {
  .modal#productModal { --product-modal-gutter: 8px; }
  .product-detail { border-radius: 21px; }
  .product-detail-header { gap: 12px; padding: 16px 50px 14px 14px; }
  .product-detail-header h2 { font-size: 17px; line-height: 1.28; }
  .product-detail-header p { font-size: 11px; }
  .detail-product-icon { width: 48px; height: 48px; border-radius: 14px; }
  .product-detail-body { padding: 12px 14px 14px; }
  .detail-badges { gap: 6px; }
  .detail-badges span { padding: 5px 8px; font-size: 10px; }
  .detail-description { flex-basis: 160px; min-height: 82px; margin-top: 10px; padding: 11px; }
  .detail-description h3 { margin-bottom: 7px; font-size: 13px; }
  .detail-description > div { font-size: 12px; line-height: 1.65; }
  .detail-purchase { align-items: center; flex-direction: row; gap: 10px; margin-top: 10px; padding: 9px 2px; }
  .detail-purchase strong { font-size: 22px; }
  .detail-purchase label { gap: 6px; }
  .quantity-control { grid-template-columns: 32px 42px 32px; height: 34px; }
  .quantity-control input { width: 42px; }
  .buyer-fields { gap: 8px; padding: 10px 2px 2px; }
  .buyer-fields label { grid-template-columns: 72px minmax(0, 1fr); gap: 6px; }
  .buyer-fields input { height: 38px; }
  .buyer-fields p { margin-left: 78px; }
  .detail-total { padding: 10px 2px; }
  .detail-total b { font-size: 22px; }
  .detail-buy-button { padding: 12px; }
}
