/* Pixel Paint 游戏壳 · 移动优先设计 */
:root {
  --gp-bg: #f4faf6;
  --gp-surface: #ffffff;
  --gp-ink: #1b3a2b;
  --gp-ink-light: #4a6b5a;
  --gp-brand: #2f9e44;
  --gp-brand-dark: #237b34;
  --gp-brand-light: #d3f9d8;
  --gp-accent: #ffd43b;
  --gp-line: #c8e6c9;
  --gp-danger: #e03131;
  --gp-radius: 14px;
  --game-bg-1: #8bc34a;
  --game-bg-2: #689f38;
  /* UI 控件配色变量（随主题切换）：按钮底/描边/图标色/外部标签色 */
  --ui-btn-bg: rgba(255, 255, 255, 0.25);
  --ui-btn-border: rgba(255, 255, 255, 0.85);
  --ui-btn-ink: #fff;
  --ui-btn-active-bg: rgba(255, 255, 255, 0.45);
  --ui-label: #fff;
  /* 表面（侧栏/浮层） */
  --ui-surface: #ffffff;
  --ui-surface-2: #f8fdf9;
  --ui-ink: #1b3a2b;
  --ui-ink-light: #4a6b5a;
  --ui-line: #c8e6c9;
  --shadow-card: 0 6px 20px rgba(27, 58, 43, 0.12);
}

