/* Lab UX v67 · 手机安置：可拖动二叉圆圈画布 */

.binary-tree {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 0;
  height: 100%;
  padding-bottom: 0.25rem;
}

.bt-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 0 0 auto;
}
.bt-hint {
  margin: 0;
  padding: 0.45rem 0.65rem;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--ink-soft);
  background: rgba(26, 122, 92, 0.07);
  border: 1px solid rgba(26, 122, 92, 0.14);
  border-radius: 10px;
}
.bt-tools {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.bt-tools .btn {
  flex: 1 1 auto;
  min-width: 4.5rem;
  min-height: 2.2rem;
  margin: 0;
  border-radius: 10px;
  font-weight: 700;
}
.bt-tools .btn-primary {
  flex: 1.4 1 auto;
}

.bt-viewport {
  position: relative;
  flex: 1 1 auto;
  min-height: min(62vh, 520px);
  max-height: min(70vh, 640px);
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(10, 28, 38, 0.1);
  background:
    radial-gradient(circle at 20% 10%, rgba(45, 154, 116, 0.08), transparent 42%),
    radial-gradient(circle at 80% 0%, rgba(196, 92, 38, 0.06), transparent 40%),
    linear-gradient(180deg, #f4f8fa 0%, #eef3f6 100%);
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.bt-viewport.is-panning {
  cursor: grabbing;
}
.bt-viewport:focus {
  outline: 2px solid rgba(26, 122, 92, 0.35);
  outline-offset: 1px;
}

.bt-canvas {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.bt-edges {
  position: absolute;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}
.bt-edge {
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bt-edge.is-L {
  stroke: rgba(26, 122, 92, 0.55);
}
.bt-edge.is-R {
  stroke: rgba(196, 92, 38, 0.55);
}

.bt-nodes {
  position: absolute;
  inset: 0;
}

.bt-node-wrap {
  position: absolute;
  pointer-events: none;
}
.bt-node-wrap .bt-node {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  left: 0 !important;
  top: 0 !important;
  pointer-events: auto;
}
.bt-node-wrap .bt-badge {
  pointer-events: auto;
  z-index: 3;
}

.bt-node {
  position: absolute;
  border: 0;
  padding: 0;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  color: #fff;
  background: radial-gradient(120% 100% at 30% 20%, #3bbc8a 0%, #1a7a5c 55%, #0f5a44 100%);
  box-shadow:
    0 10px 22px rgba(10, 28, 38, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.bt-node:active {
  transform: scale(0.96);
}
.bt-node.is-root {
  background: radial-gradient(120% 100% at 30% 20%, #4fd4a0 0%, #167a58 50%, #0a4634 100%);
  box-shadow:
    0 12px 28px rgba(26, 122, 92, 0.28),
    0 0 0 4px rgba(26, 122, 92, 0.14);
}
.bt-node.is-zone-L {
  background: radial-gradient(120% 100% at 30% 20%, #4ecf9a 0%, #1a7a5c 60%, #0f5a44 100%);
}
.bt-node.is-zone-R {
  background: radial-gradient(120% 100% at 30% 20%, #f0a078 0%, #c45c26 58%, #8f3d14 100%);
}
.bt-node.is-zone-sponsor {
  background: radial-gradient(120% 100% at 30% 20%, #6eb6e8 0%, #2a6f97 58%, #184a66 100%);
}
.bt-zone.sponsor {
  color: #2a6f97;
}
.bt-edge.is-sponsor {
  stroke: rgba(42, 111, 151, 0.55);
}
.sponsor-tree .ol-hint {
  background: rgba(42, 111, 151, 0.07);
  border-color: rgba(42, 111, 151, 0.14);
  color: #3a5a6c;
}
.bt-node.is-sel {
  box-shadow:
    0 12px 26px rgba(10, 28, 38, 0.2),
    0 0 0 3px #fff,
    0 0 0 6px rgba(26, 122, 92, 0.55);
}
.bt-node.is-empty {
  background: repeating-linear-gradient(
      -45deg,
      rgba(244, 248, 250, 0.95),
      rgba(244, 248, 250, 0.95) 6px,
      rgba(230, 236, 240, 0.95) 6px,
      rgba(230, 236, 240, 0.95) 12px
    );
  color: var(--ink-soft);
  border: 2px dashed rgba(10, 28, 38, 0.22);
  box-shadow: none;
}
.bt-node.is-empty.is-zone-L {
  border-color: rgba(26, 122, 92, 0.35);
  color: var(--zone-l);
}
.bt-node.is-empty.is-zone-R {
  border-color: rgba(196, 92, 38, 0.35);
  color: var(--zone-r);
}
.bt-node.is-locked {
  opacity: 0.72;
}

.bt-zone {
  position: absolute;
  top: -0.15rem;
  left: 50%;
  transform: translate(-50%, -55%);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.38rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--jade-deep);
  box-shadow: 0 2px 8px rgba(10, 28, 38, 0.12);
}
.bt-node.is-zone-R .bt-zone {
  color: var(--zone-r);
}
.bt-zone.root {
  background: var(--jade-deep);
  color: #fff;
}
.bt-node.is-empty .bt-zone {
  background: #fff;
}

.bt-code {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.05;
  max-width: 4.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bt-node.is-root .bt-code {
  font-size: 0.78rem;
}
.bt-star {
  font-style: normal;
  font-size: 0.68rem;
  font-weight: 800;
  opacity: 0.95;
}
.bt-meta {
  font-style: normal;
  font-size: 0.58rem;
  font-weight: 700;
  opacity: 0.88;
  max-width: 4.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bt-node.is-empty .bt-code,
.bt-node.is-empty .bt-meta {
  color: inherit;
}

.bt-badge {
  position: absolute;
  right: -0.15rem;
  bottom: -0.1rem;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1;
  border: 2px solid #fff;
  box-shadow: 0 4px 10px rgba(10, 28, 38, 0.18);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.bt-plus {
  background: var(--jade);
  color: #fff;
}
.bt-minus {
  background: #e07a3a;
  color: #fff;
}
.bt-badge.is-busy {
  opacity: 0.7;
}

/* —— 卡片弹层（挂到 body，避免被 tree-stage overflow 裁切） —— */
.bt-sheet-host {
  position: fixed;
  inset: 0;
  z-index: 2600;
  pointer-events: none;
}
.bt-sheet-host[hidden] {
  display: none !important;
}
.bt-sheet-host .bt-sheet {
  pointer-events: auto;
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.bt-sheet {
  position: fixed;
  inset: 0;
  z-index: 2600;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.bt-sheet[hidden] {
  display: none !important;
}
.bt-sheet-scrim {
  position: absolute;
  inset: 0;
  background: rgba(8, 18, 24, 0.45);
  backdrop-filter: blur(2px);
}
.bt-sheet-panel {
  position: relative;
  width: min(100%, 420px);
  max-height: min(78vh, 640px);
  overflow: auto;
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 40px rgba(10, 28, 38, 0.22);
  padding: 0.85rem 0.9rem calc(0.9rem + env(safe-area-inset-bottom, 0px));
  animation: btSheetIn 0.22s ease;
}
@keyframes btSheetIn {
  from {
    transform: translateY(18%);
    opacity: 0.4;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
.bt-sheet-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
}
.bt-sheet-head h3 {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  word-break: break-all;
}
.bt-sheet-tip {
  margin: 0 0 0.75rem;
  color: var(--ink-muted);
  font-size: 0.82rem;
}
.bt-sheet-acts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-top: 0.55rem;
}
.bt-sheet-acts .btn {
  width: 100%;
  min-height: 2.65rem;
  margin: 0;
  border-radius: 12px;
  font-weight: 700;
}
.bt-sheet-acts .btn-primary,
.bt-sheet-acts .btn-collapse,
.bt-sheet-acts [data-bt-toggle],
.bt-sheet-acts [data-fill] {
  grid-column: 1 / -1;
}
.bt-sheet-acts .btn-collapse,
.binary-tree .btn-collapse {
  background: linear-gradient(180deg, #f4a261, #e07a3a);
  border: 1px solid rgba(196, 92, 38, 0.45);
  color: #fff;
}

/* sheet 复用的统计块 */
.binary-tree .ol-pill {
  flex: 0 0 auto;
  font-size: 0.62rem;
  font-weight: 800;
  color: #fff;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
}
.binary-tree .ol-pill.root { background: var(--jade-deep); }
.binary-tree .ol-pill.L { background: var(--zone-l); }
.binary-tree .ol-pill.R { background: var(--zone-r); }
.binary-tree .ol-pill.THIRD { background: var(--zone-t); }
.binary-tree .ol-star {
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--jade-deep);
  background: rgba(26, 122, 92, 0.1);
  padding: 0.25rem 0.45rem;
  border-radius: 8px;
}
.binary-tree .ol-life {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}
.binary-tree .ol-life > div {
  text-align: center;
  padding: 0.4rem 0.3rem;
  border-radius: 10px;
  background: rgba(244, 248, 250, 0.95);
  border: 1px solid rgba(10, 28, 38, 0.06);
}
.binary-tree .ol-life > div.L { border-top: 3px solid var(--zone-l); }
.binary-tree .ol-life > div.R { border-top: 3px solid var(--zone-r); }
.binary-tree .ol-life > div.T { border-top: 3px solid var(--zone-t); }
.binary-tree .ol-life em {
  display: block;
  font-style: normal;
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--ink-muted);
}
.binary-tree .ol-life b {
  display: block;
  font-size: 0.9rem;
  font-family: var(--font-display);
  margin-top: 0.1rem;
}
.binary-tree .ol-carry {
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-bottom: 0.55rem;
  padding: 0.4rem 0.5rem;
  border-radius: 10px;
  background: rgba(10, 28, 38, 0.035);
}
.binary-tree .ol-carry b { color: var(--ink); }

/* —— 四奖金币气泡 —— */
.bt-coin-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(255, 214, 102, 0.35), rgba(240, 160, 120, 0.18)),
    #fff8e8;
  border: 1px solid rgba(196, 140, 38, 0.28);
  box-shadow: 0 8px 20px rgba(196, 140, 38, 0.12);
}
.bt-coin-banner-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 0.25rem;
}
.bt-coin-banner-main strong {
  font-family: var(--font-display);
  font-size: 0.88rem;
}
.bt-coin-banner-main > span {
  font-size: 0.72rem;
  color: var(--ink-muted);
}
.bt-banner-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.15rem;
}
.bt-banner-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  padding: 0.18rem 0.42rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  color: #fff;
}
.bt-banner-chip em { font-style: normal; opacity: 0.9; font-weight: 700; }
.bt-banner-chip.is-DIRECT { background: #1a7a5c; }
.bt-banner-chip.is-DEPTH { background: #2a6f97; }
.bt-banner-chip.is-BINARY { background: #c45c26; }
.bt-banner-chip.is-MANAGE { background: #7a5af8; }

.bt-coins {
  position: absolute;
  z-index: 4;
  min-width: 5.2rem;
  padding: 0.35rem 0.4rem;
  border-radius: 12px;
  background: linear-gradient(165deg, #fff9e8 0%, #fff 70%);
  border: 1px solid rgba(196, 140, 38, 0.35);
  box-shadow: 0 10px 22px rgba(196, 140, 38, 0.18);
  pointer-events: none;
  animation: btCoinPop 0.35s ease;
}
.bt-coins.is-buyer {
  border-color: rgba(26, 122, 92, 0.45);
  box-shadow: 0 10px 22px rgba(26, 122, 92, 0.18);
}
@keyframes btCoinPop {
  from { opacity: 0; transform: translateY(6px) scale(0.92); }
  to { opacity: 1; transform: none; }
}
.bt-coins-sum {
  font-size: 0.72rem;
  font-weight: 800;
  color: #a66b00;
  margin-bottom: 0.2rem;
}
.bt-coins-rows {
  display: grid;
  gap: 0.18rem;
}
.bt-coin {
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.12rem 0.3rem;
  border-radius: 7px;
  font-size: 0.62rem;
  font-weight: 800;
  color: #fff;
}
.bt-coin em { font-style: normal; opacity: 0.92; }
.bt-coin.is-DIRECT { background: #1a7a5c; }
.bt-coin.is-DEPTH { background: #2a6f97; }
.bt-coin.is-BINARY { background: #c45c26; }
.bt-coin.is-MANAGE { background: #7a5af8; }

/* —— 多标签详情 / 报单 —— */
.bt-tabs {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  padding: 0.15rem 0 0.55rem;
  margin-bottom: 0.15rem;
  border-bottom: 1px solid rgba(10, 28, 38, 0.08);
  -webkit-overflow-scrolling: touch;
}
.bt-tab {
  flex: 0 0 auto;
  border: 0;
  background: rgba(10, 28, 38, 0.04);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  min-height: 2.2rem;
}
.bt-tab.is-on {
  background: var(--jade-deep);
  color: #fff;
}
.bt-panel { display: none; }
.bt-panel.is-on { display: block; }
.bt-load-pill {
  font-size: 0.7rem;
  color: var(--ink-muted);
  font-weight: 700;
}
.bt-kpi {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}
.bt-kpi > div {
  padding: 0.5rem 0.55rem;
  border-radius: 12px;
  background: #f4f8fa;
  border: 1px solid rgba(10, 28, 38, 0.06);
}
.bt-kpi em {
  display: block;
  font-style: normal;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--ink-muted);
}
.bt-kpi b {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--font-display);
  font-size: 1rem;
}
.bt-kpi .tone-jade { border-top: 3px solid var(--zone-l); }
.bt-kpi .tone-amber { border-top: 3px solid #d4a017; }
.bt-kpi .tone-ember { border-top: 3px solid var(--zone-r); }
.bt-kpi .tone-info { border-top: 3px solid #2a6f97; }
.bt-banner.warn {
  margin: 0 0 0.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  background: rgba(196, 92, 38, 0.1);
  color: var(--zone-r);
  font-size: 0.78rem;
  font-weight: 700;
}
.bt-sec {
  margin: 0 0 0.75rem;
}
.bt-sec h4 {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  font-family: var(--font-display);
}
.bt-line {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.bt-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.bt-chip-row.wrap { margin-bottom: 0.55rem; }
.bt-chip {
  border: 0;
  background: rgba(26, 122, 92, 0.1);
  color: var(--jade-deep);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
}
.bt-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}
.bt-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  background: #f4f8fa;
  font-size: 0.8rem;
}
.bt-mini-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}
.bt-mini-cards li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0.6rem;
  border-radius: 12px;
  background: linear-gradient(180deg, #f7fafb, #fff);
  border: 1px solid rgba(10, 28, 38, 0.06);
}
.bt-mini-cards strong { display: block; font-size: 0.82rem; }
.bt-mini-cards em {
  font-style: normal;
  font-size: 0.68rem;
  color: var(--ink-muted);
}
.bt-mini-cards b { font-family: var(--font-display); color: var(--jade-deep); }
.bt-rew-chip {
  display: inline-flex;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  background: rgba(26, 122, 92, 0.12);
  color: var(--jade-deep);
}

.bt-reg-form {
  display: grid;
  gap: 0.55rem;
  margin: 0.55rem 0 0.75rem;
}
.bt-reg-form label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.bt-reg-form select {
  min-height: 2.6rem;
  border-radius: 12px;
  border: 1px solid rgba(10, 28, 38, 0.12);
  padding: 0.4rem 0.65rem;
  font-size: 0.92rem;
  background: #fff;
}
.bt-check {
  display: flex !important;
  align-items: flex-start;
  gap: 0.45rem;
  grid-template-columns: none;
  font-size: 0.78rem !important;
}
.bt-check input { margin-top: 0.15rem; width: 1.1rem; height: 1.1rem; }
.bt-alert {
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(26, 122, 92, 0.08), rgba(196, 92, 38, 0.06));
  border: 1px solid rgba(26, 122, 92, 0.18);
  margin-bottom: 0.75rem;
}
.bt-alert strong {
  display: block;
  font-family: var(--font-display);
  margin-bottom: 0.25rem;
}
.bt-alert p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--ink-soft);
}
.bt-sheet-panel {
  max-height: min(82vh, 720px);
}
.bt-sheet-acts.sticky-acts {
  margin-top: 0.25rem;
}

.ol-hint,
.bt-hint {
  margin: 0;
  padding: 0.45rem 0.65rem;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--ink-soft);
  background: rgba(26, 122, 92, 0.07);
  border: 1px solid rgba(26, 122, 92, 0.14);
  border-radius: 10px;
}

@media (max-width: 980px) {
  #pane-trees .tree-stage:has(.binary-tree) {
    min-height: 0 !important;
    background: transparent !important;
    border: 0 !important;
    padding: 0.1rem !important;
    display: flex;
    flex-direction: column;
    overflow: visible !important;
  }
  #pane-trees .tree-stage:has(.binary-tree) > .binary-tree {
    flex: 1;
  }
}
