:root { --bg:#0f1222; --card:#1a1e36; --text:#f1f3fb; --muted:#9aa2c4; --accent:#7c5cff; color-scheme: dark; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: env(safe-area-inset-bottom); }

/* Splash: shown while the first wallpapers load, then fades out */
#splash { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: radial-gradient(circle at 50% 35%, #2a2160, var(--bg) 70%); transition: opacity .4s ease, visibility .4s; }
#splash.done { opacity: 0; visibility: hidden; }
.splash-logo { font-size: 40px; font-weight: 800; letter-spacing: .5px; animation: pop .7s ease both; }
.splash-sub { color: var(--muted); letter-spacing: 6px; text-transform: uppercase; font-size: 12px; }
.splash-bar { width: 140px; height: 3px; margin-top: 22px; background: #ffffff1f; border-radius: 3px; overflow: hidden; }
.splash-bar span { display: block; width: 40%; height: 100%; background: var(--accent); border-radius: 3px; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }

/* Thin progress bar for every later load */
#progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 90; opacity: 0; transition: opacity .2s; pointer-events: none; }
#progress.on { opacity: 1; }
#progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }

.top { display: flex; align-items: center; gap: 12px; padding: calc(12px + env(safe-area-inset-top)) 16px 8px; position: sticky; top: 0; background: var(--bg); z-index: 20; }
.top h1 { margin: 0; font-size: 20px; white-space: nowrap; }
.top small { color: var(--muted); font-weight: 500; font-size: 13px; }
#search { flex: 1; min-width: 0; padding: 10px 14px; border-radius: 22px; border: 0; background: var(--card); color: var(--text); font-size: 15px; outline: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 10px; position: sticky; top: calc(58px + env(safe-area-inset-top)); background: var(--bg); z-index: 19; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 14px; border-radius: 18px; border: 0; background: var(--card); color: var(--muted); font-size: 14px; cursor: pointer; }
.chip.on { background: var(--accent); color: #fff; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 4px 16px 16px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(5, 1fr); } }
.tile { position: relative; aspect-ratio: 9 / 16; border-radius: 14px; overflow: hidden; background: var(--card); border: 0; padding: 0; cursor: pointer; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .3s; }
.tile img.ok { opacity: 1; }
.tile.skeleton { animation: shimmer 1.2s ease-in-out infinite; }
@keyframes shimmer { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.sentinel { height: 1px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* Full-screen viewer: swipe left/right between wallpapers. No ads here. */
.viewer { position: fixed; inset: 0; z-index: 50; background: #000; }
.viewer-track { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior: contain; }
.viewer-track::-webkit-scrollbar { display: none; }
.slide { flex: none; width: 100%; height: 100%; scroll-snap-align: center; scroll-snap-stop: always; display: flex; align-items: center; justify-content: center; }
.slide img { max-width: 100%; max-height: 100%; object-fit: contain; }
.v-btn { border: 0; background: #00000099; color: #fff; border-radius: 22px; min-width: 44px; height: 44px; padding: 0 16px; font-size: 20px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; cursor: pointer; backdrop-filter: blur(6px); }
.v-close { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 14px; font-size: 28px; padding: 0; }
.v-info { position: absolute; left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); text-shadow: 0 1px 6px #000; pointer-events: none; }
#vTitle { font-weight: 700; font-size: 17px; }
#vCat { color: #ffffffb3; font-size: 13px; }
.v-actions { position: absolute; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; gap: 10px; justify-content: flex-end; }
.v-dl { background: var(--accent); font-size: 16px; font-weight: 600; }
