/* 排盘 / 独立结果页统一顶栏 .pan-result-topbar
 *
 * 两套顶栏（互斥，由「是否在结果态」决定，不要互相点才出现）：
 *   选盘态 = 顶部导航类目（#setupPageHeader：大六壬/奇门/…）
 *   结果态 = 结果导航栏（#setupResultTopbar：返回 + 标题）
 *
 * 结果态判定：各术数 *-has-result / 八字紫微 .result-area.show
 */
:root {
  --result-topbar-action-height: 30px;
  --result-topbar-pad-block: 13.2px;
  --result-topbar-border: 1px;
  --bazi-result-tabs-height: 42px;
  --result-topbar-offset: calc(
    var(--result-topbar-pad-block) + var(--result-topbar-action-height) + var(--result-topbar-border) +
      env(safe-area-inset-top, 0px)
  );
}

/* 选盘态：结果导航栏默认藏 */
#setupResultTopbar[hidden] {
  display: none !important;
}

/* 选盘态：给固定顶部类目留空；结果态改用结果顶栏高度 */
body.setup-page:not(.module-nav-visible):not(:has(.liuren-setup-embed.liuren-has-result)):not(:has(.qimen-setup-embed.qimen-has-result)):not(:has(.yinpan-setup-embed.yinpan-has-result)):not(:has(.liuyao-setup-embed.liuyao-has-result)):not(:has(.meihua-setup-embed.meihua-has-result)):not(:has(.bazi-setup-embed .result-area.show)):not(:has(.ziwei-setup-embed .result-area.show)) {
  padding-top: var(--setup-header-offset, calc(48px + env(safe-area-inset-top, 0px))) !important;
}
body.setup-page.module-nav-visible,
body.setup-page:has(.liuren-setup-embed.liuren-has-result),
body.setup-page:has(.qimen-setup-embed.qimen-has-result),
body.setup-page:has(.yinpan-setup-embed.yinpan-has-result),
body.setup-page:has(.liuyao-setup-embed.liuyao-has-result),
body.setup-page:has(.meihua-setup-embed.meihua-has-result),
body.setup-page:has(.bazi-setup-embed .result-area.show),
body.setup-page:has(.ziwei-setup-embed .result-area.show) {
  padding-top: var(--result-topbar-offset) !important;
}

/* ========== 结果态：自动显示「结果导航栏」========== */
body.setup-page.module-nav-visible #setupResultTopbar,
body.setup-page:has(.liuren-setup-embed.liuren-has-result) #setupResultTopbar,
body.setup-page:has(.qimen-setup-embed.qimen-has-result) #setupResultTopbar,
body.setup-page:has(.yinpan-setup-embed.yinpan-has-result) #setupResultTopbar,
body.setup-page:has(.liuyao-setup-embed.liuyao-has-result) #setupResultTopbar,
body.setup-page:has(.meihua-setup-embed.meihua-has-result) #setupResultTopbar,
body.setup-page:has(.bazi-setup-embed .result-area.show) #setupResultTopbar,
body.setup-page:has(.ziwei-setup-embed .result-area.show) #setupResultTopbar {
  display: grid !important;
}

