:root {
  color-scheme: light;
  --ig-black: #0b0b0b;
  --ig-blue: #00376b;
  --ig-link: #00376b;
  --ig-border: #dbdbdb;
  --ig-soft: #efefef;
  --ig-muted: #737373;
  --screen-width: 430px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(94, 46, 94, 0.08), transparent 32%),
    radial-gradient(circle at 82% 88%, rgba(16, 86, 112, 0.07), transparent 34%),
    #ececed;
  color: var(--ig-black);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
  font: inherit;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.phone-shell {
  position: relative;
  width: min(var(--screen-width), calc((100dvh - 36px) * 0.51));
  min-width: 340px;
  height: min(890px, calc(100dvh - 36px));
  padding: 10px;
  overflow: hidden;
  border: 7px solid #a5a5a7;
  border-radius: 56px;
  background: #090909;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.15);
}

.device-notch {
  position: absolute;
  z-index: 90;
  top: 10px;
  left: 50%;
  width: 47%;
  height: 31px;
  transform: translateX(-50%);
  border-radius: 0 0 20px 20px;
  background: #090909;
  pointer-events: none;
}

.phone-screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 40px;
  background: #fff;
}

.app-scroll {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.app-scroll::-webkit-scrollbar,
.highlights::-webkit-scrollbar,
.stories-row::-webkit-scrollbar {
  display: none;
}

.view {
  min-height: 100%;
  padding-bottom: 61px;
  background: #fff;
}

.view[hidden] {
  display: none;
}

.top-safe {
  height: 29px;
  background: #fff;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 13px;
  border-bottom: 1px solid rgba(219, 219, 219, 0.55);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
}

.profile-topbar {
  justify-content: space-between;
  border-bottom-color: transparent;
}

.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-size: 1rem;
  font-weight: 700;
}

.topbar-actions,
.post-actions,
.post-actions-left {
  display: flex;
  align-items: center;
}

