/* 指定前台页面共用薄顶栏，滚动时固定显示，不改变正文占位。 */
body.account-scroll-header-page {
  --account-header-height: calc(44px + env(safe-area-inset-top, 0px));
  --account-header-ink: #292d34;
  --account-header-paper: #fff;
  overscroll-behavior-y: none;
}

html.account-header-enabled { overscroll-behavior-y: none; }

/* 固定顶栏的祖先不能裁切视口，尤其是 iOS 顶部下拉时。 */
body.account-scroll-header-page.front-frame-page > .front-app-frame,
body.account-scroll-header-page.front-frame-page > .front-app-frame > .front-app-content,
body.account-scroll-header-page.front-frame-page > .front-app-frame > .front-app-content > .front-page-layer {
  overflow: visible !important;
}

html.front-night body.account-scroll-header-page {
  --account-header-ink: #f1f3f5;
  --account-header-paper: #24282e;
}

body.account-scroll-header-page :is([data-account-scroll-header], #orderSearchForm, #buyerAppView > [data-account-scroll-header]) {
  position: sticky !important;
  top: var(--account-header-viewport-top, 0px) !important;
  z-index: 1250 !important;
  display: grid !important;
  align-items: center !important;
  width: 100% !important;
  height: var(--account-header-height) !important;
  min-height: var(--account-header-height) !important;
  max-height: none !important;
  margin: 0 !important;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 14px 6px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  background-image: none !important;
  color: var(--account-header-ink) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  transform: none !important;
}

body.account-scroll-header-page .account-page-topbar[data-account-scroll-header],
body.account-scroll-header-page [data-detail-scroll-header] {
  grid-template-columns: 32px minmax(0, 1fr) 32px !important;
  column-gap: 10px !important;
}

body.account-scroll-header-page #buyerAppView > [data-account-scroll-header] {
  grid-template-columns: minmax(0, 1fr) auto !important;
}

body.account-scroll-header-page.account-header-ready :is([data-account-scroll-header], #orderSearchForm, #buyerAppView > [data-account-scroll-header]) {
  position: fixed !important;
  left: 50% !important;
  right: auto !important;
  width: min(430px, 100vw) !important;
  transform: translateX(-50%) !important;
  transition: background-color .2s ease, box-shadow .2s ease !important;
}

html.account-header-scrolled body.account-scroll-header-page :is([data-account-scroll-header], #orderSearchForm, #buyerAppView > [data-account-scroll-header]) {
  background: var(--account-header-paper) !important;
  box-shadow: 0 1px 0 rgba(120, 125, 135, .1) !important;
}

/* 回到页顶直接完整显示，避免回弹时停在收起动画的半截位置。 */
html:not(.account-header-scrolled) body.account-scroll-header-page :is([data-account-scroll-header], #orderSearchForm, #buyerAppView > [data-account-scroll-header]) {
  transition: none !important;
}

.account-scroll-header-space { height: var(--account-header-height); min-height: var(--account-header-height); flex: 0 0 var(--account-header-height); pointer-events: none; }

body.account-scroll-header-page .account-page-topbar[data-account-scroll-header] :is(a, button),
body.account-scroll-header-page [data-detail-scroll-header] :is(a, button),
body.account-scroll-header-page #orderSearchForm .user-order-top-actions,
body.account-scroll-header-page #orderSearchForm .user-order-top-actions button,
body.account-scroll-header-page #buyerAppView > [data-account-scroll-header] .icon-button {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  min-height: 32px !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  color: inherit !important;
  box-shadow: none !important;
}

body.account-scroll-header-page .account-page-topbar[data-account-scroll-header] h1,
body.account-scroll-header-page [data-detail-scroll-header] > strong,
body.account-scroll-header-page #orderSearchForm .user-order-title-slot > h1 {
  color: inherit !important;
  font-size: 14px !important;
  line-height: 1.3 !important;
}

