/* Load once in head, after the existing layout styles and theme overrides. */
html[data-sgc-mobile-guard-v25="1"] {
  --sgc-mobile-menu-height-v25: calc(72px + env(safe-area-inset-bottom, 0px));
}

/* This independent source mark survives the add-ons' route cleanup. */
html[data-sgc-mobile-guard-v25="1"] body [data-sgc-mobile-source-v25="home"],
html[data-sgc-mobile-guard-v25="1"] body [data-sgc-mobile-source-v25="mine"] {
  display: none !important;
}

/* The native My wrapper reserves a viewport even when its inner source is hidden. */
html[data-sgc-mobile-route-v25="mine"] body uni-page[data-page="pages/my/my"] uni-page-body > .my {
  display: none !important;
}

/* Only the current custom page/view can be painted during SPA handoff. */
html[data-sgc-mobile-guard-v25="1"]:not([data-sgc-mobile-route-v25="home"]) body uni-page[data-page="pages/index/index"],
html[data-sgc-mobile-guard-v25="1"]:not([data-sgc-mobile-route-v25="record"]) body uni-page[data-page="pages/detail/detail"],
html[data-sgc-mobile-guard-v25="1"]:not([data-sgc-mobile-route-v25="receive"]) body uni-page[data-page="pages/order/order"],
html[data-sgc-mobile-guard-v25="1"]:not([data-sgc-mobile-route-v25="service"]) body uni-page[data-page="pages/service/service"],
html[data-sgc-mobile-guard-v25="1"]:not([data-sgc-mobile-route-v25="mine"]) body uni-page[data-page="pages/my/my"],
html[data-sgc-mobile-guard-v25="1"]:not([data-sgc-mobile-route-v25="home"]) body .sgc-home-shell,
html[data-sgc-mobile-guard-v25="1"]:not([data-sgc-mobile-route-v25="mine"]) body .sgc-my-shell,
html[data-sgc-mobile-route-v25="mine"][data-sgc-mobile-view-v25="mine"] body .sgc-my-shell:not([data-view="mine"]),
html[data-sgc-mobile-route-v25="mine"][data-sgc-mobile-view-v25="profile"] body .sgc-my-shell:not([data-view="profile"]),
html[data-sgc-mobile-route-v25="mine"][data-sgc-mobile-view-v25="account-details"] body .sgc-my-shell:not([data-view="account-details"]),
html[data-sgc-mobile-route-v25="mine"][data-sgc-mobile-view-v25="daily-checkin"] body .sgc-my-shell:not([data-view="daily-checkin"]),
html[data-sgc-mobile-route-v25="mine"][data-sgc-mobile-view-v25="messages"] body .sgc-my-shell:not([data-view="messages"]),
html[data-sgc-mobile-route-v25="mine"][data-sgc-mobile-view-v25="about"] body .sgc-my-shell:not([data-view="about"]),
html[data-sgc-mobile-route-v25="mine"][data-sgc-mobile-view-v25="security"] body .sgc-my-shell:not([data-view="security"]) {
  display: none !important;
}

/* More specific than each legacy nav's route stylesheet, independent of load order. */
html[data-sgc-mobile-guard-v25="1"][data-sgc-mobile-primary-v25="1"] body .tabbar,
html[data-sgc-mobile-guard-v25="1"][data-sgc-mobile-primary-v25="1"] body uni-tabbar,
html[data-sgc-mobile-guard-v25="1"][data-sgc-mobile-primary-v25="1"] body .uni-tabbar,
html[data-sgc-mobile-guard-v25="1"][data-sgc-mobile-primary-v25="1"] body .feature-tabbar,
html[data-sgc-mobile-guard-v25="1"][data-sgc-mobile-primary-v25="1"] body .receive-tabbar-v15,
html[data-sgc-mobile-guard-v25="1"][data-sgc-mobile-primary-v25="1"] body .sgc-home-tabbar {
  display: none !important;
}

