.gallery-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 90% 8%, rgba(214, 107, 22, 0.12), transparent 26rem),
    radial-gradient(circle at 5% 35%, rgba(44, 129, 125, 0.1), transparent 24rem),
    var(--paper);
}

.gallery-main {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 78px 0 96px;
}

.gallery-intro {
  max-width: 820px;
  padding: 58px 0 34px;
}

.gallery-intro h1 {
  margin: 0 0 18px;
  font-size: clamp(2.35rem, 6vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.gallery-intro > p:last-child {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.gallery-intro code {
  padding: 0.08em 0.32em;
  color: var(--copper-dark);
  background: rgba(214, 107, 22, 0.09);
  border-radius: 4px;
}

.gallery-controls {
  display: flex;
  align-items: end;
  gap: 16px;
  margin-bottom: 28px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(23, 34, 42, 0.06);
  backdrop-filter: blur(10px);
}

.gallery-controls label {
  display: grid;
  gap: 6px;
  min-width: min(260px, 40vw);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.gallery-controls select {
  width: 100%;
  min-height: 44px;
  padding: 8px 36px 8px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
}

.gallery-count {
  margin: 0 0 10px auto;
  color: var(--muted);
  font-size: 0.92rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 350px), 1fr));
  gap: 24px;
}

.gallery-card {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  scroll-margin-top: 80px;
}

.gallery-card:target,
.gallery-card.is-linked {
  outline: 4px solid rgba(214, 107, 22, 0.55);
  outline-offset: 4px;
}

.gallery-card-image {
  position: relative;
  display: block;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: #141b1e;
}

.gallery-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 180ms ease;
}

.gallery-card-image:hover img {
  transform: scale(1.025);
}

.gallery-image-switcher {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  overflow-x: auto;
  background: #182326;
}

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

.gallery-image-switcher button {
  padding: 5px 9px;
  color: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  cursor: pointer;
}

.gallery-image-switcher button[aria-pressed="true"] {
  color: #fff;
  background: var(--copper);
  border-color: var(--copper);
}

.gallery-side-badge {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 4px 8px;
  color: #fff;
  background: rgba(12, 18, 20, 0.78);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 750;
}

.gallery-card-copy {
  padding: 20px;
}

.gallery-card-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.gallery-card h2 {
  margin: 2px 0 0;
  font-size: 1.35rem;
  line-height: 1.18;
}

.gallery-card h2 a {
  color: inherit;
  text-decoration: none;
}

.gallery-card h2 a:hover {
  color: var(--copper-dark);
  text-decoration: underline;
}

.gallery-machine {
  margin: 0;
  color: var(--copper-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.065em;
  text-transform: uppercase;
}

.gallery-card time,
.gallery-author,
.gallery-card-footer > span {
  color: var(--muted);
  font-size: 0.82rem;
}

.gallery-card time {
  white-space: nowrap;
}

.gallery-author {
  margin: 8px 0 0;
}

.gallery-description {
  min-height: 3.1em;
  margin: 16px 0;
}

.gallery-card details {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.gallery-card summary {
  color: var(--teal);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
}

.gallery-card details p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.91rem;
  white-space: pre-wrap;
}

.gallery-card-footer {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}

.gallery-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.gallery-card-footer .button {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 0.88rem;
  white-space: nowrap;
}

.gallery-card-footer small {
  display: block;
  margin-top: 3px;
}

.gallery-empty {
  padding: 70px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 14px;
}

.gallery-empty h2,
.gallery-empty p {
  margin: 0;
}

.gallery-empty p {
  margin-top: 8px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .gallery-main {
    width: min(100% - 28px, 1280px);
    padding-top: 64px;
  }

  .gallery-intro {
    padding-top: 42px;
  }

  .gallery-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .gallery-controls label {
    min-width: 0;
  }

  .gallery-count {
    margin: 2px 0 0;
  }

  .gallery-card-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .gallery-card-footer .button {
    text-align: center;
  }
}
