/* 工具页局部收紧卡片/区域圆角：仅作用于本页，不改动主站设计令牌 */
:root { --r-card: 6px; --r-sm: 4px; }

/* ============================================================
   自由创作 · 在线工具（独立页面 · 网页版）
   纯工具界面：独立顶栏 + 中大画布 / 右信息，两栏内部各自滚动。
   与图片转拼豆的差异：去掉左参数栏，画布参数收进顶栏「设置」抽屉。
   工具区高度锁定为 100dvh，窄屏改为单列自然高度。
   全部走 main.css 设计令牌，深浅主题自适应。
   功能介绍与常见问题统一放在 features/bead-pattern-maker/ 的 #web 章节。
   ============================================================ */

/* 应用本体占满视口：独立工具界面，不与正文拼接 */
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);
}

/* ---------- 独立顶栏（高度与全站 .header-inner 一致 = 64px） ---------- */
.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-main { grid-template-columns: minmax(0, 1fr); }
  .board-wrap { order: -1; }
}

/* 通用栏卡片：与全站卡片同一套表面语言（白底 + 1px 外框 + 纸厚暖晕） */
.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); }

/* ---------- 中栏：创作画布 ---------- */
.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;
}

/* 拼豆板：铺满整个预览区，缩放 / 平移由 BoardViewport 重绘（此处 transform 必须为 none） */
.board {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  aspect-ratio: auto;
  transform: none;
  transition: none;
  overflow: hidden;
  touch-action: none;
}
.board canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}
.board.is-pan, .board.is-pan canvas { cursor: grab; }
.board.is-panning, .board.is-panning canvas { transition: none; cursor: grabbing; }
.board.is-painting canvas { cursor: crosshair; }

/* 静态样式预览用的示例图纸（非真实绘制结果），真实页由 canvas 绘制 */
.mock-board {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  pointer-events: none;
}

/* 空态：盖在恒定米白纸面上，文字 / 图标 / 虚线一律用固定深墨（纸面不随主题变，故不走 --c-text*）。
   整层不拦截指针：底下的画布仍可拖动 / 缩放，只有按钮可点。 */
.stage-empty {
  --se-ink: #26211d;
  --se-ink-sub: #5a544e;
  --se-line: rgba(38, 33, 30, 0.28);
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: var(--sp-6);
  background: var(--c-paper);
  color: var(--se-ink-sub);
  z-index: 4;
  pointer-events: none;
}
.stage-empty[hidden] { display: none; }
.stage-empty .se-box {
  display: grid; place-items: center; gap: var(--sp-3);
  width: min(100%, 460px, max(70vh, 260px));
  aspect-ratio: 1 / 1;
  padding: var(--sp-8) var(--sp-6);
  text-align: center;
  border: 2px dashed var(--se-line);
  border-radius: var(--r-card);
  color: var(--se-ink-sub);
}
@supports (width: 1cqh) {
  /* 与 image-to-bead 同步：cqh 在部分移动浏览器算成 0 会让空态框塌成竖排文字 */
  .stage-empty .se-box { width: min(100%, 460px, max(calc(100cqh - var(--sp-4) * 2), 260px)); }
}
.stage-empty .se-icon {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(38, 33, 30, 0.05);
  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; pointer-events: auto; }
.stage-empty .btn-ghost { border-color: var(--se-line); color: var(--se-ink); }
.stage-empty .btn-ghost:hover { background: rgba(38, 33, 30, 0.06); border-color: rgba(38, 33, 30, 0.45); color: var(--se-ink); }

/* 恢复条：检测到上次未导出的草稿时显示在画布卡片顶部 */
.restore-bar {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 8px var(--sp-4);
  background: var(--c-primary-soft);
  color: var(--c-text);
  border-bottom: 1px solid var(--c-divider);
  font-size: 12.5px;
}
.restore-bar[hidden] { display: none; }
.restore-bar .rb-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c-primary); flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-primary) 18%, transparent);
}
.restore-bar #restoreText { flex: 1 1 auto; min-width: 0; }
.restore-bar .btn { height: 28px; padding: 0 10px; font-size: 12px; flex: none; }

/* 状态栏 */
.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; }

/* ---------- 分段控件 / 开关 / 滑块（shared.css 未覆盖，随页携带） ---------- */
.segment {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  padding: 3px;
  background: var(--c-surface);
  border-radius: 999px;
}
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment label {
  display: grid; place-items: center;
  height: 30px;
  border-radius: 999px;
  background: transparent;
  font-size: 13px; color: var(--c-text-sub);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.segment label:hover { color: var(--c-text); }
.segment input:checked + label {
  background: var(--c-surface-highest);
  color: var(--c-primary); font-weight: 700;
  box-shadow: var(--shadow-card);
}
.segment-inline { flex: none; width: 132px; }
.segment-inline label { height: 25px; font-size: 12px; }

.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-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 .span-2 { grid-column: 1 / -1; }
.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); }
/* 开着「显示色号」但格子不够大：开关置灰（仍可点），下方给提示 */
.switch-row.is-muted .switch { opacity: .5; }
.switch-hint {
  padding: 0 0 4px;
  font-size: 12px; line-height: 1.5; color: var(--c-outline);
}
.switch-hint[hidden] { display: none; }