.topbar-actions {
  gap: 9px;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  padding: 7px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.icon-button:hover {
  background: rgba(0, 0, 0, 0.045);
}

.icon-button:focus-visible,
.profile-action:focus-visible,
.grid-post:focus-visible,
.story:focus-visible,
.nav-button:focus-visible,
.carousel-button:focus-visible,
.reel-control:focus-visible {
  outline: 2px solid #1c74d9;
  outline-offset: 2px;
}

.icon {
  display: block;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.icon.small {
  width: 17px;
  height: 17px;
}

.instagram-wordmark {
  margin-right: auto;
  font-family: "Brush Script MT", "Segoe Script", cursive;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
}

.profile-header {
  padding: 15px 14px 0;
}

.profile-overview {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.avatar-wrap {
  width: 100px;
  height: 100px;
  padding: 3px;
  border-radius: 50%;
  background: linear-gradient(145deg, #f9ce34 3%, #ee2a7b 48%, #6228d7 90%);
}

.avatar {
  width: 100%;
  height: 100%;
  padding: 2px;
  border-radius: 50%;
  background: #fff;
  object-fit: cover;
}

.profile-name {
  margin: 0 0 12px;
  font-size: 0.93rem;
  font-weight: 700;
  line-height: 1.24;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 0;
  text-align: center;
}

.stat {
  min-width: 0;
}

.stat strong,
.stat span {
  display: block;
}

.stat strong {
  font-size: 0.98rem;
  line-height: 1.1;
}

.stat span {
  margin-top: 2px;
  font-size: 0.72rem;
  line-height: 1.1;
}

.profile-copy {
  margin-top: 15px;
  font-size: 0.86rem;
  line-height: 1.34;
}

.category {
  margin-bottom: 2px;
  color: #8e8e8e;
}

.profile-copy p {
  margin: 0;
}

.bio-link {
  display: inline-block;
  margin-top: 3px;
  color: var(--ig-link);
  font-weight: 600;
  text-decoration: none;
}

.email-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 35px;
  color: var(--ig-black);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
}

.profile-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr 38px;
  gap: 6px;
  margin-top: 9px;
}

.profile-action {
  min-height: 35px;
  padding: 0 11px;
  border: 0;
  border-radius: 8px;
  background: var(--ig-soft);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: default;
}

.profile-action.icon-only {
  display: grid;
  padding: 0;
  place-items: center;
}

.highlights {
  display: flex;
  gap: 15px;
  margin: 18px -14px 0;
  padding: 0 14px 14px;
  overflow-x: auto;
  scrollbar-width: none;
}

.highlight {
  flex: 0 0 70px;
  margin: 0;
  text-align: center;
}

.highlight-image {
  width: 67px;
  height: 67px;
  padding: 2px;
  border: 1px solid #cfcfcf;
  border-radius: 50%;
  background: #fff;
  object-fit: cover;
}

.highlight figcaption {
  margin-top: 7px;
  overflow: hidden;
  font-size: 0.64rem;
  letter-spacing: 0.035em;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: 43px;
  border-top: 1px solid var(--ig-border);
}

.profile-tab {
  position: relative;
  display: grid;
  border: 0;
  background: #fff;
  place-items: center;
}

.profile-tab.active::before {
  position: absolute;
  top: -1px;
  right: 0;
  left: 0;
  height: 1px;
  background: var(--ig-black);
  content: "";
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  padding-bottom: 2px;
  background: #fff;
}

.grid-spacer,
.grid-post {
  aspect-ratio: 3 / 4;
}

.grid-spacer {
  background: #fff;
}

.grid-post {
  position: relative;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #f4f4f4;
  cursor: pointer;
}

.grid-post img {
  width: 100%;
  height: 100%;
  transition: transform 180ms ease;
  object-fit: cover;
}

.grid-post:hover img {
  transform: scale(1.02);
}

.grid-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

.home-topbar {
  gap: 3px;
}

.stories-row {
  display: flex;
  gap: 8px;
  padding: 12px 10px 13px;
  overflow-x: auto;
  border-bottom: 1px solid var(--ig-border);
  scrollbar-width: none;
}

.story {
  flex: 0 0 76px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: center;
}

.story-static {
  cursor: default;
  pointer-events: none;
  user-select: none;
}

.story-reference {
  display: block;
  width: 74px;
  height: 74px;
  margin: 0 auto 5px;
  border-radius: 50%;
  background: #fff;
  object-fit: cover;
}

.story-ring {
  width: 65px;
  height: 65px;
  margin: 0 auto 5px;
  padding: 3px;
  border-radius: 50%;
  background: linear-gradient(145deg, #f9ce34 3%, #ee2a7b 48%, #6228d7 90%);
}

.story-ring.seen {
  padding: 2px;
  background: #d7d7d7;
}

.story-ring img {
  width: 100%;
  height: 100%;
  padding: 2px;
  border-radius: 50%;
  background: #fff;
  object-fit: cover;
}

.story-label {
  display: block;
  overflow: hidden;
  font-size: 0.67rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-caption {
  padding: 0 12px 13px;
  font-size: 0.8rem;
  line-height: 1.38;
  overflow-wrap: anywhere;
}

.home-caption p {
  margin: 0 0 10px;
}

.home-caption p:last-child {
  margin-bottom: 0;
}

.home-caption strong {
  margin-right: 3px;
  font-weight: 700;
}

.caption-hashtags {
  color: var(--ig-blue);
}

.feed-post {
  border-bottom: 1px solid var(--ig-border);
  background: #fff;
}

.post-head {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 54px;
  padding: 8px 10px;
}

.post-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.post-user {
  min-width: 0;
  font-size: 0.79rem;
  font-weight: 700;
}

.post-menu {
  margin-left: auto;
}

.media-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: #111;
  touch-action: pan-y;
}

.media-frame > img,
.media-frame > video,
.reel-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.carousel {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111;
  touch-action: pan-y;
  user-select: none;
}

.carousel-track {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 260ms cubic-bezier(0.2, 0.74, 0.26, 1);
  will-change: transform;
}

.carousel.dragging .carousel-track {
  transition: none;
}

.carousel-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  background: #111;
}

.carousel-slide img,
.carousel-slide video {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  object-fit: cover;
}

.carousel-button {
  position: absolute;
  z-index: 4;
  top: 50%;
  display: grid;
  width: 31px;
  height: 31px;
  padding: 0;
  transform: translateY(-50%);
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.carousel-button.prev {
  left: 9px;
}

.carousel-button.next {
  right: 9px;
}

.carousel-button[hidden] {
  display: none;
}

.carousel-counter {
  position: absolute;
  z-index: 4;
  top: 12px;
  right: 12px;
  min-width: 40px;
  padding: 5px 8px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.63);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
}

.reel-shell {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.reel-play {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 58px;
  height: 58px;
  transform: translate(-50%, -50%);
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.43);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.reel-shell.paused .reel-play {
  opacity: 1;
}

.reel-control {
  position: absolute;
  z-index: 5;
  right: 12px;
  bottom: 12px;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
}

.post-actions {
  justify-content: space-between;
  min-height: 45px;
  padding: 3px 8px 1px;
}

.post-actions-left {
  gap: 1px;
}

.post-dots {
  position: absolute;
  left: 50%;
  display: flex;
  gap: 4px;
  transform: translateX(-50%);
}

.post-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c7c7c7;
}

.post-dot.active {
  background: #0095f6;
}

.post-spacer {
  min-height: 9px;
}

.bottom-nav {
  position: absolute;
  z-index: 50;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: 59px;
  padding-bottom: max(2px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--ig-border);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
}

.nav-button {
  position: relative;
  display: grid;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.nav-button[aria-current="page"] .icon {
  stroke-width: 2.5;
}

.nav-avatar {
  width: 26px;
  height: 26px;
  padding: 1px;
  border: 1px solid transparent;
  border-radius: 50%;
  object-fit: cover;
}

.nav-button[aria-current="page"] .nav-avatar {
  border-color: var(--ig-black);
}

.post-modal {
  position: absolute;
  z-index: 100;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  color: var(--ig-black);
}

.post-modal[hidden] {
  display: none;
}

#modalBody {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

#modalBody::-webkit-scrollbar {
  display: none;
}

.modal-head {
  position: relative;
  z-index: 20;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 78px;
  padding: 26px 9px 4px;
  border-bottom: 1px solid var(--ig-border);
  background: #fff;
}

.modal-head #modalClose {
  position: absolute;
  bottom: 8px;
  left: 7px;
}

.modal-heading {
  display: grid;
  gap: 1px;
  place-items: center;
  line-height: 1.08;
}

.modal-title {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
}

.modal-profile-name {
  color: var(--ig-muted);
  font-size: 0.64rem;
  font-weight: 600;
}

.detail-feed-post {
  position: relative;
  border-bottom: 8px solid #f2f2f2;
  scroll-margin-top: 0;
}

.detail-feed-post .media-frame {
  width: 100%;
  background: #000;
}

.detail-carousel-post .media-frame {
  aspect-ratio: 4 / 5;
}

.detail-reel-post .media-frame {
  aspect-ratio: 9 / 16;
}

.detail-reel-post > .post-head {
  position: absolute;
  z-index: 8;
  top: 0;
  right: 0;
  left: 0;
  color: #fff;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}

.detail-reel-post > .post-head .post-avatar {
  border: 1px solid rgba(255, 255, 255, 0.9);
}

.detail-reel-post > .post-head .icon-button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.detail-feed-post .post-actions {
  position: relative;
}

.detail-feed-post .home-caption {
  padding-bottom: 18px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 520px) {
  body {
    display: block;
    overflow: hidden;
    background: #fff;
  }

  .phone-shell {
    width: 100%;
    min-width: 0;
    height: 100vh;
    height: 100dvh;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .device-notch {
    display: none;
  }

  .phone-screen {
    border-radius: 0;
  }

  .top-safe {
    height: max(7px, env(safe-area-inset-top));
  }

  .modal-head {
    min-height: calc(55px + env(safe-area-inset-top));
    padding-top: max(3px, env(safe-area-inset-top));
  }
}

@media (max-width: 370px) {
  .profile-overview {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 12px;
  }

  .avatar-wrap {
    width: 82px;
    height: 82px;
  }

  .profile-name {
    font-size: 0.84rem;
  }

  .stats {
    gap: 3px;
  }

  .stat strong {
    font-size: 0.89rem;
  }

  .stat span {
    font-size: 0.66rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
