/* ============================================================================
   Kempur Basketball — Instagram-light design system
   Clean white surfaces · #0095f6 blue · #262626 ink · hairline borders
   System font stack · gradient rings · photo-first
   ========================================================================== */

:root {
  --bg:        #fafafa;   /* app canvas */
  --surface:   #ffffff;   /* cards, bars */
  --ink:       #262626;   /* primary text */
  --ink-2:     #8e8e8e;   /* secondary text */
  --line:      #dbdbdb;   /* hairline borders */
  --line-soft: #efefef;   /* subtle dividers */
  --hover:     #f2f2f2;   /* hover fill */
  --blue:      #0095f6;   /* Instagram action blue */
  --blue-ink:  #00376b;   /* links */
  --liked:     #ff3040;   /* liked red */
  --grad:      radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%,
                              #fd5949 45%, #d6249f 60%, #285aeb 90%);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
          Arial, sans-serif;
  --r:    12px;
  --r-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: auto;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.muted { color: var(--ink-2); }

/* ---- shared buttons -------------------------------------------------- */
.btn-blue {
  background: var(--blue); color: #fff; border: none; cursor: pointer;
  padding: 7px 16px; border-radius: var(--r-sm);
  font: 600 14px/1 var(--sans); transition: opacity .15s;
}
.btn-blue:hover { opacity: .9; }
.btn-blue:disabled { opacity: .5; cursor: default; }

/* =====================================================================
   TOPBAR (feed + home)
   Safe-area top padding keeps the bar clear of the iPhone notch.
   height = 60px + inset on notched devices; on desktop inset=0 ⇒ identical
   to the original 60px. box-sizing:border-box keeps the inner content box
   at 60px regardless of inset.
   ========================================================================== */
#topbar, .home-top {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  height: calc(60px + env(safe-area-inset-top));
  padding: 0 20px;
  padding-top: env(safe-area-inset-top);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(8px);
}
.brand {
  font: 800 22px/1 var(--sans); letter-spacing: .02em; color: var(--ink);
  white-space: nowrap;
}
#topbar .spacer, .home-top .spacer { flex: 1; }
#search, #date {
  background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  padding: 8px 12px; border-radius: var(--r-sm);
  font: 400 13px var(--sans); outline: none;
  transition: border-color .15s, background .15s;
}
#search { width: 220px; }
#search::placeholder { color: var(--ink-2); }
#search:focus, #date:focus { border-color: var(--ink); background: var(--surface); }
#date { max-width: 150px; }
#cats { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
#cats::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 6px 12px; border-radius: 999px;
  font: 600 12px/1 var(--sans); transition: all .15s;
}
.chip:hover { background: var(--hover); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .n { opacity: .6; margin-left: 4px; }

/* =====================================================================
   FEED — Instagram post cards
   ========================================================================== */
#feed {
  max-width: 614px; margin: 0 auto; padding: 20px 0 60px;
}
.post {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin-bottom: 24px; overflow: hidden;
}
.post-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
}
.avatar { line-height: 0; }
.ring {
  display: inline-block; padding: 2px; border-radius: 50%; background: var(--grad);
}
.ring > * {
  display: block; width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--surface); background: var(--surface);
  object-fit: cover;
}
.post-id { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.username { font: 600 14px/1.1 var(--sans); color: var(--ink); }
.username:hover { color: var(--ink-2); }
.post-sub { font-size: 12px; color: var(--ink-2); }
.follow {
  background: var(--blue); color: #fff; border: none; cursor: pointer;
  padding: 6px 14px; border-radius: var(--r-sm);
  font: 600 13px/1 var(--sans); transition: all .15s;
}
.follow:hover { opacity: .9; }
.follow.following {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
}
.icon-btn {
  background: none; border: none; cursor: pointer; color: var(--ink);
  padding: 10px; line-height: 0;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px;        /* Apple HIG touch target */
  border-radius: 6px; transition: background .12s;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 24px; height: 24px; }
.more { margin-left: auto; }
.more svg { width: 22px; height: 22px; }

/* media */
.post-media { position: relative; background: #000; }
.post-media video { width: 100%; max-height: 75dvh; object-fit: contain; display: block; background: #000; cursor: pointer; }
.mute-btn {
  position: absolute; right: 10px; bottom: 10px; z-index: 6;
  background: rgba(0,0,0,.6); color: #fff; border: none; cursor: pointer;
  width: 44px; height: 44px; border-radius: 50%; line-height: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.mute-btn svg { width: 16px; height: 16px; }
.q-btn {
  position: absolute; top: 10px; right: 10px; z-index: 6;
  background: rgba(0,0,0,.55); color: #fff; border: 1px solid rgba(255,255,255,.25);
  padding: 8px 12px; min-height: 40px; border-radius: 6px;
  font: 700 11px/1 var(--sans);
  cursor: pointer; transition: background .15s;
}
.q-btn:hover { background: rgba(0,0,0,.8); }
.fs-btn {
  position: absolute; top: 10px; left: 10px; z-index: 6;
  background: rgba(0,0,0,.55); color: #fff; border: 1px solid rgba(255,255,255,.25);
  padding: 0; width: 44px; height: 44px; border-radius: 6px;
  cursor: pointer; line-height: 0; transition: background .15s;
  display: inline-flex; align-items: center; justify-content: center;
}
.fs-btn:hover { background: rgba(0,0,0,.8); }
.fs-btn svg { width: 18px; height: 18px; display: block; }

/* play overlay */
.play-overlay {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .18s;
}
.play-overlay svg { width: 64px; height: 64px; color: #fff; opacity: .85;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.5)); transform: scale(.8); transition: transform .18s; }
.play-overlay.show { opacity: 1; }
.play-overlay.show svg { transform: scale(1); }

/* seek bar */
.progress {
  position: absolute; left: 0; right: 0; bottom: 0; height: 16px; z-index: 6;
  pointer-events: auto; cursor: pointer; touch-action: none; outline: none;
  display: flex; align-items: flex-end;
}
.progress-buf, .progress-fill {
  position: absolute; left: 0; bottom: 0; height: 3px; transition: height .15s;
}
.progress-buf { width: 0; background: rgba(255,255,255,.25); }
.progress-fill { width: 0; background: var(--blue); }
.progress:hover .progress-buf,
.progress:hover .progress-fill,
.progress:focus-visible .progress-fill { height: 5px; }
.progress-fill::after {
  content: ''; position: absolute; right: -5px; top: 50%; transform: translateY(-50%);
  width: 11px; height: 11px; border-radius: 50%; background: var(--blue);
  opacity: 0; transition: opacity .15s;
}
.progress:hover .progress-fill::after,
.progress:focus-visible .progress-fill::after { opacity: 1; }

/* action bar */
.post-bar { padding: 8px 12px 12px; }
.post-actions { display: flex; align-items: center; gap: 4px; }
.post-actions .save { margin-left: auto; }
.like.liked svg { stroke: var(--liked); fill: var(--liked); }
.like.liked { animation: pop .25s ease; }
@keyframes pop { 0%{transform:scale(1)} 40%{transform:scale(1.2)} 100%{transform:scale(1)} }
.save.saved svg { stroke: var(--ink); fill: var(--ink); }
.post-likes { font: 600 13px/1 var(--sans); padding: 6px 4px 0; }
.post-cap { padding: 2px 4px 0; font-size: 13px; line-height: 1.4; }
.post-cap .un { font-weight: 600; margin-right: 6px; }
.post-cap .tag { color: var(--blue-ink); cursor: pointer; margin-right: 5px; }
.post-foot { padding: 4px 4px 0; font-size: 11px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .02em; }

/* double-tap heart burst */
.heart-burst {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%) scale(.3);
  width: 90px; height: 90px; color: #fff; pointer-events: none; z-index: 7;
  filter: drop-shadow(0 2px 10px rgba(0,0,0,.4));
  animation: burst .72s ease forwards;
}
.heart-burst svg { width: 100%; height: 100%; fill: var(--liked); stroke: var(--liked); }
@keyframes burst {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.25) rotate(-14deg); }
  35%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.25) rotate(10deg); }
}