/* 键盘焦点：开关 / 分段控件的 input 是透明的，焦点环画在相邻的轨道 / label 上 */
.switch input:focus-visible + .track { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.segment input:focus-visible + label { outline: 2px solid var(--c-primary); outline-offset: 1px; }
.tool-opt:focus-visible, .zb-btn:focus-visible, .drawer-close:focus-visible, .color-pop-close:focus-visible,
.layer-act:focus-visible, .tb-navlink:focus-visible, .drawer-links a:focus-visible {
  outline: 2px solid var(--c-primary); outline-offset: 1px;
}
.layer-row:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 1px; }

.slider { padding: 5px 0; }
.slider .lab {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--c-text-sub);
  margin-bottom: 2px;
}
.slider .lab b { color: var(--c-primary); font-weight: 700; font-variant-numeric: tabular-nums; }
.slider input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; background: transparent; cursor: pointer;
}
.slider input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: var(--r-pill);
  background: var(--c-surface-high);
}
.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 17px; height: 17px; margin-top: -6px;
  border-radius: 50%;
  background: var(--c-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
}
.slider input[type="range"]::-moz-range-track {
  height: 6px; border-radius: var(--r-pill); background: var(--c-surface-high);
}
.slider input[type="range"]::-moz-range-thumb {
  width: 17px; height: 17px; border: 0;
  border-radius: 50%; background: var(--c-primary);
}

/* ---------- 图层列表 ---------- */
.layer-list { display: flex; flex-direction: column; gap: 6px; }
/* 行本体是 button：可聚焦，回车 / 空格选中该层 */
.layer-row {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 6px 6px 6px 8px;
  border: 1px solid var(--c-card-edge);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  color: inherit; font: inherit; text-align: left;
  cursor: pointer;
}
.layer-row:hover { border-color: var(--c-outline-variant); }
.layer-row.on { border-color: var(--c-primary); box-shadow: inset 0 0 0 1px var(--c-primary-soft); }
.layer-row.is-hidden { opacity: .6; }
.layer-row.is-hidden .layer-swatch { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--c-outline-variant); }
.layer-swatch { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.layer-name {
  flex: 1; min-width: 0; font-size: 13px; color: var(--c-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.layer-tools { display: inline-flex; align-items: center; gap: 2px; flex: none; }
.layer-act {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0;
  border: 0; border-radius: 4px; background: none;
  color: var(--c-outline); cursor: pointer;
}
.layer-act:hover, .layer-act:focus-visible { color: var(--c-primary); background: var(--c-paper); }
.layer-actions { margin-top: 8px; }

/* 设置抽屉里的「清空画布」：危险操作用红色描边提示 */
.tool-opt--danger { color: var(--c-danger); }
.tool-opt--danger:hover { color: var(--c-danger); }
.drawer-links {
  display: flex; justify-content: center; gap: 14px;
  padding-top: 4px; font-size: 12.5px;
}
.drawer-links a { color: var(--c-text-sub); text-decoration: none; padding: 4px 6px; border-radius: 6px; }
.drawer-links a:hover { color: var(--c-primary); background: var(--c-surface-high); }

/* ---------- 轻提示 ---------- */
.toast-box {
  position: fixed; left: 50%; bottom: 56px; transform: translateX(-50%);
  z-index: 90; display: grid; gap: 6px; pointer-events: none;
}
.toast {
  max-width: min(90vw, 460px);
  padding: 9px 14px; border-radius: var(--r-pill);
  background: var(--c-surface-highest); color: var(--c-text);
  font-size: 13px; line-height: 1.5; text-align: center;
  box-shadow: var(--shadow-card);
  animation: toast-in .18s ease both;
}
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .18s ease, transform .18s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 设置抽屉会向下溢出工具条，需高于 .stage-status(30) 才不会
   被预览区底部的状态条压住（shared.css 里 .board-bar 为 20）。 */
.board-bar { z-index: 40; }

/* ---------- 缩放条（预览区底栏右侧） ---------- */
.zoom-bar {
  display: flex; align-items: center; gap: 2px;
  margin-left: auto;
}
.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 { background: var(--c-paper); color: var(--c-primary); }
/* 已到缩放上下限：置灰且不可点 */
.zb-btn:disabled { opacity: .35; cursor: default; }
.zb-btn:disabled:hover { background: none; color: var(--c-text); }
.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: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.drawer-body .tool-pop-title { margin: 0; }
.drawer-body .slider { margin: 0; }
.drawer-body .switch-grid { margin: 0; }

/* 尺寸预设文字较长（如 120 × 120），固定三列避免换行参差不齐 */
#sizePresets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
#sizePresets .tool-opt { width: 100%; padding-left: 4px; padding-right: 4px; }

/* ---------- 色板浮层（与图片转拼豆同一套类名与结构） ---------- */
.color-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30;
  width: 292px;
  background: var(--c-card);
  border: 1px solid var(--c-outline-variant);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.color-pop[hidden] { display: none; }
.color-pop-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  font-size: 12.5px; font-weight: 700; color: var(--c-text-sub);
  border-bottom: 1px solid var(--c-divider);
}
.color-pop-close {
  width: 22px; height: 22px; display: grid; place-items: center;
  padding: 0; border: 0; background: none; font-family: inherit;
  border-radius: var(--r-sm); cursor: pointer;
  color: var(--c-outline); font-size: 15px; line-height: 1;
}
.color-pop-close:hover { background: var(--c-surface-high); color: var(--c-text); }
.color-pop-tools {
  display: grid; gap: 8px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--c-divider);
}
.color-pop-list {
  max-height: min(320px, 46vh); overflow-y: auto;
  padding: 8px; display: grid; gap: 4px;
}
.cp-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 7px; border: 0; border-radius: var(--r-sm);
  background: transparent; cursor: pointer;
  font-size: 12.5px; color: var(--c-text-sub);
  text-align: left; width: 100%;
}
.cp-row:hover { background: var(--c-surface-high); color: var(--c-text); }
.cp-row.on { background: var(--c-primary-soft); color: var(--c-primary); font-weight: 700; }
.cp-row .dot { width: 16px; height: 16px; flex: none; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--c-hairline); }
.cp-row .cp-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-row .cp-name small { color: var(--c-outline); }
.cp-row .cnt { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--c-outline); font-weight: 400; }
.cp-empty { padding: 14px 10px; text-align: center; font-size: 12px; color: var(--c-outline); }

