.bwe-support-shell {
  --bwe-support-ink: #111312;
  --bwe-support-paper: #efefeb;
  --bwe-support-line: #5b5e5b;
  --bwe-support-signal: #ed2533;
  /* V-08:暗面上的信号红文字用提亮阶(#111312 上 7.17:1);描边/渐变仍用 --bwe-support-signal */
  --bwe-support-signal-text: #ff7578;
}

.bwe-support-launch {
  position: fixed;
  z-index: 1029;
  /* D3(2026-09-03 K3):第三方 FAB 占据右下 20~64px,launcher 抬到其上方,垂直成栈 */
  inset: auto 20px 72px auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 236px;
  min-height: 52px;
  padding: 8px 10px;
  /* V-07(2026-09-02 K3):开启器是 <a>,平台方案链接色会压过这里——暗面上「NEED HELP?」
     草稿实测 1.58:1;用 !important 钉死 paper 色 */
  color: var(--bwe-support-paper) !important;
  background: var(--bwe-support-ink);
  border: 1px solid var(--bwe-support-line);
  border-inline-start: 5px solid var(--bwe-support-signal);
  border-radius: 0;
  box-shadow: 5px 5px 0 rgb(0 0 0 / 25%);
  font: 700 13px/1.15 "Courier New", Courier, monospace;
  letter-spacing: 0.04em;
  text-align: left;
  cursor: pointer;
}

.bwe-support-launch__signal {
  width: 10px;
  height: 10px;
  background: var(--bwe-support-paper);
  border: 1px solid currentColor;
  border-radius: 50%;
  animation: bwe-support-pulse 2.4s ease-out infinite;
}

/* 可见性(2026-08-31 店主反馈"找不到入口"):信号点呼吸,吸引视线但不喧哗 */
@keyframes bwe-support-pulse {
  0% { box-shadow: 0 0 0 0 rgb(237 37 51 / 55%); }
  70% { box-shadow: 0 0 0 9px rgb(237 37 51 / 0%); }
  100% { box-shadow: 0 0 0 0 rgb(237 37 51 / 0%); }
}

/* ── 首访提示气泡:锚在入口上方,纸面质感,点正文即开窗 ── */
.bwe-support-nudge {
  position: fixed;
  z-index: 1030;
  /* D3:launcher 抬到 72px 后,nudge 抬到 72+52+8=132,不与 FAB/launcher 相碰 */
  inset: auto 20px 132px auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px;
  align-items: start;
  width: min(300px, calc(100vw - 40px));
  padding: 10px 12px;
  color: var(--bwe-support-ink);
  background: var(--bwe-support-paper);
  border: 2px solid var(--bwe-support-ink);
  border-inline-start: 5px solid var(--bwe-support-signal);
  box-shadow: 5px 5px 0 rgb(0 0 0 / 25%);
  font: 700 12px/1.45 "Courier New", Courier, monospace;
}

.bwe-support-nudge[hidden] {
  display: none;
}

/* 产品页不出气泡:右下角是变体选择/购买路径,10 秒遮挡得不偿失(入口按钮仍在) */
body[data-page-type="product"] .bwe-support-nudge,
body[data-page-type="cart"] .bwe-support-nudge {
  display: none !important;
}

.bwe-support-nudge__body {
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.bwe-support-nudge__body:hover {
  color: #a30e20;
}

.bwe-support-nudge__close {
  min-width: 24px;
  min-height: 24px;
  /* D7(2026-09-03 K3):命中区 44×44(负 margin 保持布局不挤邻居) */
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  margin: -10px;
  color: inherit;
  background: transparent;
  border: 0;
  font: 700 16px/1 "Courier New", Courier, monospace;
  cursor: pointer;
}

.bwe-support-launch__copy {
  display: grid;
  gap: 3px;
}

.bwe-support-launch__copy strong,
.bwe-support-launch__copy small {
  font: inherit;
}

.bwe-support-launch__copy small {
  color: #c8cac5;
  font-size: 13px;
}

.bwe-support-launch__action {
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  color: var(--bwe-support-ink);
  background: var(--bwe-support-paper);
}

.bwe-support-launch:hover,
.bwe-support-launch:focus-visible,
.bwe-product-trust a:hover,
.bwe-product-trust a:focus-visible,
.bwe-support-dialog :is(a, button):focus-visible {
  outline: 3px solid var(--bwe-support-signal);
  outline-offset: 3px;
}

.bwe-support-dialog:not([hidden]) {
  position: fixed;
  z-index: 100100;
  inset: 0;
  display: grid;
  align-items: end;
  justify-items: end;
  padding: 20px;
}

.bwe-support-dialog__backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  background: rgb(9 10 10 / 72%);
  border: 0;
  cursor: pointer;
}