/* 主题：云白（浅灰中性，不抢创作色彩） */
:root[data-theme="cloud"] {
  --game-bg-1: #f7f9fa;
  --game-bg-2: #dfe6ec;
  --ui-btn-bg: rgba(255, 255, 255, 0.8);
  --ui-btn-border: var(--gp-line, #c8e6c9);
  --ui-btn-ink: var(--gp-ink, #1b3a2b);
  --ui-btn-active-bg: var(--gp-brand-light, #d3f9d8);
  --ui-label: var(--gp-ink, #1b3a2b);
  --ui-surface: #ffffff;
  --ui-surface-2: #f8fdf9;
  --ui-ink: #1b3a2b;
  --ui-ink-light: #4a6b5a;
  --ui-line: #c8e6c9;
}
html[data-theme="cloud"] .header-btn-label { text-shadow: none; }
/* 主题：夜黑（深色，夜间/OLED 友好） */
:root[data-theme="night"] {
  --game-bg-1: #2f343c;
  --game-bg-2: #1c2026;
  --ui-btn-bg: rgba(255, 255, 255, 0.10);
  --ui-btn-border: rgba(255, 255, 255, 0.35);
  --ui-btn-ink: #fff;
  --ui-btn-active-bg: rgba(255, 255, 255, 0.28);
  --ui-label: #e8eaed;
  --ui-surface: #242930;
  --ui-surface-2: rgba(255, 255, 255, 0.06);
  --ui-ink: #e8eaed;
  --ui-ink-light: #b9bec6;
  --ui-line: rgba(255, 255, 255, 0.14);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh; /* 动态视口高：移动浏览器地址栏/底部工具栏收起变化时不遮罩底栏（不支持 dvh 时回退 100%） */
  overflow: hidden;
  font-family: -apple-system, "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
  color: #fff;
}

body {
  background: #4a7328;
  background-image: linear-gradient(160deg, var(--game-bg-1), var(--game-bg-2));
}

/* 全端全屏（Phase 2 M1：去掉 ≥640px 的 480px 手机壳限制） */
#app {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  overflow: hidden;
  background-image: linear-gradient(160deg, var(--game-bg-1), var(--game-bg-2));
}

/* ── 屏管理 ─────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.screen.visible {
  display: flex;
  animation: screenIn 0.28s ease-out;
}
/* 绘制屏顶部系统按钮保留带：角落组件（Menu/更多）与拉绳柄浮于带上，
   绘制区（簇）整体位于带下方——系统按钮与绘制控件双向不侵入。
   --top-reserve 由 home-screen.js 按浮件实际底缘测量写入 */
#screen-home {
  padding-top: max(var(--top-reserve, 0px), env(safe-area-inset-top));
}
@keyframes screenIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── 加载屏 ─────────────────────────────── */
#screen-loading {
  align-items: center;
  justify-content: center;
  gap: 22px;
}
.loading-logo {
  font-size: 52px;
  font-weight: 900;
  text-align: center;
  line-height: 1.1;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  letter-spacing: 2px;
}
.loading-bar-wrap {
  width: 200px;
  height: 10px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  overflow: hidden;
}
.loading-bar {
  width: 0%;
  height: 100%;
  background: #fff;
  border-radius: 6px;
  transition: width 0.2s ease;
}
.loading-text { font-weight: 700; opacity: 0.9; }

/* ── 图标按钮 ───────────────────────────── */
.icon-btn {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 2px solid var(--ui-btn-border, rgba(255, 255, 255, 0.85));
  border-radius: 12px;
  background: var(--ui-btn-bg, rgba(255, 255, 255, 0.25));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s, background 0.15s;
}
.icon-btn:active { transform: scale(0.9); background: rgba(255, 255, 255, 0.5); }
.icon-btn img { width: 22px; height: 22px; object-fit: contain; pointer-events: none; }
.icon-btn { font-size: 20px; line-height: 1; color: var(--ui-btn-ink, #fff); }
/* 文字图标（Import/Save/EN 等短词）：小号粗体白字，与 glyph 图标统一 */
.icon-btn .icon-txt { font-size: 12px; font-weight: 800; letter-spacing: 0.2px; }
/* 激活态保持半透明家族：更亮的透明白 + 白图标（不跳实心白卡） */
.icon-btn.active { background: var(--ui-btn-active-bg, rgba(255, 255, 255, 0.45)); }
.icon-btn.lock-btn.active { background: rgba(255, 255, 255, 0.45); box-shadow: 0 0 0 3px var(--gp-accent, #ffd43b); }
/* 锁定后色板与工具条淡化提示 */
.board-locked .palette-bar,
.board-locked .tool-bar { opacity: 0.45; pointer-events: none; }
.icon-btn.cooldown { opacity: 0.5; filter: grayscale(1); }
.icon-btn.back-btn { font-size: 30px; color: #fff; font-weight: 700; line-height: 1; }

/* ── 绘板屏布局 ─────────────────────────── */
.board-header {
  display: flex;
  gap: 10px;
  padding: 14px 16px 6px;
  align-items: flex-start;
  justify-content: space-between;
}
/* 头部三组块（归属/顺序由 modules.header 驱动，槽位由 modules.headerRegions 驱动）。
   竖屏：单行三簇（直出网格 + 更多按钮），块内按钮去文字标签 */
.hdr-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.hdr-group-empty { display: none; }
.hdr-group[data-slot="left"] { justify-content: flex-start; }
.hdr-group[data-slot="center"] { justify-content: center; }
.hdr-group[data-slot="right"] { justify-content: flex-end; }
.hdr-direct { display: grid; gap: 6px; }
.hdr-more-btn { position: relative; }
/* 所有按钮都没有时，头部整体隐藏（仅 home 屏，挑战屏头部保留） */
#screen-home .board-header:not(:has(.header-btn-wrap)) { display: none; }

/* 竖屏单行顶栏（<900px）：单行紧凑、可横滑兜底、图标按钮去标签 */
@media (max-width: 899px) and (orientation: portrait), (max-width: 639px) {
  #screen-home .board-header {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 10px;
    padding: 10px 12px 4px;
    scrollbar-width: none;
  }
  #screen-home .board-header::-webkit-scrollbar { display: none; }
  #screen-home .hdr-group { max-width: none; flex-wrap: nowrap; gap: 6px; }
}

/* 组「更多」下拉面板：浮在画布上方，网格排列（保留文字标签），点外部关闭 */
.hdr-more-panel {
  position: absolute;
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 6px 12px;
  background: var(--gp-surface, #fff); /* 实色全覆盖，任何背景上可读 */
  border: 1px solid var(--gp-line, #c8e6c9);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 280;
  max-width: calc(100vw - 16px);
  max-height: 50vh;
  overflow-y: auto;
}
/* 面板内按钮/文字/图片图标适配浅色面板（对比度） */
.hdr-more-panel .icon-btn,
.rope-panel .icon-btn { border-color: var(--gp-line, #c8e6c9); background: var(--gp-surface-2, #f8fdf9); color: var(--gp-ink, #1b3a2b); }
.hdr-more-panel .header-btn-label,
.rope-panel .header-btn-label { color: var(--gp-ink-light, #4a6b5a); text-shadow: none; }
.hdr-more-panel .icon-btn img,
.rope-panel .icon-btn img { filter: brightness(0.25); }
/* 面板内激活态：浅底深字（覆盖全局激活白字） */
.rope-panel .icon-btn.active,
.hdr-more-panel .icon-btn.active { color: var(--gp-ink, #1b3a2b); background: var(--gp-brand-light, #d3f9d8); border-color: var(--gp-brand, #2f9e44); }
/* 左上角固定列：Menu / Reset / 尺寸 */
.board-header-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
#size-select-slot {
  display: flex;
  flex-direction: column;
}
.board-header-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 70%;
}
.size-select {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.92) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%233a5a2b' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 8px center;
  border: none;
  border-radius: 10px;
  padding: 8px 26px 8px 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--gp-ink);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.size-select:focus { outline: 2px solid var(--gp-accent); }
.import-btn span { font-size: 20px; line-height: 1; }

/* 画布+工具包裹器：竖屏为上下结构（工具栏在上），横屏重排为左右（见横屏媒体查询）。
   内容（工具+画布）作为一个整体在两个方向居中（画布区由渲染器收缩包裹画布） */
/* 画布+工具包裹器：竖屏为上下结构（工具栏在上），横屏重排为左右（见横屏媒体查询）。
   内容（工具+画布）作为一个整体在两个方向居中（画布区由渲染器收缩包裹画布）。
   色板不在簇内：竖屏贴底、横屏贴左，独立于居中单元。
   簇内顺序用 order 显式声明：竖屏 工具→画布→缩放；横屏见底部媒体查询 */
.canvas-cluster {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}
.canvas-cluster .tool-bar { order: 0; }
.canvas-cluster .canvas-area { order: 1; }
.canvas-cluster .zoom-float { order: 2; }

.canvas-area {
  flex: 1;
  align-self: center; /* 渲染器写入显式尺寸后，保证水平居中而非左对齐 */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}
/* 画布格子超出容器时滚动查看（格子保持物理尺寸） */
.canvas-area.canvas-scrollable {
  overflow: auto;
  align-items: flex-start;
  justify-content: flex-start;
}
.canvas-area canvas.pixi-canvas {
  display: block;
  border-radius: 12px;
  border: 4px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  /* 玻璃透明板：透出主题底色（Pixi 画布本体透明、棋盘格半透明），白色豆/像素在其上可辨 */
  background: rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#reference-preview {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  padding: 6px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 10;
}
#reference-canvas { display: block; width: 72px; height: 72px; image-rendering: pixelated; }

.board-side-btns {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}

.board-footer {
  padding: 10px 14px 18px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
/* 色板条：白色胶囊包裹内容（宽度跟随颜色数量），在角落组件之外的剩余空间里居中 */
.board-footer .palette-bar {
  flex: 0 0 auto;
  margin: 0 auto;
  min-width: 0;
}

/* 工具条：紧贴画布上边、相对画布居中 */
.tool-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  padding: 8px 12px;
}
.palette-bar {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: clamp(4px, 1.5vw, 8px);
  align-items: center;
  overflow-x: auto; /* 色点多时横向滚动（不超过页面宽度） */
  overflow-y: hidden;
  scrollbar-width: none;
  background: #fff;
  border-radius: 22px;
  padding: 10px clamp(8px, 2.5vw, 16px);
  box-shadow: var(--shadow-card);
  width: auto; /* 白胶囊宽度跟随颜色内容（配合 margin auto 居中） */
  max-width: 100%;
  box-sizing: border-box;
  position: relative;
  margin-top: 20px;
}
.color-swatch-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  position: relative;
}
/* 编号放在白色背景上方的绿色区，白字深影才看得清 */
.color-swatch-number {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  line-height: 1;
  user-select: none;
  pointer-events: none;
  white-space: nowrap;
}
.color-swatch {
  width: clamp(28px, 8.5vw, 38px);
  height: clamp(28px, 8.5vw, 38px);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid rgba(0, 0, 0, 0.08);
  transition: transform 0.1s;
  position: relative;
  flex: 0 0 auto;
}
.color-swatch:active { transform: scale(0.88); }
.color-swatch.selected {
  border: 2px solid var(--gp-brand, #2f9e44); /* 细品牌绿圈标记选中，不放大不遮挡 */
}
.color-swatch.eraser {
  background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50% / 14px 14px;
  display: flex; align-items: center; justify-content: center;
}
.color-swatch.eraser img { width: 20px; height: 20px; opacity: 0.65; }

/* 色相族主色点：上下拖动切换渐变，需禁止页面跟随滚动 */
.color-swatch.family { touch-action: none; }
/* 夹子工具激活时：色点上的拖动手势用于拾取豆子，禁止浏览器接管为色板滚动（否则 pointercancel 会中断携带） */
.palette-bar.tweezers-on .color-swatch,
.palette-bar.tweezers-on .bead-peg,
.bead-panel .color-swatch,
.bead-panel .bead-peg { touch-action: none; }
/* 长按相近色弹窗 */
.color-family-popup {
  position: fixed;
  z-index: 300;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  padding: 12px 14px;
  /* 宽度由内容决定，仅设上限，任何设备都不越界 */
  width: max-content;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
}
.color-family-popup .cfp-grid {
  display: grid;
  grid-template-columns: repeat(8, auto);
  justify-content: center;
  gap: 8px;
  max-height: 45vh;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.color-family-popup .cfp-grid::-webkit-scrollbar { display: none; }
.color-family-popup .cfp-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.color-family-popup .cfp-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid rgba(0, 0, 0, 0.08);
}
.color-family-popup .cfp-code {
  font-size: 9px;
  font-weight: 700;
  color: var(--gp-ink-light, #4a6b5a);
  line-height: 1;
  user-select: none;
}
.color-family-popup .cfp-dot.selected { border: 2px solid var(--gp-brand, #2f9e44); }
.color-family-popup .cfp-dot:active { transform: scale(0.9); }

/* ── 拼豆豆料清单（锚定 screen 底部，与底栏色板两边/底部对齐）────────────── */
.usage-sheet {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  z-index: 260;
  overflow: hidden;
}
/* 色块区：竖排小块横排换行，一行半高度（第二行露一半提示有更多），超出滚动 */
.usage-sheet-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  padding: 8px 12px;
  max-height: 76px;
  overflow-y: auto;
  scrollbar-width: none;
}
.usage-sheet-list::-webkit-scrollbar { display: none; }
.usage-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 2px 3px;
  border-radius: 8px;
  font-size: 10px;
  line-height: 1.2;
  color: var(--gp-ink, #1b3a2b);
}
.usage-chip-count { font-weight: 700; color: var(--gp-ink-light, #4a6b5a); }
.usage-dot { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.1); flex: 0 0 auto; }
.usage-code { font-weight: 700; }
/* 对照模式：其他豆品牌的最近色号（小字灰） */
.usage-compare { font-size: 9px; color: var(--gp-ink-light, #4a6b5a); text-align: center; line-height: 1.25; word-break: break-all; }
.usage-close-btn.active { background: var(--gp-brand-light, #d3f9d8); color: var(--gp-brand-dark, #237b34); }
.usage-empty { text-align: center; color: var(--gp-ink-light, #4a6b5a); font-size: 12px; padding: 10px 0; width: 100%; }
.usage-chip.tappable { cursor: pointer; }
.usage-chip.tappable:active { background: var(--gp-brand-light, #d3f9d8); }
.usage-chip.focused { background: var(--gp-brand-light, #d3f9d8); }
/* 底栏：汇总 + 导出 + 关闭 */
.usage-sheet-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--gp-ink, #1b3a2b);
  border-top: 1px solid var(--gp-line, #c8e6c9);
}
/* 进度文字（26/7569 (0%)）始终另起一行——统计信息到"N 色"后换行 */
.usage-progress {
  flex-basis: 100%;
  color: var(--gp-ink-light, #4a6b5a);
  font-weight: 600;
}
.usage-summary { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usage-export-btn {
  padding: 4px 10px;
  border: none;
  border-radius: 8px;
  background: var(--gp-brand, #2f9e44);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.usage-close-btn {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--gp-ink-light, #4a6b5a);
  font-size: 12px;
  cursor: pointer;
}

/* ── 拼豆展示模式 ─────────────────────────────────────── */
/* 工具条保留占位（画布不位移）：只隐藏工具按钮与尺寸选择器，缩放平移控件原位保留 */
.present-mode .tool-bar .tool-btn,
.present-mode .tool-bar .size-select-wrap { display: none; }
.present-mode .palette-bar { pointer-events: none; opacity: 0.75; }
.zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 10px;
  padding: 6px 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  z-index: 50;
}
.zoom-controls button {
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--gp-line, #c8e6c9);
  border-radius: 8px;
  background: #fff;
  font-size: 16px;
  font-weight: 700;
  color: var(--gp-ink, #1b3a2b);
  cursor: pointer;
  padding: 0 8px;
}
.zoom-controls span {
  min-width: 44px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--gp-ink, #1b3a2b);
}

/* ── 头部按钮名称标签 ─────────────────────────────── */
.header-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}
.header-btn-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--ui-label, #fff);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

/* 缩放条：竖屏在画布下方一行（右对齐，留边不越界），横屏在画布左侧一列；不占工具栏 */
.zoom-float {
  align-self: flex-end;
  margin: 6px 12px 0;
  max-width: calc(100% - 24px);
  z-index: 30;
}
.zoom-float .zoom-pan-control { margin-left: 0; flex-direction: row; }

/* 侧栏展开时：角落组件（☰）浮到侧栏之上，保持可点 */
#screen-home.sidebar-open .hdr-corner { z-index: 82; }

/* ── 右侧栏（Phase 2 M1：按钮位置 sidebar 渲染进此容器）───────────── */
/* z-index 层级：内容 < 侧栏遮罩(78) < 侧栏(80) < 侧栏开关(82) < 导航抽屉(90/91) */
/* 侧栏为浮动覆盖层（全端一致）：从右侧滑入，不推挤内容；☰ 开关是头部功能组按钮（renderHeader 渲染） */
.sidebar-toggle {
  font-size: 18px;
  line-height: 1;
  padding: 0;
}
/* 侧栏展开时开关浮在白色侧栏之上：提高层级 + 实心品牌绿保证可见 */
#screen-home.sidebar-open .wrap-sidebar-toggle { position: relative; z-index: 82; }
#screen-home.sidebar-open .sidebar-toggle {
  background: var(--gp-brand, #2f9e44);
  border-color: var(--gp-brand, #2f9e44);
  color: #fff;
}
.board-sidebar {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 208px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: calc(64px + env(safe-area-inset-top)) 10px calc(16px + env(safe-area-inset-bottom));
  background: var(--ui-surface, #fff);
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.18);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  scrollbar-width: none;
}
.board-sidebar::-webkit-scrollbar { display: none; }
#screen-home.sidebar-open .board-sidebar { transform: translateX(0); }
.sidebar-mask {
  position: absolute;
  inset: 0;
  z-index: 78;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.sidebar-mask.open { opacity: 1; pointer-events: auto; }
/* 系统组角落组件（布局约定）：在色板条（footer）首位——竖屏与色板同行居左，横屏在色板列上方 */
/* 系统组角落组件（布局约定）：竖屏右上角，横屏左上角（见横屏媒体查询） */
.hdr-corner {
  position: absolute;
  z-index: 75;
  top: calc(10px + env(safe-area-inset-top));
  right: 10px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.hdr-corner.hdr-group-empty { display: none; }

/* 按钮图片图标对比：浅色底（云白主题）或激活态时，白色图片图标转深色 */
html[data-theme="cloud"] .icon-btn img,
html[data-theme="cloud"] .tool-btn img { filter: brightness(0.25); }
html:not([data-theme="night"]) .icon-btn.active img,
html:not([data-theme="night"]) .tool-btn.active img { filter: brightness(0.25); }

/* 拉绳模式：顶部中央拉绳柄（屏幕层绝对定位）+ 下滑面板 */
.board-header.rope-mode { justify-content: center; padding-top: 4px; }
.rope-handle {
  position: absolute;
  top: calc(4px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 76;
  width: 64px; height: 26px;
  border: 2px solid var(--gp-line, #c8e6c9);
  border-radius: 0 0 14px 14px;
  border-top: none;
  background: var(--gp-surface, #fff); /* 实色白底，绿底/白画布上都清晰 */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.rope-handle .rope-grip {
  width: 28px; height: 4px; border-radius: 2px; background: var(--gp-brand, #2f9e44);
  transition: transform 0.2s;
}
.rope-handle.open .rope-grip { transform: rotate(180deg) scaleX(0.7); }
.rope-panel {
  position: absolute;
  top: calc(34px + env(safe-area-inset-top));
  left: 8px;
  right: 8px; /* 竖屏面板尽量接近两边，按钮一行尽量多放 */
  transform: translateY(-16px);
  visibility: hidden;
  opacity: 0;
  pointer-events: none; /* 收起时彻底不吃点击（否则盖住拉绳柄） */
  z-index: 76;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--gp-surface, #fff); /* 实色白底 + 深色内容 */
  border: 1px solid var(--gp-line, #c8e6c9);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  max-height: 60vh;
  overflow-y: auto;
  transition: transform 0.22s ease, opacity 0.22s ease, visibility 0.22s;
  scrollbar-width: none;
}
.rope-panel::-webkit-scrollbar { display: none; }
.rope-panel.open {
  transform: translateY(0);
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}
.rope-section .rope-sec-title {
  font-size: 11px; font-weight: 700; color: var(--gp-ink-light, #4a6b5a);
  margin-bottom: 6px;
}
.rope-panel .hdr-group { display: flex; flex-wrap: wrap; gap: 8px; }
/* 面板内按钮用站点浅色风（实色白底上的可读性） */
.rope-panel .icon-btn { border-color: var(--gp-line, #c8e6c9); background: var(--gp-surface-2, #f8fdf9); color: var(--gp-ink, #1b3a2b); }
.rope-panel .header-btn-label { color: var(--gp-ink-light, #4a6b5a); text-shadow: none; }
.tool-btn img { width: 20px; height: 20px; object-fit: contain; pointer-events: none; }

/* 侧栏教学图纸区（教学模式入口：缩略图网格） */
.side-patterns { margin-top: 10px; border-top: 1px solid var(--ui-line, #c8e6c9); padding-top: 10px; }
.side-patterns-title { font-size: 12px; font-weight: 700; color: var(--ui-ink-light, #4a6b5a); padding: 0 6px 8px; }
.side-patterns-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.side-pattern-cell {
  aspect-ratio: 1; border: 1px solid var(--ui-line, #c8e6c9); border-radius: 10px;
  background: var(--ui-surface-2, #f8fdf9); padding: 4px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.side-pattern-cell:active { border-color: var(--gp-brand, #2f9e44); background: var(--gp-brand-light, #d3f9d8); }
.side-pattern-cell img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; border-radius: 6px; }

/* 侧栏按钮：横向行（图标 + 常显文字标签） */
.board-sidebar .header-btn-wrap {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 4px 6px;
  border-radius: var(--gp-radius-sm, 10px);
}
.board-sidebar .header-btn-wrap:active { background: var(--gp-brand-light, #d3f9d8); }
.board-sidebar .icon-btn {
  border-color: var(--ui-line, #c8e6c9);
  background: var(--ui-surface-2, #f8fdf9);
  color: var(--ui-ink, #1b3a2b);
}
.board-sidebar .icon-btn.active { background: var(--gp-brand, #2f9e44); color: #fff; }
.board-sidebar .icon-btn.lock-btn.active { box-shadow: 0 0 0 3px var(--gp-accent, #ffd43b); }
.board-sidebar .header-btn-label {
  font-size: 13px;
  color: var(--ui-ink, #1b3a2b);
  text-shadow: none;
}
.board-sidebar .icon-btn img { filter: brightness(0.25); }
html[data-theme="night"] .board-sidebar .icon-btn img { filter: none; }
/* 侧栏展开时角落组件浮在侧栏上：标签跟随表面色 */
/* 侧栏展开时角落组件浮在侧栏上：按钮/标签跟随表面色 */
#screen-home.sidebar-open .hdr-corner .header-btn-label { color: var(--ui-ink, #1b3a2b); text-shadow: none; }
#screen-home.sidebar-open .hdr-corner .icon-btn:not(.sidebar-toggle) { color: var(--ui-ink, #1b3a2b); border-color: var(--ui-line, #c8e6c9); background: var(--ui-surface-2, #f8fdf9); }
#screen-home.sidebar-open .hdr-corner .icon-btn:not(.sidebar-toggle).active { color: #fff; }
#screen-home.sidebar-open .hdr-corner .icon-btn:not(.sidebar-toggle) img { filter: brightness(0.25); }
html[data-theme="night"] #screen-home.sidebar-open .hdr-corner .icon-btn img { filter: none; }
html[data-theme="night"] #screen-home.sidebar-open .hdr-corner .header-btn-label { color: var(--ui-ink); }

/* ── 多端断点（Phase 2 M1）────────────────────────────────────── */
/* 侧栏全端浮动覆盖（2026-08-06 起）：不再推挤内容，展开时遮罩点击收起 */
/* 注：PC 宽屏不再限制内容列宽——绘制区模型（色板贴边 + 簇居中）天然适配任意宽度；
   旧 max-width:1200px + auto 外边距规则会把横屏簇内工具列推离画布，已移除。 */
/* 手机横屏（高度受限）：压缩头部/底部与工具栏，色板更紧凑；功能按钮去文字标签（与竖屏顶栏一致） */
@media (orientation: landscape) and (max-height: 500px) {
  .board-header { padding: 6px 12px 2px; gap: 6px; }
  .tool-bar { padding: 0 12px 2px; gap: 6px; }
  .board-footer { padding: 4px 12px calc(8px + env(safe-area-inset-bottom)); gap: 6px; }
  .palette-bar { margin-top: 10px; padding: 6px 10px; border-radius: 16px; }
  .color-swatch { width: 28px; height: 28px; }
  .color-swatch-number { display: none; }
}

/* ── 缩放平移共享控件 ─────────────────────────────── */
.zoom-pan-control {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  background: var(--ui-btn-bg, rgba(255, 255, 255, 0.25));
  border: 1px solid var(--ui-btn-border, rgba(255, 255, 255, 0.55));
  border-radius: 10px;
  padding: 3px 5px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}
.zoom-pan-control .zp-btn {
  min-width: 28px;
  height: 28px;
  border: 1px solid var(--ui-btn-border, rgba(255, 255, 255, 0.55));
  border-radius: 7px;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  color: var(--ui-btn-ink, #fff);
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
}
.zoom-pan-control .zp-btn.active { background: var(--ui-btn-active-bg, rgba(255, 255, 255, 0.45)); color: var(--ui-btn-ink, #fff); border-color: var(--ui-btn-border, rgba(255, 255, 255, 0.85)); }
.zoom-pan-control .zp-label {
  min-width: 40px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ui-btn-ink, #fff);
}
/* 描边按钮右下颜色指示点 */
.tool-btn { position: relative; }
/* 有选项的工具：右上角小三角提示 */
.tool-caret {
  position: absolute;
  right: 2px;
  top: 0;
  font-size: 8px;
  color: var(--ui-btn-ink, #fff);
  opacity: 0.9;
  pointer-events: none;
}
/* 工具选项弹层（激活态再点一次弹出） */
.tool-options-popup {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--gp-surface, #fff);
  border: 1px solid var(--gp-line, #c8e6c9);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 280;
}
.tool-option-item {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--gp-ink, #1b3a2b);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}
.tool-option-item:active { background: var(--gp-brand-light, #d3f9d8); }
.tool-option-item.active { color: var(--gp-brand, #2f9e44); }
.tool-color-dot {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

/* ── 拼豆色板：全色横向滑动条 + 圆环豆粒样式 ─────────────────────── */
.palette-bar.bead-palette {
  justify-content: center;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  gap: 6px;
  padding: 10px 12px;
}
.palette-bar.bead-palette::-webkit-scrollbar { display: none; }
.bead-strip-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
}
.bead-peg {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.18);
  transition: transform 0.1s;
}
/* 豆粒中心孔（平面圆环，无高光立体） */
.bead-peg::after {
  content: "";
  position: absolute;
  inset: 34%;
  background: #fff;
  border-radius: 50%;
}
.bead-peg.selected {
  border: 2px solid var(--gp-brand, #2f9e44); /* 细品牌绿圈标记选中，不放大不遮挡 */
}
.bead-peg-code {
  font-size: 9px;
  font-weight: 700;
  color: var(--gp-ink-light, #4a6b5a);
  line-height: 1;
  user-select: none;
}

/* ── 拼豆族面板（颜色栏上方浮出，无 Tab） ─────────────────────── */
.bead-panel {
  position: fixed;
  z-index: 280;
  /* 宽度跟随颜色数量（内容决定），仅设上限；与横屏 width:auto 的包裹行为一致 */
  width: max-content;
  max-width: min(420px, calc(100vw - 24px));
  box-sizing: border-box;
  max-height: 46vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  padding: 12px 14px;
  overflow: hidden;
  animation: beadSheetUp 0.18s ease-out;
}
@keyframes beadSheetUp {
  from { transform: translate(-50%, 12px); opacity: 0.6; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
.bead-sheet-close {
  position: absolute;
  top: 8px;
  left: 10px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--gp-ink-light, #4a6b5a);
  font-size: 15px;
  cursor: pointer;
}
.bead-sheet-tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  justify-content: center;
  padding: 6px 2px 12px 34px;
  scrollbar-width: none;
}
.bead-sheet-tabs::-webkit-scrollbar { display: none; }
.bead-sheet-tab {
  flex: 0 0 auto;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}
/* 族 Tab 色环与主栏/网格同尺寸（28px），选中加描边 */
.bead-sheet-tab .bead-peg {
  pointer-events: none;
}
.bead-sheet-tab.active .bead-peg {
  transform: scale(1.2);
  border: 2px solid var(--gp-ink, #1b3a2b);
}
.bead-sheet-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 6px;
  overflow-y: auto;
  padding: 4px 2px 8px;
  scrollbar-width: none;
}
.bead-sheet-grid::-webkit-scrollbar { display: none; }
.bead-sheet-grid .bead-peg-code { font-size: 10px; }

/* ── 尺寸选择：原位自定义下拉 ─────────────────────────────── */
.size-select-wrap { position: relative; }
.size-select-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 12px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.size-select-caret { font-size: 12px; opacity: 0.85; }
.size-select-popup {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--gp-surface, #fff);
  border: 1px solid var(--gp-line, #c8e6c9);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 120;
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: none;
}
.size-select-popup::-webkit-scrollbar { display: none; }
.size-select-item {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--gp-ink, #1b3a2b);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.size-select-item:hover { background: var(--gp-surface-2, #f8fdf9); }
.size-select-item.active { background: var(--gp-brand, #2f9e44); color: #fff; }

.done-btn {
  min-width: 220px;
  min-height: 52px;
  border: 3px solid #fff;
  border-radius: 28px;
  background: var(--gp-brand);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 3px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s;
}
.done-btn:active { transform: scale(0.95); background: var(--gp-brand-dark); }

.tutorial-tip {
  position: absolute;
  left: 50%;
  bottom: 150px;
  transform: translateX(-50%);
  background: rgba(27, 58, 43, 0.92);
  color: #fff;
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 14px;
  max-width: 82%;
  text-align: center;
  z-index: 30;
  box-shadow: var(--shadow-card);
  animation: tipPulse 1.6s ease-in-out infinite;
}
@keyframes tipPulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.04); }
}

/* ── 结算屏 ─────────────────────────────── */
#screen-result { align-items: center; justify-content: center; padding: 20px; }
.result-card {
  width: 100%;
  max-width: 380px;
  background: rgba(0, 0, 0, 0.16);
  border-radius: 24px;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: cardIn 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes cardIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}
.result-title {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  margin-bottom: 14px;
}
.result-stars { display: flex; gap: 12px; margin-bottom: 10px; min-height: 56px; }
.result-stars img {
  width: 56px;
  height: 56px;
  opacity: 0.25;
  filter: grayscale(1);
  transform: scale(0.8);
  transition: all 0.3s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.result-stars img.earned { opacity: 1; filter: none; transform: scale(1.1); }
.result-accuracy { font-size: 42px; font-weight: 900; margin-bottom: 12px; }
.result-reward {
  background: var(--gp-accent);
  color: var(--gp-ink);
  font-weight: 800;
  border-radius: 14px;
  padding: 10px 16px;
  margin-bottom: 14px;
  text-align: center;
  font-size: 15px;
  align-self: center;
  animation: rewardPulse 1.4s ease-in-out infinite;
}
@keyframes rewardPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.result-compare { display: flex; gap: 22px; margin-bottom: 22px; }
.compare-label { font-size: 12px; font-weight: 700; opacity: 0.85; text-align: center; margin-bottom: 6px; letter-spacing: 1px; }
.compare-item canvas {
  width: 120px;
  height: 120px;
  border: 4px solid #fff;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  image-rendering: pixelated;
}
.result-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }

.main-btn {
  min-height: 48px;
  border: 2px solid #fff;
  border-radius: 24px;
  background: var(--gp-brand);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: transform 0.1s;
  width: 100%;
}
.main-btn:active { transform: scale(0.96); }
.main-btn.secondary { background: #fff; color: var(--gp-brand-dark); }
.main-btn.text { background: transparent; border: none; box-shadow: none; }

/* ── 二级页(挑战/画廊/我的) ─────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}
.page-title { font-size: 22px; font-weight: 900; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); }
.thumb-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 8px 16px 24px;
  align-content: start;
  -webkit-overflow-scrolling: touch;
}
.level-card {
  background: #fff;
  border-radius: var(--gp-radius);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform 0.12s;
  color: var(--gp-ink);
  position: relative;
}
.level-done-badge {
  position: absolute;
  top: -7px;
  right: -5px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gp-brand);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  border: 2px solid #fff;
}
.level-card:active { transform: scale(0.95); }
.level-card.locked { opacity: 0.75; cursor: default; }
.level-card canvas { width: 100%; aspect-ratio: 1; border-radius: 8px; image-rendering: pixelated; background: #fff; }
.level-card .lock-img { width: 40%; margin: 22% 0; opacity: 0.5; }
.level-name { font-size: 12px; font-weight: 700; text-align: center; line-height: 1.25; }
.level-stars { display: flex; gap: 3px; min-height: 14px; }
.level-stars img { width: 14px; height: 14px; opacity: 0.25; filter: grayscale(1); }
.level-stars img.earned { opacity: 1; filter: none; }
.level-price { font-size: 12px; font-weight: 800; color: var(--gp-brand-dark); min-height: 14px; }
.gallery-convert-btn {
  width: 100%;
  margin-top: 4px;
  padding: 6px 4px;
  border: none;
  border-radius: var(--gp-radius-sm);
  background: var(--gp-brand);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.gallery-convert-btn:disabled {
  background: var(--gp-line-strong);
  cursor: default;
}

.home-actions { display: flex; gap: 10px; align-items: center; }
.home-lib-btn { width: 52px; height: 52px; font-size: 22px; border-radius: 26px; }

/* ── 我的 ───────────────────────────────── */
.me-content { flex: 1; overflow-y: auto; padding: 8px 18px 24px; }
.me-card {
  background: #fff;
  color: var(--gp-ink);
  border-radius: var(--gp-radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
}
.me-name { font-size: 20px; font-weight: 900; }
.me-email { color: var(--gp-ink-light); font-size: 13px; margin-top: 2px; }
.me-stats { display: flex; gap: 12px; margin-top: 14px; }
.me-stat { flex: 1; background: var(--gp-bg); border-radius: 10px; padding: 12px; text-align: center; }
.me-stat-num { font-size: 22px; font-weight: 900; color: var(--gp-brand-dark); }
.me-stat-label { font-size: 12px; color: var(--gp-ink-light); margin-top: 2px; }
.me-actions { display: flex; flex-direction: column; gap: 10px; }
.me-actions .main-btn { letter-spacing: 0; }

/* ── 抽屉 ───────────────────────────────── */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 90;
}
.drawer-mask.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(78vw, 300px);
  background: var(--gp-surface);
  color: var(--gp-ink);
  z-index: 91;
  transform: translateX(-102%);
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  display: flex;
  flex-direction: column;
  padding: calc(18px + env(safe-area-inset-top)) 14px 18px;
  box-shadow: 6px 0 30px rgba(0, 0, 0, 0.25);
}
.drawer.open { transform: translateX(0); }
.drawer-user {
  padding: 10px 12px 16px;
  border-bottom: 1px solid var(--gp-line);
  margin-bottom: 10px;
  font-weight: 800;
}
.drawer-user .sub { font-weight: 400; font-size: 12px; color: var(--gp-ink-light); margin-top: 2px; }
.drawer-login-btn {
  margin-top: 8px;
  width: 100%;
  min-height: 40px;
  border: none;
  border-radius: 20px;
  background: var(--gp-brand);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.drawer-login-btn:active { background: var(--gp-brand-dark); }
.drawer-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-size: 17px;
  font-weight: 700;
  color: var(--gp-ink);
  padding: 14px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.drawer-item:active { background: var(--gp-brand-light); }
.drawer-logout { color: var(--gp-danger); margin-top: 6px; }
.drawer-foot { margin-top: auto; font-size: 12px; color: var(--gp-ink-light); padding: 10px 12px; }

/* ── 弹层(登录墙) ───────────────────────── */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal-mask.open { display: flex; }
.modal-card {
  width: 100%;
  max-width: 340px;
  background: #fff;
  color: var(--gp-ink);
  border-radius: 20px;
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
  animation: cardIn 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.modal-emoji { font-size: 42px; }
.modal-title { font-size: 20px; font-weight: 900; }
.modal-desc { font-size: 14px; color: var(--gp-ink-light); margin-bottom: 8px; }
.modal-card .main-btn.text { color: var(--gp-ink-light); }

/* ── 活动横幅(挑战页) ───────────────────── */
.event-banner {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #fff8e1, #ffecb3);
  border: 3px solid var(--gp-accent);
  border-radius: var(--gp-radius);
  padding: 12px;
  box-shadow: var(--shadow-card);
}
.event-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--gp-ink); }
.event-tag {
  background: var(--gp-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 8px;
}
.event-head b { font-size: 16px; flex: 1; }
.event-dates { font-size: 11px; color: var(--gp-ink-light); font-weight: 700; }
.event-levels { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 2px; }
.event-level-card { flex: 0 0 96px; background: #fff; }
.event-level-card.claimed { opacity: 0.65; }

/* ── 积分余额条(商店等共用) ─────────────── */
.daily-wallet {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.daily-wallet b { font-size: 20px; }

/* ── 分类筛选条 ─────────────────────────── */
.cat-chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; -webkit-overflow-scrolling: touch; }
.gallery-chips { flex: 0 0 auto; padding: 0 16px 8px; }
.cat-chip {
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.cat-chip.active { background: #fff; color: var(--gp-brand-dark); border-color: #fff; }

/* ── 作品库 ─────────────────────────────── */
.works-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.work-item { display: flex; flex-direction: column; gap: 4px; }
.work-item img, .work-item canvas { width: 100%; aspect-ratio: 1; border-radius: 8px; image-rendering: pixelated; background: #fff; border: 1px solid var(--gp-line); }
.work-name { font-size: 11px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-ops { display: flex; gap: 4px; }
.work-ops button {
  flex: 1;
  border: 1px solid var(--gp-line);
  background: var(--gp-bg);
  border-radius: 8px;
  padding: 4px 0;
  font-size: 13px;
  cursor: pointer;
}
.work-ops button:active { background: var(--gp-brand-light); }
.work-author { font-size: 11px; color: var(--gp-ink-light); }

/* ── 商店 ───────────────────────────────── */
.shop-content { flex: 1; overflow-y: auto; padding: 8px 18px 24px; display: flex; flex-direction: column; gap: 10px; }
.shop-section-title { font-size: 15px; font-weight: 900; margin-top: 8px; text-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.shop-row {
  background: #fff;
  border-radius: var(--gp-radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-card);
  color: var(--gp-ink);
}
.shop-row-info { flex: 1; min-width: 0; }
.shop-row-title { font-weight: 800; font-size: 15px; }
.shop-row-desc { font-size: 12px; color: var(--gp-ink-light); margin-top: 2px; }
.shop-row-swatches { display: flex; gap: 4px; margin-top: 6px; }
.shop-row-swatches span { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.1); }
.shop-buy-btn {
  border: none;
  border-radius: 18px;
  background: var(--gp-brand);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.shop-buy-btn:active { background: var(--gp-brand-dark); }
.shop-buy-btn.owned { background: var(--gp-brand-light); color: var(--gp-brand-dark); cursor: default; }
.shop-buy-btn.poor { background: #adb5bd; }

/* ── 工具行(创作屏) ─────────────────────── */
.tool-bar {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}
/* 缩放条内的尺寸选择器：与 zp 按钮同高同风格（紧凑） */
.zoom-pan-control .size-select-wrap { display: flex; }
.zoom-pan-control .size-select-btn {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--ui-btn-border, rgba(255, 255, 255, 0.55));
  border-radius: 7px;
  background: transparent;
  box-shadow: none;
  color: var(--ui-btn-ink, #fff);
  font-size: 12px;
  font-weight: 700;
  gap: 4px;
}
.zoom-pan-control .size-select-caret { font-size: 9px; }
/* 缩放条靠右停靠，弹层右对齐防溢出 */
.zoom-pan-control .size-select-popup { left: auto; right: 0; }
.tool-btn {
  min-width: 40px;
  height: 40px;
  border: 2px solid var(--ui-btn-border, rgba(255, 255, 255, 0.85));
  border-radius: 9px;
  background: var(--ui-btn-bg, rgba(255, 255, 255, 0.25));
  color: var(--ui-btn-ink, #fff);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  transition: transform 0.1s, background 0.15s;
}
.tool-btn:active { transform: scale(0.92); }
.tool-btn.active { background: var(--ui-btn-active-bg, rgba(255, 255, 255, 0.45)); }
.tool-btn.locked { opacity: 0.85; }
.tool-btn .tool-price { font-size: 9px; font-weight: 800; line-height: 1; }

/* ── 每日免费卡(挑战页) ─────────────────── */
.level-card.daily-card { position: relative; border: 3px solid var(--gp-accent); }
.daily-badge {
  position: absolute;
  top: -8px;
  right: -6px;
  background: var(--gp-accent);
  color: var(--gp-ink);
  font-size: 11px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 9px;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.daily-thumb-loading { width: 100%; aspect-ratio: 1; border-radius: 8px; background: var(--gp-bg); }
.new-work-btn { letter-spacing: 0; margin-bottom: 14px; }

/* 拼豆夹子光标：跟随指针，携带时双臂收拢 + 挂豆 */
.tweezers-cursor {
  position: fixed; z-index: 300; width: 48px; height: 48px;
  pointer-events: none; transform: translate(-50%, -78%);
  display: none;
}
.tweezers-cursor.on { display: block; }
.tweezers-cursor .tw-arm {
  position: absolute; top: 0; width: 5px; height: 37px;
  background: linear-gradient(#e8edf1, #c3ccd4);
  border: 1px solid #98a3ad; border-radius: 3px;
  /* 顶端为轴、底端向内收拢：V 字尖朝下，尾部（尖端）在豆子处会合 */
  transform-origin: top center; transition: transform 0.12s ease;
}
.tweezers-cursor .tw-arm.left { left: 13px; transform: rotate(10deg); }
.tweezers-cursor .tw-arm.right { right: 13px; transform: rotate(-10deg); }
.tweezers-cursor.carrying .tw-arm.left { transform: rotate(16deg); }
.tweezers-cursor.carrying .tw-arm.right { transform: rotate(-16deg); }
.tweezers-cursor .tw-bead {
  position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.35);
  display: none;
}
.tweezers-cursor.carrying .tw-bead { display: block; transform: translateX(-50%) scale(1.45); }

/* 参考小图（教学模式）：工具栏中间的缩略图按钮，点击全屏查看 */
.ref-thumb {
  width: 40px; height: 40px; padding: 3px; flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.9); border: 2px solid #fff; border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22); cursor: pointer;
}
.ref-thumb img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; border-radius: 7px; display: block; }
.ref-preview-mask {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(27, 58, 43, 0.72); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.ref-preview-mask img {
  width: min(80vmin, 560px); height: min(80vmin, 560px);
  image-rendering: pixelated; background: #fff; border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

/* ── Toast ──────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(27, 58, 43, 0.94);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 320;
  max-width: 84%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── 图片导入转换弹窗 ───────────────────────────── */
.import-dialog {
  position: fixed;
  inset: 0;
  background: rgba(27, 58, 43, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.import-card {
  background: var(--gp-surface);
  border-radius: var(--gp-radius);
  padding: 20px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--gp-shadow);
}
.import-card h4 {
  margin: 0 0 14px;
  color: var(--gp-ink);
  font-size: 18px;
}
.import-file-label {
  display: block;
  border: 2px dashed var(--gp-line-strong);
  border-radius: var(--gp-radius-sm);
  padding: 18px;
  text-align: center;
  color: var(--gp-ink-light);
  cursor: pointer;
  margin-bottom: 14px;
  transition: border-color 0.15s, background 0.15s;
}
.import-file-label:hover { border-color: var(--gp-brand); background: var(--gp-surface-2); }
.import-file-label input { display: none; }
.import-preview {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  min-height: 80px;
}
.import-preview img {
  max-width: 100%;
  max-height: 160px;
  border-radius: var(--gp-radius-sm);
  object-fit: contain;
}
.import-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}
.import-row label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--gp-ink-light);
}
.import-row select {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--gp-line);
  background: #fff;
  color: var(--gp-ink);
  font-size: 14px;
}
.import-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--gp-ink);
}
.import-options label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.import-actions button {
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.import-actions .btn-primary { background: var(--gp-brand); color: #fff; }
.import-actions .btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.import-actions .btn-link { background: transparent; color: var(--gp-ink-light); }
.import-error {
  color: var(--gp-danger);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}
.import-preview-meta {
  text-align: center;
  font-size: 13px;
  color: var(--gp-ink-light);
  margin-bottom: 10px;
}
.import-preview-canvas-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 120px;
  margin-bottom: 16px;
  background: var(--gp-surface-2);
  border-radius: var(--gp-radius-sm);
  padding: 12px;
}
.import-preview-canvas-wrap canvas {
  max-width: 100%;
  image-rendering: pixelated;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(27, 58, 43, 0.08);
}

/* ── 横屏/宽屏自适应（≥900px）─────────────────────────────────────────
   与竖屏同一「绘制区」模型，轴向旋转 90°：色板列 | 缩放列 | 画布 | 工具列，
   整簇作为整体居中；系统按钮（角落组件/拉绳柄）浮于顶部保留带，不侵入绘制区。 */
@media (min-width: 900px), (orientation: landscape) and (min-width: 640px) {
  /* 横屏：色板列永远贴左（grid 列），画布簇在剩余空间居中 */
  #screen-home.visible {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: "header header" "palette cluster";
  }
  #screen-home .board-header { grid-area: header; }
  #screen-home .canvas-cluster {
    grid-area: cluster;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    min-height: 0;
  }

  /* 最左列：颜色区（整列高度，内容垂直居中，超高可滚动） */
  #screen-home .board-footer {
    grid-area: palette;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 14px 4px 14px 14px;
    gap: 0;
    min-height: 0;
  }
  #screen-home .palette-bar {
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: safe center;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 100%;
    border-radius: 22px;
    padding: 12px 8px;
    scrollbar-width: none;
  }
  #screen-home .palette-bar::-webkit-scrollbar { display: none; }

  /* 缩放列：画布左侧（竖排） */
  #screen-home .zoom-float {
    order: 1;
    align-self: center;
    margin: 0;
    flex: 0 0 auto;
  }
  #screen-home .zoom-float .zoom-pan-control { flex-direction: column; }

  /* 画布：尺寸由渲染器按簇内剩余空间写入（收缩包裹，两侧控件贴画布边缘） */
  #screen-home .canvas-area {
    order: 2;
    flex: 0 0 auto;
    align-self: center;
  }

  /* 工具列：贴画布右缘（竖排，宽度按内容，超高可滚动） */
  #screen-home .tool-bar {
    order: 3;
    flex: 0 0 auto;
    width: auto;
    box-sizing: border-box;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: safe center;
    align-items: center;
    gap: 8px;
    padding: 10px 8px;
    overflow-y: auto;
    min-height: 0;
    max-height: 100%;
    scrollbar-width: none;
  }
  #screen-home .tool-bar::-webkit-scrollbar { display: none; }
  #screen-home .tool-bar .zoom-pan-control {
    flex-direction: column;
    margin-left: 0;
  }
  #screen-home .tool-bar .zoom-pan-control .zp-label { min-width: 0; }

  /* 横屏内联头部（回滚路径；默认拉绳模式头部为空自动隐藏）：普通顶行 */
  #screen-home .board-header {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 10px;
    padding: 10px 12px 4px;
    scrollbar-width: none;
  }
  #screen-home .board-header::-webkit-scrollbar { display: none; }

  /* 拼豆清单：横屏锚定左列颜色区底部（跟随颜色区） */
  #screen-home .usage-sheet {
    left: 14px;
    right: auto;
    transform: none;
    width: min(380px, 46%);
    bottom: 18px;
  }
}

/* ── 横屏适配修正 ─────────────────────────────────────────
   1. 尺寸下拉：向左弹出（贴缩放条左侧），纵向不越界
   2. 色族弹层：颜色竖排（从上到下，放不下向右换列朝画布展开）
   3. 拉绳柄移到右缘中部，面板从右缘中部展开（竖屏保持顶部中央）
   4. 工具列限高：上下各留 70px，永不触顶被右上角 Menu 压
   注：角落组件横竖屏均为右上角横排；横屏无顶部保留带（Menu 浮于角落不占布局） */
@media (min-width: 900px), (orientation: landscape) and (min-width: 640px) {
  /* 拉绳柄：横屏贴右缘、垂直居中（竖屏保持顶部中央） */
  .rope-handle {
    top: 50%;
    left: auto;
    right: 0;
    transform: translateY(-50%);
    width: 26px;
    height: 64px;
    border: 2px solid var(--gp-line, #c8e6c9);
    border-right: none;
    border-radius: 14px 0 0 14px;
  }
  .rope-handle .rope-grip { width: 4px; height: 28px; }
  .rope-handle.open .rope-grip { transform: scaleY(0.7); }
  /* 工具列限高：上下延伸接近画布两端（角落 Menu 体积小且有右缘保留带，实测不重叠） */
  #screen-home .tool-bar { max-height: calc(100% - 16px); }
  /* 右缘保留带：拉绳柄在右缘中部，绘制区右收，工具列不被拉绳柄覆盖 */
  #screen-home { padding-right: 36px; }
  /* 拉绳面板：右缘中部弹出（跟随拉绳柄），按钮竖排；到最大高度向左换列（朝画布方向），不滚动 */
  .rope-panel {
    top: 50%;
    left: auto;
    right: 36px;
    transform: translate(16px, -50%);
    max-height: 86vh;
    overflow: visible;
    flex-wrap: wrap;
    align-content: flex-start;
    align-items: center;
    direction: rtl; /* 新列向左增长 */
  }
  .rope-panel .rope-section,
  .rope-panel .hdr-group { display: contents; } /* 拍平分组：所有按钮直接进入面板的换列流 */
  .rope-panel .header-btn-wrap { direction: ltr; }
  .rope-panel.open { transform: translate(0, -50%); }

  /* 尺寸下拉：向左弹出（贴缩放条左侧），纵向不越界 */
  #screen-home .zoom-pan-control .size-select-popup {
    left: auto;
    right: calc(100% + 8px);
    top: 0;
    bottom: auto;
    max-height: 80vh;
  }

  /* 色族弹层：竖排（从上到下），放不下向右换列朝画布展开 */
  .bead-panel {
    width: auto;
    max-width: 46vw;
    max-height: 82vh;
    animation: none; /* 竖屏上弹动画带横向位移，横屏禁用 */
  }
  .bead-panel .bead-sheet-grid {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    gap: 6px;
    max-height: calc(82vh - 24px);
    align-content: flex-start;
    overflow: visible;
  }
  .color-family-popup .cfp-grid {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 70vh;
    align-content: flex-start;
    overflow: visible;
  }
}

/* 横屏：拼豆清单——恰好两列、多出向右滚动、上下居中、底栏文字可换行 */
@media (min-width: 900px), (orientation: landscape) and (min-width: 640px) {
  #screen-home .usage-sheet {
    left: 14px;
    right: auto;
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    width: max-content; /* 宽度跟随内容（两列清单），不产生空白区 */
    max-width: 46vw;
    max-height: 78vh;
  }
  #screen-home .usage-sheet .usage-sheet-list {
    flex-direction: column;
    flex-wrap: wrap;
    align-content: flex-start;
    max-height: calc(78vh - 40px);
    max-width: 124px; /* 恰好两列：一列排满才换第二列，更多颜色向右滚动 */
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  #screen-home .usage-sheet .usage-sheet-foot {
    max-width: 124px; /* 底栏跟随清单宽度，文字自动换行，不撑宽弹层 */
  }
}

/* ── 按钮激活态与拼豆图标（2026-08-06）────────────────────────────── */
/* 激活态保持白图标（激活底色为更亮的透明白，见 .icon-btn/.tool-btn） */
.icon-btn.active,
.tool-btn.active { color: var(--ui-btn-ink, #fff); }

/* 拼豆按钮图标：三原色豆粒（三角放置：上二下一，大颗粒），替代 🫘 */
.beads-icon {
  display: grid;
  grid-template-columns: repeat(2, 12px);
  gap: 3px;
  justify-items: center;
  align-items: center;
}
.beads-icon .b3 {
  grid-column: 1 / -1;
  justify-self: center;
}
.beads-icon i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: block;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.beads-icon i::after {
  content: "";
  position: absolute;
  inset: 36%;
  background: #fff;
  border-radius: 50%;
}
.beads-icon .b1 { background: #e03131; } /* 红 */
.beads-icon .b2 { background: #ffd43b; } /* 黄 */
.beads-icon .b3 { background: #1971c2; } /* 蓝 */

/* ── 本地作品库面板（Phase 2）────────────────────────────────────────── */
.works-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
}
.works-card {
  background: #fff;
  border-radius: 18px;
  width: min(560px, 100%);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
.works-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--gp-line, #c8e6c9);
}
.works-title { font-size: 16px; font-weight: 800; color: var(--gp-ink, #1b3a2b); }
.works-close {
  width: 30px; height: 30px; border: none; border-radius: 8px;
  background: transparent; color: var(--gp-ink-light, #4a6b5a); font-size: 15px; cursor: pointer;
}
.works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  padding: 14px 16px;
  overflow-y: auto;
}
.works-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--gp-ink-light, #4a6b5a);
  font-size: 13px;
  padding: 32px 0;
}
.works-card-item {
  border: 2px solid var(--gp-line, #c8e6c9);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.works-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  background: #eef0f3;
  image-rendering: pixelated;
}
.works-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--gp-ink, #1b3a2b);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.works-meta { font-size: 11px; color: var(--gp-ink-light, #4a6b5a); }
.works-actions { display: flex; gap: 6px; }
.works-actions button {
  flex: 1;
  padding: 6px 0;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.works-open { background: var(--gp-brand, #2f9e44); color: #fff; }
.works-del { background: var(--gp-surface-2, #f8fdf9); color: var(--gp-danger, #e03131); border: 1px solid var(--gp-line, #c8e6c9) !important; }

/* ── 侧栏导航项（navMenu 配置渲染：图标 + 文字行）────────────────────── */
.side-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--ui-ink, #1b3a2b);
  text-decoration: none;
  cursor: pointer;
  text-align: left;
  box-sizing: border-box;
}
.side-nav-item:active { background: var(--gp-brand-light, #d3f9d8); }
.side-nav-check { color: var(--gp-brand, #2f9e44); font-weight: 800; margin-left: 6px; }
.side-nav-icon { font-size: 17px; width: 26px; text-align: center; flex: 0 0 auto; }
.side-nav-label { flex: 1; }