/* ---------- 右栏色号统计 ---------- */
.color-list { display: grid; gap: 6px; }
.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-row {
  padding: 8px 10px;
  background: var(--c-surface);
  border-radius: var(--r-sm);
  display: grid; gap: 6px;
  border: 0; width: 100%; text-align: left; font-family: inherit;
  cursor: pointer;
  transition: background .15s ease;
}
.color-row:hover { background: var(--c-surface-high); }
.color-row.on { background: var(--c-primary-soft); }
.color-row .top { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.color-row .dot { width: 17px; height: 17px; flex: none; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--c-hairline); }
.color-row .nm { color: var(--c-text); font-weight: 700; }
.color-row .nm small { color: var(--c-outline); font-weight: 400; margin-left: 5px; }
.color-row .cnt { margin-left: auto; color: var(--c-text-sub); font-variant-numeric: tabular-nums; }
.color-row .bar { height: 4px; border-radius: var(--r-pill); background: var(--c-surface-high); overflow: hidden; }
.color-row .bar i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--bar-color, var(--c-primary)); }

/* ---------- 图层画布堆叠（DOM 顺序 = 层级，顶层最后追加） ---------- */
.layer-stack { position: absolute; inset: 0; }
.layer-stack canvas { pointer-events: none; }

/* ---------- 窄屏顶栏收口 ---------- */
@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; }
  /* 底栏让位给缩放控件：隐藏「共 N 颗」，保留尺寸 / 色数 / 缩放 / 居中 */
  .stage-status { gap: 8px; padding: 0 10px; }
  .stage-status .st-count { display: none; }
  .stage-status .zb-val { min-width: 40px; }
  .stage-status .zb-wide { padding: 0 6px; }
  /* 触控目标 ≥40px：缩放钮保持 26×24 的视觉尺寸，用伪元素向四周扩热区。
     状态条本身 36px 高，放开 overflow 让热区向上多出 4px（下方被卡片圆角裁掉）。 */
  .stage-status { overflow: visible; }
  .zb-btn { position: relative; }
  .zb-btn::after {
    content: ""; position: absolute; left: 50%; top: 50%;
    width: 44px; height: 44px; transform: translate(-50%, -50%);
  }
  /* 关闭钮：视觉不变大，用负 margin 抵消扩大的宽高，不撑开布局 */
  .drawer-close { width: 40px; height: 40px; margin: -7px; }
  .color-pop-close { width: 40px; height: 40px; margin: -9px -8px -9px 0; }
}

/* ---------- 堆叠模式（≤1080）· 覆盖规则置于末尾 ----------
   必须放在所有基础规则之后：同特异性按源码顺序后者胜，
   否则 .board-stage{min-height:0} 会反覆盖 → 窄屏画布塌成一条缝。
   窄屏改为纵向堆叠，页面整体可滚动，故放开 body 的高度与溢出限制。
   ⚠️ 窄屏同时关掉 container-type:size，避免 cqh 在移动浏览器算成 0 让空态框竖排。 */
@media (max-width: 1080px) {
  html, body { height: auto; min-height: 100%; overflow: visible; }
  .app-shell { height: auto; overflow: visible; background: var(--c-bg); }
  .app-main { height: auto; overflow: visible; }
  .board-stage { container-type: normal; flex: none; min-height: 56vh; }
  .stage-empty .se-box { width: min(100%, 420px); aspect-ratio: auto; }
  .board { transition: none; }
  .info-body { overflow: visible; }
}
