/* ===== ===== ===== ===== ===== ===== ===== ===== =====
 * 拼豆图纸生成 — style.css
 * ===== ===== ===== ===== ===== ===== ===== ===== ===== */
.bead-estimate{display:block;margin-top:3px;color:var(--t3);font-size:12px;line-height:1.5}

/*
 * 目录
 * ──────────────────────────────────────────
 * 001. 选区 + 鬼影 + 对齐预览      (L001)
 * 002. 选区叠加层                   (L043)
 * 003. 绘图区域 / 坐标系            (L054)
 * 004. 顶栏 iOS Navigation Bar      (L150)
 * 005. 画布区（网格 + 缩放容器）    (L196)
 * 006. 底部浮动玻璃胶囊             (L242)
 * 007. 系列 Tab 筛选栏              (L311)
 * 008. 遮罩 / 底部抽屉 / 居中弹窗   (L340)
 * 009. 底部 Action Sheet / 导出设置  (L374)
 * 010. 3D 预览弹窗                  (L433)
 * 011. 色系标签（色卡编码）         (L463)
 * 012. 图层面板（备用区）           (L475)
 * 013. HSV 颜色选择器               (L626)
 * 014. 参考图浮动控制面板           (L804)
 * 015. 设置弹窗色板预览             (L840)
 * 016. ★ 图层面板 — Apple HIG 重设计 (L847)
 * 017. 移动端响应式适配（4 断点）   (L1168)
 * ──────────────────────────────────────────
 * 总共约 1,239 行 · 28KB（gzip ~7KB）
 * ===== ===== ===== ===== ===== ===== ===== ===== ===== */

/* 选区鬼影 — 半透明重叠预览 */
.selection-ghost {
  box-shadow: 0 0 12px rgba(0,0,0,0.15);
  image-rendering: pixelated;
}

/* 对齐拖放预览 */
.drop-preview {
  animation: dropPulse 1.5s ease-in-out infinite;
}
@keyframes dropPulse {
  0%, 100% { border-color: rgba(99,102,241,0.6); background: rgba(99,102,241,0.08); }
  50% { border-color: rgba(99,102,241,0.9); background: rgba(99,102,241,0.15); }
}

/* 导出面板输出格式选项 — 3列 */
#outputFormatOptions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 16px;
}
#outputFormatOptions .export-fopt {
  text-align: center;
  padding: 14px 8px;
}
#outputFormatOptions .export-fopt i {
  font-size: 22px;
  display: block;
  margin-bottom: 4px;
}

/* 暗色适配 */
@media (prefers-color-scheme: dark) {
  .selection-ghost { box-shadow: 0 0 12px rgba(0,0,0,0.3); }
  .drop-preview { background: rgba(99,102,241,0.12); }
}

/* ===== 选区叠加层基础样式 ===== */
.select-overlay {
  position: absolute;
  pointer-events: none;
  z-index: 7;
  border: 2px solid #6366f1;
  border-radius: 4px;
  background: rgba(99,102,241,0.06);
  box-sizing: border-box;
}

/* =============================================
   专注拼豆 · Apple HIG 设计语言
   ============================================= */
:root {
  /* Brand accent */
  --yellow: #FFD43B;
  --yellow-d: #E8BA20;
  --yellow-light: #FFF9E5;
  --yellow-alpha: rgba(255,212,59,0.15);

  /* iOS System Colors - Light */
  --bg: #F2F2F7;          /* systemGray6 */
  --white: #FFFFFF;
  --t: #1C1C1E;           /* label */
  --t2: #3C3C43;          /* secondaryLabel */
  --t3: #8E8E93;          /* tertiaryLabel */
  --t4: #C7C7CC;          /* quaternaryLabel */
  --bd: #E5E5EA;          /* separator */
  --bd2: #F0F0F5;         /* opaqueSeparator */

  /* iOS Fill Colors */
  --fill-primary: rgba(120,120,128,0.2);
  --fill-secondary: rgba(120,120,128,0.16);
  --fill-tertiary: rgba(120,120,128,0.12);

  /* Safe area */
  --safe-b: env(safe-area-inset-bottom,0px);
  --safe-t: env(safe-area-inset-top,0px);

  /* Corner radius — Apple HIG */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  /* Apple SF Typography Scale */
  --fs-caption: 11px;
  --fs-footnote: 13px;
  --fs-subhead: 15px;
  --fs-body: 17px;
  --fs-title3: 20px;
  --fs-title2: 22px;
  --fs-title1: 28px;

  /* Apple Spring & Easing */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* Apple Material */
  --blur-frost: blur(40px) saturate(180%);
  --blur-modal: blur(30px) saturate(180%);
  --blur-sheet: blur(24px) saturate(180%);

  /* Shadows — Apple multi-layer */
  --shadow-sm: 0 0.5px 1px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 1px 3px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-lg: 0 2px 8px rgba(0,0,0,0.06), 0 8px 32px rgba(0,0,0,0.08);
  --shadow-xl: 0 4px 16px rgba(0,0,0,0.06), 0 16px 48px rgba(0,0,0,0.1);
}

/* Dark Mode — System Preference */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1C1C1E;          /* system Gray 6 dark */
    --white: #2C2C2E;
    --t: #FFFFFF;
    --t2: #EBEBF5;          /* secondaryLabel dark */
    --t3: #8E8E93;          /* tertiaryLabel dark (kept) */
    --t4: #636366;
    --bd: #38383A;          /* separator dark */
    --bd2: #1C1C1E;
    --yellow: #FFD43B;
    --yellow-d: #F5C518;
    --yellow-light: #2A2815;
    --yellow-alpha: rgba(255,212,59,0.12);
    --fill-primary: rgba(120,120,128,0.36);
    --fill-secondary: rgba(120,120,128,0.32);
    --fill-tertiary: rgba(120,120,128,0.24);
    --shadow-sm: 0 0.5px 1px rgba(0,0,0,0.2), 0 1px 2px rgba(0,0,0,0.12);
    --shadow-md: 0 1px 3px rgba(0,0,0,0.2), 0 2px 8px rgba(0,0,0,0.14);
    --shadow-lg: 0 2px 8px rgba(0,0,0,0.24), 0 8px 32px rgba(0,0,0,0.18);
    --shadow-xl: 0 4px 16px rgba(0,0,0,0.24), 0 16px 48px rgba(0,0,0,0.2);
  }
}
*,*::before,*::after{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent}
[hidden]{display:none!important}
button :is(svg,use,.icon,span:not(.interactive),i){pointer-events:none}
html,body{height:100%;overflow:hidden;-webkit-font-smoothing:antialiased}
body{font-family:-apple-system,BlinkMacSystemFont,'Helvetica Neue',Arial,sans-serif;background:var(--bg);display:flex;flex-direction:column;font-size:15px;color:var(--t);line-height:1.4}
body.modal-open{overflow:hidden}
main{flex:1;display:flex;flex-direction:column;min-height:0}
svg{display:block;flex-shrink:0}
input,select,button{font-family:inherit;font-size:inherit}
button{cursor:pointer;border:none;background:none;padding:0}
:focus-visible{outline:2px solid var(--yellow);outline-offset:2px}

/* ===== 顶栏 — iOS Navigation Bar ===== */
.topbar{height:52px;background:var(--white);display:flex;align-items:center;justify-content:space-between;padding:0 10px;border-bottom:0.5px solid var(--bd);flex-shrink:0;z-index:50;box-shadow:var(--shadow-sm)}
.topbar-left{display:flex;align-items:center;gap:6px;flex:1;min-width:0}
.topbar-right{display:flex;align-items:center;gap:6px;flex-shrink:0}

/* 品牌选择器 — 黄色药丸，与工具栏 .float-btn 风格统一 */
.brand-btn{display:inline-flex;align-items:center;gap:4px;padding:0 9px;min-height:34px;height:34px;max-width:112px;border-radius:9px;background:var(--yellow);cursor:pointer;font-size:12px;font-weight:600;color:var(--t);transition:transform .1s,background-color .1s;box-shadow:none;border:none;outline:none}
.brand-btn:active{transform:scale(0.96);background:var(--yellow-d)}
.brand-btn span{max-width:82px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;font-weight:600;color:var(--t)}
.brand-btn svg{width:10px;height:10px;flex-shrink:0;color:var(--t)}

/* 子集色板行 — 次级导航 */
.sub-palette-row{display:flex;align-items:center;gap:8px;padding:4px 12px;background:var(--white);border-bottom:0.5px solid var(--bd);flex-shrink:0;overflow-x:auto;-webkit-overflow-scrolling:touch}
.sub-palette-row::-webkit-scrollbar{display:none}
.sub-palette-label{font-size:11px;color:var(--t3);font-weight:500;flex-shrink:0}
.chip-sm{display:inline-flex;align-items:center;padding:4px 10px;border:1px solid var(--bd);border-radius:var(--r-full);font-size:11px;cursor:pointer;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;white-space:nowrap;flex-shrink:0;background:transparent}
.chip-sm:active{transform:scale(0.94)}
.chip-sm:has(input:checked){background:var(--yellow-alpha);border-color:var(--yellow);font-weight:600;color:var(--t)}
.chip-sm input{display:none}

/* 顶栏按钮 — 尺寸/操作 (与 .float-btn 风格统一) */
.topbar-size{display:inline-flex;align-items:center;gap:6px;padding:0 12px;min-height:44px;border-radius:999px;background:var(--fill-secondary);font-size:12px;font-weight:600;color:var(--t2);font-family:monospace;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;border:none;cursor:pointer}
.topbar-size:active{transform:scale(0.96);background:var(--fill-primary)}
.topbar-size svg{width:10px;height:10px;color:var(--t3)}

