/* 工具页局部收紧卡片/区域圆角：仅作用于本页，不改动主站设计令牌 */
:root { --r-card: 6px; --r-sm: 4px; }

/* ============================================================
   拼豆模式 · 在线工具（网页版）
   三段工作台：① 顶部显示设置 ② 中部图纸预览 ③ 底部当前色 / 进度 / 色号条
   底座沿用 image-to-bead/tool.css 的 app-shell、顶栏、分段控件、状态条与
   main.css 设计令牌；本文件只负责三段布局与拼豆模式自己的控件。
   ⚠️ 关键：image-to-bead 的 @media (max-width:1080px) 会把 .app-shell 改成
   height:auto / overflow:visible、把 .app-main 改成自然高度，那是三栏工具页的
   单列退化。拼豆模式必须锁死 100dvh，否则手机上画布拿不到高度 —— 下面用
   .app-shell.bm-shell / .app-main.bm-main 的高特异性规则覆盖，勿删。
   ============================================================ */

/* ---------- 外壳：顶栏 + 三段工作区，整页不滚 ---------- */
.app-shell.bm-shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 56px minmax(0, 1fr);
  overflow: hidden;
}
.bm-shell > .app-topbar { height: 56px; padding: 0 16px; }

.app-main.bm-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

/* 三段共用卡片表面 */
.bm-settings,
.bm-view,
.bm-panel {
  min-width: 0;
  max-width: 100%;
  background: var(--c-card);
  border: var(--bw-hairline, 1px) solid var(--c-card-edge);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card), var(--shadow-card-halo);
}

/* ============================================================
   ① 顶部：显示设置
   ============================================================ */
.bm-settings {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 8px 12px;
}
.bm-set-title {
  flex: none;
  padding-right: 14px;
  border-right: 1px solid var(--c-divider);
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text-sub);
  white-space: nowrap;
}
.bm-set-group { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.bm-set-lbl { flex: none; font-size: 12px; color: var(--c-outline); white-space: nowrap; }

/* 分段控件沿用图片转拼豆的 .segment，仅压成工具条尺寸 */
.bm-seg.segment {
  display: inline-grid;
  grid-template-columns: repeat(2, auto);
  gap: 2px;
  padding: 2px;
  width: auto;
}
.bm-seg.segment label {
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

/* 紧凑开关：标尺 / 网格 / 高亮选中行列 / 常亮（窄屏允许换行，防止溢出） */
.bm-set-toggles { gap: 14px; flex-wrap: wrap; row-gap: 6px; }
.bm-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--c-text-sub);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.bm-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.bm-tg {
  position: relative;
  flex: none;
  width: 28px;
  height: 16px;
  border-radius: 999px;
  background: var(--c-surface-high);
  transition: background .15s ease;
}
.bm-tg::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c-outline);
  transition: transform .15s ease, background .15s ease;
}
.bm-toggle input:checked + .bm-tg { background: var(--c-primary-soft); }
.bm-toggle input:checked + .bm-tg::after { transform: translateX(12px); background: var(--c-primary); }
.bm-toggle input:focus-visible + .bm-tg { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.bm-toggle.is-unsupported { opacity: .42; cursor: not-allowed; }

.bm-set-spacer { flex: 1 1 auto; }
.bm-set-zoom { gap: 2px; }
.bm-set-zoom .tb-zoom { min-width: 52px; justify-content: center; text-align: center; }

/* ============================================================
   ② 中部：图纸预览（吃掉所有剩余高度）
   ============================================================ */
.bm-view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bm-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--c-paper);
  overflow: hidden;
}
.bm-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
.bm-stage.is-dragging canvas { cursor: grabbing; }

/* 左上角图纸信息：常驻、单行省略 */
.bm-status {
  position: absolute;
  left: 12px;
  top: 10px;
  max-width: calc(100% - 90px);
  padding: 5px 11px;
  border: 1px solid var(--c-border-subtle);
  border-radius: 8px;
  background: var(--c-card);
  color: var(--c-text-sub);
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: var(--shadow-btn-float);
  pointer-events: none;
  opacity: .96;
}
.bm-shell.is-empty .bm-status { display: none; }

/* 左下角当前色提示（窄屏隐藏，底部面板已有） */
.bm-remain {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 90px);
  padding: 6px 13px;
  border: 1px solid var(--c-border-subtle);
  border-radius: 999px;
  background: var(--c-card);
  color: var(--c-text-sub);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: var(--shadow-btn-float);
}
.bm-remain[hidden] { display: none; }
.bm-remain i { width: 13px; height: 13px; border-radius: 50%; flex: none; border: 1px solid var(--c-hairline); }

