/* 工具页局部收紧卡片/区域圆角：仅作用于本页，不改动主站设计令牌 */
:root { --r-card: 6px; --r-sm: 4px; }

/* ============================================================
   拼豆图纸解析 · 在线工具（独立页面 · 网页版）
   把其他品牌的拼豆图纸解析成可编辑的拼豆图纸。
   布局与 image-to-bead 完全一致：独立顶栏 + 左参数 / 中大画布 / 右信息。
   ============================================================ */

/* 浮动校正面板：预览阶段显示在步骤条上方 */
.stage-controls[hidden] { display: none !important; }
.stage-controls {
  position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  padding: 8px 14px; background: rgba(255,255,255,0.95); backdrop-filter: blur(8px);
  border: 1px solid rgba(0,0,0,0.08); border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08); z-index: 10;
  max-width: calc(100% - 24px);
}
.sc-item { display: flex; align-items: center; gap: 4px; }
.sc-item label { font-size: 12px; color: var(--c-text-sub); white-space: nowrap; }
.sc-item input {
  width: 56px; padding: 3px 6px; border: 1px solid var(--c-card-edge); border-radius: 6px;
  font-size: 13px; font-weight: 700; text-align: center;
}
.sc-btn {
  padding: 5px 14px; background: var(--c-primary, #4a9e6a); color: var(--c-on-primary);
  border: none; border-radius: 6px; font-size: 12px; cursor: pointer; white-space: nowrap;
}
@media (max-width: 768px) {
  .stage-controls { bottom: 80px; gap: 6px; padding: 6px 10px; }
  .sc-item input { width: 48px; font-size: 12px; }
}

html { height: 100%; overflow: hidden; }
body { height: 100%; overflow: hidden; }
.app-shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr);
  overflow: hidden;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.noscript-tip {
  max-width: 640px; margin: 24px auto; padding: 16px 20px;
  background: var(--c-card); color: var(--c-text);
  border-radius: var(--r-card); font-size: 14px; line-height: 1.7;
  box-shadow: var(--shadow-card), var(--shadow-card-halo);
}

/* ---------- 独立顶栏 ---------- */
.app-topbar {
  display: flex; align-items: center; gap: 10px;
  height: 64px; padding: 0 16px;
  background: var(--c-card);
  border-bottom: 1px solid var(--c-card-edge);
  position: relative; z-index: 10;
}
.tb-back {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: var(--r-pill);
  background: var(--c-surface);
  color: var(--c-text-sub);
  font-size: 13px; text-decoration: none; flex: none;
  transition: background .15s ease, color .15s ease;
}
.tb-back:hover { background: var(--c-surface-high); color: var(--c-text); }
.tb-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--c-text);
  min-width: 0;
}
.tb-brand img { width: 30px; height: 30px; border-radius: 7px; flex: none; }
.tb-brand .pn { font-weight: 700; font-size: 16px; white-space: nowrap; }
.tb-brand .sep { width: 1px; height: 20px; background: var(--c-divider); flex: none; }
.tb-brand .tn { font-size: 13.5px; color: var(--c-text-sub); white-space: nowrap; }
.tb-brand .tag {
  padding: 2px 8px; border-radius: var(--r-pill);
  background: var(--c-primary-soft); color: var(--c-primary);
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.app-topbar .spacer { flex: 1 1 auto; }
.tb-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.tb-navlink { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; line-height: 1; color: var(--c-text-sub); text-decoration: none; padding: 6px 10px; border-radius: 8px; white-space: nowrap; transition: background .15s, color .15s; }
.tb-navlink:hover { background: var(--c-surface-high); color: var(--c-text); }
@media (max-width: 720px) { .tb-navlink { display: none; } }

.tb-switch {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 2px; padding: 3px;
  border-radius: var(--r-pill);
  background: var(--c-surface);
  border: 1px solid var(--c-outline-variant);
  z-index: 2;
}
.tb-switch-item {
  display: inline-flex; align-items: center; justify-content: center;
  height: 30px; padding: 0 16px; border-radius: var(--r-pill);
  font-size: 13px; line-height: 1; white-space: nowrap;
  color: var(--c-text-sub); text-decoration: none;
  transition: background .15s, color .15s;
}
.tb-switch-item:hover { color: var(--c-text); }
.tb-switch-item.is-active { background: var(--c-surface-highest); color: var(--c-primary); font-weight: 700; box-shadow: var(--shadow-card); }
.sw-short { display: none; }
@media (max-width: 1120px) {
  .tb-brand .sep, .tb-brand .tn, .tb-brand .tag { display: none; }
}
.icon-sq {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: 0; border-radius: var(--r-sm);
  background: var(--c-surface); color: var(--c-text-sub);
  cursor: pointer; text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.icon-sq:hover { background: var(--c-surface-high); color: var(--c-text); }

/* ---------- 两栏主体 ---------- */
.app-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 10px;
  padding: 10px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
@media (max-width: 1280px) {
  .app-main { grid-template-columns: minmax(0, 1fr) 268px; }
}
@media (max-width: 1080px) {
  .app-shell { height: auto; overflow: visible; }
  .app-main { grid-template-columns: minmax(0, 1fr); height: auto; overflow: visible; }
  .board-wrap { order: -1; }
  .info-body { overflow: visible; }
}

.info, .board-wrap {
  background: var(--c-card);
  border: var(--bw-hairline) solid var(--c-card-edge);
  border-radius: 6px;
  box-shadow: var(--shadow-card), var(--shadow-card-halo);
  display: flex; flex-direction: column;
  overflow: hidden;
  min-height: 0; min-width: 0;
}
.info-head {
  flex: none;
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--c-divider);
  font-size: 13px; font-weight: 700; color: var(--c-text-sub);
}
.info-body {
  flex: 1 1 auto; overflow-y: auto;
  padding: 0 var(--sp-4) var(--sp-4);
  min-height: 0;
}

/* ---------- 参数分组 ---------- */
.pg { padding: var(--sp-4) 0; border-bottom: 1px solid var(--c-divider); }
.pg:first-child { padding-top: var(--sp-3); }
.pg:last-child { border-bottom: 0; }
.pg-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 700;
  color: var(--c-text-sub);
  margin-bottom: var(--sp-3);
  letter-spacing: .02em;
}
.pg-title .hint { font-size: 12px; font-weight: 400; color: var(--c-outline); }

