.gallery-hero {
  position: relative;
  min-height: 430px;
  display: grid;
  align-items: end;
  overflow: hidden;
}

.gallery-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 45%;
}

.gallery-hero::after {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(14, 18, 22, 0.92), rgba(14, 18, 22, 0.22)),
    linear-gradient(0deg, rgba(14, 18, 22, 1), rgba(14, 18, 22, 0.05) 55%);
  content: "";
}

.gallery-hero-copy {
  position: relative;
  z-index: 1;
  width: min(var(--max, 1200px), calc(100% - 44px));
  margin: 0 auto;
  padding: 90px 0 54px;
}

.gallery-hero-copy h1 {
  margin-top: 12px;
  color: var(--text, #fff);
  font-size: 3.5rem;
}

.gallery-hero-copy p:last-child {
  max-width: 620px;
  margin-top: 16px;
  color: var(--soft, #a0aec0);
  font-size: 1.05rem;
}

.portfolio-section {
  width: min(var(--max, 1200px), calc(100% - 44px));
  margin: 0 auto;
  padding: 76px 0;
}

.portfolio-group + .portfolio-group {
  margin-top: 72px;
}

.portfolio-heading {
  margin-bottom: 24px;
}

.portfolio-heading h2 {
  margin-top: 8px;
  color: var(--text, #fff);
  font-size: 2.1rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 16px;
}

.avatar-card {
  display: grid;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius, 8px);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text, #fff);
  text-align: left;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background-color 0.18s ease;
}

.avatar-card:hover,
.avatar-card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(101, 224, 189, 0.55);
  background: rgba(101, 224, 189, 0.09);
  outline: none;
}

.avatar-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: calc(var(--radius, 8px) - 2px);
  object-fit: cover;
  background: var(--panel, #12161a);
}

.avatar-card span {
  padding: 0 4px 4px;
  font-weight: 800;
}

.avatar-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(6, 8, 10, 0.78);
  backdrop-filter: blur(12px);
}

.avatar-modal-content {
  position: relative;
  width: min(980px, 100%);
  max-height: calc(100vh - 44px);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 22px;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line-strong, rgba(255, 255, 255, 0.2));
  border-radius: var(--radius, 8px);
  background: var(--panel, #12161a);
  box-shadow: var(--shadow, 0 10px 30px rgba(0, 0, 0, 0.5));
}

.modal-gallery-view {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050607;
  border-radius: var(--radius, 8px);
  overflow: hidden;
}

.modal-gallery-view img {
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  transition: opacity 0.2s ease;
}

.slider-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  background: rgba(6, 8, 10, 0.75);
  color: var(--text, #fff);
  border: 1px solid var(--line-strong, rgba(255, 255, 255, 0.2));
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  user-select: none;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease;
}

.slider-btn:hover,
.slider-btn:focus-visible {
  border-color: rgba(101, 224, 189, 0.7);
  background: rgba(101, 224, 189, 0.2);
  outline: none;
}

.slider-btn.prev {
  left: 10px;
}

.slider-btn.next {
  right: 10px;
}

.avatar-modal-content h2 {
  margin-top: 10px;
  color: var(--text, #fff);
  font-size: 2rem;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong, rgba(255, 255, 255, 0.2));
  border-radius: var(--radius, 8px);
  background: rgba(6, 8, 10, 0.8);
  color: var(--text, #fff);
  font-weight: 800;
  cursor: pointer;
}

.modal-close:hover,
.modal-close:focus-visible {
  border-color: rgba(101, 224, 189, 0.7);
  outline: none;
}

@media (max-width: 900px) {
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .avatar-modal-content {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .gallery-hero {
    min-height: 390px;
  }

  .gallery-hero-copy {
    width: calc(100% - 36px);
  }

  .gallery-hero-copy h1 {
    font-size: 2.3rem;
  }

  .portfolio-section {
    width: calc(100% - 36px);
    padding: 56px 0;
  }

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