.paginated-gallery [hidden] {
  display: none !important;
}

.paginated-gallery {
  display: grid;
  gap: 18px;
}

.home-page-route .image-page,
.home-page-route .hero,
.home-page-route .stats,
.home-page-route .upload-section,
.home-page-route .dashboard,
.home-page-route footer,
html[data-page-mode="home"] .hero,
html[data-page-mode="home"] .stats,
html[data-page-mode="home"] .upload-section,
html[data-page-mode="home"] .dashboard,
html[data-page-mode="home"] .image-page,
html[data-page-mode="home"] footer,
.gallery-page-route .hero,
.gallery-page-route .stats,
.gallery-page-route .upload-section,
.gallery-page-route .image-page,
.gallery-page-route .dashboard,
.gallery-page-route footer,
.image-page-route .hero,
.image-page-route .stats,
.image-page-route .upload-section,
.image-page-route .image-page,
.image-page-route .dashboard,
.image-page-route footer {
  display: none !important;
}

.standalone-gallery-section,
.standalone-image-section {
  min-height: calc(100vh - 72px);
}

.home-page-route .gallery-section {
  min-height: calc(100vh - 72px);
  display: grid;
  align-items: center;
  padding-top: 54px;
  padding-bottom: 64px;
  background: var(--bg);
}

.full-gallery-heading,
.image-detail-heading,
.highlights-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 22px;
}

.full-gallery-heading h1,
.image-detail-heading h1,
.highlights-heading h2 {
  margin: 6px 0 0;
  color: var(--text);
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.15;
}

.gallery-status-text,
.image-detail-subtitle,
.home-gallery-block header span {
  display: inline-block;
  margin-top: 8px;
  color: var(--muted);
}

.gallery-link-button {
  min-height: 42px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #06110f;
  background: var(--accent);
  font-weight: 800;
  white-space: nowrap;
}

.home-about {
  width: min(980px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 28px;
}

.home-about-hero {
  display: grid;
  gap: 16px;
}

.home-about-hero h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(42px, 7vw, 84px);
  line-height: 1;
}

.home-about-lead {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(18px, 2.3vw, 24px);
  line-height: 1.8;
}

.home-about-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.home-about-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.home-about-grid article {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.home-about-grid h2 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 20px;
}

.home-about-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.image-detail-page {
  display: grid;
  gap: 20px;
}

.image-detail-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.image-detail-nav a,
.image-detail-actions button,
.image-detail-actions a {
  min-height: 42px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-2);
  font-weight: 800;
  cursor: pointer;
}

.image-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: 18px;
  align-items: start;
}

.image-detail-media,
.image-detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.image-detail-media {
  min-height: clamp(320px, 62vh, 760px);
  display: grid;
  place-items: center;
}

.image-detail-media img {
  width: 100%;
  height: 100%;
  max-height: 78vh;
  object-fit: contain;
  display: block;
  background: var(--bg);
}

.image-detail-placeholder {
  width: 100%;
  min-height: clamp(320px, 58vh, 680px);
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  background: linear-gradient(135deg, var(--surface-2), var(--bg));
  text-align: center;
  font-weight: 800;
}

.image-detail-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  position: sticky;
  top: 92px;
}

.image-detail-panel h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.image-detail-description {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.image-detail-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.image-detail-actions .primary {
  color: #06110f;
  background: var(--accent);
}

.image-detail-actions .ghost {
  color: var(--text);
  background: var(--surface-2);
}

.image-detail-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.image-detail-stats div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.image-detail-stats dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.image-detail-stats dd {
  margin: 0;
  color: var(--text);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.image-detail-feedback {
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
  border-radius: 8px;
  color: var(--accent);
  background: color-mix(in srgb, var(--surface) 82%, var(--accent) 7%);
}

.home-gallery-highlights {
  display: grid;
  gap: 26px;
  width: min(1240px, 100%);
  margin: 0 auto;
}

.home-gallery-block {
  display: grid;
  gap: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.home-gallery-block header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 14px;
}

.home-gallery-block h3 {
  margin: 0;
  color: var(--text);
  font-size: clamp(22px, 3vw, 30px);
}

.home-gallery-block header a {
  min-height: 38px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-2);
  font-weight: 800;
  white-space: nowrap;
}

.gallery-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 420px) 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 2px;
}

.gallery-search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.gallery-search span {
  font-size: 13px;
  font-weight: 800;
}

.gallery-search input {
  min-height: 46px;
  padding: 0;
  border: 0;
  background: transparent;
}

.gallery-counter {
  color: var(--muted);
  font-size: 14px;
  text-align: end;
}

.gallery-refresh,
.gallery-pagination button,
.gallery-selection button,
.gallery-page-card button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
}

.gallery-refresh {
  padding: 0 16px;
  font-weight: 800;
}

.gallery-feedback {
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
  border-radius: 8px;
  color: var(--accent);
  background: color-mix(in srgb, var(--surface) 82%, var(--accent) 7%);
}

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

.highlight-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.gallery-page-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition:
    transform 0.22s,
    border-color 0.22s,
    box-shadow 0.22s;
}

