.fg-wrap {
  --fg-gap: 16px;
  --fg-radius: 12px;
  width: 100%;
  margin: 1.5rem 0;
  color: inherit;
}
.fg-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 16px;
  font-size: 14px;
}
.fg-toolbar label { display: inline-flex; align-items: center; gap: 8px; }
.fg-sort {
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 7px;
  background: #fff;
  color: #222;
}
.fg-total { opacity: .72; }
.fg-gallery {
  display: grid;
  grid-template-columns: repeat(var(--fg-columns, 4), minmax(0, 1fr));
  gap: var(--fg-gap);
}
.fg-item { min-width: 0; overflow: hidden; }
.fg-photo {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--fg-radius);
  overflow: hidden;
  background: #eee;
  cursor: zoom-in;
  aspect-ratio: 4 / 3;
}
.fg-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .25s ease;
}
.fg-photo:hover img { transform: scale(1.035); }
.fg-photo:focus-visible, .fg-like:focus-visible, .fg-sort:focus-visible {
  outline: 3px solid #2271b1;
  outline-offset: 3px;
}
.fg-like-row { display: flex; justify-content: flex-end; padding: 7px 2px 0; }
.fg-like {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.fg-heart { color: #888; font-size: 19px; line-height: 1; }
.fg-like[aria-pressed="true"] .fg-heart { color: #e04468; }
.fg-like:disabled { opacity: .55; cursor: wait; }

.fg-lightbox {
  position: fixed;
  z-index: 999999;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(0,0,0,.92);
}
.fg-lightbox.is-open { display: flex; }
.fg-lightbox img {
  display: block;
  max-width: min(96vw, 1600px);
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
}
.fg-lightbox-close {
  position: absolute;
  top: 12px;
  right: 18px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 38px;
  line-height: 1;
  cursor: pointer;
}
.fg-lightbox-caption {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 12px;
  color: #fff;
  text-align: center;
  font-size: 14px;
}
@media (max-width: 900px) {
  .fg-gallery { grid-template-columns: repeat(min(var(--fg-columns, 4), 3), minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .fg-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .fg-lightbox { padding: 12px; }
}
@media (max-width: 360px) {
  .fg-gallery { grid-template-columns: 1fr; }
}
