/* ==========================================================================
   B · 8-bit 糖果（活泼像素游戏）视觉风格
   视觉规范：docs/style-guide.md（2026-08-13 v1）
   铁律：只改视觉，不改功能。JS 耦合点见 style-guide 第 7 节，以下
   .hidden / .canvas-wrap / .crop-stage / .crop-ratios / .crop-actions /
   #cropCanvas transform / .pixel-mode / @media 640px 均为强耦合，不可破坏。
   ========================================================================== */

@font-face {
  font-family: "FusionPixel";
  src: url("./assets/fusion-pixel-subset.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  /* 底色与纸面 */
  --bg: #FFF7E6;
  --bg-dot: rgba(59, 91, 217, 0.07);
  --card: #FFFFFF;
  --paper: #FFFFFF;
  --topbar: #FFFFFF;
  --bezel: #E9E9F2;
  /* 文字与线条 */
  --ink: #2A2B38;
  --muted: #8A8A96;
  --line: #DCDCE4;
  --line-strong: #2A2B38;
  --shadow: #C9CBE0;
  /* 主色（宝蓝） */
  --accent: #3B5BD9;
  --accent-hover: #2E49C2;
  --accent-dark: #22389B;
  --accent-soft: #E8ECFF;
  --track: #E4E4EE;
  /* 功能色 */
  --ok: #3EC9A7;
  --ok-soft: #E2F7F0;
  --ok-ink: #1E7A63;
  --warn: #FF5A4E;
  --warn-soft: #FFE9E7;
  --gold: #FFC53D;
  /* Logo 四色与糖果条纹 */
  --logo-1: #3B5BD9;
  --logo-2: #FF5A4E;
  --logo-3: #FFC53D;
  --logo-4: #3EC9A7;
  /* 打赏组件 token（057） */
  --donate: #FABC08; /* 按钮亮橙（058：加深提升与白字对比度） */
  --donate-shadow: #C8910E; /* 按钮阴影橙 */
  --donate-border: #6F4F04; /* 按钮深色边框 */
  --donate-text: #FFFFFF; /* 按钮文字纯白 */
  --strip: repeating-linear-gradient(90deg, #FF5A4E 0 56px, #FFC53D 56px 112px, #3EC9A7 112px 168px, #3B5BD9 168px 224px);
  /* 字体：标题/品牌用像素字，正文用系统黑体 */
  --font-pixel: "FusionPixel", "Microsoft YaHei", "PingFang SC", monospace;
  --font-body: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dot) 1.5px, transparent 1.5px);
  background-size: 16px 16px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--topbar);
  border-bottom: 2px solid var(--line-strong);
  box-shadow: 0 3px 0 0 var(--shadow);
  padding: 18px 20px 24px;
}

/* 底部糖果色条纹 */
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 6px;
  background: var(--strip);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

/* Logo：比特糖 2×2 四色糖果方块（SVG 每格顶面高光 + 底面暗边，双层硬投影体现糖果厚度） */
.logo-dot {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: block;
  border: 3px solid var(--accent-dark); /* 039：边框宽度 3px */
  box-sizing: content-box; /* 边框外扩，整体 52×52 */
  box-shadow: 3px 3px 0 0 var(--shadow); /* 038：阴影靠近 logo */
}
.logo-dot img { display: block; width: 100%; height: 100%; object-fit: contain; }

.topbar h1 {
  margin: 0 auto 0 4px; /* 039：标题整体左移一点（与 Logo 靠近） */
  font-family: var(--font-pixel);
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 2px; /* 039：字间距回 2px */
  color: var(--accent-dark); /* 036：标题深蓝 */
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-pixel);
  font-size: 12px;
  white-space: nowrap;
}

/* ---------- 页面布局与卡片 ---------- */
.layout {
  max-width: 1180px;
  margin: 24px auto 40px;
  padding: 0 16px;
  display: grid;
  gap: 20px;
}

.card {
  background: var(--card);
  border: 2px solid var(--line-strong);
  border-radius: 0;
  box-shadow: 6px 6px 0 0 var(--shadow);
  padding: 22px;
  min-width: 0; /* 允许 grid/flex 子项收缩，防止被内部画布撑大 */
}

.controls { display: grid; gap: 16px; }

/* 卡片标题：蓝方块 + 像素字 */
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.card-head-square {
  width: 12px;
  height: 12px;
  flex: none;
  border: 2px solid var(--line-strong);
  background: var(--accent);
  box-shadow: 2px 2px 0 0 var(--shadow);
}

.card-head h2 {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--ink);
  /* 保持 Zpix 原生 400 字重，不加粗 */
}

/* 第一行：左侧预览框 + 右侧设置列 */
.control-row {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}

.control-col {
  min-width: 0;
  display: grid;
  gap: 12px;
}

/* 图片拖入框：宽固定，高随右侧控制列拉伸（底边对齐移除背景框） */
.dropzone {
  width: 250px;
  border: 2px dashed var(--line-strong);
  border-radius: 0;
  background: var(--card);
  box-shadow: 6px 6px 0 0 var(--shadow);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
  outline: none;
  overflow: hidden;
  display: flex;
}

.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 16px;
}