/* ========== 结果态：自动隐藏「顶部导航类目」========== */
body.setup-page.module-nav-visible .setup-page-header,
body.setup-page:has(.liuren-setup-embed.liuren-has-result) .setup-page-header,
body.setup-page:has(.qimen-setup-embed.qimen-has-result) .setup-page-header,
body.setup-page:has(.yinpan-setup-embed.yinpan-has-result) .setup-page-header,
body.setup-page:has(.liuyao-setup-embed.liuyao-has-result) .setup-page-header,
body.setup-page:has(.meihua-setup-embed.meihua-has-result) .setup-page-header,
body.setup-page:has(.bazi-setup-embed .result-area.show) .setup-page-header,
body.setup-page:has(.ziwei-setup-embed .result-area.show) .setup-page-header {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.pan-result-topbar,
#setupResultTopbar:not([hidden]) {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 55;
  box-sizing: border-box;
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding: calc(6.6px + env(safe-area-inset-top, 0px)) 12px 6.6px;
  background: var(--pan-result-topbar-bg, #fff);
  border-bottom: 1px solid #cfcfcf;
  border-radius: 0 !important;
  border-top-left-radius: 0 !important;
  border-top-right-radius: 0 !important;
  display: grid !important;
  grid-template-columns: minmax(36px, auto) minmax(0, 1fr) minmax(36px, auto);
  grid-template-rows: auto;
  align-items: center;
  column-gap: 6px;
  gap: 0;
  min-height: 0;
  overflow: visible;
}

/* 八字：Tab 在顶栏框架内、标题正下方，同一白底同一底边框 */
#setupResultTopbar .pan-result-topbar__tabs {
  display: none;
  grid-column: 1 / -1;
  grid-row: 2;
  box-sizing: border-box;
  width: calc(100% + 24px);
  margin: 0 -12px;
  padding: 0;
  background: var(--pan-result-tabs-bg, #fff);
  border: 0;
}
#setupResultTopbar.has-bazi-tabs,
body.setup-page:has(.bazi-setup-embed .result-area.show) #setupResultTopbar:not([hidden]) {
  grid-template-rows: auto auto !important;
  padding: calc(6.6px + env(safe-area-inset-top, 0px)) 12px 0 !important;
  row-gap: 0 !important;
  column-gap: 6px;
  align-items: stretch !important;
  gap: 0 6px !important;
}
#setupResultTopbar.has-bazi-tabs .pan-result-topbar__tabs,
body.setup-page:not(.bazi-dark-bg):has(.bazi-setup-embed .result-area.show) #setupResultTopbar:not([hidden]) .pan-result-topbar__tabs {
  display: block !important;
  margin: 0 -12px !important;
  padding: 0 !important;
  border: 0 none !important;
  background: #fff !important;
}
body.setup-page.bazi-dark-bg:has(.bazi-setup-embed .result-area.show) #setupResultTopbar:not([hidden]) .pan-result-topbar__tabs,
body.setup-page.bazi-dark-bg #setupResultTopbar.has-bazi-tabs .pan-result-topbar__tabs {
  display: block !important;
  margin: 0 -12px !important;
  padding: 0 !important;
  border: 0 none !important;
  background: #111 !important;
  background-color: #111 !important;
}
/* 八字深色：顶栏整块（含 Tab）强制黑底 */
html.bazi-dark-bg #setupResultTopbar,
html.bazi-dark-bg #setupResultTopbar .pan-result-topbar__tabs,
html.bazi-dark-bg #setupResultTopbarTabs,
html.bazi-dark-bg #setupBaziResultSwitcher,
html.bazi-dark-bg #setupResultTopbar .pan-result-topbar__tabs .result-switcher,
body.bazi-dark-bg #setupResultTopbar,
body.bazi-dark-bg #setupResultTopbar .pan-result-topbar__tabs,
body.bazi-dark-bg #setupResultTopbarTabs,
body.bazi-dark-bg #setupBaziResultSwitcher,
body.bazi-dark-bg #setupResultTopbar .pan-result-topbar__tabs .result-switcher,
body.setup-page.bazi-dark-bg:has(.bazi-setup-embed .result-area.show) #setupResultTopbar,
body.setup-page.bazi-dark-bg:has(.bazi-setup-embed .result-area.show) #setupResultTopbar .pan-result-topbar__tabs,
body.setup-page.bazi-dark-bg:has(.bazi-setup-embed .result-area.show) #setupBaziResultSwitcher {
  background: #111 !important;
  background-color: #111 !important;
  color: #e8e8e8 !important;
  border-bottom-color: #2a2a2a !important;
  border-color: #2a2a2a !important;
}
html.bazi-dark-bg #setupResultTopbar .pan-result-topbar__title,
html.bazi-dark-bg #setupResultTopbar .topbar-title,
body.bazi-dark-bg #setupResultTopbar .pan-result-topbar__title,
body.bazi-dark-bg #setupResultTopbar .topbar-title {
  color: #eaeaea !important;
}
html.bazi-dark-bg #setupResultTopbar .result-switch-btn,
body.bazi-dark-bg #setupResultTopbar .result-switch-btn {
  color: #9a9a9a !important;
  background: transparent !important;
}
html.bazi-dark-bg #setupResultTopbar .result-switch-btn.active,
body.bazi-dark-bg #setupResultTopbar .result-switch-btn.active {
  color: #fff !important;
}
html.bazi-dark-bg #setupResultTopbar .pan-result-topbar__back,
html.bazi-dark-bg #setupResultTopbar .back-btn,
html.bazi-dark-bg #setupResultTopbar .detail-settings-btn,
body.bazi-dark-bg #setupResultTopbar .pan-result-topbar__back,
body.bazi-dark-bg #setupResultTopbar .back-btn,
body.bazi-dark-bg #setupResultTopbar .detail-settings-btn {
  background: #222 !important;
  border-color: #444 !important;
  color: #ddd !important;
}
#setupResultTopbar .pan-result-topbar__tabs .result-switcher,
#setupResultTopbar.has-bazi-tabs .pan-result-topbar__tabs .result-switcher {
  position: static !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  z-index: auto !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 none !important;
  box-shadow: none !important;
}
#setupResultTopbar .pan-result-topbar__tabs .result-switch-btn {
  padding: 8px 4px 9px !important;
}
/* setup：内容区那份 Tab 隐藏，只保留顶栏框架内的 */
body.setup-page .bazi-setup-embed .result-area > .result-switcher {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 none !important;
}
body.setup-page.module-nav-visible:has(#setupResultTopbar.has-bazi-tabs:not([hidden])),
body.setup-page:has(.bazi-setup-embed .result-area.show) {
  --bazi-result-tabs-height: 38px;
  --result-topbar-offset: calc(
    6.6px + var(--result-topbar-action-height) + var(--bazi-result-tabs-height) + var(--result-topbar-border) +
      env(safe-area-inset-top, 0px)
  );
}
body.setup-page.module-nav-visible .bazi-setup-embed .result-area.show {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

body:has(> .pan-result-topbar:not([hidden])) {
  padding-top: var(--result-topbar-offset);
}

body:has(> .app > .pan-result-topbar) {
  padding-top: 0;
}

.app:has(> .pan-result-topbar) {
  padding-top: var(--result-topbar-offset);
}

/* 顶栏下方间距 */
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ .setup-mode-panel.active {
  padding-top: 5px !important;
  margin-top: 0 !important;
  box-sizing: border-box;
}

/* 八字：顶栏已含 Tab，面板顶距清零（写在通用 gap 规则之后） */
body.setup-page.module-nav-visible:has(#setupResultTopbar.has-bazi-tabs:not([hidden])) #setupResultTopbar:not([hidden]) ~ .setup-mode-panel[data-mode-panel="bazi"].active,
body.setup-page.module-nav-visible:has(.bazi-setup-embed .result-area.show) #setupResultTopbar:not([hidden]) ~ .setup-mode-panel[data-mode-panel="bazi"].active {
  padding-top: 0 !important;
  margin-top: 0 !important;
}

body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ .setup-mode-panel[data-mode-panel="meihua"].active .meihua-setup-embed.meihua-has-result #meihua-result-panel .result-card {
  margin-top: 0 !important;
  border-top-left-radius: 10px !important;
  border-top-right-radius: 10px !important;
}

body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ .setup-mode-panel.active > .setup-card,
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ .setup-mode-panel.active > .bazi-setup-embed {
  margin-top: 0 !important;
}

body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ .liuren-setup-embed.liuren-has-result .result-area.show,
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ #liuren-result-panel {
  margin-top: 0 !important;
}

