/* ============================================================
   Waifu Wallpapers — Anime Wallpaper Site
   Mobile-first, GPU-friendly, dark glass aesthetic
   ============================================================ */

:root {
  --bg: #0b0a12;
  --bg-elevated: #12111c;
  --bg-card: rgba(22, 20, 36, 0.72);
  --bg-glass: rgba(18, 16, 30, 0.78);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f0ff;
  --text-muted: #a89ec4;
  --text-dim: #6f6688;
  --accent: #ff6bcb;
  --accent-2: #8b5cf6;
  --accent-3: #38bdf8;
  --accent-glow: rgba(255, 107, 203, 0.35);
  --success: #4ade80;
  --danger: #fb7185;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --header-h: 56px;
  --bottom-nav-h: 60px;
  --page-pad: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font: "Outfit", system-ui, sans-serif;
  --font-display: "Syne", "Outfit", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --max: 1280px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

@media (min-width: 480px) {
  :root {
    --header-h: 60px;
    --page-pad: 16px;
  }
}

@media (min-width: 900px) {
  :root {
    --header-h: 64px;
    --page-pad: 16px;
  }
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
  width: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  min-height: 100vh;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-b) + 12px);
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (min-width: 900px) {
  body { padding-bottom: 0; }
}

img { max-width: 100%; height: auto; display: block; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
/* Prevent iOS zoom on focus — keep inputs ≥16px on mobile */
input, select, textarea { font-size: 16px; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Ambient ---------- */
.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(139, 92, 246, 0.18), transparent 50%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(255, 107, 203, 0.12), transparent 45%),
    var(--bg);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  animation: float 18s var(--ease) infinite alternate;
}

.orb-1 {
  width: 420px; height: 420px;
  background: #8b5cf6;
  top: -80px; left: -100px;
}
.orb-2 {
  width: 360px; height: 360px;
  background: #ff6bcb;
  top: 30%; right: -120px;
  animation-delay: -6s;
}
.orb-3 {
  width: 280px; height: 280px;
  background: #38bdf8;
  bottom: 10%; left: 30%;
  animation-delay: -12s;
  opacity: 0.25;
}

@keyframes float {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(40px, 30px) scale(1.08); }
}

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding-top: var(--safe-t);
  background: rgba(11, 10, 18, 0.72);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  transition: box-shadow 0.3s var(--ease);
}

