.popups-root {
  position: relative;
  --header-h: 80px;
}
/* 팝업이 떠 있는 동안 배경 페이지 스크롤 잠금(이중 스크롤 방지) */
html.popup-open,
html.popup-open body {
  overflow: hidden;
}
.popup-item {
  position: fixed;
  z-index: 3000;
}
.pos-center {
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.5);
}

/* 좌표 배치용 */
.popup-item.xy {
}

/* 나열(가로/세로): 딤 없이 헤더 아래 여백을 두고 배치 (데스크톱) */
@media (max-width: 1520px) {
  .popups-root {
    --header-h: 65px;
  }
}
@media (max-width: 1290px) {
  .popups-root {
    --header-h: 60px;
  }
}
/* 나열: 페이지와 함께 스크롤(absolute). 슬라이드 모달은 .popup-item 의 fixed 유지 */
@media (min-width: 1025px) {
  .popups-root {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1100;
    pointer-events: none;
  }
  .popups-root.is-flow {
    top: calc(var(--header-h, 80px) + var(--pop-y, 20px));
    left: var(--pop-x, 20px);
    right: auto;
    bottom: auto;
    background: none;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }
  .popups-root.is-flow .popup-item {
    position: relative;
    inset: auto;
    z-index: auto;
    pointer-events: auto;
  }
  .popups-root.is-flow .popups-flow-body {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    align-items: flex-start;
    gap: var(--pop-gap, 30px);
    padding: 0;
    overflow: visible;
    pointer-events: none;
  }
  .popups-root.is-flow.dir-v .popups-flow-body {
    flex-direction: column;
  }
  /* 대각선: 문서 상단 기준, 헤더 아래 Y */
  .popups-root:not(.is-flow) .popup-item.xy {
    position: absolute;
    top: calc(var(--header-h, 80px) + var(--pop-y, 20px) + (var(--pop-i, 0) * var(--pop-gap, 30px)));
    z-index: 1100;
    pointer-events: auto;
  }
}

/* 팝업 박스 */
.popup-box {
  position: relative;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  padding: 0;
  max-width: 500px;
  width: 100%;
  overflow: hidden;
}
.popup-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* 나열 모드: 박스 너비를 이미지 크기에 맞춤 */
.popup-item.xy .popup-box {
  width: fit-content;
  max-width: 500px;
}
.popup-item.xy .popup-box img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
}

/* 상단 컨트롤 영역 — 팝업 상자 위: 왼쪽(오늘 하루 보지 않기) / 오른쪽(×) */
.popup-controls {
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  padding: 0 8px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: center;
  z-index: 2;
}
.popup-controls button {
  border: 0;
  cursor: pointer;
  border-radius: 9999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.42);
}
.popup-controls .popup-close {
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  background: rgba(0, 0, 0, 0.42);
}
.popup-controls .popup-close:hover {
  background: rgba(0, 0, 0, 0.58);
}
.popup-controls .popup-hide-today:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* 슬라이더 */
.popup-slider {
  position: relative;
  overflow: hidden;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  isolation: isolate;
  transform: translateZ(0);
}
.popup-slider {
  cursor: grab;
  touch-action: pan-y;
}
.popup-slider.grabbing {
  cursor: grabbing;
}
.popup-slider .slides {
  display: flex;
  will-change: transform;
}
.popup-slider .slide {
  flex: 0 0 auto;
  box-sizing: border-box;
  overflow: hidden;
}
.popup-slider .slide img {
  display: block;
  width: 100%;
  height: auto;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: auto;
}
.slide-prev,
.slide-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  z-index: 2;
}
.slide-prev {
  left: 8px;
}
.slide-next {
  right: 8px;
}

.dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 10px;
}
.dots button {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 0;
  background: #d1d5db;
  cursor: pointer;
}
.dots button.active {
  background: #0b6fb5;
}

/* 랩탑 이하(1024px): 나열 모드 중앙 정렬, 모달(딤드) 없음 */
@media (max-width: 1024px) {
  .popups-root {
    position: fixed;
    inset: 0;
    z-index: 3000;
    pointer-events: none;
  }

  .popups-root .popup-item.xy {
    pointer-events: auto;
  }

  .popup-item.xy {
    inset: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    display: grid !important;
    place-items: center !important;
    transform: none !important;
    max-width: none;
    background: transparent;
  }

  .popup-item.xy .popup-box {
    width: fit-content;
    max-width: min(500px, calc(100vw - 32px));
    max-height: 85vh;
    margin: 16px;
  }

  .popup-item.xy .popup-box img {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 75vh;
    object-fit: contain;
  }

  /* 모바일: 나열 팝업은 한 장씩 중앙 표시 */
  .popup-item.xy ~ .popup-item.xy {
    display: none;
  }
}

/* 가로(랜드스케이프) 화면: 흰색 배경/박스 안 보이게 */
@media (max-width: 1024px) and (orientation: landscape) {
  .popup-item.xy .popup-box {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
  }
}

@media (max-width: 640px) {
  .popup-box {
    max-width: calc(100vw - 32px);
  }

  .popup-item.xy .popup-box {
    max-width: calc(100vw - 32px);
    max-height: 88vh;
  }

  .popup-item.xy .popup-box img {
    max-height: 78vh;
  }
}

@media (max-width: 640px) and (orientation: landscape) {
  .popup-item.xy .popup-box {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
  }
}
