:root {
  --bg-default: #ffffff;
  --text-default: #0c1014;
  --text-subtle: #6f7680;
  --border-subtler: #dbdfe4;
  --icon-emphasized: #ff0034;
  --system-dark: #000000;
  --phone-width: 390px;
  --phone-height: 844px;
  --status-height: 54px;
  --nav-height: 41px;
  --tab-height: 51px;
  --chrome-top: var(--nav-height);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: var(--font-sans);
  background: #f0f2f5;
  color: var(--text-default);
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.page {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* ─── Phone shell ─── */
.phone {
  position: relative;
  width: var(--phone-width);
  height: var(--phone-height);
  background: var(--bg-default);
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(12, 16, 20, 0.18);
  border-radius: 40px;
  border: 1px solid rgba(12, 16, 20, 0.08);
  display: flex;
  flex-direction: column;
}

/* ─── Fixed: Status Bar ─── */
.status-bar {
  flex-shrink: 0;
  position: relative;
  z-index: 30;
  height: var(--status-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-default);
}

.status-bar__time {
  font-size: 17px;
  font-weight: 590;
  line-height: 22px;
}

.status-bar__levels {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--system-dark);
}

.status-bar__battery {
  position: relative;
  width: 27px;
  height: 13px;
}

.status-bar__battery-border {
  position: absolute;
  inset: 0 3px 0 0;
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 4px;
}

.status-bar__battery-cap {
  position: absolute;
  right: 0;
  top: 4px;
  width: 2px;
  height: 5px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 0 1px 1px 0;
}

.status-bar__battery-fill {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 21px;
  height: 9px;
  background: var(--system-dark);
  border-radius: 2px;
}

/* ─── Fixed: Navigation Bar ─── */
.nav-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 25;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-default);
  border-bottom: 0.5px solid var(--border-subtler);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.nav-bar--hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.nav-bar__btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.nav-bar__logo {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
}

/* ─── Scrollable Feed ─── */
.feed {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: var(--bg-default);
  padding-top: var(--nav-height);
  padding-bottom: var(--tab-height);
}

.feed::-webkit-scrollbar {
  display: none;
}

/* ─── Stories (inside feed) ─── */
.stories {
  display: flex;
  gap: 10px;
  padding: 8px 6px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg-default);
  border-bottom: 0.5px solid var(--border-subtler);
}

.stories::-webkit-scrollbar {
  display: none;
}

.story {
  flex: 0 0 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.story__ring {
  position: relative;
  width: 78px;
  height: 78px;
}

.story__ring-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.story__avatar {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 68px;
  border-radius: 50%;
  object-fit: cover;
}

.story__ring--close-friends .story__avatar {
  left: 5px;
  top: 5px;
  transform: none;
  width: calc(100% - 10px);
  height: calc(100% - 10px);
}

.story__add {
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-default);
  border: 3px solid var(--bg-default);
  display: grid;
  place-items: center;
}

.story__add img {
  width: 10px;
  height: 10px;
}

.story__label {
  width: 78px;
  font-size: 11px;
  line-height: normal;
  letter-spacing: 0.33px;
  text-align: center;
  color: var(--text-default);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story__label--subtle {
  color: var(--text-subtle);
}

/* ─── Reel (full-bleed video/image post) ─── */
.reel {
  position: relative;
  width: 100%;
  height: calc(var(--phone-height) - var(--nav-height) - var(--tab-height));
}

.reel__media {
  position: relative;
  width: 100%;
  height: 100%;
  background: #111;
  overflow: hidden;
}

.reel__image,
.reel__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.reel__video-bg {
  width: 100%;
  height: 100%;
}

/* top-to-bottom dark gradient for reel header readability */
.reel__scrim {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 110px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}

/* bottom gradient for actions */
.reel__media::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 160px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.55) 0%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}

.reel__play-indicator {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}

/* Tap-to-play/pause flash indicator */
.reel__tap-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.12s ease;
  pointer-events: none;
  z-index: 6;
}

.reel__tap-indicator--visible {
  opacity: 1;
  transition: opacity 0s;
  animation: reel-indicator-fade 0.7s ease forwards;
}

.reel__tap-indicator--persistent {
  opacity: 1;
  animation: none;
}

@keyframes reel-indicator-fade {
  0%   { opacity: 1; }
  60%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Mute/unmute button — inline in the action bar row */
.reel__mute-btn {
  flex-shrink: 0;
}

.reel__header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 6px;
}

.reel__user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.reel__avatars {
  position: relative;
  width: 40px;
  height: 38px;
  flex-shrink: 0;
}