.bwe-support-dialog__panel {
  position: relative;
  width: min(100%, 480px);
  max-height: min(720px, calc(100dvh - 40px));
  overflow: auto;
  color: var(--bwe-support-ink);
  background: var(--bwe-support-paper);
  border: 2px solid var(--bwe-support-ink);
  box-shadow: 8px 8px 0 rgb(0 0 0 / 35%);
}

.bwe-support-dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  color: var(--bwe-support-paper);
  background: var(--bwe-support-ink);
  border-block-end: 5px solid var(--bwe-support-signal);
}

.bwe-support-dialog__header span {
  font: 700 11px/1.2 "Courier New", Courier, monospace;
  letter-spacing: 0.09em;
}

.bwe-support-dialog__header h2 {
  margin: 5px 0 0;
  color: inherit;
  font: 700 clamp(24px, 5vw, 34px)/1.05 "Arial Black", Arial, sans-serif;
  text-transform: uppercase;
}

.bwe-support-dialog__close,
.bwe-support-dialog__dismiss {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid currentColor;
  border-radius: 0;
  font: 700 14px/1 "Courier New", Courier, monospace;
  cursor: pointer;
}

.bwe-support-dialog__close {
  color: var(--bwe-support-paper);
  background: transparent;
  font-size: 26px;
}

.bwe-support-dialog__status {
  padding: 18px;
  border-block-end: 1px solid var(--bwe-support-line);
}

.bwe-support-dialog__status strong {
  font: 700 13px/1.2 "Courier New", Courier, monospace;
  letter-spacing: 0.07em;
}

.bwe-support-dialog__status p,
.bwe-support-dialog__empty {
  margin: 8px 0 0;
  font: 400 15px/1.5 Arial, sans-serif;
}

.bwe-support-dialog__routes {
  display: grid;
}

.bwe-support-dialog__routes a {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 4px 10px;
  min-height: 64px;
  padding: 12px 18px;
  color: var(--bwe-support-ink);
  border-block-end: 1px solid var(--bwe-support-line);
  text-decoration: none;
}

.bwe-support-dialog__routes a > span {
  grid-row: 1 / span 2;
  color: #a30e20;
  font: 700 13px/1.2 "Courier New", Courier, monospace;
}

.bwe-support-dialog__routes strong {
  font: 700 14px/1.2 "Courier New", Courier, monospace;
  letter-spacing: 0.035em;
}

.bwe-support-dialog__routes small {
  font: 400 13px/1.3 Arial, sans-serif;
}

.bwe-support-dialog__empty {
  padding: 18px;
}

.bwe-support-dialog__dismiss {
  width: calc(100% - 36px);
  margin: 18px;
  color: var(--bwe-support-paper);
  background: var(--bwe-support-ink);
}

html.bwe-support-open {
  overflow: hidden;
}

.bwe-product-trust {
  display: grid;
  gap: 10px;
  padding: 14px;
  margin-block-start: 12px;
  color: var(--bwe-support-ink);
  background: rgb(255 255 255 / 38%);
  border: 1px solid var(--bwe-support-line);
  border-inline-start: 5px solid var(--bwe-support-signal);
}

.bwe-product-trust__heading {
  margin: 0;
  font: 700 12px/1.2 "Courier New", Courier, monospace;
  letter-spacing: 0.08em;
}

.bwe-product-trust__routes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.bwe-product-trust a {
  display: grid;
  align-content: center;
  min-height: 44px;
  padding: 8px 10px;
  color: inherit;
  background: var(--bwe-support-paper);
  border: 1px solid currentColor;
  font: 700 12px/1.25 "Courier New", Courier, monospace;
  text-align: center;
  text-decoration: none;
}

