/* ================================================================
   twxgram â€” Fullscreen Reel Feed + White Minimal  |  Built by Rahmony
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ----------------------------------------------------------------
   Design Tokens
   ---------------------------------------------------------------- */
:root {
  --bg:        #ffffff;
  --bg-2:      #f7f7f7;
  --bg-3:      #ededed;
  --border:    #e8e8e8;
  --border-2:  #f0f0f0;
  --text-1:    #0f0f0f;
  --text-2:    #555;
  --text-3:    #999;
  --accent:    #E1306C;
  --verified:  #0095F6;
  --ig-grad:   linear-gradient(45deg,#f09433,#e6683c,#dc2743,#cc2366,#bc1888);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --nav-h:     50px;
  --font:      'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --sh-xs:     0 1px 2px rgba(0,0,0,.04);
  --sh-sm:     0 2px 8px rgba(0,0,0,.07);
  --sh-md:     0 4px 20px rgba(0,0,0,.09);
  --ease:      cubic-bezier(.4,0,.2,1);
  --vh: 100svh;
}

/* ----------------------------------------------------------------
   Reset
   ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  font-size: 14px;
  /* Always reserve scrollbar width â€” prevents layout jump */
  scrollbar-gutter: stable;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
/* Feed page: true black â€” no white flash between reels */
body.page-feed {
  background: #000;
  color-scheme: dark;
}
a      { color: inherit; text-decoration: none; }
img    { display: block; max-width: 100%; }
button { font-family: var(--font); cursor: pointer; border: none; background: none;
         touch-action: manipulation; }
video  { display: block; }
input  { font-family: var(--font); font-size: 16px; }

::-webkit-scrollbar { width: 0; height: 0; }

/* ----------------------------------------------------------------
   Utility
   ---------------------------------------------------------------- */
.hidden   { display: none !important; }
.sr-only  { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }

/* ================================================================
   NAVBAR
   ================================================================ */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  height: var(--nav-h);
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid rgba(0,0,0,.07);
  will-change: transform;
  transition: transform 0.22s var(--ease), background 0.2s;
}
.navbar.nav-hidden { transform: translateY(-100%); }
.page-feed .navbar {
  background: rgba(255,255,255,.92);
  border-bottom-color: rgba(0,0,0,.06);
}