/* 八字/紫微：贴顶直角 */
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ .bazi-setup-embed .result-area.show,
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ .bazi-setup-embed .result-area.show > .result-card:first-child,
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ .ziwei-setup-embed .result-area.show,
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ .ziwei-setup-embed .result-area.show > .chart-panel {
  margin-top: 0 !important;
  border-top-left-radius: 0 !important;
  border-top-right-radius: 0 !important;
}

body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ .ziwei-setup-embed .result-area.show > .chart-panel {
  padding-top: 0 !important;
}

/* 其余结果顶卡：贴顶 + 左右上圆角 */
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ #liuren-result-panel .main-card,
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ .qimen-setup-embed .qm-main-card,
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ #yinpan-result-panel .yp-main-card,
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ #yinpan-result-panel .main-card,
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ #liuyao-result-panel .main-card,
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ #meihua-result-panel .result-card {
  margin-top: 0 !important;
  border-top-left-radius: 10px !important;
  border-top-right-radius: 10px !important;
  border-bottom-left-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
}

body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ #yinpan-result-panel,
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ #qimen-result-panel,
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ #liuren-result-panel,
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ #liuyao-result-panel,
body.setup-page.module-nav-visible #setupResultTopbar:not([hidden]) ~ #meihua-result-panel {
  margin-top: 0 !important;
}

