:root {
  --page-bg: #f2f2f2;
  --page-text: #272320;
  --page-muted: #6d6660;
  --page-border: rgba(39, 35, 32, 0.08);
  --shimmer-a: rgba(255, 255, 255, 0.08);
  --shimmer-b: rgba(255, 255, 255, 0.52);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
}

body.preview-page {
  min-height: 100vh;
  font-family:
    "Avenir Next",
    "Segoe UI Variable",
    "PingFang SC",
    "Hiragino Sans GB",
    "Microsoft YaHei",
    sans-serif;
  color: var(--page-text);
  background: var(--page-bg);
}

.gallery {
  width: min(100%, 1720px);
  margin: 0 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.gallery-item {
  position: relative;
  width: 100%;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: transparent;
  line-height: 0;
  overflow: hidden;
}

.gallery-item + .gallery-item {
  margin-top: -1px;
}

.gallery-item[style*="--aspect-ratio"] {
  aspect-ratio: var(--aspect-ratio);
}

.gallery-item::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background:
    linear-gradient(110deg, var(--shimmer-a) 8%, var(--shimmer-b) 18%, var(--shimmer-a) 33%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.03), rgba(0, 0, 0, 0.08));
  background-size: 200% 100%, 100% 100%;
  pointer-events: none;
}

.gallery-item.is-loading::before {
  opacity: 1;
  animation: preview-shimmer 1.2s linear infinite;
}

.gallery-item.is-error::after {
  content: "当前素材加载失败，请稍后刷新再试。";
  position: absolute;
  inset: auto 16px 16px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(24, 22, 19, 0.72);
  color: #fff;
  font-size: 13px;
  line-height: 1.55;
}

.gallery-item picture {
  display: block;
  width: 100%;
}

.gallery-item img,
.gallery-item video {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
  margin: 0;
  border: 0;
  background: transparent;
  vertical-align: top;
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 0.22s ease-out,
    transform 0.4s ease-out;
}

.gallery-item video {
  object-fit: contain;
}

.gallery-item.is-loading picture,
.gallery-item.is-loading img,
.gallery-item.is-loading video {
  opacity: 1;
  transform: none;
}

.gallery-item.is-error picture,
.gallery-item.is-error img,
.gallery-item.is-error video {
  opacity: 0.24;
}

.gallery-more {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 18px 16px 30px;
  text-align: center;
  line-height: 1.6;
  color: var(--page-muted);
  background:
    linear-gradient(180deg, rgba(242, 242, 242, 0), rgba(242, 242, 242, 0.92) 36%),
    var(--page-bg);
}

.gallery-more p {
  margin: 0;
  font-size: 13px;
}

.gallery-more-button {
  appearance: none;
  border: 1px solid var(--page-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--page-text);
  padding: 10px 18px;
  font: inherit;
  font-size: 13px;
  line-height: 1;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 55vh;
  padding: 40px 24px;
  text-align: center;
  line-height: 1.7;
  color: var(--page-muted);
}

.empty-state p {
  margin: 0;
}

.empty-state code {
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--page-border);
  background: #fff;
  color: var(--page-text);
}

noscript {
  display: block;
  padding: 12px 16px 18px;
  text-align: center;
  line-height: 1.7;
  color: var(--page-muted);
}

@keyframes preview-shimmer {
  0% {
    background-position: 200% 0, 0 0;
  }

  100% {
    background-position: -200% 0, 0 0;
  }
}

@media (max-width: 960px) {
  .gallery-item {
    display: block;
    contain: none;
    content-visibility: visible;
    contain-intrinsic-size: auto;
  }

  .gallery-item[data-layout-relaxed="1"] {
    overflow: visible;
  }

  .gallery-item[data-layout-relaxed="1"][style*="--aspect-ratio"] {
    aspect-ratio: auto;
  }

  .gallery-more-button {
    min-width: 128px;
  }
}

@media (min-width: 961px) {
  body.preview-page {
    padding-bottom: 36px;
  }

  .gallery-item {
    overflow: visible;
  }

  .gallery-item[style*="--aspect-ratio"] {
    aspect-ratio: auto;
  }

  .gallery-item picture {
    display: flex;
    justify-content: center;
    width: 100%;
  }

  .gallery-item img,
  .gallery-item video {
    width: auto;
    max-width: min(calc(100vw - 64px), 100%);
    height: auto;
    margin: 0 auto;
  }

  .gallery-more {
    display: none;
  }
}
