.gallery-page {
  --gallery-bg: #050506;
  --gallery-surface: rgba(255, 255, 255, 0.045);
  --gallery-line: rgba(255, 255, 255, 0.09);
  --gallery-primary: #ff4d45;
  --gallery-cyan: #ff8b54;
  --gallery-gold: #ffb3ad;
  background:
    radial-gradient(circle at 50% -12%, rgba(255, 65, 56, 0.26), transparent 34rem),
    radial-gradient(circle at 18% 18%, rgba(255, 139, 84, 0.13), transparent 30rem),
    linear-gradient(180deg, #120607 0%, #060506 34%, #020203 100%);
}

.gallery-page .topbar {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1204px, calc(100% - 32px));
  min-height: 76px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 18px;
  background: rgba(14, 14, 15, 0.74);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(22px);
}

.gallery-hero {
  position: relative;
  min-height: clamp(560px, 72svh, 780px);
  display: flex;
  align-items: flex-start;
  overflow: hidden;
  isolation: isolate;
  padding: clamp(146px, 13vw, 188px) clamp(18px, 6vw, 78px) clamp(92px, 9vw, 126px);
  border-bottom: 0;
  background: #050506;
}

.gallery-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -3;
  background-image: var(--hero-image);
  background-size: cover;
  background-position: center;
  opacity: 0;
  transform: scale(1.035);
  filter: saturate(1.05) contrast(1.06) brightness(0.86);
  transition: opacity 480ms ease;
}

.gallery-hero.has-hero-image::before {
  opacity: 0.58;
}

.gallery-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(90deg, rgba(5, 5, 6, 0.9), rgba(5, 5, 6, 0.58) 42%, rgba(5, 5, 6, 0.28)),
    linear-gradient(180deg, rgba(5, 5, 6, 0.02), rgba(5, 5, 6, 0.58) 72%, #050506),
    radial-gradient(circle at 18% 14%, rgba(255, 77, 69, 0.26), transparent 34%),
    radial-gradient(circle at 76% 54%, rgba(255, 139, 84, 0.12), transparent 28%);
}

.gallery-hero__shade {
  position: absolute;
  inset: auto 0 0;
  z-index: -1;
  height: 46%;
  background: linear-gradient(180deg, transparent, rgba(5, 5, 6, 0.78) 56%, #050506);
}

.gallery-hero__content {
  max-width: 780px;
  margin-top: clamp(12px, 4vh, 46px);
  animation: galleryHeroIn 700ms ease both;
}

.gallery-hero h1 {
  max-width: 820px;
  margin: 0;
  color: #fff7f5;
  font-size: clamp(56px, 10vw, 128px);
  line-height: 0.9;
  letter-spacing: 0;
}

.gallery-hero p:not(.eyebrow) {
  max-width: 590px;
  margin: 24px 0 0;
  color: rgba(255, 247, 245, 0.64);
  font-size: clamp(17px, 2.2vw, 23px);
  line-height: 1.7;
}

.gallery-hero__action {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  margin-top: 34px;
  border-radius: 999px;
  padding: 0 22px;
  color: #fff;
  background: linear-gradient(180deg, #ff6158, #e12a24);
  font-weight: 900;
  box-shadow: 0 22px 80px rgba(255, 45, 37, 0.32);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.gallery-hero__action:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 86px rgba(255, 45, 37, 0.42);
}

.gallery-shell {
  position: relative;
  z-index: 2;
  width: 100%;
  margin: -72px auto 0;
  padding: 72px 0 84px;
  background: linear-gradient(180deg, rgba(5, 5, 6, 0.28), #020203 220px);
}

.gallery-toolbar {
  position: sticky;
  z-index: 5;
  top: 72px;
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(260px, 0.8fr) minmax(260px, 1fr);
  align-items: center;
  gap: 14px;
  padding: 14px clamp(12px, 3vw, 28px) 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(18, 15, 16, 0.72), rgba(10, 8, 9, 0.52));
  backdrop-filter: blur(20px);
}

.gallery-toolbar__meta strong,
.gallery-toolbar__meta span {
  display: block;
}

.gallery-toolbar__meta span {
  margin-top: 4px;
  color: #a9a2b2;
  font-size: 13px;
}

.gallery-search {
  position: relative;
  display: block;
}

.gallery-search span {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #948e9c;
  font-size: 12px;
  font-weight: 800;
}

.gallery-search input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--gallery-line);
  border-radius: 999px;
  padding: 0 18px 0 58px;
  color: #f3edf7;
  background: rgba(255, 255, 255, 0.035);
  outline: none;
}

