.gallery-body,
body:has([data-gallery-root]:not([hidden])) {
  background: var(--bg);
}

.gallery-page::before {
  display: none;
}

.gallery-page {
  min-height: 78vh;
  padding-bottom: clamp(72px, 10vw, 132px);
}

.gallery-page-inner {
  width: min(100%, var(--container));
  max-width: var(--container);
}

.gallery-detail-code {
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.gallery-status {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--text-muted);
  text-align: center;
}

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

.gallery-grid {
  display: grid;
  grid-auto-flow: row;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 1.35vw, 20px);
  align-items: start;
}

.gallery-card {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: clamp(14px, 1.7vw, 22px);
  background: #101410;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.16);
  transform: translateZ(0);
  transition: border-color 180ms ease;
}

.gallery-card:hover,
.gallery-card:focus-within {
  border-color: var(--accent);
}

.gallery-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.gallery-card-media {
  position: relative;
  display: block;
  overflow: hidden;
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.025) 22%, rgba(255, 255, 255, 0.075) 40%, rgba(255, 255, 255, 0.025) 58%),
    #111611;
  background-size: 220% 100%;
}

.gallery-card-media img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: var(--gallery-aspect, 1);
  object-fit: cover;
  transition: opacity 360ms ease;
}

.gallery-detail-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: clamp(24px, 4vw, 44px);
}

.gallery-detail-nav .back-link {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 650;
  text-decoration: none;
}

.gallery-detail-nav .back-link:hover {
  color: var(--accent);
}

.gallery-share-button,
.gallery-viewer-toolbar button,
.gallery-fullscreen-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.035);
  text-decoration: none;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.gallery-share-button {
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
}

.gallery-share-button svg,
.gallery-fullscreen-button svg,
.gallery-viewer-toolbar button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gallery-share-button:hover,
.gallery-fullscreen-button:hover,
.gallery-viewer-toolbar button:hover:not(:disabled) {
  color: var(--accent);
  border-color: rgba(173, 219, 113, 0.42);
  background: rgba(173, 219, 113, 0.08);
}

.gallery-detail {
  width: 100%;
}

.gallery-detail-head {
  width: min(920px, 100%);
  margin: 0 auto clamp(26px, 4vw, 48px);
  text-align: center;
}

.gallery-detail-head h1 {
  font-size: clamp(2rem, 3.75vw, 4rem);
  line-height: 1.04;
  letter-spacing: -0.06em;
  overflow-wrap: anywhere;
}

.gallery-detail-head p:last-child {
  max-width: 720px;
  margin: 22px auto 0;
  color: var(--text-secondary);
  font-size: clamp(0.92rem, 1.35vw, 1.05rem);
  line-height: 1.85;
  white-space: pre-wrap;
}

.gallery-viewer-shell {
  width: 100%;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: clamp(18px, 2.6vw, 32px);
  background: #080a08;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
}

.gallery-viewer {
  position: relative;
  display: grid;
  width: 100%;
  height: min(76vh, 940px);
  min-height: 430px;
  place-items: center;
  overflow: hidden;
  background: #000;
  contain: strict;
  isolation: isolate;
  cursor: grab;
  touch-action: none;
}

.gallery-viewer.is-dragging {
  cursor: grabbing;
}

.gallery-viewer.is-interaction-locked {
  cursor: progress;
}

.gallery-viewer:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

.gallery-viewer img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  object-fit: contain;
  transform: translate3d(0, 0, 0) scale(1);
  transform-origin: center;
  transition: opacity 480ms ease, filter 480ms ease;
  user-select: none;
  will-change: opacity;
}

.gallery-viewer-preview {
  z-index: 0;
}

.gallery-tile-canvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 460ms ease;
}

.gallery-tile-canvas.is-ready {
  opacity: 1;
}

.gallery-tile-canvas.has-preview:not(.is-ready) {
  opacity: 0.42;
}

.gallery-viewer-full {
  z-index: 2;
}

