:root {
  --bg: #0f1117;
  --bg-soft: #111827;
  --card: #161b22;
  --card-elevated: #1b2330;
  --primary: #3b82f6;
  --primary-strong: #60a5fa;
  --text: #f8fafc;
  --muted: #94a3b8;
  --line: rgba(148, 163, 184, 0.18);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --duration: 300ms;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.18), transparent 32rem),
    linear-gradient(180deg, #10131b 0%, var(--bg) 42%, #0b0d12 100%);
}

body.modal-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: max-content;
  color: var(--text);
  text-decoration: none;
}

.brand-logo {
  position: relative;
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(147, 197, 253, 0.58);
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.95) 0 5px, transparent 6px),
    radial-gradient(circle at 74% 72%, rgba(191, 219, 254, 0.55) 0 9px, transparent 10px),
    linear-gradient(145deg, #2563eb 0%, #3b82f6 48%, #111827 100%);
  box-shadow:
    0 16px 34px rgba(59, 130, 246, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.brand-logo::after {
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  content: "";
}

.logo-orbit {
  position: absolute;
  width: 54px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-right-color: transparent;
  border-radius: 50%;
  transform: rotate(-28deg);
}

.logo-text {
  position: relative;
  z-index: 1;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 12px rgba(15, 23, 42, 0.42);
}

.brand-copy,
.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.18rem;
  line-height: 1.1;
}

.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.74rem;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(560px, 100%);
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(22, 27, 34, 0.92);
  transition: border-color var(--duration), box-shadow var(--duration), background var(--duration);
}

.search:focus-within {
  border-color: rgba(59, 130, 246, 0.72);
  background: rgba(27, 35, 48, 0.96);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.13);
}

.search svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.search input::placeholder {
  color: #64748b;
}

main {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 44px 0 72px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  min-height: 280px;
  padding: clamp(28px, 5vw, 64px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(59, 130, 246, 0.24), rgba(22, 27, 34, 0.3) 38%, rgba(15, 17, 23, 0.86)),
    radial-gradient(circle at 80% 15%, rgba(125, 211, 252, 0.28), transparent 22rem),
    var(--card);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(3.1rem, 8vw, 7rem);
  line-height: 0.95;
}

.hero-text {
  max-width: 620px;
  margin: 18px 0 0;
  color: #cbd5e1;
  font-size: clamp(1rem, 2vw, 1.22rem);
  line-height: 1.8;
}

.hero-stats {
  display: grid;
  gap: 12px;
  min-width: 180px;
}

.hero-stats span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(15, 17, 23, 0.58);
  color: #cbd5e1;
}

.hero-stats strong {
  color: var(--text);
}

.filters {
  display: flex;
  gap: 10px;
  padding: 22px 0 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #cbd5e1;
  background: rgba(22, 27, 34, 0.74);
  transition: color var(--duration), border-color var(--duration), background var(--duration), transform var(--duration);
}

.filter-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(96, 165, 250, 0.5);
  color: var(--text);
}

.filter-btn.active {
  border-color: rgba(59, 130, 246, 0.65);
  color: white;
  background: linear-gradient(135deg, #2563eb, var(--primary));
  box-shadow: 0 14px 32px rgba(59, 130, 246, 0.24);
}

.hot-rank {
  padding: 20px 0 10px;
}

main.scoped-view .hot-rank {
  padding-top: 8px;
}

.hot-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: none;
}

.hot-tabs::-webkit-scrollbar {
  display: none;
}

.hot-tab {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #cbd5e1;
  background: rgba(22, 27, 34, 0.74);
  white-space: nowrap;
  transition: color var(--duration), border-color var(--duration), background var(--duration), transform var(--duration);
}

.hot-tab:hover {
  transform: translateY(-1px);
  border-color: rgba(96, 165, 250, 0.5);
  color: var(--text);
}

.hot-tab.active {
  border-color: rgba(59, 130, 246, 0.65);
  color: white;
  background: rgba(59, 130, 246, 0.2);
}

