:root {
  --bg: #fdf5ff;
  --bg-elevated: rgba(255, 255, 255, 0.94);
  --border-subtle: rgba(148, 163, 184, 0.35);
  --text-main: #111827;
  --text-muted: #6b7280;
  --accent: #ec4899;
  --accent-soft: rgba(236, 72, 153, 0.12);
  --accent-soft-2: rgba(129, 140, 248, 0.18);
  --radius-lg: 18px;
  --shadow-soft: 0 18px 40px rgba(236, 72, 153, 0.18);
}

:root.dark {
  --bg: #020617;
  --bg-elevated: rgba(15, 23, 42, 0.96);
  --border-subtle: rgba(148, 163, 184, 0.5);
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --accent: #f97316;
  --accent-soft: rgba(248, 250, 252, 0.08);
  --accent-soft-2: rgba(79, 70, 229, 0.4);
  --shadow-soft: 0 22px 48px rgba(15, 23, 42, 0.9);
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 0% 0%, rgba(236, 72, 153, 0.18) 0, transparent 45%),
    radial-gradient(circle at 100% 0%, rgba(129, 140, 248, 0.22) 0, transparent 50%),
    linear-gradient(to bottom, #fdf2ff, var(--bg));
  color: var(--text-main);
}

:root.dark body {
  background:
    radial-gradient(circle at 0% 0%, rgba(129, 140, 248, 0.4) 0, transparent 45%),
    radial-gradient(circle at 100% 0%, rgba(236, 72, 153, 0.4) 0, transparent 50%),
    radial-gradient(circle at bottom, #020617 0, #020617 60%);
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 16px 40px;
}

/* Header */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(236, 72, 153, 0.4);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
}

.logo-emoji {
  font-size: 16px;
}

.logo-text {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-ghost {
  border-radius: 999px;
  font-size: 14px;
  border: 1px solid var(--border-subtle);
  outline: none;
  cursor: pointer;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-main);
  backdrop-filter: blur(14px);
}

:root.dark .btn-ghost {
  background: rgba(15, 23, 42, 0.86);
}

.btn-ghost:hover {
  background: var(--accent-soft);
}

/* Chips */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.9);
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
}

:root.dark .chip {
  background: rgba(15, 23, 42, 0.9);
}

.chip.active {
  background: linear-gradient(135deg, #ec4899, #a855f7);
  border-color: transparent;
  color: #f9fafb;
}

/* Toolbar */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 220px;
}

.search-box input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.92);
  outline: none;
  font-size: 13px;
}

:root.dark .search-box input {
  background: rgba(15, 23, 42, 0.9);
}

.search-box input:focus {
  border-color: rgba(236, 72, 153, 0.6);
  box-shadow: 0 0 0 1px rgba(236, 72, 153, 0.3);
}

.info-count {
  font-size: 12px;
  color: var(--text-muted);
}

/* Main */

.main {
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: var(--shadow-soft);
  padding: 14px 14px 18px;
}

:root.dark .main {
  background: rgba(15, 23, 42, 0.96);
}

/* Gallery grid */

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

.card {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  cursor: zoom-in;
  background: rgba(15, 23, 42, 0.04);
}

.card-thumb-wrap {
  position: relative;
  padding-top: 130%; /* 竖版略偏长一点 */
  overflow: hidden;
}

.card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.16s ease-out, filter 0.16s ease-out;
}

.card:hover img {
  transform: scale(1.06);
  filter: saturate(1.1);
}

.card-meta {
  position: absolute;
  inset: auto 0 0;
  padding: 6px 7px 5px;
  background: linear-gradient(
    to top,
    rgba(15, 23, 42, 0.85),
    rgba(15, 23, 42, 0.4),
    transparent
  );
  color: #f9fafb;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-title {
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.card-tags {
  font-size: 10px;
  opacity: 0.8;
}

/* Footer */

.footer {
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Viewer */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer.hidden {
  display: none;
}

.viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(6px);
}

.viewer-content {
  position: relative;
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 20px;
  background: radial-gradient(circle at top left, #111827 0, #020617 60%);
  padding: 16px 18px 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1;
}

.viewer-image-wrap {
  border-radius: 14px;
  overflow: hidden;
  background: #020617;
  max-height: 74vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-image-wrap img {
  max-width: 100%;
  max-height: 74vh;
  object-fit: contain;
}

.viewer-meta {
  color: #e5e7eb;
  font-size: 13px;
}

.viewer-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.viewer-sub {
  font-size: 11px;
  color: #9ca3af;
  display: flex;
  gap: 10px;
  margin-bottom: 4px;
}

.viewer-tags {
  font-size: 11px;
  color: #f9a8d4;
}

.viewer-tags span {
  margin-right: 6px;
}

.viewer-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: rgba(15, 23, 42, 0.7);
  color: #e5e7eb;
  border-radius: 999px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 14px;
}

.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: rgba(15, 23, 42, 0.7);
  color: #e5e7eb;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 18px;
}

.viewer-nav.prev {
  left: 8px;
}

.viewer-nav.next {
  right: 8px;
}

/* Responsive */

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

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

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

  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-right {
    justify-content: flex-start;
  }
}