.header.scrolled { box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35); }

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  min-height: var(--header-h);
  height: var(--header-h);
  padding: 0 max(var(--page-pad), var(--safe-l)) 0 max(var(--page-pad), var(--safe-r));
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (min-width: 480px) {
  .header-inner { gap: 10px; }
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.logo-text {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Short brand on narrow phones; full name from ~380px */
.logo-full { display: none; }
.logo-short { display: inline; }

@media (min-width: 380px) {
  .logo-full { display: inline; }
  .logo-short { display: none; }
  .logo { font-size: 1.1rem; }
}

@media (min-width: 900px) {
  .logo {
    flex: 0 0 auto;
    font-size: 1.15rem;
  }
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 0.8rem;
  box-shadow: 0 0 20px var(--accent-glow);
  flex-shrink: 0;
}

@media (min-width: 480px) {
  .logo-mark { width: 32px; height: 32px; border-radius: 10px; }
}

.logo-accent {
  background: linear-gradient(90deg, var(--accent), #c084fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.search-wrap {
  display: none;
  flex: 1;
  max-width: 420px;
  position: relative;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .search-wrap { display: block; }
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 42px;
  padding: 0 44px 0 42px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.search-input::placeholder { color: var(--text-dim); }
.search-input:hover { border-color: var(--border-strong); }
.search-input:focus {
  outline: none;
  border-color: rgba(255, 107, 203, 0.45);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 3px rgba(255, 107, 203, 0.12);
}

.search-kbd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.25);
}

.header-nav {
  display: none;
  align-items: center;
  gap: 4px;
}

@media (min-width: 900px) {
  .header-nav { display: flex; }
}

.nav-btn {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s, background 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.nav-btn.active {
  color: var(--text);
  background: rgba(255, 107, 203, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 107, 203, 0.25);
}

.fav-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #1a0a14;
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}

.icon-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }

.mobile-search-toggle { display: grid; }
@media (min-width: 768px) {
  .mobile-search-toggle { display: none; }
}

.menu-toggle { display: grid; }
@media (min-width: 900px) {
  .menu-toggle { display: none; }
}

/* Sticky toolbar offset when mobile search expands header */
body.mobile-search-open .toolbar {
  top: calc(112px + var(--safe-t));
}
@media (min-width: 768px) {
  body.mobile-search-open .toolbar {
    top: calc(var(--header-h) + var(--safe-t));
  }
}

.hamburger,
.hamburger::before,
.hamburger::after {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  position: relative;
  transition: transform 0.25s var(--ease);
}
.hamburger::before,
.hamburger::after {
  content: "";
  position: absolute;
  left: 0;
}
.hamburger::before { top: -6px; }
.hamburger::after { top: 6px; }

.mobile-search {
  display: none;
  padding: 0 max(var(--page-pad), var(--safe-l)) 10px max(var(--page-pad), var(--safe-r));
  position: relative;
}
.mobile-search.open { display: block; }
.mobile-search .search-input {
  height: 44px;
  padding-left: 42px;
  padding-right: 16px;
  font-size: 16px; /* prevent iOS zoom */
}
.mobile-search .search-icon {
  left: calc(max(var(--page-pad), var(--safe-l)) + 14px);
}
@media (min-width: 768px) {
  .mobile-search { display: none !important; }
}

/* ---------- Drawer ---------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 210;
  width: min(320px, 92vw);
  max-width: 340px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  padding: calc(16px + var(--safe-t)) 18px calc(24px + var(--safe-b));
  transform: translateX(100%);
  transition: transform 0.35s var(--ease);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  font-family: var(--font-display);
  font-weight: 700;
}

.drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 28px;
}

.drawer-link {
  text-align: left;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s;
}
.drawer-link:hover,
.drawer-link.active {
  background: rgba(255, 107, 203, 0.1);
  color: var(--text);
}

.drawer-section { margin-bottom: 24px; }
.drawer-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 10px;
}

/* ---------- Main ---------- */
.main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--page-pad) 32px;
  width: 100%;
}

@media (min-width: 900px) {
  .main { padding-bottom: 48px; }
}

/* ---------- Hero ---------- */
.hero {
  padding: 22px 0 18px;
  text-align: center;
}

@media (min-width: 768px) {
  .hero { padding: 56px 0 40px; }
}

.hero-eyebrow {
  display: inline-block;
  max-width: 100%;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 107, 203, 0.1);
  border: 1px solid rgba(255, 107, 203, 0.2);
  line-height: 1.3;
}

@media (min-width: 480px) {
  .hero-eyebrow {
    font-size: 0.8rem;
    padding: 6px 12px;
  }
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 7.5vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.12;
  margin-bottom: 12px;
  padding: 0 4px;
}

.gradient-text {
  background: linear-gradient(110deg, var(--accent) 0%, #c084fc 45%, var(--accent-3) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  max-width: 520px;
  margin: 0 auto 18px;
  color: var(--text-muted);
  font-size: 0.92rem;
  padding: 0 4px;
  line-height: 1.45;
}

@media (min-width: 480px) {
  .hero-sub {
    font-size: 1.02rem;
    margin-bottom: 22px;
  }
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 0 auto 8px;
  max-width: 420px;
}

.hero-get-app {
  min-height: 48px;
  padding: 12px 22px !important;
  font-size: 0.95rem !important;
  box-shadow: 0 10px 28px var(--accent-glow);
}

.hero-get-app svg {
  flex-shrink: 0;
}

.hero-browse {
  min-height: 48px;
  padding: 12px 18px !important;
  font-size: 0.92rem !important;
  text-decoration: none;
}

.hero-cta-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin: 0 auto 20px;
  text-align: center;
}