.pan-result-topbar .pan-result-topbar__title,
.pan-result-topbar .topbar-title,
#setupResultTopbar .pan-result-topbar__title,
#setupResultTopbar .topbar-title {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  align-self: center;
  flex: unset;
  margin: 0;
  padding: 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #000;
  letter-spacing: 0.02em;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.pan-result-topbar .pan-result-topbar__back,
.pan-result-topbar .back-btn,
#setupResultTopbar .pan-result-topbar__back,
#setupResultTopbar .back-btn {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  align-self: center;
  position: relative;
  z-index: 2;
  width: 30px;
  height: 30px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid #c8c8c8;
  background: #efefef;
  color: #666;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin: 0;
  text-decoration: none;
  box-shadow: none;
  flex-shrink: 0;
  pointer-events: auto !important;
}

.pan-result-topbar .pan-result-topbar__tools,
.pan-result-topbar > .topbar-actions,
.pan-result-topbar > .topbar-tabs,
#setupResultTopbar .pan-result-topbar__tools,
#setupResultTopbar > .topbar-actions,
#setupResultTopbar > .topbar-tabs {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  align-self: center;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.pan-result-topbar .topbar-tabs,
#setupResultTopbar .topbar-tabs {
  display: none;
  align-items: center;
  gap: 4px;
}

.pan-result-topbar .topbar-tabs.show,
#setupResultTopbar .topbar-tabs.show {
  display: inline-flex !important;
}

#setupResultTopbar .setup-result-settings-wrap {
  display: none;
  position: relative;
  align-items: center;
}

#setupResultTopbar .setup-result-settings-wrap.show {
  display: inline-flex !important;
}

.pan-result-topbar .topbar-settings-btn,
.pan-result-topbar .detail-settings-btn,
#setupResultTopbar .topbar-settings-btn,
#setupResultTopbar .detail-settings-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid #c8c8c8;
  background: #efefef;
  color: #666;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin: 0;
}

.pan-result-topbar .topbar-tabs .tab-btn,
#setupResultTopbar .topbar-tabs .tab-btn {
  border: 1px solid #d0d0d0;
  background: #fff;
  color: #666;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
}

.pan-result-topbar .topbar-tabs .tab-btn.active,
#setupResultTopbar .topbar-tabs .tab-btn.active {
  background: #222;
  border-color: #222;
  color: #fff;
}

.pan-result-topbar .detail-settings-pop,
.pan-result-topbar .topbar-settings-pop,
#setupResultTopbar .detail-settings-pop,
#setupResultTopbar .topbar-settings-pop {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 160px;
  padding: 8px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.pan-result-topbar .detail-settings-pop.show,
.pan-result-topbar .topbar-settings-pop.show,
#setupResultTopbar .detail-settings-pop.show,
#setupResultTopbar .topbar-settings-pop.show {
  display: block;
}

.pan-result-topbar .detail-setting-item,
.pan-result-topbar .topbar-setting-item,
#setupResultTopbar .detail-setting-item,
#setupResultTopbar .topbar-setting-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  user-select: none;
}

.pan-result-topbar .detail-setting-item.detail-setting-action,
#setupResultTopbar .detail-setting-item.detail-setting-action {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  font: inherit;
}

.pan-result-topbar .detail-setting-item input,
.pan-result-topbar .topbar-setting-item input,
#setupResultTopbar .detail-setting-item input,
#setupResultTopbar .topbar-setting-item input {
  margin: 0;
}

#setupResultTopbar .detail-setting-view-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 4px 10px;
  border-bottom: 1px solid #eee;
  margin-bottom: 4px;
  cursor: default;
}
#setupResultTopbar .detail-setting-view-label {
  font-size: 13px;
  color: #333;
  flex-shrink: 0;
}
#setupResultTopbar .detail-setting-seg {
  display: inline-flex;
  border: 1px solid #ccc;
  border-radius: 8px;
  overflow: hidden;
  background: #f3f3f3;
}
#setupResultTopbar .detail-view-seg {
  border: none;
  background: transparent;
  padding: 6px 12px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  line-height: 1.2;
}
#setupResultTopbar .detail-view-seg + .detail-view-seg {
  border-left: 1px solid #ccc;
}
#setupResultTopbar .detail-view-seg.active {
  background: #1a1a1a;
  color: #fff;
}

