.container {
  padding-right: 10px !important; /* 원래 10px였던 것을 5px로 축소 */
  padding-left: 10px !important;
}

/* ==========================================================================
   1. 썸네일 그리드 (정사각형 레이아웃)
   ========================================================================== */
.hugo-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 5px;
  margin: 10px 0;
}

.gallery-item {
  overflow: hidden;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  aspect-ratio: var(--gallery-ratio, 1/1) !important; /* 1/1 고정 → 변수로 변경 */
}

.gallery-thumbnail {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
  position: static !important;
  left: auto !important;
  right: auto !important;
  margin: 0 !important;
  max-width: 100% !important;

  opacity: 0;
  transform: translateY(8px);
  filter: blur(3px);
  transition:
      opacity 0.8s ease,
      transform 0.8s ease,
      filter 0.8s ease;

}


.gallery-thumbnail.loaded {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
}


.gallery-item:hover .gallery-thumbnail {
  transform: scale(1.05); /* 마우스 올렸을 때 살짝 확대 효과 */
}

/* ==========================================================================
   2. 테마 기능 충돌 방지 (기존 테마의 밑줄/점선 등 전역 초기화)
   ========================================================================== */
.hugo-gallery-grid a,
.gallery-lightbox a,
.gallery-lightbox a:hover,
.gallery-lightbox a:focus,
.gallery-lightbox a:active {
  border: none !important;
  border-bottom: none !important;
  text-decoration: none !important;
  outline: none !important;
  box-shadow: none !important;
}

/* ==========================================================================
   3. 라이트박스 전체 배경 (뒤쪽 화면이 약간 보이도록 투명도 조절)
   ========================================================================== */
.gallery-lightbox {
  display: none !important; 
  visibility: hidden !important; 
  opacity: 0 !important; 
  pointer-events: none !important; 
  position: fixed;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100vh !important;
  background: rgba(15, 15, 15, 0.90) !important; 
  z-index: 999999 !important; 
  margin: 0 !important;
  padding: 0 !important;
}

/* 라이트박스가 활성화(:target) 되었을 때 */
.gallery-lightbox:target {
  display: grid !important;
  place-items: center !important; 
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* 배경 클릭 시 닫히는 오버레이 영역 */
.lightbox-close-overlay {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  z-index: 10;
  cursor: default;
}

/* ==========================================================================
   4. 이미지 및 캡션 콘텐츠 박스 (기존 테마 img 간섭 차단 및 캡션 고정 버전)
   ========================================================================== */
.lightbox-content {
  grid-area: 1 / 1; /* 부모 Grid의 정중앙에 고정 */
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  max-width: 85vw !important;
  z-index: 20;
}

.lightbox-content img {
  display: block !important;
  /* main.css의 left/right 50% 및 마진 간섭을 완전히 무력화 */
  position: relative !important;
  left: auto !important;
  right: auto !important;
  margin: 0 auto !important; 
  
  width: auto !important;
  max-width: 100% !important;
  max-height: 90vh !important; /* 화면 가득 채우되 캡션 공간 확보 */
  object-fit: contain !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.7);
}

/* 하단 고정형 검은 바탕 캡션 영역 (배경 일치 버전) */
.lightbox-caption {
  display: block !important;
  width: 100% !important;
  color: #ddd !important;
  padding: 12px 15px !important;
  font-size: 1.2rem !important;
  text-align: center !important;
  box-sizing: border-box !important;
  word-break: keep-all !important;
  
  /* 기본적으로 아래에 자리를 차지하게 만들어 고정 (글자 없어도 형태 유지) */
  margin-top: 0 !important;
  min-height: 45px !important; 
}

/* ==========================================================================
   5. 상단 우측 닫기 (X) 버튼
   ========================================================================== */
.lightbox-close-btn {
  position: absolute;
  top: 30px;
  right: 40px;
  color: rgba(255, 255, 255, 0.7) !important;
  font-size: 50px;
  font-weight: 200;
  line-height: 1;
  /* 💡 수정: 사진 레이어(20)보다 확실하게 위로 올림 */
  z-index: 99 !important; 
  cursor: pointer;
  transition: color 0.2s, transform 0.2s;
  /* 밝은 사진 위에서도 X가 선명하게 보이도록 글자 그림자 추가 */
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8) !important;
}

.lightbox-close-btn:hover {
  color: #fff !important;
  transform: scale(1.1);
}

/* ==========================================================================
   6. 좌우 내비게이션 화살표 버튼 (PC 기본 설정)
   ========================================================================== */
.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.4);
  background-color: rgba(255, 255, 255, 0.3) !important;
  font-size: 50px;
  font-weight: 200;
  padding: 30px 15px;
  z-index: 30;
  transition: color 0.2s, background-color 0.2s;
  user-select: none;
}

.lightbox-nav-btn:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

.prev-btn { left: 20px; }
.next-btn { right: 20px; }



/* ==========================================================================
   7. 모바일 전용 반응형 대응 레이아웃 보정 (768px 이하)
   ========================================================================== */
@media (max-width: 768px) {
  .hugo-gallery-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 6px;

  }

  /* 사진 영역 제한을 완전히 풀고 가로를 꽉 채우도록 변경 */
  .lightbox-content {
    max-width: 100vw !important; 
  }
  
  .lightbox-content img {
    max-width: 100vw !important;
    max-height: 90vh !important; /* 캡션과 화살표 가시성을 위해 높이만 살짝 여유 조절 */
  }

  /* 💡 [수정] 모바일 닫기 버튼: 최상위 레이어로 올리고 검은 반투명 배경 추가 */
  .lightbox-close-btn {
    top: 15px !important;
    right: 15px !important;
    font-size: 32px !important;
    line-height: 36px !important;
    width: 40px !important;
    height: 40px !important;
    text-align: center !important;
    z-index: 50 !important; /* 화살표보다도 위에 배치 */
    color: #ffffff !important; /* 글자는 하얗게 */
    background-color: rgba(0, 0, 0, 0.6) !important; /* 둥근 검은 투명 배경 박스 */
    border-radius: 50% !important;
  }

  /* 모바일 화살표를 이미지 위로 올리고 흰색 투명 바탕 부여 */
  .lightbox-nav-btn {
    font-size: 30px;
    padding: 30px 8px;
    z-index: 40 !important; /* 이미지(z-index: 20) 위 레이어로 강제 격상 */
    color: rgba(0, 0, 0, 0.7) !important; /* 화살표 자체 색상은 어둡게 해서 잘 보이게 변경 */
    background-color: rgba(255, 255, 255, 0.40) !important; /* 약간 하얀 투명 바탕 박스 */
    border-radius: 4px;
  }

  .lightbox-nav-btn:hover {
    background-color: rgba(255, 255, 255, 0.6) !important;
  }
  
  /* 사진 테두리 안쪽으로 살짝 들어오게 정렬 */
  .prev-btn { left: 0px; }
  .next-btn { right: 0px; }
  
  .lightbox-caption {
    font-size: 1rem !important;
    padding: 8px 10px !important;
  }
}