/* Small helpers that Tailwind's CDN build doesn't cover */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

.masonry { columns: 2 160px; column-gap: 0.75rem; }
@media (min-width: 640px)  { .masonry { columns: 3 200px; } }
@media (min-width: 1024px) { .masonry { columns: 4 220px; } }
.masonry > * { break-inside: avoid; margin-bottom: 0.75rem; display: block; }

.chip-scroll { scrollbar-width: none; }
.chip-scroll::-webkit-scrollbar { display: none; }

.skeleton {
  background: linear-gradient(90deg, #171717 25%, #262626 50%, #171717 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

img { max-width: 100%; height: auto; }

.app-logo-link {
  min-width: 0;
}

.app-logo-mark {
  width: 2rem;
  height: 2rem;
  flex: none;
  display: block;
  object-fit: cover;
  border-radius: 0.75rem;
}

.app-logo-text {
  width: clamp(6.75rem, 30vw, 8rem);
  height: auto;
  flex: none;
  display: block;
}

header {
  padding-top: var(--safe-top);
}

header > div,
#app {
  padding-left: max(1rem, var(--safe-left));
  padding-right: max(1rem, var(--safe-right));
}

#app {
  padding-bottom: 6rem;
}

#toast {
  bottom: 5rem;
  left: calc(50% + (var(--safe-left) - var(--safe-right)) / 2);
  max-width: calc(100vw - max(2rem, var(--safe-left)) - max(2rem, var(--safe-right)));
}

.install-prompt {
  left: max(0.75rem, var(--safe-left));
  right: max(0.75rem, var(--safe-right));
  bottom: 5rem;
  padding-bottom: 0;
}

.install-prompt-close {
  width: 2rem;
  height: 2rem;
  line-height: 1;
  font-size: 1.25rem;
}

.install-prompt-logo {
  width: 2.5rem;
  height: 2.5rem;
  flex: none;
  display: block;
  object-fit: cover;
  border-radius: 0.9rem;
}

.auth-screen {
  min-height: calc(100dvh - 9rem - var(--safe-top));
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  max-width: 97%;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.profile-carousel {
  overscroll-behavior-x: contain;
  aspect-ratio: 4 / 5;
  width: 100%;
  max-height: min(72vh, 1000px);
  background: #000;
}

.profile-carousel-slide {
  min-width: 100%;
  height: 100%;
}

.profile-carousel-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.45);
  border: 1px solid rgb(0 0 0 / 0.25);
  box-shadow: 0 1px 5px rgb(0 0 0 / 0.35);
  transition: width 160ms ease, background-color 160ms ease;
}

.profile-carousel-dot.is-active {
  width: 1.35rem;
  background: #10b981;
}

.profile-carousel-chevron {
  position: absolute;
  top: 50%;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  color: #f5f5f5;
  background: rgb(10 10 10 / 0.32);
  border: 1px solid rgb(255 255 255 / 0.18);
  box-shadow: 0 8px 20px rgb(0 0 0 / 0.24);
  backdrop-filter: blur(8px);
  transform: translateY(-50%);
  transition: background-color 160ms ease, border-color 160ms ease;
}

.profile-carousel-chevron svg {
  flex: none;
}

.profile-carousel-chevron:hover {
  background: rgb(10 10 10 / 0.52);
  border-color: rgb(255 255 255 / 0.32);
}

.profile-carousel-chevron-left {
  left: 0.75rem;
}

.profile-carousel-chevron-right {
  left: auto;
  right: 0.75rem;
}

.profile-stat-card {
  min-width: 0;
}

.profile-stat-card > div {
  max-width: 100%;
}

.profile-stat-card-value {
  overflow-wrap: anywhere;
  line-height: 1.15;
}

.app-select {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #a3a3a3 50%),
    linear-gradient(135deg, #a3a3a3 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  line-height: 1.35;
}

.app-select:focus {
  box-shadow: 0 0 0 3px rgb(16 185 129 / 0.18);
}

.profile-form-tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  padding: 0.2rem;
  border: 1px solid #262626;
  border-radius: 0.85rem;
  background: #171717;
  scrollbar-width: none;
}

.profile-form-tabs::-webkit-scrollbar {
  display: none;
}

.profile-form-tab {
  flex: 1 0 0;
  min-height: 2.5rem;
  padding: 0.55rem 0.8rem;
  border: 0;
  border-radius: 0.65rem;
  color: #a3a3a3;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  background: transparent;
  white-space: nowrap;
}

.profile-form-tab.is-active {
  color: #0a0a0a;
  background: #10b981;
}

.search-select {
  position: relative;
}