.gallery-viewer img.is-ready {
  opacity: 1;
}

.gallery-viewer.is-loading.has-preview .gallery-viewer-preview.is-ready {
  opacity: 0.36;
  filter: brightness(0.72) saturate(0.78);
}

.gallery-viewer:not(.uses-tiles).has-interaction-preview.is-interacting .gallery-viewer-preview {
  opacity: 1;
  filter: none;
  transition-duration: 80ms;
  will-change: transform, opacity;
}

.gallery-viewer:not(.uses-tiles).has-interaction-preview.is-interacting .gallery-viewer-full {
  opacity: 0;
  transition-duration: 80ms;
}

.gallery-image-loader {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  color: var(--text-secondary);
  text-align: center;
  pointer-events: none;
}

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

.gallery-image-loader p {
  max-width: min(360px, 82vw);
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(3, 5, 3, 0.64);
  font-size: 0.8rem;
  font-weight: 650;
  line-height: 1.55;
  backdrop-filter: blur(8px);
}

.gallery-image-progress {
  position: relative;
  display: grid;
  width: 78px;
  height: 78px;
  place-items: center;
  border-radius: 50%;
  background: rgba(3, 5, 3, 0.7);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(8px);
}

.gallery-image-progress svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);
}

.gallery-image-progress circle {
  fill: none;
  stroke-width: 3;
}

.gallery-image-progress-track {
  stroke: rgba(255, 255, 255, 0.1);
}

.gallery-image-progress-value {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 113.1;
  stroke-dashoffset: 113.1;
  transition: stroke-dashoffset 180ms ease;
}

.gallery-image-progress::after {
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(173, 219, 113, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  content: "";
  animation: gallery-loader-spin 1.15s linear infinite;
}

.gallery-image-progress span {
  position: relative;
  z-index: 1;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.gallery-image-retry {
  min-height: 38px;
  padding: 0 15px;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(173, 219, 113, 0.08);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 750;
  cursor: pointer;
  pointer-events: auto;
}

.gallery-image-retry:hover {
  color: var(--accent);
  border-color: rgba(173, 219, 113, 0.42);
}

@keyframes gallery-loader-spin {
  to { transform: rotate(360deg); }
}

.gallery-viewer-note {
  margin: 0;
  padding: 10px clamp(12px, 2vw, 22px);
  border-top: 1px solid var(--border);
  background: rgba(17, 22, 17, 0.96);
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.6;
}

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

.gallery-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  padding: 10px clamp(12px, 2vw, 22px);
  border-top: 1px solid var(--border);
  background: rgba(17, 22, 17, 0.96);
}

.gallery-zoom-controls {
  display: flex;
  align-items: center;
  gap: 7px;
}

.gallery-viewer-toolbar button {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
}

.gallery-viewer-toolbar button:disabled {
  opacity: 0.42;
  cursor: wait;
  pointer-events: none;
}

#galleryZoomReset {
  width: 58px;
}