/* hint toast — clears the iPhone home indicator via max() */
#hint {
  position: fixed; bottom: max(24px, env(safe-area-inset-bottom) + 16px); left: 50%; transform: translateX(-50%); z-index: 60;
  background: rgba(38,38,38,.95); color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; opacity: 0; transition: opacity .3s; pointer-events: none;
}
#hint.show { opacity: 1; }

/* loader + empty */
#loader {
  position: fixed; inset: 0; z-index: 40; display: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 14px;
  background: var(--bg);
}
#loader.show { display: flex; }
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--blue);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loader .lt { font-size: 13px; color: var(--ink-2); }

#empty {
  text-align: center; padding: 60px 30px; display: none; flex-direction: column;
  align-items: center; gap: 12px;
}
#empty.show { display: flex; }
#empty .ei { width: 56px; height: 56px; color: var(--line); }
#empty .et { font-size: 20px; font-weight: 600; }
#empty .es { color: var(--ink-2); font-size: 14px; max-width: 300px; }
.empty-btn { margin-top: 4px; }

/* =====================================================================
   SHEETS (comments / edit) — bottom sheet clears the home indicator
   ========================================================================== */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  max-width: 560px; margin: 0 auto; max-height: 70vh;
  background: var(--surface); border: 1px solid var(--line); border-bottom: none;
  border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column;
  transform: translateY(102%); transition: transform .28s cubic-bezier(.22,1,.36,1);
}
.sheet.open { transform: translateY(0); }
.sheet-head {
  display: flex; align-items: center; justify-content: center; position: relative;
  padding: 14px 16px; border-bottom: 1px solid var(--line-soft);
  font: 600 15px/1 var(--sans);
}
.sheet-head .x {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--ink);
  width: 30px; height: 30px; font-size: 18px;
}
.sheet-body { overflow-y: auto; padding: 14px 16px; flex: 1; }
.sheet-foot { display: flex; gap: 8px; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line-soft); }
.sheet-foot input {
  flex: 1; background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  padding: 10px 13px; border-radius: var(--r-sm); font: 400 14px var(--sans); outline: none;
}
.sheet-foot input:focus { border-color: var(--ink-2); }
.sheet-foot input#commentAuthor { flex: 0 0 110px; }
.sheet-foot button {
  background: none; border: none; color: var(--blue); cursor: pointer;
  font: 600 14px var(--sans); padding: 0 4px;
}
.sheet-foot button:disabled { color: var(--line); }
.edit-form { display: flex; flex-direction: column; gap: 14px; }
.edit-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
.edit-form input, .edit-form textarea {
  background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  padding: 10px 13px; border-radius: var(--r-sm); font: 400 14px var(--sans);
  outline: none; font-family: inherit; resize: vertical;
}
.edit-form input:focus, .edit-form textarea:focus { border-color: var(--ink-2); }
#saveEdit { align-self: flex-end; }