/* 详情页保留标题与分享动作，仅统一顶栏外观和正文起点。 */
body.account-scroll-header-page [data-detail-scroll-header] > strong {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-weight: 800;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.account-scroll-header-page.front-frame-page > .front-app-frame [data-detail-scroll-header] > strong {
  font-size: 14px !important;
  line-height: 1.3 !important;
}
body.account-scroll-header-page [data-detail-scroll-header] :is(a, button) {
  display: grid;
  place-items: center;
  border-radius: 0 !important;
}
body.account-scroll-header-page [data-detail-scroll-header] :is(svg, img) {
  display: block;
  width: 20px;
  height: 20px;
}
body.account-scroll-header-page [data-detail-scroll-header] .product-top-actions {
  display: flex;
  justify-content: flex-end;
  min-width: 0;
}
/* 清除旧商品胶囊遗留的位置偏移，三个区域与订单中心使用同一条中心线。 */
body.account-scroll-header-page.front-frame-page > .front-app-frame [data-detail-scroll-header] {
  grid-template-columns: 32px minmax(0, 1fr) 32px !important;
}
body.account-scroll-header-page.front-frame-page > .front-app-frame [data-detail-scroll-header] > strong {
  width: 100% !important;
  max-width: none !important;
  justify-self: stretch;
}
body.account-scroll-header-page.front-frame-page > .front-app-frame [data-detail-scroll-header] > :is(button, strong, .product-top-actions) {
  position: static !important;
  inset: auto !important;
  align-self: center !important;
  margin: 0 !important;
  transform: none !important;
}
body.account-scroll-header-page.front-frame-page > .front-app-frame [data-detail-scroll-header] :is(#productBackBtn, #shareProductBtn, #shopBackBtn, #shopShareBtn),
body.account-scroll-header-page.front-frame-page > .front-app-frame [data-detail-scroll-header] > .product-top-actions {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  min-height: 32px !important;
}
body.account-scroll-header-page.front-frame-page > .front-app-frame [data-detail-scroll-header] :is(#productBackBtn, #shareProductBtn, #shopBackBtn, #shopShareBtn) {
  position: static !important;
  inset: auto !important;
  display: grid !important;
  place-items: center !important;
  padding: 0 !important;
  color: inherit !important;
  transform: none !important;
}
body.account-scroll-header-page.front-frame-page > .front-app-frame [data-detail-scroll-header] :is(#productBackBtn, #shopBackBtn) svg {
  width: 22px !important;
  height: 22px !important;
}
body.account-scroll-header-page.detail-header-page .front-app-frame :is(.product-detail-shell, .public-shop-shell, .tutorial-shell),
body.account-scroll-header-page.detail-header-page :is(.product-detail-shell, .public-shop-shell, .tutorial-shell) {
  padding-top: 0 !important;
}
body.detail-header-page .account-scroll-header-space {
  margin-bottom: 8px;
}
body.detail-header-page .tutorial-article {
  padding-top: 0;
}
body.detail-header-page .tutorial-article-head {
  padding-top: 4px;
}

body.account-scroll-header-page #orderSearchForm .user-order-title-slot { height: 32px; }
body.account-scroll-header-page #orderSearchForm .user-order-search-field { height: 32px; }
body.account-scroll-header-page #buyerAppView > [data-account-scroll-header] .brand { min-width: 0; gap: 8px; }
body.account-scroll-header-page #buyerAppView > [data-account-scroll-header] .brand > img { width: 26px; height: 26px; border-radius: 7px; }
body.account-scroll-header-page #buyerAppView > [data-account-scroll-header] .brand-copy strong { color: inherit; font-size: 14px; }

/* 订单筛选始终位于固定顶栏下方，保留独立的透明背景。 */
body.account-scroll-header-page.account-header-ready.user-order-page .user-page-shell {
  padding-top: 8px !important;
}
body.account-scroll-header-page.user-order-page #userOrderTabs {
  z-index: 1200 !important;
  top: calc(var(--account-header-viewport-top, 0px) + var(--account-header-height)) !important;
  transition: none;
}
/* 订单筛选保留透明底色，不再随顶栏切换为白色背景。 */
body.account-scroll-header-page.user-order-page #userOrderTabs {
  background: transparent !important;
}

/* 售后记录单独滚动，始终为固定顶栏留出空间。 */
body.account-scroll-header-page.is-chat [data-account-scroll-header] {
  top: var(--message-viewport-top, 0px) !important;
}
body.account-scroll-header-page.is-chat #messageHistory {
  top: calc(var(--message-viewport-top, 0px) + var(--account-header-height)) !important;
  overflow-anchor: none;
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  body.account-scroll-header-page :is([data-account-scroll-header], #orderSearchForm, #buyerAppView > [data-account-scroll-header], #userOrderTabs, #messageHistory) { transition: none !important; }
}