.nav-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Logo */
.nav-logo { display: flex; align-items: center; flex-shrink: 0; padding: 6px 0; text-decoration: none; }
.logo-twx  { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.5px; color: var(--text-1); }
.logo-gram {
  font-size: 1.15rem; font-weight: 700; letter-spacing: -0.5px;
  background: var(--ig-grad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
/* Plain brand title â€” no color, no gradient */
.nav-logo-text {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.6px;
  color: #111;
  font-family: var(--font);
  -webkit-text-fill-color: #111;
}
/* legacy .logo-accent used in reel cards */
.logo-accent { background: var(--ig-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* Desktop search â€” flex-1, hidden on mobile */
.nav-search-desktop {
  flex: 1; min-width: 0; position: relative;
}
@media (max-width: 639px) { .nav-search-desktop { display: none; } }

/* Search box */
.nav-search-wrap { flex: 1; position: relative; min-width: 0; }
.nav-search {
  display: flex; align-items: center;
  background: #f5f5f5; border: 1px solid #e8e8e8;
  border-radius: 10px; height: 36px; overflow: hidden;
}
.nav-search input {
  flex: 1; min-width: 0; border: none; background: transparent;
  padding: 0 10px; color: var(--text-1); outline: none; font-size: .87rem;
}
.nav-search input::placeholder { color: #aaa; }
.search-icon {
  width: 36px; height: 36px; flex-shrink: 0;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E")
    center / 16px no-repeat;
}
[x-cloak] { display: none !important; }
.search-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; border: 1px solid #ececec;
  border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.10);
  z-index: 300; overflow: hidden; max-height: 320px; overflow-y: auto;
}
.search-dropdown-drawer { position: static; border-radius: 10px; margin-top: 6px; }
.sd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; cursor: pointer;
  border-bottom: 1px solid #f0f0f0; min-height: 48px;
  transition: background .1s;
}
.sd-item:last-child { border-bottom: none; }
.sd-item:active,.sd-item:hover { background: #f8f8f8; }
.sd-avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  flex-shrink: 0; border: 1px solid #ececec; background: #f0f0f0;
}
.sd-info { min-width: 0; }
.sd-name   { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-handle { font-size: .75rem; color: #aaa; }

/* â”€â”€ Hamburger button â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.nav-burger {
  display: flex; flex-direction: column; justify-content: center;
  gap: 5px; width: 40px; height: 40px; padding: 8px;
  border: none; background: transparent; cursor: pointer;
  border-radius: 8px; flex-shrink: 0; margin-left: auto;
  transition: background .15s;
}
.nav-burger:hover { background: #f5f5f5; }
.nav-burger span {
  display: block; height: 2px; border-radius: 2px;
  background: var(--text-1); transition: transform .22s, opacity .22s;
}
/* X when open */
body.drawer-open .nav-burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.drawer-open .nav-burger span:nth-child(2) { opacity: 0; transform: scaleX(0); }
body.drawer-open .nav-burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* â”€â”€ Slide drawer â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.nav-drawer { position: fixed; inset: 0; z-index: 500; pointer-events: none; }
.nav-drawer.open { pointer-events: all; }

.drawer-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.35);
  opacity: 0; transition: opacity .25s ease;
  backdrop-filter: blur(2px);
}
.nav-drawer.open .drawer-backdrop { opacity: 1; }

.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(300px, 82vw);
  background: #fff;
  box-shadow: -4px 0 24px rgba(0,0,0,.12);
  display: flex; flex-direction: column; gap: 0;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
}
.nav-drawer.open .drawer-panel { transform: translateX(0); }

.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid #ececec;
  font-size: 1.1rem; font-weight: 700; letter-spacing: -.4px;
}
.drawer-close {
  width: 34px; height: 34px; border: none; background: #f5f5f5;
  border-radius: 50%; cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center; color: #555;
  transition: background .15s;
}
.drawer-close:hover { background: #ececec; }

.drawer-search-wrap { padding: 14px 18px 0; position: relative; }

.drawer-nav {
  display: flex; flex-direction: column;
  padding: 12px 10px;
}
.drawer-link {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 12px; border-radius: 10px;
  color: var(--text-1); text-decoration: none; font-size: .92rem; font-weight: 500;
  transition: background .12s;
}
.drawer-link:hover,.drawer-link:active { background: #f5f5f5; }
.drawer-link svg { opacity: .6; flex-shrink: 0; }


.nav-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 14px;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.4px;
  flex-shrink: 0;
  padding: 6px 0;
}
.logo-gram   { color: var(--text-1); transition: color 0.2s; }
.logo-accent {
  background: var(--ig-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Search */
.nav-search-wrap { flex: 1; position: relative; min-width: 0; }
.nav-search {
  display: flex;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 34px;
  overflow: hidden;
}
.nav-search input {
  flex: 1; min-width: 0;
  border: none; background: transparent;
  padding: 0 10px;
  color: var(--text-1); outline: none;
}
.nav-search input::placeholder { color: var(--text-3); font-size: 0.85rem; }
.search-icon {
  width: 34px; height: 34px; flex-shrink: 0;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E")
    center / 16px no-repeat;
}

/* Alpine.js search dropdown */
[x-cloak] { display: none !important; }
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--sh-md);
  z-index: 300;
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}
.sd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-2);
  min-height: 48px;
  touch-action: manipulation;
  transition: background 0.1s;
}
.sd-item:last-child { border-bottom: none; }
.sd-item:active, .sd-item:hover { background: var(--bg-2); }
.sd-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--bg-3);
}
.sd-info { min-width: 0; }
.sd-name   { font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-handle { font-size: 0.75rem; color: var(--text-3); }

/* ================================================================
   PAGE BODY
   ================================================================ */
.page-body { min-height: 100svh; }
.page-feed.page-body { overflow: hidden; padding-top: 0; }
/* Non-feed pages still need top padding */
body:not(.page-feed) .page-body { padding-top: var(--nav-h); }

/* ================================================================
   TABS BAR
   ================================================================ */
.tabs-bar {
  position: fixed;
  /* sits below the overlay navbar on feed */
  bottom: 0; left: 0; right: 0;
  z-index: 150;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-2);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior-x: contain;
}
.tabs-bar::-webkit-scrollbar { display: none; }
.tabs-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  max-width: 640px;
  margin: 0 auto;
  width: max-content;
  min-width: 100%;
  /* safe area for iPhone home bar */
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 14px;
  min-height: 36px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-2);
  border: 1px solid var(--border);
  background: var(--bg);
  white-space: nowrap;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: background 0.15s, color 0.15s;
  -webkit-user-select: none;
  user-select: none;
}
.tab-btn.active {
  background: var(--text-1);
  color: #fff;
  border-color: var(--text-1);
}
.tab-btn:active { opacity: 0.7; }

/* ================================================================
   MOBILE FULLSCREEN FEED  (â‰¤ 639px)
   ================================================================ */

/* â”€â”€ Skeleton loader (pure CSS shimmer, zero deps) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
@keyframes sk-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.sk-card {
  width: 100%;
  background: linear-gradient(90deg,#e8e8e8 25%,#f5f5f5 50%,#e8e8e8 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
/* Mobile: full-screen skeleton cards */
@media (max-width: 639px) {
  .sk-card { height: 100svh; border-radius: 0; }
}
/* Desktop: masonry skeleton cards */
@media (min-width: 640px) {
  .sk-card { aspect-ratio: 9/16; min-height: 280px; }
}
/* Hide skeletons once feed has real cards */
.feed-wrap:has(.reel-card) .sk-card,
.feed-wrap:has(.masonry-item) .sk-card { display: none; }