.dz-icon { font-size: 34px; margin: 0 0 6px; }
.dz-main { margin: 0; font-weight: 700; }
.dz-hint { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }

.dropzone.has-file .dropzone-inner { display: none; }

/* 已选择图片后的预览 */
.dz-preview {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  padding: 12px;
}

.dropzone.has-file .dz-preview { display: flex; }

#previewImg {
  max-width: 100%;
  /* 固定高度上限：百分比 max-height 在高度不确定的 flex/grid 容器中会失效，
     长图会按自然高度把操作面板撑长；改用绝对像素上限，超出部分被容器裁切 */
  max-height: 220px;
  object-fit: contain;
  border: 2px solid var(--line-strong);
  border-radius: 0;
  background: #fff;
}

.dz-name {
  margin: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.dz-replace {
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-dark);
  background: #fff;
  border: 2px solid var(--line-strong);
  border-radius: 0;
  box-shadow: 3px 3px 0 0 var(--shadow);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.1s ease;
}

.dz-replace:hover { background: var(--accent-soft); }
.dz-replace:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 0 var(--shadow); }

/* 裁切按钮 + 分辨率滑块同一行 */
.crop-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.crop-row .field.grow { flex: 1 1 260px; }

.field { display: grid; gap: 7px; }

.field label { font-size: 13px; font-weight: 700; color: var(--ink); }

.field input[type="text"], .field select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--line-strong);
  border-radius: 0;
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field select { height: 45px; } /* 固定色卡选框高度（Chrome 中 select 的 line-height 不生效，只能固定 height）；与 .field-row > .check 等高 */

.field input[type="text"]:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 3px 3px 0 0 var(--accent-soft);
}

.label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* 分辨率数字：可点击手动输入 */
.label-row input[type="number"] {
  width: 86px;
  padding: 4px 8px;
  border: 2px solid var(--line-strong);
  border-radius: 0;
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-dark);
  text-align: center;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.label-row input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 3px 3px 0 0 var(--accent-soft);
}

/* 滑块：方形 thumb + 硬边框轨道 */
input[type="range"] {
  width: 100%;
  height: 34px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  accent-color: var(--accent);
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 12px;
  border: 2px solid var(--line-strong);
  border-radius: 0;
  background: var(--track);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -4px; /* 16px 拇指相对 12px 轨道垂直居中 */
  
  border: 2px solid var(--line-strong);
  border-radius: 0;
  background: var(--accent);
  box-shadow: 2px 2px 0 0 var(--shadow);
}

input[type="range"]::-moz-range-track {
  height: 12px;
  border: 2px solid var(--line-strong);
  border-radius: 0;
  background: var(--track);
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid var(--line-strong);
  border-radius: 0;
  background: var(--accent);
  box-shadow: 2px 2px 0 0 var(--shadow);
}

.hint { margin: 0; color: var(--muted); font-size: 12.5px; }

.field-row { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.field-row > .check {
  align-self: flex-end; /* 底边贴齐行底（= 色卡 select 输入框底边） */
  font-size: 14px; /* 与色卡 select 同字号 */
  line-height: 21px; /* 内容行高，保证文字垂直居中 */
  height: 45px; /* 与 .field select 固定高度一致 → 两框任何字体环境下完全等高 */
}
.field.grow { flex: 1 1 220px; }

/* 复选框（像素方块） */
.check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 2px solid var(--line-strong);
  border-radius: 0;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  flex: none;
  margin: 0;
  border: 2px solid var(--line-strong);
  border-radius: 0;
  background: #fff;
  cursor: pointer;
  transition: background 0.1s ease, box-shadow 0.1s ease;
}

.check input[type="checkbox"]:hover { border-color: var(--accent); }

.check input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 3px #fff;
}

.check input[type="checkbox"]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* 移除背景：复选框 + 相似阈值滑块 */
.bg-box {
  border: 2px solid var(--line-strong);
  border-radius: 0;
  background: #fff;
  box-shadow: 4px 4px 0 0 var(--shadow);
  padding: 2px 12px 8px;
  display: grid;
  gap: 2px;
  /* 与色卡栏自然高度等高：开启滑块时只向下扩展，不挤压/移动其它控件 */
  min-height: 72px;
}

.bg-box .check {
  border: none;
  box-shadow: none;
  padding: 8px 0;
  background: transparent;
  /* 勾选展开滑块时复选框自身高度保持不变，避免“被挤矮” */
  align-self: start;
}

.bg-threshold { display: grid; gap: 2px; }

.bg-threshold .label-row {
  font-size: 12.5px;
  color: var(--muted);
}

.bg-threshold input[type="range"] { height: 22px; }

.actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* 按钮：直角 + 硬阴影，按下时投影被位移抵消 */
.btn {
  border: 2px solid var(--line-strong);
  border-radius: 0;
  padding: 12px 24px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease, box-shadow 0.1s ease, opacity 0.15s ease;
}

.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.btn.small { padding: 10px 16px; font-size: 13.5px; }

.btn.primary {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 4px 0 0 var(--accent-dark);
}

.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn.primary:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 0 var(--accent-dark);
}

.btn.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: 0 4px 0 0 var(--shadow);
}

.btn.ghost {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 4px 0 0 var(--shadow);
}

