:root {
  --accent: #9470ff;
  --brand: linear-gradient(135deg, #a873ff, #549eff);
  --pink: #ff3366;
  --glow: rgba(255, 90, 158, 1);
  --tab-h: 60px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: max(env(safe-area-inset-bottom, 0px), 10px);
  --sheet-bg: #121212;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: #fff;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body { position: fixed; inset: 0; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* Phone-width column, so it also looks right if opened on a laptop. */
#app {
  position: fixed;
  inset: 0;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  overflow: clip; /* clip can't be scrolled programmatically */
  background: #000;
}

.icon { display: inline-flex; line-height: 0; }
.icon svg { width: 1em; height: 1em; overflow: visible; }

.wordmark {
  font: 900 26px/1 ui-rounded, "SF Pro Rounded", -apple-system, sans-serif;
  letter-spacing: -0.5px;
  background: var(--brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Feed ---------- */

#feed {
  position: absolute;
  inset: 0;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  overscroll-behavior: contain;
}
#feed::-webkit-scrollbar { display: none; }

.post {
  position: relative;
  height: 100%;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: #000;
}

.media, .media img, .media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media.fit img, .media.fit video { object-fit: contain; }

.missing {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
}

.shade {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 400px;
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.7));
  pointer-events: none;
}

.tap { position: absolute; inset: 0; }

.paused-icon {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-size: 64px;
  color: rgba(255, 255, 255, 0.55);
  pointer-events: none;
  display: none;
}
.post.paused .paused-icon { display: block; }

.overlay {
  position: absolute;
  left: 16px; right: 16px;
  bottom: calc(var(--tab-h) + var(--safe-b) + 18px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  pointer-events: none;
}
.overlay > * { pointer-events: auto; }

.info {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.who { display: flex; align-items: center; gap: 10px; }
.who .avatar { box-shadow: 0 0 0 1.2px rgba(255, 255, 255, 0.9); }
.who .name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .verified { font-size: 14px; margin-left: -6px; }

.follow {
  height: 28px;
  padding: 0 12px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.85);
  transition: background 0.25s, box-shadow 0.25s;
  flex-shrink: 0;
}
.follow.on { background: rgba(255, 255, 255, 0.15); box-shadow: none; }

.caption {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.caption.expanded { -webkit-line-clamp: 12; }
.caption b { font-weight: 700; }

.sound {
  align-self: flex-start;
  max-width: 260px;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
}
.sound span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.eq { display: flex; align-items: flex-end; gap: 2px; height: 12px; }
.eq i {
  width: 2.5px;
  height: 4px;
  border-radius: 2px;
  background: #fff;
  animation: eq 0.4s ease-in-out infinite alternate;
  animation-play-state: paused;
}
.eq i:nth-child(2) { height: 10px; animation-duration: 0.48s; animation-direction: alternate-reverse; }
.eq i:nth-child(3) { height: 6px; animation-duration: 0.56s; }
.post.active .eq i { animation-play-state: running; }
@keyframes eq { from { height: 3px; } to { height: 12px; } }

/* ---------- Action pills ---------- */

.actions { display: flex; align-items: center; gap: 8px; }
.actions .spacer { flex: 1; }

.pill {
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: rgba(40, 40, 40, 0.42);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.14);
}
.pill .icon { font-size: 20px; }
.pill:active { transform: scale(0.96); }

.save.on .icon path { fill: var(--accent); stroke: var(--accent); }
.save.bounce .icon { animation: bounce 0.4s ease; }
@keyframes bounce { 40% { transform: scale(1.3); } 100% { transform: scale(1); } }

/* ---------- The like heart ---------- */

.heart-wrap {
  position: relative;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}
.heart-wrap.small { width: 16px; height: 16px; }
.heart-wrap svg { width: 100%; height: 100%; overflow: visible; }
.heart-wrap .heart path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.liked .heart-wrap .heart path { fill: url(#likeGrad); stroke: url(#likeGrad); }
.liked .heart-wrap .heart { filter: drop-shadow(0 0 5px rgba(255, 90, 158, 0.55)); }

.heart-wrap .ring {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid var(--glow);
  opacity: 0;
  pointer-events: none;
}

.pulse .heart-wrap .heart { animation: heartPulse 0.8s cubic-bezier(0.25, 0.9, 0.3, 1) both; }
.pulse .heart-wrap .ring { animation: ring 0.55s ease-out 0.06s both; }

@keyframes heartPulse {
  0%   { transform: scale(1); }
  10%  { transform: scale(0.8); }
  35%  { transform: scale(1.75); filter: drop-shadow(0 0 14px rgba(255, 90, 158, 1)) drop-shadow(0 0 5px rgba(255, 51, 102, 0.9)); }
  55%  { transform: scale(0.94); filter: drop-shadow(0 0 12px rgba(255, 90, 158, 0.9)) drop-shadow(0 0 4px rgba(255, 51, 102, 0.8)); }
  72%  { transform: scale(1.08); }
  100% { transform: scale(1); filter: drop-shadow(0 0 5px rgba(255, 90, 158, 0.55)); }
}
@keyframes ring {
  0%   { opacity: 0.9; transform: scale(0.6); }
  100% { opacity: 0; transform: scale(2.4); }
}

/* Double-tap heart */
.burst {
  position: absolute;
  width: 100px;
  height: 100px;
  margin: -50px 0 0 -50px;
  pointer-events: none;
  animation: burst 1s ease forwards;
}
.burst svg { width: 100%; height: 100%; filter: drop-shadow(0 0 22px rgba(255, 90, 158, 0.9)) drop-shadow(0 0 6px rgba(255, 51, 102, 0.6)); }
.burst path { fill: url(#likeGrad); }
@keyframes burst {
  0%   { opacity: 0; transform: rotate(var(--tilt)) scale(1.6); }
  15%  { opacity: 1; transform: rotate(var(--tilt)) scale(0.9); }
  27%  { transform: rotate(var(--tilt)) scale(1.06); }
  38%  { transform: rotate(var(--tilt)) scale(1); }
  58%  { opacity: 1; transform: rotate(var(--tilt)) translateY(0) scale(1); }
  100% { opacity: 0; transform: rotate(var(--tilt)) translateY(-60px) scale(1.25); }
}

/* ---------- Avatars ---------- */

.avatar {
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background-size: cover;
  background-position: center;
}

/* ---------- Chrome ---------- */

#topbar {
  position: absolute;
  left: 0; right: 0; top: 0;
  padding: calc(var(--safe-t) + 12px) 18px 0;
  height: calc(var(--safe-t) + 150px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.45), transparent);
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
#logo { padding: 4px 0; cursor: default; }
.top-icons { display: flex; gap: 20px; font-size: 22px; padding-top: 3px; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.35)); }

.dot { position: relative; }
.dot::after {
  content: "";
  position: absolute;
  top: -1px; right: -2px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

#tabbar {
  position: absolute;
  left: 22px; right: 22px;
  bottom: calc(var(--safe-b) + 4px);
  height: var(--tab-h);
  border-radius: 30px;
  display: flex;
  align-items: center;
  background: rgba(30, 30, 30, 0.55);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  backdrop-filter: blur(24px) saturate(1.5);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.12);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 22px;
  color: rgba(255, 255, 255, 0.65);
}
.tab > i { width: 4px; height: 4px; border-radius: 50%; }
.tab.selected { color: #fff; }
.tab.selected > i { background: var(--accent); }
.tab:not(:has(i)) { gap: 0; }
.create {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--brand);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 18px;
}
#me-avatar .avatar { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.8); }

/* ---------- Comments sheet ---------- */

#backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
#backdrop.open { opacity: 1; pointer-events: auto; }

#sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 72%;
  max-height: 100%;
  background: var(--sheet-bg);
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  visibility: hidden;
  transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.25, 1), bottom 0.25s, visibility 0s linear 0.35s;
  will-change: transform;
}
#sheet.open { transform: translateY(0); visibility: visible; transition-delay: 0s; }
#sheet.dragging { transition: none; }