.hot-grid {
  column-count: 4;
  column-gap: 18px;
}

.hot-grid .wallpaper-card {
  display: inline-block;
  width: 100%;
  margin: 0 0 18px;
  break-inside: avoid;
}

main.scoped-view .hot-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  column-count: auto;
}

main.scoped-view .hot-grid .wallpaper-card {
  display: block;
  margin: 0;
  break-inside: auto;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 18px auto 6px;
  padding: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

main.scoped-view .gallery-shell .pagination {
  margin-bottom: 0;
}

main.scoped-view .hot-rank .section-heading {
  margin-top: 6px;
}

.pagination[hidden] {
  display: none;
}

.pagination::-webkit-scrollbar {
  display: none;
}

.page-btn,
.page-jump button {
  display: inline-grid;
  min-width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 999px;
  color: #f8fafc;
  background:
    radial-gradient(circle at 45% 18%, rgba(255, 255, 255, 0.18), transparent 30%),
    linear-gradient(145deg, rgba(31, 41, 55, 0.92), rgba(3, 7, 18, 0.94));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.34);
  font-weight: 800;
  transition: transform var(--duration), border-color var(--duration), box-shadow var(--duration), background var(--duration);
}

.page-btn:hover,
.page-jump button:hover {
  transform: translateY(-1px);
  border-color: rgba(96, 165, 250, 0.45);
}

.page-btn.active {
  border-color: rgba(255, 255, 255, 0.62);
  background:
    radial-gradient(circle at 45% 18%, rgba(255, 255, 255, 0.32), transparent 34%),
    linear-gradient(145deg, rgba(59, 130, 246, 0.28), rgba(3, 7, 18, 0.96));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16), 0 16px 36px rgba(59, 130, 246, 0.22);
}

.page-btn:disabled {
  cursor: not-allowed;
  opacity: 0.38;
  transform: none;
}

.page-ellipsis {
  display: inline-grid;
  height: 42px;
  min-width: 28px;
  place-items: center;
  color: #cbd5e1;
  font-weight: 800;
}

.page-jump {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.page-jump input {
  width: 74px;
  height: 42px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  color: #f8fafc;
  background: rgba(15, 17, 23, 0.86);
  text-align: center;
  font-weight: 800;
  outline: none;
}

.page-jump input:focus {
  border-color: rgba(96, 165, 250, 0.55);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.page-jump button {
  min-width: 54px;
}

.gallery-shell {
  padding-top: 18px;
}

main.scoped-view .gallery-shell {
  padding-bottom: 4px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.6rem);
}

.result-count {
  margin: 0;
  color: var(--muted);
}

.masonry {
  column-count: 5;
  column-gap: 18px;
}

.wallpaper-card {
  position: relative;
  display: inline-block;
  width: 100%;
  margin: 0 0 18px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
  color: var(--text);
  text-align: left;
  break-inside: avoid;
  transform: translateY(18px);
  opacity: 0;
  transition: transform var(--duration), opacity var(--duration), box-shadow var(--duration), border-color var(--duration);
}

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

.wallpaper-card:hover {
  border-color: rgba(96, 165, 250, 0.35);
  transform: translateY(-4px);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.38);
}

.wallpaper-card:hover .wallpaper-thumb img,
.wallpaper-card:hover .image-fallback {
  transform: scale(1.045);
}

.wallpaper-thumb {
  position: relative;
  overflow: hidden;
  aspect-ratio: var(--ratio, 3 / 4);
  background: #0b1220;
}

.wallpaper-thumb img,
.wallpaper-thumb .image-fallback {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration);
}