/* ---------- 本工具特有：底部横向步骤条 ---------- */
.step-bar {
  flex: none;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 14px 8px;
  background: var(--c-card);
  border-top: 1px solid var(--c-divider);
}
.step-track {
  flex: 1 1 auto;
  display: flex; align-items: center; justify-content: center;
  gap: 0;
  margin: 0; padding: 0; list-style: none;
}
.step-bar-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.step-node {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  flex: none;
}
.sn-num {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--c-surface-high);
  color: var(--c-outline);
  font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: background .15s ease, color .15s ease;
}
.sn-name {
  font-size: 11.5px; color: var(--c-outline);
  white-space: nowrap;
}
.step-line {
  flex: 1 1 auto;
  height: 2px;
  margin: 0 10px;
  max-width: 48px;
  background: var(--c-surface-high);
  border-radius: var(--r-pill);
}
.step-node.is-done .sn-num {
  background: var(--c-primary-soft); color: var(--c-primary);
}
.step-node.is-done .sn-name { color: var(--c-text-sub); }
.step-line.is-done { background: var(--c-primary); opacity: .5; }
.step-node.is-current .sn-num {
  background: var(--c-primary); color: var(--c-on-primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-primary) 18%, transparent);
}
.step-node.is-current .sn-name { color: var(--c-primary); font-weight: 700; }
.step-line.is-current { background: var(--c-primary); }
.step-node.is-todo .sn-num { background: var(--c-surface-high); }
.step-node.is-todo .sn-name { color: var(--c-outline); }
.step-line.is-todo { background: var(--c-surface-high); }

/* ---------- 本工具特有：对齐参数面板 ---------- */
.align-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}
.align-field { display: grid; gap: 3px; }
.align-field label {
  font-size: 11.5px; color: var(--c-outline);
  letter-spacing: .02em;
}
.align-field .af-input {
  display: flex; align-items: center; gap: 4px;
  height: 30px; padding: 0 8px;
  background: var(--c-surface);
  border: 1px solid var(--c-outline-variant);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--c-text);
}
.align-field .af-input b { color: var(--c-primary); font-weight: 700; }
.align-field .af-input .unit { color: var(--c-outline); font-size: 11px; }
.align-field.is-full { grid-column: 1 / -1; }
/* 「可数字微调」：P1 / P2 / cw / ch 是真正的 number 输入 */
.align-field label small { display: block; margin-top: 1px; font-size: 10.5px; font-weight: 400; color: var(--c-primary); }
.align-field .af-input input.af-num {
  flex: 1 1 auto; min-width: 0; height: 100%;
  padding: 0; border: none; background: transparent;
  font: inherit; font-weight: 700; color: var(--c-primary);
  font-variant-numeric: tabular-nums;
}
.align-field .af-input input.af-num:focus { outline: none; }
.align-field .af-input:focus-within {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--c-primary) 18%, transparent);
}
.align-note {
  margin: 10px 0 0;
  padding: 8px 10px;
  background: var(--c-primary-soft);
  border-radius: var(--r-sm);
  font-size: 12px; line-height: 1.55;
  color: var(--c-primary);
}