#setupResultTopbar .detail-settings-pop {
  right: 0;
  left: auto;
}

/* 八字设置：灰色风格 */
#setupResultTopbar #setupBaziSettingsBtn.detail-settings-btn {
  background: #dcdcdc;
  border-color: #c4c4c4;
  color: #555;
}
#setupResultTopbar #setupBaziSettingsBtn.detail-settings-btn:hover {
  background: #d0d0d0;
  color: #333;
}
#setupResultTopbar #setupBaziSettingsPop.detail-settings-pop {
  min-width: 188px;
  padding: 10px 12px;
  background: #e8e8e8;
  border: 1px solid #c8c8c8;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
  display: none;
  flex-direction: column;
  gap: 8px;
}
#setupResultTopbar #setupBaziSettingsPop.detail-settings-pop.show {
  display: flex;
}
#setupResultTopbar #setupBaziSettingsPop .detail-setting-item {
  color: #3a3a3a;
  padding: 7px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.35);
}
#setupResultTopbar #setupBaziSettingsPop .detail-setting-item:hover {
  background: rgba(255, 255, 255, 0.55);
}
#setupResultTopbar #setupBaziSettingsPop .detail-setting-item input {
  accent-color: #666;
}

@media (max-width: 360px) {
  .pan-result-topbar .pan-result-topbar__title,
  .pan-result-topbar .topbar-title,
  #setupResultTopbar .pan-result-topbar__title,
  #setupResultTopbar .topbar-title {
    font-size: 0.95rem;
  }

  .pan-result-topbar .pan-result-topbar__back,
  .pan-result-topbar .back-btn,
  #setupResultTopbar .pan-result-topbar__back,
  #setupResultTopbar .back-btn {
    width: 28px;
    height: 28px;
  }

  .pan-result-topbar .topbar-settings-btn,
  .pan-result-topbar .detail-settings-btn,
  #setupResultTopbar .topbar-settings-btn,
  #setupResultTopbar .detail-settings-btn {
    width: 28px;
    height: 28px;
  }
}

/* ========== 小程序 web-view（?from=mp）：压过上方 ID 选择器 ========== */
html.mp-webview #setupResultTopbar .pan-result-topbar__back,
html.mp-webview #setupResultTopbar .back-btn,
html.mp-webview #setupResultTopbar #setupResultBackBtn,
html.mp-webview .pan-result-topbar .pan-result-topbar__back,
html.mp-webview .pan-result-topbar .back-btn,
html.mp-webview .pan-result-topbar .pan-result-topbar__title,
html.mp-webview .pan-result-topbar .topbar-title,
html.mp-webview #setupResultTopbar .pan-result-topbar__title,
html.mp-webview #setupResultTopbar .topbar-title,
html.mp-webview #setupResultTopbar .detail-settings-btn,
html.mp-webview #setupResultTopbar .topbar-settings-btn,
html.mp-webview #setupResultTopbar .header-user,
html.mp-webview .app-header,
body.mp-webview #setupResultTopbar .pan-result-topbar__back,
body.mp-webview #setupResultTopbar .back-btn,
body.mp-webview #setupResultTopbar #setupResultBackBtn,
body.mp-webview .pan-result-topbar .pan-result-topbar__back,
body.mp-webview .pan-result-topbar .back-btn,
body.mp-webview .pan-result-topbar .pan-result-topbar__title,
body.mp-webview .pan-result-topbar .topbar-title,
body.mp-webview #setupResultTopbar .pan-result-topbar__title,
body.mp-webview #setupResultTopbar .topbar-title,
body.mp-webview #setupResultTopbar .detail-settings-btn,
body.mp-webview #setupResultTopbar .topbar-settings-btn,
body.mp-webview #setupResultTopbar .header-user,
body.mp-webview .app-header {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  width: 0 !important;
  height: 0 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  overflow: hidden !important;
}

