/* Mobile-first: full-screen overlay with a solid background. */
.profile-overlay {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 9500;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  font-family: system-ui, sans-serif;
  overflow-y: auto;
}

.profile-modal {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.profile-back {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 6px 10px;
  font: inherit;
  font-size: 16px;
  cursor: pointer;
  color: #1e88e5;
}

.profile-title {
  font-weight: 600;
  font-size: 16px;
  flex: 1 1 auto;
}

.profile-count,
.profile-likes {
  color: #666;
  font-size: 14px;
  font-weight: 400;
}

.profile-body {
  padding: 16px;
  flex: 1 1 auto;
}

.profile-state {
  padding: 48px 24px;
  text-align: center;
  color: #555;
}

.profile-state .profile-retry {
  margin-top: 16px;
  appearance: none;
  background: #1e88e5;
  color: #fff;
  border: 0;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.profile-tile {
  appearance: none;
  background: #eee;
  border: 0;
  padding: 0;
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 6px;
  cursor: pointer;
}

.profile-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}

/* Desktop: centered card on a dimmed backdrop. */
@media (min-width: 641px) {
  .profile-overlay {
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    padding: 32px;
  }
  .profile-modal {
    flex: 0 0 auto;
    width: min(720px, 100%);
    max-height: 80vh;
    overflow-y: auto;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}