.comment { padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.comment .ca { font: 600 13px/1 var(--sans); }
.comment .cb { font-size: 14px; margin-top: 4px; line-height: 1.4; }

/* =====================================================================
   HOMEPAGE — profile + explore
   ========================================================================== */
.home-main { max-width: 935px; margin: 0 auto; padding: 24px 20px 60px; }
.search-pill {
  display: flex; align-items: center; gap: 8px; flex: 0 1 260px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 7px 12px;
}
.search-pill .s-icon { width: 16px; height: 16px; color: var(--ink-2); flex: none; }
.search-pill input {
  flex: 1; background: none; border: none; outline: none; color: var(--ink);
  font: 400 13px var(--sans); min-width: 0;
}
.search-pill input::placeholder { color: var(--ink-2); }
.search-pill button { background: none; border: none; color: var(--blue); cursor: pointer; font: 600 13px var(--sans); }

/* profile header */
.profile { display: flex; gap: 60px; padding: 8px 0 28px; align-items: center; }
.ring.lg > * { width: 88px; height: 88px; }
.avatar.logo { display: flex; align-items: center; justify-content: center;
  font: 800 34px/1 var(--sans); color: var(--ink); }
.profile-info { flex: 1; display: flex; flex-direction: column; gap: 16px; }
.profile-row { display: flex; align-items: center; gap: 14px; }
.profile-row h1 { font: 400 22px/1 var(--sans); font-weight: 300; letter-spacing: .01em; }
.stats { display: flex; gap: 28px; }
.stats span { font-size: 14px; }
.stats b { font-weight: 600; }
.bio { font-size: 14px; line-height: 1.5; }
.bio b { font-weight: 600; }

.row-label {
  font: 600 14px/1 var(--sans); color: var(--ink);
  margin: 24px 4px 14px; display: flex; align-items: center; gap: 12px;
}
.row-label::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* section header that carries a right-aligned action (e.g. Sessions + Feel lucky) */
.row-head {
  display: flex; align-items: center; gap: 12px;
  margin: 24px 4px 14px;
}
.row-head .row-label { margin: 0; flex: 1; }
.lucky-btn {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  border: none; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, #d6249f, #285aeb);
  padding: 8px 16px; border-radius: 999px;
  font: 700 13px/1 var(--sans);
  box-shadow: 0 2px 8px rgba(90,60,200,.3);
  transition: transform .12s ease, box-shadow .2s ease, opacity .15s;
}
.lucky-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(90,60,200,.42); }
.lucky-btn:active { transform: translateY(0) scale(.97); }
.lucky-btn:disabled { opacity: .55; cursor: default; transform: none; box-shadow: none; }
.lucky-btn svg { width: 15px; height: 15px; flex: 0 0 auto; }