/* 无八字 tabs 时整条顶栏收起（大六壬详细/简洁已进设置，不再占顶） */
html.mp-webview #setupResultTopbar:not(.has-bazi-tabs),
body.mp-webview #setupResultTopbar:not(.has-bazi-tabs),
html.mp-webview .pan-result-topbar:not(.has-bazi-tabs):not(#setupResultTopbar),
body.mp-webview .pan-result-topbar:not(.has-bazi-tabs):not(#setupResultTopbar) {
  min-height: 0 !important;
  height: 0 !important;
  padding: 0 !important;
  border: none !important;
  overflow: visible !important;
  background: transparent !important;
  pointer-events: none !important;
}

/* 八字：只留第二行 tabs，藏掉返回/标题/设置那一行 */
html.mp-webview #setupResultTopbar.has-bazi-tabs,
html.mp-webview body.setup-page #setupResultTopbar.has-bazi-tabs,
body.mp-webview #setupResultTopbar.has-bazi-tabs,
body.mp-webview.setup-page #setupResultTopbar.has-bazi-tabs {
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: auto !important;
  padding: env(safe-area-inset-top, 0px) 0 0 !important;
  column-gap: 0 !important;
  row-gap: 0 !important;
  gap: 0 !important;
  align-items: stretch !important;
  background: #fff !important;
  pointer-events: auto !important;
  height: auto !important;
  min-height: 0 !important;
  border-bottom: 1px solid #cfcfcf !important;
}
html.mp-webview #setupResultTopbar.has-bazi-tabs > .pan-result-topbar__tools,
body.mp-webview #setupResultTopbar.has-bazi-tabs > .pan-result-topbar__tools {
  display: none !important;
}
html.mp-webview #setupResultTopbar.has-bazi-tabs > .pan-result-topbar__tabs,
html.mp-webview #setupResultTopbar.has-bazi-tabs #setupResultTopbarTabs,
body.mp-webview #setupResultTopbar.has-bazi-tabs > .pan-result-topbar__tabs,
body.mp-webview #setupResultTopbar.has-bazi-tabs #setupResultTopbarTabs {
  display: block !important;
  grid-column: 1 / -1 !important;
  grid-row: 1 !important;
  width: 100% !important;
  margin: 0 !important;
  pointer-events: auto !important;
  visibility: visible !important;
  height: auto !important;
}

/* 大六壬：顶栏详细/简洁隐藏，改走设置弹层 */
html.mp-webview #setupLiurenViewTabs > .tab-btn,
body.mp-webview #setupLiurenViewTabs > .tab-btn {
  display: none !important;
}
html.mp-webview #setupLiurenViewTabs .detail-settings-btn,
body.mp-webview #setupLiurenViewTabs .detail-settings-btn {
  display: none !important;
}
html.mp-webview #setupLiurenSettingsPop.show,
body.mp-webview #setupLiurenSettingsPop.show {
  display: flex !important;
  flex-direction: column;
  pointer-events: auto !important;
  visibility: visible !important;
  height: auto !important;
  width: max-content;
  min-width: 220px;
}

html.mp-webview,
body.mp-webview {
  --result-topbar-offset: env(safe-area-inset-top, 0px);
}
html.mp-webview:has(#setupResultTopbar.has-bazi-tabs:not([hidden])),
body.mp-webview:has(#setupResultTopbar.has-bazi-tabs:not([hidden])) {
  --result-topbar-offset: calc(42px + env(safe-area-inset-top, 0px));
}

body.mp-webview.setup-page.bazi-dark-bg #setupResultTopbar.has-bazi-tabs {
  background: #111 !important;
  border-bottom-color: #2a2a2a !important;
}

/* 小程序结果态：类目顶栏必须藏（web-view 对 [hidden]/:has 支持不稳） */
html.mp-webview body.setup-page.module-nav-visible #setupPageHeader,
html.mp-webview body.setup-page.module-nav-visible .setup-page-header,
body.mp-webview.setup-page.module-nav-visible #setupPageHeader,
body.mp-webview.setup-page.module-nav-visible .setup-page-header,
html.mp-webview #setupPageHeader[hidden],
body.mp-webview #setupPageHeader[hidden],
html.mp-webview .setup-page-header[hidden],
body.mp-webview .setup-page-header[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  height: 0 !important;
  max-height: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
}
