.masonry {
  column-gap: 16px;
  column-count: 4;
}

.masonry-item {
  break-inside: avoid;
  margin-bottom: 16px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  position: relative;
  background: #111;
}

.masonry-item a {
  display: block;
  color: inherit;
  text-decoration: none;
}

.masonry-item img {
  width: 100%;
  height: auto;
  display: block;
}

.masonry-view-post {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity 120ms ease, transform 120ms ease, background 120ms ease;
  opacity: 0;
  transform: translateY(6px);
}

.masonry-item:hover .masonry-view-post,
.masonry-item:focus-within .masonry-view-post,
.masonry-view-post:focus {
  opacity: 1;
  transform: translateY(0);
}

.masonry-view-post:hover,
.masonry-view-post:focus {
  background: rgba(0, 123, 255, 0.85);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.35);
}

.masonry-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease, transform 120ms ease;
  transform: scale(0.9);
}

.masonry-delete:hover,
.masonry-delete:focus {
  background: rgba(220, 53, 69, 0.85);
  outline: none;
}

.masonry-item:hover .masonry-delete,
.masonry-delete:focus {
  opacity: 1;
  transform: scale(1);
}

.pictures-lightbox {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
}

.pictures-lightbox.hidden {
  display: none;
}

.pictures-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
}

.pictures-lightbox__content {
  position: relative;
  max-width: min(900px, 92vw);
  max-height: min(90vh, 92vh);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 48px;
  box-sizing: border-box;
  z-index: 1;
}

.pictures-lightbox__figure {
  margin: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pictures-lightbox__image {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.pictures-lightbox__caption {
  margin-top: 12px;
  color: #f2f2f2;
  text-align: center;
  font-size: 0.95rem;
}

.pictures-lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pictures-lightbox__nav:hover,
.pictures-lightbox__nav:focus {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  outline: none;
}

.pictures-lightbox__prev {
  left: 24px;
}

.pictures-lightbox__next {
  right: 24px;
}

.pictures-lightbox__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  z-index: 3;
}

.pictures-lightbox__close:hover,
.pictures-lightbox__close:focus {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  outline: none;
}

body.pictures-lightbox-open {
  overflow: hidden;
}

@media (max-width: 1200px) {
  .masonry {
    column-count: 3;
  }
}

@media (max-width: 900px) {
  .masonry {
    column-count: 2;
  }
}

@media (max-width: 600px) {
  .masonry {
    column-count: 1;
  }
}

.hidden {
  display: none !important;
}

#pictures-upload-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.6);
}

#pictures-upload-modal .modal-body {
  background: var(--card-bg, #0e0f13);
  border-radius: 16px;
  padding: 20px;
  max-width: 520px;
  width: 92%;
}