@media (max-width: 820px) {
  /* 2026-09-04 修复:此覆盖曾为 4/5 列(早于聊天项与沉浸开关入列),第 6 项折到第二行。
     与 public/bwe-archive.css 的 5/6 列对齐,保证标签栏恒为一行;标签 nowrap 防单元格内折行。 */
  .bwe-archive-ui .bigwhite-mobile-tabbar {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .bwe-archive-ui .bigwhite-mobile-tabbar--with-fx {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .bwe-archive-ui .bigwhite-mobile-tabbar__item span {
    white-space: nowrap;
  }

  /* 2026-08-31 店主反馈:悬浮块占太多可视空间 → 收紧为 44×44(WCAG 触控最小值)。
     长文案 "NEED HELP?" 在窄方块里会折行撑高,移动端改用短标签 HELP(__action)。 */
  .bwe-support-launch {
    inset: auto 12px calc(96px + env(safe-area-inset-bottom, 0px)) auto;
    min-width: 0;
    width: 44px;
    min-height: 44px;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    justify-items: center;
    gap: 4px;
    padding: 7px 4px;
    border-inline-start-width: 4px;
    box-shadow: 3px 3px 0 rgb(0 0 0 / 25%);
    text-align: center;
  }

  /* D1/D2(2026-09-03 K3):首页底部的 RELEASE FEED/INDEX 控制台条(~113px)是最高的——
     launcher 抬到其上方 120px,不再压条,也不再与 nudge 相碰 */
  body[data-page-type="index"] .bwe-support-launch {
    inset-block-end: calc(140px + env(safe-area-inset-bottom, 0px)); /* D1/D2:实测 deck 条高 120+10 底距,抬到 140 脱开 20px */
  }

  .bwe-support-launch__signal {
    width: 7px;
    height: 7px;
  }

  .bwe-support-launch__copy {
    display: none;
  }

  .bwe-support-launch__action {
    display: block;
    min-width: 0;
    min-height: 0;
    padding: 0;
    color: var(--bwe-support-paper);
    background: transparent;
    font-size: 10px;
    letter-spacing: 0.04em;
  }

  .bwe-support-nudge {
    inset: auto 12px calc(148px + env(safe-area-inset-bottom, 0px)) auto;
    width: min(260px, calc(100vw - 24px));
    font-size: 11px;
  }

  /* D1:nudge 抬到 launcher(120+44)上方 10px,不再压住 INDEX/NEW PRODUCTS 入口 */
  body[data-page-type="index"] .bwe-support-nudge {
    inset-block-end: calc(194px + env(safe-area-inset-bottom, 0px));
  }

  body[data-page-type="product"]:has(.is-sticky > .product-detail__buy-buttons) .bwe-support-launch,
  body[data-page-type="product"]:has(.is-sticky > .block-product-buy-button-group) .bwe-support-launch {
    /* The bottom navigation keeps its Chat entry; avoid covering the variable-height purchase panel. */
    display: none;
    pointer-events: none;
  }

  .bwe-support-dialog:not([hidden]) {
    inset-block-end: calc(88px + env(safe-area-inset-bottom, 0px));
    padding: 10px;
  }

  .bwe-support-dialog__panel {
    width: 100%;
    max-height: calc(100dvh - 108px - env(safe-area-inset-bottom, 0px));
  }

  .bwe-product-trust__routes {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 821px) {
  /* Product imagery and purchase fields keep their space; the full desk opens on click. */
  body[data-page-type="product"] .bwe-support-launch {
    min-width: 0;
    width: 64px;
    min-height: 52px;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 4px;
    padding: 8px 4px;
    inset-inline-end: 12px;
  }

  body[data-page-type="product"] .bwe-support-launch__copy,
  body[data-page-type="product"] .bwe-support-launch__signal {
    display: none;
  }

  body[data-page-type="product"] .bwe-support-launch__action {
    min-width: 0;
    min-height: 0;
    color: var(--bwe-support-paper);
    background: transparent;
    font-size: 13px;
  }

  body:has(.is-sticky > .product-detail__buy-buttons) .bwe-support-launch,
  body:has(.is-sticky > .block-product-buy-button-group) .bwe-support-launch {
    inset-block-end: 96px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bwe-support-shell *,
  .bwe-support-shell *::before,
  .bwe-support-shell *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

/* 聊天窗版面板：加宽以容纳聊天与历史 */
.bwe-support-dialog__panel--chat {
  display: flex;
  flex-direction: column;
  width: min(480px, calc(100vw - 32px));
  max-height: min(720px, calc(100dvh - 40px));
  overflow: hidden;
}

.bwe-support-dialog__panel--chat > .bwe-support-dialog__header,
.bwe-support-dialog__panel--chat > .bwe-support-dialog__dismiss {
  flex: 0 0 auto;
}

.bwe-support-dialog__panel--chat > .bwe-support-dialog__dismiss {
  margin-block: 8px 12px;
}

.bwe-support-dialog__chat {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 16px;
}

/* Desktop support reserves reading space even with an empty or short history. */
@media (min-width: 821px) {
  .bwe-support-dialog__panel--chat {
    height: min(920px, calc(100dvh - 40px));
    max-height: calc(100dvh - 40px);
  }

  .bwe-support-dialog__panel--chat > .bwe-support-dialog__header {
    align-items: center;
    padding: 12px 16px;
  }

  .bwe-support-dialog__panel--chat .bwe-support-dialog__header h2 {
    margin-block-start: 4px;
    font-size: 24px;
  }

  .bwe-support-dialog__chat {
    flex: 1 1 auto;
  }

  .bwe-support-dialog__chat > .bwe-chat-widget {
    height: 100%;
    min-height: 0;
  }

  .bwe-support-dialog__chat > .bwe-chat-widget > * {
    flex: 0 0 auto;
  }

  .bwe-support-dialog__chat .bwe-chat-widget__history {
    flex: 1 1 0;
    min-height: 160px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .bwe-support-dialog__chat .bwe-chat-msg {
    flex: 0 0 auto;
  }
}

/* This final rule owns the chat budget, including the fixed mobile navigation. */
@media (max-width: 820px) {
  .bwe-support-dialog__panel--chat {
    width: 100%;
    max-height: calc(100dvh - 108px - env(safe-area-inset-bottom, 0px));
  }

  .bwe-support-dialog__header {
    padding: 12px;
  }

  .bwe-support-dialog__header h2 {
    font-size: 24px;
  }

  .bwe-support-dialog__chat {
    padding: 12px;
  }

  .bwe-support-nudge {
    font-size: 13px;
  }
}

.bwe-support-dialog__routes--compact a {
  padding: 8px 16px;
}

.bwe-support-dialog__routes--compact a small {
  display: none;
}

/* Membership shares this desk; its account data and transactions stay in the
   official app. Only a successfully connected app root receives these rules. */
.bwe-support-dialog__tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 0 0 auto;
  background: #1a1d1a;
  border-bottom: 1px solid var(--bwe-support-line);
}

.bwe-support-dialog__tabs > button {
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: #c8cac5;
  background: transparent;
  font: 700 12px/1.3 "Courier New", Courier, monospace;
  letter-spacing: .07em;
  cursor: pointer;
}

.bwe-support-dialog__tabs > button[aria-selected="true"] {
  color: var(--bwe-support-paper);
  border-bottom-color: var(--bwe-support-signal);
  background: rgb(255 255 255 / 4%);
}

.bwe-support-dialog__tabs > button:focus-visible {
  outline: 2px solid var(--bwe-support-paper);
  outline-offset: -5px;
}

.bwe-support-dialog__membership {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.bwe-support-dialog__member-host,
#member-system-plugin[data-bwe-member-docked] {
  flex: 1 1 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.bwe-support-dialog__member-host {
  display: flex;
  overflow: hidden;
}

.bwe-support-dialog__member-status {
  flex: 0 0 auto;
  padding: 12px 16px;
  font: 14px/1.5 Arial, sans-serif;
}

.bwe-support-dialog__member-status button {
  min-height: 44px;
  padding: 8px 12px;
  color: var(--bwe-support-paper);
  background: var(--bwe-support-ink);
  border: 1px solid var(--bwe-support-line);
  font: 700 12px/1.3 "Courier New", Courier, monospace;
}

.bwe-support-dialog__tabs[hidden],
.bwe-support-dialog__chat[hidden],
.bwe-support-dialog__membership[hidden],
.bwe-support-dialog__member-status[hidden],
.bwe-support-dialog__member-status button[hidden],
.bwe-support-shell[data-member-integrated] [data-bwe-chat-chip="member"],
.bwe-support-shell[data-member-integrated] [data-bwe-chat-card="member"],
#member-system-plugin[data-bwe-member-docked] > button[aria-label="Rewards"],
#member-system-plugin[data-bwe-member-docked] > button[aria-label="Close"] {
  display: none !important;
}

#member-system-plugin[data-bwe-member-docked] > [data-bwe-member-panel] {
  position: relative !important;
  inset: auto !important;
  display: grid !important;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  max-height: none !important;
  transform: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  overflow: hidden;
}

[data-bwe-member-panel] > .bwe-support-dialog__header {
  padding: 12px 16px;
}

[data-bwe-member-panel] > .bwe-support-dialog__dismiss {
  margin-block: 8px 12px;
}

[data-bwe-member-panel] > #sl-member-plugin-iframe-id,
[data-bwe-member-panel] #sl-member-plugin-iframe-id > div,
[data-bwe-member-panel] #sl-member-plugin-iframe-id > div > div,
[data-bwe-member-panel] #sl-member-plugin-iframe-id > div > div > div,
[data-bwe-member-panel] .proxy-member-page-layout {
  height: 100% !important;
  min-height: 0;
  max-height: 100%;
}

[data-bwe-member-panel] > #sl-member-plugin-iframe-id {
  min-width: 0;
  overflow: hidden;
}

.bwe-support-shell[data-member-panel="true"] .bwe-support-dialog__member-status {
  display: none;
}

@media (max-width: 820px) {
  .bwe-support-shell[data-support-view="member"] .bwe-support-dialog__panel--chat {
    height: calc(100dvh - 108px - env(safe-area-inset-bottom, 0px));
  }

  [data-bwe-member-panel] > .bwe-support-dialog__header {
    padding: 12px;
  }
}

/* The storefront's button text rule otherwise makes the official sign-in
   action dark on its dark card. Keep its native action and change contrast. */
[data-bwe-member-panel] .member-signInBtn {
  color: #eceee9 !important;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Account facts remain visible before the optional native launcher loads. */
.bwe-support-dialog__summary { flex: 0 0 auto; padding: 8px 12px 0; }
.bwe-support-shell[data-support-view="member"] .bwe-support-dialog__summary { display: none; }
.bwe-support-dialog__member-overview { flex: 0 0 auto; padding: 10px 12px; }
.bwe-support-shell[data-member-panel="true"] .bwe-support-dialog__member-overview,
.bwe-support-shell [data-bwe-chat-chip="member"],
.bwe-support-shell [data-bwe-chat-card="member"] { display: none !important; }
.bwe-support-shell:not([data-member-panel="true"]) .bwe-support-dialog__membership { overflow-y: auto; }
.bwe-support-shell:not([data-member-panel="true"]) .bwe-support-dialog__member-host { flex: 0 0 auto; height: auto; }

@media (min-width: 821px) {
  .bwe-support-dialog__chat { display: flex; flex-direction: column; }
  .bwe-support-dialog__chat > .bwe-chat-widget { flex: 1 1 auto; height: auto; min-height: 340px; }
}

.bwe-support-dialog__member-status [data-bwe-member-native-link] {
  display: inline-flex; align-items: center; min-height: 44px; margin: 6px;
  padding: 8px 12px; color: #eceee9; background: #121412;
  border: 1px solid #626958; font: 700 12px/1.3 "Courier New", monospace;
}
.bwe-support-dialog__member-status [data-bwe-member-native-link][hidden] { display: none; }

/* Keep cart totals/recovery and mobile empty-state actions unobstructed. */
@media (min-width: 821px) {
  body[data-page-type="cart"] .bwe-support-launch {
    inset: auto auto 20px 20px; min-width: 0; width: 64px; min-height: 52px;
    grid-template-columns: 1fr; justify-items: center; padding: 8px 4px;
  }
  body[data-page-type="cart"] .bwe-support-launch__copy,
  body[data-page-type="cart"] .bwe-support-launch__signal { display: none; }
  body[data-page-type="cart"] .bwe-support-launch__action {
    min-width: 0; min-height: 0; color: var(--bwe-support-paper);
    background: transparent; font-size: 13px;
  }
}
@media (max-width: 820px) {
  body:is([data-page-type="cart"], [data-page-type="search"], [data-page-type="collection"]):has(.bigwhite-mobile-tabbar) .bwe-support-launch,
  body:is([data-page-type="search"], [data-page-type="collection"]):has(.bigwhite-mobile-tabbar) .bwe-support-nudge {
    display: none;
  }
}