.grab { display: grid; place-items: center; padding: 8px 0 0; }
.grab span { width: 36px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.18); }

.sheet-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px 14px;
}
.sheet-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.chip {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  padding: 0 8px;
  height: 22px;
  line-height: 22px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.1);
}
.sort {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
}
.sort .icon { font-size: 11px; }
.close {
  width: 28px; height: 28px;
  margin-left: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: grid;
  place-items: center;
  font-size: 12px;
}

.list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px 16px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.empty { text-align: center; color: rgba(255, 255, 255, 0.5); font-size: 15px; padding-top: 40px; }

.comment { display: flex; gap: 12px; margin-bottom: 20px; }
.comment .body { flex: 1; min-width: 0; }
.comment .meta { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.comment .user { font-weight: 600; }
.comment .time { color: rgba(255, 255, 255, 0.45); font-size: 13px; }
.author {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(148, 112, 255, 0.25);
  padding: 0 6px;
  height: 16px;
  line-height: 16px;
  border-radius: 8px;
}
.comment .text {
  margin: 4px 0 0;
  font-size: 15px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.92);
  word-wrap: break-word;
  -webkit-user-select: text;
  user-select: text;
}
.comment .row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 7px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
}
.comment .clike { display: inline-flex; align-items: center; gap: 5px; color: inherit; font-variant-numeric: tabular-nums; }
.comment .replies { margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--accent); }
.comment.new { animation: slideIn 0.35s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 0.5px solid rgba(255, 255, 255, 0.08);
  background: var(--sheet-bg);
}
#sheet.keyboard .composer { padding-bottom: 10px; }
.field {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 19px;
  background: rgba(255, 255, 255, 0.1);
}
.field textarea {
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  font: 16px/22px -apple-system, BlinkMacSystemFont, sans-serif; /* 16px stops iOS zooming in */
  max-height: 88px;
  padding: 0;
  caret-color: var(--accent);
  -webkit-user-select: text;
  user-select: text;
}
.field textarea::placeholder { color: rgba(255, 255, 255, 0.45); }
.field-icons { display: flex; gap: 12px; font-size: 20px; padding-bottom: 1px; }
.composer.has-text .field-icons { display: none; }
.send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--brand);
  display: none;
  place-items: center;
  font-size: 16px;
}
.composer.has-text .send { display: grid; animation: pop 0.2s ease; }
@keyframes pop { from { transform: scale(0.5); opacity: 0; } }

/* ---------- Loader ---------- */

#loader {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  transition: opacity 0.35s;
  z-index: 10;
}
#loader.done { opacity: 0; pointer-events: none; }
.wordmark.big { font-size: 46px; }
.bar { width: 140px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--brand); transition: width 0.2s; }
#errors { max-width: 320px; padding: 0 20px; font-size: 13px; line-height: 1.5; color: rgba(255, 255, 255, 0.7); text-align: center; }
#errors:empty { display: none; }