.search-select-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.search-select-button {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 2.5rem 0.5rem 0.75rem;
  border: 1px solid #404040;
  border-radius: 0.75rem;
  color: #f5f5f5;
  font-size: 0.875rem;
  line-height: 1.35;
  text-align: left;
  background:
    linear-gradient(45deg, transparent 50%, #a3a3a3 50%) calc(100% - 18px) 50% / 6px 6px no-repeat,
    linear-gradient(135deg, #a3a3a3 50%, transparent 50%) calc(100% - 12px) 50% / 6px 6px no-repeat,
    #171717;
}

.search-select-button:focus {
  outline: none;
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgb(16 185 129 / 0.18);
}

.search-select-sheet {
  width: 100%;
  max-height: min(78dvh, 680px);
  display: flex;
  flex-direction: column;
  border: 1px solid #262626;
  border-radius: 1rem 1rem 0 0;
  background: #0a0a0a;
  overflow: hidden;
}

.search-select-options {
  flex: 1;
  overflow-y: auto;
  padding: 0.35rem;
}

.search-select-option {
  width: 100%;
  min-height: 46px;
  padding: 0.75rem 0.9rem;
  border-radius: 0.75rem;
  color: #e5e5e5;
  text-align: left;
  font-size: 0.95rem;
}

.search-select-option.is-active {
  color: #0a0a0a;
  background: #10b981;
  font-weight: 800;
}

.location-sheet {
  width: 100%;
}

@media (min-width: 640px) {
  #toast {
    bottom: max(1.5rem, var(--safe-bottom));
  }

  .install-prompt {
    left: auto;
    right: max(1.25rem, var(--safe-right));
    bottom: max(1.25rem, var(--safe-bottom));
  }

  .location-sheet {
    max-width: 440px;
    border: 1px solid #262626;
    border-radius: 1rem;
    overflow: hidden;
  }

  .search-select-sheet {
    max-width: 440px;
    border-radius: 1rem;
    background: #171717;
  }
}

@media (max-width: 639px) {
  .auth-screen {
    min-height: calc(100dvh - 8rem - var(--safe-top));
    align-items: center;
    padding-top: 0;
  }

  .auth-card {
    max-width: 97%;
  }

  input,
  textarea,
  select {
    font-size: 16px;
  }

  .app-select {
    font-size: 16px;
    min-height: 50px;
    padding-top: 0.8rem;
    padding-bottom: 0.8rem;
    border-radius: 0.9rem;
    background-position:
      calc(100% - 22px) 50%,
      calc(100% - 15px) 50%;
    background-size: 7px 7px, 7px 7px;
  }

  .search-select-button {
    min-height: 50px;
    border-radius: 0.9rem;
    font-size: 16px;
    background-position:
      calc(100% - 22px) 50%,
      calc(100% - 15px) 50%,
      0 0;
    background-size:
      7px 7px,
      7px 7px,
      auto;
  }

  .front-filter-grid {
    padding: 0.25rem 0;
  }

  .front-filter-grid label {
    font-size: 0.78rem;
    margin-bottom: 0.35rem;
  }

  .front-filter-grid .app-select {
    background-color: #171717;
    border-color: #404040;
    box-shadow: 0 1px 0 rgb(255 255 255 / 0.04) inset;
  }

  .front-filter-grid .app-select:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 4px rgb(16 185 129 / 0.18);
  }

  .location-modal {
    align-items: stretch;
  }

  .location-sheet {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding-top: var(--safe-top);
  }

  .location-sheet > .p-4 {
    flex: 1;
  }

  body.profile-view > header {
    display: none;
  }

  body.profile-view {
    width: 100%;
    overflow-x: hidden;
    touch-action: pan-y;
  }

  body.profile-view #app {
    max-width: none;
    width: 100%;
    overflow-x: hidden;
    padding-top: 0;
    padding-left: 0;
    padding-right: 0;
  }

  body.profile-view .profile-carousel,
  body.profile-view .chip-scroll {
    touch-action: pan-x pan-y;
  }

  /* Keep the single-column listing layout locked to the viewport so an
     overflow child (e.g. the thumbnail strip) can't blow the track wider
     than the screen and get clipped by overflow-x: hidden. */
  body.profile-view #app > .grid {
    grid-template-columns: minmax(0, 1fr);
  }

  body.profile-view #app > .grid > * {
    min-width: 0;
  }

  /* Compact fixed-size square thumbnails: up to 6 (the max per listing) fit
     across the screen, and a small number stays normal-sized and left-aligned
     instead of stretching to fill the row. */
  body.profile-view .profile-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    overflow: hidden;
  }

  body.profile-view .profile-thumbs .profile-carousel-thumb {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
  }

  body.profile-view .profile-carousel {
    width: 100vw;
    max-width: 100vw;
    aspect-ratio: 4 / 5;
    max-height: none;
    background: #000;
  }

  body.profile-view .profile-carousel-slide {
    width: 100vw;
    min-width: 100vw;
    max-width: 100vw;
    height: 100%;
    object-fit: cover;
  }

  body.profile-view #mobile-bottom-nav {
    display: none;
  }

  body.profile-view .profile-cover-media {
    height: auto;
    margin-top: 0;
    padding-top: var(--safe-top);
    background: #000;
  }

  .profile-carousel-chevron-left {
    left: max(0.5rem, var(--safe-left));
  }

  .profile-carousel-chevron-right {
    right: max(0.5rem, var(--safe-right));
  }

  .profile-carousel-chevron {
    width: 2.25rem;
    height: 2.25rem;
  }

  .profile-stat-card {
    min-height: 4rem;
    padding: 0.4rem 0.2rem;
  }

  .profile-stat-card .tracking-wide {
    letter-spacing: 0;
    font-size: 0.6rem;
    line-height: 1.1;
  }

  .profile-stat-card-value {
    font-size: 0.8rem;
  }

  .profile-actionbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    padding: 0.6rem max(0.75rem, var(--safe-right)) calc(0.6rem + var(--safe-bottom)) max(0.75rem, var(--safe-left));
    background: rgb(10 10 10 / 0.94);
    border-top: 1px solid #262626;
    backdrop-filter: blur(12px);
  }

  .profile-actionbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 44px;
    border-radius: 0.75rem;
    border: 1px solid #404040;
    color: #e5e5e5;
    font-size: 0.875rem;
    font-weight: 700;
  }

  .profile-actionbar-primary {
    background: #10b981;
    border-color: #10b981;
    color: #0a0a0a;
  }
}