/* Hide install CTA when app is already installed */
body.pwa-installed .hero-cta,
body.pwa-installed .hero-cta-hint {
  display: none;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

@media (min-width: 480px) {
  .hero-stats { gap: 12px; }
}

.stat {
  min-width: 0;
  padding: 10px 6px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

@media (min-width: 480px) {
  .stat {
    padding: 12px 14px;
    border-radius: var(--radius);
  }
}

.stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
}

@media (min-width: 480px) {
  .stat strong { font-size: 1.4rem; }
}

.stat span {
  font-size: 0.7rem;
  color: var(--text-dim);
}

@media (min-width: 480px) {
  .stat span { font-size: 0.8rem; }
}

/* ---------- Sections ---------- */
.section { margin-bottom: 8px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-desc {
  width: 100%;
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-top: -6px;
}

.text-btn {
  font-size: 0.88rem;
  color: var(--accent);
  font-weight: 500;
}
.text-btn:hover { text-decoration: underline; }

/* ---------- Category chips / cards ---------- */
.category-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 4px 0 12px;
  margin: 0 calc(-1 * var(--page-pad));
  padding-left: var(--page-pad);
  padding-right: var(--page-pad);
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  /* edge fade space for last card */
  scroll-padding-inline: var(--page-pad);
}
.category-scroll::-webkit-scrollbar { display: none; }

@media (min-width: 480px) {
  .category-scroll { gap: 10px; }
}

.vibe-card {
  flex: 0 0 auto;
  scroll-snap-align: start;
  width: 104px;
  height: 80px;
  border-radius: 14px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  text-align: left;
  transition: transform 0.25s var(--ease), border-color 0.2s, box-shadow 0.25s;
}

@media (min-width: 480px) {
  .vibe-card {
    width: 118px;
    height: 88px;
    border-radius: var(--radius);
  }
}

.vibe-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--vibe-gradient);
  opacity: 0.9;
}

.vibe-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, transparent 70%);
}

.vibe-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.vibe-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 107, 203, 0.35), 0 10px 28px rgba(0, 0, 0, 0.35);
}

.vibe-card .vibe-emoji {
  position: absolute;
  top: 10px; left: 12px;
  font-size: 1.25rem;
  z-index: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.vibe-card .vibe-name {
  position: absolute;
  bottom: 10px; left: 12px; right: 12px;
  z-index: 1;
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: -0.01em;
}

.vibe-card .vibe-count {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 1;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 6px 0 10px;
  padding: 8px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: sticky;
  top: calc(var(--header-h) + var(--safe-t));
  z-index: 50;
}

.toolbar-left {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.toolbar-left::-webkit-scrollbar { display: none; }

.device-tabs {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  max-width: 100%;
}

.device-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  min-height: 36px;
}

@media (min-width: 400px) {
  .device-tab {
    padding: 8px 12px;
    font-size: 0.82rem;
  }
}

.device-tab.active {
  background: linear-gradient(135deg, rgba(255, 107, 203, 0.25), rgba(139, 92, 246, 0.25));
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.device-tab svg {
  opacity: 0.85;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

@media (max-width: 359px) {
  .device-tab-label { display: none; }
  .device-tab { padding: 8px 11px; }
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.sort-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  display: none;
}

@media (min-width: 420px) {
  .sort-label { display: inline; }
}

.sort-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 8px 30px 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a89ec4' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center,
    rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 16px; /* prevent iOS zoom */
  line-height: 1.2;
  max-width: 42vw;
  cursor: pointer;
  min-height: 36px;
}

@media (min-width: 480px) {
  .sort-select {
    font-size: 0.85rem;
    max-width: none;
    padding: 8px 32px 8px 12px;
  }
}

.sort-select:focus { outline: none; border-color: rgba(255, 107, 203, 0.4); }

/* Compact sort option labels aren't needed — full width toolbar row on tiny phones */
@media (max-width: 379px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-right {
    justify-content: space-between;
  }
  .sort-select {
    flex: 1;
    max-width: none;
  }
  .sort-label { display: inline; }
}

/* ---------- Active filters ---------- */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #ddd6fe;
}

.filter-pill button {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.25);
}
.filter-pill button:hover { color: var(--text); background: rgba(255,255,255,0.1); }