/* 右下角缩放 / 全屏：移动端拇指可达 */
.bm-zoom {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bm-zoom-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--c-border-subtle);
  background: var(--c-card);
  color: var(--c-text-sub);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-btn-float);
  transition: background .15s ease, color .15s ease;
}
.bm-zoom-btn:hover { background: var(--c-surface-high); color: var(--c-text); }

/* ---------- 空状态引导：直接打开工具页时，画布区改为「选图纸 / 去创作」入口 ---------- */
.bm-empty {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
  background: var(--c-paper);
}
.bm-empty[hidden] { display: none; }
/* 引导内容放卡片里：纸面两主题恒定（浅色），文字色用卡片令牌才跟主题走 */
.bm-empty-card {
  width: 100%;
  max-width: 560px;
  margin: auto;              /* 与 overflow:auto 配合：超高时从顶部排，不被裁掉 */
  padding: 26px 24px 22px;
  border: 1px solid var(--c-card-edge);
  border-radius: 6px;
  background: var(--c-card);
  box-shadow: var(--shadow-lift);
  text-align: center;
}
.bm-empty-em {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 12px;
  border: 1px solid var(--c-card-edge);
  border-radius: 16px;
  background: var(--c-primary-tint-soft);
}
.bm-empty-card h2 { margin: 0 0 6px; font-size: 19px; color: var(--c-text); }
.bm-empty-sub {
  margin: 0 auto;
  max-width: 46ch;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--c-text-sub);
}
.bm-empty-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
  text-align: left;
}
.bm-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--c-card-edge);
  border-radius: var(--r-card);
  background: var(--c-card);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-card);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.bm-entry:hover,
.bm-entry:focus-visible {
  border-color: var(--c-primary);
  box-shadow: var(--shadow-card), var(--shadow-card-halo), 0 0 0 3px var(--c-primary-tint);
  transform: translateY(-1px);
}
.bm-entry:focus-visible { outline: none; }
.bm-entry-ic {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--c-primary-tint);
  color: var(--c-primary);
}
.bm-entry-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bm-entry-tx b { font-size: 14px; color: var(--c-text); white-space: nowrap; }
.bm-entry-tx span { font-size: 12px; line-height: 1.45; color: var(--c-text-sub); }
.bm-entry-arrow { display: grid; place-items: center; flex: none; margin-left: auto; color: var(--c-outline); }
.bm-empty-note { margin: 16px 0 0; font-size: 12px; color: var(--c-outline); }
/* 「打开工程文件」「继续上次」是按钮：外观与上面的链接入口完全一致 */
.bm-entry-btn {
  width: 100%;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.bm-entry-btn:focus-visible { outline: none; }
.bm-empty-fix { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 14px; }
.bm-empty-fix .btn { min-height: 44px; padding: 0 20px; font-size: 13.5px; }

/* 图纸加载失败说明：空状态卡片内，标题下方 */
.bm-empty-err {
  margin: 14px auto 0;
  max-width: 52ch;
  padding: 10px 14px;
  border: 1px solid var(--c-card-edge);
  border-left: 3px solid var(--c-primary);
  border-radius: var(--r-card);
  background: var(--c-surface);
  text-align: left;
}
.bm-empty-err[hidden] { display: none; }
.bm-empty-err p { margin: 0; font-size: 13px; line-height: 1.7; color: var(--c-text-sub); }
/* 有失败说明时，入口区上边距收紧一点 */
.bm-empty-err:not([hidden]) + .bm-empty-grid { margin-top: 14px; }

/* 空状态：没有图纸时隐藏显示设置、状态条与底部面板，让引导占满画布区 */
.bm-shell.is-empty .bm-settings,
.bm-shell.is-empty .bm-panel,
.bm-shell.is-empty .bm-stage-status { display: none; }

/* 深色状态条沿用 .stage-status，只压高度 */
.bm-stage-status.stage-status { height: 30px; padding: 0 14px; min-width: 0; }

/* 完成庆祝层 */
.bm-celebrate {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 251, 247, 0.86);
  z-index: 5;
}
.bm-celebrate[hidden] { display: none; }
[data-theme="dark"] .bm-celebrate { background: rgba(18, 18, 18, 0.72); }
.bm-celebrate-card {
  max-width: min(92%, 380px);
  padding: 26px 34px;
  border: 1px solid var(--c-border-subtle);
  border-radius: 6px;
  background: var(--c-card);
  box-shadow: var(--shadow-lift);
  text-align: center;
}
.bm-celebrate-em { font-size: 42px; line-height: 1.2; }
.bm-celebrate-card h2 { margin: 6px 0 4px; font-size: 19px; color: var(--c-text); }
.bm-celebrate-card p { margin: 0; font-size: 13.5px; color: var(--c-text-sub); }
.bm-celebrate-btns { display: flex; justify-content: center; gap: 10px; margin-top: 16px; }