.btn.ghost:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.btn.ghost:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 0 var(--shadow);
}

.btn.ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: 0 4px 0 0 var(--shadow);
}

.export-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* 移动端（052）：预览工具栏缩放档位横向滚动 + 导出按钮并排 + 颜色清单收紧 */
@media (max-width: 640px) {
  .preview-toolbar { gap: 8px; }
  .zoom-buttons {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    max-width: 100%;
  }
  .zoom-buttons::-webkit-scrollbar { display: none; }
  .zoom-buttons .chip { flex-shrink: 0; }
  .toolbar-hint { width: 100%; }
  .export-row { width: 100%; }
  .export-row .btn { flex: 1 1 auto; width: auto; }
  .color-panel { padding: 10px; }
}

/* JS 显隐开关（强耦合：display:none !important 不可删） */
.hidden { display: none !important; }

/* 统计条 */
.stats {
  background: var(--ok-soft);
  border: 2px solid var(--line-strong);
  border-radius: 0;
  box-shadow: 4px 4px 0 0 var(--shadow);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ok-ink);
  margin-bottom: 14px;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.toolbar-label { font-size: 13px; color: var(--muted); }

.mode-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.zoom-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.toolbar-hint { color: var(--muted); font-size: 12.5px; }

/* 标签 chip（模式 / 缩放 / 比例共用） */
.chip {
  border: 2px solid var(--line-strong);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 0 0 var(--shadow);
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease, box-shadow 0.1s ease;
}

.chip:hover { background: var(--accent-soft); }

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 3px 0 0 var(--accent-dark);
}

.chip:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 0 var(--shadow);
}

.chip:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* 预览画布容器（强耦合：尺寸/overflow/cursor/touch-action 不可破坏） */
.canvas-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: min(72vh, 820px);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--line-strong);
  border-radius: 0;
  /* 棋盘格：透明区语义，可换色但必须可辨认 */
  background: repeating-conic-gradient(#EFEFF6 0% 25%, #FFFFFF 0% 50%) 50% / 20px 20px;
  box-shadow: 0 0 0 5px var(--bezel), 6px 6px 0 0 var(--shadow);
  cursor: grab;
  touch-action: none; /* 触屏拖拽平移时不被页面滚动拦截 */
  user-select: none;
  position: relative;
}

.canvas-wrap.dragging { cursor: grabbing; }

/* 角落像素角标（纯装饰，不拦截交互） */
.canvas-wrap::before,
.canvas-wrap::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border: 2px solid var(--line-strong);
  pointer-events: none;
  z-index: 1;
}

.canvas-wrap::before { left: 6px; top: 6px; }
.canvas-wrap::after { right: 6px; bottom: 6px; }

#sheetCanvas { display: block; image-rendering: auto; will-change: transform; }

/* 像素图模式：放大时保持像素颗粒感（最近邻）——强耦合，不可删 */
.canvas-wrap.pixel-mode #sheetCanvas { image-rendering: pixelated; }

/* 颜色清单 / 去除杂色面板（直角 + 硬边框 + token 配色，遵守 style-guide） */
.color-panel {
  margin-top: 12px;
  background: var(--card);
  border: 2px solid var(--line-strong);
  border-radius: 0;
  box-shadow: 4px 4px 0 0 var(--shadow);
  padding: 12px;
}
.color-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.color-panel-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.color-panel-meta {
  font-size: 12px;
  color: var(--muted);
}
.color-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.color-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  background: var(--card);
  border: 2px solid var(--line-strong);
  border-radius: 0;
  box-shadow: 0 3px 0 0 var(--shadow);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.color-item-id,
.color-item-count {
  color: var(--ink); /* 编号/数量统一深墨色（文字在白色卡片背景上，勿按色块亮度自适应） */
}
.color-item-count {
  margin-left: 8px; /* 与色号拉开间距 */
}

.color-item:hover,
.color-item:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  box-shadow: 0 3px 0 0 var(--accent-soft);
}
.color-swatch {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  display: inline-block;
}
.color-panel-hint {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.empty-hint {
  color: var(--muted);
  text-align: center;
  padding: 40px 10px;
  margin: 0;
  font-size: 13px;
}

.page-footer {
  max-width: 1180px;
  margin: 0 auto 34px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 12.5px;
}

.page-footer p { margin: 0; }

/* ---------- 图片裁切弹窗 ---------- */
.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(24, 26, 48, 0.88);
  display: flex;
  flex-direction: column;
}

.crop-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  flex: none;
  border-bottom: 2px solid rgba(255, 255, 255, 0.28);
}

.crop-hint {
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.crop-close {
  width: 38px;
  height: 38px;
  border-radius: 0;
  border: 2px solid #fff;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 3px 3px 0 0 rgba(0, 0, 0, 0.4);
  transition: background 0.15s ease;
}

.crop-close:hover { background: rgba(255, 255, 255, 0.32); }
.crop-close:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 0 rgba(0, 0, 0, 0.4); }

/* 强耦合：position:relative + 不裁剪（无 overflow:hidden）+ padding-left:118px */
.crop-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px 28px 118px;
}

/* 裁切比例按钮：左侧竖排（强耦合：left:18px / top:50% 不可改） */
.crop-ratios {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 6;
}