.results-meta {
  margin-bottom: 14px;
  font-size: 0.88rem;
  color: var(--text-dim);
}

/* ---------- Wallpaper grid (masonry-ish CSS columns on wide) ---------- */
.wallpaper-grid {
  columns: 2;
  column-gap: 8px;
  width: 100%;
}

@media (min-width: 400px) {
  .wallpaper-grid { column-gap: 10px; }
}
@media (min-width: 600px) {
  .wallpaper-grid { columns: 3; column-gap: 14px; }
}
@media (min-width: 960px) {
  .wallpaper-grid { columns: 4; column-gap: 16px; }
}

.wallpaper-card {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  margin-bottom: 8px;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.3s var(--ease), border-color 0.2s, box-shadow 0.3s;
  animation: cardIn 0.45s var(--ease) both;
  width: 100%;
}

@media (min-width: 480px) {
  .wallpaper-card {
    margin-bottom: 12px;
    border-radius: var(--radius);
  }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (hover: hover) and (pointer: fine) {
  .wallpaper-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
  }
  .wallpaper-card:hover .card-media img {
    transform: scale(1.04);
  }
}

.wallpaper-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.card-media {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #1a1630, #0f0e18);
}

.card-media img {
  width: 100%;
  height: auto;
  aspect-ratio: var(--ar, 9/16);
  object-fit: cover;
  transition: transform 0.5s var(--ease);
  background: #16142a;
}

.card-media.desktop img { aspect-ratio: 16/10; }
.card-media.mobile img { aspect-ratio: 9/16; }

.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(8, 6, 16, 0.92) 0%, rgba(8, 6, 16, 0.2) 45%, transparent 70%);
  opacity: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 8px;
  transition: opacity 0.25s;
  pointer-events: none;
}

@media (min-width: 480px) {
  .card-overlay { padding: 12px; }
}

/* Touch: always show title strip; hover devices can fade */
@media (hover: hover) and (pointer: fine) {
  .card-overlay { opacity: 0; }
  .wallpaper-card:hover .card-overlay,
  .wallpaper-card:focus-within .card-overlay { opacity: 1; }
}

.card-badges {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 72px; /* leave room for like + fav */
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 4px;
  z-index: 2;
  pointer-events: none;
}

@media (min-width: 480px) {
  .card-badges {
    top: 10px;
    left: 10px;
    right: 80px;
    gap: 6px;
  }
}

.badge {
  font-size: 0.62rem;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-transform: capitalize;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 480px) {
  .badge {
    font-size: 0.68rem;
    padding: 4px 8px;
  }
}

.badge-device { /* kept after vibe / nsfw */ }

.card-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

@media (min-width: 480px) {
  .card-actions {
    top: 8px;
    right: 8px;
  }
}

.card-fav,
.card-like {
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  transition: transform 0.2s, background 0.2s, color 0.2s, border-color 0.2s;
  font-size: 0.78rem;
  font-weight: 600;
  min-height: 34px;
  pointer-events: auto;
}

.card-fav {
  width: 34px;
  height: 34px;
  font-size: 1rem;
}

.card-like {
  padding: 0 10px;
  min-width: 34px;
}

@media (min-width: 480px) {
  .card-fav { width: 36px; height: 36px; }
  .card-like { min-height: 36px; }
}

.card-fav:hover,
.card-like:hover {
  transform: scale(1.06);
  background: rgba(255, 107, 203, 0.28);
}

.card-fav.active { color: var(--accent); }
.card-like.active {
  color: #fde68a;
  border-color: rgba(253, 230, 138, 0.45);
  background: rgba(253, 230, 138, 0.12);
}

.card-like .like-icon { font-size: 0.7rem; line-height: 1; }
.card-like .like-count { font-variant-numeric: tabular-nums; }

.btn-like.active {
  border-color: rgba(253, 230, 138, 0.45);
  color: #fde68a;
  background: rgba(253, 230, 138, 0.1);
}