/* ============================================================
   ③ 底部：当前色 / 进度 / 色号条
   ============================================================ */
.bm-panel { flex: none; overflow: hidden; }
.bm-active {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 300px) auto;
  align-items: center;
  gap: 12px 18px;
  padding: 10px 14px;
  min-width: 0;
}
/* grid 子项默认 min-width:auto，窄屏会被 nowrap 的进度文字撑破面板 */
.bm-active > * { min-width: 0; }

/* 当前色信息行（结构对齐小程序 active-row） */
.bm-active-color { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bm-active-dot {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--c-hairline);
  background: var(--c-surface-high);
  box-sizing: border-box;
}
.bm-active-dot.is-all { background: var(--c-surface-high); border-color: var(--c-outline-variant); }
.bm-active-dot i { display: none; font-style: normal; font-size: 12px; color: var(--c-text-sub); }
.bm-active-dot.is-all i { display: block; }
.bm-active-txt { display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 8px; min-width: 0; }
.bm-active-txt b {
  color: var(--c-primary);
  font-size: 18px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.bm-active-txt span {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  color: var(--c-text-sub);
}
.bm-active-txt .bm-active-num { color: var(--c-outline); }

/* 进度：文字 + 按颗数的进度条 + 快捷键提示 */
.bm-progress { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bm-prog-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  font-size: 12.5px;
  color: var(--c-text-sub);
  white-space: nowrap;
}
.bm-prog-top > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bm-prog-top b { color: var(--c-text); font-weight: 700; font-variant-numeric: tabular-nums; }
.bm-reset {
  flex: none;
  padding: 2px 5px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--c-outline);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.bm-reset:hover { background: var(--c-surface-high); color: var(--c-primary); }
.bm-prog-track { height: 7px; border-radius: 999px; background: var(--c-surface-high); overflow: hidden; }
.bm-prog-track i { display: block; width: 0; height: 100%; border-radius: 999px; background: var(--c-primary); transition: width .25s ease; }
.bm-prog-hint { font-size: 11px; color: var(--c-outline); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.bm-active-actions { display: flex; align-items: center; gap: 6px; }
.bm-step {
  width: 34px;
  height: 38px;
  border: 1px solid var(--c-border-subtle);
  border-radius: 9px;
  font-size: 18px;
  line-height: 1;
}
/* 撤销上一次打卡：没有可撤销的那一步时置灰 */
.bm-undo.tb-btn { height: 38px; padding: 0 10px; border-radius: 9px; white-space: nowrap; }
.bm-mark.btn { height: 38px; padding: 0 18px; border-radius: 9px; font-size: 13.5px; white-space: nowrap; }
.bm-mark.btn:disabled { opacity: .45; cursor: default; }

/* 色号条：圆点 + 色号 + 完成对勾（小程序同构） */
.bm-chips {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px 11px;
  border-top: 1px solid var(--c-divider);
  overflow-x: auto;
  scrollbar-width: thin;
}
.bm-chip {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 48px;
  padding: 3px 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--c-text-sub);
  font: inherit;
  font-size: 11.5px;
  line-height: 1.2;
  cursor: pointer;
}
.bm-chip .sw {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--c-hairline);
  background: var(--c-surface-high);
  box-sizing: border-box;
  font-style: normal;
  font-size: 11px;
  color: var(--c-text-sub);
}
.bm-chip.is-all .sw { background: var(--c-surface-high); border-color: var(--c-outline-variant); }
.bm-chip.is-sel .sw { border: 2px solid var(--c-primary); box-shadow: 0 0 0 2px var(--c-primary-tint); }
.bm-chip.is-sel .code { color: var(--c-primary); font-weight: 700; }
.bm-chip.is-done .sw { opacity: .42; }
.bm-chip.is-done .code { text-decoration: line-through; color: var(--c-outline); }
.bm-chip.is-done::after {
  content: "✓";
  position: absolute;
  top: 0;
  right: 1px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--c-primary);
  color: var(--c-on-primary);
  font-size: 10px;
  line-height: 15px;
  text-align: center;
}
.bm-chip .code { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 选中具体色号后：淡化其余色号，让当前色成为唯一焦点 */
.bm-chip { transition: opacity .18s ease; }
.bm-chips.has-sel .bm-chip:not(.is-sel) { opacity: .32; }
.bm-chips.has-sel .bm-chip:not(.is-sel):hover { opacity: .6; }
.bm-chips.has-sel .bm-chip.is-sel {
  background: var(--c-primary-tint);
}
.bm-chips.has-sel .bm-chip.is-sel .sw {
  box-shadow: 0 0 0 2px var(--c-primary), 0 0 10px 1px var(--c-primary-tint);
}

/* ---------- 全屏：整壳占满屏 ---------- */
.bm-shell:fullscreen { height: 100vh; height: 100dvh; }

/* ---------- 顶栏工具切换 ---------- */
.bm-nav { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
/* 「更多」下拉：宽屏不显示，≤1280px 顶栏放不下全部入口时出现 */
.bm-more { display: none; position: relative; }
.bm-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  display: grid;
  gap: 2px;
  min-width: 156px;
  padding: 6px;
  border: 1px solid var(--c-card-edge);
  border-radius: var(--r-card);
  background: var(--c-card);
  box-shadow: var(--shadow-lift);
}
.bm-more-menu[hidden] { display: none; }
.bm-more-menu a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--c-text-sub);
  text-decoration: none;
  white-space: nowrap;
}
.bm-more-menu a:hover,
.bm-more-menu a:focus-visible { background: var(--c-surface-high); color: var(--c-text); outline: none; }