/* sessions pills */
.pill-row { display: flex; flex-wrap: wrap; gap: 10px; }
.spill {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 999px; font: 600 13px var(--sans);
  display: inline-flex; align-items: center; gap: 7px; transition: all .15s;
}
.spill:hover { background: var(--hover); }
.spill .n { color: var(--ink-2); font-weight: 400; }

/* explore grid (3-col square thumbs) */
.explore {
  display: grid; gap: 3px;
  grid-template-columns: repeat(3, 1fr);
}
.explore-tile {
  position: relative; aspect-ratio: 1 / 1; overflow: hidden; background: var(--hover);
}
.explore-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.explore-tile:hover img { transform: scale(1.04); }
.explore-tile::after {
  content: ''; position: absolute; inset: 0; background: rgba(0,0,0,0);
  transition: background .2s;
}
.explore-tile:hover::after { background: rgba(0,0,0,.18); }
.explore-views {
  position: absolute; left: 8px; bottom: 8px; z-index: 2; color: #fff;
  font: 600 12px/1 var(--sans); display: flex; align-items: center; gap: 4px;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
  opacity: 0; transition: opacity .2s;
}
.explore-tile:hover .explore-views { opacity: 1; }

/* highlights rail */
.tile-row {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px;
  scrollbar-width: none;
}
.tile-row::-webkit-scrollbar { display: none; }
.tile {
  position: relative; flex: 0 0 auto; width: 210px; aspect-ratio: 4 / 3;
  border-radius: var(--r); overflow: hidden; border: 1px solid var(--line);
  background: var(--surface);
}
.tile-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.tile:hover .tile-thumb { transform: scale(1.05); }
.tile.no-thumb .tile-thumb { display: none; }
.tile-shade { position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.85) 6%, transparent 55%); }
.tile-meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 13px; color: #fff; }
.tile-title {
  font: 600 13px/1.3 var(--sans);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile-views { margin-top: 5px; font: 600 11px/1 var(--sans); color: rgba(255,255,255,.85); }

/* tag chips */
.tag-row { display: flex; flex-wrap: wrap; gap: 10px; }
.htag {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 999px; font: 600 13px var(--sans);
  display: inline-flex; align-items: center; gap: 6px; transition: all .15s;
}
.htag:hover { background: var(--hover); }
.htag .n { color: var(--ink-2); font-weight: 400; }

/* =====================================================================
   LOGIN
   ========================================================================== */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100dvh;
  background: var(--bg);
}
.login-card {
  width: 350px; max-width: 90vw;
  display: flex; flex-direction: column; gap: 12px; text-align: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 36px 36px 28px;
}
.login-logo {
  font: 300 42px/1 var(--sans); letter-spacing: .01em; color: var(--ink); margin-bottom: 14px;
}
.login-card input {
  background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  padding: 11px 10px; border-radius: var(--r-sm); font: 400 13px var(--sans);
  text-align: left; outline: none;
}
.login-card input:focus { border-color: var(--ink-2); }
.login-card button.primary { margin-top: 6px; padding: 11px; width: 100%; }
.login-err { color: var(--liked); font-size: 13px; min-height: 16px; }