.gallery-page-card:hover,
.gallery-page-card:focus-visible {
  border-color: var(--accent);
  outline: 0;
  transform: translateY(-4px);
  box-shadow: 0 18px 46px #0000003d;
}

.gallery-page-card.selected {
  border-color: #22c55e;
  box-shadow: 0 0 0 2px #22c55e47, 0 18px 46px #00000047;
}

.gallery-page-card img,
.gallery-image-fallback,
.skeleton-image {
  width: 100%;
  aspect-ratio: 1 / 0.78;
  display: block;
  object-fit: cover;
  background: linear-gradient(135deg, var(--surface-2), var(--bg));
}

.gallery-page-card img {
  transition: transform 0.35s;
}

.gallery-page-card:hover img {
  transform: scale(1.045);
}

.gallery-image-fallback {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.gallery-select {
  position: absolute;
  z-index: 4;
  top: 12px;
  right: 12px;
  width: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid var(--line) !important;
  border-radius: 999px !important;
  color: transparent;
  background: color-mix(in srgb, var(--bg) 82%, transparent) !important;
  backdrop-filter: blur(10px);
}

.gallery-select.active {
  color: #06110f;
  border-color: #22c55e !important;
  background: #22c55e !important;
}

.gallery-card-meta {
  display: grid;
  gap: 9px;
  padding: 14px;
}

.gallery-card-meta h3 {
  min-width: 0;
  margin: 0;
  color: var(--text);
  font-size: 17px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.gallery-page-card.compact .gallery-card-meta {
  padding: 12px;
  gap: 8px;
}

.gallery-page-card.compact h3 {
  font-size: 15px;
}

.gallery-page-card.compact .gallery-card-meta div {
  align-items: stretch;
  flex-direction: column;
  gap: 8px;
}

.gallery-empty {
  grid-column: 1 / -1;
  min-height: 84px;
  padding: 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
}

.gallery-card-meta span {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.gallery-card-meta div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.gallery-card-meta button {
  min-height: 36px;
  padding: 0 12px;
  font-weight: 800;
}

.gallery-pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.gallery-pagination button {
  min-width: 42px;
  padding: 0 13px;
  font-weight: 800;
}

.gallery-pagination button.active {
  color: #06110f;
  background: var(--accent);
}

.gallery-pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.page-gap {
  color: var(--muted);
  padding: 0 4px;
}

.gallery-selection {
  position: sticky;
  z-index: 60;
  bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 65%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 54px #00000057;
}

.gallery-selection strong {
  color: var(--text);
}

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

.gallery-selection button {
  padding: 0 12px;
  font-weight: 800;
}

.gallery-selection button:first-child {
  color: #06110f;
  background: var(--accent);
}

.gallery-selection button:nth-child(2) {
  color: #06110f;
  background: #22c55e;
}

.skeleton {
  pointer-events: none;
}

.skeleton-image,
.skeleton .gallery-card-meta span {
  position: relative;
  overflow: hidden;
}

.skeleton-image::after,
.skeleton .gallery-card-meta span::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, transparent, #ffffff1c, transparent);
  transform: translateX(100%);
  animation: galleryShimmer 1.2s infinite;
}

.skeleton .gallery-card-meta span {
  width: 72%;
  height: 14px;
  border-radius: 999px;
  background: var(--surface-2);
}

.skeleton .gallery-card-meta span:last-child {
  width: 48%;
}

.gallery-toast {
  position: fixed;
  z-index: 90;
  right: 50%;
  bottom: 24px;
  min-height: 48px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  color: #06110f;
  background: #22c55e;
  font-weight: 800;
  box-shadow: 0 18px 48px #00000052;
  opacity: 0;
  transform: translate(50%, 14px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.gallery-toast.visible {
  opacity: 1;
  transform: translate(50%) scale(1);
}

@keyframes galleryShimmer {
  to {
    transform: translateX(-100%);
  }
}

@media (width <= 980px) {
  .image-detail-layout {
    grid-template-columns: 1fr;
  }

  .image-detail-panel {
    position: static;
  }

  .highlight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-about-grid {
    grid-template-columns: 1fr;
  }

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

  .gallery-counter {
    grid-column: 1 / -1;
    order: 3;
    text-align: start;
  }

  .gallery-page-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (width <= 640px) {
  .full-gallery-heading,
  .image-detail-heading,
  .highlights-heading,
  .home-gallery-block header {
    align-items: stretch;
    flex-direction: column;
  }

  .gallery-toolbar,
  .gallery-page-grid,
  .highlight-grid {
    grid-template-columns: 1fr;
  }

  .gallery-link-button,
  .image-detail-nav a,
  .home-gallery-block header a {
    width: 100%;
  }

  .home-about-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .image-detail-nav,
  .image-detail-stats {
    grid-template-columns: 1fr;
  }

  .image-detail-nav {
    flex-direction: column;
  }

  .gallery-refresh,
  .gallery-selection button,
  .gallery-card-meta button {
    width: 100%;
  }

  .gallery-card-meta div,
  .gallery-selection {
    align-items: stretch;
    flex-direction: column;
  }

  .gallery-selection div {
    justify-content: stretch;
  }
}