.gallery-viewer-toolbar .gallery-fullscreen-button {
  flex: 0 0 auto;
  gap: 8px;
  width: auto;
  height: 38px;
  min-height: 38px;
  min-width: max-content;
  padding: 0 13px;
  border-radius: 12px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.gallery-viewer-toolbar .gallery-fullscreen-button svg {
  flex: 0 0 auto;
}

.gallery-viewer-shell:fullscreen,
.gallery-viewer-shell.is-fullscreen-fallback {
  position: relative;
  display: block;
  width: 100vw;
  max-width: none;
  height: 100vh;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #020302;
}

.gallery-viewer-shell:fullscreen .gallery-viewer,
.gallery-viewer-shell.is-fullscreen-fallback .gallery-viewer {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.gallery-viewer-shell:fullscreen .gallery-viewer-note,
.gallery-viewer-shell.is-fullscreen-fallback .gallery-viewer-note {
  display: none;
}

.gallery-viewer-shell:fullscreen .gallery-viewer-toolbar,
.gallery-viewer-shell.is-fullscreen-fallback .gallery-viewer-toolbar {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  left: 0;
  align-items: center;
  flex-direction: row;
  min-height: 0;
  padding: clamp(12px, 2vw, 22px);
  border: 0;
  background: transparent;
  pointer-events: none;
}

.gallery-viewer-shell:fullscreen .gallery-zoom-controls,
.gallery-viewer-shell:fullscreen .gallery-fullscreen-button,
.gallery-viewer-shell.is-fullscreen-fallback .gallery-zoom-controls,
.gallery-viewer-shell.is-fullscreen-fallback .gallery-fullscreen-button {
  pointer-events: auto;
}

.gallery-viewer-shell:fullscreen .gallery-viewer-toolbar button,
.gallery-viewer-shell.is-fullscreen-fallback .gallery-viewer-toolbar button {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(7, 11, 7, 0.72);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
}

.gallery-viewer-shell:fullscreen .gallery-fullscreen-button,
.gallery-viewer-shell.is-fullscreen-fallback .gallery-fullscreen-button {
  width: auto;
}

.gallery-viewer-shell.is-fullscreen-fallback {
  position: fixed;
  z-index: 200;
  inset: 0;
}

body.gallery-fullscreen-fallback {
  overflow: hidden;
}

.gallery-facts {
  width: min(980px, 100%);
  margin: clamp(26px, 4vw, 48px) auto 0;
  padding: clamp(20px, 3vw, 32px);
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(26, 33, 25, 0.8), rgba(15, 19, 15, 0.8));
}

.gallery-facts h2 {
  margin-bottom: 20px;
  font-size: 1rem;
}

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

.gallery-facts dl > div {
  min-width: 0;
}

.gallery-facts dt {
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 650;
}

.gallery-facts dd {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-facts .gallery-fact-wide {
  grid-column: 1 / -1;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.gallery-toast {
  position: fixed;
  z-index: 90;
  right: 50%;
  bottom: 28px;
  padding: 11px 17px;
  color: #071006;
  border-radius: 999px;
  background: var(--accent-bright);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.36);
  font-size: 0.78rem;
  font-weight: 750;
  transform: translateX(50%);
}

@media (max-width: 1020px) {
  .gallery-facts dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .gallery-page {
    padding-bottom: 74px;
  }

  /* The list keeps the shared page offset so its head lines up with the
     other public pages; only the detail view sits closer to the nav. */
  .gallery-page:has(#galleryDetailView:not([hidden])) {
    padding-top: calc(var(--nav-h) + 34px);
  }

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

  .gallery-card {
    border-radius: 13px;
  }

  .gallery-viewer { height: 62vh; min-height: 320px; }
  .gallery-viewer-toolbar { align-items: stretch; flex-direction: column; padding: 12px; }
  .gallery-zoom-controls { justify-content: center; }
  .gallery-viewer-toolbar .gallery-fullscreen-button { width: 100%; }
  .gallery-viewer-shell:fullscreen .gallery-fullscreen-button,
  .gallery-viewer-shell.is-fullscreen-fallback .gallery-fullscreen-button { width: auto; }
  .gallery-facts dl { grid-template-columns: 1fr 1fr; gap: 18px 14px; }
}

@media (max-width: 430px) {
  .gallery-detail-nav { margin-bottom: 24px; }
  .gallery-share-button { min-height: 38px; padding-inline: 13px; }
  .gallery-viewer { height: 52vh; min-height: 290px; }
  .gallery-facts dl { grid-template-columns: 1fr; }
  .gallery-facts .gallery-fact-wide { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-card-media img,
  .gallery-card,
  .gallery-share-button,
  .gallery-fullscreen-button,
  .gallery-viewer img,
  .gallery-tile-canvas,
  .gallery-viewer-toolbar button {
    transition: none;
  }

  .gallery-image-progress::after {
    animation: none;
  }
}