.card-info h3 {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (min-width: 480px) {
  .card-info h3 { font-size: 0.9rem; }
}

.card-info p {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 480px) {
  .card-info p { font-size: 0.75rem; }
}

.card-tags {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

@media (min-width: 480px) {
  .card-tags { display: flex; }
}

.tag-mini {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  text-transform: capitalize;
}

/* ---------- Empty / load more ---------- */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.7;
}

.empty-state h3 {
  font-family: var(--font-display);
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p { margin-bottom: 20px; font-size: 0.95rem; }

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

/* ---------- Buttons ---------- */
.btn-primary,
.btn-secondary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 24px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 32px var(--accent-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.1); }

.btn-ghost {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.1); }

.btn-fav.active {
  border-color: rgba(255, 107, 203, 0.4);
  color: var(--accent);
  background: rgba(255, 107, 203, 0.1);
}

/* ---------- Characters view ---------- */
.character-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 520px) {
  .character-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 800px) {
  .character-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}
@media (min-width: 1100px) {
  .character-grid { grid-template-columns: repeat(5, 1fr); }
}

.character-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
  text-align: left;
  transition: transform 0.25s var(--ease), border-color 0.2s, box-shadow 0.25s;
  cursor: pointer;
}

.character-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 107, 203, 0.35);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.character-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 107, 203, 0.3);
}

.char-avatar {
  aspect-ratio: 1;
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #1e1a32, #12101c);
}

.char-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s var(--ease);
}

.character-card:hover .char-avatar img { transform: scale(1.06); }

.char-avatar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(11, 10, 18, 0.85), transparent 50%);
}

.char-body {
  padding: 12px 14px 14px;
  margin-top: -28px;
  position: relative;
  z-index: 1;
}

.char-body h3 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}

.char-body p {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.char-series {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: end center;
  padding: 0;
}

@media (min-width: 800px) {
  .modal {
    place-items: center;
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-b));
  }
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 3, 10, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 100%;
  max-height: min(94dvh, 100%);
  overflow: auto;
  overflow-x: hidden;
  border-radius: 20px 20px 0 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: modalIn 0.35s var(--ease);
  padding-bottom: calc(12px + var(--safe-b));
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 800px) {
  .modal-panel {
    width: min(100%, 980px);
    max-height: min(92dvh, 900px);
    border-radius: 20px;
    border-bottom: 1px solid var(--border-strong);
    padding-bottom: 0;
  }
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 800px) {
  @keyframes modalIn {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
}

.modal-close {
  position: absolute;
  top: max(10px, var(--safe-t));
  right: 10px;
  z-index: 5;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 1rem;
  display: grid;
  place-items: center;
  transition: background 0.2s;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.12); }

.modal-body {
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 800px) {
  .modal-body {
    grid-template-columns: 1.15fr 0.85fr;
    min-height: 480px;
  }
  .modal-panel { overflow: hidden; }
  .modal-info {
    overflow-y: auto;
    max-height: min(92dvh, 900px);
  }
}

.modal-media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(30, 27, 50, 0.9), #08070f 70%);
  min-height: 240px;
  max-height: 48dvh;
  overflow: hidden;
}

@media (min-width: 800px) {
  .modal-media {
    max-height: min(92dvh, 900px);
    min-height: 480px;
    height: 100%;
  }
}

/* Full image visible — fit inside frame (no crop) */
.modal-media img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 48dvh;
  object-fit: contain;
  object-position: center;
  background: transparent;
}

@media (min-width: 800px) {
  .modal-media img {
    max-height: min(92dvh, 900px);
    object-fit: contain;
    object-position: center;
  }
}

.modal-media-overlay {
  position: absolute;
  bottom: 12px; left: 12px;
}

.res-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-info {
  padding: 18px 16px 24px;
}

@media (min-width: 800px) {
  .modal-info { padding: 24px 22px 28px; }
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
  padding-right: 44px;
  line-height: 1.25;
  word-break: break-word;
}

@media (min-width: 800px) {
  .modal-title { font-size: 1.4rem; }
}

