:root {
  --bg: #0f1117;
  --bg-elevated: #171b24;
  --bg-soft: #1e2430;
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef1f6;
  --text-muted: #9aa3b2;
  --accent: #ff6b4a;
  --accent-soft: rgba(255, 107, 74, 0.16);
  --accent-hover: #ff8266;
  --success: #3ecf8e;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --radius-sm: 10px;
  --header-h: 72px;
  --nav-h: 56px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 107, 74, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(88, 130, 255, 0.1), transparent 24%),
    var(--bg);
}

img {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
  background: rgba(15, 17, 23, 0.82);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  background: linear-gradient(135deg, #ff6b4a, #ff9470);
  box-shadow: 0 10px 24px rgba(255, 107, 74, 0.28);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 1.15rem;
}

.brand-text span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.source-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: var(--success);
  background: rgba(62, 207, 142, 0.12);
  border: 1px solid rgba(62, 207, 142, 0.28);
  vertical-align: 1px;
}

.search-form {
  flex: 1;
  display: flex;
  gap: 10px;
  max-width: 520px;
  margin-left: auto;
}

.search-form input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-form input:focus {
  border-color: rgba(255, 107, 74, 0.55);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.search-form button {
  padding: 0 18px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

.search-form button:hover {
  background: var(--accent-hover);
}

.category-nav {
  position: sticky;
  top: var(--header-h);
  z-index: 15;
  background: rgba(15, 17, 23, 0.92);
  border-bottom: 1px solid var(--border);
}

.category-scroll {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-scroll::-webkit-scrollbar {
  display: none;
}

.category-chip {
  flex-shrink: 0;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.category-chip:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.18);
}

.category-chip.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #ff6b4a, #ff8266);
  box-shadow: 0 8px 20px rgba(255, 107, 74, 0.25);
}

.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 20px;
  margin-bottom: 24px;
}

.hero-copy,
.hero-stats,
.status-bar {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.hero-copy {
  padding: 28px 32px;
}

.hero-kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-copy h1 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.hero-desc {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 52ch;
}

.hero-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  padding: 0;
}

.stat {
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-elevated);
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.status-bar {
  margin-bottom: 20px;
  padding: 12px 16px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.status-bar.error {
  color: #ffb4a8;
  border-color: rgba(255, 107, 74, 0.35);
}

.status-bar.loading::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}

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

.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.wallpaper-card {
  position: relative;
  aspect-ratio: 16 / 10;
  border: none;
  padding: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-soft);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.wallpaper-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.42);
}

.wallpaper-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.wallpaper-card img.loaded {
  opacity: 1;
}

.wallpaper-card .card-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, #1e2430 8%, #2a3140 18%, #1e2430 33%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.wallpaper-card img.loaded + .card-shimmer {
  display: none;
}

@keyframes shimmer {
  to {
    background-position-x: -200%;
  }
}

.card-overlay {
  position: absolute;
  inset: auto 0 0;
  padding: 14px 12px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
}

.wallpaper-card:hover .card-overlay {
  opacity: 1;
  transform: translateY(0);
}

.card-tags {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 28px;
}

.load-more-btn {
  padding: 12px 28px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.load-more-btn:hover:not(:disabled) {
  border-color: rgba(255, 107, 74, 0.45);
  color: #fff;
}

.load-more-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.site-footer {
  padding: 24px 20px 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text);
}

.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
}

.preview-overlay[hidden] {
  display: none;
}

.preview-dialog {
  position: relative;
  width: min(960px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
}

.preview-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.preview-media {
  position: relative;
  background: #090b10;
  min-height: 240px;
}

.preview-media img {
  width: 100%;
  max-height: 68vh;
  object-fit: contain;
  margin: 0 auto;
}

.preview-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-muted);
}

.preview-loading[hidden] {
  display: none;
}

.preview-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 24px;
}

.preview-meta h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.preview-meta p {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex-shrink: 0;
}

.btn {
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

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

.btn-secondary {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(120%);
  z-index: 60;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(23, 27, 36, 0.96);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

@media (max-width: 900px) {
  :root {
    --header-h: 118px;
  }

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

  .search-form {
    max-width: none;
    margin-left: 0;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .preview-meta {
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .wallpaper-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .hero-copy,
  .stat {
    padding: 20px;
  }

  .preview-overlay {
    padding: 0;
  }

  .preview-dialog {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
}