/* 空白色基准 */
.bg-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--c-surface);
  border-radius: var(--r-sm);
}
.bg-swatch {
  width: 28px; height: 28px; flex: none;
  border-radius: var(--r-sm);
  background: var(--c-surface-highest);
  box-shadow: inset 0 0 0 1px var(--c-hairline);
}
.bg-row .bg-meta { flex: 1 1 auto; min-width: 0; }
.bg-row .bg-meta b { display: block; font-size: 12.5px; color: var(--c-text); font-weight: 700; }
.bg-row .bg-meta small { font-size: 11.5px; color: var(--c-outline); }

/* 背景容差滑杆 + 点选背景 */
.bg-tol-row {
  display: flex; align-items: center; gap: 10px;
  margin-top: 10px;
  font-size: 12px; color: var(--c-text-sub);
}
.bg-tol-row label { flex: none; }
.bg-tol-row input[type="range"] { flex: 1 1 auto; min-width: 0; accent-color: var(--c-primary); }
.bg-tol-row b { flex: none; min-width: 2ch; text-align: right; color: var(--c-primary); font-variant-numeric: tabular-nums; }
.bg-pick {
  width: 100%; margin-top: 8px; height: 30px;
  border: 1px solid var(--c-outline-variant); border-radius: var(--r-pill);
  background: var(--c-surface); color: var(--c-text-sub);
  font-size: 12.5px; font-family: inherit; cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.bg-pick:hover { background: var(--c-surface-high); color: var(--c-text); }
.bg-pick.on { background: var(--c-primary-soft); border-color: var(--c-primary); color: var(--c-primary); font-weight: 700; }

/* role=button 的背景色块：键盘聚焦时给可见焦点 */
.bg-row:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

/* chips（品牌选择，复用视觉） */
.chips { position: relative; display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips label {
  min-width: 44px; text-align: center;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--c-surface);
  font-size: 13px; color: var(--c-text-sub);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.chips label:hover { background: var(--c-surface-high); color: var(--c-text); }
.chips input:checked + label { background: var(--c-primary-soft); color: var(--c-primary); font-weight: 700; }
/* input 本体是透明的，焦点环画在紧随其后的 label 上 */
.chips input:focus-visible + label { outline: 2px solid var(--c-primary); outline-offset: 2px; }

/* switch-row（复用右栏显示设置） */
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3);
  padding: 7px 0;
  font-size: 14px; color: var(--c-text);
}
.switch-row small { display: block; font-size: 12px; color: var(--c-outline); font-weight: 400; margin-top: 1px; }
.switch { position: relative; flex: none; width: 42px; height: 25px; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--c-surface-high);
  border-radius: var(--r-pill);
  transition: background .15s ease;
  pointer-events: none;
}
.switch .track::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 19px; height: 19px;
  background: var(--c-outline);
  border-radius: 50%;
  transition: transform .15s ease, background .15s ease;
}
.switch input:checked + .track { background: var(--c-primary-soft); }
.switch input:checked + .track::after { transform: translateX(17px); background: var(--c-primary); }
/* 开关的 input 透明铺满整行控件：键盘聚焦时焦点环落在轨道上 */
.switch input:focus-visible + .track { outline: 2px solid var(--c-primary); outline-offset: 2px; }

/* ---------- 中栏：工具栏 ---------- */
.board-bar {
  flex: none;
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: start; gap: var(--sp-2);
  padding: 8px 10px;
  border-bottom: 1px solid var(--c-divider);
  position: relative;
  z-index: 40;
}
.tb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 30px; height: 30px; padding: 0 8px;
  border: 0; border-radius: var(--r-pill);
  background: transparent;
  color: var(--c-text-sub);
  font-size: 12.5px; font-family: inherit;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.tb-btn:hover { background: var(--c-surface-high); color: var(--c-text); }
.board-bar .tb-tools { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-width: 0; }
.board-bar .tb-right { display: inline-flex; align-items: center; gap: 4px; flex-wrap: nowrap; white-space: nowrap; justify-self: end; }