.reel__avatar {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
}

.reel__avatar--back {
  left: 12px;
  top: 0;
}

.reel__avatar--front {
  left: 0;
  top: 10px;
}

/* Single-poster: larger avatar, centred in its own container */
.reel__avatars--single {
  width: 36px;
  height: 36px;
}

.reel__avatar--single {
  width: 36px;
  height: 36px;
  left: 0;
  top: 0;
  border: 2px solid rgba(255, 255, 255, 0.9);
}

.reel__details {
  min-width: 0;
}

.reel__username {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 16px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.verified {
  flex-shrink: 0;
}

.reel__music {
  display: flex;
  align-items: center;
  gap: 3px;
  padding-left: 2px;
  font-size: 11px;
  line-height: 13px;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.reel__music svg {
  flex-shrink: 0;
}

.reel__dot {
  opacity: 0.85;
}

.reel__options {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-top: 7px;
  margin-right: 2px;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
  flex-shrink: 0;
  z-index: 3;
}

/* Reel action bar at the bottom */
.reel__actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 16px;
}

.reel__actions-left {
  display: flex;
  align-items: center;
  gap: 3px;
}

.reel__action-count {
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
  margin-right: 8px;
  color: #fff;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

.reel__action-btn {
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  padding: 0;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
}

/* ─── Standard Image Post ─── */
.post {
  background: var(--bg-default);
  border-bottom: 0.5px solid var(--border-subtler);
}

.post__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
}

.post__user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.post__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-subtler);
}

.post__user-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.post__username {
  font-size: 13px;
  font-weight: 600;
  line-height: 16px;
}

.post__location {
  font-size: 11px;
  color: var(--text-subtle);
  line-height: 14px;
}

.post__options {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: var(--text-default);
  cursor: pointer;
}

.post__image-wrap {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
}

.post__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.post__footer {
  padding: 10px 12px 14px;
}

.post__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.post__actions-left {
  display: flex;
  align-items: center;
  gap: 3px;
}

.post__action-count {
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
  margin-right: 8px;
  color: var(--text-default);
}

.post__action-btn {
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text-default);
  cursor: pointer;
  padding: 0;
}

.post__likes {
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
  margin-bottom: 3px;
}

.post__caption {
  font-size: 13px;
  line-height: 18px;
  color: var(--text-default);
  margin-bottom: 4px;
  white-space: pre-line;
}

.post__caption .emoji-img {
  display: inline;
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}

.post__hashtag {
  color: #00376b;
}

.post__time {
  font-size: 11px;
  color: var(--text-subtle);
  letter-spacing: 0.2px;
}

/* ─── Fixed: Tab Bar ─── */
.tab-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  height: var(--tab-height);
  background: var(--bg-default);
  border-top: 0.5px solid var(--border-subtler);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.tab-bar--hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

.tab-bar__tabs {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 4px;
}

.tab-bar__tab {
  position: relative;
  width: 75px;
  height: 51px;
  padding-top: 8px;
  border: 0;
  background: transparent;
  display: grid;
  place-items: start center;
  cursor: pointer;
}

.tab-bar__avatar {
  border-radius: 50%;
  object-fit: cover;
}


/* ─── Badges ─── */
.badge {
  position: absolute;
  border-radius: 50%;
  background: var(--icon-emphasized);
}

.badge--nav {
  width: 8px;
  height: 8px;
  top: 0;
  right: -2px;
  border: 1.5px solid var(--bg-default);
}

.badge--tab {
  width: 6px;
  height: 6px;
  top: 26px;
  left: 44px;
}

.badge--tab-avatar {
  border: 2px solid var(--bg-default);
}

/* ─── Splash Screen ─── */
.splash {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  transition: opacity 0.8s ease;
  pointer-events: none;
}

.splash.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.splash__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.splash__body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  text-align: center;
  padding: 0 24px;
}

/* Gradient shared by heading and friends text */
.splash__heading,
.splash__friends {
  background: linear-gradient(90deg, #833AB4 0%, #C13584 30%, #E1306C 55%, #F77737 80%, #FCAF45 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.splash__heading {
  width: 80%;
  max-width: 260px;
  height: auto;
  display: block;
  /* override the gradient-text rule for the img */
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  -webkit-text-fill-color: unset;
  animation: splash-pulse 2.4s ease-in-out infinite;
}

@keyframes splash-pulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%       { transform: scale(1.02); opacity: 0.9; }
}