/* 轻提示：main.css 的 .toast 默认隐藏、且每条都 fixed 定位叠在同一处；
   本页的 toast() 不加 .show，这里改为在容器里正常排布并直接可见 */
#toastBox .toast {
  position: static;
  left: auto;
  bottom: auto;
  transform: none;
  visibility: visible;
  opacity: 1;
  white-space: normal;
  text-align: center;
  line-height: 1.5;
}
#toastBox .toast.is-out { opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility 0s .25s; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1180px) {
  .bm-set-title { display: none; }
  .bm-settings { gap: 8px 12px; }
}

@media (max-width: 980px) {
  .app-shell.bm-shell { grid-template-rows: 52px minmax(0, 1fr); }
  .bm-shell > .app-topbar { height: 52px; }

  /* 设置条折成网格：视图 / 高亮 一行，显示 / 缩放 各占一行，功能一个不少 */
  .bm-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; padding: 8px 10px; }
  .bm-set-toggles { grid-column: 1 / -1; gap: 18px; }
  .bm-set-zoom { grid-column: 1 / -1; justify-content: flex-end; }
  .bm-set-spacer { display: none; }

  /* 底部：色信息 + 进度一行，打卡按钮独占一行 */
  .bm-active { grid-template-columns: minmax(0, 1fr) minmax(0, 240px); gap: 9px 14px; }
  .bm-active-actions { grid-column: 1 / -1; }
  .bm-mark.btn { flex: 1; }
  .bm-prog-hint { display: none; }
}

@media (max-width: 620px) {
  .app-shell.bm-shell { grid-template-rows: 48px minmax(0, 1fr); }
  .bm-shell > .app-topbar { height: 48px; padding: 0 10px; }
  .bm-shell .tb-brand .sep,
  .bm-shell .tb-brand .tn,
  .bm-shell .tb-brand .tag { display: none; }
  .bm-shell .tb-brand img { width: 26px; height: 26px; }
  .bm-shell .tb-back { padding: 0 10px; }
  .app-main.bm-main { gap: 8px; padding: 8px; }

  .bm-settings { gap: 7px 8px; padding: 7px 9px; }
  .bm-set-lbl { display: none; }
  .bm-seg.segment label { padding: 0 8px; font-size: 11.5px; }
  .bm-set-toggles { gap: 12px; }
  .bm-toggle { font-size: 12px; }
  .bm-set-zoom .tb-zoom { min-width: 44px; }

  .bm-status { left: 8px; top: 8px; max-width: calc(100% - 60px); padding: 4px 8px; font-size: 11px; }
  .bm-remain { display: none; }
  .bm-zoom { right: 8px; bottom: 8px; gap: 5px; }
  .bm-zoom-btn { width: 34px; height: 34px; }
  .bm-stage-status.stage-status { height: 24px; padding: 0 9px; font-size: 11px; }
  .bm-stage-status .st-mid { gap: 4px; }
  .bm-stage-status .st-right { gap: 7px; }

  .bm-active { grid-template-columns: minmax(0, 1fr) minmax(0, 148px); gap: 8px 10px; padding: 9px 10px; }
  .bm-active-dot { width: 32px; height: 32px; }
  .bm-active-txt { gap: 2px 6px; }
  .bm-active-txt b { font-size: 16px; }
  .bm-active-txt span { max-width: 82px; font-size: 11.5px; }
  .bm-prog-top { font-size: 11px; }
  .bm-prog-track { height: 6px; }
  .bm-mark.btn { height: 40px; font-size: 13px; }
  .bm-step { height: 40px; }

  .bm-chips { gap: 12px; padding: 9px 10px 11px; }
  .bm-chip { min-width: 46px; }
  .bm-chip .sw { width: 34px; height: 34px; }
  .bm-celebrate-card { padding: 20px 22px; }
}