/* 步骤大按钮 */
.step-nav {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 14px;
  border: 0; border-radius: var(--r-pill);
  background: var(--c-surface);
  color: var(--c-text-sub);
  font-size: 13px; font-family: inherit; font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.step-nav:hover { background: var(--c-surface-high); color: var(--c-text); }
.step-nav:disabled { opacity: .4; cursor: default; pointer-events: none; }
.step-nav.is-next {
  background: var(--c-primary); color: var(--c-on-primary); font-weight: 700;
}
.step-nav.is-next:hover { background: color-mix(in srgb, var(--c-primary) 88%, var(--c-text)); }

/* ---------- 中栏：舞台 ---------- */
.board-stage {
  position: relative;
  flex: 1 1 auto;
  display: grid; place-items: center;
  padding: var(--sp-4);
  background-color: var(--c-paper);
  overflow: hidden;
  min-height: 0;
  container-type: size;
}
.board-stage canvas { touch-action: none; }

/* 读图中的轻提示：贴在舞台顶部居中，不挡操作（纸面恒为浅色，所以用深底白字） */
.stage-loading[hidden] { display: none !important; }
.stage-loading {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 6;
  padding: 5px 12px; border-radius: var(--r-pill);
  background: rgba(38, 33, 30, 0.8); color: #fff;
  font-size: 12.5px; white-space: nowrap;
  pointer-events: none;
}

/* ---------- 当前步骤操作说明（步骤条上方常驻，随步骤切换） ---------- */
.stage-guide[hidden] { display: none !important; }
.stage-guide {
  flex: none;
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 14px;
  background: var(--c-primary-soft); color: var(--c-primary);
  font-size: 12.5px; line-height: 1.45;
}
.stage-guide .sg-step { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }
.stage-guide .sg-text { min-width: 0; }

/* ---------- 空态：未上传图纸（绝对定位覆盖在画布之上） ---------- */
.stage-empty {
  /* 纸面 --c-paper 两主题恒为浅色：空态文字必须固定深墨，不能跟随 --c-text*（深色下会翻成浅灰、在白纸上不可读） */
  --se-ink: #26211d;
  --se-ink-sub: #5a544e;
  --se-line: rgba(38, 33, 30, 0.28);
  position: absolute; inset: 0; z-index: 4;
  display: grid; place-items: center;
  padding: var(--sp-6);
  background: var(--c-paper);
  color: var(--se-ink-sub);
}
.stage-empty[hidden] { display: none; }
.stage-empty .se-box {
  display: grid; place-items: center; gap: var(--sp-3);
  /* 以可用高度为准做正方形，避免内容被底部步骤条压住 */
  height: min(100%, 460px);
  max-width: 100%;
  aspect-ratio: 1 / 1;
  padding: var(--sp-6) var(--sp-5);
  text-align: center;
  border: 2px dashed var(--se-line);
  border-radius: var(--r-card);
  color: var(--se-ink-sub);
  overflow: hidden;
}
.stage-empty .se-icon {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(38, 33, 30, 0.06);
  border: 1px solid rgba(38, 33, 30, 0.18);
  color: var(--se-ink-sub);
}
.stage-empty b { font-size: 16px; color: var(--se-ink); }
.stage-empty p { margin: 0; font-size: 13px; max-width: 300px; line-height: 1.6; color: var(--se-ink-sub); }
.stage-empty .se-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); flex-wrap: wrap; justify-content: center; }
.stage-empty .se-actions .btn { height: 34px; padding: 0 16px; font-size: 13px; }
.stage-empty .se-guide {
  display: inline-flex; align-items: center;
  height: 34px; padding: 0 12px;
  border: 1px solid var(--se-line); border-radius: var(--r-pill);
  color: var(--se-ink-sub); font-size: 13px; text-decoration: none;
}
.stage-empty .se-guide:hover { color: var(--se-ink); border-color: var(--se-ink-sub); }

