* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #ffffff;
}

body {
  min-height: 100%;
  margin: 0;
  color: #222222;
  background: #ffffff;
  font-family: Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.6;
}

button {
  font: inherit;
}

.gallery-page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.gallery-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid #e5e5e5;
  padding-bottom: 18px;
}

.gallery-title {
  margin: 0;
  color: #111111;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.35;
}

.gallery-count {
  flex: 0 0 auto;
  color: #666666;
  font-size: 13px;
}

.gallery-status {
  padding: 32px 0;
  color: #666666;
  text-align: center;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.gallery-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #e3e3e3;
  border-radius: 6px;
  background: #f7f7f7;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.gallery-item:hover,
.gallery-item:focus-visible {
  border-color: #a9a9a9;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
  outline: none;
}

.gallery-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #eeeeee;
}

.gallery-caption {
  min-height: 36px;
  padding: 8px 10px;
  color: #444444;
  font-size: 12px;
  text-align: left;
}

.gallery-caption:empty {
  display: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 56px 20px 28px;
  background: rgba(255, 255, 255, 0.96);
}

.lightbox.is-open {
  display: flex;
}

.lightbox-figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: min(100%, 1080px);
  max-height: 100%;
  margin: 0;
  gap: 12px;
}

.lightbox-image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 136px);
  margin: 0 auto;
  object-fit: contain;
  background: #f5f5f5;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
}

.lightbox-caption {
  min-height: 1.6em;
  color: #333333;
  font-size: 14px;
  text-align: center;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: fixed;
  display: grid;
  place-items: center;
  border: 1px solid #d6d6d6;
  border-radius: 999px;
  color: #111111;
  background: #ffffff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.lightbox-close {
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  font-size: 24px;
  line-height: 1;
}

.lightbox-prev,
.lightbox-next {
  top: 50%;
  width: 44px;
  height: 44px;
  font-size: 26px;
  transform: translateY(-50%);
}

.lightbox-prev {
  left: 16px;
}

.lightbox-next {
  right: 16px;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover,
.lightbox-close:focus-visible,
.lightbox-prev:focus-visible,
.lightbox-next:focus-visible {
  border-color: #999999;
  outline: none;
}

@media (max-width: 640px) {
  .gallery-page {
    width: min(100% - 20px, 1120px);
    padding: 20px 0 32px;
  }

  .gallery-header {
    display: block;
    margin-bottom: 16px;
  }

  .gallery-title {
    font-size: 20px;
  }

  .gallery-count {
    margin-top: 6px;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .gallery-caption {
    min-height: 0;
    padding: 6px 8px;
  }

  .lightbox {
    padding: 58px 10px 24px;
  }

  .lightbox-image {
    max-height: calc(100vh - 132px);
  }

  .lightbox-prev,
  .lightbox-next {
    top: auto;
    bottom: 18px;
    transform: none;
  }
}