/* 空状态引导：窄屏入口卡改单列 */
@media (max-width: 560px) {
  .bm-empty { padding: 14px; }
  .bm-empty-card { padding: 20px 16px 16px; }
  .bm-empty-em { width: 56px; height: 56px; margin-bottom: 10px; }
  .bm-empty-card h2 { font-size: 17px; }
  .bm-empty-sub { font-size: 12.5px; }
  .bm-empty-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 14px; }
  .bm-entry { padding: 11px 12px; }
  .bm-empty-note { margin-top: 12px; }
}

/* 顶栏放不下全部切换入口：次要入口收进「更多」下拉 */
@media (max-width: 1280px) {
  .bm-nav2 { display: none; }
  .bm-more { display: block; }
}

/* ---------- 触控目标：≤720px 最小命中区 40–44px（用 padding / 伪元素扩热区，不动布局） ---------- */
@media (max-width: 720px) {
  .bm-shell .tb-btn { min-height: 40px; }
  .bm-set-zoom .tb-btn { min-width: 44px; }
  .bm-set-zoom .tb-btn--ico { min-width: 40px; }
  .bm-step { width: 40px; }
  .bm-mark.btn { height: 40px; }
  .bm-shell .tb-actions .icon-sq { width: 40px; height: 40px; }
  .bm-shell .tb-back { min-height: 40px; }

  /* 分段控件：上下各扩 7px */
  .bm-seg.segment label { position: relative; }
  .bm-seg.segment label::after { content: ""; position: absolute; left: -2px; right: -2px; top: -7px; bottom: -7px; }

  /* 开关：视觉高 16px → 命中区 40px（上下各扩 12px、左右各扩 4px，负外边距抵消，排版不变） */
  .bm-toggle { padding: 12px 4px; margin: -12px -4px; }

  /* 重置：上下各扩 10px */
  .bm-reset { position: relative; }
  .bm-reset::after { content: ""; position: absolute; left: -4px; right: -4px; top: -10px; bottom: -10px; }

  .bm-chip { min-width: 48px; min-height: 44px; justify-content: center; }
}

/* ---------- 低高度（手机横屏 / 分屏）：允许页面滚动，保证画布不被挤没 ----------
   外壳原本锁 100dvh + overflow hidden，360px 高时扣掉设置条、状态条、底部面板后画布只剩 0。
   这里改为整页可滚 + 设置条折成一行 + 底部面板压成一行，并给预览区 160px 保底。 */
@media (max-height: 480px) {
  .app-shell.bm-shell {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    grid-template-rows: 44px auto;
    overflow: visible;
  }
  .bm-shell > .app-topbar { height: 44px; }
  .app-main.bm-main { height: auto; min-height: 0; overflow: visible; }

  /* 设置条折成一行：放不下时在条内横向滑动，不换行占高度 */
  .bm-settings { display: flex; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; gap: 6px 12px; padding: 5px 10px; }
  .bm-set-title,
  .bm-set-spacer { display: none; }

  /* 底部面板压成一行：当前色 · 进度 · 打卡同排 */
  .bm-active { grid-template-columns: minmax(0, 1fr) minmax(120px, 220px) auto; gap: 8px; padding: 6px 10px; }
  .bm-active-actions { grid-column: auto; }
  .bm-mark.btn { flex: none; }
  .bm-chips { padding: 5px 10px 6px; }

  /* 画布保底：预览区（含 24–30px 状态条）至少约 190px，画布本身 ≥ 160px */
  .bm-view { flex: 1 0 auto; min-height: 190px; }
  /* 空状态：引导卡片随页面自然排布，不在保底高度里再套一层内滚动 */
  .bm-shell.is-empty .bm-view { min-height: 0; overflow: visible; }
  .bm-shell.is-empty .bm-empty { position: static; padding: 10px; }
}