.crop-ratio {
  border: 2px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-radius: 0;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  text-align: center;
}

.crop-ratio:hover { background: rgba(255, 255, 255, 0.32); }

.crop-ratio.active {
  background: #fff;
  color: var(--accent-dark);
  font-weight: 700;
}

#cropCanvas {
  max-width: 100%;
  max-height: 100%;
  /* 强耦合：位移参与 getBoundingClientRect 命中检测，不可改 */
  transform: translate(-3%, -4%);
  box-shadow: 0 0 0 3px var(--bezel), 8px 8px 0 0 rgba(0, 0, 0, 0.4);
  background: #222;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  border-radius: 0;
}

/* 强耦合：position/transform/z-index 由 JS 命中计算依赖，不可改 */
.crop-actions {
  position: absolute;
  display: flex;
  gap: 12px;
  transform: translate(-50%, 10px);
  z-index: 5;
}

.crop-btn {
  width: 46px;
  height: 46px;
  border-radius: 0;
  border: 3px solid #fff;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 0 rgba(0, 0, 0, 0.45);
  transition: transform 0.1s ease;
}

.crop-btn:active { transform: translateY(2px); }

.crop-ok { background: var(--ok); color: #fff; }
.crop-no { background: var(--warn); color: #fff; }

/* 像素图导出倍率选择 */
.export-scale {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.export-scale select {
  padding: 4px 6px;
  border: 2px solid var(--line-strong);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  box-shadow: 2px 2px 0 0 var(--shadow);
}

/* 裁切弹窗打开时锁定背景滚动（强耦合） */
body.crop-open { overflow: hidden; }

/* 移动端断点（强耦合：结构规则不可删） */
@media (max-width: 640px) {
  .topbar h1 { font-size: 20px; }
  #previewImg { max-height: 150px; }
  .card { padding: 16px; }
  .control-row { grid-template-columns: 1fr; }
  .dropzone { width: 100%; height: 260px; }
  .actions { flex-direction: column; align-items: stretch; }
  .btn { width: 100%; }
  .crop-row { flex-direction: column; }
  .crop-row .field.grow { width: 100%; }
  .topbar { padding: 12px 14px 18px; }
  .topbar-inner { gap: 10px; }
  .tagline { white-space: normal; }
  .view-tabs { width: 100%; margin-left: 0; }
  .view-tab { flex: 1 1 auto; text-align: center; }
  .canvas-wrap { height: min(55vh, 460px); }
}

/* ===== 绘制视图（B 阶段） ===== */
.view-tabs { display: flex; gap: 8px; margin-left: 16px; flex-shrink: 0; }
.view-tab {
  font-family: var(--font-body); font-size: 13px;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--line-strong); border-radius: 0;
  padding: 6px 12px; cursor: pointer;
  box-shadow: 0 3px 0 0 var(--shadow);
}
.view-tab:hover { background: var(--accent-soft); }
.view-tab.active { background: var(--accent); color: #fff; box-shadow: 0 3px 0 0 var(--accent-dark); }
.view-tab.active:hover { background: var(--accent-hover); }

.draw-view { display: flex; flex-direction: column; gap: 12px; }
.draw-stage { display: flex; gap: 12px; align-items: stretch; }
.draw-toolbar {
  width: 96px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--card);
  border: 2px solid var(--line-strong); border-radius: 0;
  box-shadow: 4px 4px 0 0 var(--shadow);
  padding: 10px; overflow-y: auto;
  max-height: min(72vh, 820px);
}
.tool-btn {
  font-family: var(--font-body); font-size: 12px;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--line-strong); border-radius: 0;
  padding: 8px 6px; cursor: pointer; width: 100%;
  box-shadow: 0 3px 0 0 var(--shadow);
  text-align: center; line-height: 1.3;
}
.tool-btn:hover { background: var(--accent-soft); }
.tool-btn.active { background: var(--accent); color: #fff; box-shadow: 0 3px 0 0 var(--accent-dark); }
.tool-btn.active:hover { background: var(--accent-hover); }
.tool-btn:disabled { opacity: .45; cursor: not-allowed; }
.tool-divider { height: 2px; background: var(--line); margin: 2px 0; flex-shrink: 0; }
.draw-size { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--ink); margin-top: -6px; /* 034：与上方分隔线收紧 */ }
.draw-size-label { text-align: center; font-weight: 700; }
.draw-size-col { display: flex; flex-direction: column; gap: 4px; }
.draw-size-item { display: flex; align-items: center; justify-content: flex-start; gap: 6px; font-size: 12px; color: var(--ink); }
.draw-size-item input[type="number"] {
  width: 64px; height: 32px; box-sizing: border-box;
  border: 2px solid var(--line-strong); border-radius: 0;
  font-size: 13px; font-weight: 700; text-align: center; background: var(--card); color: var(--ink);
  padding-right: 4px; /* 三位数不被右侧加减按钮遮挡 */
}
.draw-size-item input:focus { border-color: var(--accent); box-shadow: 2px 2px 0 0 var(--accent-soft); outline: none; }
.draw-canvas-wrap {
  flex: 1; min-width: 0; position: relative; overflow: hidden;
  border: 2px solid var(--line-strong); border-radius: 0;
  box-shadow: 0 0 0 5px var(--bezel), 6px 6px 0 0 var(--shadow);
  background: repeating-conic-gradient(#EFEFF6 0% 25%, #FFFFFF 0% 50%) 50% / 20px 20px;
  cursor: crosshair; touch-action: none; user-select: none; overscroll-behavior: contain;
  height: min(72vh, 820px);
}
.draw-canvas-wrap.tool-move { cursor: grab; }
.draw-canvas-wrap.dragging { cursor: grabbing; }
#drawCanvas { position: absolute; left: 0; top: 0; }
.draw-empty-hint {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px; text-align: center; padding: 20px;
  pointer-events: none;
}
.draw-bottom-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 2px solid var(--line-strong); border-radius: 0;
  box-shadow: 4px 4px 0 0 var(--shadow);
  padding: 10px 12px;
}
.draw-palette { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.pen-swatch {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  background: var(--card); border: 2px solid var(--line-strong); border-radius: 0;
  padding: 4px 8px 4px 4px; cursor: default;
  box-shadow: 0 3px 0 0 var(--shadow); font-size: 12px; font-weight: 700; color: var(--ink);
}
.pen-swatch-color { width: 20px; height: 20px; border: 1px solid var(--line-strong); display: inline-block; }
.pen-swatch-id { color: var(--ink); }
.draw-color-list { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0; }
.draw-color-item {
  width: 26px; height: 26px; flex-shrink: 0;
  border: 2px solid var(--line-strong); border-radius: 0;
  padding: 0; cursor: pointer; position: relative;
  box-shadow: 0 2px 0 0 var(--shadow);
}
.draw-color-item:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.draw-color-item.active { outline: 2px solid var(--gold); outline-offset: 1px; }
.draw-palette-select { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink); flex-shrink: 0; }
.draw-palette-select select {
  height: 34px; box-sizing: border-box;
  border: 2px solid var(--line-strong); border-radius: 0;
  background: var(--card); font-size: 13px; color: var(--ink); padding: 0 6px;
}
.draw-export { display: flex; gap: 8px; flex-shrink: 0; }

@media (max-width: 640px) {
  .view-tabs { margin-left: 0; }
  .view-tab { padding: 4px 8px; font-size: 12px; }
  .draw-stage { flex-direction: column; }
  .draw-toolbar { width: 100%; flex-direction: row; overflow-x: auto; overflow-y: hidden; max-height: none; }
  .draw-toolbar .tool-btn { width: auto; flex-shrink: 0; }
  .tool-divider { width: 2px; height: auto; margin: 0 2px; }
  .draw-size { flex-direction: row; align-items: center; }
  .draw-canvas-wrap { height: 50vh; }
  .draw-bottom-bar { flex-wrap: wrap; }
  .draw-export { width: 100%; justify-content: flex-end; }
}

/* 绘制视图 B 阶段调整：画笔色移工具栏 + 色卡弹层 + 画布用色 */
.draw-toolbar { position: relative; overflow-x: hidden; }

/* 移动端（052）：工具栏横向可滚动 + 画板高度修复 + 底栏重排 */
@media (max-width: 640px) {
  /* 桌面规则 overflow-x:hidden 会覆盖上方断点内的 overflow-x:auto，这里显式恢复 */
  .draw-toolbar {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    align-items: center;
    padding: 8px;
  }
  .draw-toolbar::-webkit-scrollbar { display: none; }
  .draw-toolbar .tool-btn { white-space: nowrap; padding: 10px 12px; font-size: 13px; }
  .draw-size { flex-shrink: 0; }
  .tool-divider { flex-shrink: 0; }
  .pen-swatch { width: auto; flex-shrink: 0; }
  /* flex:1 的 flex-basis:0 在纵向 flex 中覆盖 height → 画板塌陷成一条线；改 flex:none + 固定高度 */
  .draw-canvas-wrap { flex: none; width: 100%; height: 50vh; min-height: 300px; }
  .draw-bottom-bar { padding: 10px; gap: 10px; }
  .draw-palette { flex: 1 1 100%; }
  .draw-palette-select { flex: 1 1 auto; }
  .draw-export { width: auto; justify-content: flex-end; }
  .draw-bottom-bar .btn { width: auto; }
}
.pen-swatch { width: 100%; justify-content: flex-start; cursor: pointer; }
.pen-swatch:hover { background: var(--accent-soft); }
.draw-palette-popover {
  position: fixed; z-index: 70; /* 高于顶栏(60)：手机上弹层贴视口顶显示时不被顶栏遮挡（054） */
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  background: transparent; border: none; box-shadow: none; padding: 0;
}
.draw-popover-card {
  background: var(--card);
  border: 2px solid var(--line-strong); border-radius: 0;
  box-shadow: 4px 4px 0 0 var(--shadow);
  padding: 10px;
  width: 224px; max-height: 340px; overflow-y: auto;
}
.draw-popover-card-title { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.draw-popover-list { display: flex; flex-wrap: wrap; gap: 6px; }
.draw-popover-item {
  width: 26px; height: 26px; flex-shrink: 0;
  border: 2px solid var(--line-strong); border-radius: 0;
  padding: 0; cursor: pointer;
  box-shadow: 0 2px 0 0 var(--shadow);
}
.draw-popover-item:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.draw-popover-item.active { outline: 2px solid var(--gold); outline-offset: 1px; }
.draw-palette-label { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.draw-color-empty { font-size: 12px; color: var(--muted); }

/* 画板右上角控制（网格 / 色号显隐） */
.draw-view-controls {
  position: absolute; top: 8px; right: 8px; z-index: 10;
  display: flex; gap: 6px;
}
.view-control-btn {
  font-family: var(--font-body); font-size: 11px;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--line-strong); border-radius: 0;
  padding: 3px 8px; cursor: pointer;
  box-shadow: 0 2px 0 0 var(--shadow);
}
.view-control-btn:hover { background: var(--accent-soft); }
.view-control-btn.active { background: var(--accent); color: #fff; box-shadow: 0 2px 0 0 var(--accent-dark); }
.view-control-btn.active:hover { background: var(--accent-hover); }

/* 绘制视图导入图片转拼豆面板（C 阶段） */
.draw-import-modal {
  position: fixed; z-index: 50;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 380px; max-width: 92vw; max-height: 90vh; overflow-y: auto;
  background: var(--card);
  border: 2px solid var(--line-strong); border-radius: 0;
  box-shadow: 6px 6px 0 0 var(--shadow);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.draw-import-head { display: flex; align-items: center; justify-content: space-between; }
.draw-import-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.draw-import-close {
  background: var(--card); border: 2px solid var(--line-strong); border-radius: 0;
  width: 28px; height: 28px; cursor: pointer; color: var(--ink); font-size: 13px;
  box-shadow: 0 2px 0 0 var(--shadow);
}
.draw-import-close:hover { background: var(--accent-soft); }
#drawImportPreview {
  max-width: 100%; max-height: 240px; object-fit: contain;
  border: 2px solid var(--line); border-radius: 0;
}
.draw-import-size { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink); }
.draw-import-size label { flex-shrink: 0; }
.draw-import-size input[type="range"] { flex: 1; min-width: 0; }
.draw-import-size input[type="number"] {
  width: 64px; height: 32px; box-sizing: border-box;
  border: 2px solid var(--line-strong); border-radius: 0;
  font-size: 13px; font-weight: 700; text-align: center; color: var(--ink);
}
.draw-import-actions { display: flex; justify-content: flex-end; }

/* 025：预览框右上角「移到绘制编辑」+ 绘制画板左上角「定位」 */
#sendToDrawBtn {
  position: absolute; top: 10px; right: 10px; z-index: 10;
  font-size: 13px;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 3px 0 0 var(--accent-dark);
}
#sendToDrawBtn:hover { background: var(--accent-hover); }
.draw-view-controls-left {
  left: 8px; right: auto;
}

/* 绘制视图裁切弹窗：图片显示区调大（padding 收紧） */
.draw-crop-stage { padding: 6px 16px 18px 118px; }

/* 图片裁切弹窗（居中弹窗样式，两视图共用；028 取代原全屏 crop-modal） */
.crop-dialog {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 100;
  width: 920px; max-width: 96vw;
  height: 62vh; min-height: 420px; /* 050：高度调低 35%（96vh×0.65） */
  background: var(--card);
  border: 2px solid var(--line-strong); border-radius: 0;
  box-shadow: 8px 8px 0 0 rgba(24, 26, 48, 0.35);
  display: flex; flex-direction: column;
}
.crop-dialog-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 16px; /* 049：压缩，给图片区更多空间 */
  border-bottom: 2px solid var(--line);
}
.crop-dialog-title { font-size: 15px; font-weight: 700; color: var(--ink); }
.crop-dialog-close {
  width: 32px; height: 32px;
  border: 2px solid var(--line-strong); border-radius: 0;
  background: var(--card); color: var(--ink); font-size: 14px;
  cursor: pointer; box-shadow: 0 2px 0 0 var(--shadow);
}
.crop-dialog-close:hover { background: var(--accent-soft); }
.crop-dialog-body {
  flex: 1; min-height: 0;
  display: flex; gap: 12px; padding: 10px 16px 12px; /* 049：压缩 */
}
.crop-dialog-body .crop-ratios {
  position: static; top: auto; left: auto; transform: none; z-index: auto;
  flex-direction: column; gap: 6px;
  width: 84px; flex-shrink: 0;
}
.crop-dialog-body .crop-ratio {
  border: 2px solid var(--line-strong);
  background: var(--card); color: var(--ink);
  box-shadow: 0 2px 0 0 var(--shadow);
}
.crop-dialog-body .crop-ratio:hover { background: var(--accent-soft); }
.crop-dialog-body .crop-ratio.active {
  background: var(--accent); color: #fff; box-shadow: 0 2px 0 0 var(--accent-dark);
}
.crop-dialog-body .crop-stage {
  flex: 1; min-width: 0; min-height: 0;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 8px;
  border: 2px solid var(--line);
  background: var(--paper);
  margin-top: 8px; /* 048：图片框下移一点 */
}
.crop-dialog-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 16px; /* 049：压缩 */
  border-top: 2px solid var(--line);
}
.crop-dialog-hint { font-size: 12px; color: var(--muted); }
.crop-dialog-actions { display: flex; gap: 8px; }

