.photo-count-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(10, 16, 22, .72);
  color: #fff;
  font-size: 11px;
  font-weight: 650;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.photo-count-badge .icon {
  width: 15px;
  height: 15px;
}

.photo-album-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.photo-gallery-item {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.photo-gallery-item:first-child:nth-last-child(n + 2) {
  grid-column: 1 / -1;
}

.photo-gallery-item > a {
  display: block;
  background: var(--soft);
}

.photo-gallery-item img {
  width: 100%;
  height: auto;
  max-height: 82vh;
  object-fit: contain;
}

.photo-gallery-item figcaption {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: flex-end;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 11px;
}

.photo-gallery-item figcaption a {
  color: var(--accent);
}

.photo-lightbox {
  width: min(96vw, 1200px);
  max-width: none;
  height: min(92vh, 1000px);
  max-height: none;
  margin: auto;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: #090b0e;
  color: #fff;
}

.photo-lightbox::backdrop {
  background: rgba(0, 0, 0, .82);
}

.photo-lightbox img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.photo-lightbox-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, .32);
  border-radius: 50%;
  background: rgba(10, 13, 18, .62);
  color: #fff;
  font-size: 24px;
}

.photo-upload-preview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: -4px 0 22px;
}

.photo-upload-preview:empty {
  display: none;
}

.photo-upload-preview figure {
  position: relative;
  aspect-ratio: 1;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
}

.photo-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-upload-preview figcaption {
  position: absolute;
  right: 5px;
  bottom: 5px;
  left: 5px;
  overflow: hidden;
  color: #fff;
  font-size: 10px;
  line-height: 1.4;
  text-overflow: ellipsis;
  text-shadow: 0 1px 5px #000;
  white-space: nowrap;
}

.photo-upload-form .upload-progress {
  margin-top: 20px;
}

@media (max-width: 520px) {
  .photo-album-gallery {
    gap: 7px;
  }

  .photo-gallery-item {
    border-radius: 10px;
  }

  .photo-upload-preview {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .photo-lightbox {
    animation: none;
  }
}