.gallery-search input:focus {
  border-color: rgba(255, 77, 69, 0.52);
  box-shadow: 0 0 0 3px rgba(255, 77, 69, 0.1);
}

.gallery-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.gallery-tags button {
  min-height: 36px;
  border: 1px solid var(--gallery-line);
  border-radius: 999px;
  padding: 0 14px;
  color: #cbc4d2;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.gallery-tags button.is-active,
.gallery-tags button:hover {
  border-color: transparent;
  color: #fff;
  background: rgba(255, 77, 69, 0.24);
}

.gallery-masonry {
  column-count: 4;
  column-gap: 0;
  line-height: 0;
}

.gallery-tile {
  position: relative;
  width: 100%;
  display: block;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  color: #fff;
  background: linear-gradient(135deg, rgba(207, 188, 255, 0.08), rgba(0, 242, 255, 0.05));
  cursor: zoom-in;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  transform: translateY(12px);
  opacity: 0;
  animation: galleryRise 520ms ease both;
  animation-delay: var(--delay);
}

.gallery-tile:focus {
  outline: none;
}

.gallery-tile:focus-visible::before {
  box-shadow: inset 0 0 0 2px rgba(0, 242, 255, 0.62);
}

.gallery-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border: 0;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.gallery-tile img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 180px;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.012);
  image-rendering: auto;
  transition: opacity 260ms ease, transform 420ms ease;
}

.gallery-tile.is-loaded img {
  opacity: 1;
}

.gallery-tile span {
  position: absolute;
  inset: auto 0 0;
  z-index: 2;
  display: grid;
  gap: 5px;
  padding: 72px 16px 16px;
  text-align: left;
  background: linear-gradient(180deg, transparent, rgba(8, 6, 12, 0.88));
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.gallery-tile strong {
  color: #fff;
  font-size: 16px;
}

.gallery-tile small,
.gallery-tile em {
  color: #d8d0df;
  font-size: 13px;
  font-style: normal;
  line-height: 1.45;
}

.gallery-tile em {
  color: var(--gallery-cyan);
  font-size: 12px;
}

.gallery-tile:hover::before {
  border-color: rgba(0, 242, 255, 0.32);
  box-shadow: inset 0 0 0 1px rgba(207, 188, 255, 0.18);
}

.gallery-tile:hover img {
  transform: scale(1.035);
}

.gallery-tile:hover span,
.gallery-tile:focus-visible span {
  opacity: 1;
  transform: translateY(0);
}

.gallery-empty {
  margin: 70px 0;
  color: #a9a2b2;
}

.gallery-viewer {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(22px);
  animation: galleryViewerIn 180ms ease both;
}

.gallery-viewer__backdrop {
  position: fixed;
  inset: -34px;
  z-index: 0;
  background-color: #050409;
  background-position: center;
  background-size: cover;
  opacity: 0.72;
  filter: blur(34px) saturate(1.18) brightness(0.62);
  transform: scale(1.08);
  transition: opacity 220ms ease, background-image 120ms ease;
}

.gallery-viewer__backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 42%, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.64) 68%),
    rgba(0, 0, 0, 0.22);
}

.gallery-viewer[hidden] {
  display: none;
}

.gallery-viewer figure {
  position: relative;
  z-index: 1;
  max-width: min(1240px, 92vw);
  max-height: 90svh;
  margin: 0;
  display: grid;
  gap: 14px;
  transform-origin: center;
  transition: max-width 240ms ease, max-height 240ms ease, transform 240ms ease, opacity 180ms ease;
}

.gallery-viewer figure.is-screen-fit {
  max-width: calc(100vw - 24px);
  max-height: calc(100svh - 24px);
  gap: 0;
}

.gallery-viewer figure.is-original-size {
  max-width: none;
  max-height: none;
  gap: 0;
  place-self: start center;
}

.gallery-viewer figure.is-compact-size {
  max-width: 100vw;
  max-height: 100svh;
  gap: 0;
}

.gallery-viewer img {
  max-width: 100%;
  max-height: 86svh;
  border-radius: 6px;
  object-fit: contain;
  cursor: zoom-in;
  background: #050409;
  box-shadow: 0 28px 95px rgba(0, 0, 0, 0.62);
  opacity: 1;
  user-select: none;
  -webkit-user-drag: none;
  transform: scale(0.985);
  transition: opacity 220ms ease, transform 260ms ease, filter 220ms ease;
}

.gallery-viewer.is-loading img {
  opacity: 0;
  filter: blur(8px);
}