/* 横幅（比特糖）：操作面板前全宽色块，高度约操作面板 1/3 */
.hero-banner {
  width: 100%;
  background:
    radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(135deg, var(--hero-1) 0%, var(--hero-2) 100%); /* 039：横幅渐变偏青、降饱和 */
  color: #fff;
  min-height: 150px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-bottom: 2px solid var(--line-strong);
  box-shadow: 0 3px 0 0 var(--shadow);
  position: relative;
}
.hero-banner-inner {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 16px 34px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hero-banner::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 6px;
  background: var(--strip);
}
.hero-title {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: 28px;
  line-height: 1.35;
  color: #fff;
}
.hero-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #C9EAF9; /* 043：浅青，适配青蓝横幅 */
}
.hero-text strong { color: #fff; }
@media (max-width: 640px) {
  .hero-banner { min-height: 110px; }
  .hero-banner-inner { padding: 20px 16px 26px; }
  .hero-title { font-size: 20px; }
  .hero-text { font-size: 12px; }
}

/* 图纸命名弹窗（032） */
.draw-title-body input[type="text"] {
  width: 100%; height: 38px; box-sizing: border-box;
  border: 2px solid var(--line-strong); border-radius: 0;
  font-size: 14px; padding: 0 8px; color: var(--ink); background: var(--card);
}
.draw-title-body input:focus { border-color: var(--accent); box-shadow: 3px 3px 0 0 var(--accent-soft); outline: none; }
/* 定位按钮移到左下角（032） */
.draw-view-controls-left-2 { left: 8px; right: auto; top: auto; bottom: 8px; }

/* 全局即时提示（033） */
.global-tooltip {
  position: fixed; z-index: 999;
  max-width: 260px;
  background: var(--card);
  border: 2px solid var(--line-strong); border-radius: 0;
  box-shadow: 3px 3px 0 0 var(--shadow);
  padding: 5px 8px;
  font-size: 12px; line-height: 1.4; color: var(--ink);
  pointer-events: none; display: none; white-space: normal;
}
/* 画笔色弹层字母分区 + 历史（033） */
.draw-popover-list { display: block; }
.draw-popover-group-head { font-size: 11px; font-weight: 700; color: var(--muted); margin: 4px 0 2px; }
.draw-popover-group { display: flex; flex-wrap: wrap; gap: 6px; }
.draw-popover-sep { height: 2px; background: var(--line); margin: 8px 0 2px; }

:root {
  /* 039：横幅渐变（偏青、降低饱和度） */
  --hero-1: #4FB6D8; /* 043：再提亮 */
  --hero-2: #2F84B8;
}

/* 页脚署名与联系（045） */
.footer-meta { margin-top: 8px; color: var(--muted); }
.footer-meta a { color: var(--accent); }

/* 移动端（054）：工具栏整体缩小，一行展示更多工具 */
@media (max-width: 640px) {
  .draw-toolbar { gap: 5px; padding: 6px; }
  .draw-toolbar .tool-btn { padding: 7px 9px; font-size: 12px; line-height: 1.3; }
  .draw-size { gap: 3px; }
  .draw-size-label { font-size: 11px; }
  .draw-size-item { gap: 3px; font-size: 11px; }
  .draw-size-item input[type="number"] { width: 46px; height: 27px; font-size: 12px; padding-right: 2px; }
  .pen-swatch { width: auto; flex-shrink: 0; padding: 3px 7px 3px 3px; font-size: 11px; }
  .pen-swatch-color { width: 16px; height: 16px; }
}

/* 色块上的色号文字（055）：桌面端隐藏（26px 纯色块），移动端断点内 8px 显示 */
.draw-swatch-labeled {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  line-height: 1;
  font-weight: 700;
  overflow: hidden;
}
.swatch-text-dark { color: var(--ink); }
.swatch-text-light { color: #fff; }

/* 移动端（055）：撤回/重做移到画布右下角（桌面端隐藏，桌面工具栏内有原按钮） */
.draw-undo-group {
  top: auto;
  bottom: 8px;
  display: none;
}

/* 移动端（055）：工具栏顺序重排 + 撤回重做显示在画布内 + 色块显示色号 */
@media (max-width: 640px) {
  .draw-toolbar > [data-mo="0"] { order: 0; }
  .draw-toolbar > [data-mo="1"] { order: 1; }
  .draw-toolbar > [data-mo="2"] { order: 2; }
  .draw-toolbar > [data-mo="3"] { order: 3; }
  .draw-toolbar > [data-mo="4"] { order: 4; }
  .draw-toolbar > [data-mo="5"] { order: 5; }
  .draw-toolbar > [data-mo="6"] { order: 6; }
  .draw-toolbar > [data-mo="7"] { order: 7; }
  .draw-toolbar > [data-mo="8"] { order: 8; }
  .draw-toolbar > [data-mo="9"] { order: 9; }
  .draw-toolbar > [data-mo="10"] { order: 10; }
  .draw-toolbar > [data-mo="11"] { order: 11; }
  .draw-toolbar > [data-mo="12"] { order: 12; }
  .draw-toolbar > [data-mo="13"] { order: 13; }
  .draw-toolbar > [data-mo="14"] { order: 14; }
  #undoBtn, #redoBtn { display: none; }
  .draw-undo-group { display: flex; }
  .draw-swatch-labeled { font-size: 8px; }
  .draw-color-item, .draw-popover-item { width: 28px; height: 28px; }
}

/* 移动端（052）：裁切弹窗比例按钮改横排可滚动，图片区占满剩余空间 */
@media (max-width: 640px) {
  .crop-dialog { width: 94vw; height: 70vh; min-height: 400px; }
  .crop-dialog-body { flex-direction: column; gap: 8px; padding: 8px 10px 10px; }
  .crop-dialog-body .crop-ratios { flex-direction: row; width: 100%; overflow-x: auto; }
  .crop-dialog-body .crop-ratio { flex-shrink: 0; white-space: nowrap; }
  .crop-dialog-body .crop-stage { margin-top: 0; }
}

/* App 启动页覆盖层（056）：仅安卓 App 内由内联脚本加 .show 显示，浏览器环境保持隐藏 */
.app-splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #fff;
  display: none;
  align-items: center;
  justify-content: center;
}
.app-splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  transform: translateY(-6vh); /* 仅内容略偏屏幕中心上方，白色背景保持全屏覆盖 */
}
.app-splash.show { display: flex; }
.app-splash-logo { width: 96px; height: 96px; }
.app-splash-name {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: 2px;
  color: var(--accent-dark); /* 品牌深蓝，与顶栏标题一致 */
  font-weight: 400;
}
.app-splash-sub { margin: 0; font-size: 13px; color: var(--muted); }