/* =====================================================================
   ACCOUNT widget + auth modal + notifications
   ========================================================================== */
#account { position: relative; display: flex; align-items: center; gap: 10px; }
.acct-name { font: 600 13px var(--sans); color: var(--ink); max-width: 120px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-btn {
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  padding: 7px 14px; border-radius: var(--r-sm); font: 600 13px var(--sans); cursor: pointer;
  transition: background .15s;
}
.acct-btn:hover { background: var(--hover); }
.acct-btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.acct-btn.primary:hover { opacity: .9; background: var(--blue); }
.acct-btn.text { background: none; border: none; color: var(--ink-2); padding: 7px 10px; }
.acct-btn.icon { position: relative; padding: 7px; line-height: 0; }
.acct-btn.icon svg { width: 22px; height: 22px; }
.badge {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 999px; background: var(--liked); color: #fff;
  font: 700 10px/16px var(--sans); text-align: center;
}
.dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  width: 300px; max-width: 92vw; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 8px 30px rgba(0,0,0,.18); overflow: hidden; display: none;
}
.dropdown.open { display: block; }
.notif { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft); text-decoration: none; color: var(--ink); font-size: 13px; }
.notif:hover { background: var(--hover); }
.notif.unread { background: rgba(0,149,246,.06); }
.notif .nbody { color: var(--ink-2); font-size: 12px; }
.notif-empty { padding: 20px; text-align: center; color: var(--ink-2); font-size: 13px; }

/* auth modal */
.modal {
  position: fixed; inset: 0; z-index: 90; display: none;
  align-items: center; justify-content: center; background: rgba(0,0,0,.55);
}
.modal.open { display: flex; }
.modal-card {
  width: 360px; max-width: 92vw; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); padding: 20px;
}
.modal-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.modal-tabs button {
  flex: 1; background: none; border: 1px solid var(--line); color: var(--ink-2);
  padding: 9px; border-radius: var(--r-sm); font: 600 13px var(--sans); cursor: pointer;
}
.modal-tabs button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
  background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  padding: 11px 13px; border-radius: var(--r-sm); font: 400 14px var(--sans); outline: none;
}
.auth-form input:focus { border-color: var(--ink-2); }
.auth-form button { margin-top: 4px; padding: 11px; }
.comment-as { font: 600 12px var(--sans); color: var(--blue-ink); white-space: nowrap; }
.mention { color: var(--blue); font-weight: 600; cursor: pointer; }

/* =====================================================================
   Kempur Basketball — fullscreen swipe viewer
   Bottom UI clears the home indicator; close button clears the notch.
   ========================================================================== */