.modal-character {
  color: var(--accent);
  font-weight: 500;
  font-size: 0.95rem;
  margin-bottom: 14px;
  cursor: pointer;
}
.modal-character:hover { text-decoration: underline; }

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.modal-tag {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  text-transform: capitalize;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.modal-tag:hover {
  border-color: rgba(255, 107, 203, 0.4);
  background: rgba(255, 107, 203, 0.1);
}

.modal-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 22px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-meta div {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.modal-meta strong {
  display: block;
  color: var(--text);
  font-size: 0.9rem;
  margin-top: 2px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

.btn-download {
  flex: 1 1 100%;
  min-width: 0;
  min-height: 48px;
}

@media (min-width: 400px) {
  .btn-download {
    flex: 1 1 auto;
    min-width: 140px;
  }
}

.modal-actions .btn-secondary,
.modal-actions .btn-ghost {
  min-height: 48px;
}

.modal-actions .btn-ghost {
  flex: 0 0 auto;
}

.modal-related h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.related-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.related-thumb {
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 3/4;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}
.related-thumb:hover {
  border-color: var(--accent);
  transform: scale(1.02);
}
.related-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + var(--safe-b) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  z-index: 400;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(22, 20, 36, 0.95);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s var(--ease);
  pointer-events: none;
  white-space: normal;
  text-align: center;
  max-width: min(92vw, 360px);
  line-height: 1.35;
}

@media (min-width: 900px) {
  .toast {
    bottom: 28px;
    white-space: nowrap;
    max-width: 90vw;
  }
}

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

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  margin-top: 32px;
  background: rgba(8, 7, 14, 0.6);
}

.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px var(--page-pad) 20px;
  display: grid;
  gap: 24px;
}

@media (min-width: 700px) {
  .footer-inner {
    padding: 40px var(--page-pad) 28px;
    gap: 32px;
  }
}

@media (min-width: 700px) {
  .footer-inner {
    grid-template-columns: 1.4fr 1fr;
  }
}

.footer-brand p {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 320px;
}

.footer-brand .logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
}

.footer-brand .logo-mark {
  display: inline-grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 0.75rem;
  margin-right: 6px;
  vertical-align: middle;
}

