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

:root {
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
  --accent: #f43f5e;
  --accent-hover: #e0304f;
  --accent-dim: rgba(244, 63, 94, 0.12);
  --accent-border: rgba(244, 63, 94, 0.35);
  --border: rgba(255, 255, 255, 0.07);
  --surface: rgba(18, 18, 18, 0.96);
  --text: #f0f0f0;
  --muted: rgba(255, 255, 255, 0.45);
  --nav-h: 60px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --grid-gap: 14px;
  --card-radius: 16px;
  --touch-min: 44px;
  --vh: 1vh;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: radial-gradient(ellipse 120% 60% at 50% 0%, #2a0810 0%, #0d0d0d 55%, #080808 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  font-feature-settings: 'kern' 1, 'liga' 1;
  min-height: calc(var(--vh, 1vh) * 100);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

body.modal-open {
  overflow: hidden;
  touch-action: none;
}

::selection { background: var(--accent); color: white; }

/* ── NAV ── */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 max(16px, var(--safe-left)) 0 max(16px, var(--safe-right));
  height: calc(var(--nav-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: rgba(8, 8, 8, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  transition: height 0.2s ease, box-shadow 0.2s ease;
}

.top-nav.nav-compact {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  min-height: var(--touch-min);
}

.logo-icon { font-size: 1.25rem; }

.logo-text {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 3.2vw, 1.3rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  font-stretch: normal;
  color: var(--accent);
}

.nav-links { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.tutorial-btn,
.sfw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s;
  -webkit-tap-highlight-color: transparent;
}

.sfw-btn:active { transform: scale(0.97); }
.tutorial-btn:active { transform: scale(0.97); }
.tutorial-btn-short { display: none; }
.tutorial-btn:hover,
.sfw-btn:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.14);
}
.sfw-btn.sfw-on { color: #86efac; border-color: rgba(34,197,94,0.3); background: rgba(34,197,94,0.08); }

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-button:hover { color: var(--accent-hover); }

.tutorial-backdrop {
  z-index: 200;
}

.tutorial-modal {
  position: relative;
  width: min(720px, 100%);
  max-height: min(92vh, 900px);
  overflow-y: auto;
  padding: 24px 20px calc(20px + var(--safe-bottom));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.tutorial-title {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 4vw, 1.5rem);
  font-weight: 700;
  margin: 0 36px 10px 0;
  line-height: 1.2;
}

.tutorial-intro {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
  margin-bottom: 16px;
}

.tutorial-video-wrap {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.tutorial-video {
  display: block;
  width: 100%;
  max-height: 52vh;
  background: #000;
}

.tutorial-steps {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.tutorial-steps li + li { margin-top: 8px; }

.tutorial-steps strong { color: var(--text); font-weight: 600; }

@media (max-width: 639px) {
  .tutorial-btn span.tutorial-btn-long { display: none; }
  .tutorial-btn-short { display: inline; }
  .tutorial-modal {
    width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    margin-top: auto;
  }

  .tutorial-backdrop {
    align-items: flex-end;
    padding: 0;
  }
}

@media (min-width: 640px) {
  .tutorial-backdrop {
    align-items: center;
    padding: 20px;
  }
}

body.sfw .card-photo { filter: blur(22px); transform: scale(1.18); }

/* ── HERO ── */
.hero {
  text-align: center;
  padding: clamp(28px, 6vw, 52px) 16px 16px;
}

.seo-noscript {
  max-width: 640px;
  margin: 0 auto 16px;
  padding: 0 16px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
  font-size: 0.95rem;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.85rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  font-stretch: normal;
  color: var(--accent);
  text-shadow: 0 0 48px rgba(244, 63, 94, 0.35);
  margin-bottom: 8px;
  line-height: 1.15;
}

.hero-emoji { display: inline-block; }

.hero-sub {
  color: var(--muted);
  font-size: clamp(0.85rem, 2.5vw, 0.98rem);
  font-weight: 500;
  letter-spacing: 0.01em;
  margin-bottom: 20px;
}

.search-wrapper {
  position: relative;
  max-width: 520px;
  margin: 0 auto;
}

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

.search-input {
  width: 100%;
  min-height: var(--touch-min);
  padding: 12px 44px 12px 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: white;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

.search-input::placeholder { color: rgba(255,255,255,0.28); }

.search-input:focus {
  border-color: var(--accent-border);
  background: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.08);
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.08);
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}

.search-clear[hidden] { display: none; }

.suggestions-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: rgba(18, 18, 18, 0.98);
  border: 1px solid var(--accent-border);
  border-radius: 14px;
  overflow: hidden;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  display: none;
  max-height: min(280px, 40vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.suggestions-dropdown.open { display: block; }

.suggestion-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  min-height: var(--touch-min);
  cursor: pointer;
  font-size: 0.9rem;
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
}

.suggestion-item:active { background: var(--accent-dim); }

.results-count {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 10px 0 0;
  min-height: 24px;
}

/* ── FILTERS ── */
.filters-bar {
  position: sticky;
  top: calc(var(--nav-h) + var(--safe-top));
  z-index: 90;
  background: linear-gradient(to bottom, rgba(8,8,8,0.95) 70%, transparent);
  padding: 8px 0 12px;
  margin-bottom: 4px;
}

.filters {
  display: flex;
  gap: 8px;
  padding: 0 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  justify-content: flex-start;
}

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

.filter-button {
  flex: 0 0 auto;
  min-height: var(--touch-min);
  padding: 0 18px;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  font-stretch: normal;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.filter-button:active { transform: scale(0.97); }

.filter-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 4px 16px rgba(244, 63, 94, 0.3);
}

/* ── GRID ── */
.model-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--grid-gap);
  padding: 0 12px 32px;
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
}

.model-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (hover: hover) {
  .model-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(244, 63, 94, 0.16);
    border-color: rgba(244, 63, 94, 0.28);
  }
  .model-card:active { transform: translateY(-2px); }
}

.card-thumb {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: #111;
}

.card-thumb-bg {
  position: absolute;
  inset: -12px;
  width: calc(100% + 24px);
  height: calc(100% + 24px);
  background-size: cover;
  background-position: center top;
  filter: blur(20px) brightness(0.4) saturate(1.4);
  z-index: 0;
  pointer-events: none;
}

.card-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.35s ease;
}