/* 示意图纸（静态占位：CSS 画的格子图） */
.demo-pattern {
  position: relative;
  width: min(78%, 62vh);
  aspect-ratio: 1 / 1;
  background: var(--c-surface-highest);
  box-shadow: 0 6px 24px rgba(60, 40, 20, 0.12);
  border-radius: 2px;
  overflow: hidden;
}
/* 用 repeating-conic-gradient 画 8×8 格子线，模拟拼豆图纸 */
.demo-pattern .grid-bg {
  position: absolute; inset: 0;
  background-image:
    repeating-conic-gradient(from 0deg, var(--c-outline-variant) 0 1px, transparent 1px 12.5%);
  background-size: 100% 100%;
}
/* 模拟几个彩色豆块（一个小爱心轮廓） */
.bead {
  position: absolute;
  width: 12.5%; height: 12.5%;
}
.bead.red { background: var(--c-danger, #d9534f); }
.bead.pink { background: color-mix(in srgb, var(--c-danger, #d9534f) 35%, var(--c-surface-highest)); }
.bead.cream { background: color-mix(in srgb, var(--c-warning, #f5e6c8) 40%, var(--c-surface-highest)); }
.bead.sage { background: color-mix(in srgb, var(--c-primary) 35%, var(--c-surface-highest)); }

/* ---------- 本工具特有：田字格锚点 ---------- */
.anchor {
  position: absolute;
  width: 120px; height: 120px;
  z-index: 5;
  pointer-events: none;
}
.anchor svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.anchor .anchor-tag {
  position: absolute;
  left: 50%; top: -26px;
  transform: translateX(-50%);
  padding: 2px 9px;
  border-radius: var(--r-pill);
  background: var(--c-card);
  border: 1px solid var(--c-outline-variant);
  color: var(--c-text-sub);
  font-size: 11px; font-weight: 700;
  white-space: nowrap;
  box-shadow: var(--shadow-card);
}
.anchor.is-active { z-index: 7; }
.anchor.is-active .anchor-tag {
  background: var(--c-primary); color: var(--c-on-primary); border-color: var(--c-primary);
}
.anchor.is-done .anchor-tag { color: var(--c-primary); }

/* 左上锚点：贴在 demo-pattern 的 (0,0) 位置 */
.anchor-tl { left: 8%; top: 12%; }
/* 右下锚点：贴在 demo-pattern 的右下角 */
.anchor-br { right: 8%; bottom: 12%; }

/* ---------- 状态栏 ---------- */
.stage-status {
  --st-bg: var(--c-footer);
  --st-fg: #B7B2A8;
  --st-strong: #F2EDE4;
  flex: none;
  display: flex; align-items: center; gap: var(--sp-4);
  height: 36px; padding: 0 var(--sp-4);
  background: var(--st-bg); color: var(--st-fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 11.5px;
  white-space: nowrap; overflow: hidden;
}
[data-theme="light"] .stage-status { --st-fg: #6B6158; --st-strong: #20160E; }
.stage-status .st-mid { display: inline-flex; align-items: center; gap: 6px; }
.stage-status .st-mid b { color: var(--st-strong); font-weight: 700; }
.stage-status .st-mid em { font-style: normal; opacity: .5; }
.stage-status .st-right { display: inline-flex; gap: 10px; margin-left: auto; }
.stage-status .st-right b { color: var(--st-strong); font-weight: 700; min-width: 2ch; display: inline-block; text-align: right; }

/* 底栏缩放条：与图片转拼豆共用视觉口径 */
.zoom-bar {
  display: flex; align-items: center; gap: 2px;
  margin-left: 0;
}
.zb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 26px; height: 24px; padding: 0 5px;
  border: 0; border-radius: var(--r-pill); background: none;
  color: var(--c-text); font-size: 13px; cursor: pointer;
}
.zb-btn:hover:not(:disabled) { background: var(--c-paper); color: var(--c-primary); }
.zb-btn:disabled { opacity: .35; cursor: default; }
.zb-val {
  min-width: 44px; text-align: center;
  font-size: 12px; font-variant-numeric: tabular-nums; color: var(--c-text);
}
.zb-sep { width: 1px; height: 14px; background: var(--c-card-edge); margin: 0 3px; }
.zb-wide { padding: 0 8px; }

/* ---------- 设置抽屉（预览区右侧滑出） ---------- */
.drawer-mask {
  position: absolute; inset: 0; z-index: 55;
  background: rgba(31, 26, 22, .32);
  opacity: 0; visibility: hidden;
  transition: opacity .22s ease, visibility .22s ease;
}
.drawer-mask.open { opacity: 1; visibility: visible; }
.canvas-drawer {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 60;
  width: min(320px, 88%);
  display: flex; flex-direction: column;
  background: var(--c-card);
  border-left: 1px solid var(--c-card-edge);
  box-shadow: -12px 0 32px rgba(31, 26, 22, .18);
  transform: translateX(102%);
  visibility: hidden;
  transition: transform .24s ease, visibility .24s ease;
}
.canvas-drawer.open { transform: none; visibility: visible; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--c-card-edge);
  font-size: 14px; font-weight: 600; color: var(--c-text);
}
.drawer-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 6px; background: none;
  color: var(--c-outline); cursor: pointer;
}
.drawer-close:hover { color: var(--c-primary); background: var(--c-paper); }
.drawer-body {
  flex: 1; overflow-y: auto; padding: 0 14px 14px;
  display: flex; flex-direction: column;
}
.switch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.switch-grid .switch-row { min-width: 0; gap: 8px; padding: 5px 0; font-size: 12.5px; }
.switch-grid .switch-row > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch-grid .switch-row small { display: block; white-space: normal; }

/* ---------- 右栏 ---------- */
/* 色号统计行只读、不可点：盖掉 shared.css 里 button 式的 pointer 光标和 hover 高亮 */
#colorList .color-row { cursor: default; }
#colorList .color-row:hover { background: var(--c-surface); }
.color-empty {
  padding: var(--sp-6) var(--sp-4);
  text-align: center; font-size: 12.5px; line-height: 1.7;
  color: var(--c-outline);
  border: 1.5px dashed var(--c-outline-variant);
  border-radius: var(--r-sm);
}
.color-more { padding: 6px 2px 0; font-size: 11.5px; color: var(--c-outline); text-align: center; }
.info-foot {
  flex: none;
  position: relative;
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  border-top: 1px solid var(--c-divider);
}
.info-foot .pg-title { margin-bottom: var(--sp-2); }
.info-foot .btn { height: 36px; font-size: 13px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; box-sizing: border-box; }
.info-foot .btn:disabled { opacity: .45; cursor: not-allowed; }
.export-pop-btn small { display: block; font-size: 11px; color: var(--c-outline); font-weight: 400; }
.export-row { display: flex; gap: 8px; margin-top: var(--sp-2); }
.export-row .btn-export-primary { flex: 1.4; }
.export-row .btn-export-more { flex: 1; }
.btn-export-bead { width: 100%; margin-top: 8px; }

/* ---------- 窄屏 ---------- */
@media (max-width: 1080px) {
  html, body { height: auto; min-height: 100%; overflow: visible; }
  .app-shell { background: var(--c-bg); }
  .board-stage { min-height: 56vh; }
}
@media (max-width: 720px) {
  .app-topbar { padding: 0 10px; gap: 8px; }
  .tb-back { padding: 0 11px; }
  .tb-brand .sep, .tb-brand .tn, .tb-brand .tag, .tb-brand .pn { display: none; }
  .tb-switch-item { padding: 0 11px; font-size: 12.5px; }
  .sw-full { display: none; }
  .sw-short { display: inline; }
  .stage-status { gap: 8px; padding: 0 8px; height: 44px; }
  /* 窄屏状态栏只留「阶段 + 缩放组」：尺寸 / 单格 px / 品牌、P1 P2 读数收起，避免 360px 屏溢出 */
  .stage-status .st-right,
  .stage-status .st-opt,
  .stage-status .st-sep { display: none; }
  .stage-status .zb-val { min-width: 40px; }
  .stage-status .zb-wide { padding: 0 8px; }
  /* 步骤条收成「序号 + 当前步名称」，5 个中文名在 360px 屏会被裁 */
  .sn-name { display: none; }
  .step-node.is-current .sn-name { display: block; }
  .step-line { margin: 0 4px; min-width: 12px; }
  .stage-guide { padding: 5px 10px; gap: 6px; font-size: 12px; }

  /* 触控目标 ≥ 40px：相邻的按钮直接撑高（伪元素外扩会互相压），孤立按钮用伪元素扩大热区 */
  .tb-btn, .step-nav { min-height: 40px; }
  .stage-status .zb-btn { min-width: 36px; min-height: 40px; }
  .stage-empty .se-actions .btn, .stage-empty .se-guide { min-height: 40px; }
  .sc-btn, .bg-pick, .chips label, .drawer-close { position: relative; }
  .sc-btn::after, .bg-pick::after { content: ""; position: absolute; inset: -7px 0; }
  .chips label::after { content: ""; position: absolute; inset: -7px -4px; }
  .drawer-close::after { content: ""; position: absolute; inset: -8px -9px; }
  .switch::after { content: ""; position: absolute; inset: -9px -4px; }
  .tb-actions .icon-sq::after { content: ""; position: absolute; inset: -4px; }
  .tb-actions .icon-sq { position: relative; }
}