/* â”€â”€ Feed empty / error state â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.feed-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60svh;
  gap: 12px;
  padding: 40px 24px;
  text-align: center;
}
.feed-empty-icon { font-size: 48px; line-height: 1; }
.feed-empty h2   { font-size: 1.2rem; font-weight: 600; color: var(--text-1); margin: 0; }
.feed-empty p    { font-size: .9rem;  color: var(--text-2); margin: 0; max-width: 260px; }

@media (max-width: 639px) {
  .feed-wrap {
    position: fixed;
    top: 0; left: 0; right: 0;
    /* Height set by JS via --vh var */
    height: var(--vh);
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    /* Momentum scrolling on iOS */
    -webkit-overflow-scrolling: touch;
    padding: 0;
    max-width: none;
    margin: 0;
    background: #000;
    z-index: 10;
  }

  .reel-card {
    position: relative;
    width: 100%;
    height: var(--vh);
    scroll-snap-align: start;
    /* Force scroll to stop at each card */
    scroll-snap-stop: always;
    border: none;
    border-radius: 0;
    margin: 0;
    box-shadow: none;
    background: #000;
    /* Contain repaints */
    contain: layout style;
  }

  .reel-media {
    position: absolute;
    inset: 0;
    aspect-ratio: unset;
    background: #000;
  }
  .reel-media img,
  .reel-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* Right-side action buttons */
  .reel-actions {
    position: absolute;
    right: 8px;
    bottom: 100px;
    flex-direction: column;
    gap: 14px;
    padding: 0;
    background: none;
    border: none;
    z-index: 20;
    align-items: center;
  }
  .act-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #fff;
    font-size: 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: transform 0.1s, opacity 0.1s;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .act-btn:active { transform: scale(0.84); opacity: .75; }
  .act-btn.reacted { color: #ff4d6d; }
  .act-btn svg { width: 20px; height: 20px; }
  .act-count { font-size: .6rem; font-weight: 600; color: rgba(255,255,255,.8); line-height: 1; }
  .act-profile { display: none; }

  /* Reel overlay â€” deep gradient for text readability, no noise */
  .reel-overlay {
    background: linear-gradient(
      to bottom,
      rgba(0,0,0,.28) 0%,
      rgba(0,0,0,0)   22%,
      rgba(0,0,0,0)   42%,
      rgba(0,0,0,.55) 68%,
      rgba(0,0,0,.88) 100%
    );
  }
  .reel-ol-top {
    display: flex;
    justify-content: flex-end;
    pointer-events: auto;
  }
  .reel-ol-bottom {
    padding-right: 64px;
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
    pointer-events: auto;
  }
  .reel-username-text { font-size: .88rem; font-weight: 600; }
  .reel-caption-text  { font-size: .8rem; opacity: .8; line-height: 1.45; }

  /* Mute button — top right of video */
  .btn-mute {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
  }

/* ================================================================
   DESKTOP FEED  (≥ 640px) — premium centered phone-frame layout
   ================================================================ */
@media (min-width: 640px) {
  /* Dark base — matches mobile dark mode */
  body.page-feed { background: #0c0c0c; }
  body.page-feed .page-body {
    background: #0c0c0c;
    padding-top: var(--nav-h);
    overflow: visible;
  }

  /* Navbar adapts to dark context on desktop feed */
  body.page-feed .navbar {
    background: rgba(12,12,12,.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(255,255,255,.07);
  }
  body.page-feed .navbar .logo-gram { color: #fff; text-shadow: none; }
  body.page-feed .nav-search-wrap   { display: flex; }
  body.page-feed .nav-link,
  body.page-feed .nav-icon-btn      { color: rgba(255,255,255,.75); }

  /* Centered phone-frame feed */
  .feed-wrap {
    max-width: 430px;
    margin: 0 auto;
    padding: 24px 0 80px;
    overflow-x: hidden;
  }

  /* Tabs bar */
  .tabs-bar {
    position: sticky;
    top: var(--nav-h);
    background: rgba(12,12,12,.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: none;
    border-bottom: 1px solid rgba(255,255,255,.08);
    z-index: 90;
  }
  .tabs-inner { padding-bottom: 8px; }
  .tab-btn { color: rgba(255,255,255,.5); }
  .tab-btn.active { color: #fff; }

  /* Reel card — rounded, floating, dark */
  .reel-card {
    position: relative;
    margin: 0 auto 28px;
    max-width: 430px;
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 8px 40px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.4);
    background: #111;
    contain: layout style;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }
  .reel-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 56px rgba(0,0,0,.65), 0 4px 16px rgba(0,0,0,.5);
  }

  /* Media — 9:16 aspect ratio */
  .reel-media {
    position: relative;
    aspect-ratio: 9 / 16;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .reel-actions {
    display: flex;
    flex-direction: row;
    gap: 4px;
    padding: 6px 10px;
    background: #fff;
    border-top: none;
    position: relative;
  }
  .act-btn {
    width: 34px; height: 34px;
    border-radius: 0;
    border: none;
    background: transparent;
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    transition: transform 0.1s;
    flex-shrink: 0;
  }
  .act-btn:active { transform: scale(0.85); }
  .act-btn.reacted { color: #e1306c; }
}

/* ================================================================
   SHARED REEL CARD INTERNALS
   ================================================================ */
/* Thumbnail â€” sits on top, fades to 0 when video plays */
.reel-thumb {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 1;
  transition: opacity 0.25s;
  z-index: 3;
}
.reel-thumb.loading { opacity: 0; }
/* Video â€” always rendered, hidden via opacity until playing.
   NEVER use display:none on video â€” iOS Safari loses the frame. */
.reel-video {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.2s;
}
.reel-video.playing {
  opacity: 1;
  pointer-events: auto;
}
/* Play button â€” traditional: dark frosted circle, white triangle */
.play-btn {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  width: 58px; height: 58px;
  background: rgba(0,0,0,0.48);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.18s;
  pointer-events: auto;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.play-btn svg { margin-left: 3px; } /* optical center for triangle */
.play-btn:active { transform: translate(-50%, -50%) scale(0.85); }
.play-btn.hidden { opacity: 0; pointer-events: none; }
/* Hide while actively scrolling â€” reappears 350ms after stop */
.is-scrolling .play-btn {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.75);
}

/* Gradient overlay */
.reel-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,.25) 0%,
    rgba(0,0,0,0)   30%,
    rgba(0,0,0,0)   55%,
    rgba(0,0,0,.7)  100%
  );
  pointer-events: none;
  z-index: 5;
}
.reel-ol-top {
  display: flex;
  justify-content: flex-end;
  pointer-events: none;  /* children re-enable */
}
.reel-ol-bottom { pointer-events: auto; padding-bottom: 12px; }

.type-pill { display: none; } /* removed per design */

.reel-user-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  min-height: 34px;
  pointer-events: auto;
  touch-action: manipulation;
  text-decoration: none;
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(255,255,255,.1);
}
.reel-avatar {
  display: block;           /* kill inline-block baseline gap */
  width: 28px; height: 28px;
  min-width: 28px;          /* never shrink in flex */
  max-width: 28px;          /* override global img { max-width:100% } */
  max-height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(255,255,255,0.85);
  flex-shrink: 0;
  background: rgba(255,255,255,0.15);
}
.reel-avatar-placeholder {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: rgba(255,255,255,0.2);
  border: 1.5px solid rgba(255,255,255,0.7);
  flex-shrink: 0;
}
.reel-username-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.v-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px; height: 13px;
  background: var(--verified);
  color: #fff;
  border-radius: 50%;
  font-size: 0.5rem;
  font-weight: 700;
  margin-left: 2px;
  vertical-align: middle;
}
.reel-caption-text {
  font-size: 0.76rem;
  color: rgba(255,255,255,.9);
  line-height: 1.4;
  margin-bottom: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 3px rgba(0,0,0,.4);
}
/* Stat row â€” clean text, readable via gradient, no pill noise */
.reel-stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 5px;
}
.reel-stat-row span {
  font-size: .72rem;
  font-weight: 500;
  color: rgba(255,255,255,.82);
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
  white-space: nowrap;
}
.reel-date { opacity: .65; }