html[data-sgc-mobile-guard-v25="1"][data-sgc-mobile-primary-v25="0"] body .sgc-fixed-menu-v1 {
  display: none !important;
}

/* Keep native claim layout measurable while its existing enhancer prepares the first frame. */
html[data-sgc-mobile-route-v25="receive"] body uni-page[data-page="pages/order/order"] .order_container:not(.receive-page-sync-v15) {
  visibility: hidden !important;
}

/* The legacy service page is a webview; the current chat module owns .feature-page. */
html[data-sgc-mobile-route-v25="service"] body uni-page[data-page="pages/service/service"] uni-page-body > .service {
  display: none !important;
}

html[data-sgc-mobile-guard-v25="1"] body > iframe[src="https://shougongceshi.shop/sever"],
html[data-sgc-mobile-guard-v25="1"] body > iframe[src="/sever"] {
  display: none !important;
}

html[data-sgc-mobile-guard-v25="1"][data-sgc-mobile-primary-v25="1"] body .sgc-fixed-menu-v1 {
  height: var(--sgc-mobile-menu-height-v25) !important;
  min-height: var(--sgc-mobile-menu-height-v25) !important;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)) !important;
  box-sizing: border-box !important;
}

/* Keep the selected icon and its color inside the fixed menu. */
html[data-sgc-mobile-guard-v25="1"][data-sgc-mobile-primary-v25="1"] body .sgc-fixed-menu-v1 {
  overflow: hidden !important;
}

html[data-sgc-mobile-guard-v25="1"][data-sgc-mobile-primary-v25="1"] body .sgc-fixed-menu-v1 .sgc-fixed-menu-item-v1.is-active .sgc-fixed-menu-icon-v1 {
  width: 36px !important;
  height: 36px !important;
  flex: 0 0 36px !important;
  margin-top: 0 !important;
  transform: none !important;
  box-shadow: none !important;
}

/* Home and My share the document scroller. Other routes and modal internals keep their owners. */
html[data-sgc-mobile-route-v25="home"],
html[data-sgc-mobile-route-v25="mine"] {
  height: auto !important;
  min-height: 100% !important;
  overflow-x: hidden !important;
  overflow-x: clip !important;
  overflow-y: auto !important;
}

html[data-sgc-mobile-route-v25="home"] body,
html[data-sgc-mobile-route-v25="mine"] body {
  height: auto !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  overflow: visible !important;
}

html[data-sgc-mobile-route-v25="home"] :is(#app, uni-app, uni-page, uni-page-wrapper, uni-page-body),
html[data-sgc-mobile-route-v25="mine"] :is(#app, uni-app, uni-page, uni-page-wrapper, uni-page-body) {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
}

html[data-sgc-mobile-route-v25="home"] body .sgc-home-shell,
html[data-sgc-mobile-route-v25="mine"] body .sgc-my-shell {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  width: 100% !important;
  max-width: 480px !important;
  height: auto !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  max-height: none !important;
  margin-right: auto !important;
  margin-left: auto !important;
  padding-bottom: calc(var(--sgc-mobile-menu-height-v25) + 24px) !important;
  box-sizing: border-box !important;
  overflow: visible !important;
}

html[data-sgc-mobile-route-v25="record"] body uni-page-body > .detail,
html[data-sgc-mobile-route-v25="receive"] body .order_container.receive-page-sync-v15 {
  padding-bottom: calc(var(--sgc-mobile-menu-height-v25) + 16px) !important;
  box-sizing: border-box !important;
}

/* Existing service padding already includes its 72px menu and safe-area inset. */
@media (min-width: 481px) {
  html.mobile-canvas-desktop[data-sgc-mobile-primary-v25="1"] body .sgc-fixed-menu-v1 {
    right: auto !important;
    left: 50% !important;
    width: 480px !important;
    max-width: 480px !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
    transform: translateX(-50%) !important;
  }
}