/* ===== 打赏功能（057）：橙色强调系，规范见 style-guide 5.16 ===== */
.donate-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.donate-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border: 2px solid var(--donate-border);
  border-radius: 0;
  background: var(--donate);
  color: var(--donate-text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 0 var(--donate-shadow);
  transition: transform 0.1s ease, background 0.15s ease, box-shadow 0.1s ease;
  text-decoration: none;
}
.donate-btn:hover { background: #FCCB3E; color: var(--donate-text); }
.donate-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 0 var(--donate-shadow); }
.donate-btn:focus-visible { outline: 2px solid var(--donate-border); outline-offset: 2px; }
.donate-btn.small { padding: 8px 14px; font-size: 13px; box-shadow: 0 3px 0 0 var(--donate-shadow); }
.donate-btn-icon { width: 20px; height: 20px; flex: none; }
.donate-note {
  margin: 0 0 14px; /* 058：与下方「提示」拉大间距 */
  max-width: 640px;
  text-align: center;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}

/* 打赏弹窗（居中白底，同 crop-dialog 风格；橙色强调） */
body.donate-open { overflow: hidden; }
.donate-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  width: 460px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card);
  border: 2px solid var(--line-strong);
  border-radius: 0;
  box-shadow: 8px 8px 0 0 rgba(24, 26, 48, 0.35);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.donate-head { display: flex; align-items: center; justify-content: space-between; }
