.mac-ads-popup-open{overflow:hidden!important}
.mac-ads-popup{
  position:fixed!important;
  inset:0!important;
  left:0!important;top:0!important;right:0!important;bottom:0!important;
  width:100vw!important;height:100vh!important;
  width:100dvw!important;height:100dvh!important;
  margin:0!important;padding:0!important;
  z-index:2147483000!important;
  display:none;
  box-sizing:border-box;
  /* 与原站一致：图片弹窗 / 宫格 同一最大宽 25rem，且不超过 575px */
  --mac-popup-max:min(90vw, 25rem, 575px);
}
.mac-ads-popup.is-open{
  display:flex!important;
  align-items:center;
  justify-content:center;
  padding:12px;
}
.mac-ads-popup__mask{
  position:absolute;left:0;top:0;right:0;bottom:0;
  background:rgba(0,0,0,.6)
}
/* 普通图片弹窗：随图片尺寸，不撑黑边 */
.mac-ads-popup__dialog{
  position:relative;
  z-index:1;
  width:auto;
  max-width:var(--mac-popup-max);
  max-height:80vh;
  margin:0;
  line-height:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  background:transparent;
}
.mac-ads-popup__close{
  position:relative;left:auto;top:auto;transform:none;
  z-index:2;width:42px;height:42px;margin:0 0 16px;
  border:2px solid #fff;border-radius:50%;
  background:rgba(0,0,0,.35);color:#fff;font-size:28px;line-height:36px;cursor:pointer;
  padding:0;box-sizing:border-box;
  -webkit-tap-highlight-color:transparent;
  flex-shrink:0;
}
.mac-ads-popup__picture{
  display:block;
  border-radius:12px;
  overflow:hidden;
  background:#1a1a1a;
  line-height:0;
  width:auto;
  max-width:var(--mac-popup-max);
  max-height:70vh;
  box-sizing:border-box;
  position:relative;
  /* 默认不再强撑到最大 4:5；有尺寸时由 JS 按原图像素定框 */
  aspect-ratio:auto;
}
.mac-ads-popup__picture.is-ready{
  aspect-ratio:auto;
  width:auto;
}
.mac-ads-popup__img{
  display:block;
  width:100%;
  height:100%;
  max-width:var(--mac-popup-max);
  max-height:70vh;
  object-fit:contain;
  object-position:center center;
  background:transparent;
  vertical-align:top;
  opacity:0;
  transition:opacity .2s ease;
}
.mac-ads-popup__picture.is-ready .mac-ads-popup__img{
  width:auto;
  height:auto;
  opacity:1;
}
.mac-ads-popup__picture.is-loading .mac-ads-popup__img{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  opacity:1;
}
.mac-ads-popup__picture.is-thumb .mac-ads-popup__img{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  opacity:1;
  object-fit:contain;
}
.mac-ads-popup__grid-list.is-loading{
  background:
    linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent) 0 0 / 40% 100% no-repeat,
    linear-gradient(-45deg, #000, #313131);
  animation:mac-popup-ph-shine 1.2s linear infinite;
}
@keyframes mac-popup-ph-shine{
  0%{background-position:-40% 0, 0 0}
  100%{background-position:140% 0, 0 0}
}
/* 九宫格：与图片弹窗同尺寸（宽对齐 + 高按 4:5 锁定，与现网弹窗图一致） */
.mac-ads-popup--grid.is-open{
  align-items:center;
  justify-content:center;
  padding:12px;
}
.mac-ads-popup__grid-wrap{
  position:relative;
  z-index:1;
  width:var(--mac-popup-max);
  max-width:var(--mac-popup-max);
  flex:0 0 auto;
  box-sizing:border-box;
  max-height:80vh;
  display:flex;
  flex-direction:column;
  align-items:center; /* 关闭按钮水平居中 */
  justify-content:center;
}
.mac-ads-popup__grid-wrap > .mac-ads-popup__close{
  align-self:center;
  margin-left:auto;
  margin-right:auto;
  display:block;
}
.mac-ads-popup__grid-list{
  --mac-grid-cols:5;
  --mac-grid-gap-x:8px;
  --mac-grid-gap-y:4px;
  position:relative;
  width:100%;
  max-width:100%;
  align-self:stretch;
  box-sizing:border-box;
  /* 与弹窗图 400x500 = 4:5 一致；高度由宽度锁定，JS 再按实测像素精调 */
  aspect-ratio:4 / 5;
  height:auto;
  max-height:70vh;
  min-height:0;
  display:grid;
  grid-template-columns:repeat(5, minmax(0, 1fr)) !important;
  grid-auto-rows:min-content;
  row-gap:var(--mac-grid-gap-y);
  column-gap:var(--mac-grid-gap-x);
  align-content:start;
  justify-items:center;
  background:linear-gradient(-45deg, #000, #313131);
  padding:8px;
  overflow-x:hidden;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  border-radius:12px;
  touch-action:pan-y;
}
.mac-ads-popup__grid-list a{
  text-decoration:none;
  box-sizing:border-box;
  color:#fff;
  text-align:center;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-start;
  min-width:0;
  width:100%;
  max-width:100%;
}
.mac-ads-popup__grid-list a img{
  width:min(2.6rem, 70%);
  height:auto;
  aspect-ratio:1 / 1;
  max-width:100%;
  flex-shrink:0;
  border-radius:8px;
  display:block;
  margin:0 auto;
  background-color:#353535;
  object-fit:cover;
}
.mac-ads-popup__grid-list a p{
  font-size:11px;
  white-space:nowrap;
  margin:0.15rem 0 0;
  overflow:hidden;
  text-overflow:ellipsis;
  line-height:1.15;
  display:block;
  width:100%;
  max-width:100%;
  box-sizing:border-box;
  color:#fff;
}