/* Video mute toggle */
.btn-mute {
  position: absolute;
  top: 50px; right: 12px;
  z-index: 20;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(6px);
  border: none;
  color: #fff;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}

/* Skeleton */
.reel-skeleton {
  margin: 0 12px 16px;
  border-radius: var(--radius-lg);
  overflow: hidden;
}
@media (max-width: 639px) {
  .reel-skeleton {
    height: var(--vh);
    margin: 0;
    border-radius: 0;
  }
}
.reel-skeleton-media {
  aspect-ratio: 9 / 16;
  background: linear-gradient(90deg, #1a1a1a 25%, #2a2a2a 50%, #1a1a1a 75%);
  background-size: 300% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
@media (max-width: 639px) { .reel-skeleton-media { height: var(--vh); aspect-ratio: unset; } }
.reel-skeleton-bar { height: 0; }
@media (min-width: 640px) { .reel-skeleton-bar { height: 52px; background: var(--bg-2); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.load-more-trigger { height: 1px; }
.loading-spinner { font-size: 0.78rem; color: var(--text-3); text-align: center; padding: 12px; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }

/* ================================================================
   EMPTY STATE
   ================================================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}
.empty-state p     { font-size: 0.88rem; font-weight: 500; margin-bottom: 6px; color: var(--text-2); }
.empty-state small { font-size: 0.75rem; display: block; margin-bottom: 14px; }
.empty-state code  {
  display: inline-block;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.72rem;
  font-family: monospace;
  color: var(--text-2);
}

/* ================================================================
   PROFILE PAGE
   ================================================================ */
.profile-page {
  max-width: 935px;
  margin: 0 auto;
  padding: 0 12px 60px;
  overflow-x: hidden;
}
.profile-header {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border-2);
}
.profile-avatar-wrap { flex-shrink: 0; }
.profile-avatar {
  width: 86px; height: 86px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}
.profile-meta       { flex: 1; min-width: 0; }
.profile-handle-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.profile-handle     { font-size: 1rem; font-weight: 400; }
.profile-name       { font-size: 0.82rem; font-weight: 600; margin-bottom: 6px; }
.profile-bio        { font-size: 0.8rem; color: var(--text-2); line-height: 1.55; margin-bottom: 10px; white-space: pre-wrap; }
.verified-badge     { display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;background:var(--verified);color:#fff;border-radius:50%;font-size:.6rem;font-weight:700;flex-shrink:0; }
.premium-badge      { font-size: 0.85rem; }
.profile-stats      { display:flex;gap:18px;margin-bottom:12px;flex-wrap:wrap; }
.stat-item          { font-size: 0.8rem; color: var(--text-2); white-space: nowrap; }
.stat-item strong   { font-weight: 700; color: var(--text-1); }
.profile-links      { display:flex;gap:6px;flex-wrap:wrap;margin-top:4px; }
.profile-link-btn   { display:inline-flex;align-items:center;gap:4px;font-size:.74rem;font-weight:500;padding:6px 11px;min-height:32px;border-radius:6px;border:1px solid var(--border);color:var(--text-2);background:var(--bg);touch-action:manipulation;transition:background .15s; }
.profile-link-btn:hover,.profile-link-btn:active { background: var(--bg-2); }
.tg-link  { color:#229ED9;border-color:#229ED9; }
.tg-link:active,.tg-link:hover  { background:#e8f4ff; }
.sub-link { color:var(--accent);border-color:var(--accent); }
.sub-link:active,.sub-link:hover { background:#fff0f5; }

/* Profile tabs */
.profile-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-2);
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: 8px;
}
.profile-tabs::-webkit-scrollbar { display: none; }
.profile-tab {
  flex: 1;
  min-width: 80px;
  text-align: center;
  padding: 11px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  touch-action: manipulation;
  transition: color 0.15s, border-color 0.15s;
}
.profile-tab:hover  { color: var(--text-2); }
.profile-tab.active { color: var(--text-1); border-bottom-color: var(--text-1); font-weight: 600; }

/* Masonry Grid */
.masonry-grid {
  columns: 3;
  column-gap: 3px;
  width: 100%;
}
.masonry-item {
  break-inside: avoid;
  margin-bottom: 3px;
  position: relative;
  overflow: hidden;
  background: var(--bg-3);
  cursor: pointer;
  isolation: isolate;
  border-radius: 2px;
  touch-action: manipulation;
}
.masonry-item img { width:100%; display:block; transition:transform 0.22s; }
.masonry-item:hover img,.masonry-item:active img { transform: scale(1.04); }
.masonry-overlay {
  position:absolute;inset:0;
  background:rgba(0,0,0,0);
  display:flex;align-items:center;justify-content:center;gap:16px;
  opacity:0;
  transition:background 0.18s,opacity 0.18s;
}
.masonry-item:hover .masonry-overlay,.masonry-item:active .masonry-overlay { background:rgba(0,0,0,.28);opacity:1; }
.masonry-overlay span { color:#fff;font-size:.78rem;font-weight:600;display:flex;align-items:center;gap:3px;text-shadow:0 1px 3px rgba(0,0,0,.5); }
.vid-badge { position:absolute;top:6px;right:6px;background:rgba(0,0,0,.5);color:#fff;font-size:.58rem;font-weight:700;padding:2px 5px;border-radius:4px;text-transform:uppercase;pointer-events:none; }

/* Lightbox */
/* Fullscreen photo lightbox */
.lightbox { display:none;position:fixed;inset:0;z-index:9000;background:rgba(0,0,0,.95);overscroll-behavior:contain; }
.lightbox.open { display:flex;align-items:center;justify-content:center; }
.lightbox-inner { position:relative;width:100%;height:100%;display:flex;align-items:center;justify-content:center; }
#lightboxImg { max-width:100%;max-height:100svh;object-fit:contain;display:block;user-select:none;-webkit-user-drag:none; }
/* Close - top right */
.lb-close { position:absolute;top:14px;right:14px;z-index:10;width:36px;height:36px;background:rgba(0,0,0,.5);backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);border:none;color:#fff;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:1rem;cursor:pointer;touch-action:manipulation; }
/* Counter - top left */
.lb-counter { position:absolute;top:17px;left:14px;z-index:10;font-size:.75rem;font-weight:600;color:rgba(255,255,255,.7);background:rgba(0,0,0,.45);backdrop-filter:blur(6px);padding:4px 10px;border-radius:20px; }
/* Bottom overlay */
.lb-bottom {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 10;
  padding: 40px 16px 28px;
  background: linear-gradient(to top, rgba(0,0,0,.92) 0%, rgba(0,0,0,.6) 50%, rgba(0,0,0,0) 100%);
}
.lb-user-row { display:flex;align-items:center;gap:9px;text-decoration:none;margin-bottom:7px; }
.lb-avatar { width:34px;height:34px;border-radius:50%;object-fit:cover;border:2px solid rgba(255,255,255,.4);flex-shrink:0; }
.lb-username { font-size:.86rem;font-weight:700;color:#fff; }
.lb-stats { font-size:.75rem;font-weight:600;color:rgba(255,255,255,.9);margin:0 0 7px;letter-spacing:.01em; }
.lb-caption { font-size:.75rem;color:rgba(255,255,255,.75);margin:0;line-height:1.45;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden; }
/* Prev / Next */
.lb-nav { position:absolute;top:50%;transform:translateY(-50%);width:40px;height:40px;background:rgba(0,0,0,.45);backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);border:none;color:#fff;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:1.1rem;cursor:pointer;z-index:10;touch-action:manipulation;transition:background .2s; }
.lb-nav:hover { background:rgba(0,0,0,.7); }
.lb-prev { left:10px; }
.lb-next { right:10px; }

/* Toast */
.toast { position:fixed;bottom:80px;left:50%;transform:translateX(-50%) translateY(12px);background:var(--text-1);color:#fff;font-size:.78rem;font-weight:500;padding:8px 18px;border-radius:20px;box-shadow:var(--sh-md);z-index:2000;opacity:0;pointer-events:none;transition:opacity .2s,transform .2s;white-space:nowrap; }
.toast.show { opacity:1;transform:translateX(-50%) translateY(0); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-2);
  padding: 28px 16px;
  background: var(--bg);
}
.footer-inner {
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.footer-brand { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.footer-logo {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  text-decoration: none;
}
.footer-tagline { font-size: 0.72rem; color: var(--text-3); letter-spacing: 0.3px; }
.footer-divider { width: 32px; height: 1px; background: var(--border-2); }
.footer-credit {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-3);
}
.footer-built { color: var(--text-3); }
.footer-author {
  font-weight: 600;
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.15s;
}
.footer-author:hover { color: var(--accent); }
.footer-copy { font-size: 0.68rem; color: var(--text-3); }

/* Responsive */
@media (max-width: 480px) {
  .masonry-grid  { columns: 2; }
  .profile-header { gap: 14px; padding: 14px 0; }
  .profile-avatar { width: 72px; height: 72px; }
}
@media (min-width: 481px) and (max-width: 768px) { .masonry-grid { columns: 3; } }
@media (min-width: 769px) {
  .masonry-grid { columns: 4; }
  .profile-avatar { width: 110px; height: 110px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ================================================================
   REEL VIEWER OVERLAY  â€” profile reel tap â†’ fullscreen feed
   ================================================================ */
.reel-viewer-ov {
  position: fixed;
  top: var(--nav-h);         /* starts below navbar â€” identical to feed-wrap */
  left: 0; right: 0; bottom: 0;
  z-index: 195;              /* below navbar (200) so header shows on top */
  background: #000;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.4,0,.2,1);
}
.reel-viewer-ov.open { transform: translateY(0); }

/* X close button â€” top-right, same frosted style as mute btn */
.rv-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 10;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: none;
  color: #fff;
  font-size: 1rem;
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
  flex-shrink: 0;
}
.rv-close:hover { background: rgba(0,0,0,.7); }

/* rv-feed is identical to .feed-wrap on index */
.rv-feed {
  width: 100%;
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.rv-feed::-webkit-scrollbar { display: none; }

/* Cards: SAME height as index reel cards */
.rv-feed .reel-card {
  scroll-snap-align: start;
  height: 100svh;
}

/* ================================================================
   PROFILE REEL BANNER  â€” slim overlay above fullscreen reel feed
   ================================================================ */
.profile-reel-banner {
  position: fixed;
  top: var(--nav-h);
  left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(0,0,0,0.60);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  min-height: 48px;
}
.prb-back {
  color: #fff; text-decoration: none; font-size: 1.2rem;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(255,255,255,.1);
  flex-shrink: 0;
}
.prb-avatar {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  border: 1.5px solid rgba(255,255,255,.6); flex-shrink: 0;
}
.prb-info {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px;
  overflow: hidden;
}
.prb-handle { font-size: .85rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prb-name   { font-size: .72rem; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prb-tabs   { display: flex; gap: 6px; flex-shrink: 0; }
.prb-tab {
  padding: 4px 10px; border-radius: 16px; font-size: .78rem; font-weight: 600;
  color: rgba(255,255,255,.7); text-decoration: none; background: rgba(255,255,255,.1);
  transition: background .15s;
}
.prb-tab.active { color: #fff; background: rgba(255,255,255,.25); }
/* Push feed down below banner on mobile reel profile */
body.page-feed #feedContainer { padding-top: 0; }

/* â”€â”€ Profile reel back pill â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.profile-reel-back {
  position: fixed;
  top: calc(var(--nav-h) + 10px);
  left: 12px;
  z-index: 300;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
  text-decoration: none;
  text-shadow: none;
  white-space: nowrap;
  pointer-events: auto;
  transition: background .15s;
}
.profile-reel-back:hover { background: rgba(0,0,0,.65); }

.btn-mute {
  width: 34px; height: 34px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.4);
  color: #fff; font-size: .95rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; pointer-events: auto;
  backdrop-filter: blur(4px);
  flex-shrink: 0;
  transition: background .15s;
}
.btn-mute:hover { background: rgba(0,0,0,.6); }

/* ================================================================
   PREMIUM PROFILE HERO  (reference-matched layout)
   ================================================================ */
.profile-page  { max-width: 680px; margin: 0 auto; padding-bottom: 80px; }
.profile-hero  { padding: 20px 16px 0; border-bottom: 1px solid var(--border); }

/* Row 1 â€” Avatar left, stats right */
.profile-top-row {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 14px;
}
.ph-avatar-wrap { flex-shrink: 0; }
.ph-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--bg-3);
  display: block;
}
.ph-avatar-ph {
  width: 80px; height: 80px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  background: var(--bg-3);
  border: 2px solid var(--border);
}
.ph-stats {
  flex: 1;
  display: flex;
  justify-content: space-around;
  gap: 4px;
}
.ph-stat {
  display: flex; flex-direction: column;
  align-items: center; gap: 1px;
  min-width: 0;
}
.ph-stat-n { font-size: 1.05rem; font-weight: 700; color: var(--text-1); letter-spacing: -.3px; }
.ph-stat-l { font-size: .72rem; color: var(--text-3); white-space: nowrap; }

/* Row 2 â€” Name / handle / bio */
.ph-info { margin-bottom: 12px; }
.ph-name-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 2px; }
.ph-name     { font-size: 1rem; font-weight: 700; color: var(--text-1); }
.ph-verified {
  font-size: .65rem; font-weight: 700;
  background: var(--verified); color: #fff;
  border-radius: 50%;
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ph-premium  { font-size: .9rem; line-height: 1; }
.ph-handle   { font-size: .83rem; color: var(--text-3); margin-bottom: 6px; }
.ph-bio      { font-size: .82rem; color: var(--text-2); line-height: 1.5; margin: 0; max-width: 520px; }

/* Row 3 â€” Action buttons */
.ph-actions {
  display: flex; gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.ph-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 16px;
  border-radius: 8px;
  font-size: .82rem; font-weight: 600;
  text-decoration: none;
  transition: opacity .15s, transform .12s;
  white-space: nowrap;
  border: none; cursor: pointer;
}
.ph-btn:hover  { opacity: .85; }
.ph-btn:active { transform: scale(.96); }
.ph-btn-ig  { background: var(--ig-grad); color: #fff; }
.ph-btn-tg  { background: #0088cc; color: #fff; }
.ph-btn-sub { background: #111; color: #fff; }

/* Row 4 â€” Scrollable tab bar */
.ph-tabs {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px;
  padding: 0 16px;
  gap: 0;
  border-bottom: none;   /* hero already has border-bottom */
}
.ph-tabs::-webkit-scrollbar { display: none; }
.ph-tab {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 10px 12px;
  font-size: .8rem; font-weight: 600;
  color: var(--text-3);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color .15s, border-color .15s;
}
.ph-tab.active { color: var(--text-1); border-bottom-color: #111; }
.ph-tab:hover:not(.active) { color: var(--text-2); }
.ph-tab-ct {
  font-size: .72rem; font-weight: 500;
  color: var(--text-3);
  background: var(--bg-2);
  border-radius: 10px;
  padding: 1px 6px;
}
.ph-tab.active .ph-tab-ct { background: #111; color: #fff; }

/* Masonry grid spacing below hero */
.profile-page .masonry-grid { padding: 12px 12px 20px; }
/* Masonry items */
.masonry-item { break-inside: avoid; position: relative; margin-bottom: 4px; overflow: hidden; border-radius: 4px; }

/* ── aspect-container: height locked at render via padding-bottom ratio ─────
   Image is position:absolute inside, so height NEVER changes after paint.
   Zero CLS — no layout shift as images load. Pinterest / reference approach. */
.aspect-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: var(--bg-3);
  border-radius: inherit;
}
.aspect-container > img {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block;
  opacity: 0;
  transition: opacity 0.22s, transform 0.22s !important;
  aspect-ratio: unset !important;
}
.aspect-container > img.loaded { opacity: 1; }
.masonry-item:hover .aspect-container > img,
.masonry-item:active .aspect-container > img { transform: scale(1.04); }

/* ── infinite-grid: flexbox columns for AJAX-loaded items ───────────────────
   Each new card goes into the SHORTEST column (JS-driven) so both columns
   grow evenly — prevents CSS column-count's right-column-only bias. */
#infinite-grid,
#profileInfiniteGrid {
  display: flex;
  gap: 3px;
  padding: 0 12px 40px;
}
.inf-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.inf-col .masonry-item { margin-bottom: 0; }
/* Fade-in on insert */
.inf-card { opacity: 0; transition: opacity 0.25s; }
.inf-card.inf-visible { opacity: 1; }

/* Responsive: below 400px avatar shrinks */
@media (max-width: 400px) {
  .ph-avatar, .ph-avatar-ph { width: 64px; height: 64px; }
  .ph-stat-n { font-size: .95rem; }
  .profile-top-row { gap: 16px; }
}

/* ================================================================
   IGSTARS â€” Creator Directory  (lightweight masonry)
   ================================================================ */
.stars-page { padding-bottom: 60px; }

.stars-hero {
  padding: 18px 14px 12px;
  text-align: center;
  background: linear-gradient(135deg,#0f0f0f 0%,#1a1a2e 60%,#16213e 100%);
  color: #fff;
}
.stars-title {
  font-size: 1.7rem; font-weight: 800; letter-spacing: -1px;
  background: var(--ig-grad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 2px;
}
.stars-sub { font-size: .75rem; color: rgba(255,255,255,.45); }

/* True masonry via CSS columns */
.stars-cols {
  columns: 2;
  column-gap: 5px;
  padding: 5px;
}
@media (min-width: 480px) { .stars-cols { columns: 3; } }
@media (min-width: 720px) { .stars-cols { columns: 4; } }
@media (min-width: 960px) { .stars-cols { columns: 5; } }

/* Card */
.sc {
  display: block;
  position: relative;
  break-inside: avoid;
  margin-bottom: 5px;
  border-radius: 8px;
  overflow: hidden;
  background: #111;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.sc img:first-child {
  width: 100%;
  display: block;
  height: auto;
  transition: transform .3s ease;
}
.sc:active img:first-child { transform: scale(1.04); }
.sc-empty { width: 100%; aspect-ratio: 3/4; background: #1e1e2e; }

/* Bottom info strip */
.sc-info {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 20px 7px 7px;
  background: linear-gradient(to top, rgba(0,0,0,.85) 0%, transparent 100%);
  display: flex;
  align-items: center;
  gap: 5px;
}
.sc-av {
  width: 24px; height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(255,255,255,.3);
  flex-shrink: 0;
}
.sc-text {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}
.sc-name {
  font-size: .68rem; font-weight: 700; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 2px;
}
.sc-v {
  font-size: .5rem; font-weight: 800;
  background: var(--verified); color: #fff;
  border-radius: 50%; width: 11px; height: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sc-handle { font-size: .6rem; color: rgba(255,255,255,.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-fol { font-size: .6rem; font-weight: 700; color: rgba(255,255,255,.7); white-space: nowrap; flex-shrink: 0; }
.sc-badge {
  position: absolute; top: 5px; left: 5px;
  font-size: .65rem; line-height: 1;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  border-radius: 20px; padding: 2px 5px; color: #fff;
}
/* Lightbox stats row */
.lb-stats { font-size: .75rem; color: rgba(255,255,255,.75); margin: 0 0 5px; }

/* Reel card date chip */
.reel-date { opacity: .75; }

/* aspect-ratio CLS prevention handled by .aspect-container above */

/* Profile grid: fade on tab switch */
.masonry-grid { transition: opacity 0.18s ease; }
.masonry-grid.fading { opacity: 0; }

/* Lightbox: crossfade between photos */
#lightboxImg {
  transition: opacity 0.2s ease;
  max-width: 100%;
  max-height: 100svh;
  object-fit: contain;
  display: block;
  user-select: none;
}
#lightboxImg.fading { opacity: 0; }

/* Profile hero: reserve height while avatar loads */
.profile-hero { min-height: 200px; }