.donate-title { font-size: 15px; font-weight: 700; color: var(--ink); }
.donate-close {
  width: 28px;
  height: 28px;
  border: 2px solid var(--line-strong);
  border-radius: 0;
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 0 0 var(--shadow);
}
.donate-close:hover { background: #FFF3D6; border-color: var(--donate-border); }
.donate-body { display: flex; flex-direction: column; gap: 12px; }
.donate-methods { display: flex; flex-direction: column; gap: 10px; }
.donate-method {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 2px solid var(--line-strong);
  border-radius: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  box-shadow: 0 3px 0 0 var(--shadow);
  transition: transform 0.1s ease, background 0.15s ease, box-shadow 0.1s ease;
}
.donate-method:hover { background: #FFF3D6; border-color: var(--donate-border); box-shadow: 0 3px 0 0 var(--donate-shadow); }
.donate-method:active { transform: translateY(2px); box-shadow: 0 1px 0 0 var(--donate-shadow); }
.donate-method:focus-visible { outline: 2px solid var(--donate-border); outline-offset: 2px; }
.donate-method-badge {
  width: 26px;
  height: 26px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  border: 2px solid var(--line-strong);
  border-radius: 0;
}
.donate-method-badge.wechat { background: #07C160; }
.donate-method-badge.alipay { background: #1677FF; }
.donate-method-badge.paypal { background: #003087; }
.donate-qr { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.donate-qr-img {
  max-width: 240px;
  max-height: 240px;
  width: auto;
  height: auto;
  background: #fff;
  border: 2px solid var(--donate-border);
  border-radius: 0;
  padding: 6px;
}
.donate-qr-name { margin: 0; font-size: 13px; font-weight: 700; color: var(--ink); text-align: center; word-break: break-all; }
.donate-qr-hint { margin: 0; max-width: 300px; font-size: 11px; line-height: 1.6; color: var(--muted); text-align: center; }
.donate-qr-actions { display: flex; gap: 8px; margin-top: 4px; }
.donate-foot { border-top: 2px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.donate-foot p { margin: 0; font-size: 11px; line-height: 1.6; color: var(--muted); text-align: center; }
.donate-foot a { color: var(--donate-border); font-weight: 700; }
