:root {
  --bg: #f5f4f0;
  --fg: #1a1917;
  --muted: #78756e;
  --hairline: rgba(26, 25, 23, 0.1);
  --frame-bg: rgba(26, 25, 23, 0.04);
  --lb-bg: rgba(245, 244, 240, 0.96);
}

html[data-theme="dark"] {
  --bg: #0d0d0e;
  --fg: #eae8e4;
  --muted: #8c8982;
  --hairline: rgba(255, 255, 255, 0.1);
  --frame-bg: rgba(255, 255, 255, 0.04);
  --lb-bg: rgba(10, 10, 11, 0.96);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--fg);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.page-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  padding: 32px 0 22px;
  border-bottom: 1px solid var(--hairline);
}

.brand {
  color: inherit;
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 300;
  letter-spacing: 0.06em;
}

.filter-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
}

.filter-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 300;
  padding: 4px 0;
  opacity: 0.48;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}

.filter-btn:hover {
  opacity: 0.85;
}

.filter-btn.is-active {
  opacity: 1;
  border-bottom-color: var(--fg);
}

.theme-toggle {
  appearance: none;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  opacity: 0.72;
  cursor: pointer;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}

.theme-toggle:hover {
  opacity: 1;
}

.gallery-main {
  flex: 1;
  padding: 44px 0 64px;
  display: flex;
  flex-direction: column;
  gap: 44px;
}

.gallery-row {
  display: grid;
  gap: 32px;
  align-items: end;
}

.gallery-row.cols-1 {
  grid-template-columns: 1fr;
}

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

.gallery-row.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.gallery-row.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.photo-card {
  margin: 0;
  cursor: pointer;
}

.photo-frame {
  overflow: hidden;
  background: var(--frame-bg);
}

.photo-frame img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transition: opacity 0.45s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.photo-frame img.is-loaded {
  opacity: 1;
}

.photo-card:hover .photo-frame img.is-loaded {
  transform: scale(1.016);
}

.photo-caption {
  margin-top: 10px;
  font-size: 0.8rem;
  font-weight: 300;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.empty-state {
  padding: 80px 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.site-footer {
  padding: 26px 0 34px;
  border-top: 1px solid var(--hairline);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px 56px;
  background: var(--lb-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lightbox[hidden] {
  display: none;
}

.lb-stage {
  margin: 0;
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.lb-stage img {
  display: block;
  max-width: 100%;
  max-height: 82vh;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
}

.lb-caption {
  font-size: 0.85rem;
  font-weight: 300;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.lb-btn {
  position: fixed;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg);
  font-weight: 200;
  line-height: 1;
  opacity: 0.5;
  cursor: pointer;
  padding: 12px;
  transition: opacity 0.2s ease;
  user-select: none;
}

.lb-btn:hover {
  opacity: 1;
}

.lb-close {
  top: 18px;
  right: 22px;
  font-size: 1.9rem;
}

.lb-prev,
.lb-next {
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.4rem;
}

.lb-prev {
  left: 14px;
}

.lb-next {
  right: 14px;
}

@media (max-width: 900px) {
  .gallery-row.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .gallery-row.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 0 16px;
  }
  .site-header {
    padding: 22px 0 18px;
    gap: 14px;
  }
  .gallery-main {
    padding: 28px 0 44px;
    gap: 28px;
  }
  .gallery-row {
    gap: 18px;
  }
  .gallery-row.cols-2,
  .gallery-row.cols-3 {
    grid-template-columns: 1fr;
  }
  .gallery-row.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
  .lightbox {
    padding: 20px 14px;
  }
  .lb-prev,
  .lb-next {
    font-size: 1.9rem;
    padding: 8px;
  }
  .lb-prev { left: 4px; }
  .lb-next { right: 4px; }
  .lb-close { top: 10px; right: 12px; }
}