.gallery-viewer.is-zooming img {
  opacity: 1;
  filter: none;
}

.gallery-viewer.is-ready img {
  opacity: 1;
  transform: scale(1);
  filter: blur(0);
}

.gallery-viewer.is-entering figure {
  opacity: 0;
  transform: translateY(10px) scale(0.975);
}

.gallery-viewer.is-wheel-next figure {
  animation: galleryWheelNext 260ms cubic-bezier(0.2, 0.86, 0.28, 1) both;
}

.gallery-viewer.is-wheel-prev figure {
  animation: galleryWheelPrev 260ms cubic-bezier(0.2, 0.86, 0.28, 1) both;
}

.gallery-viewer figure.is-mode-changing img {
  animation: galleryModePulse 220ms ease both;
}

.gallery-viewer img.is-opening {
  border-radius: 0;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
  will-change: left, top, width, height;
}

.gallery-viewer figure.is-screen-fit img {
  max-width: calc(100vw - 24px);
  max-height: calc(100svh - 24px);
  border-radius: 0;
  cursor: zoom-in;
}

.gallery-viewer figure.is-original-size img {
  max-width: none;
  max-height: none;
  border-radius: 0;
  cursor: zoom-out;
}

.gallery-viewer figure.is-compact-size img {
  max-width: 100vw;
  max-height: 100svh;
  border-radius: 0;
  cursor: zoom-in;
}

.gallery-viewer figcaption {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  color: #f3edf7;
}

.gallery-viewer figcaption strong,
.gallery-viewer figcaption span {
  display: block;
}

.gallery-viewer figcaption span {
  margin-top: 5px;
  color: #bdb5c7;
  line-height: 1.5;
}

.gallery-viewer figure.is-screen-fit figcaption,
.gallery-viewer figure.is-compact-size figcaption,
.gallery-viewer figure.is-original-size figcaption {
  display: none;
}

.gallery-viewer__actions {
  display: flex;
  gap: 8px;
}

.gallery-viewer__actions button,
.gallery-viewer__actions a {
  min-height: 38px;
  border: 1px solid var(--gallery-line);
  border-radius: 999px;
  padding: 0 14px;
  color: #f3edf7;
  background: rgba(255, 255, 255, 0.06);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.gallery-viewer__close,
.gallery-viewer__nav {
  position: fixed;
  z-index: 2;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  backdrop-filter: blur(14px);
}

.gallery-viewer__close {
  top: 18px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 28px;
}

.gallery-viewer__nav {
  top: 50%;
  width: 54px;
  height: 74px;
  border-radius: 999px;
  font-size: 44px;
  transform: translateY(-50%);
}

.gallery-viewer__nav--prev {
  left: 18px;
}

.gallery-viewer__nav--next {
  right: 18px;
}

.gallery-viewer-open {
  overflow: hidden;
}

@keyframes galleryHeroIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes galleryRise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes galleryViewerIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(22px);
  }
}

@keyframes galleryModePulse {
  0% {
    transform: scale(0.992);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes galleryWheelNext {
  0% {
    opacity: 0.68;
    transform: translateY(18px) scale(0.992);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes galleryWheelPrev {
  0% {
    opacity: 0.68;
    transform: translateY(-18px) scale(0.992);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 1180px) {
  .gallery-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .gallery-tags {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .gallery-masonry {
    column-count: 3;
  }
}

@media (max-width: 760px) {
  .gallery-hero {
    min-height: 52svh;
    padding-top: 118px;
  }

  .gallery-toolbar {
    position: static;
    grid-template-columns: 1fr;
  }

  .gallery-masonry {
    column-count: 2;
    column-gap: 0;
  }

  .gallery-tile {
    margin-bottom: 0;
  }

  .gallery-viewer {
    padding: 12px;
  }

  .gallery-viewer figure.is-screen-fit,
  .gallery-viewer figure.is-screen-fit img {
    max-width: calc(100vw - 16px);
    max-height: calc(100svh - 16px);
  }

  .gallery-viewer figure.is-compact-size,
  .gallery-viewer figure.is-compact-size img {
    max-width: 100vw;
    max-height: 100svh;
  }

  .gallery-viewer figcaption {
    display: grid;
  }

  .gallery-viewer__nav {
    width: 42px;
    height: 58px;
    font-size: 34px;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .gallery-viewer,
  .gallery-viewer figure,
  .gallery-viewer img,
  .gallery-viewer figure.is-mode-changing img {
    animation: none;
    transition: none;
  }
}
