.app-account-panel {
  z-index: 2201 !important;
  isolation: isolate;
  background: #ffffff !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/*
 * The account sheet is injected on feature pages that do not necessarily load
 * the shared generated stylesheet. Own the closed-state rule here so a panel
 * with the `hidden` class cannot render as a full mobile sheet on those pages.
 */
.app-account-panel.hidden {
  display: none !important;
}

.app-account-sheet-heading {
  display: none;
}

.app-account-backdrop {
  display: none;
}

.app-account-friends-link {
  text-decoration: none;
}

.app-account-friends-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.app-account-friends-copy strong,
.app-account-friends-copy small {
  display: block;
}

.app-account-friends-copy small {
  font-size: 0.76rem;
  font-weight: 750;
  line-height: 1.35;
}

.app-account-friends-arrow {
  margin-left: auto;
  font-size: 1.7rem;
  line-height: 1;
}

@media (max-width: 720px) {
  .mobile-app-header,
  .mobile-global-nav {
    background: #ffffff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    isolation: isolate;
  }

  .mobile-global-nav {
    border-top-color: rgba(124, 58, 237, 0.18) !important;
    box-shadow: 0 -8px 28px rgba(47, 37, 67, 0.14) !important;
  }

  body.mobile-app-standalone {
    min-height: 100vh;
    min-height: 100dvh;
  }

  /*
   * iOS Home Screen fallback: keep app chrome in normal document flow.
   * This deliberately trades persistent fixed chrome for compositor safety in
   * standalone WebKit, where fixed layers can intermittently cover page content.
   */
  body.mobile-app-chrome-ready.mobile-app-standalone {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  body.mobile-app-standalone .mobile-app-header {
    position: static !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: 100% !important;
    height: calc(58px + env(safe-area-inset-top));
    min-height: calc(58px + env(safe-area-inset-top));
    max-height: calc(58px + env(safe-area-inset-top));
    box-sizing: border-box;
    flex: 0 0 auto;
  }

  body.mobile-app-standalone .mobile-global-nav {
    position: static !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: 100% !important;
    height: calc(64px + env(safe-area-inset-bottom));
    min-height: calc(64px + env(safe-area-inset-bottom));
    max-height: calc(64px + env(safe-area-inset-bottom));
    box-sizing: border-box;
    margin-top: 8px;
    flex: 0 0 auto;
  }

  /*
   * The Library reproduced the same WebKit blank/occluded lower-page failure in
   * ordinary iPhone Safari, not only in Home Screen mode. During normal Library
   * browsing, keep both shared chrome layers in document flow so no fixed
   * compositor layer can cover or clip Library cards. Deep-link Return flows are
   * excluded because they intentionally use the immersive fixed Return control.
   */
  body.account-settings-page.mobile-app-chrome-ready:not(.mobile-contextual-return) {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  body.account-settings-page:not(.mobile-contextual-return) .mobile-app-header {
    position: static !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: 100% !important;
    height: calc(58px + env(safe-area-inset-top));
    min-height: calc(58px + env(safe-area-inset-top));
    max-height: calc(58px + env(safe-area-inset-top));
    box-sizing: border-box;
    flex: 0 0 auto;
  }

  body.account-settings-page:not(.mobile-contextual-return) .mobile-global-nav {
    position: static !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: 100% !important;
    height: calc(64px + env(safe-area-inset-bottom));
    min-height: calc(64px + env(safe-area-inset-bottom));
    max-height: calc(64px + env(safe-area-inset-bottom));
    box-sizing: border-box;
    margin-top: 8px;
    flex: 0 0 auto;
  }

  body.app-account-menu-open {
    overflow: hidden;
    overscroll-behavior: none;
  }

  body.app-account-menu-open .mobile-global-nav {
    opacity: 0;
    transform: translateY(115%);
    pointer-events: none;
  }

  .app-account-backdrop {
    position: fixed;
    z-index: 2200;
    inset: 0;
    display: block;
    background: rgba(31, 21, 43, 0.48);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: account-menu-fade-in 140ms ease-out both;
  }

  .app-account-backdrop.hidden {
    display: none !important;
  }

  .app-account-panel.app-account-mobile-sheet {
    position: fixed !important;
    z-index: 2201 !important;
    top: calc(70px + env(safe-area-inset-top)) !important;
    right: 12px !important;
    bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    left: 12px !important;
    width: auto !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 16px !important;
    gap: 10px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    border: 1px solid rgba(72, 39, 102, 0.16) !important;
    border-radius: 26px !important;
    background: #ffffff !important;
    box-shadow: 0 30px 90px rgba(37, 28, 49, 0.34) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    animation: account-menu-sheet-in 180ms cubic-bezier(.2, .8, .2, 1) both;
  }

  .app-account-sheet-heading {
    position: sticky;
    z-index: 2;
    top: -16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: -16px -16px 2px;
    padding: 15px 16px 12px;
    border-bottom: 1px solid rgba(72, 39, 102, 0.1);
    background: #ffffff;
  }

  .app-account-sheet-heading > strong {
    color: #251c31;
    font-size: 1.02rem;
  }

  .app-account-sheet-close {
    min-height: 40px;
    padding: 8px 13px;
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 999px;
    color: #5b21b6;
    background: #f5f3ff;
    font: inherit;
    font-weight: 900;
  }

  .app-account-panel .app-account-email {
    margin-top: 2px;
    color: #251c31;
    font-size: 1.02rem;
    overflow-wrap: anywhere;
  }

  .app-account-panel .app-account-status {
    margin-bottom: 4px;
    color: #776d83;
    line-height: 1.35;
  }

  .app-account-panel .app-account-menu-link,
  .app-account-panel .app-account-signout {
    width: 100%;
    min-height: 56px;
    padding: 13px 15px !important;
    border: 1px solid rgba(72, 39, 102, 0.13) !important;
    border-radius: 17px !important;
    color: #4c1d95 !important;
    background: #faf8ff !important;
    box-shadow: none !important;
    font-weight: 900 !important;
    text-align: left;
  }

  .app-account-panel .app-account-menu-link {
    display: flex !important;
    align-items: center;
    gap: 12px;
  }

  .app-account-panel .app-account-friends-link {
    min-height: 78px;
    color: #ffffff !important;
    border-color: transparent !important;
    background: linear-gradient(135deg, #6d28d9, #8b5cf6 58%, #ec4899) !important;
    box-shadow: 0 16px 32px rgba(109, 40, 217, 0.24) !important;
  }

  .app-account-panel .app-account-friends-link:focus-visible {
    outline-color: rgba(236, 72, 153, 0.42);
  }

  .app-account-friends-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.18);
    font-size: 1.32rem;
  }

  .app-account-friends-copy small {
    color: rgba(255, 255, 255, 0.82);
  }

  .app-account-panel .app-account-signout {
    margin-top: 4px;
    color: #6b2145 !important;
    background: #fff7fb !important;
    text-align: center;
  }
}

@keyframes account-menu-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes account-menu-sheet-in {
  from { opacity: 0; transform: translateY(-8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .app-account-backdrop,
  .app-account-panel.app-account-mobile-sheet {
    animation: none !important;
  }
}

/*
 * Account Settings already receives bottom-nav clearance from the shared mobile
 * shell. The feature stylesheet's older 150px mobile allowance predates that
 * global shell and otherwise creates a large empty tail below Library cards.
 * Preserve the larger allowance only when a wheel deep-link activates the
 * fixed contextual Return bar (the shared nav is hidden in that state).
 */
@media (max-width: 720px) {
  body.account-settings-page .account-settings-shell {
    padding-bottom: 24px;
  }

  body.account-settings-page.mobile-contextual-return .account-settings-shell {
    padding-bottom: 150px;
  }
}

/*
 * iOS Library compositor-safe mode.
 *
 * The persistent device failure survives removing fixed shared chrome, so the
 * remaining mobile Library surface intentionally avoids the other high-risk
 * WebKit compositor inputs as well: fixed blurred decoration, backdrop blur,
 * animated transforms, and large layered shadows. This is page-local and does
 * not change normal app chrome or contextual Return flows on other surfaces.
 */
@media (max-width: 720px) {
  body.account-settings-page:not(.mobile-contextual-return) {
    background: #fbf9ff !important;
  }

  body.account-settings-page:not(.mobile-contextual-return) .background-orb {
    display: none !important;
  }

  body.account-settings-page:not(.mobile-contextual-return) .account-settings-shell {
    position: relative;
    z-index: 1;
  }

  body.account-settings-page:not(.mobile-contextual-return) .hero,
  body.account-settings-page:not(.mobile-contextual-return) .panel,
  body.account-settings-page:not(.mobile-contextual-return) .library-overview-card {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
  }

  body.account-settings-page:not(.mobile-contextual-return) .hero,
  body.account-settings-page:not(.mobile-contextual-return) .panel,
  body.account-settings-page:not(.mobile-contextual-return) .library-overview-card {
    background: #ffffff !important;
  }

  body.account-settings-page:not(.mobile-contextual-return) .library-overview-card {
    transform: none !important;
    transition: none !important;
    text-decoration: none;
  }

  body.account-settings-page:not(.mobile-contextual-return) .mobile-app-header,
  body.account-settings-page:not(.mobile-contextual-return) .mobile-global-nav {
    transform: none !important;
    transition: none !important;
  }

  body.account-settings-page:not(.mobile-contextual-return) .app-account-backdrop,
  body.account-settings-page:not(.mobile-contextual-return) .app-account-panel.app-account-mobile-sheet {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    animation: none !important;
  }

  body.account-settings-page:not(.mobile-contextual-return) .skip-link {
    position: absolute;
  }
}