.image-fallback {
  display: grid;
  min-height: 0;
  place-items: center;
  padding: 20px;
  color: rgba(255, 255, 255, 0.8);
  text-align: center;
  background:
    linear-gradient(145deg, rgba(59, 130, 246, 0.32), rgba(22, 27, 34, 0.2)),
    radial-gradient(circle at 72% 22%, rgba(96, 165, 250, 0.42), transparent 30%),
    radial-gradient(circle at 20% 80%, rgba(45, 212, 191, 0.22), transparent 26%),
    #111827;
}

.card-body {
  padding: 14px;
}

.card-title {
  margin: 0 0 10px;
  font-size: 0.98rem;
  line-height: 1.45;
}

.card-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 999px;
  color: #bfdbfe;
  background: rgba(59, 130, 246, 0.14);
  font-size: 0.78rem;
  font-weight: 700;
}

.usage-pill,
.rank-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.12);
  font-size: 0.78rem;
  font-weight: 700;
}

.rank-badge {
  color: #bfdbfe;
  background: rgba(59, 130, 246, 0.16);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 240px;
  border: 1px dashed var(--line);
  border-radius: 22px;
  color: var(--muted);
  background: rgba(22, 27, 34, 0.5);
}

.empty-state[hidden] {
  display: none;
}

.empty-state strong {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 1.1rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  padding: 24px;
}

.modal.open {
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.74);
  backdrop-filter: blur(18px);
}

.modal-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  width: min(1120px, 100%);
  max-height: min(860px, calc(100vh - 48px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  color: white;
  background: rgba(15, 17, 23, 0.68);
  transition: background var(--duration), transform var(--duration);
}

.modal-close:hover {
  transform: rotate(90deg);
  background: rgba(59, 130, 246, 0.8);
}

.modal-close svg,
.download-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.modal-preview {
  min-height: 420px;
  background: #0b1220;
}

.modal-preview img,
.modal-preview .image-fallback {
  width: 100%;
  height: 100%;
  min-height: 420px;
  object-fit: cover;
}

.modal-content {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 34px;
  overflow-y: auto;
}

.modal-content h2 {
  margin: 0;
  padding-right: 34px;
  font-size: clamp(1.7rem, 3vw, 2.6rem);
  line-height: 1.15;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.12);
  font-size: 0.82rem;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  border: 0;
  border-radius: var(--radius);
  color: white;
  background: linear-gradient(135deg, #2563eb, var(--primary));
  box-shadow: 0 18px 36px rgba(59, 130, 246, 0.28);
  font-weight: 800;
  transition: transform var(--duration), box-shadow var(--duration);
}

.download-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 44px rgba(59, 130, 246, 0.36);
}

.recommend-section h3 {
  margin: 0 0 12px;
}

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

.recommend-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: var(--card-elevated);
  text-align: left;
}

.recommend-card img,
.recommend-card .image-fallback {
  aspect-ratio: var(--ratio, 16 / 9);
  min-height: 0;
  object-fit: cover;
}

.recommend-card span {
  display: block;
  padding: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 700;
}

@media (max-width: 1120px) {
  .masonry {
    column-count: 3;
  }

  .hot-grid {
    column-count: 3;
  }

  main.scoped-view .hot-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .hero-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search {
    width: 100%;
  }

  main {
    width: min(100% - 20px, 1480px);
    padding-top: 18px;
  }

  .hero {
    min-height: 230px;
    border-radius: 22px;
  }

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

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

  .masonry {
    column-count: 2;
    column-gap: 10px;
  }

  .hot-grid {
    column-count: 2;
    gap: 10px;
    column-gap: 10px;
  }

  main.scoped-view .hot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wallpaper-card {
    margin-bottom: 10px;
    border-radius: 14px;
  }

  .card-body {
    padding: 10px;
  }

  .modal {
    padding: 10px;
  }

  .modal-panel {
    grid-template-columns: 1fr;
    max-height: calc(100vh - 20px);
    overflow-y: auto;
  }

  .modal-preview,
  .modal-preview img,
  .modal-preview .image-fallback {
    min-height: 280px;
    max-height: 48vh;
  }

  .modal-content {
    padding: 22px;
  }
}
