.gallery-page {
  background: var(--paper-light);
}

.gallery-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 50px;
  padding-top: 156px;
  padding-bottom: 58px;
}

.gallery-hero h1 {
  margin: 0;
  color: var(--navy);
  font-family: var(--serif);
  font-size: clamp(42px, 5.2vw, 68px);
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.42;
}

.gallery-intro {
  max-width: 570px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 2;
}

.gallery-total {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  flex: 0 0 auto;
  margin: 0 0 8px;
  color: var(--red);
  font-family: Georgia, serif;
  font-size: 58px;
  line-height: 1;
}

.gallery-total small {
  margin-top: 12px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.gallery-content {
  padding-bottom: 110px;
}

.gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 25px;
  margin-bottom: 32px;
  padding: 17px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

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

.gallery-filters button {
  min-height: 36px;
  padding: 6px 15px;
  border: 1px solid transparent;
  border-radius: 99px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.gallery-filters button:hover {
  color: var(--red);
}

.gallery-filters button[aria-pressed="true"] {
  border-color: rgba(167, 59, 53, 0.2);
  color: var(--red);
  background: rgba(167, 59, 53, 0.06);
}

.gallery-filter-status {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.06em;
}

.gallery-grid {
  columns: 3;
  column-gap: 24px;
}

.gallery-item {
  display: inline-block;
  width: 100%;
  margin: 0 0 26px;
  break-inside: avoid;
}

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

.gallery-item > a {
  display: block;
  padding: 12px;
  border: 1px solid rgba(39, 54, 79, 0.12);
  background: var(--paper);
  box-shadow: 0 12px 35px rgba(39, 54, 79, 0.045);
  transition: border-color 220ms ease, box-shadow 220ms ease, transform 220ms ease;
}

.gallery-item > a:hover {
  border-color: rgba(167, 59, 53, 0.3);
  box-shadow: 0 20px 45px rgba(39, 54, 79, 0.1);
  transform: translateY(-4px);
}

.gallery-image-frame {
  display: block;
  overflow: hidden;
  background: #f0efed;
}

.gallery-image-frame.tone-portrait {
  background: linear-gradient(145deg, #eee3cd, #e5d5b4);
}

.gallery-image-frame img {
  width: 100%;
  height: auto;
  transition: transform 450ms ease;
}

.gallery-item > a:hover .gallery-image-frame img {
  transform: scale(1.012);
}

.gallery-caption {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 4px 3px;
}

.gallery-caption strong {
  color: var(--navy);
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.gallery-caption small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.05em;
}

.gallery-dialog {
  width: min(1180px, calc(100% - 48px));
  max-width: none;
  max-height: 92svh;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: var(--paper-light);
  box-shadow: 0 30px 120px rgba(0, 0, 0, 0.35);
}

.gallery-dialog::backdrop {
  background: rgba(12, 19, 30, 0.84);
  backdrop-filter: blur(7px);
}

.gallery-dialog-layout {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  max-height: 92svh;
}

.gallery-dialog-close {
  position: absolute;
  z-index: 3;
  top: 15px;
  right: 15px;
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  color: white;
  background: rgba(25, 37, 58, 0.8);
  cursor: pointer;
}

.gallery-dialog-close svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.5;
}

.gallery-dialog-image-wrap {
  display: grid;
  min-height: 280px;
  place-items: center;
  overflow: auto;
  background: #e9e4dc;
}

.gallery-dialog-image-wrap img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 72svh;
  object-fit: contain;
}

.gallery-dialog-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  padding: 19px 24px;
}

.gallery-dialog-info > div:first-child > p:first-child {
  margin: 0 0 4px;
  color: var(--red);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.gallery-dialog-info h2 {
  margin: 0;
  color: var(--navy);
  font-family: var(--serif);
  font-size: 23px;
  letter-spacing: 0.08em;
}

.gallery-dialog-info [data-dialog-caption] {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.gallery-dialog-controls {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 14px;
}

.gallery-dialog-controls button {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--navy);
  background: transparent;
  cursor: pointer;
}

.gallery-dialog-controls button:hover {
  color: white;
  background: var(--navy);
}

.gallery-dialog-controls span {
  min-width: 50px;
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 11px;
  text-align: center;
}

@media (max-width: 1000px) {
  .gallery-grid {
    columns: 2;
  }
}

@media (max-width: 860px) {
  .gallery-hero {
    padding-top: 132px;
  }

  .gallery-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }
}

@media (max-width: 600px) {
  .gallery-hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 28px;
    padding-top: 112px;
    padding-bottom: 40px;
  }

  .gallery-hero h1 {
    font-size: 39px;
  }

  .gallery-total {
    align-items: center;
    flex-direction: row;
    gap: 15px;
    font-size: 42px;
  }

  .gallery-total small {
    margin-top: 0;
  }

  .gallery-grid {
    columns: 1;
  }

  .gallery-content {
    padding-bottom: 75px;
  }

  .gallery-filters {
    gap: 5px;
  }

  .gallery-filters button {
    padding-inline: 12px;
    font-size: 11px;
  }

  .gallery-dialog {
    width: calc(100% - 20px);
    max-height: 94svh;
  }

  .gallery-dialog-layout {
    max-height: 94svh;
  }

  .gallery-dialog-image-wrap img {
    max-height: 66svh;
  }

  .gallery-dialog-info {
    align-items: flex-start;
    flex-direction: column;
    gap: 17px;
    padding: 16px;
  }

  .gallery-dialog-controls {
    align-self: flex-end;
  }
}
