/* Profile stability pass: preserve the mobile identity card while editing. */
@media (min-width: 761px) {
  /* Recent projects may change, the desktop grid must not. */
  .product-side-panel {
    min-height: 486px;
    max-height: 486px;
    grid-template-rows: auto 154px auto auto auto minmax(0, 1fr);
    align-content: start;
  }

  .product-side-panel .recent-projects {
    min-height: 154px;
    max-height: 154px;
    overflow: hidden;
    position: relative;
    align-content: start;
  }

  .product-side-panel .recent-projects::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 28px;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,.98));
  }
}

@media (max-width: 760px) {
  /* The profile is a real scroll page, rather than a clipped flex child. */
  #mobileProfilePage.is-active {
    display: block;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  #mobileProfilePage .m-scroll-content {
    margin: 0;
    min-height: 0;
    overflow: visible;
    padding: 12px 11px calc(44px + env(safe-area-inset-bottom));
  }

  #mobileProfilePage .m-profile-hero {
    overflow: hidden;
    border-radius: 24px;
  }

  /* Editing only folds away stats: cover, avatar, name and ID keep their place. */
  #mobileProfileContent.is-editing .m-profile-hero {
    height: auto;
    min-height: 0;
    overflow: hidden !important;
    border-radius: 24px;
  }

  #mobileProfileContent.is-editing .m-profile-cover {
    position: static;
    inset: auto;
    height: 118px;
    border-radius: 0;
  }

  #mobileProfileContent.is-editing .m-profile-main {
    display: block;
    min-height: 0;
    height: auto;
    padding: 0 16px 15px;
    background: var(--m-tile);
  }

  #mobileProfileContent.is-editing .m-profile-avatar {
    display: block;
    width: 78px;
    height: 78px;
    margin-top: -38px;
    border-width: 4px;
  }

  #mobileProfileContent.is-editing .m-profile-main h2 {
    margin: 8px 0 0;
    color: var(--m-ink);
    font-size: 22px;
  }

  #mobileProfileContent.is-editing .m-profile-main p {
    margin: 4px 0 0;
    color: var(--m-muted);
  }

  #mobileProfileContent.is-editing .m-profile-stats { display: none; }

  /* Match the recovery control's height and make each achievement an honest tap target. */
  #mobileProfileContent .m-mobile-achievements {
    min-height: 56px;
    height: 56px;
    padding: 6px 10px !important;
    align-items: center;
    gap: 8px;
  }

  #mobileProfileContent .m-mobile-achievements button {
    width: 42px !important;
    min-width: 42px;
    height: 42px !important;
    flex-basis: 42px;
    border-radius: 13px !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  #mobileProfileContent .m-mobile-achievements button i { font-size: 21px !important; }
  #mobileProfileContent .m-mobile-achievements button:active { transform: scale(.9); }

  .m-achievement-popover {
    margin: -2px 1px 2px;
    padding: 10px 12px;
    border: 1px solid rgba(6,93,253,.2);
    border-radius: 15px;
    color: #17417f;
    background: rgba(232,240,255,.98);
    box-shadow: 0 10px 25px rgba(27,48,91,.12);
    font-size: 12px;
    line-height: 1.35;
    animation: mobile-achievement-pop 180ms cubic-bezier(.2,1.2,.3,1);
  }

  .m-achievement-popover[hidden] { display: none; }

  @keyframes mobile-achievement-pop {
    from { opacity: 0; transform: translateY(-5px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }

  /* Toasts belong above the mobile app, never beneath its fixed shell. */
  .toast { z-index: 1200 !important; }
}