@media (hover: hover) {
  .model-card:hover .card-photo { transform: scale(1.04); }
}

.card-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #1a0a10, #2a1020);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 6vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card-body {
  padding: 10px 12px 12px;
  text-align: center;
}

.card-body h3 {
  font-family: var(--font-display);
  font-size: clamp(0.84rem, 2.8vw, 0.94rem);
  font-weight: 600;
  letter-spacing: 0;
  font-stretch: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.card-body p {
  margin-top: 3px;
  font-size: 0.72rem;
  color: var(--muted);
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
}

.empty-state code {
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 4px;
}

.scroll-sentinel {
  grid-column: 1 / -1;
  height: 1px;
  visibility: hidden;
  pointer-events: none;
}

/* ── FOOTER ── */
.site-footer {
  text-align: center;
  padding: 20px 16px calc(20px + var(--safe-bottom));
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

.backend-banner {
  position: sticky;
  top: calc(var(--nav-h) + var(--safe-top));
  z-index: 99;
  margin: 0 12px 8px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(244, 63, 94, 0.35);
  background: rgba(244, 63, 94, 0.12);
  color: #fecdd3;
  font-size: 0.82rem;
  line-height: 1.5;
}

.backend-banner a { color: white; }
.backend-banner code {
  background: rgba(0,0,0,0.25);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ── SCROLL TOP ── */
.scroll-top {
  position: fixed;
  right: max(16px, var(--safe-right));
  bottom: calc(16px + var(--safe-bottom));
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--accent-border);
  background: rgba(18,18,18,0.92);
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 80;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.scroll-top.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── MODAL ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  backdrop-filter: blur(10px);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-backdrop[hidden] { display: none; }

.modal-sheet {
  width: 100%;
  max-width: 440px;
  max-height: calc(var(--vh, 1vh) * 94);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 0;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  touch-action: pan-y;
}

.modal-sheet.is-dragging {
  animation: none;
  transition: none;
}

.modal-drag-zone {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  z-index: 6;
  touch-action: none;
  cursor: grab;
}

.modal-sheet.is-dragging .modal-drag-zone {
  cursor: grabbing;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255,255,255,0.35);
  z-index: 4;
}

.modal-hero {
  position: relative;
  flex-shrink: 0;
}

.modal-thumb {
  aspect-ratio: 3 / 4;
  max-height: 58vh;
  width: 100%;
  overflow: hidden;
  background: #111;
  margin: 0;
  border-radius: 20px 20px 0 0;
}

.modal-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.modal-thumb .card-placeholder {
  font-size: clamp(2.5rem, 12vw, 4rem);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(10px);
  color: white;
  cursor: pointer;
  font-size: 1.1rem;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.modal-hero-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 48px 20px 18px;
  background: linear-gradient(to top, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0.55) 55%, transparent 100%);
  text-align: center;
  pointer-events: none;
}

.modal-hero-overlay h3 {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 4.5vw, 1.25rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  font-stretch: normal;
  margin: 0;
  color: white;
  line-height: 1.2;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.modal-footer {
  flex-shrink: 0;
  padding: 14px 16px calc(14px + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.modal-actions {
  display: flex;
  flex-direction: row;
  gap: 10px;
}

.modal-actions .btn-primary,
.modal-actions .btn-secondary {
  flex: 1;
  min-height: 52px;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}

.modal-hint {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  margin-bottom: 16px;
}

.btn-primary,
.btn-secondary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch-min);
  padding: 12px 18px;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.18s;
  border: 1px solid transparent;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

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

.btn-primary:disabled {
  opacity: 0.7;
  cursor: wait;
}

.btn-primary.is-loading .btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-spinner { display: none; }

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

.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: white;
  border-color: var(--border);
}

.btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── VERIFY ── */
.verify-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(var(--vh, 1vh) * 100);
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
}

.verify-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
}

