.gallery-container {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 1rem;
}

/* 상단 헤더 */
.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 2px solid #222;
}

.gallery-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: #111;
}

.btn-download-all {
  flex: 0 0 auto;
  background: var(--primary);
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s ease;
}

.btn-download-all:hover { background: var(--primary5); }

/* 갤러리 그리드 */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

@media (max-width: 900px) {
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
}

@media (max-width: 540px) {
  .gallery-container { margin: 24px auto; padding: 0 14px; }
  .gallery-header { align-items: flex-start; flex-direction: column; }
  .photo-grid { grid-template-columns: 1fr; gap: 12px; }
}

/* 사진 카드 */
.photo-item {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  background: #e9ecef;
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.photo-item.is-hidden { display: none; }

.photo-open {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  display: block;
}

.photo-open:focus-visible {
  outline: 3px solid #4c9ffe;
  outline-offset: -3px;
}

.photo-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease, opacity 0.2s ease;
  background: #e9ecef;
}

.photo-item:hover .photo-thumb { transform: scale(1.045); }

/* 오버레이: 배경은 클릭을 가로채지 않고 아이콘만 클릭 가능 */
.photo-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.photo-item:hover .photo-overlay,
.photo-item:focus-within .photo-overlay { opacity: 1; }

.overlay-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #222;
  background: rgba(255,255,255,0.94);
  text-decoration: none;
  pointer-events: auto;
  transition: transform 0.18s ease, background 0.18s ease;
}

.overlay-btn:hover { background: #fff; transform: scale(1.08); }
.overlay-btn:focus-visible { outline: 3px solid #4c9ffe; outline-offset: 2px; }
.overlay-btn svg { width: 20px; height: 20px; fill: currentColor; }

@media (hover: none) {
  .photo-overlay {
	opacity: 1;
	align-items: flex-end;
	justify-content: flex-end;
	padding: 10px;
	background: linear-gradient(to top, rgba(0,0,0,.34), transparent 52%);
  }
  .overlay-btn { width: 40px; height: 40px; }
}

/* 더보기 */
.load-more-wrapper { text-align: center; margin-top: 36px; }

.btn-load-more {
  background: #fff;
  border: 1px solid #ced4da;
  padding: 12px 28px;
  border-radius: 25px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.btn-load-more:hover { background: #f1f3f5; border-color: #adb5bd; }
.btn-load-more:focus-visible { outline: 3px solid #4c9ffe; outline-offset: 3px; }

/* 원본보기 라이트박스 */
.lightbox[hidden] { display: none; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: rgba(0, 0, 0, 0.94);
  color: #fff;
  overscroll-behavior: contain;
}

.lightbox-toolbar {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
}

.lightbox-title {
  min-width: 0;
  margin-right: auto;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.lightbox-action {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255,255,255,0.12);
  cursor: pointer;
  text-decoration: none;
}

.lightbox-action:hover { background: rgba(255,255,255,0.22); }
.lightbox-action:focus-visible { outline: 3px solid #8ec5ff; outline-offset: 2px; }
.lightbox-action svg { width: 21px; height: 21px; fill: currentColor; }

/* 원본보기 확대/축소 컨트롤 */
.lightbox-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
}

.lightbox-zoom-controls .lightbox-action {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
}

.lightbox-zoom-level {
  min-width: 56px;
  height: 36px;
  padding: 0 8px;
  border: 0;
  border-radius: 18px;
  color: #fff;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.lightbox-zoom-level:hover { background: rgba(255,255,255,0.12); }
.lightbox-zoom-level:focus-visible { outline: 3px solid #8ec5ff; outline-offset: 2px; }

.lightbox-action:disabled {
  opacity: 0.38;
  cursor: default;
}

.lightbox-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 64px;
  overflow: hidden;
}

/* width/height를 고정하지 않아 원본의 세로/가로/와이드 비율을 자동 반영 */
.lightbox-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  box-shadow: 0 10px 36px rgba(0,0,0,0.35);
  transform-origin: center center;
  touch-action: none;
  cursor: zoom-in;
  will-change: transform;
  transition: opacity 0.18s ease, filter 0.18s ease, transform 0.14s ease;
}

.lightbox-image.is-zoomed { cursor: grab; }
.lightbox-image.is-panning {
  cursor: grabbing;
  transition: opacity 0.18s ease, filter 0.18s ease;
}

/* 원본이 도착하기 전 썸네일을 즉시 보여주는 상태 */
.lightbox-image.is-placeholder {
  filter: blur(7px);
  opacity: 0.78;
  transform: translateZ(0);
}

.lightbox-loading {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,.58);
  font-size: 12px;
  color: rgba(255,255,255,.9);
  pointer-events: none;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 58px;
  border: 0;
  border-radius: 8px;
  background: rgba(255,255,255,0.10);
  color: #fff;
  cursor: pointer;
  font-size: 32px;
  line-height: 1;
}

.lightbox-nav:hover { background: rgba(255,255,255,0.20); }
.lightbox-nav:focus-visible { outline: 3px solid #8ec5ff; outline-offset: 2px; }
.lightbox-prev { left: 10px; z-index: 10; }
.lightbox-next { right: 10px; z-index: 10; }

.lightbox-caption {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 16px max(10px, env(safe-area-inset-bottom));
  color: rgba(255,255,255,.86);
  font-size: 13px;
  text-align: center;
}

.lightbox-resolution { color: rgba(255,255,255,.62); }

@media (max-width: 700px) {
  .lightbox-toolbar { padding-left: 8px; padding-right: 8px; flex-wrap: wrap; }
  .lightbox-title { font-size: 12px; }
  .lightbox-zoom-controls .lightbox-action { width: 34px; height: 34px; flex-basis: 34px; }
  .lightbox-zoom-level { min-width: 48px; height: 34px; padding: 0 5px; font-size: 11px; }
  .lightbox-stage { padding: 8px 10px 64px; }
  .lightbox-nav {
	top: auto;
	bottom: 8px;
	transform: none;
	width: 50px;
	height: 46px;
  }
  .lightbox-prev { left: calc(50% - 58px); }
  .lightbox-next { right: calc(50% - 58px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}