/* 顶栏保存按钮 — 黄色圆形，同 .float-btn.icon-only 风格 */
.topbar-save{display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;border-radius:50%;background:var(--yellow);color:#5a4200;font-size:16px;border:none;cursor:pointer;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;box-shadow:var(--shadow-sm)}
.topbar-save:active{transform:scale(0.94);background:var(--yellow-d)}
.topbar-save i{font-size:16px;display:flex}

/* 顶栏图标按钮 — 灰色圆形，同 .float-btn.icon-only 风格 */
.topbar-list{display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;border-radius:50%;background:var(--fill-secondary);border:none;cursor:pointer;color:var(--t2);font-size:17px;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;flex-shrink:0}
.topbar-list:active{transform:scale(0.94);background:var(--fill-primary)}
.topbar-list i{font-size:17px;display:flex}

/* 顶栏撤销/重做 — 灰色圆形，紧凑排列 */
.topbar-center{display:flex;align-items:center;gap:2px;flex-shrink:0;margin:0 2px}
.topbar-undo{display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;border-radius:50%;background:transparent;border:none;cursor:pointer;color:var(--t2);font-size:16px;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;flex-shrink:0}
.topbar-undo:active{transform:scale(0.94);background:var(--fill-tertiary)}
.topbar-undo.disabled{opacity:0.3;pointer-events:none;cursor:default}
.topbar-undo i{font-size:16px;display:flex}

/* ===== 画布区 ===== */
.canvas-area{flex:1;display:flex;align-items:center;justify-content:center;overflow:hidden;position:relative;background:var(--bg);touch-action:none;-webkit-user-select:none;user-select:none}
.canvas-area .grid-wrapper{touch-action:none}
.canvas-container{touch-action:none;-webkit-overflow-scrolling:touch;overscroll-behavior:none}

/* 首页空状态：品牌、主动作、辅助入口三层信息结构。 */
.empty-state{width:min(100%,430px);padding:28px 22px;text-align:center;max-height:100%;overflow-y:auto}
.empty-icon{width:92px;height:92px;margin:0 auto 16px;display:flex;align-items:center;justify-content:center;animation:fadeIn .4s var(--ease-out),scaleIn .4s var(--ease-out)}
.empty-icon img{display:block;width:92px;height:92px}
.empty-title{margin:0;color:#1d1d1f;font-size:30px;font-weight:760;line-height:1.16;letter-spacing:-.02em}
.empty-title span{font-family:Inter,-apple-system,BlinkMacSystemFont,"SF Pro Display","Segoe UI",sans-serif;font-weight:720}
.empty-tagline{margin:7px 0 0;color:#8f4f28;font-size:13px;font-weight:650;letter-spacing:0}
.empty-desc{max-width:360px;margin:14px auto 24px;color:#6e6e73;font-size:15px;line-height:1.55}
.primary-btn{display:inline-flex;align-items:center;justify-content:center;padding:12px 32px;background:var(--yellow);color:var(--t);font-size:16px;font-weight:600;border-radius:12px;transition:transform .15s var(--ease-spring),background-color .2s ease,border-color .2s ease,color .2s ease,box-shadow .2s ease;min-height:48px}
.primary-btn:active{transform:scale(.97);background:var(--yellow-d)}
.primary-btn:disabled{opacity:.4;transform:none;cursor:not-allowed}
.secondary-btn{display:inline-flex;align-items:center;justify-content:center;padding:10px 28px;background:var(--white);color:var(--t2);font-size:15px;font-weight:500;border-radius:12px;border:1.5px solid var(--bd);transition:transform .15s var(--ease-spring),background-color .2s ease,border-color .2s ease,color .2s ease,box-shadow .2s ease;min-height:44px;cursor:pointer}
.secondary-btn:active{transform:scale(.97);background:var(--bg)}
.empty-state .primary-btn{display:inline-flex;align-items:center;justify-content:center;gap:7px;min-height:50px;padding:12px 28px;border-radius:13px;background:#1d1d1f;color:#fff;font-size:15px;font-weight:650;transition:background .16s,transform .16s}
.empty-state .primary-btn:hover{background:#000}
.empty-state .primary-btn:active{transform:scale(.98);background:#000}
.empty-state .primary-btn:disabled{opacity:.4;transform:none;cursor:not-allowed}
.empty-state .secondary-btn{display:inline-flex;align-items:center;justify-content:center;gap:7px;min-height:46px;padding:10px 20px;border:.5px solid rgba(0,0,0,.11);border-radius:12px;background:rgba(255,255,255,.78);color:#3a3a3c;font-size:14px;font-weight:600;transition:background .16s,transform .16s,border-color .16s;cursor:pointer}
.empty-state .secondary-btn:hover{background:#fff;border-color:rgba(0,0,0,.16)}
.empty-state .secondary-btn:active{transform:scale(.98);background:#f5f5f7}
.empty-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;width:100%}
#emptyUploadBtn{grid-column:1/-1;width:100%}
.empty-meta{display:flex;align-items:center;justify-content:center;gap:9px;margin-top:18px;color:#86868b;font-size:11px;line-height:1.3}
.local-privacy{display:inline-flex;align-items:center;gap:5px;margin:0;padding:0;background:transparent;color:#6e6e73;font-size:11px;font-weight:500}
.local-privacy .icon{width:12px;height:12px;color:#248a3d}
.empty-meta-divider{width:1px;height:11px;background:rgba(0,0,0,.14)}
.empty-meta .legal-review-link{margin:0;padding:3px 0;color:#6e6e73;font-size:11px;font-weight:500}
.empty-meta .legal-review-link:hover{color:#06c}
.desktop-image-dropzone{display:none}
@media(min-width:900px){
  .empty-state{width:min(680px,calc(100vw - 96px));max-width:none;padding:42px 36px}
  .empty-icon{width:96px;height:96px;margin-bottom:18px}
  .empty-icon img{width:96px;height:96px}
  .empty-title{font-size:34px}
  .empty-tagline{font-size:14px}
  .empty-desc{margin:15px auto 28px;font-size:16px}
  .desktop-image-dropzone{display:flex;width:min(560px,100%);min-height:176px;box-sizing:border-box;flex-direction:column;align-items:center;justify-content:center;gap:7px;margin:0 auto 14px;padding:26px;border:1px solid rgba(0,0,0,.1);border-radius:var(--r-xl);background:rgba(255,255,255,.72);box-shadow:0 1px 2px rgba(0,0,0,.03),0 10px 32px rgba(0,0,0,.045);cursor:pointer;transition:border-color .18s,background .18s,box-shadow .18s,transform .18s}
  .desktop-image-dropzone:hover,.desktop-image-dropzone:focus-visible{border-color:rgba(0,102,204,.38);background:#fff;box-shadow:0 1px 2px rgba(0,0,0,.03),0 14px 38px rgba(0,0,0,.07),0 0 0 4px rgba(0,102,204,.08);outline:none;transform:translateY(-1px)}
  .desktop-drop-icon{display:grid;place-items:center;width:46px;height:46px;margin-bottom:3px;border-radius:50%;background:#1d1d1f;color:#fff;box-shadow:none}
  .desktop-drop-icon .icon{width:21px;height:21px}
  .desktop-image-dropzone strong{color:#1d1d1f;font-size:17px;font-weight:650;letter-spacing:0}
  .desktop-image-dropzone>span:not(.desktop-drop-icon){color:#6e6e73;font-size:13px}
  .desktop-image-dropzone small{color:#a1a1a6;font-size:11px}
  .empty-actions{display:flex;justify-content:center;gap:8px}
  .empty-actions .secondary-btn{min-width:126px}
  #emptyUploadBtn{display:none}
  .canvas-area.drag-over .desktop-image-dropzone{border-color:#06c;background:#fff;box-shadow:0 16px 44px rgba(0,0,0,.08),0 0 0 5px rgba(0,102,204,.1);transform:scale(1.008)}
  .canvas-area.drag-over .desktop-drop-icon{transform:scale(1.06)}
}
@media(max-height:700px) and (max-width:899px){
  .empty-state{padding-top:18px;padding-bottom:18px}
  .empty-icon{width:72px;height:72px;margin-bottom:9px}.empty-icon img{width:72px;height:72px}
  .empty-title{font-size:26px}.empty-tagline{margin-top:4px}.empty-desc{margin:9px auto 15px}
  .empty-meta{margin-top:12px}
}

.segmentation-modal{z-index:360}.segmentation-panel{width:min(760px,94vw);max-width:94vw;max-height:92vh}.segmentation-stage{margin:0 16px;background:#161616;border-radius:14px;overflow:auto;display:flex;align-items:center;justify-content:center;min-height:220px;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}.segmentation-stage canvas{display:block;max-width:none;max-height:none;touch-action:none;object-fit:contain;transform-origin:center center}.segmentation-status-row{display:flex;align-items:center;gap:8px;padding:8px 18px 2px}.segmentation-status{color:var(--t3);font-size:12px;line-height:1.4;flex:1;min-width:0}.segmentation-status[data-warning="true"]{color:#d97706}.segmentation-cancel{padding:6px 10px!important;min-height:34px!important;font-size:12px!important;white-space:nowrap}.segmentation-tools,.segmentation-actions{display:flex;align-items:center;gap:8px;padding:8px 16px;flex-wrap:wrap}.segmentation-tools .secondary-btn{padding:8px 14px;min-height:38px}.segmentation-tools .secondary-btn.is-active{background:var(--yellow-alpha);border-color:var(--yellow);color:var(--t);font-weight:600}.segmentation-tools .secondary-btn:disabled{opacity:.35;pointer-events:none}.segmentation-tools label{display:flex;align-items:center;gap:8px;color:var(--t2);font-size:13px;flex:1;min-width:150px}.segmentation-tools input{width:100%}.segmentation-actions{justify-content:flex-end;padding-bottom:calc(16px + var(--safe-b))}.segmentation-actions .primary-btn,.segmentation-actions .secondary-btn{padding:10px 18px;min-height:44px}@media(max-width:600px){.segmentation-modal{align-items:flex-end}.segmentation-panel{width:100%;max-width:100%;max-height:96vh;border-radius:20px 20px 0 0}.segmentation-stage{margin:0 10px;min-height:180px;max-height:48vh}.segmentation-tools{gap:6px;padding:6px 10px;overflow-x:auto;flex-wrap:nowrap}.segmentation-tools .secondary-btn{flex:0 0 auto;min-height:42px}.segmentation-tools label{flex:0 0 150px}.segmentation-actions{padding:6px 10px calc(10px + var(--safe-b))}.segmentation-actions>*{flex:1}}@media(orientation:landscape) and (max-height:600px){.segmentation-panel{max-height:100vh}.segmentation-stage{min-height:120px;max-height:42vh}.segmentation-panel .modal-head{padding-top:8px}.segmentation-status-row{padding-top:4px}.segmentation-tools{padding-top:4px;padding-bottom:4px}.segmentation-actions{padding-top:2px}}

/* 本地主体保留：将预览、说明和工具归入可收缩工作区，确认操作始终保留。 */
.segmentation-panel{height:min(760px,92dvh);max-height:92dvh;min-height:0;overflow:hidden}
.segmentation-panel .modal-head{flex:0 0 auto}
.segmentation-workarea{display:flex;flex:1 1 0;flex-direction:column;min-height:0;overflow:auto;overscroll-behavior:contain}
.segmentation-stage{flex:1 1 180px;min-height:120px;max-height:none}
.segmentation-actions{flex:0 0 auto;margin-top:0;border-top:.5px solid var(--apple-separator,var(--bd));background:var(--dialog-surface,var(--apple-surface,var(--white)))}

/* 主体分割弹窗：移动端 / 小平板接近全屏底部抽屉（对齐导入向导全屏阶段） */
@media (max-width:899px){
  .segmentation-modal{align-items:flex-end!important;justify-content:center;padding:0}
  .segmentation-panel{width:100%;max-width:100%;height:100dvh;max-height:100dvh;border-radius:0}
  .segmentation-stage{margin:0 10px;min-height:160px;max-height:46vh}
  .segmentation-actions{padding-bottom:calc(12px + var(--safe-b, env(safe-area-inset-bottom)))}
}

/* 画布 */
.canvas-wrapper{position:relative;touch-action:none;width:100%;height:100%;display:flex;align-items:center;justify-content:center;backface-visibility:hidden;transform:translateZ(0)}

/* 内部 canvasArea（由 enterEditor 设为 absolute 填满 wrapper） */
#canvasArea{backface-visibility:hidden;transform:translateZ(0)}

/* DOM 网格 — 替换 canvas 方案 */
.grid-wrapper{position:absolute;top:0;left:0;transform-origin:0 0;backface-visibility:hidden;pointer-events:none;transform:translateZ(0)}
.grid-wrapper .grid-container{pointer-events:auto;display:block;background:#fff;box-shadow:0 2px 12px rgba(0,0,0,0.08);overflow:hidden;position:absolute;backface-visibility:hidden;transform:translateZ(0);image-rendering:pixelated;image-rendering:crisp-edges}
/* 坐标覆盖层（在 Canvas 外部边缘，由 buildGridDOM 设置 absolute 定位） */
.grid-coord-area{pointer-events:none;z-index:4;transform:translateZ(0);backface-visibility:hidden;contain:layout style}
.grid-coord-area .coord-label{pointer-events:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.label-overlay{position:absolute;pointer-events:none;z-index:6;overflow:visible}
.label-overlay .cell-label{position:absolute;font-family:Consolas,monospace;font-weight:600;pointer-events:none;line-height:1;white-space:nowrap;display:none;transform:translate(-50%,-50%)}
.grid-wrapper.show-labels .label-overlay .cell-label{display:block}
/* 对比度自适应：浅底暗字 + 亮描边，深底亮字 + 暗描边 */
.cell-label.on-light{color:#222;text-shadow:0 0 1px rgba(255,255,255,0.85),0 0 2px rgba(255,255,255,0.7)}
.cell-label.on-dark{color:#FFF;text-shadow:0 0 1px rgba(0,0,0,0.7),0 0 2px rgba(0,0,0,0.5)}

.canvas-wrapper canvas{display:block;image-rendering:pixelated;background:#fff;box-shadow:0 2px 12px rgba(0,0,0,0.08);border-radius:var(--r-sm);transform-origin:0 0}
.zoom-badge{position:absolute;bottom:10px;right:10px;background:rgba(0,0,0,0.6);color:#fff;padding:3px 10px;border-radius:var(--r-full);font-size:12px;font-family:monospace;pointer-events:none;z-index:5}
#patternPreview{display:none;max-width:100%;max-height:100%;object-fit:contain;align-self:center;justify-self:center}
#resultCanvas{display:none}

/* 三策略结果选择 */
.strategy-chooser{position:fixed;inset:0;z-index:420;display:flex;align-items:flex-end;justify-content:center;padding:20px;background:rgba(0,0,0,.38);opacity:0;transition:opacity .2s ease;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}
.strategy-chooser.show{opacity:1}
.strategy-panel{width:min(1080px,100%);max-height:92vh;overflow:hidden;background:var(--bg);border-radius:24px;box-shadow:var(--shadow-xl);padding:18px;display:flex;flex-direction:column;gap:14px}
.strategy-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.strategy-head h2{font-size:21px;letter-spacing:-.4px}.strategy-head p{font-size:13px;color:var(--t3);margin-top:2px}
.strategy-close{width:34px;height:34px;border-radius:50%;background:var(--fill-secondary);color:var(--t2);font-size:24px;line-height:1}
.strategy-source{height:84px;display:flex;align-items:center;gap:12px;padding:8px;background:var(--white);border:1px solid var(--bd);border-radius:14px;color:var(--t3);font-size:12px}
.strategy-notice{margin:8px 0 0;padding:8px 10px;border-left:3px solid var(--yellow);background:var(--yellow-light);color:var(--t2);font-size:12px;line-height:1.5}
.strategy-source img{width:68px;height:68px;object-fit:cover;border-radius:9px;background:#fff}
.strategy-list{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;overflow:auto;padding:2px;scroll-snap-type:x mandatory}
.strategy-card{scroll-snap-align:center;min-width:0;padding:10px;background:var(--white);border:2px solid transparent;border-radius:16px;box-shadow:var(--shadow-sm);transition:border-color .15s,transform .15s;outline:none;cursor:pointer}
.strategy-card.selected,.strategy-card:focus-visible{border-color:var(--yellow)}
.strategy-card.selected{transform:translateY(-1px)}
.strategy-card-head{display:flex;justify-content:space-between;gap:8px;margin-bottom:8px}.strategy-card-head strong{display:block;font-size:15px}.strategy-card-head small{display:block;color:var(--t3);font-size:11px;margin-top:2px}.strategy-card-head>span{font:11px monospace;color:var(--t3)}
.strategy-card>img{width:100%;aspect-ratio:1;object-fit:contain;background:#fff;border-radius:10px;image-rendering:pixelated}
.strategy-card footer{display:grid;grid-template-columns:1fr 1fr;align-items:center;gap:6px;margin-top:8px;color:var(--t3);font-size:11px}
.strategy-actions{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-top:2px}
.strategy-actions>span{min-width:0;color:var(--t2);font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.strategy-confirm{flex:0 0 auto;min-width:180px;min-height:46px;padding:0 20px;border-radius:12px;background:var(--yellow);color:var(--t);font-size:14px;font-weight:750}
@media(max-width:700px){.strategy-chooser{padding:0;align-items:flex-end}.strategy-panel{width:100%;max-height:94vh;border-radius:24px 24px 0 0;padding:16px 12px calc(16px + var(--safe-b))}.strategy-source{height:70px}.strategy-source img{width:54px;height:54px}.strategy-list{display:flex;margin:0 -12px;padding:2px 12px 8px;gap:10px}.strategy-card{min-width:82vw;max-width:360px}.strategy-actions{position:sticky;bottom:0;margin:0 -12px -16px;padding:10px 12px calc(10px + var(--safe-b));background:var(--bg)}.strategy-actions>span{display:none}.strategy-confirm{width:100%;min-width:0}}

/* 空状态整体居中 */
.empty-state{display:flex;flex-direction:column;align-items:center;justify-content:center;flex:1;min-height:0;text-align:center;padding:24px;max-height:100%;overflow-y:auto}

/* ===== 颜色缩量面板（移动端大触控） ===== */

.float-row-denoise {
  flex-direction: column;
  padding: 4px 12px 8px;
  border-top: 0.5px solid var(--bd);
  gap: 6px;
}

/* 顶部行：色号 + 进度条 + 计数 */
.reduce-header {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.reduce-swatch {
  width: 18px; height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.3);
}
.reduce-code {
  font-size: 11px; font-weight: 700;
  font-family: Consolas, monospace;
  color: var(--t);
  flex-shrink: 0;
  min-width: 48px;
  line-height: 1;
}
.reduce-bar-bg {
  flex: 1; height: 8px;
  background: var(--fill-tertiary);
  border-radius: 4px;
  overflow: hidden;
  min-width: 40px;
}
.reduce-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--yellow);
  transition: width 0.08s ease;
}
.reduce-count {
  font-size: 11px; font-weight: 600;
  color: var(--t2);
  text-align: right;
  min-width: 40px;
  flex-shrink: 0;
  font-family: Consolas, monospace;
}

/* 底部行：步进按钮 + 大滑块 */
.reduce-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}
.reduce-slider {
  flex: 1;
  height: 44px;
  accent-color: var(--yellow);
  -webkit-appearance: none;
  appearance: none;
  background: var(--fill-tertiary);
  border-radius: 22px;
  cursor: pointer;
  margin: 0;
  outline: none;
}
.reduce-slider:disabled {
  opacity: 0.35;
  cursor: default;
}
.reduce-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--yellow);
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.1s;
}
.reduce-slider::-webkit-slider-thumb:active {
  transform: scale(1.15);
}
.reduce-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--yellow);
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  cursor: pointer;
}
.reduce-step {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--bd);
  background: var(--bg);
  color: var(--t2);
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
  line-height: 1;
  padding: 0;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.reduce-step:active {
  transform: scale(0.90);
  background: var(--yellow-light);
  border-color: var(--yellow);
}
.reduce-close {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--fill-tertiary);
  color: var(--t3);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
  padding: 0;
  opacity: 0.7;
}
.reduce-close:active {
  transform: scale(0.82);
  background: var(--fill-primary);
  opacity: 1;
}
@media(min-width:768px){
  .reduce-close:hover {
    opacity: 1;
    background: var(--fill-primary);
  }
}
.reduce-step:disabled {
  opacity: 0.3;
  cursor: default;
  transform: none;
}

/* 小屏适配 */
@media(max-width:480px){
  .float-row-denoise { padding: 3px 8px 6px; gap: 4px; }
  .reduce-step { width: 34px; height: 34px; font-size: 13px; }
  .reduce-slider { height: 40px; }
}
@media(max-width:380px){
  .reduce-swatch { width: 14px; height: 14px; }
  .reduce-code { font-size: 10px; min-width: 40px; }
  .reduce-count { font-size: 10px; min-width: 34px; }
  .reduce-step { width: 30px; height: 30px; font-size: 12px; }
  .reduce-slider { height: 36px; }
}
/* 桌面：保持标准尺寸 */
@media(min-width:768px){
  .float-row-denoise { padding: 4px 16px 8px; }
  .reduce-slider { height: 36px; }
  .reduce-step { width: 36px; height: 36px; }
}


/* 浮动胶囊容器 — fixed 底部居中 */
.bottom-area{position:fixed;bottom:12px;left:50%;transform:translateX(-50%);z-index:100;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none}
.bottom-area > * { pointer-events: auto; }

/* 主胶囊 — 两行自适应高度 */
.float-capsule{display:flex;flex-direction:column;gap:3px;padding:4px 3px;background:rgba(255,255,255,0.88);backdrop-filter:blur(24px) saturate(180%);-webkit-backdrop-filter:blur(24px) saturate(180%);border-radius:22px;border:0.5px solid rgba(0,0,0,0.06);box-shadow:0 4px 16px rgba(0,0,0,0.08),0 1px 4px rgba(0,0,0,0.04),0 0 0 0.5px rgba(0,0,0,0.03);max-width:calc(100vw - 24px)}

/* 每一行：横向排列左/中/右 */
.float-row{display:flex;align-items:center;gap:2px;min-height:38px}

/* 左侧：统计 + 颜色指示 */
.float-left{display:flex;align-items:center;gap:4px;flex-shrink:0;padding-left:3px}
.float-stat{display:inline-flex;align-items:center;gap:3px;padding:4px 10px;font-size:12px;font-weight:600;color:var(--t);border-radius:var(--r-full);background:transparent;cursor:pointer;transition:transform .12s ease,background-color .2s ease,border-color .2s ease,color .2s ease;border:none;white-space:nowrap;min-height:36px;flex-shrink:0;line-height:1}
.float-stat:active{transform:scale(0.94);background:var(--fill-tertiary)}
.float-stat i{font-size:14px;display:flex}
.float-dot{margin:0 2px;color:var(--t3)}

/* 颜色指示器（整合到胶囊左侧） */
.float-sci{display:inline-flex;align-items:center;gap:3px;padding:2px 7px 2px 3px;background:var(--fill-tertiary);border-radius:var(--r-full);flex-shrink:0;cursor:pointer;transition:transform .12s ease,background-color .2s ease,border-color .2s ease,color .2s ease;font-size:10px;font-weight:600;line-height:1}
.float-sci:active{transform:scale(0.94)}
.float-sci .sci-swatch{width:16px;height:16px;border-radius:50%;border:1px solid rgba(0,0,0,0.08);flex-shrink:0;box-shadow:inset 0 0 0 1px rgba(255,255,255,0.4)}
.float-sci .sci-code{font-family:Consolas,monospace;color:var(--t2);font-size:10px;font-weight:700}
.float-sci-empty{font-size:10px;color:var(--t3);white-space:nowrap;padding:0 4px;flex-shrink:0;font-weight:500}

/* 中间：工具滚动区 */
.float-tools{display:flex;align-items:center;gap:2px;overflow-x:auto;flex:1;min-width:0;padding:0 2px;scrollbar-width:none;-ms-overflow-style:none}
.float-tools::-webkit-scrollbar{display:none}
.float-divider{width:1px;height:20px;background:var(--bd);flex-shrink:0;margin:0 2px}

/* 工具按钮 — 图标+标签横向药丸形 */
.float-btn{display:inline-flex;align-items:center;gap:5px;padding:0 12px;height:36px;border-radius:999px;font-size:12px;font-weight:550;color:var(--t2);background:transparent;cursor:pointer;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;border:none;flex-shrink:0;white-space:nowrap}
.float-btn i{font-size:16px;display:flex;flex-shrink:0}
.float-label{font-size:12px;font-weight:550;letter-spacing:-0.01em}
.float-btn:active{transform:scale(0.92);background:var(--fill-tertiary)}
.float-btn.active{background:var(--yellow);color:var(--t);box-shadow:0 1px 4px rgba(255,212,59,0.25)}
.float-btn.disabled{opacity:0.3;pointer-events:none;cursor:default}
.tool-size-badge{display:inline-flex;align-items:center;justify-content:center;min-width:17px;height:17px;padding:0 4px;border:1px solid var(--bd);border-radius:5px;background:var(--fill-secondary);color:var(--t2);font-size:10px;font-weight:700;line-height:1;font-variant-numeric:tabular-nums}
.float-btn.active .tool-size-badge{border-color:rgba(90,66,0,0.22);background:rgba(255,255,255,0.68);color:#5a4200}

/* 纯图标按钮（搜索、下载、撤销/重做）保持圆形 */
.float-btn.icon-only{width:36px;height:36px;border-radius:50%;padding:0;justify-content:center}
.float-btn.icon-only i{font-size:17px}
.float-btn.icon-only .float-label{display:none}

/* 右侧：生成 + 设置 */
.float-right{display:flex;align-items:center;gap:2px;flex-shrink:0;padding-right:3px}
.float-play{width:38px;height:38px;border-radius:50%;padding:0;justify-content:center;background:var(--yellow) !important;color:var(--t) !important;font-size:20px;box-shadow:var(--shadow-sm)}
.float-play i{font-size:20px}
.float-play:active{transform:scale(0.88) !important;background:var(--yellow-d) !important}
.float-play:disabled{opacity:0.3;transform:none !important;box-shadow:none;cursor:not-allowed}
.float-set{width:36px;height:36px;font-size:17px;color:var(--t3)}
.float-set i{font-size:17px}

/* 色卡浮动面板 (③整合) */
.float-color-wrap{position:absolute;bottom:calc(100% + 8px);left:50%;transform:translateX(-50%);background:rgba(255,255,255,0.95);backdrop-filter:blur(24px) saturate(180%);-webkit-backdrop-filter:blur(24px) saturate(180%);border-radius:var(--r-xl);border:0.5px solid rgba(0,0,0,0.06);box-shadow:0 8px 32px rgba(0,0,0,0.1),0 2px 8px rgba(0,0,0,0.04);padding:8px 10px;max-height:260px;overflow-y:auto;min-width:200px;max-width:min(90vw,400px);transform-origin:bottom center;animation:floatUp 0.2s var(--ease-out)}
.float-color-wrap::-webkit-scrollbar{width:3px}
.float-color-wrap::-webkit-scrollbar-thumb{background:var(--bd);border-radius:2px}
.float-color-inner{width:100%}
.float-color-wrap .color-strip{display:flex;flex-wrap:wrap;gap:4px;padding:2px 0;justify-content:center}
.float-color-wrap .swatch-item{width:34px;height:43px;border-radius:7px;cursor:pointer;border:2px solid transparent;transition:transform .1s,border-color .1s,box-shadow .1s;flex-shrink:0;position:relative;overflow:hidden;backface-visibility:hidden}
.float-color-wrap .swatch-item:active{transform:scale(0.94)}
.float-color-wrap .swatch-item.active{border-color:#b78300 !important;box-shadow:0 0 0 2px var(--yellow),0 2px 6px rgba(0,0,0,.18) !important;transform:translateY(-1px)}
.float-color-wrap .swatch-label{position:absolute;inset:auto 0 0;height:15px;display:flex;align-items:center;justify-content:center;padding:0 1px;background:rgba(255,255,255,.94);color:#171717!important;font-family:Consolas,"SFMono-Regular",monospace;font-size:10px;font-weight:700;letter-spacing:-.25px;text-shadow:none;pointer-events:none;line-height:15px;opacity:1;border-top:1px solid rgba(0,0,0,.12);white-space:nowrap}
.float-color-wrap .swatch-item.active .swatch-label{opacity:1;background:#fff8d6}
.float-color-wrap .color-strip-search{padding:5px 0 0}
.float-color-wrap .color-strip-input{width:100%;padding:6px 10px;border:1px solid var(--bd);border-radius:var(--r-sm);font-size:11px;outline:none;background:var(--bg);transition:border-color 0.15s;color:var(--t)}
.float-color-wrap .color-strip-input:focus{border-color:var(--yellow)}
.float-color-wrap .color-strip-input::placeholder{color:var(--t3)}

/* ===== 系列 Tab 筛选栏 ===== */
.series-tabs{display:flex;gap:4px;padding:2px 0 6px;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none;flex-shrink:0;width:100%}
.series-tabs::-webkit-scrollbar{display:none}
.series-tab{flex-shrink:0;padding:3px 10px;font-size:11px;font-weight:600;color:var(--t2);background:var(--fill-tertiary);border-radius:999px;cursor:pointer;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;border:none;line-height:1.4;white-space:nowrap;-webkit-user-select:none;user-select:none}
.series-tab:active{transform:scale(0.94)}
.series-tab.active{background:var(--yellow);color:var(--t);box-shadow:0 1px 4px rgba(255,212,59,0.3)}
.series-tab-body{display:flex;flex-wrap:wrap;gap:3px;padding:2px 2px 6px;width:100%}

/* 底部色卡内的颜色块尺寸 */
.series-tab-body .swatch-item{width:34px;height:43px;border-radius:7px}

/* 全局色卡 */
.swatch-item{width:32px;height:32px;border-radius:7px;cursor:pointer;border:2px solid transparent;transition:transform .12s var(--ease-spring),background-color .2s ease,border-color .2s ease,color .2s ease,box-shadow .2s ease;flex-shrink:0;position:relative;backface-visibility:hidden}
.swatch-item:active{transform:scale(0.88)}
.swatch-item.active{border-color:var(--yellow) !important;box-shadow:0 0 0 2px var(--yellow),0 2px 8px rgba(255,212,59,0.35) !important;transform:scale(1.1)}
.swatch-label{position:absolute;bottom:1px;left:2px;font-size:5px;font-weight:700;text-shadow:0 0 2px rgba(255,255,255,0.8);pointer-events:none;line-height:1;opacity:0.4}
.swatch-item.active .swatch-label{opacity:1}

/* 信息详情（隐藏，仅JS使用） */
.info-bar-meta{display:none}

@keyframes floatUp{from{opacity:0;transform:translateX(-50%) translateY(8px) scale(0.96)}to{opacity:1;transform:translateX(-50%) translateY(0) scale(1)}}

/* Dark mode 适配 */
@media (prefers-color-scheme: dark) {
  .float-capsule{background:rgba(44,44,46,0.92);border-color:rgba(255,255,255,0.08)}
  .float-color-wrap{background:rgba(44,44,46,0.95);border-color:rgba(255,255,255,0.08)}
}

/* ===== 遮罩 — iOS 毛玻璃 ===== */
.overlay{position:fixed;inset:0;background:rgba(0,0,0,0.2);z-index:150;visibility:hidden;transition:visibility 0s 0.3s;contain:paint;transform:translateZ(0)}
.overlay.show{visibility:visible;transition:visibility 0s}

/* ===== 底部抽屉 — iOS 风格 ===== */
.drawer{position:fixed;bottom:0;left:0;right:0;background:var(--white);border-radius:var(--r-xl) var(--r-xl) 0 0;padding:8px 20px calc(16px + var(--safe-b));z-index:200;transform:translateY(100%) translateZ(0);transition:transform 0.42s cubic-bezier(0.32,0.72,0,1);max-height:65vh;overflow-y:auto;box-shadow:var(--shadow-xl)}
.drawer.show{transform:translateY(0) translateZ(0)}
.drawer-handle{width:36px;height:4px;background:var(--t4);border-radius:2px;margin:0 auto 14px}
.drawer-title{font-size:16px;font-weight:700;text-align:center;margin-bottom:14px;color:var(--t);letter-spacing:-0.2px}
.drawer-title>span{display:inline-flex;align-items:center;gap:6px}
.color-picker-close{display:none}
.drawer-search{padding:0 0 10px}
.drawer-search input{width:100%;padding:10px 14px;border:1px solid var(--bd);border-radius:var(--r-md);font-size:15px;outline:none;background:var(--bg);transition: transform 0.15s var(--ease-out), opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;color:var(--t)}
.drawer-search input:focus{border-color:var(--yellow);box-shadow:0 0 0 3px var(--yellow-alpha)}
.drawer-grid{display:flex;flex-wrap:wrap;gap:4px;justify-content:center;padding:2px 0}
/* The category tabs and colour cells are rendered as separate children. Keep the
   swatch container self-sizing on every viewport, not only tablet overrides. */
.picker-color-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(34px,1fr));align-content:start;width:100%;gap:4px}
.color-picker-item{width:auto;height:34px;min-width:34px;border-radius:7px;cursor:pointer;border:2px solid transparent;transition:transform 0.12s var(--ease-spring),border-color 0.12s var(--ease-spring),box-shadow 0.12s var(--ease-spring);flex-shrink:0;position:relative;backface-visibility:hidden}
.color-picker-item:active{transform:scale(0.88)}
.color-picker-item.selected{border-color:var(--yellow) !important;box-shadow:0 0 0 2px var(--yellow),0 2px 8px rgba(255,212,59,0.35) !important;transform:scale(1.1)}
.color-picker-label{position:absolute;bottom:1px;left:2px;font-size:5px;font-weight:700;text-shadow:0 0 2px rgba(255,255,255,0.8);pointer-events:none;line-height:1;opacity:0.6}
.color-picker-item.selected .color-picker-label{opacity:1}
.drawer-close{display:block;width:100%;padding:14px;margin-top:12px;color:var(--t2);font-size:16px;font-weight:500;cursor:pointer;border-top:0.5px solid var(--bd);text-align:center;transition: transform 0.15s var(--ease-out), opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;min-height:44px;border-radius:0;background:transparent}
.drawer-close:active{background:var(--bg);transform:scale(0.97)}

/* ===== 居中弹窗 — iOS 风格 ===== */
.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,0.25);display:flex;align-items:center;justify-content:center;z-index:300;visibility:hidden;opacity:0;transition:opacity .16s linear,visibility 0s .16s;contain:strict;transform:translateZ(0)}
.modal-overlay.show{visibility:visible;opacity:1;transition:opacity .16s linear,visibility 0s}
.modal-panel{background:var(--white);border-radius:var(--r-xl);width:380px;max-width:86vw;max-height:60vh;display:flex;flex-direction:column;box-shadow:var(--shadow-xl);transform:scale(.96) translateZ(0);opacity:0;transition:transform .2s var(--ease-out),opacity .14s linear;backface-visibility:hidden}
.modal-overlay.show .modal-panel{transform:scale(1) translateZ(0);opacity:1}
.modal-head{display:flex;align-items:center;justify-content:space-between;padding:16px 20px 10px;font-size:16px;font-weight:600;color:var(--t)}
.modal-x{width:28px;height:28px;display:flex;align-items:center;justify-content:center;font-size:22px;color:var(--t3);border-radius:50%;transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;background:transparent;border:none;cursor:pointer;backface-visibility:hidden}
.modal-x:active{background:var(--fill-tertiary);transform:scale(0.9)}
.modal-body{padding:2px 18px 16px;overflow-y:auto;max-height:45vh}
.modal-body::-webkit-scrollbar{width:3px}
.modal-body::-webkit-scrollbar-thumb{background:var(--bd);border-radius:2px}
.modal-footer{padding:0 20px 20px;flex-shrink:0}

/* ===== 底部 Action Sheet — iOS 风格 ===== */
.sheet-overlay{position:fixed;inset:0;z-index:300;background:rgba(0,0,0,0.25);display:flex;align-items:flex-end;justify-content:center;visibility:hidden;opacity:0;transition:opacity .16s linear,visibility 0s .2s;contain:paint;transform:translateZ(0)}
.sheet-overlay.show{visibility:visible;opacity:1;transition:opacity .16s linear,visibility 0s}
.sheet-panel{background:var(--white);border-radius:var(--r-xl) var(--r-xl) 0 0;width:100%;max-width:500px;padding:8px 20px calc(16px + var(--safe-b));box-shadow:var(--shadow-xl);transform:translate3d(0,24px,0);opacity:0;transition:transform .22s var(--ease-out),opacity .14s linear;max-height:75vh;overflow-y:auto;backface-visibility:hidden}
.sheet-overlay.show .sheet-panel{transform:translate3d(0,0,0);opacity:1}
.sheet-overlay.closing{opacity:0;pointer-events:none}
.sheet-overlay.closing .sheet-panel{transform:translate3d(0,24px,0);opacity:0;animation:none}
/* 进场动画已改用 transition（见 .sheet-overlay.show .sheet-panel），keyframe 不再需要 */
.sheet-panel::-webkit-scrollbar{width:3px}
.sheet-panel::-webkit-scrollbar-thumb{background:var(--bd);border-radius:2px}
.sheet-handle{width:36px;height:4px;background:var(--t4);border-radius:2px;margin:0 auto 14px}
.sheet-title{font-size:16px;font-weight:700;text-align:center;margin-bottom:14px;color:var(--t)}
.sheet-title i{font-size:18px;vertical-align:middle;margin-right:4px}
.sheet-btn{display:block;width:100%;padding:14px 12px;margin-bottom:8px;border-radius:var(--r-md);font-size:15px;font-weight:500;cursor:pointer;min-height:44px;text-align:center;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;border:none;backface-visibility:hidden}
.sheet-btn i{font-size:16px;vertical-align:middle;margin-right:4px}
.sheet-btn:active{transform:scale(0.98)}
.sheet-cancel{display:block;width:100%;padding:14px;margin-top:4px;border-top:0.5px solid var(--bd);border-radius:0;background:transparent;color:var(--t2);font-size:15px;font-weight:500;cursor:pointer;text-align:center;min-height:44px;transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease}
.sheet-cancel:active{background:var(--fill-tertiary)}

/* ===== 导出设置卡片 — iOS Settings 风格 ===== */
.export-settings-panel{display:flex;flex-direction:column;overflow:hidden}
.export-settings-title{position:relative;flex:0 0 auto}
.export-settings-title>span{display:block;width:100%;text-align:center}
.export-settings-close{display:none;position:absolute;right:14px;top:50%;align-items:center;justify-content:center;width:32px;height:32px;padding:0;border:1px solid var(--bd);border-radius:50%;background:var(--fill-secondary);color:var(--t2);cursor:pointer;transform:translateY(-50%);transition:background .15s,color .15s,transform .15s}
.export-settings-close .icon{width:16px;height:16px}
.export-settings-close:hover{background:var(--fill-tertiary);color:var(--t)}
.export-settings-close:active{transform:translateY(-50%) scale(.94)}
.export-settings-scroll{min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:0 2px;scrollbar-width:auto;scrollbar-color:#7c828c #e5e7eb}
.export-settings-scroll::-webkit-scrollbar{width:10px}
.export-settings-scroll::-webkit-scrollbar-track{background:#e5e7eb;border-radius:999px}
.export-settings-scroll::-webkit-scrollbar-thumb{background:#7c828c;border:2px solid #e5e7eb;border-radius:999px}
.export-settings-scroll::-webkit-scrollbar-thumb:hover{background:#555b65}
.export-settings-panel>.export-btn-row{flex:0 0 auto}
.export-project-btn{display:flex;flex:0 0 auto;align-items:center;justify-content:center;gap:10px;width:100%;min-height:52px;margin-top:8px;padding:9px 14px;border:1px solid var(--bd);border-radius:var(--r-md);background:var(--white);color:var(--t);cursor:pointer;text-align:left;transition:background .12s,transform .12s,border-color .12s}
.export-project-btn>.icon{flex:0 0 auto;width:20px;height:20px;color:var(--blue)}
.export-project-btn>span{display:flex;min-width:0;flex-direction:column;gap:2px}
.export-project-btn strong{font-size:14px;font-weight:650;line-height:1.2}
.export-project-btn small{font-size:11px;line-height:1.25;color:var(--t3)}
.export-project-btn:active{background:var(--fill-tertiary);border-color:var(--blue);transform:scale(.985)}
.export-toggle{display:flex;align-items:center;justify-content:space-between;padding:12px 14px;margin-bottom:8px;border:0.5px solid var(--bd);border-radius:var(--r-md);cursor:pointer;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;-webkit-user-select:none;user-select:none;min-height:52px;backface-visibility:hidden;background:var(--white)}
.export-toggle:active{transform:scale(0.98);background:var(--fill-tertiary)}
.export-toggle.on{border-color:var(--yellow);background:var(--yellow-light)}
.export-toggle-l{flex:1;min-width:0}
.export-toggle-name{font-size:14px;font-weight:600;color:var(--t)}
.export-toggle-desc{font-size:11px;color:var(--t3);margin-top:2px;line-height:1.4}
.export-toggle-r{flex-shrink:0;margin-left:12px;font-size:11px;font-weight:600;padding:3px 10px;border-radius:var(--r-full);transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease}
.export-toggle.on .export-toggle-r{background:var(--yellow);color:#5a4200}
.export-toggle:not(.on) .export-toggle-r{background:var(--fill-tertiary);color:var(--t3)}
/* 字体选项卡片 */
.export-fsize-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:8px 0 16px}
.export-fopt{border:0.5px solid var(--bd);border-radius:var(--r-md);padding:10px 12px;cursor:pointer;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;text-align:left;backface-visibility:hidden;background:var(--white)}
.export-fopt:active{transform:scale(0.97);background:var(--fill-tertiary)}
.export-fopt.on{border-color:var(--yellow);background:var(--yellow-light)}
.export-fopt-name{font-size:14px;font-weight:600;color:var(--t)}
.export-fopt-desc{font-size:11px;color:var(--t3);margin-top:1px}
.export-fw-grid{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px;margin:8px 0 16px}
.export-section-title{font-size:12px;font-weight:600;color:var(--t2);text-transform:uppercase;letter-spacing:0.5px;margin:16px 0 8px}
.export-guide{font-size:12px;color:var(--t3);text-align:center;margin:0 0 12px}
/* Custom export title */
.export-title-field{display:flex;flex-direction:column;gap:6px;margin:0 0 14px;padding:12px 14px;border:.5px solid var(--bd);border-radius:var(--r-md);background:var(--white)}
.export-title-label{font-size:13px;font-weight:650;color:var(--t)}
.export-title-input{box-sizing:border-box;width:100%;min-height:42px;padding:9px 11px;border:.5px solid var(--bd);border-radius:9px;background:var(--fill-primary);color:var(--t);font:inherit;font-size:14px;outline:none;transition:border-color .15s,box-shadow .15s,background .15s}
.export-title-input:focus{border-color:var(--apple-blue,var(--yellow));background:var(--white);box-shadow:0 0 0 3px color-mix(in srgb,var(--apple-blue,var(--yellow)) 12%,transparent)}
.export-title-input::placeholder{color:var(--t3)}
.export-title-hint{font-size:11px;line-height:1.4;color:var(--t3)}

/* 下载/预览按钮组 */
.export-btn-row{display:flex;gap:10px;margin-top:8px}
.export-btn-row .export-btn{flex:1;padding:14px;font-size:15px;font-weight:600;border-radius:var(--r-md);cursor:pointer;min-height:44px;text-align:center;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;border:none}
.export-btn-row .export-btn:active{transform:scale(0.98)}
.export-preview-btn{background:var(--white);color:var(--t2);border:1.5px solid var(--bd)!important}
.export-preview-btn:active{background:var(--fill-tertiary)}
.export-download-btn{background:var(--yellow);color:#5a4200;font-weight:700}
.export-download-btn:active{background:var(--yellow-d)}

/* 导出预览弹窗 */
.export-preview-overlay{position:fixed;inset:0;z-index:400;background:rgba(0,0,0,0.85);display:flex;flex-direction:column;align-items:center;justify-content:center;visibility:hidden;transition:visibility 0s 0.25s;contain:paint;transform:translateZ(0);padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)}
.export-preview-overlay.show{visibility:visible;transition:visibility 0s}
.export-preview-overlay.closing{visibility:hidden;transition:visibility 0s 0.15s}
.export-preview-img-wrap{flex:1;overflow:auto;width:100%;-webkit-overflow-scrolling:touch;position:relative;user-select:none;-webkit-user-select:none}
.export-preview-img-wrap img{display:block;border-radius:var(--r-sm);box-shadow:0 4px 40px rgba(0,0,0,0.4);pointer-events:none}
.export-preview-zoom-badge{position:absolute;bottom:12px;right:12px;background:rgba(0,0,0,0.55);backdrop-filter:blur(10px);color:#fff;padding:4px 10px;border-radius:var(--r-full);font-size:11px;font-family:monospace;pointer-events:none;z-index:1}
.export-preview-bar{display:flex;gap:12px;padding:12px 16px calc(12px + var(--safe-b));width:100%;max-width:500px;flex-shrink:0}
.export-preview-bar .ep-btn{flex:1;padding:14px;font-size:16px;font-weight:600;border-radius:var(--r-md);cursor:pointer;text-align:center;min-height:48px;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;border:none}
.export-preview-bar .ep-btn:active{transform:scale(0.97)}
.ep-btn-back{background:rgba(255,255,255,0.12);color:#fff;backdrop-filter:blur(10px)}
.ep-btn-back:active{background:rgba(255,255,255,0.2)}
.ep-btn-download{background:var(--yellow);color:#5a4200;font-weight:700}
.ep-btn-download:active{background:var(--yellow-d)}

/* ===== 3D 预览弹窗 ===== */
.preview-3d-overlay{position:fixed;inset:0;z-index:410;background:#242422;display:flex;flex-direction:column;visibility:hidden;transition:visibility 0s 0.25s;contain:paint;transform:translateZ(0)}
.preview-3d-overlay.show{visibility:visible;transition:visibility 0s}
.preview-3d-overlay.closing{visibility:hidden;transition:visibility 0s 0.15s}
.preview-3d-container{flex:1;overflow:hidden;position:relative;cursor:grab;touch-action:none}
.preview-3d-container:active{cursor:grabbing}
.preview-3d-container canvas{display:block;width:100%;height:100%}
.preview-3d-bar{display:flex;align-items:center;gap:12px;padding:12px 16px calc(12px + var(--safe-b));width:100%;max-width:500px;margin:0 auto;flex-shrink:0}
.preview-3d-bar .ep-btn{flex:0 1 auto;padding:10px 18px;font-size:14px;font-weight:600;border-radius:var(--r-md);cursor:pointer;text-align:center;min-height:44px;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;border:none;white-space:nowrap}
.preview-3d-bar .ep-btn:active{transform:scale(0.97)}
.preview-3d-controls{flex:1;text-align:center}
.preview-3d-tip{font-size:12px;color:rgba(255,255,255,0.4);user-select:none}
.preview-3d-toggle{padding:10px 18px;font-size:13px;font-weight:600;border-radius:var(--r-md);cursor:pointer;min-height:44px;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;background:rgba(255,255,255,0.1);color:#fff;border:1px solid rgba(255,255,255,0.15);white-space:nowrap}
.preview-3d-toggle:active{transform:scale(0.97);background:rgba(255,255,255,0.2)}

/* 分辨率选择 */
.export-res-grid{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px;margin:0 0 8px}
.export-res-opt{border:0.5px solid var(--bd);border-radius:var(--r-md);padding:12px 8px;cursor:pointer;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;text-align:center;backface-visibility:hidden;background:var(--white)}
.export-res-opt:active{transform:scale(0.97);background:var(--fill-tertiary)}
.export-res-opt.on{border-color:var(--yellow);background:var(--yellow-light)}
.export-res-name{font-size:18px;font-weight:700;color:var(--t)}
.export-res-desc{font-size:11px;color:var(--t3);margin-top:1px}

/* 更多设置折叠 */
.export-more-toggle{display:flex;align-items:center;justify-content:space-between;padding:10px 6px;margin:8px 0;cursor:pointer;font-size:13px;font-weight:500;color:var(--t2);border-bottom:0.5px solid var(--bd);-webkit-user-select:none;user-select:none;transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease}
.export-more-toggle:active{background:var(--fill-tertiary);border-radius:var(--r-sm)}
.export-more-arrow{font-size:11px;transition:transform 0.2s;color:var(--t3)}
.export-more-toggle.open .export-more-arrow{transform:rotate(180deg)}
.export-more-body{margin-bottom:8px}

/* ===== 色系标签（OhMyBead 风格色卡编码） ===== */
.series-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--t2);
  padding: 6px 2px 2px;
  letter-spacing: 0.3px;
  width: 100%;
  border-bottom: 0.5px solid var(--bd);
  margin-bottom: 2px;
}

/* ===== 图层面板 ===== */
.layer-panel-overlay {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(320px, 85vw);
  z-index: 180;
  display: flex;
  flex-direction: column;
  background: var(--white);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.35s var(--ease-spring);
  will-change: transform;
  padding: 20px 0 calc(16px + var(--safe-b));
}
.layer-panel-overlay.show {
  transform: translateX(0);
}
.layer-panel {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.layer-panel::-webkit-scrollbar {
  width: 3px;
}
.layer-panel::-webkit-scrollbar-thumb {
  background: var(--bd);
  border-radius: 2px;
}
.layer-close-btn {
  width:28px;height:28px;display:flex;align-items:center;justify-content:center;
  font-size:16px;color:var(--t3);border-radius:50%;transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
  background:transparent;border:none;cursor:pointer;flex-shrink:0;margin-left:auto;
}
.layer-close-btn:active{background:var(--fill-tertiary);transform:scale(0.9)}
.layer-panel-head {
  display:flex;align-items:center;gap:8px;padding:8px 12px;
  font-size:15px;font-weight:700;border-bottom:0.5px solid var(--bd);flex-shrink:0;
}
.layer-list {
  flex: 1;
  min-height: 100px;
  overflow-y: auto;
  padding: 4px 8px;
}
.layer-item {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 5px 6px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
  margin-bottom: 2px;
  background: var(--bg);
  border: 1px solid transparent;
}
.layer-item:active {
  transform: scale(0.98);
}
.layer-item.active {
  border-color: var(--yellow);
  background: var(--yellow-light);
}
.layer-item .layer-vis-btn,
.layer-item .layer-lock-btn {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
}
.layer-item .layer-vis-btn:active,
.layer-item .layer-lock-btn:active {
  background: var(--fill-tertiary);
}
.layer-item .layer-name {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 2px;
}
/* 透明度滑块：极简模式 */
.layer-item .layer-opacity {
  width: 32px;
  height: 12px;
  cursor: pointer;
  flex-shrink: 0;
}
.layer-item .layer-op-val {
  font-size: 8px;
  color: var(--t3);
  width: 22px;
  text-align: right;
  flex-shrink: 0;
}
.layer-item .layer-act-btn {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  color: var(--t3);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  flex-shrink: 0;
}
.layer-item .layer-act-btn:active {
  background: var(--fill-tertiary);
}
.layer-item .layer-act-btn.layer-del-btn {
  color: #FF3B30;
}
.layer-actions {
  padding-top: 8px;
  border-top: 0.5px solid var(--bd);
}
.layer-add-btn {
  width: 100%;
  padding: 10px;
  background: var(--yellow);
  color: var(--t);
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
}
.layer-add-btn:active {
  transform: scale(0.97);
  background: var(--yellow-d);
}

/* ===== 可视化颜色选择器 (HSV Picker) ===== */
.cp-picker-panel { padding-bottom: calc(12px + var(--safe-b)); }
.cp-picker-panel .sheet-handle { margin-bottom: 8px; }
.cp-sv-wrap { margin: 0 auto 10px; text-align: center; border-radius: var(--r-sm); overflow: hidden; box-shadow: 0 0 0 1px rgba(0,0,0,0.06); }
.cp-sv-canvas { display: block; width: 100%; max-width: 280px; height: auto; aspect-ratio: 240/180; cursor: crosshair; touch-action: none; }
.cp-hue-wrap { margin: 0 auto 12px; text-align: center; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 1px rgba(0,0,0,0.06); }
.cp-hue-canvas { display: block; width: 100%; max-width: 280px; height: 20px; cursor: pointer; touch-action: none; }
.cp-info-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding: 0 4px; }
.cp-preview { width: 44px; height: 44px; border-radius: var(--r-sm); border: 1px solid var(--bd); flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.3); }
.cp-values { flex: 1; min-width: 0; }
.cp-value-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.cp-value-row:last-child { margin-bottom: 0; }
.cp-val-lbl { font-size: 10px; font-weight: 600; color: var(--t3); width: 28px; flex-shrink: 0; }
.cp-hex-input { flex: 1; padding: 6px 8px; border: 1px solid var(--bd); border-radius: var(--r-sm); font-size: 13px; font-family: 'SF Mono', Consolas, monospace; outline: none; background: var(--bg); color: var(--t); transition: border-color 0.15s; }
.cp-hex-input:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-alpha); }
.cp-rgb-text { font-size: 11px; color: var(--t2); font-family: 'SF Mono', Consolas, monospace; }
.cp-actions { display: flex; gap: 8px; }
.cp-btn { flex: 1; padding: 12px; border-radius: var(--r-md); font-size: 14px; font-weight: 600; text-align: center; cursor: pointer; transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease; min-height: 44px; border: none; }
.cp-btn:active { transform: scale(0.97); }
.cp-btn-cancel { background: var(--fill-tertiary); color: var(--t2); }
.cp-btn-cancel:active { background: var(--fill-primary); }
.cp-btn-confirm { background: var(--yellow); color: var(--t); }
.cp-btn-confirm:active { background: var(--yellow-d); }
@media (prefers-color-scheme: dark) {
  .cp-sv-wrap, .cp-hue-wrap { box-shadow: 0 0 0 1px rgba(255,255,255,0.08); }
}

/* 取色器按钮（在自定义颜色面板中） */
.cp-open-picker-btn { display: flex; align-items: center; justify-content: center; gap: 4px; width: 100%; padding: 8px; border: 1.5px dashed var(--bd); border-radius: var(--r-sm); background: transparent; color: var(--t2); font-size: 12px; font-weight: 500; cursor: pointer; transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease; margin-bottom: 6px; }
.cp-open-picker-btn:active { background: var(--fill-tertiary); border-color: var(--t3); transform: scale(0.98); }



/* 表单 — iOS 风格 */
.fld{margin-bottom:12px}
.fld-lbl{font-size:13px;font-weight:500;color:var(--t2);margin-bottom:4px;display:block}
.fld-sel{width:100%;padding:10px 12px;border:0.5px solid var(--bd);border-radius:var(--r-md);font-size:14px;outline:none;background:var(--white);color:var(--t);cursor:pointer;-webkit-appearance:auto;appearance:auto;transition: transform 0.15s var(--ease-out), opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease}
.fld-sel:focus{border-color:var(--yellow);box-shadow:0 0 0 3px var(--yellow-alpha)}
.fld-inp{width:100%;padding:10px 12px;border:0.5px solid var(--bd);border-radius:var(--r-md);font-size:14px;outline:none;background:var(--white);color:var(--t);transition: transform 0.15s var(--ease-out), opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease}
.fld-inp:focus{border-color:var(--yellow);box-shadow:0 0 0 3px var(--yellow-alpha)}
.fld-row{display:flex;align-items:center;gap:8px}
.fld-row input[type="range"]{-webkit-appearance:none;appearance:none;flex:1;height:4px;background:var(--bd);border-radius:2px;outline:none;cursor:pointer}
.fld-row input[type="range"]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:22px;height:22px;border-radius:50%;background:var(--white);border:0.5px solid var(--bd);box-shadow:var(--shadow-sm);cursor:pointer;transition:transform 0.12s}
.fld-row input[type="range"]::-webkit-slider-thumb:active{transform:scale(1.15)}
.fld-val{font-size:13px;color:var(--t2);min-width:36px;text-align:right;font-weight:600}
.fld-hint{display:block;font-size:11px;color:var(--t3);margin-top:3px;line-height:1.4}

/* 生成风格分段控件（对齐参考项目：卡通/写实二选一） */
.style-seg{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.engine-seg{grid-template-columns:repeat(2,minmax(0,1fr))}
.style-seg-item{position:relative;display:flex;cursor:pointer}
.style-seg-item input{position:absolute;opacity:0;pointer-events:none}
.style-seg-item>span{display:flex;flex-direction:column;gap:2px;width:100%;min-height:52px;justify-content:center;padding:9px 12px;border-radius:10px;background:var(--fill-tertiary);transition:background-color .16s,box-shadow .16s}
.style-seg-item>span strong{font-size:14px;font-weight:600;color:var(--t)}
.style-seg-item>span small{font-size:11px;color:var(--t3);line-height:1.3}
.style-seg-item:has(input:checked)>span{background:var(--yellow);box-shadow:inset 0 0 0 .5px rgba(90,66,0,.12)}
.style-seg-item:has(input:checked)>span strong{color:#4d3b00}
.style-seg-item:has(input:checked)>span small{color:#6b5200}

.canvas-guide-seg{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;width:100%}
.canvas-guide-seg label{position:relative;display:flex;cursor:pointer}
.canvas-guide-seg input{position:absolute;opacity:0;pointer-events:none}
.canvas-guide-seg span{display:grid;width:100%;min-height:38px;place-items:center;border:1px solid var(--bd);border-radius:9px;background:var(--fill-tertiary);color:var(--t2);font-size:12px;font-weight:650;transition:border-color .15s,background .15s,color .15s,box-shadow .15s}
.canvas-guide-seg label:has(input:checked) span{border-color:var(--yellow);background:color-mix(in srgb,var(--yellow) 13%,var(--white));color:var(--t);box-shadow:0 0 0 2px color-mix(in srgb,var(--yellow) 18%,transparent)}
.strategy-picker-grid,.algorithm-picker-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}
.strategy-picker-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
.strategy-option,.algorithm-option{position:relative;display:flex;min-width:0;flex-direction:column;gap:3px;padding:10px 8px;border:1px solid var(--bd);border-radius:12px;background:var(--white);cursor:pointer}
.strategy-option input,.algorithm-option input{position:absolute;opacity:0;pointer-events:none}.strategy-option span,.algorithm-option span{font-size:13px;font-weight:700}.strategy-option small,.algorithm-option small{font-size:10px;line-height:1.3;color:var(--t3)}
.strategy-option:has(input:checked),.algorithm-option:has(input:checked){border-color:var(--yellow);background:color-mix(in srgb,var(--yellow) 10%,var(--white));box-shadow:0 0 0 2px color-mix(in srgb,var(--yellow) 20%,transparent)}
.algorithm-option-experimental span::after{content:'实验';display:inline-block;margin-left:6px;padding:1px 5px;border-radius:999px;background:var(--fill-tertiary);color:var(--t3);font-size:9px;vertical-align:1px}
.enhanced-only-setting[hidden]{display:none!important}
.effective-options-summary{display:block;margin-top:8px;padding:8px 10px;border-radius:9px;background:var(--fill-tertiary);color:var(--t2);font-size:11px;line-height:1.45}
.mode-recommend-btn{margin-left:auto;padding:4px 8px;border:1px solid var(--bd);border-radius:8px;background:var(--white);color:var(--t2);font-size:11px}.mode-picker-head .mode-recommend-btn+.mode-picker-status{margin-left:0}
.strategy-effective{grid-column:1/-1;padding-top:2px;color:var(--t2)!important;line-height:1.4}
@media(max-width:700px){.strategy-picker-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}

.fld.setting-disabled{opacity:.58}
.fld.setting-disabled .fld-sel{cursor:not-allowed;background:var(--fill-tertiary)}
.fld.setting-disabled .setting-availability-hint{color:var(--t2)}

/* ★ 管线模式联动：candidate 模式下禁用的图像处理控件 */
.fld.pipeline-disabled{opacity:0.38;pointer-events:none;filter:grayscale(0.5);transition:opacity 0.2s,filter 0.2s}
.fld.pipeline-disabled .fld-lbl::after{content:' (仅全色直出模式)';font-size:10px;color:var(--t3);font-weight:400}
.fld-chips{display:flex;gap:8px;flex-wrap:wrap}
.chip{display:inline-flex;align-items:center;gap:4px;padding:8px 16px;border:0.5px solid var(--bd);border-radius:var(--r-full);font-size:13px;cursor:pointer;transition:transform .15s var(--ease-spring),background-color .2s ease,border-color .2s ease,color .2s ease,box-shadow .2s ease;backface-visibility:hidden;background:var(--white)}
.chip input{display:none}
.chip:active{transform:scale(0.95)}
.chip:has(input:checked),.chip.active{background:var(--yellow-light);border-color:var(--yellow);font-weight:600;color:var(--t);box-shadow:0 0 0 1px color-mix(in srgb,var(--yellow) 35%,transparent)}
.mode-picker-field{margin-bottom:14px}
.mode-picker-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:8px}
.mode-picker-head .fld-lbl{margin:0}
.mode-picker-status{font-size:11px;color:var(--t3);text-align:right}
.mode-card-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.mode-card{position:relative;display:flex;min-width:0;min-height:76px;flex-direction:column;justify-content:center;gap:4px;padding:12px 13px;border:1px solid var(--bd);border-radius:14px;background:var(--white);cursor:pointer;transition:border-color .16s,background .16s,box-shadow .16s,transform .12s}
.mode-card input{position:absolute;opacity:0;pointer-events:none}
.mode-card-title{font-size:14px;font-weight:700;color:var(--t)}
.mode-card small{font-size:11px;line-height:1.35;color:var(--t3)}
.mode-card:active{transform:scale(.98)}
.mode-card:has(input:checked){border-color:var(--yellow);background:color-mix(in srgb,var(--yellow) 10%,var(--white));box-shadow:0 0 0 2px color-mix(in srgb,var(--yellow) 22%,transparent)}
.mode-card:has(input:checked)::after{content:'✓';position:absolute;top:9px;right:10px;width:19px;height:19px;border-radius:50%;display:grid;place-items:center;background:var(--yellow);color:var(--t);font-size:11px;font-weight:800}
@media(max-width:420px){.mode-card-grid{grid-template-columns:1fr}.mode-card{min-height:66px}}


/* v7 编辑器工具控件：统一线框图标、尺寸选择状态与触控反馈 */
.topbar :where(.topbar-save,.topbar-list,.topbar-undo,.topbar-size){border:1px solid color-mix(in srgb,var(--bd) 78%,transparent);box-shadow:none}
.topbar :where(.topbar-save,.topbar-list,.topbar-undo,.topbar-size)>.icon{width:18px;height:18px;flex:0 0 auto}
.topbar .topbar-save{border-color:color-mix(in srgb,var(--yellow) 72%,#b88700)}
.topbar-size{height:32px;min-height:32px;padding:0 8px;border-radius:9px;background:var(--white);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;gap:5px}
.topbar :where(.topbar-save,.topbar-list){width:34px;height:34px}
.topbar .topbar-undo{width:32px;height:32px}
.topbar-size .topbar-chevron{width:13px;height:13px;color:var(--t3);transition:transform .18s ease}
.topbar-size:active .topbar-chevron{transform:translateY(1px)}
.size-preset-chip{position:relative;display:grid;grid-template-columns:15px auto 1fr 16px;align-items:center;gap:5px;min-width:122px;padding:7px 8px;border-radius:9px;text-align:left;color:var(--t2);font-size:12px}
.size-preset-chip>.icon{width:17px;height:17px;color:var(--t3)}
.size-preset-chip>small{color:var(--t3);font-size:11px;font-weight:500;text-align:right}
.size-preset-chip .size-chip-check{display:grid;place-items:center;width:18px;height:18px;border-radius:50%;background:var(--yellow);color:#5a4200;font-size:11px;font-weight:800;opacity:0;transform:scale(.6);transition:.16s ease}
.size-preset-chip.active{background:var(--yellow-light);border-color:var(--yellow);color:var(--t)}
.size-preset-chip.active>.icon{color:#8a6500}
.size-preset-chip.active .size-chip-check{opacity:1;transform:scale(1)}
.ref-inline-panel{padding:5px 6px 5px 34px;gap:3px}
.ref-inline-row{gap:3px;min-height:22px;box-shadow:none}
.ref-inline-label{width:30px;font-size:10px}
.ref-inline-slider{min-width:60px;height:18px}
.ref-inline-num{width:38px!important;height:18px!important;min-height:18px!important;padding:0 2px!important;font-size:10px;line-height:16px;border-radius:4px}
.ref-inline-unit{font-size:9px;min-width:13px}
.ref-transform-btn{min-height:22px!important;border-radius:4px}
.ref-transform-btn .icon{width:13px!important;height:13px!important}
.ref-inline-btn{min-height:21px!important;padding:3px 4px!important;font-size:10px;gap:3px}
.ref-inline-btn .icon{width:12px;height:12px}
.fld-chk{display:flex;align-items:center;gap:8px;font-size:14px;cursor:pointer;padding:6px 0}
.fld-chk input[type="checkbox"]{width:20px;height:20px;accent-color:var(--yellow);cursor:pointer;border-radius:5px}

/* fieldset 参数分组 */
.param-group{border:0.5px solid var(--bd);border-radius:var(--r-md);padding:12px 12px 0;margin-bottom:12px}
.param-legend{font-size:12px;font-weight:600;color:var(--t2);padding:0 8px;margin-left:-4px;background:var(--white);letter-spacing:0.3px}

/* 通用输入弹窗 */
#inputDialogInput:focus{border-color:var(--yellow);box-shadow:0 0 0 3px var(--yellow-alpha)}

/* 颜色统计弹窗 — iOS 风格 */
.stats-item{display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:var(--r-md);cursor:pointer;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;margin-bottom:2px;backface-visibility:hidden}
.stats-item:active{transform:scale(0.97)}
.stats-item:hover{background:var(--fill-tertiary)}
.stats-item.highlighted{background:var(--yellow-light)!important;color:var(--t);border:0.5px solid var(--yellow)}
.stats-swatch{width:28px;height:28px;border-radius:var(--r-sm);border:0.5px solid rgba(0,0,0,0.08);flex-shrink:0;display:flex;align-items:center;justify-content:center;font-size:9px;font-weight:700;color:#fff;text-shadow:0 0 2px rgba(0,0,0,0.5)}
.stats-code{font-size:13px;font-weight:600;color:var(--t);min-width:44px;font-family:Consolas,monospace}
.stats-name{font-size:11px;color:var(--t3);flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.stats-count{font-size:14px;font-weight:700;color:var(--t2);min-width:36px;text-align:right;font-variant-numeric:tabular-nums}
.stats-actions{display:flex;gap:2px;margin-left:4px;flex-shrink:0}
.stats-act-btn{width:36px;height:36px;border-radius:7px;border:none;background:transparent;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:12px;transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;color:var(--t3)}
.stats-act-btn:active{background:var(--fill-secondary);transform:scale(0.88)}
/* 颜色清理是画布实时预览工具：遮罩保持透明清晰，控制器缩为悬浮卡片。 */
.color-cleanup-overlay{
  background:transparent!important;
  backdrop-filter:none!important;
  -webkit-backdrop-filter:none!important;
  align-items:flex-end;
  justify-content:flex-end;
  padding:16px;
  pointer-events:none;
}
.color-cleanup-panel{
  width:min(400px,calc(100vw - 32px));
  border-radius:18px!important;
  padding:10px 16px calc(12px + var(--safe-b));
  box-shadow:0 10px 36px rgba(0,0,0,.18);
  pointer-events:auto;
  animation:none;
}
.color-cleanup-panel .sheet-handle{display:none}
.color-cleanup-panel .sheet-title{margin-bottom:8px}
@media(max-width:520px){
  .color-cleanup-overlay{padding:8px;align-items:flex-end;justify-content:center}
  .color-cleanup-panel{width:100%;padding:9px 12px calc(10px + var(--safe-b));border-radius:var(--r-xl)!important}
  .color-cleanup-copy{margin-bottom:8px!important;font-size:12px!important}
}
@media(max-width:520px){
  .stats-item{gap:5px;padding:8px 6px}
  .stats-code{min-width:36px}
  .stats-count{min-width:28px}
  .stats-actions{gap:1px;margin-left:1px}
  .stats-act-btn{width:36px;height:36px}
}

/* 选区拖拽遮罩 */
.select-overlay{position:absolute;z-index:20;background:rgba(99,102,241,0.08);border:2px solid #6366f1;pointer-events:none;transition:none;border-radius:var(--r-xs)}
.select-overlay .select-handle{position:absolute;right:-6px;bottom:-6px;width:12px;height:12px;background:#6366f1;border-radius:50%;pointer-events:all;cursor:nwse-resize;border:2px solid var(--white);box-shadow:var(--shadow-sm)}

/* 工具提示 Toast — 毛玻璃 */
.tool-hint-toast{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%) translateY(10px);z-index:9999;pointer-events:none;display:flex;align-items:center;gap:8px;padding:10px 20px 10px 14px;background:rgba(22,22,28,0.88);backdrop-filter:blur(20px) saturate(1.4);-webkit-backdrop-filter:blur(20px) saturate(1.4);border-radius:999px;box-shadow:0 0 0 1px rgba(255,255,255,0.1),var(--shadow-lg);opacity:0;transition:opacity 0.2s,transform 0.3s var(--ease-spring);white-space:nowrap}
.tool-hint-toast.show{opacity:1;transform:translate(-50%,-50%) translateY(0)}
.tool-hint-toast.emphasize{animation:toolHintEmphasize 0.28s ease-out}
.tool-hint-icon{width:28px;height:28px;border-radius:50%;background:linear-gradient(135deg,var(--yellow),var(--yellow-d));display:flex;align-items:center;justify-content:center;font-size:15px;box-shadow:0 2px 8px rgba(255,212,59,0.3);flex-shrink:0}
.tool-hint-label{color:rgba(255,255,255,0.92);font-size:14px;font-weight:600;letter-spacing:0.01em}
@keyframes toolHintEmphasize{0%{transform:translate(-50%,-50%) scale(.96)}60%{transform:translate(-50%,-50%) scale(1.035)}100%{transform:translate(-50%,-50%) scale(1)}}

/* 动画 */
@keyframes fadeIn{from{opacity:0}to{opacity:1}}
@keyframes scaleIn{from{opacity:0;transform:scale(0.9)}to{opacity:1;transform:scale(1)}}
@keyframes fadeOut{from{opacity:1}to{opacity:0}}
@keyframes scaleOut{from{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(0.9)}}

/* 进度处理指示器 — iOS 风格 */
#processingOverlay{display:none;position:fixed;inset:0;z-index:9998;align-items:center;justify-content:center}
#processingOverlay .proc-overlay-bg{position:absolute;inset:0;background:rgba(0,0,0,0.3);backdrop-filter:blur(20px) saturate(1.4);-webkit-backdrop-filter:blur(20px) saturate(1.4)}
#processingOverlay .proc-panel{position:relative;background:var(--white);border-radius:var(--r-xl);padding:32px 36px 28px;width:300px;max-width:80vw;text-align:center;box-shadow:var(--shadow-xl);animation:scaleIn 0.35s var(--ease-spring)}
#processingOverlay .proc-icon{font-size:42px;margin-bottom:10px}
#processingOverlay .proc-title{font-size:18px;font-weight:700;color:var(--t);margin-bottom:4px}
#processingOverlay .proc-step{font-size:14px;color:var(--t2);margin-bottom:16px;min-height:20px}
#processingOverlay .proc-bar-track{height:5px;background:var(--fill-tertiary);border-radius:3px;overflow:hidden;margin-bottom:8px}
#processingOverlay .proc-bar-fill{height:100%;background:linear-gradient(90deg,var(--yellow),var(--yellow-d));border-radius:3px;width:0%;transition:width 0.35s var(--ease-out)}
#processingOverlay .proc-sub{font-size:11px;color:var(--t3);min-height:16px}
#processingOverlay .proc-cancel{margin-top:14px;min-width:116px;min-height:38px;padding:0 16px;border:1px solid var(--bd);border-radius:10px;background:var(--fill-secondary);color:var(--t2);font-size:13px;font-weight:650}
#processingOverlay .proc-cancel:disabled{opacity:.55;cursor:wait}

/* 拖拽上传反馈 */
.canvas-area.drag-over{background:rgba(250,204,21,0.06)!important}
.canvas-area.drag-over::before{content:'';position:absolute;inset:16px;border:2.5px dashed var(--yellow);border-radius:var(--r-lg);z-index:50;pointer-events:none;animation:dashPulse 1.2s ease-in-out infinite}
.canvas-area.drag-over::after{content:'📎 松开放置图片';position:absolute;top:50%;left:50%;transform:translate(-50%,-50%) scale(1);background:rgba(255,255,255,0.96);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);padding:16px 28px;border-radius:var(--r-lg);font-size:18px;font-weight:700;color:var(--t);z-index:51;pointer-events:none;box-shadow:var(--shadow-lg);animation:dashPulse 1.2s ease-in-out infinite,scaleIn 0.3s var(--ease-spring)}
@media(min-width:900px){
  .canvas-area.drag-over:has(.empty-state:not([style*="display: none"]))::before,
  .canvas-area.drag-over:has(.empty-state:not([style*="display: none"]))::after{display:none}
}
@keyframes dashPulse{0%,100%{opacity:0.7}50%{opacity:1}}

/* 图纸列表项 */
.drawing-item{display:flex;align-items:center;padding:12px 12px;border-radius:var(--r-md);cursor:pointer;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;gap:10px;border-bottom:0.5px solid var(--bd);background:var(--white)}
.drawing-item:active{background:var(--fill-tertiary);transform:scale(0.98)}
.drawing-item:last-child{border-bottom:none}
.drawing-item-icon{width:40px;height:40px;border-radius:var(--r-md);background:var(--yellow-alpha);display:flex;align-items:center;justify-content:center;font-size:18px;flex-shrink:0;color:#5a4200}
.drawing-item-info{flex:1;min-width:0}
.drawing-item-name{font-size:15px;font-weight:600;color:var(--t);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.drawing-item-meta{font-size:11px;color:var(--t3);margin-top:3px;font-variant-numeric:tabular-nums}
.drawing-item-actions{display:flex;gap:4px;flex-shrink:0;opacity:0.5;transition:opacity 0.15s}
.drawing-item:hover .drawing-item-actions{opacity:1}
.drawing-item-act{width:32px;height:32px;border-radius:var(--r-xs);border:none;background:transparent;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:15px;color:var(--t3);transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease}
.drawing-item-act:active{transform:scale(0.88);background:var(--fill-secondary)}
.drawing-item-act.danger{color:#e53935}

/* 保存成功 Toast */
.saved-toast{position:fixed;bottom:100px;left:50%;transform:translateX(-50%) translateY(16px);background:rgba(0,0,0,0.82);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);color:#fff;padding:12px 24px;border-radius:var(--r-full);font-size:14px;font-weight:600;z-index:9999;pointer-events:none;opacity:0;transition:opacity 0.25s,transform 0.3s var(--ease-spring);white-space:nowrap}
.saved-toast.show{opacity:1;transform:translateX(-50%) translateY(0)}

/* 参考图浮动面板（已废弃，移至 REF 内联面板） */

/* 替换工具通知条 */
.replace-notify{position:absolute;top:12px;left:50%;transform:translateX(-50%);background:rgba(0,0,0,0.78);color:#fff;padding:6px 16px;border-radius:var(--r-full);font-size:13px;font-weight:500;pointer-events:none;z-index:10;white-space:nowrap;transition:opacity 0.25s;opacity:0}
.replace-notify.show{opacity:1}
/* 擦除模式：隐藏默认光标，圆圈由 JS mousemove 动态绘制 */
.canvas-area.erase-mode .grid-wrapper{cursor:none}
.canvas-area.erase-mode .grid-container{cursor:none}
.erase-ring{position:fixed;pointer-events:none;z-index:999;border:2px solid rgba(255,59,48,0.7);border-radius:50%;background:rgba(255,59,48,0.1);transform:translate(-50%,-50%);display:none;backface-visibility:hidden;transition:width 0.12s,height 0.12s,opacity 0.12s,border-color 0.12s,background-color 0.12s;box-shadow:0 0 0 1px rgba(255,255,255,0.28) inset}
.erase-ring.brush-preview{border-color:rgba(99,102,241,0.82);background:rgba(99,102,241,0.10)}
.erase-ring.erase-preview{border-color:rgba(255,59,48,0.72);background:rgba(255,59,48,0.10)}
.erase-ring.show{display:block}


/* 参考图叠加层（已废弃，Canvas 内联渲染） */

/* 高亮叠加 Canvas */
.grid-highlight-overlay{backface-visibility:hidden;transform:translateZ(0)}

/* 参考图浮动控制面板（已废弃，移至 REF 内联面板） */
@media(max-width:380px){
  .info-stat-item{padding:0 18px}
  .info-stat-num{font-size:22px}
  .tool{padding:6px 12px;font-size:12px;min-height:40px}
}

/* ===== 设置弹窗色板预览 — 网格布局 ===== */
.palette-preview{display:flex;flex-wrap:wrap;gap:3px;padding:8px 0}
.palette-preview .pp-swatch{width:16px;height:16px;border-radius:3px;flex-shrink:0;border:0.5px solid rgba(0,0,0,0.08);cursor:default;transition:transform 0.1s}
.palette-preview .pp-swatch:active{transform:scale(1.3)}

/* ===== 品牌选择弹窗 — Apple HIG 风格平铺列表 ===== */
.brand-section{margin:0;padding:0}
.brand-section-header{font-size:12px;font-weight:600;color:var(--t2);letter-spacing:0.3px;padding:12px 16px 4px;border-bottom:0;text-transform:uppercase}
.brand-row{display:flex;align-items:center;gap:8px;padding:10px 16px;cursor:pointer;transition:background 0.1s;min-height:40px;-webkit-tap-highlight-color:transparent}
.brand-row:active{background:var(--fill-tertiary)}
.brand-row.active{background:var(--yellow-light)}
.brand-row-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.brand-row-name{font-size:14px;font-weight:400;color:var(--t);display:flex;align-items:center;gap:6px;line-height:1.3}
.brand-row.active .brand-row-name{font-weight:500}
.brand-row-meta{font-size:11px;color:var(--t3);display:flex;align-items:center;gap:4px}
.brand-checkmark{width:20px;height:20px;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;transition: transform 0.15s var(--ease-out), opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;color:transparent;font-size:13px;font-weight:700}
.brand-row.active .brand-checkmark{color:var(--yellow);background:var(--yellow-alpha)}
.brand-mini-pal{display:flex;gap:2px;flex-shrink:0;margin-left:auto;padding-left:8px}
.brand-mini-pal .bp-swatch{width:10px;height:10px;border-radius:1.5px;border:0.5px solid rgba(0,0,0,0.06);flex-shrink:0}
.brand-mini-pal .bp-more{font-size:9px;color:var(--t3);line-height:10px;padding-left:2px}
.brand-row-divider{height:0.5px;background:var(--bd);margin:0 16px}

/* ===== 设置弹窗品牌字段按钮 ===== */
.brand-field-btn{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border:1px solid var(--bd);border-radius:var(--r-sm);background:var(--bg);cursor:pointer;transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;min-height:40px;-webkit-tap-highlight-color:transparent}
.brand-field-btn:active{background:var(--fill-tertiary);border-color:var(--t3)}
.brand-field-btn span{font-size:14px;font-weight:500;color:var(--t);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.brand-field-btn svg{width:12px;height:12px;color:var(--t3);flex-shrink:0;transition:transform 0.12s}
.brand-field-btn:active svg{transform:translateX(2px)}

/* ===== 设置品牌弹窗内部品牌列表（紧凑版） ===== */
#settingsBrandModalContent .brand-section-header{padding:10px 8px 2px;font-size:11px}
#settingsBrandModalContent .brand-row{padding:8px 8px;min-height:36px;gap:6px}
#settingsBrandModalContent .brand-row-name{font-size:13px}
#settingsBrandModalContent .brand-row-meta{font-size:10px}
#settingsBrandModalContent .brand-mini-pal .bp-swatch{width:8px;height:8px}
#settingsBrandModalContent .brand-checkmark{width:18px;height:18px;font-size:12px}
#settingsBrandModalContent .brand-row-divider{margin:0 8px}

/* ===== 设置弹窗画布预览 ===== */
.settings-preview-wrap{background:var(--fill-tertiary);border-radius:var(--r-md);padding:10px;margin-bottom:16px;text-align:center}
.settings-preview-head{font-size:11px;font-weight:600;color:var(--t2);margin-bottom:8px;letter-spacing:0.3px}
.settings-preview-wrap canvas{display:block;margin:0 auto;border-radius:8px;background:#fff;image-rendering:pixelated;max-width:100%;max-height:220px;width:auto;height:auto}

/* ===== 图层面板 — 悬浮卡片式 ===== */

/* 面板容器 — 从全高侧栏改为浮动卡片（Apple HIG 悬浮窗） */
.layer-panel-overlay {
  position: fixed;
  right: 16px;
  top: 52px;
  width: min(220px, 60vw);
  max-height: 50vh;
  z-index: 180;
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  box-shadow: 0 2px 20px rgba(0,0,0,0.08), 0 8px 32px rgba(0,0,0,0.06);
  border-radius: 14px;
  border: 0.5px solid rgba(0,0,0,0.04);
  transform: scale(0.92) translateY(-8px);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.2s ease-out;
  will-change: transform, opacity;
  pointer-events: none;
  overflow: hidden;
}
.layer-panel-overlay.show {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* 面板滚动容器 */
.layer-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ── 头部 ── */
.layer-panel-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px 8px;
  border-bottom: 0.5px solid var(--bd);
  flex-shrink: 0;
}
.layer-panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--t);
  letter-spacing: -0.2px;
}
.layer-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--t3);
  background: var(--fill-tertiary);
  padding: 1px 6px;
  border-radius: var(--r-full);
  line-height: 1.4;
}
.layer-panel-spacer { flex: 1; }
.layer-close-btn {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--t3);
  border-radius: 50%; transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
  background: transparent; border: none; cursor: pointer;
  flex-shrink: 0;
}
.layer-close-btn:active { background: var(--fill-tertiary); transform: scale(0.9); }
.layer-close-btn svg { width: 14px; height: 14px; }

/* ── 图层列表 ── */
.layer-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  -webkit-overflow-scrolling: touch;
}
.layer-list::-webkit-scrollbar { width: 3px; }
.layer-list::-webkit-scrollbar-thumb { background: var(--bd); border-radius: 2px; }

/* ── 每个图层项 — 更紧凑 ── */
.layer-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  margin-bottom: 3px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s var(--ease-out);
  border: 1px solid transparent;
  position: relative;
  background: var(--bg);
}
.layer-item:active { transform: scale(0.98); }
.layer-item.active {
  border-color: var(--yellow);
  background: var(--yellow-light);
  box-shadow: 0 1px 3px rgba(255,212,59,0.12);
}

/* 缩略图 + 手柄组合 */
.layer-thumb-wrap {
  position: relative;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
}
.layer-thumb {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--bd);
  overflow: hidden;
  background: #fff;
  image-rendering: pixelated;
  cursor: pointer;
  transition: border-color 0.12s;
}
.layer-thumb canvas { display: block; width: 100%; height: 100%; }
.layer-item.active .layer-thumb { border-color: var(--yellow); box-shadow: 0 0 0 1px var(--yellow); }

/* 拖拽手柄 */
.layer-drag-handle {
  position: absolute;
  bottom: -2px; right: -2px;
  width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: grab;
  color: var(--t4);
  font-size: 8px;
  background: var(--white);
  border-radius: 50%;
  border: 0.5px solid var(--bd);
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
  touch-action: none;
}
.layer-drag-handle:active { cursor: grabbing; color: var(--yellow); }
.layer-drag-handle::before { content: "⋮⋮"; font-size: 6px; letter-spacing: -1px; line-height: 1; }

/* 拖拽状态 */
.layer-item.dragging {
  opacity: 0.85;
  border: 1px solid var(--yellow);
  background: var(--yellow-light);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12), 0 0 0 1px var(--yellow);
  transform: scale(1.02);
  z-index: 10;
  position: relative;
  transition: transform .15s var(--ease-spring), background-color .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.layer-item.drag-over {
  border-top: 2px solid var(--yellow) !important;
  background: rgba(250,204,21,0.06);
  transition: border-color 0.1s, background 0.1s;
}
.layer-item.drag-source {
  opacity: 0.3;
  border: 1px dashed var(--t4);
  background: var(--fill-tertiary);
  transform: scale(0.97);
}

/* ── 中间信息区 ── */
.layer-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.layer-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--t);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}
.layer-meta {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}
.layer-meta-op {
  font-size: 9px;
  color: var(--t3);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.layer-meta-tag {
  font-size: 8px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1.3;
}
.layer-tag-locked { background: rgba(255,149,0,0.12); color: #C07A00; }
.layer-tag-hidden { background: rgba(142,142,147,0.15); color: var(--t3); }
.layer-meta-count {
  font-size: 9px;
  color: var(--t3);
  font-weight: 400;
}

/* ── 右侧控制区 ── */
.layer-controls {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}
.layer-ctrl-btn {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  cursor: pointer;
  color: var(--t2);
  font-size: 12px;
  border-radius: 5px;
  transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
  flex-shrink: 0;
}
.layer-ctrl-btn:active { background: var(--fill-tertiary); transform: scale(0.88); }
.layer-ctrl-btn.off { color: var(--t4); opacity: 0.5; }
.layer-ctrl-btn.on { color: var(--yellow); }
.layer-ctrl-btn svg { width: 14px; height: 14px; display: block; }

/* ── ⋯更多按钮 ── */
.layer-more-btn {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  cursor: pointer;
  color: var(--t3);
  font-size: 14px;
  border-radius: 5px;
  transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
  flex-shrink: 0;
  font-weight: 700;
  letter-spacing: -1px;
}
.layer-more-btn:active { background: var(--fill-tertiary); transform: scale(0.88); }

/* ── 底部操作栏 ── */
.layer-panel-footer {
  flex-shrink: 0;
  padding: 6px 10px 8px;
  border-top: 0.5px solid var(--bd);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.layer-footer-btn {
  width: 100%;
  padding: 7px;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
}
.layer-footer-btn:active { transform: scale(0.97); }
.layer-footer-new {
  background: var(--yellow);
  color: var(--t);
  box-shadow: 0 1px 3px rgba(255,212,59,0.2);
}
.layer-footer-new:active { background: var(--yellow-d); }
.layer-footer-new svg { width: 14px; height: 14px; }
.layer-footer-row {
  display: flex;
  gap: 3px;
}
.layer-footer-chip {
  flex: 1;
  padding: 5px 3px;
  border: none;
  border-radius: 6px;
  font-size: 9px;
  font-weight: 600;
  color: var(--t2);
  background: var(--fill-tertiary);
  cursor: pointer;
  transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  white-space: nowrap;
  min-height: 26px;
}
.layer-footer-chip:active { transform: scale(0.95); background: var(--fill-primary); }
.layer-footer-chip svg { width: 11px; height: 11px; flex-shrink: 0; }
.layer-footer-chip.active { background: var(--yellow); color: var(--t); }

/* 底部 [+添加参考图] 按钮 */
.layer-footer-addref {
  width: 100%;
  padding: 6px;
  border: 1px dashed var(--t4);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--t3);
  background: transparent;
  cursor: pointer;
  transition: transform 0.12s var(--ease-out), opacity 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 28px;
}
.layer-footer-addref:active { transform: scale(0.97); background: var(--fill-tertiary); border-color: var(--yellow); color: var(--t); }
.layer-footer-addref svg { width: 12px; height: 12px; }

/* ── REF 参考图图层 ── */
.layer-item.type-ref { border-left: 3px solid rgba(99,102,241,0.3); }
.layer-item.type-ref.active { border-left-color: #6366f1; }
.layer-ref-thumb { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--bd); overflow: hidden; background: #f0f0f5; display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--t3); }
.layer-ref-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.layer-ref-dims { font-size: 9px; color: var(--t3); font-weight: 400; }
.layer-ctrl-btn.ref-transform { color: #6366f1; }
.layer-ctrl-btn.ref-transform.on { background: rgba(99,102,241,0.12); }
.layer-ctrl-btn.ref-delete { color: #d63a3a; }
.layer-ctrl-btn.ref-delete:active { background: rgba(255,59,48,0.10); }

/* 图纸导入向导 */
.pattern-import-open{overscroll-behavior:none}
.pattern-import-mode-note{margin:0 0 12px;padding:10px 12px;border:1px solid #bfdbfe;border-radius:8px;background:#eff6ff;color:#1d4ed8;font-size:13px}
.pattern-import-open .pattern-import-overlay,.pattern-import-open .pattern-import-sheet{touch-action:pan-y;overscroll-behavior:none}
.pattern-import-open .pattern-import-canvas-wrap,.pattern-import-open .pattern-grid-preview,.pattern-import-open .pattern-result-preview{touch-action:none}
.pattern-import-overlay{position:fixed;inset:0;z-index:900;background:rgba(9,15,29,.62);display:flex;align-items:flex-end;justify-content:center;opacity:0;transition:opacity .18s ease}
.pattern-import-overlay.show{opacity:1}
.pattern-import-sheet{width:min(760px,100%);max-height:min(100dvh,900px);background:#f7f8fc;color:#101828;border-radius:24px 24px 0 0;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 -18px 60px rgba(0,0,0,.22);transform:translateY(22px);transition:transform .22s ease}
.pattern-import-overlay.show .pattern-import-sheet{transform:none}
.pattern-import-head{display:flex;align-items:center;gap:14px;padding:18px 22px 12px;background:#fff;border-bottom:1px solid #e5eaf2}.pattern-import-head h2{margin:0;font-size:22px}.pattern-import-head p{margin:4px 0 0;color:#667085;font-size:13px}.pattern-import-back,.pattern-import-close{border:0;background:#f1f4f9;width:38px;height:38px;border-radius:50%;font-size:24px;color:#344054;cursor:pointer}.pattern-import-close{margin-left:auto;font-size:26px}
.pattern-import-steps{display:flex;align-items:center;justify-content:center;gap:10px;padding:13px 18px;background:#fff;color:#98a2b3;font-size:13px}.pattern-import-steps span{padding:6px 10px;border-radius:999px}.pattern-import-steps span.active{background:#1769e0;color:#fff;font-weight:700}.pattern-import-steps span.done{color:#1769e0}.pattern-import-steps i{height:1px;width:34px;background:#dfe5ee}
.pattern-import-body{overflow:auto;padding:20px 22px 10px;min-height:360px}.pattern-import-copy{display:flex;flex-direction:column;gap:6px;margin-bottom:14px}.pattern-import-copy strong{font-size:20px}.pattern-import-copy span,.pattern-import-hint{color:#667085;font-size:13px}.pattern-import-canvas-wrap,.pattern-grid-preview,.pattern-result-preview{position:relative;background:#101827;border-radius:14px;display:flex;justify-content:center;align-items:center;min-height:280px;overflow:hidden}.pattern-import-canvas-wrap canvas,.pattern-grid-preview canvas,.pattern-result-preview canvas{max-width:100%;display:block}.pattern-import-crop{position:absolute;border:2px solid #2f80ed;background:rgba(47,128,237,.18);box-shadow:0 0 0 9999px rgba(0,0,0,.42);cursor:move;touch-action:none;color:#fff;padding:6px;font-size:12px}.pattern-import-crop b{background:#1677ff;padding:4px 7px;border-radius:5px}.pattern-import-foot{display:flex;gap:12px;padding:14px 22px calc(14px + env(safe-area-inset-bottom));background:#fff;border-top:1px solid #e5eaf2}.pattern-import-foot button{flex:1;min-height:48px;border-radius:14px;font-size:16px;font-weight:700;cursor:pointer}.pattern-import-primary{border:0;background:#1769e0;color:#fff}.pattern-import-secondary{border:1px solid #cbd5e1;background:#fff;color:#1769e0}.pattern-import-legend-list{display:flex;flex-direction:column;gap:9px}.pattern-import-legend-row{display:grid;grid-template-columns:44px minmax(90px,1fr) 110px 38px;gap:10px;align-items:center;background:#fff;border-radius:12px;padding:9px}.pattern-import-swatch{width:34px;height:34px;border-radius:9px;border:1px solid rgba(0,0,0,.12)}.pattern-import-legend-row input,.pattern-grid-fields input{width:100%;box-sizing:border-box;border:1px solid #d0d5dd;border-radius:9px;padding:10px;font-size:15px;background:#fff}.legend-remove{border:0;background:#fef3f2;color:#d92d20;border-radius:9px;height:34px;font-size:21px}.pattern-import-add,.pattern-import-auto{border:1px dashed #98a2b3;background:#fff;color:#1769e0;border-radius:10px;padding:11px 14px;margin-top:12px;font-weight:700}.pattern-grid-fields{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-top:12px}.pattern-grid-fields label{display:flex;flex-direction:column;gap:5px;color:#667085;font-size:12px}.pattern-grid-fields button{align-self:end;height:42px}.pattern-import-progress{min-height:340px;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:12px}.pattern-import-spinner{width:34px;height:34px;border:4px solid #dbe8ff;border-top-color:#1769e0;border-radius:50%;animation:pattern-import-spin .8s linear infinite}@keyframes pattern-import-spin{to{transform:rotate(360deg)}}.pattern-result-stats{display:flex;align-items:baseline;gap:12px;margin-bottom:12px}.pattern-result-stats b{font-size:22px}.pattern-result-stats span{color:#667085}.pattern-result-colors{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.pattern-result-colors span{background:#fff;border-radius:999px;padding:6px 10px;font-size:12px}.pattern-result-colors i{display:inline-block;width:12px;height:12px;border-radius:50%;vertical-align:-2px;margin-right:4px;border:1px solid #ddd}
@media(max-width:600px){.pattern-import-body{padding:16px 14px 8px}.pattern-import-head{padding-left:14px;padding-right:14px}.pattern-import-foot{padding-left:14px;padding-right:14px}.pattern-grid-fields{grid-template-columns:repeat(2,1fr)}.pattern-import-legend-row{grid-template-columns:38px minmax(70px,1fr) 84px 34px}.pattern-import-steps{gap:3px}.pattern-import-steps i{width:16px}}

.pattern-import-canvas-wrap{touch-action:none;cursor:grab}.pattern-import-canvas-wrap:active{cursor:grabbing}.pattern-import-crop{box-sizing:border-box}.pattern-import-crop b{pointer-events:none}.pattern-crop-handle{position:absolute;width:28px;height:28px;z-index:3;touch-action:none}.pattern-crop-handle:after{content:"";position:absolute;left:9px;top:9px;width:10px;height:10px;border-radius:50%;background:#fff;border:2px solid #1677ff;box-shadow:0 1px 4px rgba(0,0,0,.35);box-sizing:border-box}.handle-nw{left:-14px;top:-14px;cursor:nwse-resize}.handle-n{left:50%;top:-14px;transform:translateX(-50%);cursor:ns-resize}.handle-ne{right:-14px;top:-14px;cursor:nesw-resize}.handle-e{right:-14px;top:50%;transform:translateY(-50%);cursor:ew-resize}.handle-se{right:-14px;bottom:-14px;cursor:nwse-resize}.handle-s{left:50%;bottom:-14px;transform:translateX(-50%);cursor:ns-resize}.handle-sw{left:-14px;bottom:-14px;cursor:nesw-resize}.handle-w{left:-14px;top:50%;transform:translateY(-50%);cursor:ew-resize}

.pattern-legend-reference{position:sticky;top:-20px;z-index:5;background:#fff;border:1px solid #dfe5ee;border-radius:14px;padding:10px;margin-bottom:12px;box-shadow:0 8px 24px rgba(15,23,42,.08)}.pattern-legend-reference-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}.pattern-legend-reference-head button{border:0;background:#edf4ff;color:#1769e0;border-radius:8px;padding:7px 10px;font-weight:700}.pattern-legend-reference-image{background:#101827;border-radius:9px;overflow:auto;max-height:180px;text-align:center}.pattern-legend-reference-image img{display:block;max-width:none;min-width:100%;height:auto;margin:auto;image-rendering:auto}.pattern-legend-summary{display:flex;align-items:center;gap:14px;padding:10px 12px;margin-bottom:10px;background:#eef4ff;border-radius:11px}.pattern-legend-summary small{margin-left:auto;color:#667085}.pattern-import-legend-row{grid-template-columns:26px 58px minmax(86px,1fr) 138px 34px;transition:border-color .15s,box-shadow .15s;border:1px solid transparent}.pattern-import-legend-row.is-reviewing{border-color:#1769e0;box-shadow:0 0 0 3px rgba(23,105,224,.12)}.legend-order{color:#98a2b3;font-weight:700;text-align:center}.pattern-import-swatch-pair{display:flex;width:54px;height:34px;overflow:hidden;border-radius:9px;border:1px solid rgba(0,0,0,.12)}.pattern-import-swatch-pair i{flex:1}.pattern-import-legend-row label{display:flex;flex-direction:column;gap:3px}.pattern-import-legend-row label small{color:#667085;font-size:11px}.legend-stepper{display:grid;grid-template-columns:34px 1fr 34px;align-items:center}.legend-stepper button{height:38px;border:0;background:#edf4ff;color:#1769e0;font-size:18px}.legend-stepper button:first-child{border-radius:9px 0 0 9px}.legend-stepper button:last-child{border-radius:0 9px 9px 0}.legend-stepper .legend-count{border-radius:0;text-align:center;padding-left:3px;padding-right:3px;appearance:textfield}.legend-stepper .legend-count::-webkit-inner-spin-button{display:none}@media(max-width:600px){.pattern-legend-reference{top:-16px}.pattern-legend-reference-image{max-height:140px}.pattern-legend-summary{display:grid;grid-template-columns:1fr 1fr;gap:5px}.pattern-legend-summary small{grid-column:1/-1;margin:0}.pattern-import-legend-row{grid-template-columns:22px 50px minmax(70px,1fr) 112px 30px;gap:6px;padding:8px 5px}.pattern-import-swatch-pair{width:46px}.legend-stepper{grid-template-columns:28px 1fr 28px}.legend-stepper button{padding:0}.legend-remove{width:30px}}

.pattern-legend-ocr-debug{grid-column:1/-1;font-style:normal;font-size:11px;color:#7c2d12;word-break:break-all}.pattern-import-legend-row.is-ocr{border-color:rgba(22,163,74,.3)}.pattern-import-legend-row.is-ocr label small{color:#15803d}.pattern-import-legend-row.needs-review{border-color:rgba(217,119,6,.35)}.pattern-import-legend-row.needs-review label small{color:#b45309}.pattern-import-primary:disabled{opacity:.65;cursor:wait}

.pattern-import-file-pick{width:100%;min-height:160px;border:1px dashed #98a2b3;background:#fff;color:#1769e0;font-size:17px;font-weight:700;cursor:pointer}.pattern-progress-track{width:min(360px,82%);height:8px;background:#dbe5f2;border-radius:4px;overflow:hidden}.pattern-progress-track i{display:block;width:0;height:100%;background:#1769e0;transition:width .16s linear}.pattern-classification-list{display:flex;flex-direction:column;gap:8px}.pattern-classification-row{display:grid;grid-template-columns:38px minmax(0,1fr);gap:10px;align-items:center;background:#fff;border:1px solid #e5eaf2;border-radius:8px;padding:10px}.pattern-classification-row>i{width:34px;height:34px;border:1px solid rgba(0,0,0,.12);border-radius:6px}.pattern-classification-row label{display:flex;align-items:center;gap:10px;min-width:0}.pattern-classification-row small{min-width:110px;color:#667085}.pattern-classification-row input{flex:1;min-width:0;border:1px solid #d0d5dd;border-radius:7px;padding:9px;background:#fff}.pattern-classification-row.is-match{border-color:rgba(22,163,74,.35)}.pattern-classification-row.has-diff{border-color:rgba(217,119,6,.45)}.pattern-import-warning{color:#b45309;font-size:13px}.pattern-import-steps{overflow-x:auto;justify-content:flex-start;scrollbar-width:none}.pattern-import-steps span{white-space:nowrap}.pattern-import-steps i{flex:0 0 16px}@media(max-width:600px){.pattern-import-steps{padding-left:12px;padding-right:12px}.pattern-import-steps span{padding:6px 8px}.pattern-classification-row label{align-items:stretch;flex-direction:column;gap:5px}.pattern-classification-row small{min-width:0}}

.pattern-legend-review-tools{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:0 0 9px}.pattern-legend-review-tools button{border:1px solid #cbd5e1;background:#fff;color:#475467;border-radius:999px;padding:7px 12px;font-weight:700}.pattern-legend-review-tools button.active{border-color:#d97706;background:#fff7ed;color:#b45309}.pattern-legend-review-tools small{color:#667085}.pattern-import-legend-row[hidden]{display:none!important}

.pattern-cloud-ocr-toggle{display:flex;align-items:center;gap:9px;margin:-4px 0 12px;padding:10px 12px;background:#fff;border:1px solid #dfe5ee;border-radius:8px;color:#475467;font-size:13px}.pattern-cloud-ocr-toggle input{width:18px;height:18px;accent-color:#1769e0}.pattern-ocr-services{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:3px;margin:-4px 0 10px;padding:3px;background:#edf1f6;border-radius:8px}.pattern-ocr-services label{position:relative;min-width:0}.pattern-ocr-services input{position:absolute;opacity:0;pointer-events:none}.pattern-ocr-services span{display:grid;place-items:center;min-height:36px;padding:0 3px;border:1px solid transparent;border-radius:6px;color:#667085;font-size:12px;font-weight:700;line-height:1;white-space:nowrap;cursor:pointer}.pattern-ocr-services label small{display:none}.pattern-ocr-services input:checked+span{border-color:#c9d8ee;background:#fff;color:#1769e0;box-shadow:0 1px 4px rgba(15,23,42,.08)}.pattern-ai-ocr-key{grid-template-columns:1fr}.pattern-ai-ocr-key label{grid-column:1/-1}@media(max-width:380px){.pattern-ocr-services{gap:2px;padding:2px}.pattern-ocr-services span{min-height:34px;padding:0 1px;font-size:11px}}
.pattern-grid-workbench{display:flex;flex-direction:column;gap:12px}.pattern-grid-intro{display:flex;align-items:center;justify-content:space-between;gap:14px}.pattern-grid-intro>div{display:flex;flex-direction:column;gap:3px}.pattern-grid-intro strong{font-size:18px}.pattern-grid-intro span{color:#667085;font-size:12px}.pattern-grid-auto{min-height:42px;border:0;border-radius:8px;padding:0 15px;background:#e8f1ff;color:#175fc2;font-weight:800}.pattern-grid-auto:disabled{opacity:.55}.pattern-grid-preview{min-height:380px;touch-action:none;cursor:move;border-radius:8px}.pattern-grid-preview canvas{width:100%;height:100%}.pattern-grid-view-tools{position:absolute;z-index:3;left:10px;top:10px;display:flex;align-items:center;gap:6px;padding:5px;background:rgba(15,23,42,.72);border-radius:7px;color:#fff;backdrop-filter:blur(6px)}.pattern-grid-view-tools button{min-height:32px;border:0;border-radius:5px;padding:0 9px;background:rgba(255,255,255,.14);color:#fff;font-size:11px}.pattern-grid-view-tools label{display:flex;align-items:center;gap:5px;font-size:11px}.pattern-grid-view-tools input{width:64px;accent-color:#60a5fa}.pattern-grid-gesture-hint{position:absolute;left:50%;bottom:10px;transform:translateX(-50%);z-index:2;padding:5px 9px;border-radius:6px;background:rgba(15,23,42,.7);color:#fff;font-size:10px;white-space:nowrap;pointer-events:none}.pattern-grid-nudges{position:absolute;right:12px;bottom:38px;z-index:4;display:grid;grid-template-columns:42px 42px 42px;grid-template-rows:18px 42px 42px 42px;gap:3px;filter:drop-shadow(0 4px 10px rgba(0,0,0,.3))}.pattern-grid-nudges>span{grid-column:1/-1;text-align:center;color:#fff;font-size:10px;font-weight:700;text-shadow:0 1px 2px #000}.pattern-grid-nudges button,.pattern-grid-nudges i{width:42px;height:42px;display:grid;place-items:center;box-sizing:border-box;border:1px solid rgba(255,255,255,.55);border-radius:6px;background:rgba(15,23,42,.78);color:#fff;font-size:20px;font-weight:800;font-style:normal;touch-action:none}.pattern-grid-nudges [data-grid-nudge="up"]{grid-column:2}.pattern-grid-nudges [data-grid-nudge="left"]{grid-column:1;grid-row:3}.pattern-grid-nudges i{grid-column:2;grid-row:3;font-size:10px}.pattern-grid-nudges [data-grid-nudge="right"]{grid-column:3;grid-row:3}.pattern-grid-nudges [data-grid-nudge="down"]{grid-column:2;grid-row:4}.pattern-grid-panel{padding:14px;background:#fff;border:1px solid #e4e9f0;border-radius:8px}.pattern-grid-panel>header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px}.pattern-grid-panel>header div{display:flex;flex-direction:column;gap:2px}.pattern-grid-panel>header strong{font-size:16px}.pattern-grid-panel>header small{color:#7b8798;font-size:11px}.pattern-grid-panel>header>span{padding:5px 8px;border-radius:6px;background:#eaf7ef;color:#167344;font-size:11px;font-weight:800}.pattern-grid-core-fields{display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px}.pattern-grid-core-fields>label,.pattern-grid-core-fields>div{display:flex;flex-direction:column;gap:5px;color:#667085;font-size:11px}.pattern-grid-core-fields input,.pattern-grid-advanced input{height:46px;box-sizing:border-box;border:1px solid #ccd5e1;border-radius:7px;padding:0 12px;background:#fff;color:#172033;font-size:16px}.pattern-grid-core-fields>div>strong{height:46px;display:flex;align-items:center;padding:0 12px;border:1px solid #e0e6ee;border-radius:7px;background:#f4f6f9;color:#64748b;font-size:14px}.pattern-grid-core-fields>div b{margin-right:4px;color:#172033;font-size:17px}.pattern-grid-advanced{margin-top:10px;border-top:1px solid #edf0f4}.pattern-grid-advanced summary{padding:11px 0 1px;color:#46556a;font-size:12px;font-weight:800;cursor:pointer}.pattern-grid-advanced summary small{margin-left:5px;color:#98a2b3;font-weight:400}.pattern-grid-advanced>div{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:9px}.pattern-grid-advanced label{display:flex;flex-direction:column;gap:5px;color:#667085;font-size:11px}.pattern-grid-status{margin:11px 0 0;color:#64748b;font-size:12px}.is-grid-stage .pattern-import-body{padding-top:12px}.is-grid-stage .pattern-import-foot{flex:0 0 auto}
@media(max-width:600px){.is-grid-stage{max-height:100dvh;height:100dvh;border-radius:0}.is-grid-stage .pattern-import-head{padding-top:10px;padding-bottom:8px}.is-grid-stage .pattern-import-head h2{font-size:19px}.is-grid-stage .pattern-import-head p{margin-top:1px;font-size:11px}.is-grid-stage .pattern-import-steps{display:none}.is-grid-stage .pattern-import-body{padding:10px 10px 6px;min-height:0}.pattern-grid-workbench{gap:9px}.pattern-grid-intro strong{font-size:16px}.pattern-grid-auto{min-height:40px}.pattern-grid-preview{min-height:360px;height:48vh;max-height:520px}.pattern-grid-view-tools{left:7px;top:7px}.pattern-grid-view-tools label{display:none}.pattern-grid-gesture-hint{bottom:7px}.pattern-grid-nudges{right:8px;bottom:32px;transform:scale(.92);transform-origin:right bottom}.pattern-grid-panel{padding:11px}.pattern-grid-panel>header{margin-bottom:9px}.pattern-grid-core-fields{gap:7px}.pattern-grid-core-fields input,.pattern-grid-core-fields>div>strong{height:43px;padding:0 9px}.pattern-grid-status{margin-top:8px}.is-grid-stage .pattern-import-foot{padding:10px 10px calc(10px + env(safe-area-inset-bottom));gap:8px}.is-grid-stage .pattern-import-foot button{min-height:46px;border-radius:8px;font-size:14px}.is-grid-stage .pattern-import-foot .pattern-import-secondary{flex:.72}}
@media(max-width:380px){.pattern-grid-preview{height:44vh;min-height:330px}.pattern-grid-view-tools button{padding:0 7px}.pattern-grid-core-fields input,.pattern-grid-core-fields>div>strong{font-size:14px}}

.pattern-crop-heading{align-items:center}.pattern-crop-heading>div{min-width:0}.pattern-crop-auto{flex:0 0 auto;min-height:34px;border:1px solid #a9c9b3;border-radius:6px;padding:0 10px;background:#f4fbf6;color:#167344;font-size:12px;font-weight:800}.pattern-crop-auto:disabled{opacity:.55;cursor:wait}.pattern-crop-auto-status{margin:-3px 0 7px;color:#5e7467;font-size:12px}.pattern-crop-info{margin:8px 0 0;color:#475467;font-size:12px;font-variant-numeric:tabular-nums;text-align:center}.pattern-import-crop{min-width:1px;min-height:1px}.pattern-grid-crop{border-color:#16a34a;background:rgba(22,163,74,.08)}
.pattern-classification-top{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:14px}.pattern-classification-metrics{display:flex;gap:22px}.pattern-classification-metrics span{display:flex;flex-direction:column}.pattern-classification-metrics b{font-size:22px;color:#16a34a}.pattern-classification-metrics small{font-size:11px;color:#64748b}.pattern-classification-metrics .is-unknown b{color:#d97706}.pattern-classification-tools{display:flex;gap:8px}.pattern-classification-tools button{height:38px;border:0;border-radius:8px;padding:0 12px;background:#edf2f8;color:#475569;font-weight:700}.pattern-classification-list.cards{gap:14px}.pattern-class-card{background:#fff;border:1px solid #e7ebf1;border-radius:8px;padding:14px}.pattern-class-card>header{display:grid;grid-template-columns:28px 32px auto minmax(0,1fr) auto auto;align-items:center;gap:8px;margin-bottom:12px}.pattern-class-card>header>i{width:28px;height:28px;border:1px solid #d8dee8;border-radius:7px}.pattern-class-card>header strong{font-size:18px}.pattern-class-card>header small{color:#64748b;font-weight:700}.pattern-class-card>header em{border-radius:6px;padding:4px 8px;font-size:11px;font-style:normal;font-weight:700}.pattern-class-card>header em.is-ok{background:#dcfce7;color:#15803d}.pattern-class-card>header em.is-diff,.pattern-class-card>header em.is-warn{background:#fef3c7;color:#b45309}.pattern-class-card>header button{border:0;background:transparent;color:#1769e0;font-weight:700}.pattern-group-check{width:24px;height:24px;border:2px solid #d8dee8;border-radius:7px;cursor:pointer}.pattern-cell-grid{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:9px}.pattern-cell-thumb,.pattern-cell-more{aspect-ratio:1;border:2px solid transparent;border-radius:8px;padding:0;overflow:hidden;background:#f3f6fb;cursor:pointer}.pattern-cell-thumb img,.pattern-cell-thumb i{display:block;width:100%;height:100%;object-fit:cover}.pattern-cell-thumb.selected{border-color:#1769e0;box-shadow:0 0 0 2px rgba(23,105,224,.18)}.pattern-cell-thumb.selected:after{content:'✓';position:absolute;right:2px;top:2px;width:18px;height:18px;border-radius:50%;background:#1769e0;color:#fff;font-size:12px;line-height:18px}.pattern-cell-thumb{position:relative}.pattern-cell-more{display:grid;place-items:center;color:#52647c;font-size:16px;font-weight:800;background:#eef3fb}.pattern-class-card.unknown{border-color:#f5d58a}.pattern-class-assign{display:grid;grid-template-columns:auto 92px auto;align-items:center;gap:6px;min-width:260px}.pattern-class-assign span{font-size:11px;color:#64748b}.pattern-class-assign input{width:100%;height:42px;box-sizing:border-box;border:1px solid #cbd5e1;border-radius:8px;padding:0 9px}.pattern-class-assign button{height:42px;border:0;border-radius:8px;background:#1769e0;color:#fff;font-weight:700}.pattern-import-foot:has(.pattern-class-assign){flex-wrap:wrap}.pattern-import-foot:has(.pattern-class-assign)>button{flex:0 1 auto;padding:0 14px}.pattern-import-foot:has(.pattern-class-assign) .pattern-class-assign{margin-left:auto}
@media(max-width:600px){.pattern-classification-top{align-items:stretch;flex-direction:column}.pattern-classification-metrics{justify-content:space-between;padding:0 4px}.pattern-classification-tools{justify-content:flex-end}.pattern-class-card{padding:12px}.pattern-class-card>header{grid-template-columns:26px 30px auto minmax(0,1fr) auto}.pattern-class-card>header em{grid-column:4}.pattern-class-card>header button{grid-column:5;grid-row:1}.pattern-cell-grid{grid-template-columns:repeat(5,minmax(0,1fr));gap:8px}.pattern-import-foot:has(.pattern-class-assign){display:grid;grid-template-columns:repeat(4,1fr);gap:8px}.pattern-import-foot:has(.pattern-class-assign)>button{min-width:0;padding:0 6px;font-size:13px}.pattern-import-foot:has(.pattern-class-assign) .pattern-class-assign{grid-column:1/-1;grid-row:1;grid-template-columns:1fr 90px;width:100%;min-width:0;margin:0}.pattern-import-foot:has(.pattern-class-assign)>[data-action="preview"]{grid-column:4}.pattern-import-foot:has(.pattern-class-assign)>[data-action="back"]{display:none}}

/* 601–899px：分类阶段底部 6 控件复用移动端网格布局（颜色选择独占一行，其余 4 控件一行） */
@media (min-width:601px) and (max-width:899px){
  .pattern-import-foot:has(.pattern-class-assign){display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
  .pattern-import-foot:has(.pattern-class-assign)>button{min-width:0;padding:0 6px;font-size:13px}
  .pattern-import-foot:has(.pattern-class-assign) .pattern-class-assign{grid-column:1/-1;grid-row:1;grid-template-columns:1fr 90px;width:100%;min-width:0;margin:0}
  .pattern-import-foot:has(.pattern-class-assign)>[data-action="preview"]{grid-column:4}
  .pattern-import-foot:has(.pattern-class-assign)>[data-action="back"]{display:none}
}
.pattern-assign-overlay{position:fixed;inset:0;z-index:980;display:flex;align-items:flex-end;justify-content:center;background:rgba(15,23,42,.42);opacity:0;transition:opacity .16s}.pattern-assign-overlay.show{opacity:1}.pattern-assign-sheet{width:min(760px,100%);height:min(82vh,820px);display:grid;grid-template-rows:18px 62px 72px minmax(0,1fr) 88px;background:#fff;border-radius:28px 28px 0 0;overflow:hidden}.pattern-sheet-grip{width:90px;height:7px;border-radius:5px;background:#dbe2ec;margin:12px auto 0}.pattern-assign-sheet>header{display:flex;align-items:center;padding:0 28px}.pattern-assign-sheet>header strong{font-size:22px}.pattern-assign-sheet>header em{color:#1769e0;font-style:normal}.pattern-assign-sheet>header button{margin-left:auto;width:46px;height:46px;border:0;border-radius:50%;background:#f3f6fb;color:#94a3b8;font-size:30px}.pattern-assign-tabs{display:grid;grid-template-columns:1fr 1fr;margin:10px 28px;background:#f1f5fb;border-radius:12px;padding:4px}.pattern-assign-tabs button{border:0;border-radius:10px;background:transparent;color:#64748b;font-size:16px;font-weight:800}.pattern-assign-tabs button.active{background:#fff;color:#1769e0;box-shadow:0 3px 10px rgba(15,23,42,.08)}.pattern-assign-sheet>main{overflow:auto;padding:10px 28px 28px}.pattern-assign-sheet section>b{display:flex;align-items:center;gap:14px;margin:20px 0 12px;color:#64748b}.pattern-assign-sheet section>b:after{content:'';height:1px;flex:1;background:#e7ebf1}.pattern-assign-sheet section>div{display:flex;flex-wrap:wrap;gap:12px}.pattern-assign-sheet [data-code]{height:48px;display:flex;align-items:center;gap:10px;border:1px solid #d8dee8;border-radius:12px;padding:0 14px;background:#fff;color:#334155;font-size:17px;font-weight:800}.pattern-assign-sheet [data-code] i{width:27px;height:27px;border:1px solid rgba(0,0,0,.1);border-radius:7px}.pattern-assign-sheet [data-code].selected{border-color:#1769e0;box-shadow:0 0 0 2px rgba(23,105,224,.14)}.pattern-assign-sheet>footer{display:grid;grid-template-columns:1fr 2fr;gap:20px;padding:14px 28px calc(14px + env(safe-area-inset-bottom));border-top:1px solid #e7ebf1}.pattern-assign-sheet>footer button{border-radius:15px;border:1px solid #1769e0;background:#fff;color:#1769e0;font-size:17px;font-weight:800}.pattern-assign-sheet>footer [data-confirm]{border:0;background:#1769e0;color:#fff}.pattern-assign-sheet button:disabled{background:#e8eef6!important;border-color:#e8eef6!important;color:#9aa8bb!important}
.pattern-all-cells{position:absolute;inset:0;z-index:20;display:grid;grid-template-rows:auto auto auto minmax(0,1fr) auto;background:#f6f8fb;color:#172033}.pattern-all-cells>header{display:grid;grid-template-columns:54px minmax(0,1fr) 60px;align-items:center;gap:12px;padding:18px 24px;background:#1769c9;color:#fff}.pattern-all-cells>header>button{height:46px;border:0;border-radius:12px;background:rgba(255,255,255,.15);color:#fff;font-size:28px;font-weight:800}.pattern-all-cells>header>button:last-child{background:transparent;font-size:16px}.pattern-all-cells>header div{display:flex;flex-direction:column}.pattern-all-cells>header strong{font-size:21px}.pattern-all-cells>header small{color:#bcd5f2}.pattern-all-issue{display:flex;align-items:center;gap:10px;padding:12px 24px;background:#fffbeb}.pattern-all-issue span{margin-right:auto;color:#b45309;font-weight:800}.pattern-all-issue button{height:38px;border:1px solid #f4d66f;border-radius:10px;background:#fff;color:#b45309;padding:0 14px;font-weight:700}.pattern-all-cells>nav{display:flex;gap:9px;padding:12px 16px;overflow:auto;background:#fff;border-bottom:1px solid #e5eaf2}.pattern-all-cells>nav button{flex:0 0 auto;height:46px;display:flex;align-items:center;gap:8px;border:2px solid #e1e7ef;border-radius:11px;padding:0 14px;background:#fff;color:#334155}.pattern-all-cells>nav button.active{border-color:#1769c9;color:#1769c9}.pattern-all-cells>nav i{width:24px;height:24px;border:1px solid #d8dee8;border-radius:6px}.pattern-all-cells>main{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));align-content:start;gap:16px 14px;overflow:auto;padding:22px 24px 120px}.pattern-all-cell{min-width:0;border:0;background:transparent;padding:0}.pattern-all-cell>span{position:relative;display:block;aspect-ratio:1;border:3px solid transparent;border-radius:10px;overflow:hidden;background:#fff}.pattern-all-cell img{width:100%;height:100%;object-fit:cover}.pattern-all-cell em{position:absolute;inset:auto 0 0;padding:3px;background:rgba(30,41,59,.48);color:#fff;font-style:normal;font-weight:800}.pattern-all-cell small{display:block;margin-top:5px;color:#94a3b8}.pattern-all-cell.selected>span{border-color:#1769c9}.pattern-all-cells>footer{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;padding:14px 24px calc(14px + env(safe-area-inset-bottom));background:#fff;border-top:1px solid #e5eaf2}.pattern-all-cells>footer button{height:52px;border:0;border-radius:13px;background:#edf3fb;color:#1769c9;font-size:16px;font-weight:800}.pattern-all-cells>footer button:last-child{background:#1769c9;color:#fff}.pattern-all-cells>footer button:disabled{color:#aab5c4;background:#eff3f8}
.pattern-all-cells.is-busy>main{opacity:.58;pointer-events:none}.pattern-all-cells.is-busy [data-all-status]{color:#1769c9}.pattern-all-issue [data-all-status]{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pattern-confidence-order{flex:0 0 auto;border:1px solid #f0d36b;border-radius:6px;padding:5px 8px;background:#fff;color:#9a5b08;font-size:11px;font-weight:800}.pattern-all-cell>span:after{content:'';position:absolute;inset:0;border:2px solid transparent;border-radius:7px;pointer-events:none}.pattern-all-cell.confidence-low>span:after{border-color:#dc5a45}.pattern-all-cell.confidence-medium>span:after{border-color:#e5a52f}.pattern-all-cell.confidence-high>span:after{border-color:#21a66a}.pattern-all-cell.confidence-low em{background:#b9382b}.pattern-all-cell.confidence-medium em{background:#a96812}.pattern-all-cell.confidence-high em{background:rgba(30,41,59,.54)}.pattern-all-cell.confidence-low small{color:#a33b2c;font-weight:800}.pattern-all-cell.selected>span:after{border-color:#1769c9;box-shadow:inset 0 0 0 2px #fff}
@media(max-width:600px){.pattern-all-cells{grid-template-rows:auto auto auto minmax(0,1fr) auto;background:#f4f6f9}.pattern-all-cells>header{grid-template-columns:44px minmax(0,1fr) 54px;gap:10px;padding:10px 14px}.pattern-all-cells>header>button{height:42px;border-radius:8px}.pattern-all-cells>header strong{font-size:19px}.pattern-all-cells>header small{font-size:11px}.pattern-all-issue{gap:7px;padding:9px 14px}.pattern-all-issue button{height:36px;border-radius:7px;padding:0 11px}.pattern-all-cells>nav{gap:7px;padding:9px 12px}.pattern-all-cells>nav button{height:42px;border-width:1px;border-radius:8px;padding:0 11px}.pattern-all-cells>main{grid-template-columns:repeat(5,minmax(0,1fr));gap:12px 9px;padding:14px 12px 94px}.pattern-all-cell>span{border-width:2px;border-radius:8px}.pattern-all-cell em{padding:4px 2px;font-size:14px}.pattern-all-cell small{margin-top:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:10px}.pattern-all-cells>footer{gap:8px;padding:10px 12px calc(10px + env(safe-area-inset-bottom));box-shadow:0 -4px 16px rgba(15,23,42,.08)}.pattern-all-cells>footer button{height:48px;border-radius:8px;font-size:15px}}
@media(max-width:380px){.pattern-confidence-order{display:none}.pattern-all-issue{padding-left:10px;padding-right:10px}.pattern-all-issue button{padding:0 8px}.pattern-all-cells>main{gap:10px 7px;padding-left:9px;padding-right:9px}}
.pattern-crop-auto-status{height:34px;overflow:hidden;line-height:17px}

/* Apple-style classification review: neutral hierarchy, compact evidence, one clear primary action. */
.pattern-all-cells{background:var(--apple-bg,#f5f5f7);color:var(--apple-label,#1d1d1f)}
.pattern-all-cells>header{grid-template-columns:44px minmax(0,1fr) 58px;min-height:64px;padding:8px 16px;border-bottom:.5px solid var(--apple-separator,rgba(0,0,0,.08));background:rgba(250,250,252,.9);color:var(--apple-label,#1d1d1f);backdrop-filter:saturate(180%) blur(20px);-webkit-backdrop-filter:saturate(180%) blur(20px)}
.pattern-all-cells>header>button{height:40px;border-radius:50%;background:var(--apple-fill,rgba(118,118,128,.12));color:var(--apple-blue,#0071e3);font-size:25px;font-weight:600}.pattern-all-cells>header>button:last-child{border-radius:10px;background:transparent;color:var(--apple-blue,#0071e3);font-size:15px}.pattern-all-cells>header strong{font-size:19px;font-weight:700;letter-spacing:0}.pattern-all-cells>header small{margin-top:2px;color:var(--apple-secondary,#6e6e73);font-size:12px}
.pattern-all-issue{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:8px;padding:9px 16px;border-bottom:.5px solid var(--apple-separator,rgba(0,0,0,.08));background:rgba(255,255,255,.82);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px)}.pattern-all-issue span{min-width:0;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--apple-label,#1d1d1f);font-size:14px;font-weight:600}.pattern-confidence-order{border:0;border-radius:999px;padding:5px 9px;background:rgba(255,149,0,.12);color:#a45c00;font-size:11px;font-weight:700;white-space:nowrap}.pattern-all-pager{display:grid;grid-template-columns:repeat(2,72px);gap:6px;flex:0 0 auto}.pattern-all-issue .pattern-all-pager button{width:72px;height:34px;border:0;border-radius:9px;padding:0;background:var(--apple-fill,rgba(118,118,128,.12));color:var(--apple-blue,#0071e3);font-size:13px;font-weight:600;white-space:nowrap}.pattern-all-back{position:relative;display:grid;place-items:center;width:40px;padding:0}.pattern-all-back:before{content:'';width:11px;height:11px;border-left:2.5px solid currentColor;border-bottom:2.5px solid currentColor;transform:translateX(2px) rotate(45deg);border-radius:1px}
.pattern-all-cells>nav{gap:8px;padding:10px 12px;border-bottom:.5px solid var(--apple-separator,rgba(0,0,0,.08));background:var(--apple-surface,#fff);scrollbar-width:none}.pattern-all-cells>nav::-webkit-scrollbar{display:none}.pattern-all-cells>nav button{height:42px;gap:7px;border:.5px solid var(--apple-separator,rgba(0,0,0,.08));border-radius:11px;padding:0 12px;background:var(--apple-surface,#fff);color:var(--apple-label,#1d1d1f);font-size:14px}.pattern-all-cells>nav button.active{border-color:rgba(0,113,227,.25);background:var(--apple-blue-light,rgba(0,113,227,.1));color:var(--apple-blue,#0071e3);box-shadow:none}.pattern-all-cells>nav i{width:22px;height:22px;border:.5px solid var(--apple-separator,rgba(0,0,0,.08));border-radius:7px}
.pattern-all-cells>main{gap:14px 10px;padding:16px 12px 104px}.pattern-all-cell{border-radius:12px;text-align:left}.pattern-all-cell>span{border:0;border-radius:11px;background:var(--apple-surface,#fff);box-shadow:0 1px 2px rgba(0,0,0,.05),0 4px 14px rgba(0,0,0,.04)}.pattern-all-cell>span:after{display:none}.pattern-all-cell img{border-radius:11px}.pattern-all-cell em{inset:6px 6px auto auto;width:auto;min-width:38px;border-radius:999px;padding:3px 7px;background:rgba(29,29,31,.72);font-size:12px;line-height:18px;text-align:center;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}.pattern-all-cell small{margin-top:5px;padding:0 2px;color:var(--apple-tertiary,#86868b);font-size:10px}.pattern-all-cell.confidence-low>span:before,.pattern-all-cell.confidence-medium>span:before{content:'';position:absolute;z-index:2;left:7px;top:7px;width:8px;height:8px;border:2px solid #fff;border-radius:50%;box-shadow:0 1px 3px rgba(0,0,0,.2)}.pattern-all-cell.confidence-low>span:before{background:var(--apple-red,#ff3b30)}.pattern-all-cell.confidence-medium>span:before{background:var(--apple-orange,#ff9500)}.pattern-all-cell.confidence-low em{background:rgba(200,38,31,.86)}.pattern-all-cell.confidence-medium em{background:rgba(180,101,0,.82)}.pattern-all-cell.confidence-high em{background:rgba(29,29,31,.68)}.pattern-all-cell.confidence-low small{color:var(--apple-red,#ff3b30);font-weight:600}.pattern-all-cell.selected>span{border:3px solid var(--apple-blue,#0071e3);box-shadow:0 0 0 3px rgba(0,113,227,.14)}.pattern-all-cell.selected>span:after{display:block;content:'✓';position:absolute;z-index:4;inset:6px auto auto 6px;width:23px;height:23px;border:0;border-radius:50%;background:var(--apple-blue,#0071e3);color:#fff;font-size:14px;font-weight:700;line-height:23px;text-align:center;box-shadow:0 1px 4px rgba(0,0,0,.18)}
.pattern-all-cells>footer{gap:8px;padding:10px 12px calc(10px + env(safe-area-inset-bottom));border-top:.5px solid var(--apple-separator,rgba(0,0,0,.08));background:rgba(250,250,252,.9);box-shadow:0 -8px 24px rgba(0,0,0,.05);backdrop-filter:saturate(180%) blur(20px);-webkit-backdrop-filter:saturate(180%) blur(20px)}.pattern-all-cells>footer button{height:48px;border-radius:12px;background:var(--apple-fill,rgba(118,118,128,.12));color:var(--apple-blue,#0071e3);font-size:15px;font-weight:600}.pattern-all-cells>footer button:last-child{background:var(--apple-blue,#0071e3);color:#fff}.pattern-all-cells>footer button:disabled{opacity:.38;color:var(--apple-secondary,#6e6e73);background:var(--apple-fill,rgba(118,118,128,.12))}
@media(max-width:600px){.pattern-all-cells>header{grid-template-columns:40px minmax(0,1fr) 54px;min-height:60px;padding:7px 12px}.pattern-all-cells>header>button{height:38px}.pattern-all-cells>header strong{font-size:18px}.pattern-all-issue{grid-template-columns:minmax(0,1fr) auto;padding:8px 12px}.pattern-confidence-order{display:none}.pattern-all-pager{grid-template-columns:repeat(2,68px)}.pattern-all-issue .pattern-all-pager button{width:68px;height:34px}.pattern-all-cells>nav{padding:9px 10px}.pattern-all-cells>main{gap:13px 9px;padding:14px 10px 92px}.pattern-all-cell em{font-size:11px}.pattern-all-cells>footer{padding-left:10px;padding-right:10px}.pattern-all-cells>footer button{height:46px}}
@media(max-width:380px){.pattern-all-issue{padding-left:9px;padding-right:9px}.pattern-all-pager{grid-template-columns:repeat(2,62px);gap:5px}.pattern-all-issue .pattern-all-pager button{width:62px;font-size:12px}.pattern-all-cells>main{gap:11px 7px;padding-left:8px;padding-right:8px}}
@media(min-width:700px){.pattern-all-cells{inset:2vh calc(50% - 380px);border-radius:20px;overflow:hidden;box-shadow:var(--apple-shadow-modal,0 20px 60px rgba(0,0,0,.2))}.pattern-all-cells>main{grid-template-columns:repeat(7,minmax(0,1fr))}}

/* 图纸导入向导交互反馈 */
.pattern-import-back:focus-visible,.pattern-import-close:focus-visible,.pattern-import-foot button:focus-visible,.pattern-import-body button:focus-visible,.pattern-import-body input:focus-visible,.pattern-import-body select:focus-visible,.pattern-import-body summary:focus-visible{outline:3px solid rgba(23,105,224,.35);outline-offset:2px}
.pattern-import-foot button:disabled,.pattern-import-body button:disabled{opacity:.55;cursor:not-allowed}
.pattern-image-loading{min-height:300px;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:10px;color:#344054}.pattern-image-loading strong{font-size:20px;color:#101828}.pattern-image-loading span{max-width:min(520px,90%);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#667085;font-size:14px}.pattern-image-loading small{color:#98a2b3;line-height:1.5}.pattern-import-spinner{display:block;width:38px;height:38px;margin-bottom:6px;border:4px solid #dbe8fb;border-top-color:#1769e0;border-radius:50%;animation:pattern-import-spin .8s linear infinite}@keyframes pattern-import-spin{to{transform:rotate(360deg)}}
.pattern-import-progress[aria-busy="true"] .pattern-progress-track{box-shadow:0 0 0 3px rgba(23,105,224,.08)}
@media(max-width:600px){.pattern-import-head>div{min-width:0}.pattern-import-head h2,.pattern-import-head p{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pattern-import-steps{scroll-snap-type:x proximity}.pattern-import-steps span{scroll-snap-align:center}.pattern-import-copy strong{font-size:18px}.pattern-import-copy span{line-height:1.45}}
@media(prefers-reduced-motion:reduce){.pattern-import-overlay,.pattern-import-sheet,.pattern-progress-track i,.pattern-import-spinner{transition:none;animation-duration:1.5s}}

/* Reference image color picker */
.ref-color-picker{position:fixed;inset:0;z-index:520;display:grid;grid-template-rows:auto minmax(220px,1fr) auto;background:#f7f7f9;color:var(--t);opacity:0;visibility:hidden;transition:opacity .16s linear;overscroll-behavior:none}
.ref-color-picker.show{opacity:1;visibility:visible}
.ref-picker-head{min-height:calc(58px + var(--safe-t));padding:var(--safe-t) 16px 0;display:grid;grid-template-columns:44px auto minmax(0,1fr);align-items:center;gap:10px;background:var(--white);border-bottom:.5px solid var(--bd)}
.ref-picker-head>strong{font-size:18px}
.ref-picker-layer-name{font-size:12px;color:var(--t3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:right}
.ref-picker-icon-btn{width:40px;height:40px;border:0;background:transparent;color:var(--t);display:grid;place-items:center}
.ref-picker-icon-btn .icon{width:24px;height:24px}
.ref-picker-stage{position:relative;min-width:0;min-height:0;overflow:hidden;background:#ececef;touch-action:none;user-select:none;-webkit-user-select:none;cursor:crosshair}
.ref-picker-stage.space-pan-ready,.ref-picker-stage.is-panning{cursor:grab}
.ref-picker-stage.is-panning{cursor:grabbing}
.ref-picker-canvas{position:absolute;inset:0;display:block}
.ref-picker-crosshair{position:absolute;width:52px;height:52px;transform:translate(-50%,-50%);pointer-events:none;opacity:0;filter:drop-shadow(0 1px 1px rgba(255,255,255,.9))}
.ref-picker-crosshair.visible{opacity:1}
.ref-picker-crosshair:before,.ref-picker-crosshair:after{content:"";position:absolute;background:#ef4444}
.ref-picker-crosshair:before{left:25.5px;top:-999px;width:1px;height:2048px}
.ref-picker-crosshair:after{top:25.5px;left:-999px;width:2048px;height:1px}
.ref-picker-crosshair i{position:absolute;inset:17px;border:2px solid #ef4444;border-radius:50%}
.ref-picker-crosshair.locked i{inset:15px;border-width:3px;background:rgba(239,68,68,.14);box-shadow:0 0 0 3px rgba(255,255,255,.86)}
.ref-picker-stage.sample-locked{cursor:pointer}
.ref-picker-results{min-width:0;overflow:hidden;background:var(--white);border-top:.5px solid var(--bd);padding:14px 16px calc(14px + var(--safe-b));box-shadow:0 -8px 24px rgba(0,0,0,.06)}
.ref-picker-source{display:flex;align-items:center;gap:12px;min-height:56px}
.ref-picker-source>span:last-child{display:flex;flex-direction:column;gap:3px;min-width:0}
.ref-picker-source-swatch{width:48px;height:48px;flex:0 0 auto;border:1px solid var(--bd);border-radius:7px;background-size:12px 12px!important}
.ref-picker-rgba{font-size:16px;white-space:nowrap}
.ref-picker-hex{font-size:13px;color:var(--t3)}
.ref-picker-match-head{display:flex;align-items:baseline;gap:10px;margin:10px 0 8px}
.ref-picker-match-head strong{font-size:15px}
.ref-picker-match-head span{font-size:12px;color:var(--t3)}
.ref-picker-matches{display:grid;grid-template-columns:repeat(6,minmax(58px,1fr));gap:8px;overflow-x:auto;padding-bottom:2px}
.ref-picker-match{height:82px;min-width:58px;padding:6px;border:1px solid var(--bd);border-radius:7px;background:#f8f8fa;color:var(--t);display:grid;grid-template-rows:40px auto auto;align-items:center;text-align:center}
.ref-picker-match.best{border-color:var(--yellow);background:var(--yellow-light)}
.ref-picker-match:active{transform:scale(.96)}
.ref-picker-match-swatch{width:100%;height:36px;border-radius:5px;border:1px solid rgba(0,0,0,.08)}
.ref-picker-match strong{font-size:13px;line-height:16px}
.ref-picker-match small{font-size:11px;color:var(--t3);line-height:13px}
.layer-ctrl-btn.ref-pick-color{color:#0891b2}
@media(max-width:600px){.ref-picker-matches{grid-template-columns:repeat(6,72px)}.ref-picker-results{padding-inline:12px}.ref-picker-rgba{font-size:14px}.ref-picker-stage{min-height:260px;cursor:crosshair}.ref-picker-stage.relative-crosshair:after{content:"单指取色 · 双指缩放拖动";position:absolute;left:50%;bottom:12px;transform:translateX(-50%);padding:5px 10px;border-radius:999px;background:rgba(0,0,0,.58);color:#fff;font-size:11px;pointer-events:none;white-space:nowrap}.ref-picker-stage.is-pinching:after{opacity:.55}}
@media(min-width:900px){.ref-color-picker{grid-template-columns:minmax(0,1fr) 360px;grid-template-rows:auto minmax(0,1fr)}.ref-picker-head{grid-column:1/-1}.ref-picker-results{grid-column:2;grid-row:2;border-top:0;border-left:.5px solid var(--bd);box-shadow:-8px 0 24px rgba(0,0,0,.05);overflow:auto}.ref-picker-stage{grid-column:1;grid-row:2}.ref-picker-stage:after{content:"滚轮缩放 · 空格/中键拖动 · 0重置";position:absolute;left:50%;bottom:16px;transform:translateX(-50%);padding:6px 12px;border-radius:999px;background:rgba(0,0,0,.52);color:#fff;font-size:12px;pointer-events:none;white-space:nowrap}.ref-picker-stage.is-panning:after{content:"拖动中";opacity:.7}.ref-picker-matches{grid-template-columns:repeat(3,1fr)}}

/* ── REF 内联变换面板 ── */
.ref-inline-panel {
  padding: 8px 8px 6px 42px;
  border-top: 0.5px dashed var(--bd);
  background: rgba(99,102,241,0.03);
  border-radius: 0 0 8px 8px;
  margin-top: -3px;
  margin-bottom: 3px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  animation: fadeIn 0.15s ease-out;
}
.ref-inline-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.ref-inline-lock-note {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 4px 6px;
  border-radius: 5px;
  background: rgba(255,149,0,0.08);
  color: #9a6200;
  font-size: 10px;
  font-weight: 600;
}
.ref-inline-lock-note .icon { width: 12px; height: 12px; flex-shrink: 0; }
.ref-inline-panel :is(input, button):disabled { opacity: 0.38; cursor: not-allowed; }
.ref-inline-panel .ref-inline-slider:disabled::-webkit-slider-thumb { cursor: not-allowed; }
.layer-sheet-op-slider:disabled { opacity: 0.38; cursor: not-allowed; }
.ref-inline-label {
  font-size: 9px;
  font-weight: 500;
  color: var(--t3);
  min-width: 24px;
  flex-shrink: 0;
}
.ref-inline-slider {
  flex: 1;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bd);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.ref-inline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--white);
  border: 0.5px solid var(--bd);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.ref-inline-num {
  width: 32px;
  padding: 1px 2px;
  border: 0.5px solid var(--bd);
  border-radius: 4px;
  font-size: 9px;
  text-align: center;
  outline: none;
  background: var(--bg);
  color: var(--t);
}
.ref-inline-unit {
  font-size: 8px;
  color: var(--t3);
  min-width: 8px;
}
/* 旋转/翻转按钮 */
.ref-transform-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 3px 2px;
  border: 0.5px solid var(--bd);
  border-radius: 5px;
  background: var(--fill-tertiary);
  color: var(--t2);
  font-size: 9px;
  cursor: pointer;
  transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
  min-height: 24px;
}
.ref-transform-btn:active { transform: scale(0.92); background: var(--fill-primary); }
.ref-transform-btn:hover { background: var(--fill-secondary); }
.ref-inline-actions {
  display: flex;
  gap: 3px;
  margin-top: 1px;
}
.ref-inline-btn {
  flex: 1;
  padding: 4px 6px;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-align: center;
  transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
  min-height: 22px;
}
.ref-inline-btn:active { transform: scale(0.95); }
.ref-inline-btn-primary { background: rgba(99,102,241,0.12); color: #6366f1; }
.ref-inline-btn-primary:active { background: rgba(99,102,241,0.2); }
.ref-inline-btn-secondary { background: var(--fill-tertiary); color: var(--t2); }
.ref-inline-btn-secondary:active { background: var(--fill-primary); }

/* v10 全站弹层与控件密度统一 */
.modal-overlay,.sheet-overlay{background:rgba(20,20,24,.34);-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}
.modal-panel{max-width:calc(100vw - 24px);border:1px solid color-mix(in srgb,var(--bd) 82%,transparent);border-radius:16px;overflow:hidden}
.modal-head{min-height:48px;padding:10px 14px;border-bottom:.5px solid var(--bd)}
.modal-head>span,.sheet-title{display:flex;align-items:center;justify-content:center;gap:6px}
.modal-head>span{font-size:15px}
.modal-x,.strategy-close{width:30px;height:30px;background:var(--fill-secondary);color:var(--t2);font-size:20px;line-height:1}
.modal-body{padding:10px 14px 14px}
.modal-footer{padding:10px 14px 14px;border-top:.5px solid var(--bd)}
.modal-footer .primary-btn{min-height:42px!important;padding:9px 14px!important;font-size:14px!important;border-radius:10px}
.sheet-panel{padding:7px 14px calc(12px + var(--safe-b));border-radius:18px 18px 0 0}
.sheet-handle{margin-bottom:10px;background:var(--t4)}
.sheet-title{font-size:15px;margin-bottom:10px}
.sheet-btn{display:flex;align-items:center;justify-content:flex-start;gap:9px;min-height:40px;padding:9px 11px;margin-bottom:5px;text-align:left;border-radius:10px;background:var(--fill-secondary)}
.sheet-btn.danger{color:#c9342f;background:rgba(255,59,48,.08)}
.sheet-cancel{min-height:40px;padding:9px;margin-top:6px}
.modal-head .icon,.sheet-title .icon{color:#9a7200}
@media(max-width:420px){.modal-panel{width:calc(100vw - 20px);max-width:none}.modal-body{max-height:62vh}.modal-head{min-height:44px}.sheet-panel{max-height:82vh}}
/* v11 Android/WebView 性能模式：避免全屏实时模糊参与画布合成 */
@media (hover:none),(pointer:coarse){
  body :where(.modal-overlay,.sheet-overlay,.layer-panel-overlay,.wb-export-modal){backdrop-filter:none!important;-webkit-backdrop-filter:none!important}
  body :where(.modal-panel,.sheet-panel,.layer-panel,.drawer,.wb-export-modal-card){backdrop-filter:none!important;-webkit-backdrop-filter:none!important;background:var(--white)!important}
  .modal-panel{transition:transform .18s var(--ease-out),opacity .15s linear;will-change:auto}
  .sheet-panel{animation-duration:.22s}
  .brand-btn,.topbar-size,.topbar-list,.topbar-undo,.float-btn{transition-duration:.08s!important}
}
@media (prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}

/* 图层名称 inline 编辑 */
.layer-name-input { font-size: 12px; font-weight: 600; }

/* ===== 图层操作 Bottom Sheet — Apple HIG 精细化 ===== */
.layer-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 210;
  background: rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.layer-sheet-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* Panel 在 overlay 内部（fix 了子代选择器 bug），使用 absolute 锚定底部 */
.layer-sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border-radius: 18px 18px 0 0;
  padding: 0 16px calc(12px + var(--safe-b));
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 70vh;
  overflow-y: auto;
}
.layer-sheet-overlay.show .layer-sheet-panel {
  transform: translateY(0);
}

/* 拖拽指示条 — 更细 */
.layer-sheet-drag {
  width: 36px;
  height: 3px;
  background: var(--t4);
  border-radius: 999px;
  margin: 8px auto 10px;
}

/* 头部 — 更紧凑 */
.layer-sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.layer-sheet-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--t);
  letter-spacing: -0.2px;
}
.layer-sheet-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--fill-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  color: var(--t3);
  transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
  flex-shrink: 0;
}
.layer-sheet-close:active { transform: scale(0.88); background: var(--fill-primary); }

/* 不透明度滑块 — 紧凑 */
.layer-sheet-opacity {
  margin-bottom: 12px;
}
.layer-sheet-op-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 6px;
}
.layer-sheet-op-label { color: var(--t); font-weight: 500; }
.layer-sheet-op-value { color: var(--t3); font-variant-numeric: tabular-nums; }
.layer-sheet-op-slider {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--fill-tertiary);
  outline: none;
  cursor: pointer;
}
.layer-sheet-op-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--white);
  border: 0.5px solid var(--bd);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

/* 名称编辑行 */
.layer-sheet-rename-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  align-items: center;
}
.layer-sheet-rename-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--bd);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  outline: none;
  background: var(--bg);
  color: var(--t);
}
.layer-sheet-rename-input:focus { border-color: var(--yellow); }
.layer-sheet-rename-btn {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  background: var(--yellow);
  color: var(--t);
  cursor: pointer;
  white-space: nowrap;
}
.layer-sheet-rename-btn:active { transform: scale(0.95); }

/* 功能卡片网格 — Apple HIG 药丸卡片 */
.layer-sheet-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.layer-sheet-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.layer-sheet-card {
  background: var(--fill-tertiary);
  border-radius: 12px;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
  border: none;
  font-family: inherit;
}
.layer-sheet-card:active { transform: scale(0.94); background: var(--fill-primary); }
.sheet-card-icon { font-size: 18px; line-height: 1; }
.layer-sheet-card span { font-size: 10px; font-weight: 500; color: var(--t); line-height: 1.2; }
.layer-sheet-card.danger span { color: #FF3B30; }

/* ===== 移动端响应式适配 ===== */

/* 小屏手机：底部胶囊紧凑 */
@media(max-width:480px){
  .bottom-area{bottom:6px}
  .float-capsule{padding:3px 2px;border-radius:18px;gap:2px}
  .float-btn{padding:0 8px;height:32px;font-size:11px}
  .float-btn.icon-only{width:32px;height:32px}
  .float-play{width:34px;height:34px}
  .float-set{width:32px;height:32px}
  .float-stat{padding:3px 6px;font-size:11px;min-height:30px}
  .float-left{gap:2px;padding-left:2px}
  .float-right{padding-right:2px}
  .float-tools{gap:1px}
  .float-row{min-height:32px}
  .float-label{font-size:10px}
  .float-color-wrap{max-height:200px;padding:6px 8px;border-radius:var(--r-xl)}
  .float-color-wrap .swatch-item{width:26px;height:26px;border-radius:5px}
  .layer-panel-overlay{width:70vw;right:8px;top:44px}
  .layer-panel-head{padding:10px 12px 6px}
  .layer-panel-title{font-size:14px}
  .layer-item{padding:5px 6px;gap:5px}
  .layer-thumb-wrap{width:24px;height:24px}
  .layer-thumb{width:24px;height:24px}
  .layer-name{font-size:11px}
  .layer-ctrl-btn{width:22px;height:22px}
  .layer-more-btn{width:22px;height:22px;font-size:13px}
  .topbar{padding:0 4px;height:40px}
  .brand-btn{padding:0 6px;height:30px;font-size:11px}
  .brand-btn span{max-width:60px;font-size:11px}
  .topbar-save,.topbar-list{width:30px;height:30px}
  .topbar-undo{width:28px;height:28px}
  .topbar-center{gap:1px}
  .empty-title{font-size:20px}
  .empty-desc{font-size:13px}
  .modal-panel{max-width:92vw}
}

/* 极小屏（iPhone SE 等） */
@media(max-width:380px){
  .float-capsule{max-width:calc(100vw - 10px);border-radius:16px}
  .float-btn{padding:0 6px;height:28px;font-size:10px}
  .float-btn.icon-only{width:28px;height:28px}
  .float-play{width:30px;height:30px}
  .float-set{width:28px;height:28px}
  .float-label{display:none} /* 极小屏隐藏文字标签，仅保留图标 */
  .float-stat{font-size:10px;padding:2px 5px;min-height:26px}
  .float-row{min-height:28px}
  .layer-panel-overlay{width:75vw;right:4px;top:40px}
  .layer-item{padding:4px 5px;gap:4px}
  .layer-name{font-size:10px}
  .layer-meta-op,.layer-meta-count{font-size:8px}
  .layer-ctrl-btn{width:20px;height:20px}
  .layer-more-btn{width:20px;height:20px;font-size:12px}
  .topbar{height:36px}
}

/* 平板：预留更多内边距 */
@media(min-width:768px){
  .canvas-area{padding:24px}
  .float-capsule{max-width:min(720px,90vw)}
}

/* 大屏桌面：限制胶囊最大宽度 */
@media(min-width:1024px){
  .float-capsule{max-width:800px;padding:6px 8px;border-radius:28px}
  .float-btn{padding:0 16px;height:42px;font-size:13px}
  .float-stat{padding:5px 14px;font-size:13px}
  .float-play{width:44px;height:44px}
}

/* ===== 018. ★ 全站交互反馈增强 — 确保每个可点元素都有反馈 =====
 *
 *  原则：所有 cursor:pointer 的元素必须有 :active 反馈
 *  ① 桌面 hover 色 — 仅 desktop 生效（mobile hover 无副作用）
 *  ② 按压反馈 — transform:scale + bg 变化
 *  ③ 滑块拖动增强 — thumb 按压放大 + 轨道高亮
 *  ④ 触摸高亮抑制 + 自定义
 *  ⑤ 禁用态统一
 *  ⑥ 键盘焦点增强
 *  ============================================================ */

/* ── 统一 transition 缺失补丁 ── */
.settings-adv-toggle,
.export-more-toggle,
.drawer-close,
.sheet-btn,
.sheet-cancel,
.export-btn,
.ep-btn,
.layer-sheet-card,
.ref-inline-btn,
.layer-footer-chip,
.brand-row,
.drawing-item-act,
.stats-act-btn,
#textToolConfirm,
#textToolCancel,
#saveNameConfirm,
#drawingListClose,
#cropResetBtn,
#cropCancelBtn,
#cropConfirmBtn,
#inputDialogCancel,
#inputDialogConfirm,
.cp-open-picker-btn {
  transition: all 0.12s var(--ease-out) !important;
  backface-visibility: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ── 桌面 hover 反馈（仅非触摸设备生效） ── */
@media (hover: hover) {
  /* 通用按钮 */
  .primary-btn:hover { background: var(--yellow-d); box-shadow: 0 2px 12px rgba(255,212,59,0.25); }
  .primary-btn:disabled:hover { background: var(--yellow); box-shadow: none; }
  .secondary-btn:hover { background: var(--fill-tertiary); border-color: var(--t4); }
  .secondary-btn:active:hover { background: var(--bg); }
  .float-btn:hover { background: var(--fill-tertiary); }
  .float-btn.active:hover { background: var(--yellow); box-shadow: 0 1px 6px rgba(255,212,59,0.35); }
  .float-btn.icon-only:hover { background: var(--fill-tertiary); }
  .float-stat:hover { background: var(--fill-tertiary); }
  .brand-btn:hover { background: var(--yellow-d); box-shadow: 0 2px 8px rgba(255,212,59,0.3); }
  .topbar-size:hover { background: var(--fill-primary); }
  .topbar-save:hover { background: var(--yellow-d); }
  .topbar-list:hover { background: var(--fill-primary); }
  .chip:hover { background: var(--fill-tertiary); }
  .chip:has(input:checked):hover { background: var(--yellow-light); }
  .chip-sm:hover { background: var(--fill-tertiary); }
  .series-tab:hover { background: var(--fill-primary); }
  .series-tab.active:hover { background: var(--yellow); }
  .modal-x:hover { background: var(--fill-tertiary); }
  .sheet-btn:hover { background: var(--fill-tertiary); }
  .sheet-cancel:hover { background: var(--fill-tertiary); }
  .drawer-close:hover { background: var(--fill-tertiary); }
  .drawing-item:hover { background: var(--fill-tertiary); }
  .brand-row:hover { background: var(--fill-tertiary); }
  .brand-row.active:hover { background: var(--yellow-light); }
  .stats-item:hover { background: var(--fill-tertiary); }
  .layer-sheet-card:hover { background: var(--fill-primary); }
  .export-toggle:hover { background: var(--fill-tertiary); }
  .export-fopt:hover { background: var(--fill-tertiary); }
  .export-res-opt:hover { background: var(--fill-tertiary); }
  .export-btn-row .export-btn:hover { transform: scale(0.98); }
  .export-preview-btn:hover { background: var(--fill-tertiary); }
  .export-download-btn:hover { background: var(--yellow-d); }
  .ep-btn-back:hover { background: rgba(255,255,255,0.2); }
  .ep-btn-download:hover { background: var(--yellow-d); }
  .preview-3d-toggle:hover { background: rgba(255,255,255,0.2); }
  .drawing-item-act:hover { background: var(--fill-secondary); }
  .stats-act-btn:hover { background: var(--fill-secondary); }
  .settings-adv-toggle:hover { color: var(--t); }
  .layer-footer-chip:hover { background: var(--fill-primary); }
  .layer-ctrl-btn:hover { background: var(--fill-tertiary); }
  .ref-inline-btn:hover { transform: scale(0.96); }
  .layer-sheet-close:hover { background: var(--fill-primary); }
  .brand-field-btn:hover { border-color: var(--t3); }
  .cp-open-picker-btn:hover { border-color: var(--t3); background: var(--fill-tertiary); }
  .fld-sel:hover { border-color: var(--t3); }
  .fld-inp:hover { border-color: var(--t3); }
  .color-strip-input:hover { border-color: var(--t3); }
  #rpSearch:hover { border-color: var(--t3); }
}

/* ── 缺失的按压（:active）反馈补丁 ── */
/* 设置弹窗高级选项折叠 */
.settings-adv-toggle:active { opacity: 0.6; transform: translateX(2px); }
/* 颜色选择器搜索输入聚焦 */
.drawer-search input:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-alpha); }
/* 色卡面板搜索聚焦 */
.color-strip-input:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-alpha); }
#textToolSheet .sheet-panel{box-sizing:border-box;max-width:min(500px,100vw)}
/* 文字工具 */
.text-tool-preview{position:relative;display:flex;align-items:center;justify-content:center;height:112px;margin:0 0 14px;overflow:auto;border:1px solid var(--bd);border-radius:var(--r-md);background-color:var(--bg);background-image:linear-gradient(var(--bd) 1px,transparent 1px),linear-gradient(90deg,var(--bd) 1px,transparent 1px);background-size:12px 12px}
.text-tool-preview canvas{display:block;max-width:none;image-rendering:pixelated}
.text-tool-preview-empty{position:absolute;color:var(--t3);font-size:12px;pointer-events:none}
#textToolInput:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-alpha); }
#textSizeNum:focus,
#textSpacingNum:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-alpha); outline: none; }
/* 保存命名输入聚焦 */
#saveNameInput:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-alpha); outline: none; }
/* 图纸弹窗关闭按钮 */
#drawingListClose:active { background: var(--fill-tertiary); }
#drawingListClose:hover { background: var(--fill-tertiary); }
/* 通用输入弹窗聚焦 */
#inputDialogInput:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-alpha); }
/* 裁剪按钮 */
#cropResetBtn:active { transform: scale(0.96); background: var(--fill-tertiary); }
#cropCancelBtn:active { transform: scale(0.96); background: var(--fill-tertiary); }
#cropConfirmBtn:active { transform: scale(0.96); background: var(--yellow-d); }
/* 文字工具确认/取消 */
#textToolConfirm:active { transform: scale(0.97); background: var(--yellow-d); }
#textToolCancel:active { transform: scale(0.97); background: var(--fill-tertiary); }
/* 保存按钮 */
#saveNameConfirm:active { transform: scale(0.97); background: var(--yellow-d); }
/* 通用弹窗按钮 */
#inputDialogCancel:active { transform: scale(0.97); background: var(--fill-tertiary); }
#inputDialogConfirm:active { transform: scale(0.97); background: var(--yellow-d); }
/* sheet-btn 增强按压 */
.sheet-btn:active { background: var(--fill-tertiary); }
/* layer-sheet-card 增强 */
.layer-sheet-card:active { transform: scale(0.94); background: var(--fill-primary); }
/* 品牌行按压 */
.brand-row:active { background: var(--fill-tertiary); }
/* 图纸操作按钮按压增强 */
.drawing-item-act:active { transform: scale(0.88); background: var(--fill-secondary); }
/* 统计操作按钮按压增强 */
.stats-act-btn:active { background: var(--fill-secondary); transform: scale(0.88); }
/* 颜色替换选择器色块按压 */
.rp-color:active { transform: scale(0.88); }
/* 设置品牌字段按钮按压增强 */
.brand-field-btn:active { background: var(--fill-tertiary); border-color: var(--t3); }
/* 导出按钮增强 */
.export-btn-row .export-btn:active { background: var(--fill-tertiary); }
.export-preview-btn:active { background: var(--fill-primary); }
.export-download-btn:active { background: var(--yellow-d); }
.ep-btn-back:active { background: rgba(255,255,255,0.25); }
.ep-btn-download:active { background: var(--yellow-d); }
/* 图层面板底部芯片 */
.layer-footer-chip:active { transform: scale(0.95); background: var(--fill-primary); }
/* 参考图内联按钮 */
.ref-inline-btn:active { transform: scale(0.95); }
/* 层操作 sheet 关闭 */
.layer-sheet-close:active { transform: scale(0.88); background: var(--fill-primary); }
/* 色卡条搜索聚焦 */
#epSearch:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-alpha); outline: none; }
/* 输入弹窗输入框聚焦增强 */
#inputDialogInput:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-alpha); outline: none; }
/* 颜色替换选择器搜索框聚焦 */
#rpSearch:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-alpha); outline: none; }
/* 通用 disable 态 — 所有 primary/secondary 按钮 */
.primary-btn:disabled,
.secondary-btn:disabled,
.float-btn.disabled,
.float-play:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ── 滑块拖拽反馈增强 ── */
.fld-row input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.25);
  box-shadow: 0 0 0 4px var(--yellow-alpha), var(--shadow-md);
}
.fld-row input[type="range"]::-webkit-slider-thumb:active + .fld-row input[type="range"] { background: var(--yellow); }
.fld-row input[type="range"]:active { background: var(--yellow); }
/* 文本工具滑块 */
#textSizeSlider:active,
#textSpacingSlider:active { accent-color: var(--yellow-d); }
#textSizeSlider::-webkit-slider-thumb:active,
#textSpacingSlider::-webkit-slider-thumb:active {
  transform: scale(1.25);
  box-shadow: 0 0 0 4px var(--yellow-alpha), var(--shadow-md);
}
/* 参考图 inline 滑块 */
.ref-inline-slider::-webkit-slider-thumb:active {
  transform: scale(1.3);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.2), var(--shadow-sm);
}
.ref-inline-slider:active { background: rgba(99,102,241,0.3); }
/* 层 opacity 滑块 */
.layer-sheet-op-slider::-webkit-slider-thumb:active {
  transform: scale(1.25);
  box-shadow: 0 0 0 4px var(--yellow-alpha), var(--shadow-md);
}

/* ── iOS 弹簧按键效果 — 给重要按钮添加弹性按压 ── */
.primary-btn,
#saveNameConfirm,
#cropConfirmBtn,
#textToolConfirm,
#inputDialogConfirm,
#settingsGenerateBtn,
.export-download-btn,
.ep-btn-download { transition: transform .15s var(--ease-spring), background-color .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease !important; }

/* ── 键盘 focus 增强 ── */
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible { outline: 2.5px solid var(--yellow) !important; outline-offset: 2px; }

/* ── 触摸设备 tap 高亮统一抑制 ── */
* { -webkit-tap-highlight-color: transparent; }
input, textarea, select, button { -webkit-tap-highlight-color: transparent; }
a, .sheet-btn, .brand-row, .drawing-item, .stats-item, .chip, .chip-sm { -webkit-tap-highlight-color: transparent; }

/* ── 选区按钮交互增强 ── */
#selectMoveBtn:active { transform: scale(0.97); }
#selectCopyBtn:active { transform: scale(0.97); }
#selectCropBtn:active { transform: scale(0.97); }
#selectDeleteBtn:active { transform: scale(0.97); }
#selectCancelBtn:active { background: var(--fill-tertiary); }

/* ===== 019. ★ 专注拼豆模式 — 浮动面板 ===== */
.focus-overlay {
  position: fixed;
  right: 16px;
  top: 56px;
  width: min(260px, 70vw);
  max-height: 70vh;
  z-index: 200;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08), 0 8px 48px rgba(0,0,0,0.06);
  border: 0.5px solid rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: focusPanelIn 0.18s var(--ease-out);
}
@keyframes focusPanelIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .focus-overlay { animation: none; }
}
.focus-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: auto;
  max-height: min(70dvh, 680px);
}
.focus-collapse-body {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.focus-color-list {
  flex: 0 1 auto;
  min-height: 0;
  max-height: min(36dvh, 320px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.focus-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 8px;
  border-bottom: 0.5px solid var(--bd);
}
.focus-title { display:flex; align-items:center; gap:5px; flex:1; min-width:0; font-size:15px; font-weight:700; color:var(--t); letter-spacing:0; }
.focus-drag-handle {
  display:grid; grid-template-columns:repeat(2,3px); grid-template-rows:repeat(3,3px); gap:3px;
  width:32px; height:32px; flex:0 0 32px; place-content:center; border-radius:7px;
  color:var(--t3); cursor:grab; touch-action:none;
}
.focus-drag-handle span { width:3px; height:3px; border-radius:50%; background:currentColor; }
.focus-drag-handle:active,.focus-overlay.is-dragging .focus-drag-handle { background:var(--fill-tertiary); cursor:grabbing; }
.focus-overlay.focus-overlay-ready { animation:none; }
.focus-overlay.is-dragging { animation:none; box-shadow:0 10px 34px rgba(0,0,0,.17); user-select:none; will-change:transform; }
.focus-header-actions { display: flex; align-items: center; gap: 2px; }
.focus-collapse-btn { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--t3); border-radius: 50%; border: none; background: transparent; cursor: pointer; transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease; }
.focus-collapse-btn:active { background: var(--fill-tertiary); transform: scale(0.88); }
.focus-close-btn {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--t3);
  border-radius: 50%; border: none; background: transparent;
  cursor: pointer; transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
}
.focus-close-btn:active { background: var(--fill-tertiary); transform: scale(0.88); }

.focus-spacing-control { display:flex; align-items:center; gap:8px; min-height:48px; padding:7px 10px 7px 14px; border-bottom:.5px solid var(--bd); }
.focus-spacing-control>span { display:flex; flex:1; min-width:0; flex-direction:column; gap:2px; }
.focus-spacing-control strong { color:var(--t); font-size:11px; font-weight:650; }
.focus-spacing-control small { color:var(--t3); font-size:9px; line-height:1.25; }
.focus-spacing-segments { display:grid; grid-template-columns:repeat(4,minmax(27px,auto)); gap:2px; flex:0 0 auto; padding:2px; border-radius:7px; background:var(--fill-tertiary); }
.focus-spacing-segments button { min-width:27px; height:24px; padding:0 5px; border:0; border-radius:5px; background:transparent; color:var(--t3); font-size:9px; font-weight:650; cursor:pointer; letter-spacing:0; }
.focus-spacing-segments button.active { background:var(--bg); color:var(--t); box-shadow:0 1px 3px rgba(0,0,0,.13); }
.focus-spacing-segments button:active { transform:scale(.94); }
.focus-spacing-segments button:focus-visible { outline:2px solid var(--yellow); outline-offset:0; }
.focus-progress-wrap { padding: 8px 14px 6px; }
.focus-progress-info { display: flex; justify-content: space-between; font-size: 11px; color: var(--t3); margin-bottom: 4px; }
.focus-progress-track { height: 4px; background: var(--fill-tertiary); border-radius: 2px; overflow: hidden; }
.focus-progress-fill { height: 100%; background: linear-gradient(90deg, var(--yellow), var(--yellow-d)); border-radius: 2px; transition: width 0.3s var(--ease-out); }

.focus-color-display {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: var(--yellow-alpha);
  border-top: 0.5px solid var(--bd);
  border-bottom: 0.5px solid var(--bd);
}
.focus-current-color { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.focus-swatch-wrap { display: flex; align-items: center; gap: 4px; }
.focus-swatch { width: 24px; height: 24px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.08); flex-shrink: 0; }
.focus-code { font-size: 12px; font-weight: 700; font-family: Consolas,monospace; color: var(--t); }
.focus-count-info { display: flex; align-items: center; gap: 2px; font-size: 10px; color: var(--t3); }
.focus-remaining-count { font-size: 14px; font-weight: 700; color: var(--t); font-variant-numeric: tabular-nums; }
.focus-unit { font-size: 9px; color: var(--t3); }
.focus-actions { display: flex; gap: 3px; flex-shrink: 0; }
.focus-btn {
  border: none; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease; font-weight: 600;
}
.focus-btn:active { transform: scale(0.92); }
.focus-btn-prev, .focus-btn-next { width: 22px; height: 22px; font-size: 10px; background: var(--fill-tertiary); color: var(--t2); }
.focus-btn-prev:active, .focus-btn-next:active { background: var(--fill-primary); }
.focus-btn-complete { padding: 0 8px; height: 22px; font-size: 9px; background: var(--yellow); color: var(--t); }
.focus-btn-complete:active { background: var(--yellow-d); }

.focus-color-list { padding: 4px 8px; }
.focus-color-list::-webkit-scrollbar { width: 3px; }
.focus-color-list::-webkit-scrollbar-thumb { background: var(--bd); border-radius: 2px; }
.focus-list-item {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; border-radius: 6px; cursor: pointer;
  transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease; margin-bottom: 2px;
}
.focus-list-item:active { background: var(--fill-tertiary); }
.focus-list-item.active { background: var(--yellow-light); border: 0.5px solid var(--yellow); }
.focus-list-item.done { opacity: 0.4; }
.focus-list-swatch { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; border: 0.5px solid rgba(0,0,0,0.06); }
.focus-list-code { font-size: 11px; font-weight: 600; font-family: Consolas,monospace; color: var(--t); flex: 1; min-width: 0; }
.focus-list-count { font-size: 10px; color: var(--t3); font-variant-numeric: tabular-nums; }
.focus-list-check { font-size: 10px; color: #4CAF50; font-weight: 700; }

.focus-footer { padding: 6px 14px 10px; border-top: 0.5px solid var(--bd); }
.focus-exit-btn {
  width: 100%; padding: 8px; border: none; border-radius: 8px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  background: var(--fill-tertiary); color: var(--t2);
  transition: transform 0.1s var(--ease-out), opacity 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
}
.focus-exit-btn:active { background: var(--fill-primary); transform: scale(0.97); }
@media (prefers-color-scheme: dark) {
  .focus-overlay { background: rgba(44,44,46,0.96); border-color: rgba(255,255,255,0.06); }
}
.focus-panel-collapsed { height: auto !important; max-height: none !important; }
.focus-panel-collapsed .focus-color-list,
.focus-panel-collapsed .focus-progress-wrap,
.focus-panel-collapsed .focus-footer { display: none; }
.focus-panel-collapsed .focus-color-display { border-bottom: none; }

@media (max-width: 767px) {
  .bottom-area {
    bottom: 8px;
    gap: 6px;
    width: 100%;
    padding: 0 8px;
  }
  .float-capsule {
    width: min(100%, calc(100vw - 16px));
    max-width: 760px;
    border-radius: 20px;
    padding: 4px 4px 6px;
    gap: 4px;
  }
  .float-row {
    gap: 3px;
    min-height: 36px;
    align-items: center;
  }
  .float-left,
  .float-right {
    gap: 2px;
  }
  .float-tools {
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .float-tools::-webkit-scrollbar { display: none; }
  .float-btn {
    height: 38px;
    min-height: 38px;
    padding: 0 10px;
    border-radius: 999px;
    gap: 4px;
    font-size: 11px;
  }
  .float-btn .icon {
    width: 16px;
    height: 16px;
  }
  .float-label {
    font-size: 11px;
    line-height: 1;
  }
  .float-btn.icon-only {
    width: 38px;
    min-width: 38px;
    height: 38px;
    padding: 0;
  }
  .float-play {
    width: auto;
    min-width: 72px;
    height: 38px;
    padding: 0 12px;
    border-radius: 999px;
    gap: 5px;
  }
  .float-play-label {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -0.02em;
  }

  /* 弹窗分级：默认仍为轻量 modal，不强制占满底部 */
  .modal-overlay {
    align-items: center;
    padding: 16px;
  }
  .modal-panel {
    width: min(420px, calc(100vw - 24px));
    max-width: 100%;
    max-height: min(72vh, 640px);
    border-radius: 18px;
  }
  .modal-head {
    padding: 15px 16px 10px;
  }
  .modal-body {
    padding: 4px 14px 14px;
    max-height: calc(min(72vh, 640px) - 112px);
  }
  .modal-footer {
    padding: 0 16px 16px;
  }

  /* 参数设置：大 Sheet，但不彻底吞掉画布感知 */
  #settingsModal {
    align-items: flex-end;
    padding: 0;
  }
  .modal-panel.modal-panel-settings {
    width: 100%;
    max-width: none;
    max-height: 82vh;
    min-height: 64vh;
    border-radius: 24px 24px 0 0;
  }
  #settingsModal .modal-body {
    max-height: none;
    padding: 4px 16px 14px;
  }
  #settingsModal .modal-footer {
    padding: 0 16px calc(14px + var(--safe-b));
  }

  /* 裁剪：更沉浸，优先给预览区 */
  #cropOverlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal-panel.modal-panel-crop {
    width: 100%;
    max-width: none;
    max-height: 90vh;
    border-radius: 24px 24px 0 0;
  }
  #cropPreviewContainer {
    height: min(62vh, 520px) !important;
  }

  /* Sheet：中量面板，保留画布感 */
  .sheet-overlay {
    padding: 0;
  }
  .sheet-panel {
    max-width: none;
    width: 100%;
    max-height: 70vh;
    border-radius: 24px 24px 0 0;
    padding-left: 14px;
    padding-right: 14px;
  }

  /* 统计作为中量查看面板，避免全屏压迫 */
  #statsModal .modal-panel {
    width: min(440px, calc(100vw - 20px));
    max-height: 68vh;
  }

  /* 输入确认保持轻量，不做大 Sheet */
  #inputDialog .modal-panel {
    width: min(360px, calc(100vw - 24px));
    max-height: none;
    border-radius: 18px;
  }
}

@media (max-width: 480px) {
  .float-capsule {
    width: min(100%, calc(100vw - 10px));
    border-radius: 18px;
    padding: 3px 3px 5px;
    gap: 3px;
  }
  .float-row {
    min-height: 32px;
    gap: 2px;
  }
  .float-btn {
    height: 34px;
    min-height: 34px;
    padding: 0 8px;
    font-size: 10px;
  }
  .float-btn .icon {
    width: 15px;
    height: 15px;
  }
  .float-btn.icon-only {
    width: 34px;
    min-width: 34px;
    height: 34px;
  }
  .float-play {
    min-width: 64px;
    height: 34px;
    padding: 0 10px;
  }
  .float-play-label,
  .float-label {
    font-size: 10px;
  }
  .float-stat {
    min-height: 32px;
    padding: 3px 7px;
    font-size: 11px;
  }
  .sheet-panel {
    max-height: 66vh;
  }
}

@media (max-width: 380px) {
  .float-label {
    display: none;
  }
  .float-play-label {
    display: inline-block;
  }
  .float-btn {
    padding: 0 7px;
  }
  .float-play {
    min-width: 56px;
    padding: 0 9px;
  }
}

@media (hover:none), (pointer:coarse) {
  .strategy-chooser {
    backdrop-filter:none;
    -webkit-backdrop-filter:none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== 021. Settings System — Apple HIG inspired ===== */
.modal-panel-settings{width:min(520px,calc(100vw - 24px));max-width:520px;max-height:min(84vh,760px);overflow:hidden;background:color-mix(in srgb,var(--white) 92%,transparent);backdrop-filter:var(--blur-modal);-webkit-backdrop-filter:var(--blur-modal);border:0.5px solid color-mix(in srgb,var(--bd) 75%,transparent)}
.modal-panel-settings .modal-head{min-height:56px;padding:10px 16px;border-bottom:0.5px solid var(--bd);background:color-mix(in srgb,var(--white) 82%,transparent)}
.modal-panel-settings .modal-head>span{display:flex;align-items:center;gap:7px;font-size:17px;font-weight:650;letter-spacing:-.01em}
.modal-panel-settings .modal-body{padding:14px 14px 8px;max-height:none;overscroll-behavior:contain}
.modal-panel-settings .modal-footer{padding:10px 14px calc(14px + var(--safe-b));border-top:0.5px solid var(--bd);background:color-mix(in srgb,var(--white) 90%,transparent)}
.modal-panel-settings .modal-footer .primary-btn{border-radius:14px;box-shadow:0 5px 18px rgba(232,186,32,.2)}
.param-group{border:0;margin:0 0 18px;padding:0;background:var(--white);border-radius:14px;box-shadow:0 0 0 .5px var(--bd);overflow:hidden}
.param-legend{display:flex;align-items:center;gap:6px;width:100%;padding:0 4px 7px;margin:0;background:var(--bg);color:var(--t3);font-size:12px;font-weight:650;letter-spacing:.01em;text-transform:none}
.param-group .fld{position:relative;display:grid;grid-template-columns:minmax(94px,.8fr) minmax(0,1.2fr);align-items:center;gap:12px;min-height:54px;margin:0;padding:7px 12px 7px 16px;background:var(--white);transition:background-color .18s var(--ease-out)}
.param-group .fld:not(:last-child)::after{content:"";position:absolute;left:16px;right:0;bottom:0;height:.5px;background:var(--bd);transform:scaleY(.75);transform-origin:bottom}
.param-group .fld.is-confirmed::before{content:'';position:absolute;inset:0;border-radius:var(--r-md);background:var(--yellow-alpha);pointer-events:none;opacity:0;animation:settingsConfirm .42s var(--ease-out)}
@keyframes settingsConfirm{0%{opacity:1}100%{opacity:0}}
.fld-lbl{margin:0;color:var(--t);font-size:15px;font-weight:450;line-height:1.25}
.fld-sel,.fld-inp,.brand-field-btn{min-height:40px;width:100%;margin:0;border:0;border-radius:10px;background-color:var(--fill-tertiary);color:var(--t);font-size:15px;font-weight:500;outline:none;box-shadow:none;transition:background-color .16s,box-shadow .16s,transform .12s}
.fld-sel{padding:8px 36px 8px 12px;-webkit-appearance:none;appearance:none;background-image:linear-gradient(45deg,transparent 50%,var(--t3) 50%),linear-gradient(135deg,var(--t3) 50%,transparent 50%);background-position:calc(100% - 17px) 17px,calc(100% - 12px) 17px;background-size:5px 5px,5px 5px;background-repeat:no-repeat}
.fld-inp{padding:8px 12px;text-align:right;font-variant-numeric:tabular-nums}
.fld-sel:focus-visible,.fld-inp:focus-visible,.brand-field-btn:focus-visible{box-shadow:0 0 0 3px var(--yellow-alpha),0 0 0 1px var(--yellow);background-color:var(--white)}
.fld-sel:active,.fld-inp:active,.brand-field-btn:active{transform:scale(.985);background-color:var(--fill-secondary)}
.brand-field-btn{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;cursor:pointer}
.fld-row{min-width:0;gap:10px}
.fld-row .fld-inp{min-width:0;text-align:center}
.fld-row input[type="range"]{height:28px;background:linear-gradient(to right,var(--yellow),var(--yellow)) 0/var(--range-progress,0%) 4px no-repeat,var(--fill-secondary);border-radius:999px}
.fld-row input[type="range"]::-webkit-slider-thumb{width:24px;height:24px;border:0;background:var(--white);box-shadow:0 1px 5px rgba(0,0,0,.18),0 0 0 .5px rgba(0,0,0,.08)}
.fld-val{min-width:48px;padding:5px 8px;border-radius:8px;background:var(--fill-tertiary);color:var(--t2);font-size:13px;text-align:center;font-variant-numeric:tabular-nums}
.fld-chips{grid-column:1/-1;display:grid;grid-template-columns:repeat(auto-fit,minmax(72px,1fr));gap:7px;width:100%}
.chip{min-height:40px;justify-content:center;padding:8px 10px;border:0;background:var(--fill-tertiary);border-radius:10px;font-size:13px;font-weight:500}
.chip:has(input:checked){background:var(--yellow);border-color:transparent;color:#4d3b00;box-shadow:inset 0 0 0 .5px rgba(90,66,0,.12)}
.chip:focus-within{box-shadow:0 0 0 3px var(--yellow-alpha),0 0 0 1px var(--yellow)}
.settings-adv-toggle{display:flex;width:100%;min-height:48px;align-items:center;justify-content:space-between;padding:8px 14px 8px 16px;background:var(--white);border-radius:14px;margin:0 0 10px;color:var(--t);font-size:15px;font-weight:500;box-shadow:0 0 0 .5px var(--bd);transition:background-color .15s,transform .12s}
.settings-adv-toggle:active{background:var(--fill-tertiary);transform:scale(.99)}
.settings-adv-toggle svg{color:var(--t3);transition:transform .28s var(--ease-spring)}
.settings-adv-toggle[aria-expanded="true"] svg{transform:rotate(90deg)}
.settings-adv-body{display:block;overflow:hidden;transform-origin:top;animation:settingsReveal .26s var(--ease-out)}
.settings-adv-body[hidden]{display:none}
@keyframes settingsReveal{from{opacity:0;transform:translateY(-6px)}to{opacity:1;transform:translateY(0)}}
.settings-preview-wrap{margin:0 0 18px;padding:12px;background:var(--white);border-radius:14px;box-shadow:0 0 0 .5px var(--bd)}
.settings-preview-head{display:flex;align-items:center;min-height:30px;color:var(--t2);font-size:13px;font-weight:600}
#settingsPreviewCanvas{display:block;width:100%;border-radius:10px;background:var(--bg)}
.modal-x,.drawer-close,.sheet-cancel{min-width:44px;min-height:44px}
button:not(:disabled){touch-action:manipulation}
.generation-simple-note{margin:0 0 12px;padding:10px 12px;border-left:3px solid var(--yellow);background:var(--fill-secondary);color:var(--t2);font-size:13px;line-height:1.5}
@media(hover:hover){.fld-sel:hover,.fld-inp:hover,.brand-field-btn:hover{background-color:var(--fill-secondary)}.settings-adv-toggle:hover{background:var(--fill-tertiary)}}
@media(max-width:899px), (hover:none) and (pointer:coarse){
  .modal-panel-settings .modal-body{display:block!important;min-width:0;grid-template-columns:none!important}
  .modal-panel-settings .settings-column{display:block!important;min-width:0}
  .modal-panel-settings .settings-column-secondary:empty{display:none!important}
  .modal-panel-settings .settings-preview-wrap{min-height:0;margin:0 0 18px;padding:12px;display:block}
  .modal-panel-settings #settingsPreviewCanvas{width:100%;max-height:220px;margin:0 auto}
}
@media(max-width:600px), (hover:none) and (pointer:coarse){
  #settingsModal{align-items:flex-end!important;padding:0!important}
  #settingsModal .modal-panel-settings{width:100%!important;max-width:none!important;max-height:92dvh!important;border-radius:22px 22px 0 0!important;transform:translateY(24px);transform-origin:bottom}
  #settingsModal.show .modal-panel-settings{transform:translateY(0)}
  .modal-panel-settings .modal-head{padding-top:8px}
  .modal-panel-settings .modal-body{padding:12px 12px 6px}
  .modal-panel-settings .param-legend{width:auto;margin:0 0 7px;padding:0 2px;background:transparent;color:var(--t2)}
  .param-group .fld{grid-template-columns:minmax(88px,.75fr) minmax(0,1.25fr);padding-left:14px;padding-right:10px}
  .fld-chips{grid-template-columns:repeat(3,1fr)}
}
@media(max-width:360px){.param-group .fld{grid-template-columns:1fr;gap:6px;padding:10px 12px}.param-group .fld:not(:last-child)::after{left:12px}.fld-inp{text-align:left}.fld-chips{grid-template-columns:repeat(2,1fr)}}
.settings-size-row{width:100%}
.settings-number-field{display:flex;min-width:0;flex:1;flex-direction:column;gap:3px}
.settings-number-field>span{color:var(--t3);font-size:10px;font-weight:550;text-align:center}
.settings-size-times{flex:0 0 auto;padding-top:16px;color:var(--t3)}

/* ===== 022. Tablet & Desktop workspace adaptation ===== */
@media (min-width:768px) and (max-width:1199px) {
  .topbar {
    height:60px;
    padding:0 max(20px, env(safe-area-inset-left)) 0 max(20px, env(safe-area-inset-right));
  }
  .brand-btn { max-width:156px; padding-inline:13px; }
  .brand-btn span { max-width:118px; }
  .topbar-center { gap:6px; }
  .canvas-area { padding:24px 24px 132px; }
  .bottom-area { bottom:18px; width:min(920px, calc(100vw - 40px)); }
  .float-capsule {
    width:100%;
    max-width:none;
    padding:7px 9px;
    gap:5px;
    border-radius:24px;
  }
  .float-row { min-height:44px; gap:6px; }
  .float-tools { justify-content:center; gap:4px; }
  .float-btn { height:40px; padding:0 13px; }
  .float-btn.icon-only { width:40px; height:40px; padding:0; justify-content:center; }
  .float-play { width:auto; min-width:82px; padding:0 15px; border-radius:999px; }
  .float-play-label { display:inline-block; }
  .float-color-wrap { width:min(760px, calc(100vw - 64px)); max-height:340px; }
  .modal-panel-settings { width:min(680px, calc(100vw - 64px)); max-width:680px; }
  .modal-panel-settings .modal-body { padding:18px; }
  .fld-chips { grid-template-columns:repeat(5, minmax(76px,1fr)); }
}

@media (min-width:1200px) {
  .topbar {
    height:64px;
    padding:0 24px;
    border-bottom:1px solid var(--bd);
    box-shadow:0 1px 0 rgba(0,0,0,.02);
  }
  .topbar-left, .topbar-right { flex:1; }
  .topbar-right { justify-content:flex-end; }
  .topbar-center { gap:8px; margin:0; }
  .brand-btn { height:38px; max-width:190px; padding:0 14px; border-radius:11px; font-size:13px; }
  .brand-btn span { max-width:148px; font-size:13px; }
  .topbar-size { min-height:40px; padding-inline:16px; font-size:13px; }
  .topbar-save, .topbar-list, .topbar-undo { width:40px; height:40px; }

  .canvas-area { padding:28px 28px 28px 272px; }
  .canvas-area:has(.empty-state:not([style*="display: none"])) { padding:28px; }
  .canvas-area .empty-state { transform:none; }
  .bottom-area {
    left:20px;
    top:84px;
    bottom:20px;
    width:228px;
    transform:none;
    align-items:stretch;
    justify-content:flex-start;
    gap:10px;
  }
  .float-capsule {
    width:228px;
    max-width:none;
    max-height:calc(100vh - 104px);
    padding:10px;
    gap:8px;
    border-radius:20px;
    overflow-y:auto;
    overscroll-behavior:contain;
    scrollbar-width:thin;
  }
  .float-row {
    min-height:0;
    align-items:stretch;
    gap:8px;
    padding:8px;
    border-radius:14px;
    background:color-mix(in srgb,var(--fill-tertiary) 72%,transparent);
  }
  .float-row-top, .float-row-bottom { flex-direction:column; }
  .float-left, .float-right {
    width:100%;
    padding:0;
    gap:6px;
  }
  .float-row-top .float-left { justify-content:space-between; min-height:36px; }
  .float-row-bottom .float-left { order:2; }
  .float-row-bottom .float-right { order:3; }
  .float-tools {
    width:100%;
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:6px;
    padding:0;
    overflow:visible;
  }
  .float-btn {
    width:100%;
    height:40px;
    justify-content:flex-start;
    padding:0 11px;
    border-radius:10px;
    gap:8px;
    font-size:12px;
  }
  .float-btn:hover { background:var(--fill-secondary); }
  .float-btn.active { box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--yellow) 72%,transparent); }
  .float-btn.icon-only, .float-set {
    width:40px;
    min-width:40px;
    height:40px;
    padding:0;
    justify-content:center;
  }
  .float-row-bottom .float-left { justify-content:flex-start; }
  .float-row-bottom .float-right { justify-content:flex-end; width:100%; }
  .float-divider { display:none; }
  .float-play {
    width:100%;
    height:44px;
    justify-content:center;
    border-radius:11px;
    padding:0 14px;
  }
  .float-play-label { display:inline-block; font-size:13px; }
  .float-stat { padding:5px 8px; }
  .float-sci-empty { overflow:hidden; text-overflow:ellipsis; }
  .float-row-denoise { padding:10px; }
  .reduce-controls { flex-wrap:wrap; }
  .reduce-slider { flex-basis:100%; order:-1; height:34px; }

  .float-color-wrap {
    left:calc(100% + 12px);
    top:0;
    bottom:auto;
    transform:none;
    width:360px;
    min-width:360px;
    max-width:calc(100vw - 300px);
    max-height:calc(100vh - 108px);
    border-radius:18px;
    padding:12px;
  }
  .float-color-wrap .color-strip { justify-content:flex-start; }
  .float-color-wrap .swatch-item { width:38px; height:48px; }
  .zoom-badge { right:18px; bottom:18px; }

  .modal-panel-settings {
    width:min(920px, calc(100vw - 96px));
    max-width:920px;
    max-height:min(88vh,840px);
  }
  .modal-panel-settings .modal-body {
    display:grid;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    align-items:start;
    gap:18px;
    padding:18px;
  }
  .modal-panel-settings .modal-body > * { min-width:0; margin-bottom:0; }
  .modal-panel-settings .settings-preview-wrap { grid-column:2; grid-row:1; }
  .modal-panel-settings .modal-body > .param-group:nth-of-type(1) { grid-column:1; }
  .modal-panel-settings .modal-body > .param-group:nth-of-type(2) { grid-column:2; }
  .modal-panel-settings .modal-body > .param-group:nth-of-type(n+3) { grid-column:1 / -1; }
  .fld-chips { grid-template-columns:repeat(5,minmax(72px,1fr)); }

  .drawer { width:min(520px, calc(100vw - 48px)); left:50%; right:auto; transform:translate(-50%,110%); border-radius:20px 20px 0 0; }
  .drawer.show { transform:translate(-50%,0); }
}

/* 020. 放大镜工具已移除 */

/* 021. 触屏命中区：视觉图标尺寸不变，只扩大真实按钮盒。 */
@media (hover:none),(pointer:coarse) {
  .float-btn { min-height: 40px; }
  .float-btn.icon-only, .float-set { width: 40px; height: 40px; }
  .float-play { width: 42px; height: 42px; }
  .layer-close-btn, .layer-ctrl-btn, .layer-more-btn { width: 36px; height: 36px; }
  .layer-controls { gap: 2px; }
  .layer-footer-chip, .layer-footer-addref { min-height: 36px; }
  .ref-transform-btn { min-width: 36px !important; min-height: 36px !important; flex: 1 1 36px; }
  .ref-inline-btn { min-height: 36px !important; padding: 6px 8px !important; }
  .layer-sheet-close { min-width: 36px; min-height: 36px; }
}

/* 图例 OCR 服务选择与临时凭据 */
.pattern-baidu-ocr-keys[hidden]{display:none}
.pattern-baidu-ocr-keys{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:-4px 0 12px;padding:12px;background:#fff;border:1px solid #dfe5ee;border-radius:8px}
.pattern-baidu-ocr-keys label{display:flex;flex-direction:column;gap:5px;color:#475467;font-size:12px}
.pattern-baidu-ocr-keys input{width:100%;box-sizing:border-box;border:1px solid #d0d5dd;border-radius:8px;padding:10px;font-size:14px;background:#fff}
.pattern-baidu-ocr-keys>small{grid-column:1/-1;color:#667085;font-size:11px}
.pattern-cloud-ocr-toggle{flex-wrap:wrap}
.pattern-cloud-ocr-toggle>small{margin-left:auto;color:#667085}
@media(max-width:600px){.pattern-baidu-ocr-keys{grid-template-columns:1fr}.pattern-baidu-ocr-keys>small{grid-column:auto}.pattern-cloud-ocr-toggle>small{width:100%;margin-left:27px}}

/* 图例色号实时匹配状态 */
.legend-code-status.is-valid{color:#15803d!important}
.legend-code-status.is-invalid{color:#b45309!important}
.pattern-import-swatch-pair i{transition:background-color .15s ease}

/* 网格校准采样区 */
.pattern-grid-sample-control{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:11px;padding:9px 10px;border:1px solid #dfe7e3;border-radius:7px;background:#f4fbf6}.pattern-grid-sample-control>div:first-child{display:flex;flex-direction:column;gap:2px}.pattern-grid-sample-control strong{color:#173526;font-size:13px}.pattern-grid-sample-control small{color:#667a6d;font-size:10px}.pattern-grid-sample-control>div:last-child{display:grid;grid-template-columns:34px minmax(58px,auto) 34px;align-items:center;gap:5px}.pattern-grid-sample-control button{width:34px;height:34px;border:1px solid #bad9c4;border-radius:50%;background:#fff;color:#168147;font-size:20px;line-height:1}.pattern-grid-sample-control b{text-align:center;color:#173526;font-size:13px;font-variant-numeric:tabular-nums}
@media(max-width:600px){.pattern-grid-sample-control{margin-bottom:9px;padding:8px}.pattern-grid-sample-control small{display:none}.pattern-grid-sample-control>div:last-child{grid-template-columns:32px minmax(54px,auto) 32px}.pattern-grid-sample-control button{width:32px;height:32px}}

/* 最终成品配置 */
.pattern-preview-workbench{display:flex;flex-direction:column;gap:12px}.pattern-preview-heading{display:flex;align-items:end;justify-content:space-between}.pattern-preview-heading>div{display:flex;flex-direction:column;gap:3px}.pattern-preview-heading strong{font-size:20px}.pattern-preview-heading span{color:#64748b;font-size:12px}.pattern-preview-heading em{padding:6px 10px;border-radius:8px;background:#e9f2ff;color:#175fc2;font-style:normal;font-weight:900}.pattern-preview-workbench .pattern-result-preview{min-height:320px;padding:14px;background-color:#101827;background-image:linear-gradient(45deg,rgba(255,255,255,.035) 25%,transparent 25%),linear-gradient(-45deg,rgba(255,255,255,.035) 25%,transparent 25%);background-size:22px 22px}.pattern-result-preview canvas{box-shadow:0 12px 34px rgba(0,0,0,.34)}.pattern-result-preview>span{position:absolute;right:10px;bottom:9px;padding:5px 9px;border-radius:999px;background:rgba(8,15,28,.78);color:#fff;font-size:11px}.pattern-preview-controls{display:grid;grid-template-columns:1fr 1fr;gap:10px}.pattern-preview-controls label{display:flex;flex-direction:column;gap:6px;padding:11px 12px;border:1px solid #e1e7ef;border-radius:8px;background:#fff;color:#64748b;font-size:11px;font-weight:700}.pattern-preview-controls select{width:100%;height:42px;border:0;border-radius:7px;padding:0 10px;background:#f1f5f9;color:#172033;font-size:14px;font-weight:800}.pattern-preview-mode,.pattern-preview-compatible{margin:0;padding:10px 12px;border-radius:8px;font-size:12px}.pattern-preview-mode{background:#eef4ff;color:#315f9b}.pattern-preview-compatible{background:#eaf8ef;color:#167344;font-weight:800}.pattern-preview-conflicts{overflow:hidden;border:1px solid #f2cf78;border-radius:8px;background:#fff}.pattern-preview-conflicts>header{display:flex;align-items:center;padding:12px;background:#fff8e6}.pattern-preview-conflicts>header div{display:flex;flex-direction:column;gap:2px}.pattern-preview-conflicts>header strong{color:#92400e}.pattern-preview-conflicts>header span{color:#a16207;font-size:11px}.pattern-preview-conflicts>header>b{margin-left:auto;padding:4px 7px;border-radius:6px;background:#f59e0b;color:#fff;font-size:10px}.pattern-preview-conflict{display:grid;grid-template-columns:34px minmax(0,1fr) auto;align-items:center;gap:9px;padding:10px 12px;border-top:1px solid #f3e5bd}.pattern-preview-conflict>i{width:32px;height:32px;border:1px solid rgba(0,0,0,.12);border-radius:8px}.pattern-preview-conflict>div{display:flex;flex-direction:column}.pattern-preview-conflict small{color:#7c6b4a;font-size:11px}.pattern-preview-conflict button{height:38px;display:flex;align-items:center;gap:6px;border:1px solid #e7b950;border-radius:8px;padding:0 10px;background:#fffaf0;color:#92400e;font-weight:800}.pattern-preview-conflict button i{width:18px;height:18px;border-radius:5px;border:1px solid rgba(0,0,0,.1)}
@media(max-width:600px){.pattern-preview-workbench .pattern-result-preview{min-height:285px;max-height:44vh}.pattern-preview-controls{gap:7px}.pattern-preview-controls label{padding:9px}.pattern-preview-conflict{grid-template-columns:30px minmax(0,1fr)}.pattern-preview-conflict button{grid-column:1/-1;justify-content:center}.pattern-result-colors{max-height:104px;overflow:auto}.pattern-import-foot [data-action="open"]:disabled{background:#d9e1ec;color:#7b8798;cursor:not-allowed}}
/* 品牌-色系三级配置 */
.pattern-preview-controls{grid-template-columns:repeat(3,minmax(0,1fr))}
@media(max-width:600px){.pattern-preview-controls{grid-template-columns:1fr}}

/* Final preview · Apple-inspired inspection workspace */
.pattern-preview-workbench{gap:0;margin:-20px -22px -10px;background:#f5f7fb;color:#111827}
.pattern-preview-workbench .pattern-result-preview{min-height:330px;border-radius:0;padding:22px;background-color:#edf2fa;background-image:linear-gradient(45deg,#fff 25%,transparent 25%),linear-gradient(-45deg,#fff 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#fff 75%),linear-gradient(-45deg,transparent 75%,#fff 75%);background-size:24px 24px;background-position:0 0,0 12px,12px -12px,-12px 0;box-shadow:inset 0 -1px rgba(15,23,42,.05)}
.pattern-preview-workbench .pattern-result-preview canvas{border-radius:8px;box-shadow:0 14px 36px rgba(29,47,76,.13)}
.pattern-preview-workbench .pattern-result-preview>b{position:absolute;left:20px;top:18px;padding:8px 13px;border-radius:999px;background:rgba(17,24,39,.65);color:#fff;font-size:13px;font-variant-numeric:tabular-nums;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}
.pattern-preview-summary{display:flex;align-items:center;gap:8px;padding:20px 28px 12px;background:#f8f9fc}.pattern-preview-summary strong{font-size:20px}.pattern-preview-summary strong i{display:inline-block;width:8px;height:8px;margin-right:10px;border-radius:50%;background:#22c55e;box-shadow:0 0 0 3px #dcfce7}.pattern-preview-summary span{color:#94a3b8;font-weight:700}
.pattern-preview-section{padding:12px 28px;background:#f8f9fc}.pattern-preview-section>h3,.pattern-preview-issues>h3{margin:0 0 12px;color:#64748b;font-size:14px;font-weight:800;letter-spacing:.02em}
.pattern-preview-sizes{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}.pattern-preview-sizes button{min-width:0;height:50px;border:1px solid #e7ebf2;border-radius:15px;background:rgba(255,255,255,.78);color:#334155;font-size:15px;font-weight:800;box-shadow:0 1px 2px rgba(15,23,42,.02)}.pattern-preview-sizes button.active{border-color:#78afe4;background:#e4f0fc;color:#1168b7;box-shadow:inset 0 0 0 1px #9cc6ec}
.pattern-preview-pickers{display:grid;grid-template-columns:1fr 1fr;gap:10px}.pattern-preview-pickers label{position:relative;display:grid;grid-template-columns:minmax(0,1fr) 20px;grid-template-rows:auto auto;align-items:center;min-height:74px;padding:12px 14px;border:1px solid #e5e9f0;border-radius:17px;background:rgba(255,255,255,.86);box-shadow:0 2px 8px rgba(15,23,42,.025)}.pattern-preview-pickers label>span{grid-column:1;color:#94a3b8;font-size:11px;font-weight:700}.pattern-preview-pickers select{grid-column:1;min-width:0;width:100%;height:34px;border:0;background:transparent;color:#1e293b;font-size:16px;font-weight:800;appearance:none;white-space:nowrap;text-overflow:ellipsis}.pattern-preview-pickers label>b{grid-column:2;grid-row:1/3;color:#b6c3d2;font-size:27px;font-weight:400}
.pattern-preview-issues{padding:18px 28px 24px;background:#f8f9fc}.pattern-preview-issues>h3{color:#b45309}.pattern-preview-issues>h3 span{font-weight:500}.pattern-preview-issue{display:grid;grid-template-columns:44px minmax(0,1fr) auto;align-items:center;gap:12px;min-height:76px;margin-bottom:10px;padding:10px 12px;border:1px solid #f4db83;border-radius:17px;background:#fffae9}.pattern-preview-issue>i{width:42px;height:42px;border:1px solid rgba(0,0,0,.08);border-radius:12px}.pattern-preview-issue>div{display:flex;flex-direction:column}.pattern-preview-issue strong{font-size:19px}.pattern-preview-issue small{color:#8b7957;font-size:12px}.pattern-preview-issue button{height:44px;border:0;border-radius:13px;padding:0 16px;background:#0874d1;color:#fff;font-size:14px;font-weight:800}.pattern-preview-compatible{margin:12px 28px 24px;border:1px solid #bde5ca;border-radius:15px;background:#effaf3}
.pattern-replace-overlay{position:fixed;inset:0;z-index:1100;display:flex;align-items:flex-end;justify-content:center;background:rgba(18,25,38,.38);opacity:0;transition:opacity .18s ease;backdrop-filter:blur(2px)}.pattern-replace-overlay.show{opacity:1}.pattern-replace-sheet{width:min(760px,100%);height:min(82dvh,820px);display:grid;grid-template-rows:18px auto auto auto 64px minmax(0,1fr) auto;background:#fff;border-radius:28px 28px 0 0;overflow:hidden;transform:translateY(24px);transition:transform .22s cubic-bezier(.2,.8,.2,1);box-shadow:0 -22px 60px rgba(15,23,42,.18)}.pattern-replace-overlay.show .pattern-replace-sheet{transform:none}.pattern-replace-grip{width:72px;height:6px;margin:10px auto 0;border-radius:999px;background:#dfe5ed}.pattern-replace-sheet>header{display:flex;align-items:center;padding:16px 28px 12px}.pattern-replace-sheet>header div{display:flex;align-items:baseline;gap:10px}.pattern-replace-sheet>header strong{font-size:22px}.pattern-replace-sheet>header span{color:#94a3b8;font-weight:700}.pattern-replace-sheet>header button{margin-left:auto;width:44px;height:44px;border:0;border-radius:50%;background:#f3f6fa;color:#94a3b8;font-size:28px}
.pattern-replace-current{display:grid;grid-template-columns:48px auto 36px minmax(0,1fr);align-items:center;gap:10px;margin:4px 28px 10px;padding:14px;border:1px solid #edf0f4;border-radius:19px;background:#f8fafc}.pattern-replace-current>i{width:46px;height:46px;border:1px solid rgba(0,0,0,.1);border-radius:13px}.pattern-replace-current>div{display:flex;flex-direction:column}.pattern-replace-current small{color:#94a3b8}.pattern-replace-current strong{font-size:19px}.pattern-replace-current>b{color:#94a3b8;font-size:26px}.pattern-replace-current>span{display:flex;align-items:center;gap:8px;color:#94a3b8;font-weight:800}.pattern-replace-current>span i{width:26px;height:26px;border-radius:8px;border:1px solid rgba(0,0,0,.08)}.pattern-replace-current>span strong{color:#334155}
.pattern-replace-suggest{display:flex;align-items:center;gap:8px;padding:0 28px 12px;overflow-x:auto}.pattern-replace-suggest>b{color:#64748b}.pattern-replace-suggest button{flex:0 0 auto;height:42px;display:flex;align-items:center;gap:6px;border:1px solid #dfe5ed;border-radius:14px;padding:0 10px;background:#fff;color:#334155}.pattern-replace-suggest button i{width:25px;height:25px;border-radius:7px;border:1px solid rgba(0,0,0,.08)}.pattern-replace-suggest button small{color:#94a3b8}.pattern-replace-suggest button.selected{border-color:#1681df;background:#eef7ff}
.pattern-replace-sheet>nav{display:grid;grid-template-columns:1fr 1fr;margin:0 28px 10px;padding:4px;border-radius:14px;background:#f0f3f8}.pattern-replace-sheet>nav button{height:48px;border:0;border-radius:11px;background:transparent;color:#64748b;font-size:16px;font-weight:800}.pattern-replace-sheet>nav button.active{background:#fff;color:#0874d1;box-shadow:0 3px 10px rgba(15,23,42,.07)}.pattern-replace-sheet>main{overflow:auto;padding:4px 28px 28px}.pattern-replace-sheet>main section>b{display:flex;align-items:center;gap:12px;margin:18px 0 10px;color:#64748b}.pattern-replace-sheet>main section>b:after{content:'';height:1px;flex:1;background:#edf0f4}.pattern-replace-sheet>main section>div{display:flex;flex-wrap:wrap;gap:10px}.pattern-replace-sheet>main button{height:46px;display:flex;align-items:center;gap:8px;border:1px solid #dfe5ed;border-radius:14px;padding:0 13px;background:#fff;color:#334155;font-size:16px;font-weight:800}.pattern-replace-sheet>main button i{width:26px;height:26px;border-radius:7px;border:1px solid rgba(0,0,0,.08)}.pattern-replace-sheet>main button.selected{border-color:#1681df;background:#eef7ff;box-shadow:0 0 0 2px rgba(22,129,223,.1)}.pattern-replace-sheet>footer{display:grid;grid-template-columns:1fr 2fr;gap:14px;padding:14px 28px calc(14px + env(safe-area-inset-bottom));border-top:1px solid #edf0f4;background:rgba(255,255,255,.96)}.pattern-replace-sheet>footer button{height:54px;border:1px solid #9aa4b2;border-radius:17px;background:#fff;color:#0874d1;font-size:17px;font-weight:800}.pattern-replace-sheet>footer [data-confirm]{border:0;background:#0874d1;color:#fff}.pattern-replace-sheet>footer [data-confirm]:disabled{background:#dce4ef;color:#9aa8b9}
@media(max-width:600px){.pattern-preview-workbench{margin:-16px -14px -8px}.pattern-preview-workbench .pattern-result-preview{min-height:300px;padding:16px}.pattern-preview-summary{padding:17px 20px 10px}.pattern-preview-summary strong{font-size:18px}.pattern-preview-section,.pattern-preview-issues{padding-left:18px;padding-right:18px}.pattern-preview-sizes{gap:6px}.pattern-preview-sizes button{height:48px;padding:0 4px;font-size:14px}.pattern-preview-pickers{gap:8px}.pattern-preview-pickers label{min-height:70px;padding:10px 11px}.pattern-preview-pickers select{font-size:15px}.pattern-preview-issue{grid-template-columns:40px minmax(0,1fr) auto}.pattern-preview-issue>i{width:38px;height:38px}.pattern-preview-issue button{padding:0 12px}.pattern-replace-sheet{height:84dvh}.pattern-replace-sheet>header,.pattern-replace-sheet>main{padding-left:18px;padding-right:18px}.pattern-replace-current{margin-left:18px;margin-right:18px}.pattern-replace-suggest{padding-left:18px;padding-right:18px}.pattern-replace-sheet>nav{margin-left:18px;margin-right:18px}.pattern-replace-sheet>footer{padding-left:18px;padding-right:18px}}

/* Import editing workspace · full-document-first */
.pattern-import-sheet:has(.pattern-import-canvas-wrap),.pattern-import-sheet.is-grid-stage{width:min(920px,100%);height:min(96dvh,980px);max-height:none;background:#f2f4f7}
.pattern-import-sheet:has(.pattern-import-canvas-wrap) .pattern-import-body,.is-grid-stage .pattern-import-body{min-height:0;flex:1;padding:14px 18px 8px;overscroll-behavior:contain}
.pattern-import-sheet:has(.pattern-import-canvas-wrap) .pattern-import-copy{margin-bottom:10px;padding:0 4px}.pattern-import-sheet:has(.pattern-import-canvas-wrap) .pattern-import-copy strong{font-size:18px;letter-spacing:-.015em}.pattern-import-sheet:has(.pattern-import-canvas-wrap) .pattern-import-copy span{font-size:12px}
.pattern-import-canvas-wrap,.pattern-grid-preview{min-height:360px;border:1px solid rgba(15,23,42,.08);border-radius:20px;background-color:#e9edf3;background-image:linear-gradient(45deg,rgba(255,255,255,.72) 25%,transparent 25%),linear-gradient(-45deg,rgba(255,255,255,.72) 25%,transparent 25%),linear-gradient(45deg,transparent 75%,rgba(255,255,255,.72) 75%),linear-gradient(-45deg,transparent 75%,rgba(255,255,255,.72) 75%);background-size:20px 20px;background-position:0 0,0 10px,10px -10px,-10px 0;box-shadow:0 10px 30px rgba(23,35,58,.08),inset 0 0 0 1px rgba(255,255,255,.55)}
.pattern-import-canvas-wrap canvas,.pattern-grid-preview canvas{width:100%;height:auto;max-height:none;border-radius:19px}
.pattern-import-crop{border:2px solid #0a84ff;background:rgba(10,132,255,.12);box-shadow:0 0 0 9999px rgba(16,24,40,.34),0 0 0 1px rgba(255,255,255,.72);padding:0}.pattern-import-crop b{position:absolute;left:8px;top:8px;padding:5px 9px;border-radius:999px;background:rgba(10,132,255,.92);box-shadow:0 4px 12px rgba(10,132,255,.25);font-size:11px;white-space:nowrap;backdrop-filter:blur(10px)}
.pattern-crop-handle:after{width:12px;height:12px;left:8px;top:8px;border:3px solid #0a84ff;box-shadow:0 2px 8px rgba(0,0,0,.22)}
.pattern-canvas-tools{position:absolute;z-index:7;right:12px;top:12px;display:flex;pointer-events:auto}.pattern-canvas-tools button{height:38px;border:1px solid rgba(255,255,255,.6);border-radius:12px;padding:0 13px;background:rgba(255,255,255,.88);color:#0874d1;font-size:13px;font-weight:750;box-shadow:0 6px 18px rgba(15,23,42,.12);backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px)}
.pattern-import-hint{margin:10px 4px 2px;text-align:center;color:#667085}.pattern-crop-info{margin:4px 4px 8px;text-align:center;color:#98a2b3;font-variant-numeric:tabular-nums}
.pattern-grid-workbench{gap:10px}.pattern-grid-preview{height:auto;min-height:360px;max-height:none}.pattern-grid-view-tools{border-radius:14px;background:rgba(255,255,255,.9);box-shadow:0 7px 22px rgba(15,23,42,.12);backdrop-filter:blur(18px)}
.pattern-grid-panel{border-radius:var(--r-xl);border-color:#e2e7ee;box-shadow:0 5px 18px rgba(15,23,42,.045)}
@media(max-width:600px){.pattern-import-sheet:has(.pattern-import-canvas-wrap),.pattern-import-sheet.is-grid-stage{height:100dvh;max-height:100dvh;border-radius:0}.pattern-import-sheet:has(.pattern-import-canvas-wrap) .pattern-import-head,.is-grid-stage .pattern-import-head{padding-top:max(10px,env(safe-area-inset-top));padding-bottom:8px}.pattern-import-sheet:has(.pattern-import-canvas-wrap) .pattern-import-steps{padding-top:7px;padding-bottom:7px}.pattern-import-sheet:has(.pattern-import-canvas-wrap) .pattern-import-body,.is-grid-stage .pattern-import-body{padding:10px 10px 6px}.pattern-import-canvas-wrap,.pattern-grid-preview{min-height:340px;border-radius:16px}.pattern-import-canvas-wrap canvas,.pattern-grid-preview canvas{border-radius:15px}.pattern-canvas-tools{right:9px;top:9px}.pattern-canvas-tools button{height:36px;padding:0 11px}.pattern-import-foot{padding-top:10px}.pattern-import-foot button{min-height:50px}}
@media(max-height:700px) and (max-width:600px){.pattern-import-canvas-wrap,.pattern-grid-preview{min-height:300px}.pattern-import-sheet:has(.pattern-import-canvas-wrap) .pattern-import-copy{display:none}}
/* JS owns the operation viewport size; never stretch the rendered bitmap in CSS. */
.pattern-import-canvas-wrap,.pattern-grid-preview{max-height:none!important;overflow:hidden}
.pattern-import-canvas-wrap canvas,.pattern-grid-preview canvas{display:block;flex:0 0 auto;max-width:none!important;max-height:none!important;object-fit:unset}
@media(max-width:600px){.pattern-grid-preview{height:auto;max-height:none}.pattern-import-canvas-wrap,.pattern-grid-preview{min-height:0}}

/* Legend review: the complete cropped strip is visible by default, including both ends. */
.pattern-legend-reference-image{display:flex;align-items:center;justify-content:center;min-height:72px;max-height:260px;overflow:hidden;padding:8px;background:#eef1f5}
.pattern-legend-reference-image img{display:block;width:auto!important;height:auto!important;min-width:0!important;max-width:100%!important;max-height:244px!important;object-fit:contain;margin:auto}
@media(max-width:600px){.pattern-legend-reference-image{height:190px;max-height:none;padding:6px}.pattern-legend-reference-image img{max-height:178px!important}.pattern-legend-reference-head{align-items:flex-start}.pattern-legend-reference-actions{justify-content:flex-end}}
.pattern-legend-reference-actions{display:flex;align-items:center;gap:5px;flex-wrap:wrap}.pattern-legend-reference-actions button{min-width:34px;height:34px;padding:0 9px}.pattern-legend-reference-image{height:220px;max-height:none;touch-action:none;cursor:grab;user-select:none;overscroll-behavior:contain}.pattern-legend-reference-image:active{cursor:grabbing}.pattern-legend-reference-image img{transform-origin:center center;will-change:transform;pointer-events:none;transition:transform .08s ease-out}.pattern-legend-reference-hint{display:block;margin-top:7px;color:#98a2b3;text-align:center;font-size:11px}@media(max-width:600px){.pattern-legend-reference-image{height:190px}}

/* Operation stages reserve most of the screen for the image, matching an iOS photo editor. */
.pattern-import-sheet.is-operation-stage{height:min(100dvh,960px);max-height:100dvh}
.is-operation-stage .pattern-import-body{display:flex;flex:1 1 auto;flex-direction:column;min-height:0;overflow:hidden;padding:8px 10px 5px}
.is-operation-stage .pattern-import-copy{flex:0 0 auto;margin:0 2px 6px}
.is-operation-stage .pattern-cloud-ocr-toggle{flex:0 0 auto;margin:0 0 6px;padding:7px 10px}
.is-operation-stage .pattern-baidu-ocr-keys{flex:0 0 auto;max-height:124px;overflow:auto}
.is-operation-stage .pattern-import-canvas-wrap{flex:1 1 auto;height:auto!important;min-height:0!important}
.is-operation-stage .pattern-import-hint{flex:0 0 auto;margin:5px 2px 0;font-size:11px;line-height:15px}
.is-operation-stage .pattern-crop-info{flex:0 0 auto;margin:1px 2px 2px;font-size:11px;line-height:14px}
.is-operation-stage .pattern-import-foot{flex:0 0 auto;padding-top:8px}
.is-operation-stage.is-grid-stage .pattern-grid-workbench{height:100%;min-height:0;gap:6px}
.is-operation-stage.is-grid-stage .pattern-grid-intro{flex:0 0 auto}
.is-operation-stage.is-grid-stage .pattern-grid-preview{flex:1 1 auto;height:auto!important;min-height:0!important}
.is-operation-stage.is-grid-stage .pattern-grid-panel{flex:0 0 auto;max-height:22dvh;overflow:auto}
@media(max-width:600px){
.pattern-import-sheet.is-operation-stage{width:100%;height:100dvh;max-height:100dvh;border-radius:0}
.is-operation-stage .pattern-import-head{padding:calc(6px + env(safe-area-inset-top)) 12px 6px;min-height:44px;box-sizing:content-box}
.is-operation-stage .pattern-import-head h2{font-size:18px}.is-operation-stage .pattern-import-head p{display:none}
.is-operation-stage .pattern-import-back,.is-operation-stage .pattern-import-close{width:34px;height:34px}
.is-operation-stage .pattern-import-steps{padding:5px 10px}.is-operation-stage .pattern-import-steps span{padding:4px 7px;font-size:11px}.is-operation-stage .pattern-import-steps i{width:10px}
.is-operation-stage .pattern-import-copy strong{font-size:15px}.is-operation-stage .pattern-import-copy span{display:none}
.is-operation-stage .pattern-import-foot{gap:8px;padding:8px 10px calc(8px + env(safe-area-inset-bottom))}.is-operation-stage .pattern-import-foot button{min-height:46px;font-size:14px}
.is-operation-stage.is-grid-stage .pattern-grid-panel{max-height:18dvh}
}
@media(max-width:600px) and (max-height:760px){.is-operation-stage .pattern-import-copy{display:none}.is-operation-stage .pattern-cloud-ocr-toggle{font-size:11px}.is-operation-stage.is-grid-stage .pattern-grid-panel{max-height:15dvh}}

/* Grid overlay controls need strong contrast over light pattern sheets. */
.pattern-grid-view-tools{background:rgba(17,24,39,.94);border:1px solid rgba(255,255,255,.24);color:#fff;box-shadow:0 6px 20px rgba(0,0,0,.3);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px)}
.pattern-grid-view-tools button{background:#fff;color:#172033;border:1px solid rgba(255,255,255,.8);font-weight:750;box-shadow:0 1px 2px rgba(0,0,0,.14)}
.pattern-grid-view-tools button:active{background:#dbeafe;color:#075fc4}
.pattern-grid-auto.is-running{background:#dbeafe;color:#075fc4;opacity:1}
@media(max-width:600px){.pattern-grid-view-tools{left:9px;top:9px;padding:4px;gap:4px}.pattern-grid-view-tools button{min-height:34px;padding:0 10px;font-size:11px}}

/* Keep legend review usable while the mobile keyboard is open. */
@media(max-width:600px){
  .is-legend-review-stage{height:100dvh;max-height:100dvh;border-radius:0}
  .is-legend-review-stage .pattern-import-body{min-height:0;padding:10px 10px 6px;scroll-padding-block:96px}
  .is-legend-review-stage .pattern-import-copy{margin-bottom:8px}
  .is-legend-review-stage .pattern-import-copy strong{font-size:17px}
  .is-legend-review-stage .pattern-import-copy span{font-size:11px}
  .is-legend-review-stage .pattern-legend-reference{top:-10px;margin-bottom:8px;padding:8px}
  .is-legend-review-stage .pattern-legend-reference-image{height:128px;max-height:128px}
  .is-legend-review-stage .pattern-legend-reference-image img{max-height:116px!important}
  .is-legend-review-stage .pattern-legend-reference-hint{display:none}
  .is-legend-review-stage .pattern-import-foot{padding:9px 10px calc(9px + env(safe-area-inset-bottom));gap:8px}
  .is-legend-review-stage .pattern-import-foot button{min-height:44px;font-size:14px}
  .is-legend-review-stage.is-keyboard-editing .pattern-import-head,
  .is-legend-review-stage.is-keyboard-editing .pattern-import-steps,
  .is-legend-review-stage.is-keyboard-editing .pattern-import-copy,
  .is-legend-review-stage.is-keyboard-editing .pattern-import-foot{display:none}
  .is-legend-review-stage.is-keyboard-editing .pattern-legend-reference{position:static;padding:6px 8px;margin-bottom:6px}
  .is-legend-review-stage.is-keyboard-editing .pattern-legend-reference-head{margin:0}
  .is-legend-review-stage.is-keyboard-editing .pattern-legend-reference-head>b{font-size:12px}
  .is-legend-review-stage.is-keyboard-editing .pattern-legend-reference-actions [data-legend-zoom],
  .is-legend-review-stage.is-keyboard-editing .pattern-legend-reference-image,
  .is-legend-review-stage.is-keyboard-editing .pattern-legend-reference-hint{display:none}
  .is-legend-review-stage.is-keyboard-editing .pattern-legend-summary{margin-bottom:6px;padding:6px 8px}
  .is-legend-review-stage.is-keyboard-editing .pattern-legend-summary>small,
  .is-legend-review-stage.is-keyboard-editing .pattern-legend-ocr-debug{display:none}
  .is-legend-review-stage.is-keyboard-editing .pattern-import-legend-list{gap:6px}
  .is-legend-review-stage.is-keyboard-editing .pattern-import-legend-row{padding:6px;scroll-margin-block:90px}
}

/* Legend review: refined iOS-style grouped editor. */
.is-legend-review-stage{--legend-blue:#007aff;--legend-bg:#f2f2f7;--legend-surface:#fff;--legend-label:#8e8e93;--legend-text:#1c1c1e;--legend-line:rgba(60,60,67,.16);background:var(--legend-bg);color:var(--legend-text)}
.is-legend-review-stage .pattern-import-head{background:rgba(249,249,251,.9);border-bottom-color:var(--legend-line);backdrop-filter:saturate(180%) blur(18px);-webkit-backdrop-filter:saturate(180%) blur(18px)}
.is-legend-review-stage .pattern-import-head h2{font-weight:700;color:var(--legend-text)}
.is-legend-review-stage .pattern-import-head p{color:var(--legend-label)}
.is-legend-review-stage .pattern-import-back,.is-legend-review-stage .pattern-import-close{background:transparent;color:var(--legend-blue);box-shadow:none}
.is-legend-review-stage .pattern-import-steps{background:rgba(249,249,251,.86);border-bottom:1px solid var(--legend-line)}
.is-legend-review-stage .pattern-import-steps span.active{background:var(--legend-blue)}
.is-legend-review-stage .pattern-import-body{background:var(--legend-bg)}
.is-legend-review-stage .pattern-import-copy{padding:2px 4px 0}
.is-legend-review-stage .pattern-import-copy strong{font-weight:750;color:var(--legend-text)}
.is-legend-review-stage .pattern-import-copy span{color:var(--legend-label)}
.is-legend-review-stage .pattern-legend-reference{border:0;border-radius:8px;padding:12px;background:rgba(255,255,255,.94);box-shadow:0 1px 2px rgba(0,0,0,.06),0 8px 24px rgba(0,0,0,.05);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px)}
.is-legend-review-stage .pattern-legend-reference-head b{font-size:15px;font-weight:700}
.is-legend-review-stage .pattern-legend-reference-actions{gap:0;padding:2px;border-radius:8px;background:#e9e9ee}
.is-legend-review-stage .pattern-legend-reference-actions button{height:30px;min-width:34px;border-radius:6px;padding:0 9px;background:transparent;color:var(--legend-blue);font-size:12px;font-weight:600}
.is-legend-review-stage .pattern-legend-reference-actions button+button{border-left:1px solid rgba(60,60,67,.12)}
.is-legend-review-stage .pattern-legend-reference-actions button:active{background:rgba(255,255,255,.72)}
.is-legend-review-stage .pattern-legend-reference-image{border-radius:6px;background:#e5e5ea;box-shadow:inset 0 0 0 1px rgba(60,60,67,.08)}
.is-legend-review-stage .pattern-legend-reference-hint{display:block;margin-top:7px;color:var(--legend-label);text-align:center;font-size:11px}
.is-legend-review-stage .pattern-legend-summary{border:0;border-radius:8px;padding:10px 12px;background:var(--legend-surface);box-shadow:inset 0 0 0 1px rgba(60,60,67,.06)}
.is-legend-review-stage .pattern-legend-summary b,.is-legend-review-stage .pattern-legend-summary strong{color:var(--legend-text);font-weight:700}
.is-legend-review-stage .pattern-legend-summary small{color:var(--legend-label)}
.is-legend-review-stage .pattern-import-legend-list{gap:0;border-radius:8px;overflow:hidden;background:var(--legend-surface);box-shadow:inset 0 0 0 1px rgba(60,60,67,.07)}
.is-legend-review-stage .pattern-import-legend-row{position:relative;border:0!important;border-radius:0;padding:10px 12px;background:transparent;box-shadow:none!important;transition:background-color .15s ease}
.is-legend-review-stage .pattern-import-legend-row:not(:last-child):after{content:"";position:absolute;left:82px;right:12px;bottom:0;height:1px;background:var(--legend-line)}
.is-legend-review-stage .pattern-import-legend-row.is-reviewing{background:#f0f7ff}
.is-legend-review-stage .legend-order{color:var(--legend-label);font-size:12px;font-variant-numeric:tabular-nums}
.is-legend-review-stage .pattern-import-swatch-pair{border-radius:8px;border:1px solid rgba(60,60,67,.12);box-shadow:0 1px 2px rgba(0,0,0,.06)}
.is-legend-review-stage .pattern-import-legend-row label small{font-size:10px;font-weight:600}
.is-legend-review-stage .pattern-import-legend-row input{height:38px;border:1px solid var(--legend-line);border-radius:7px;background:#f2f2f7;color:var(--legend-text);font-size:16px;outline:0;transition:border-color .15s ease,box-shadow .15s ease,background .15s ease}
.is-legend-review-stage .pattern-import-legend-row input:focus{border-color:var(--legend-blue);background:#fff;box-shadow:0 0 0 3px rgba(0,122,255,.14)}
.is-legend-review-stage .legend-stepper{overflow:hidden;border:1px solid var(--legend-line);border-radius:7px;background:#f2f2f7}
.is-legend-review-stage .legend-stepper button{height:36px;border-radius:0!important;background:transparent;color:var(--legend-blue);font-size:20px;font-weight:400}
.is-legend-review-stage .legend-stepper button:active{background:#dedee3}
.is-legend-review-stage .legend-stepper .legend-count{height:36px;border-width:0 1px;border-style:solid;border-color:var(--legend-line);border-radius:0;background:transparent;box-shadow:none}
.is-legend-review-stage .legend-remove{border-radius:50%;background:#f2f2f7;color:#ff3b30;font-size:18px;font-weight:400}
.is-legend-review-stage .legend-remove:active{background:#e5e5ea}
.is-legend-review-stage .pattern-import-add{width:100%;min-height:44px;border:0;border-radius:8px;margin:12px 0 4px;background:var(--legend-surface);color:var(--legend-blue);font-size:15px;font-weight:600;box-shadow:inset 0 0 0 1px rgba(60,60,67,.07)}
.is-legend-review-stage .pattern-import-foot{background:rgba(249,249,251,.9);border-top-color:var(--legend-line);backdrop-filter:saturate(180%) blur(18px);-webkit-backdrop-filter:saturate(180%) blur(18px)}
.is-legend-review-stage .pattern-import-foot button{min-height:46px;border-radius:8px;font-weight:650}
.is-legend-review-stage .pattern-import-foot .pattern-import-secondary{border:0;background:#e9e9ee;color:var(--legend-blue)}
.is-legend-review-stage .pattern-import-foot .pattern-import-primary{background:var(--legend-blue);box-shadow:0 2px 6px rgba(0,122,255,.2)}
@media(max-width:600px){
  .is-legend-review-stage .pattern-import-head{padding:10px 12px 8px}
  .is-legend-review-stage .pattern-import-head h2{font-size:18px}
  .is-legend-review-stage .pattern-import-head p{font-size:11px}
  .is-legend-review-stage .pattern-import-steps{display:none}
  .is-legend-review-stage .pattern-import-copy{padding:0 4px}
  .is-legend-review-stage .pattern-legend-reference{border-radius:8px;padding:10px}
  .is-legend-review-stage .pattern-legend-reference-actions button{padding:0 7px}
  .is-legend-review-stage .pattern-legend-reference-hint{display:none}
  .is-legend-review-stage .pattern-import-legend-row{grid-template-columns:20px 42px minmax(68px,1fr) 104px 28px;gap:6px;padding:9px 8px}
  .is-legend-review-stage .pattern-import-legend-row:not(:last-child):after{left:70px;right:8px}
  .is-legend-review-stage .pattern-import-swatch-pair{width:40px;height:34px}
  .is-legend-review-stage .legend-remove{width:28px;height:28px}
  .is-legend-review-stage.is-keyboard-editing .pattern-legend-reference{border-radius:8px;box-shadow:inset 0 0 0 1px rgba(60,60,67,.07)}
  .is-legend-review-stage.is-keyboard-editing .pattern-import-legend-row{padding:8px}
}
@media(prefers-reduced-motion:no-preference){.is-legend-review-stage .pattern-import-legend-row{animation:legend-row-in .22s ease both}.is-legend-review-stage .pattern-import-legend-row:nth-child(2){animation-delay:.025s}.is-legend-review-stage .pattern-import-legend-row:nth-child(3){animation-delay:.05s}.is-legend-review-stage .pattern-import-legend-row:nth-child(4){animation-delay:.075s}@keyframes legend-row-in{from{opacity:0;transform:translateY(5px)}to{opacity:1;transform:none}}}

/* Legend review mobile layout: one stable rule set for review and keyboard states. */
@media(max-width:600px){
  .is-legend-review-stage .pattern-legend-reference{top:-10px;margin-bottom:8px;padding:8px}
  .is-legend-review-stage .pattern-legend-reference-image{display:flex;height:96px;min-height:96px;max-height:96px;padding:5px}
  .is-legend-review-stage .pattern-legend-reference-image img{display:block;max-height:86px!important}
  .is-legend-review-stage .pattern-legend-summary{padding:8px 10px;margin-bottom:8px}
  .is-legend-review-stage .pattern-import-legend-list{overflow:visible}

  .is-legend-review-stage .pattern-import-legend-row{
    display:grid;
    grid-template-columns:22px 46px minmax(0,1fr) 34px!important;
    grid-template-rows:auto 38px auto!important;
    column-gap:8px;
    row-gap:6px;
    align-items:center;
    min-height:0;
    height:auto;
    padding:10px 10px;
    overflow:visible;
  }
  .is-legend-review-stage .legend-order{grid-column:1;grid-row:1 / 4;align-self:center}
  .is-legend-review-stage .pattern-import-swatch-pair{grid-column:2;grid-row:1 / 4;align-self:center;width:42px;height:42px}
  .is-legend-review-stage .pattern-import-legend-row>label{grid-column:3;grid-row:1 / 3;min-width:0;display:grid;grid-template-rows:auto 38px;gap:4px}
  .is-legend-review-stage .pattern-import-legend-row>label .legend-code{width:100%;min-width:0;height:38px;padding:7px 10px;font-size:15px;box-sizing:border-box}
  .is-legend-review-stage .legend-stepper{grid-column:3;grid-row:3;display:grid;grid-template-columns:36px minmax(0,1fr) 36px;width:100%;height:36px;box-sizing:border-box;align-self:start}
  .is-legend-review-stage .legend-stepper button,.is-legend-review-stage .legend-stepper .legend-count{height:34px;min-height:34px;box-sizing:border-box}
  .is-legend-review-stage .legend-stepper .legend-count{min-width:0;padding:0 4px;font-size:14px;text-align:center}
  .is-legend-review-stage .legend-remove{grid-column:4;grid-row:1 / 4;align-self:center;width:32px;height:32px;font-size:17px}
  .is-legend-review-stage .pattern-import-legend-row:not(:last-child):after{left:84px;right:10px}

  .is-legend-review-stage.is-keyboard-editing .pattern-legend-reference{
    position:sticky;
    top:0;
    z-index:12;
    display:block;
    padding:6px 8px;
    margin-bottom:6px;
    background:rgba(255,255,255,.98);
    box-shadow:0 4px 14px rgba(0,0,0,.1);
  }
  .is-legend-review-stage.is-keyboard-editing .pattern-legend-reference-head{display:flex;margin-bottom:4px}
  .is-legend-review-stage.is-keyboard-editing .pattern-legend-reference-actions{display:flex}
  .is-legend-review-stage.is-keyboard-editing .pattern-legend-reference-actions [data-legend-zoom]{display:none}
  .is-legend-review-stage.is-keyboard-editing .pattern-legend-reference-image{display:flex;height:64px;min-height:64px;max-height:64px;padding:3px}
  .is-legend-review-stage.is-keyboard-editing .pattern-legend-reference-image img{display:block;max-height:58px!important}
  .is-legend-review-stage.is-keyboard-editing .pattern-legend-summary{display:none}
  .is-legend-review-stage.is-keyboard-editing .pattern-import-legend-list{gap:0}
  .is-legend-review-stage.is-keyboard-editing .pattern-import-legend-row{min-height:86px;padding:7px 10px;scroll-margin-block:112px}
}

.pattern-verification-summary{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:0 0 12px;padding:9px 10px;border:1px solid #dfe5ee;background:#f8fafc;color:#475467;font-size:12px}.pattern-verification-summary span{display:inline-flex;align-items:center;gap:4px}.pattern-verification-summary b{color:#101828}.pattern-verification-summary .is-conflict{color:#b54708}.pattern-verification-summary button{border:1px solid #d0d5dd;background:#fff;color:#344054;padding:6px 9px;cursor:pointer}.pattern-verification-summary button:first-of-type{margin-left:auto}.pattern-all-cell.status-conflict,.pattern-all-cell.status-color-review{outline:2px solid #f79009;outline-offset:-2px}.pattern-all-cell.status-text-corrected,.pattern-all-cell.status-agree{outline:2px solid #12b76a;outline-offset:-2px}.pattern-all-cell.status-color-only{outline:2px solid #94a3b8;outline-offset:-2px}.pattern-all-cell small{overflow-wrap:anywhere}.pattern-cell-thumb>small{position:absolute;left:2px;right:2px;bottom:2px;z-index:2;overflow:hidden;padding:2px 3px;background:rgba(15,23,42,.78);color:#fff;font-size:8px;line-height:1.15;text-align:center;white-space:nowrap;text-overflow:ellipsis}.pattern-cell-thumb.status-conflict,.pattern-cell-thumb.status-color-review{border-color:#f79009}.pattern-cell-thumb.status-text-corrected,.pattern-cell-thumb.status-agree{border-color:#12b76a}.pattern-cell-thumb.status-color-only{border-color:#94a3b8}
.pattern-recognition-alert{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 14px;align-items:center;margin-bottom:14px;padding:13px 14px;border:1px solid #fda4af;border-radius:10px;background:#fff1f2;color:#9f1239}.pattern-recognition-alert strong{font-size:14px}.pattern-recognition-alert span{font-size:12px;color:#be123c}.pattern-recognition-alert button{grid-column:2;grid-row:1/3;min-height:40px;border:0;border-radius:8px;padding:0 13px;background:#be123c;color:#fff;font-weight:800}.pattern-cell-thumb.status-quantity-assigned{border-color:#bfdbfe}.pattern-cell-thumb.status-quantity-assigned small{background:#dbeafe;color:#1d4ed8}@media(max-width:600px){.pattern-recognition-alert{grid-template-columns:1fr}.pattern-recognition-alert button{grid-column:1;grid-row:auto;margin-top:6px}}

/* Full-cell review is a second modal above the importer: backdrop absorbs all outside input. */
.pattern-all-cells-overlay{position:absolute;inset:0;z-index:40;display:flex;align-items:center;justify-content:center;padding:12px;background:rgba(9,15,29,.42);touch-action:none}.pattern-all-cells-overlay .pattern-all-cells{position:relative;inset:auto;width:min(1340px,100%);height:min(920px,100%);z-index:1;box-shadow:0 20px 60px rgba(9,15,29,.32)}
@media(max-width:600px){.pattern-all-cells-overlay{padding:0}.pattern-all-cells-overlay .pattern-all-cells{width:100%;height:100%;border-radius:0}}