.footer-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (min-width: 700px) {
  .footer-cols {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.footer-social[hidden] {
  display: none !important;
}

.footer-cols h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.footer-cols li { margin-bottom: 8px; }
.footer-cols a,
.footer-cols .link-btn {
  color: var(--text-muted);
  font-size: 0.92rem;
  transition: color 0.2s;
}
.footer-cols a:hover,
.footer-cols .link-btn:hover { color: var(--text); }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding: 14px var(--page-pad) calc(16px + var(--bottom-nav-h) * 0);
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.45;
  word-break: break-word;
}

@media (min-width: 900px) {
  .footer-bottom { font-size: 0.78rem; padding: 16px; }
}

/* Characters view mobile tweaks */
.characters-view,
.favorites-view {
  padding-top: 8px;
}

.char-body h3 {
  font-size: 0.85rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (min-width: 480px) {
  .char-body h3 { font-size: 0.95rem; }
}

.char-body {
  padding: 10px 10px 12px;
}

@media (min-width: 480px) {
  .char-body { padding: 12px 14px 14px; }
}

/* Age gate mobile */
.age-gate {
  padding: max(16px, var(--safe-t)) max(16px, var(--safe-r)) max(16px, var(--safe-b)) max(16px, var(--safe-l));
}

.age-gate-panel {
  width: min(100%, 420px);
  max-height: min(90dvh, 100%);
  overflow-y: auto;
}

.age-actions .btn-primary,
.age-actions .btn-secondary {
  min-height: 48px;
  width: 100%;
}

/* Desktop font-size restore for inputs where zoom isn't an issue */
@media (min-width: 768px) {
  input, select, textarea { font-size: inherit; }
  .search-input { font-size: 0.95rem; }
  .sort-select { font-size: 0.85rem; }
}

/* Results meta shouldn't overflow */
.results-meta {
  overflow-wrap: anywhere;
  line-height: 1.4;
}

/* SEO intro + FAQ */
.seo-intro {
  margin-bottom: 20px;
  padding: 18px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.seo-intro-copy {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  max-width: 720px;
}

.seo-intro-copy p + p {
  margin-top: 10px;
}

.seo-intro-copy strong {
  color: var(--text);
  font-weight: 600;
}

.seo-section-desc {
  margin: -6px 0 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.faq-section {
  margin-top: 36px;
  margin-bottom: 16px;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 720px;
}

.faq-item {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  padding: 4px 14px;
}

.faq-item summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 0;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  float: right;
  color: var(--text-dim);
  font-weight: 500;
}

.faq-item[open] summary::after {
  content: "–";
}

.faq-item p {
  padding: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.faq-item p strong {
  color: var(--text);
}

/* Hide SEO/FAQ blocks on non-home views */
body.view-characters .seo-intro,
body.view-characters .faq-section,
body.view-favorites .seo-intro,
body.view-favorites .faq-section {
  display: none;
}

/* file:// protocol warning */
.file-protocol-banner {
  position: sticky;
  top: 0;
  z-index: 500;
  background: linear-gradient(135deg, #7f1d1d, #9a3412);
  color: #fff7ed;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding: 12px 16px;
}
.file-protocol-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  line-height: 1.4;
}
.file-protocol-inner a {
  color: #fde68a;
  text-decoration: underline;
}
.file-protocol-cmd {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 0.85rem;
  width: fit-content;
}

/* ---------- PWA install ---------- */
.pwa-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--bottom-nav-h) + var(--safe-b) + 10px);
  z-index: 120;
  animation: modalIn 0.35s var(--ease);
}

@media (min-width: 900px) {
  .pwa-banner {
    left: auto;
    right: 20px;
    bottom: 20px;
    width: min(400px, calc(100vw - 40px));
  }
}

.pwa-banner-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(18, 17, 28, 0.96);
  border: 1px solid var(--border-strong);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
}

.pwa-banner-icon img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: block;
}

.pwa-banner-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pwa-banner-text strong {
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.pwa-banner-text span {
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.3;
}

.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.pwa-install-btn {
  padding: 10px 14px !important;
  font-size: 0.82rem !important;
  min-height: 40px;
  white-space: nowrap;
}

.pwa-dismiss-btn {
  width: 36px;
  height: 36px;
  padding: 0 !important;
  border-radius: 10px !important;
}

.pwa-drawer-btn {
  width: 100%;
  margin-bottom: 8px;
}

.pwa-ios-sheet {
  position: fixed;
  inset: 0;
  z-index: 450;
  display: grid;
  place-items: end center;
}

.pwa-ios-sheet[hidden] { display: none; }

.pwa-ios-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 3, 10, 0.7);
  backdrop-filter: blur(6px);
}

.pwa-ios-panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 24px 20px calc(24px + var(--safe-b));
  border-radius: 20px 20px 0 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  animation: modalIn 0.35s var(--ease);
}

.pwa-ios-panel h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin-bottom: 14px;
}

.pwa-ios-steps {
  margin: 0 0 18px 1.1rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.pwa-ios-steps li { margin-bottom: 8px; }
.pwa-ios-steps strong { color: var(--text); }
.ios-share {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
}

.pwa-ios-panel .btn-primary {
  width: 100%;
  min-height: 48px;
}

/* When installed as PWA, slight safe area polish */
@media (display-mode: standalone) {
  .header {
    padding-top: max(var(--safe-t), 0px);
  }
}

/* Prevent horizontal rubber-band from full-bleed scroll rows */
.section,
.grid-section,
.toolbar {
  max-width: 100%;
}

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: calc(var(--bottom-nav-h) + var(--safe-b));
  padding: 4px max(var(--safe-l), 0px) var(--safe-b) max(var(--safe-r), 0px);
  display: flex;
  background: rgba(11, 10, 18, 0.92);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border-top: 1px solid var(--border);
}