.verify-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 50px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
  font-stretch: normal;
  margin-bottom: 16px;
}

.verify-card h2 {
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 5vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  font-stretch: normal;
  margin-bottom: 12px;
}

.verify-card p {
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.verify-card .btn-primary,
.verify-card .btn-ghost {
  width: 100%;
  margin-bottom: 10px;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

/* ── SKELETON ── */
@keyframes shimmer {
  0% { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}

.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  overflow: hidden;
}

.skeleton-pulse {
  background: linear-gradient(90deg, #1c1c1c 25%, #282828 50%, #1c1c1c 75%);
  background-size: 600px 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-thumb { aspect-ratio: 2 / 3; width: 100%; }
.skeleton-body { padding: 11px 14px 14px; }
.skeleton-line { height: 13px; border-radius: 6px; width: 72%; }

/* ── BREAKPOINTS ── */
@media (min-width: 480px) {
  .model-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 0 16px 36px;
  }
}

@media (min-width: 640px) {
  .model-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    padding: 0 20px 40px;
  }

  .filters { justify-content: center; flex-wrap: wrap; overflow: visible; }

  .modal-backdrop {
    align-items: center;
    padding: 20px;
  }

  .modal-sheet {
    border-radius: 20px;
    max-height: 90vh;
    max-width: 420px;
    padding: 20px;
    animation: fadeIn 0.24s ease;
  }

  .modal-handle { display: none; }

  .modal-drag-zone { display: none; }

  .modal-thumb {
    border-radius: 14px;
    max-height: 380px;
    aspect-ratio: 4 / 5;
  }

  .modal-hero-overlay {
    position: static;
    background: none;
    padding: 16px 0 0;
    text-align: center;
    pointer-events: auto;
  }

  .modal-hero-overlay h3 {
    color: inherit;
    font-size: 1.25rem;
    -webkit-line-clamp: unset;
    display: block;
  }

  .modal-close {
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.5);
    border: none;
    backdrop-filter: blur(8px);
  }

  .modal-footer {
    padding: 16px 0 0;
    border-top: none;
  }

  @keyframes fadeIn {
    from { transform: scale(0.96); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
  }

  .modal-actions {
    flex-direction: row;
  }
}

@media (min-width: 900px) {
  .model-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .model-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 20px;
    padding: 0 24px 48px;
  }
}

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