.splash__sub {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.splash__from {
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  font-size: 13px;
  color: #aaa;
  letter-spacing: 0.01em;
}

.splash__friends {
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.splash__home-indicator {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 139px;
  height: 5px;
  background: #000;
  border-radius: 100px;
  opacity: 0.18;
}

/* ─── Story thumbnail: ring-spin on open ─── */
.story--has-story {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

@keyframes story-ring-spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.story--opening .story__ring-bg {
  animation: story-ring-spin 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Story Viewer ─── */
.sv {
  position: absolute;
  inset: 0;
  z-index: 200;
  background: #111;
  border-radius: inherit;
  overflow: hidden;
  animation: sv-enter 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center top;
}

@keyframes sv-enter {
  from { transform: scale(0.94); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.sv[hidden] { display: none; }

/* Media background */
.sv__bg {
  position: absolute;
  inset: 0;
}

.sv__img,
.sv__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.sv__bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.5)  0%,
    transparent      22%,
    transparent      78%,
    rgba(0,0,0,0.22) 100%
  );
  pointer-events: none;
}

/* UI overlay */
.sv__ui {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

/* Progress bars */
.sv__bars {
  display: flex;
  gap: 3px;
  padding: 14px 8px 4px;
}

.sv-bar {
  flex: 1;
  min-width: 0;
  height: 2px;
  background: rgba(255,255,255,0.38);
  border-radius: 2px;
  overflow: hidden;
}

.sv-bar__fill {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 2px;
  will-change: width;
}

/* Header */
.sv__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 8px;
  pointer-events: auto;
}

.sv__user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sv__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.85);
  object-fit: cover;
  flex-shrink: 0;
}

.sv__name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.sv__when {
  font-size: 11.5px;
  color: rgba(255,255,255,0.72);
  line-height: 1.2;
}

.sv__actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.sv__icon-btn {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 4; /* above tap zones (z-index: 3) */
}

/* Tap zones */
.sv__tap {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 45%;
  z-index: 3;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sv__tap--prev { left: 0; }
.sv__tap--next { right: 0; }

/* ─── Carousel Post ─── */
.carousel {
  position: relative;
  width: 100%;
}

.carousel__track-wrap {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: grab;
}

.carousel__track-wrap:active {
  cursor: grabbing;
}

.carousel__track {
  display: flex;
  height: 100%;
  will-change: transform;
}

.carousel__slide {
  flex: 0 0 100%;
  height: 100%;
  overflow: hidden;
}

/* Real image inside a slide — covers the square, cropped to centre */
.carousel__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Checkerboard placeholder — matches the design reference */
.carousel__placeholder {
  width: 100%;
  height: 100%;
  background-color: #e4e4e4;
  background-image:
    linear-gradient(45deg, #d2d2d2 25%, transparent 25%),
    linear-gradient(-45deg, #d2d2d2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d2d2d2 75%),
    linear-gradient(-45deg, transparent 75%, #d2d2d2 75%);
  background-size: 32px 32px;
  background-position: 0 0, 0 16px, 16px -16px, -16px 0;
}

/* "1/5" counter pill in the top-right corner */
.carousel__counter {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(28, 28, 28, 0.62);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 4px 9px;
  border-radius: 100px;
  pointer-events: none;
  z-index: 2;
  letter-spacing: 0.2px;
}

/* Prev / Next arrow buttons */
.carousel__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  opacity: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  z-index: 2;
  flex-shrink: 0;
}

.carousel__arrow--prev { left: 10px; }
.carousel__arrow--next { right: 10px; }

.carousel__arrow[hidden] { display: none; }

/* Dot indicators */
.carousel__dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 8px 0 0;
}

.carousel__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.18);
  transition: background 0.2s, width 0.2s;
  flex-shrink: 0;
}

.carousel__dot--active {
  background: #3897f0;
}

/* Carousel-specific action bar (icon + inline count) */
.carousel-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.carousel-actions__left {
  display: flex;
  align-items: center;
  gap: 3px;
}

.carousel-actions__count {
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
  margin-right: 8px;
  color: var(--text-default);
}

/* Liked-by row with mini avatars */
.post__liked-by {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 3px;
}

.post__liked-avatars {
  display: flex;
  flex-shrink: 0;
}

.post__liked-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--bg-default);
  margin-left: -5px;
}

.post__liked-avatar:first-child {
  margin-left: 0;
}

.post__liked-text {
  font-size: 13px;
  line-height: 18px;
  color: var(--text-default);
}

/* ─── Responsive: full screen on small devices ─── */
@media (max-width: 430px) {
  body {
    padding: 0;
    background: var(--bg-default);
  }

  .phone {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border: 0;
    box-shadow: none;
  }
}