#reels { position: fixed; inset: 0; z-index: 100; background: #000; display: none; }
#reels.open { display: block; }
.r-track {
  height: 100%; overflow-y: scroll; scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
.r-track::-webkit-scrollbar { display: none; }
.r-sentinel { height: 1px; }
.r-slide {
  position: relative; height: 100vh; height: 100dvh; width: 100%;
  scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; align-items: center; justify-content: center; background: #000;
}
.r-slide video { width: 100%; height: 100%; object-fit: contain; background: #000; cursor: pointer; }
.r-shade {
  position: absolute; left: 0; right: 0; bottom: 0; height: 40%; pointer-events: none;
  background: linear-gradient(to top, rgba(0,0,0,.85), transparent);
}
.r-ui {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 16px 16px max(26px, env(safe-area-inset-bottom) + 16px);
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  color: #fff; pointer-events: none;
}
.r-ui > * { pointer-events: auto; }
.r-cap {
  font-size: 14px; line-height: 1.4; max-width: 78%;
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
}
.r-cap b { font-weight: 600; }
.r-actions { display: flex; flex-direction: column; gap: 20px; align-items: center; }
.r-act {
  background: none; border: none; color: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 6px; min-width: 44px; min-height: 44px;
  font: 600 12px/1 var(--sans);
}
.r-act svg { width: 30px; height: 30px; filter: drop-shadow(0 1px 4px rgba(0,0,0,.7)); }
.r-like.liked { color: var(--liked); }
.r-like.liked svg { fill: var(--liked); stroke: var(--liked); }
.r-like.liked { animation: pop .25s ease; }
.r-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.18); }
.r-fill { height: 100%; width: 0; background: var(--blue); }
.r-close {
  position: fixed; top: max(14px, env(safe-area-inset-top) + 8px); right: 14px; z-index: 101;
  background: rgba(0,0,0,.45); color: #fff; border: none; cursor: pointer;
  width: 44px; height: 44px; border-radius: 50%; line-height: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.r-close:hover { background: rgba(0,0,0,.7); }
.r-close svg { width: 22px; height: 22px; }
.r-toast {
  position: fixed; bottom: max(24px, env(safe-area-inset-bottom) + 16px); left: 50%; transform: translateX(-50%); z-index: 102;
  background: rgba(38,38,38,.95); color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; opacity: 0; transition: opacity .3s; pointer-events: none;
}
.r-toast.show { opacity: 1; }
/* double-tap heart burst */
.r-burst {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%) scale(.3);
  width: 90px; height: 90px; color: var(--liked); pointer-events: none; z-index: 5;
  filter: drop-shadow(0 2px 10px rgba(0,0,0,.4));
  animation: rburst .72s ease forwards;
}
.r-burst svg { width: 100%; height: 100%; fill: var(--liked); }
@keyframes rburst {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.25) rotate(-14deg); }
  35%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.25) rotate(10deg); }
}

/* =====================================================================
   MOBILE — phones (≤735px). Matches Instagram's own breakpoint.
   Desktop layout (≥736px) is unaffected by anything below: every rule is
   either scoped to this media query or a safe-area addition that no-ops
   on devices without a notch (env() resolves to 0).
   ========================================================================== */
@media (max-width: 735px) {
  .profile { gap: 24px; padding: 4px 0 20px; }
  .ring.lg > * { width: 66px; height: 66px; }
  .stats { gap: 18px; }
  .home-main { padding: 16px 12px 60px; }

  /* ---- Home topbar: search-pill flexes to fill the space between
       brand and account so nothing overflows. The desktop spacer is
       dropped on mobile because the flexing search-pill handles it. ---- */
  .home-top { gap: 10px; padding: 0 12px; padding-top: env(safe-area-inset-top); }
  .home-top .spacer { display: none; }
  .home-top .search-pill { flex: 1 1 auto; min-width: 0; }

  /* ---- Feed topbar: wrap into rows so brand + chips + date + search +
       account never share one 60px line (they would overflow at ≤640px).
       Row 1: brand ............ account (margin-left:auto pins it right)
       Row 2: search (flex) + date (fixed)
       Row 3: #cats — full-width horizontally-scrollable chip strip
       The .spacer flex:1 is dropped because account's margin-left:auto
       replaces its "push right" role.                                  ---- */
  #topbar {
    height: auto;
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 10px 12px;
    padding-top: calc(env(safe-area-inset-top) + 8px);
  }
  #topbar .spacer { display: none; }
  #topbar .brand { order: 1; }
  #topbar #account { order: 2; margin-left: auto; }
  #topbar #search { order: 3; flex: 1 1 auto; width: auto; min-width: 0; }
  #topbar #date { order: 4; max-width: 140px; }
  #topbar #cats {
    order: 5; flex: 1 1 100%;
    margin: 0 -2px;
    padding-bottom: 2px;
  }
}

/* ---- Narrow phones (≤480px): tighten the feed topbar a touch more ---- */
@media (max-width: 480px) {
  #topbar {
    gap: 6px 8px;
    padding: 8px 10px;
    padding-top: calc(env(safe-area-inset-top) + 6px);
  }
  #topbar #date { max-width: 120px; }
  .home-main { padding: 12px 10px 60px; }
}