@media (min-width: 900px) {
  .bottom-nav { display: none; }
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-dim);
  transition: color 0.2s;
  padding: 6px 4px;
}

.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item svg {
  stroke: currentColor;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* ---------- Chip row (drawer) ---------- */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.chip.active {
  background: rgba(255, 107, 203, 0.15);
  border-color: rgba(255, 107, 203, 0.4);
  color: var(--text);
}

/* ---------- Skeleton loading ---------- */
.skeleton {
  background: linear-gradient(90deg, #16142a 25%, #1e1a36 50%, #16142a 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ---------- NSFW toggle ---------- */
.nsfw-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  margin-left: 4px;
}
.nsfw-toggle:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.nsfw-toggle.active {
  color: #fecdd3;
  border-color: rgba(251, 113, 133, 0.5);
  background: rgba(251, 113, 133, 0.12);
}
.nsfw-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06);
}
.nsfw-toggle.active .nsfw-dot {
  background: var(--danger);
  box-shadow: 0 0 10px rgba(251, 113, 133, 0.7);
}
.nsfw-toggle-block {
  width: 100%;
  justify-content: center;
  padding: 12px;
}
.drawer-hint {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.badge-nsfw {
  background: rgba(251, 113, 133, 0.35) !important;
  border-color: rgba(251, 113, 133, 0.45) !important;
  color: #fecdd3 !important;
}

.nsfw-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(251, 113, 133, 0.85);
  color: #1a0a0e;
}

/* ---------- Pack chips ---------- */
.pack-scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  margin: 0 calc(-1 * var(--page-pad)) 12px;
  padding: 0 var(--page-pad) 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-padding-inline: var(--page-pad);
}
.pack-scroll::-webkit-scrollbar { display: none; }

.pack-filters {
  display: flex;
  gap: 8px;
  width: max-content;
  min-width: 100%;
  padding-right: 4px;
}

.pack-chip {
  flex: 0 0 auto;
  padding: 8px 12px;
  min-height: 36px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
@media (min-width: 480px) {
  .pack-chip {
    padding: 8px 14px;
    font-size: 0.8rem;
  }
}
.pack-chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.pack-chip.active {
  color: var(--text);
  background: rgba(139, 92, 246, 0.18);
  border-color: rgba(139, 92, 246, 0.4);
}

.home-packs {
  margin-top: 4px;
  margin-bottom: 8px;
}

/* ---------- Age gate ---------- */
.age-gate {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: 20px;
}
.age-gate[hidden] { display: none; }

.age-gate-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 3, 10, 0.85);
  backdrop-filter: blur(12px);
}

.age-gate-panel {
  position: relative;
  width: min(100%, 420px);
  padding: 28px 24px;
  border-radius: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  text-align: center;
  animation: modalIn 0.35s var(--ease);
}

.age-eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--danger);
  margin-bottom: 10px;
}

.age-gate-panel h2 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  margin-bottom: 12px;
}

.age-copy {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 22px;
  line-height: 1.5;
}

.age-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (min-width: 420px) {
  .age-actions {
    flex-direction: row;
    justify-content: center;
  }
  .age-actions .btn-primary,
  .age-actions .btn-secondary {
    flex: 1;
  }
}

/* ---------- Image status ---------- */
.image-status {
  margin-top: 18px;
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 8px 14px;
  display: inline-block;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.footer-bottom code {
  font-size: 0.85em;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

/* Hide hero when filtering heavily / non-home */
body.view-characters .hero,
body.view-characters #vibeSection,
body.view-characters #toolbar,
body.view-characters #activeFilters,
body.view-characters #resultsMeta,
body.view-characters #gridSection,
body.view-characters .home-packs,
body.view-favorites .hero,
body.view-favorites #vibeSection,
body.view-favorites #toolbar,
body.view-favorites #activeFilters,
body.view-favorites #resultsMeta,
body.view-favorites #gridSection,
body.view-favorites .home-packs {
  display: none;
}

body.filter-active .hero {
  display: none;
}

/* Prevent body scroll when modal open */
body.modal-open {
  overflow: hidden;
}
