.d2-entry-popup{
  position:fixed;
  inset:0;
  z-index:999999;
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
}
.d2-entry-popup.is-open{
  display:flex;
}
.d2-entry-popup__backdrop{
  position:absolute;
  inset:0;
  background:rgba(15,23,42,.76);
  backdrop-filter:blur(6px);
}
.d2-entry-popup__card{
  position:relative;
  z-index:1;
  width:min(780px, 94vw);
  max-height:90vh;
  overflow:hidden;
  background:#fff;
  border-radius:28px;
  box-shadow:0 34px 110px rgba(0,0,0,.42);
  color:#0f172a;
}
.d2-entry-popup__image{
  width:100%;
  max-height:360px;
  overflow:hidden;
  background:#e5e7eb;
}
.d2-entry-popup__image img{
  width:100%;
  height:100%;
  max-height:360px;
  object-fit:cover;
  display:block;
}
.d2-entry-popup__body{
  padding:28px;
  text-align:center;
}
.d2-entry-popup__title{
  margin:0 0 8px;
  font-size:clamp(28px, 5vw, 46px);
  line-height:1.12;
  font-weight:900;
}
.d2-entry-popup__subtitle{
  margin:0 0 16px;
  font-size:18px;
  color:#64748b;
}
.d2-entry-popup__text{
  white-space:pre-wrap;
  line-height:1.75;
  font-size:16px;
  margin:0 0 22px;
}
.d2-entry-popup__actions{
  display:flex;
  gap:10px;
  justify-content:center;
  flex-wrap:wrap;
}
.d2-entry-popup__btn{
  border:0;
  border-radius:999px;
  padding:12px 22px;
  background:#0f172a;
  color:#fff;
  cursor:pointer;
  font-weight:800;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
.d2-entry-popup__btn--ghost{
  background:#f1f5f9;
  color:#0f172a;
}
.d2-entry-popup__close{
  position:absolute;
  top:12px;
  right:12px;
  z-index:2;
  width:38px;
  height:38px;
  border:0;
  border-radius:999px;
  background:rgba(15,23,42,.88);
  color:#fff;
  font-size:24px;
  cursor:pointer;
}
@media(max-width:768px){
  .d2-entry-popup{
    padding:10px;
  }
  .d2-entry-popup__card{
    border-radius:20px;
  }
  .d2-entry-popup__body{
    padding:22px 18px;
  }
}

/* D2 ENTRY POPUP IMAGE-FIRST MODE */
.d2-entry-popup__card{
  width:min(860px, 94vw);
  background:transparent;
  box-shadow:none;
}
.d2-entry-popup__image{
  width:100%;
  max-height:none;
  background:transparent;
  border-radius:28px;
  overflow:hidden;
  box-shadow:0 34px 110px rgba(0,0,0,.42);
}
.d2-entry-popup__image img{
  width:100%;
  height:auto;
  max-height:86vh;
  object-fit:contain;
  display:block;
  background:#fff;
}
.d2-entry-popup__card:has(.d2-entry-popup__image) .d2-entry-popup__body{
  margin-top:12px;
  padding:0;
  text-align:center;
}
.d2-entry-popup__card:has(.d2-entry-popup__image) .d2-entry-popup__title,
.d2-entry-popup__card:has(.d2-entry-popup__image) .d2-entry-popup__subtitle,
.d2-entry-popup__card:has(.d2-entry-popup__image) .d2-entry-popup__text{
  display:none;
}
.d2-entry-popup__card:has(.d2-entry-popup__image) .d2-entry-popup__actions{
  margin-top:12px;
}
.d2-entry-popup__card:has(.d2-entry-popup__image) .d2-entry-popup__btn{
  box-shadow:0 14px 40px rgba(0,0,0,.22);
}
.d2-entry-popup__close{
  top:-12px;
  right:-12px;
}
@media(max-width:768px){
  .d2-entry-popup__card{
    width:96vw;
  }
  .d2-entry-popup__image{
    border-radius:20px;
  }
  .d2-entry-popup__image img{
    max-height:82vh;
  }
  .d2-entry-popup__close{
    top:8px;
    right:8px;
  }
}

/* D2: Entry popup แบบรูปภาพล้วน ไม่แสดงชื่อหัวข้อบน popup */
.d2-entry-popup__card:has(.d2-entry-popup__image) .d2-entry-popup__title,
.d2-entry-popup__card:has(.d2-entry-popup__image) .d2-entry-popup__subtitle,
.d2-entry-popup__card:has(.d2-entry-popup__image) .d2-entry-popup__text{
  display:none !important;
}
.d2-entry-popup__card:has(.d2-entry-popup__image) .d2-entry-popup__body{
  padding:0 !important;
  margin-top:12px !important;
}

/* D2 FINAL: popup รูปภาพล้วน ไม่ให้มีหัวข้อ/ข้อความ */
.d2-entry-popup__card.is-image-only .d2-entry-popup__title,
.d2-entry-popup__card.is-image-only .d2-entry-popup__subtitle,
.d2-entry-popup__card.is-image-only .d2-entry-popup__text{
  display:none !important;
}
.d2-entry-popup__card.is-image-only .d2-entry-popup__body{
  padding:0 !important;
  margin-top:12px !important;
  background:transparent !important;
}
.d2-entry-popup__card.is-image-only{
  background:transparent !important;
  box-shadow:none !important;
}

/* D2 FINAL: ปุ่มปิด popup ต้องลอยเหนือรูปและกดง่าย */
.d2-entry-popup__close{
  position:absolute !important;
  top:14px !important;
  right:14px !important;
  z-index:9999999 !important;
  width:44px !important;
  height:44px !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  border:2px solid rgba(255,255,255,.92) !important;
  border-radius:999px !important;
  background:rgba(15,23,42,.88) !important;
  color:#fff !important;
  font-size:28px !important;
  line-height:1 !important;
  cursor:pointer !important;
  box-shadow:0 10px 28px rgba(0,0,0,.38) !important;
  pointer-events:auto !important;
}

.d2-entry-popup__close:hover{
  background:rgba(220,38,38,.94) !important;
}

.d2-entry-popup__card{
  position:relative !important;
  overflow:visible !important;
}

.d2-entry-popup__image{
  position:relative !important;
  z-index:1 !important;
}

.d2-entry-popup__body{
  position:relative !important;
  z-index:2 !important;
}

@media(max-width:768px){
  .d2-entry-popup__close{
    top:10px !important;
    right:10px !important;
    width:42px !important;
    height:42px !important;
    font-size:26px !important;
  }
}
