/* ==========================================================================
   图片设计编辑器 · 专用样式（design-editor.html）
   设计语言：暖调人文 v3，但画板保持白底以对标矢量编辑场景
   ========================================================================== */

:root {
  --ink: #0c0b0a;
  --cream: #fbf8f1;
  --paper: #f2ece0;
  --paper-2: #e9e1d2;
  --clay: #8c4a2f;
  --gold: #c9a557;
  --blue: #2b6cf6;
  --muted: #6f675c;
  --line: rgba(12, 11, 10, 0.12);
  --bar-h: 56px;
  --tool-w: 58px;
  --panel-w: 264px;
  --fs: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  font-size: var(--fs);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ===== 顶栏 ===== */
.app__bar {
  flex: 0 0 var(--bar-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  background: var(--ink);
  color: var(--cream);
  border-bottom: 2px solid var(--clay);
}
.app__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--cream);
}
.app__mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: var(--clay);
  color: var(--cream);
  font-family: "Songti SC", "SimSun", serif;
  font-weight: 700;
  font-size: 16px;
}
.app__brand-text { font-size: 15px; letter-spacing: 0.04em; }
.app__doc {
  display: flex;
  flex-direction: column;
  padding-left: 18px;
  border-left: 1px solid rgba(241, 235, 221, 0.2);
  line-height: 1.3;
}
.app__doc-name {
  max-width: 260px;
  padding: 1px 5px; margin-left: -5px;
  font-size: 13px; color: var(--cream);
  border-radius: 4px; outline: none;
  cursor: text; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  transition: background 0.14s ease, box-shadow 0.14s ease;
}
.app__doc-name:hover { background: rgba(241, 235, 221, 0.1); }
.app__doc-name::selection { background: rgba(201, 165, 87, 0.6); color: #fffdf8; }
.app__doc-name:focus {
  background: rgba(241, 235, 221, 0.14);
  box-shadow: inset 0 0 0 1px rgba(201, 165, 87, 0.72);
  overflow: visible; text-overflow: clip;
}
.app__doc-size { font-size: 11px; color: var(--muted); font-family: monospace; }
.app__actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.app__sep { width: 1px; height: 24px; background: rgba(241, 235, 221, 0.2); margin: 0 4px; }

.abtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  background: rgba(241, 235, 221, 0.08);
  color: var(--cream);
  border: 1px solid rgba(241, 235, 221, 0.2);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.abtn:hover { background: rgba(241, 235, 221, 0.16); }
.abtn:disabled { opacity: 0.35; cursor: not-allowed; }
.abtn--primary {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold);
  font-weight: 600;
}
.abtn--primary:hover { background: #d8b76a; }

/* ===== 主体 ===== */
.app__body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

/* ===== 工具栏 ===== */
.toolbar {
  flex: 0 0 var(--tool-w);
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 12px 0;
}
.tool {
  width: 46px; height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.08s ease;
}
.tool:hover { background: var(--paper-2); }
.tool:active { transform: scale(0.94); }
.tool.is-active { color: var(--gold); }
.tool.is-active:hover { background: var(--paper-2); }
.tool .ico { width: 20px; height: 20px; stroke-width: 1.7; }
.tool__img { width: 20px; height: 20px; display: block; }
.tool__img--on { display: none; }
.tool.is-active .tool__img { display: none; }
.tool.is-active .tool__img--on { display: block; }
.tool__name { font-size: 10px; line-height: 1; letter-spacing: 0.02em; white-space: nowrap; }
.toolbar__sep {
  width: 26px; height: 1px;
  background: var(--line);
  margin: 6px 0;
}

/* ===== 舞台 ===== */
.stage {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    repeating-conic-gradient(#e4ddd0 0% 25%, #ece5d8 0% 50%) 0 / 22px 22px;
  position: relative;
}
.stage__scroll {
  flex: 1 1 auto;
  display: flex;
  justify-content: safe center;
  align-items: safe center;
  overflow: auto;
  padding: 24px;
}
/* 画布按真实尺寸 1:1 显示（width/height 属性 = viewBox 尺寸，1 单位 = 1 像素）；
   超出舞台时用 safe center 保证可滚动看到全部 */
.canvas {
  flex: 0 0 auto;
  display: block;
  background: transparent;
  touch-action: none;
  user-select: none;      /* 拖动文字/路径时不要触发浏览器原生的反白选中 */
  -webkit-user-select: none;
}
.canvas text, .canvas textPath, .canvas tspan { user-select: none; }
/* 魔棒工具激活：画布光标变十字，提示「点选」语义 */
.canvas.is-wand { cursor: crosshair; }

/* ===== 画布光标小图标（选择工具 / 魔棒工具激活时，工具图标即光标） ===== */
.cursor-tip {
  position: fixed;
  left: 0; top: 0;
  z-index: 70;
  pointer-events: none;          /* 不拦截画布命中 */
  display: none;
  will-change: transform;
}
.cursor-tip.is-on { display: block; }
.cursor-tip img {
  display: block;
  width: 20px; height: 20px;
  /* 白色描边光晕：让墨色图标在深色画布上同样可辨 */
  filter: drop-shadow(0 0 1px rgba(251, 248, 241, 0.95)) drop-shadow(0 1px 2px rgba(12, 11, 10, 0.35));
}
/* 图标已就绪：隐藏系统箭头，由工具图标充当光标 */
.canvas.is-toolcursor { cursor: none; }
/* 光标隐藏期间，选中框手柄保留自己的方向光标（否则会随 svg 一起消失） */
.canvas.is-toolcursor .sel-dot[data-dir="nw"],
.canvas.is-toolcursor .sel-dot[data-dir="se"] { cursor: nwse-resize; }
.canvas.is-toolcursor .sel-dot[data-dir="ne"],
.canvas.is-toolcursor .sel-dot[data-dir="sw"] { cursor: nesw-resize; }
.canvas.is-toolcursor .sel-bar[data-dir="n"],
.canvas.is-toolcursor .sel-bar[data-dir="s"] { cursor: ns-resize; }
.canvas.is-toolcursor .sel-bar[data-dir="e"],
.canvas.is-toolcursor .sel-bar[data-dir="w"] { cursor: ew-resize; }
.canvas.is-toolcursor .sel-rot { cursor: grab; }
/* 画板阴影贴在画板本身（而非整个视口），透明背景才有意义 */
#artboard { filter: drop-shadow(0 8px 26px rgba(12, 11, 10, 0.22)); }
.stage__hint {
  flex: 0 0 auto;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(251, 248, 241, 0.7);
  border-top: 1px solid var(--line);
  text-align: center;
}

/* 选中框（overlay · Canva 风格 · 蓝色） */
.sel-box { fill: none; stroke: var(--blue); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sel-handle { fill: #fff; stroke: var(--blue); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
/* 四角圆点手柄 */
.sel-dot { fill: #fff; stroke: var(--blue); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
/* 四边中点胶囊手柄 */
.sel-bar { fill: #fff; stroke: var(--blue); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
/* 下方旋转按钮 + 连线 */
.sel-stem { stroke: var(--blue); stroke-width: 1; stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
.sel-rot { fill: #fff; stroke: var(--blue); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.sel-rot-ico { fill: none; stroke: var(--blue); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.pen-anchor { fill: #fff; stroke: var(--clay); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.pen-anchor--active { fill: var(--gold); }
/* ===== 钢笔绘制：蓝色透明细线 + 可见锚点 ===== */
.__pen-draft {
  fill: none;
  stroke: rgba(43, 108, 246, 0.6);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.pen-node { fill: #fff; stroke: var(--blue); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.pen-node--active { fill: var(--blue); }                      /* 当前锚点：实心 */
.pen-node--hot { fill: var(--gold); stroke: var(--clay); }    /* 首锚点被指针命中：可闭合 */
/* 控制手柄（杠杆）：连线 + 可拖的端点圆点 */
.pen-handle-line { stroke: rgba(43, 108, 246, 0.55); stroke-width: 1; vector-effect: non-scaling-stroke; }
.pen-handle-dot { fill: #fff; stroke: var(--blue); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.pen-handle-dot--active { fill: var(--blue); }   /* 选中的杠杆端点：实心（与锚点规则一致） */

/* ===== 右侧面板 ===== */
.panel {
  flex: 0 0 var(--panel-w);
  background: var(--paper);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel__group {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.panel__group--grow { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
/* 右侧面板页签：属性 / 历史（同级） */
.panel__tabs { flex: none; display: flex; border-bottom: 1px solid var(--line); background: var(--cream); }
.panel__tab {
  flex: 1; padding: 13px 0 11px;
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  font-size: 13px; font-weight: 600; letter-spacing: 0.06em; color: var(--muted);
  cursor: pointer; transition: color 0.14s, border-color 0.14s;
  font-family: var(--sans);
}
.panel__tab:hover { color: var(--ink); }
.panel__tab.is-active { color: var(--clay); border-bottom-color: var(--clay); }
.panel__page { display: none; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.panel__page.is-active { display: flex; }
/* 属性页：上半可滚动（变换/对齐/外观…），图层固定在底部常驻可见 */
#propPage { overflow: hidden; }
.panel__scroll { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.panel__scroll::-webkit-scrollbar { width: 8px; }
.panel__scroll::-webkit-scrollbar-track { background: transparent; }
.panel__scroll::-webkit-scrollbar-thumb { background: rgba(12, 11, 10, 0.14); border-radius: 4px; }
.panel__group--layers {
  flex: 0 0 auto;
  height: 38%;
  min-height: 168px;
  max-height: 52%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: none;
}
.layer-list { min-height: 0; }
.panel__title {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel__count {
  font-family: monospace;
  font-size: 11px;
  color: var(--muted);
  background: var(--paper-2);
  padding: 1px 7px;
  border-radius: 9px;
}
.prop-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.prop-row > label { width: 48px; font-size: 13px; color: var(--muted); }
.prop-row input[type="color"] {
  width: 38px; height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  background: none;
  cursor: pointer;
}
.prop-check {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--muted);
  width: auto !important;
  cursor: pointer;
}
.prop-row input[type="range"] { flex: 1; accent-color: var(--clay); }
.prop-val { font-family: monospace; font-size: 12px; color: var(--ink); width: 22px; text-align: right; }
.panel__tip { margin: 4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ===== 图层列表（对标 Illustrator：缩略图 + 眼睛 + 名称） ===== */
.layer-list {
  list-style: none;
  margin: 0;
  padding: 0 2px 8px;
  overflow-y: auto;
  flex: 1 1 auto;
  scrollbar-width: thin;
}
.layer-list::-webkit-scrollbar { width: 8px; }
.layer-list::-webkit-scrollbar-track { background: transparent; }
.layer-list::-webkit-scrollbar-thumb { background: rgba(12, 11, 10, 0.16); border-radius: 4px; }
.layer-list::-webkit-scrollbar-thumb:hover { background: rgba(12, 11, 10, 0.3); }
.layer-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 5px 3px 3px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.25;
  color: var(--ink);
  transition: background 0.12s ease;
}
.layer-item + .layer-item { margin-top: 1px; }
.layer-item:hover { background: var(--paper-2); }
.layer-item.is-active { background: var(--ink); color: var(--cream); }
.layer-item.is-active .layer-thumb { border-color: rgba(251, 248, 241, 0.28); }
.layer-item.is-active .layer-eye { color: rgba(251, 248, 241, 0.62); }
.layer-item.is-active .layer-eye:hover { color: var(--gold); }
.layer-item.is-active .layer-kind { color: rgba(251, 248, 241, 0.42); }
.layer-item.is-active .layer-item__del { color: rgba(251, 248, 241, 0.5); }
.layer-item.is-active .layer-item__del:hover { color: var(--gold); }

/* 缩略图：棋盘底 + 真图形 */
.layer-thumb {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #f1ebdd 25%, transparent 25%, transparent 75%, #f1ebdd 75%),
    linear-gradient(45deg, #f1ebdd 25%, transparent 25%, transparent 75%, #f1ebdd 75%);
  background-size: 6px 6px;
  background-position: 0 0, 3px 3px;
  display: grid;
  place-items: center;
}
.layer-thumb svg { width: 100%; height: 100%; display: block; }
.layer-thumb--empty { background-image: none; background-color: var(--paper); }

/* 眼睛开关 */
.layer-eye {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border: none; background: none; padding: 0;
  color: var(--muted);
  cursor: pointer;
  border-radius: 3px;
  transition: color 0.12s ease, background 0.12s ease;
}
.layer-eye:hover { color: var(--ink); background: rgba(12, 11, 10, 0.06); }
.layer-item.is-active .layer-eye:hover { background: rgba(251, 248, 241, 0.12); }
.layer-eye .ico { width: 15px; height: 15px; }
.layer-item.is-hidden .layer-eye { color: var(--muted); opacity: 0.75; }

.layer-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 双击重命名的内联输入框 */
.layer-rename {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 12px;
  padding: 2px 5px;
  border: 1px solid var(--gold);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  outline: none;
  box-shadow: 0 0 0 2px rgba(201, 165, 87, 0.18);
}
.layer-kind {
  flex: 0 0 auto;
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.layer-item.is-hidden .layer-thumb,
.layer-item.is-hidden .layer-name,
.layer-item.is-hidden .layer-kind { opacity: 0.42; }

.layer-item__del {
  flex: 0 0 auto;
  border: none; background: none; cursor: pointer;
  color: var(--muted); padding: 2px 3px; border-radius: 3px;
  display: grid; place-items: center;
  opacity: 0;
  transition: opacity 0.12s ease, color 0.12s ease;
}
.layer-item:hover .layer-item__del { opacity: 1; }
.layer-item__del:hover { color: var(--clay); }
.layer-item.is-active .layer-item__del { color: rgba(251, 248, 241, 0.5); }
.layer-item.is-active .layer-item__del:hover { color: var(--gold); }

/* 背景层：恒在最底部、不可删不可选 */
.layer-item--bg {
  cursor: default;
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
  border-radius: 0 0 5px 5px;
}
.layer-item--bg:hover { background: var(--paper-2); }
.layer-item--bg .layer-name { color: var(--muted); }
.layer-empty { padding: 14px 8px; font-size: 12px; color: var(--muted); text-align: center; }

/* ===== 历史记录列表（右侧「历史」页签） ===== */
.history-list {
  list-style: none; margin: 12px 0 0; padding: 0;
  overflow-y: auto; flex: 1 1 auto;
}
.history-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  font-size: 13px; color: var(--ink);
  cursor: pointer; transition: background 0.12s ease;
}
.history-item:hover { background: var(--paper-2); }
.history-item__no {
  flex: none; width: 20px; text-align: center;
  font-family: monospace; font-size: 11px; color: var(--muted);
}
.history-item__label { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item--cur {
  background: var(--paper-2); font-weight: 600; cursor: default;
  border-left: 3px solid var(--gold); border-radius: 0 6px 6px 0;
}
.history-item--cur:hover { background: var(--paper-2); }
.history-item--cur .history-item__no { color: var(--gold); }
.history-item--future { opacity: 0.45; }

/* ===== 移动端 ===== */
@media (max-width: 820px) {
  .app__body { flex-direction: column; }
  .toolbar {
    flex: 0 0 auto;
    flex-direction: row;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 8px 10px;
    gap: 4px;
    overflow-x: auto;
  }
  .toolbar__sep { width: 1px; height: 28px; margin: 0 6px; }
  .stage { order: 2; }
  .panel {
    flex: 0 0 auto;
    width: 100%;
    max-height: 38vh;
    border-left: none;
    border-top: 1px solid var(--line);
  }
  .app__brand-text { display: none; }
  .abtn span, .abtn--primary { font-size: 12px; padding: 0 8px; }
}

/* ===== 轮1：变换 / 对齐 / 框选 ===== */
.prop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin-bottom: 12px;
}
.prop-cell { display: flex; align-items: center; gap: 6px; }
.prop-cell > label { width: 38px; font-size: 12px; color: var(--muted); flex: 0 0 auto; }
.prop-cell input[type="number"] {
  width: 100%; min-width: 0; height: 28px;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 0 7px; font-family: monospace; font-size: 12px;
  background: #fff; color: var(--ink);
}
.prop-cell input[type="number"]:focus { outline: none; border-color: var(--clay); }

.align-row { display: flex; gap: 6px; margin-top: 8px; }
.align-btn {
  flex: 1; height: 30px;
  border: 1px solid var(--line); background: #fff;
  border-radius: 6px; cursor: pointer; color: var(--ink); font-size: 13px;
  display: grid; place-items: center;
}
.align-btn:hover { background: var(--paper-2); }
.align-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.marquee { fill: rgba(43, 108, 246, 0.10); stroke: var(--blue); stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; pointer-events: none; }

/* 智能参考线（Canva 风格 · 红色标尺线） */
.guide { stroke: #e8453c; stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }
.guide--v, .guide--h { stroke-dasharray: 6 4; }
.guide__dot { fill: #e8453c; }

/* 拖动操作实时反馈标签（图标 + 数值） */
.hud-bg { fill: var(--ink); }
.hud-text { fill: #fff; font: 600 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.hud-ico { pointer-events: none; }
.hud-ico path { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }

/* 内联 SVG 图标（自绘线性，替代 Font Awesome —— 页面零外部依赖，断网可用） */
.ico { width: 18px; height: 18px; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico--f { fill: currentColor; stroke: none; }
.abtn .ico { width: 15px; height: 15px; }
.align-btn .ico { width: 15px; height: 15px; }
.layer-item__icon { display: grid; place-items: center; }
.layer-item__icon .ico { width: 14px; height: 14px; }
.layer-item__del .ico { width: 11px; height: 11px; }

/* ===== 文件工具子菜单 ===== */
.subtool {
  position: absolute;
  left: calc(var(--tool-w) + 6px);
  top: 64px;
  z-index: 30;
  display: none;
  flex-direction: column;
  gap: 2px;
  min-width: 152px;
  padding: 6px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(12, 11, 10, 0.18);
}
.subtool.is-open { display: flex; }
.subtool__item {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: none; border-radius: 8px;
  color: var(--ink);
  font-size: 14px; font-family: inherit;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.subtool__item:hover { background: var(--paper-2); color: var(--clay); }
/* 子菜单当前激活子项（鎏金淡底 + 赭石字，与工具激活态同语言） */
.subtool__item.is-active { background: rgba(201, 165, 87, 0.16); color: var(--clay); }
.subtool__item.is-active .ico { color: var(--clay); }
.subtool__item .ico { width: 18px; height: 18px; flex: 0 0 18px; }
.subtool__item:not(:last-child) { border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; }
.subtool__item:last-child { border-radius: 0 0 8px 8px; }
.subtool__kbd {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.subtool__item:hover .subtool__kbd { color: var(--clay); }

/* ===== 内联文字编辑器（单击画布浮出的可输入层） ===== */
/* 文字输入框：外面套一圈和画布选中框一模一样的手柄框（四角圆点 + 四边胶囊 + 底部旋转/移动双钮）
   框本身能缩放、旋转、拖动；里面的文字光标可直接输入。—— 尺寸与 drawSelection 的手柄同一套 */
.tbox {
  position: absolute; left: 0; top: 0; z-index: 40;
  transform-origin: 0 0;
  will-change: transform;
}
.tbox__frame {
  position: absolute; left: 0; top: 0;
  width: 100%; height: 100%;
  overflow: visible; pointer-events: none; z-index: 41;
}
.tbox__frame .sel-dot,
.tbox__frame .sel-bar,
.tbox__frame .sel-rot,
.tbox__frame .sel-mov { pointer-events: all; }
.tbox__frame .sel-dot, .tbox__frame .sel-bar { cursor: pointer; }
/* 四角 / 四边：给出对应的缩放方向光标（角点别显示成普通箭头） */
.tbox__frame .sel-dot[data-h="c0"],
.tbox__frame .sel-dot[data-h="c2"] { cursor: nwse-resize; }
.tbox__frame .sel-dot[data-h="c1"],
.tbox__frame .sel-dot[data-h="c3"] { cursor: nesw-resize; }
.tbox__frame .sel-bar[data-h="n"],
.tbox__frame .sel-bar[data-h="s"] { cursor: ns-resize; }
.tbox__frame .sel-bar[data-h="e"],
.tbox__frame .sel-bar[data-h="w"] { cursor: ew-resize; }
.tbox__frame .sel-rot { cursor: grab; }
.tbox__frame .sel-mov { cursor: move; }
.tbox__frame.is-busy .sel-rot { cursor: grabbing; }
/* 拖动中：框内文字区跟随手柄光标，不回落成文本插入光标 */
.tbox.is-dragging .textedit { cursor: inherit; }
/* 底部移动钮：与旋转钮同款，只是图标换成四向箭头 */
.sel-mov { fill: #fff; stroke: var(--blue); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.sel-mov-ico { fill: none; stroke: var(--blue); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }

.textedit {
  position: relative;
  display: block;
  min-width: 5em;                 /* 长方形：约 5 个字宽 */
  min-height: 1.2em;              /* 一行高 */
  padding: 3px 4px;
  background: none;
  border: 0;
  border-radius: 0;
  outline: none;
  color: var(--ink);
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-weight: 600;
  line-height: 1.2;
  white-space: pre;
  cursor: text;
  caret-color: var(--blue);
}
/* 空框占位字：灰的「输入文本」，一打字就消失 */
.textedit.is-empty::before {
  content: '输入文本';
  color: var(--muted);
  opacity: 0.66;
  font-weight: 400;
  pointer-events: none;
  user-select: none;
}
/* 竖排文字框：窄高、字符正立，从右往左排 */
.textedit--v {
  writing-mode: vertical-rl;
  text-orientation: upright;
  min-width: 1.2em;
  width: auto;
  min-height: 5em;
  padding: 3px 1px;
}

/* ===== 颜色工具浮动操作条（激活颜色工具时出现在舞台顶部） ===== */
.colorbar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: 0 10px 26px rgba(12, 11, 10, 0.16);
}
.colorbar.is-on { display: flex; }
.colorbar__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--clay);
  letter-spacing: 0.04em;
}
.colorbar__row { display: flex; align-items: center; gap: 6px; }
.colorbar__sw {
  width: 24px; height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.colorbar__sw:hover { transform: scale(1.12); }
.colorbar__sw.is-active { outline: 2px solid var(--blue); outline-offset: 1px; }
.colorbar__pick {
  width: 24px; height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
}
.colorbar__pick::-webkit-color-swatch-wrapper { padding: 2px; }
.colorbar__pick::-webkit-color-swatch { border: none; border-radius: 5px; }
.colorbar__grad, .colorbar__pat {
  width: 34px; height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.colorbar__grad:hover, .colorbar__pat:hover { transform: scale(1.08); }
.colorbar__grad.is-active, .colorbar__pat.is-active { outline: 2px solid var(--blue); outline-offset: 1px; }
.colorbar__tip { font-size: 11px; color: var(--muted); }

/* ===== 变换浮动操作条 ===== */
.tfbar { top: 54px; }
.tfbar__btn {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--cream);
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.tfbar__btn:hover { border-color: var(--clay); color: var(--clay); }
.tfbar__btn--primary { background: var(--ink); border-color: var(--ink); color: var(--gold); }
.tfbar__btn--primary:hover { background: var(--ink); color: var(--gold); }
.tfbar__num {
  width: 62px; height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--cream);
  font-size: 12px;
  color: var(--ink);
  text-align: center;
}
.tfbar__num:focus { outline: none; border-color: var(--clay); }
.tfbar__unit { font-size: 11px; color: var(--muted); }

/* ===== 模板库弹窗 ===== */
.modal {
  position: fixed; inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  background: rgba(12, 11, 10, 0.42);
  padding: 24px;
}
.modal.is-open { display: grid; }
.modal__card {
  width: min(620px, 94vw);
  max-height: 88vh; overflow: auto;
  background: var(--cream);
  border-radius: 16px;
  padding: 22px 24px 26px;
  box-shadow: 0 24px 60px rgba(12, 11, 10, 0.35);
}
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal__head h3 { margin: 0; font-size: 18px; letter-spacing: 0.03em; }
.modal__close {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: transparent; border: 1px solid var(--line); border-radius: 9px;
  color: var(--muted); cursor: pointer; transition: background 0.14s, color 0.14s;
}
.modal__close:hover { background: var(--paper-2); color: var(--clay); }
.modal__close .ico { width: 16px; height: 16px; }
/* 模板面板：大尺寸，内嵌「模板中心」网页 */
.modal--tpl { padding: 20px; }
.modal__card--tpl {
  width: min(1080px, 96vw);
  height: min(92vh, 820px);
  max-height: 92vh; overflow: hidden;
  display: flex; flex-direction: column;
}
.modal__card--tpl .modal__head { margin-bottom: 14px; flex: none; }
.tpl-frame-tip {
  flex: 1; text-align: center; font-size: 12px; color: var(--muted);
  letter-spacing: 0.04em;
}
.tpl-frame-wrap {
  flex: 1; min-height: 0;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: #f2f4f8;
}
.tpl-frame-wrap iframe { display: block; width: 100%; height: 100%; border: 0; }
/* 我的功能面板：功能入口列表 */
.modal__card--me { width: min(440px, 94vw); }
.me-list { display: flex; flex-direction: column; gap: 10px; }
.me-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 14px 16px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  cursor: pointer; text-align: left;
  transition: border-color 0.14s, box-shadow 0.14s, transform 0.14s;
}
.me-item:hover { border-color: var(--clay); box-shadow: 0 6px 18px rgba(140, 74, 47, 0.12); transform: translateY(-1px); }
.me-item__ico {
  flex: none; width: 42px; height: 42px; display: grid; place-items: center;
  background: var(--paper-2); border-radius: 10px; color: var(--clay);
}
.me-item__ico .ico { width: 20px; height: 20px; }
.me-item__txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.me-item__txt b { font-size: 14px; font-weight: 600; color: var(--ink); }
.me-item__txt em { font-style: normal; font-size: 12px; color: var(--muted); }
.me-item__arr { flex: none; width: 16px; height: 16px; color: var(--muted); }
.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.tpl-card {
  display: flex; flex-direction: column; gap: 9px;
  background: transparent; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; cursor: pointer; font-family: inherit; color: var(--ink);
  transition: border-color 0.14s, box-shadow 0.14s, transform 0.08s;
}
.tpl-card:hover { border-color: var(--clay); box-shadow: 0 8px 20px rgba(140, 74, 47, 0.16); }
.tpl-card:active { transform: scale(0.97); }
.tpl-card__thumb { height: 96px; border-radius: 8px; overflow: hidden; display: grid; place-items: center; background: var(--paper); }
.tpl-card__name { font-size: 13px; text-align: center; color: var(--muted); }
.tpl-thumb { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 0 12px; }
.tpl-thumb b { font-size: 15px; }
.tpl-thumb em { font-style: normal; font-size: 11px; opacity: 0.75; }
.tpl-thumb--poster { background: var(--paper); }
.tpl-thumb--poster i { width: 30px; height: 5px; background: var(--clay); border-radius: 2px; }
.tpl-thumb--poster b { color: var(--ink); }
.tpl-thumb--card { background: var(--ink); }
.tpl-thumb--card b, .tpl-thumb--card em { color: var(--cream); }
.tpl-thumb--social { background: linear-gradient(135deg, var(--clay), var(--gold)); }
.tpl-thumb--social b { color: #fff; } .tpl-thumb--social em { color: rgba(255,255,255,0.85); }

/* ===== 拼图面板 ===== */
.modal__card--collage { width: min(880px, 96vw); }
.modal__card--collage .modal__head { margin-bottom: 14px; }
.collage__nums { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.collage__num {
  padding: 6px 14px; font: inherit; font-size: 12px; line-height: 1.4;
  color: var(--muted); background: #fff;
  border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
  font-family: ui-monospace, Menlo, monospace;
  transition: border-color 0.14s, color 0.14s, background 0.14s;
}
.collage__num:hover { border-color: var(--clay); color: var(--clay); }
.collage__num.is-active { background: var(--ink); border-color: var(--ink); color: var(--cream); }
.collage__tpls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; min-height: 196px; }
.collage__tpl {
  display: flex; flex-direction: column; gap: 7px; padding: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; font: inherit; color: var(--muted);
  transition: border-color 0.14s, box-shadow 0.14s;
}
.collage__tpl:hover { border-color: var(--clay); }
.collage__tpl.is-active { border-color: var(--clay); box-shadow: 0 0 0 1px var(--clay) inset; color: var(--ink); }
.collage__tpl b { font-size: 11px; font-weight: 500; text-align: center; }
.collage__thumb {
  display: grid; gap: 2px; height: 78px; padding: 3px;
  background: var(--paper); border-radius: 4px;
}
.collage__thumb i { background: #cfc6b3; border-radius: 1px; }
.collage__tip { margin: 12px 0 0; font-size: 11px; line-height: 1.7; color: var(--muted); }
.modal__card--collage .modal__foot { margin-top: 14px; }

/* 顶部条里的拼图属性控件 */
.qbtn.qbtn--txt { width: auto; padding: 0 9px; font-size: 12px; font-weight: 500; }
.qmeta { font-size: 11px; line-height: 1; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }

/* ===== 新建画布弹窗 ===== */
.new-name { display: flex; align-items: center; gap: 10px; margin: 2px 0 4px; }
.new-name > span { flex: 0 0 auto; font-size: 12px; color: var(--muted); }
.new-name input {
  flex: 1 1 auto; min-width: 0;
  padding: 9px 11px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); font-family: inherit;
}
.new-name input:focus { outline: none; border-color: var(--clay); }
.new-sec {
  margin: 18px 0 10px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--muted);
}
.new-sec:first-of-type { margin-top: 4px; }
.preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.preset {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 6px;
  background: var(--paper);
  border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; font-family: inherit; color: var(--ink);
  transition: border-color 0.14s, background 0.14s, box-shadow 0.14s;
}
.preset:hover { border-color: var(--gold); }
.preset.is-active { border-color: var(--clay); background: var(--cream); box-shadow: 0 0 0 1px var(--clay) inset; }
.preset__thumb { height: 30px; display: flex; align-items: center; justify-content: center; }
.preset__thumb i { display: block; background: #fff; border: 1.5px solid var(--clay); border-radius: 2px; }
.preset b { font-size: 13px; font-weight: 600; }
.preset em { font-style: normal; font-size: 11px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }

.new-size { display: flex; align-items: flex-end; gap: 10px; }
.new-size__f { flex: 1 1 0; display: flex; flex-direction: column; gap: 4px; }
.new-size__f span { font-size: 12px; color: var(--muted); }
.new-size__f input {
  width: 100%; padding: 8px 10px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
  font-family: ui-monospace, Menlo, monospace;
}
.new-size__f input:focus { outline: none; border-color: var(--clay); }
.new-size__swap {
  width: 38px; height: 38px; flex: 0 0 38px;
  display: grid; place-items: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); cursor: pointer; transition: background 0.14s, color 0.14s;
}
.new-size__swap:hover { background: var(--paper-2); color: var(--clay); }
.new-size__swap .ico { width: 18px; height: 18px; }

.bg-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bg-dot {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); cursor: pointer; padding: 0;
  transition: box-shadow 0.14s, transform 0.08s;
}
.bg-dot:hover { transform: scale(1.06); }
.bg-dot.is-active { box-shadow: 0 0 0 2px var(--cream), 0 0 0 4px var(--clay); }
.bg-dot--none {
  background:
    linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%) 0 0 / 12px 12px,
    linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%) 6px 6px / 12px 12px,
    #fff;
}
.bg-custom { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.bg-custom input[type="color"] {
  width: 34px; height: 34px; padding: 0; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; cursor: pointer;
}
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ===== 缩放控件（右下角浮动） ===== */
.zoombar {
  position: absolute;
  right: 16px;
  bottom: 48px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(12, 11, 10, 0.20);
}
.zoombar__btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: transparent; border: none; border-radius: 8px;
  color: var(--ink); cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.zoombar__btn:hover { background: var(--paper-2); color: var(--clay); }
.zoombar__btn .ico { width: 16px; height: 16px; }
.zoombar__btn--fit { width: auto; padding: 0 8px; }
.zoombar__range {
  -webkit-appearance: none; appearance: none;
  width: 108px; height: 4px; border-radius: 3px;
  background: var(--paper-2); outline: none; cursor: pointer;
}
.zoombar__range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--clay); border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(12, 11, 10, 0.35); cursor: pointer;
}
.zoombar__range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--clay); border: 2px solid #fff; cursor: pointer;
}
.zoombar__val {
  min-width: 46px; padding: 4px 6px;
  background: transparent; border: none; border-radius: 7px;
  text-align: center; cursor: pointer;
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; font-weight: 600; color: var(--muted);
  transition: background 0.14s, color 0.14s;
}
.zoombar__val:hover { background: var(--paper-2); color: var(--clay); }
.zoombar__sep { width: 1px; height: 20px; background: var(--line); }

@media (max-width: 720px) {
  .zoombar { right: 10px; bottom: 42px; padding: 5px 8px; gap: 4px; }
  .zoombar__range { width: 72px; }
  .zoombar__val { min-width: 40px; }
}

/* ===== 画布顶部功能快速导航条（随当前工具切换内容；替代原先元素下方的浮动条） ===== */
.qbar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 26;
  display: none;
  align-items: center;
  gap: 8px;
  height: 42px;
  max-width: calc(100% - 24px);
  overflow-x: auto;                 /* 内容过多时条内横向滚动，不撑破画布 */
  overflow-y: hidden;
  scrollbar-width: none;
  padding: 0 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: 0 10px 26px rgba(12, 11, 10, 0.16);
  white-space: nowrap;
}
.qbar.is-on { display: flex; }
.qbar::-webkit-scrollbar { display: none; }
.qbar__seg { display: none; align-items: center; gap: 2px; position: relative; }
.qbar__seg.is-on { display: flex; }
.qbar__sep { width: 1px; height: 18px; background: var(--line); margin: 0 2px; flex: 0 0 auto; }
/* 快捷项按钮：工具子模式 / 对象操作 */
.qbtn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px;
  background: transparent;
  border: none;
  border-radius: 7px;
  font-family: inherit;
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.qbtn:hover { background: var(--paper-2); color: var(--blue); }
.qbtn.is-active { background: rgba(201, 165, 87, 0.18); color: var(--clay); font-weight: 600; }
.qbtn .ico { width: 15px; height: 15px; }
.qbtn--danger:hover { background: rgba(217, 70, 60, 0.12); color: #d9463c; }
/* 条内的颜色 / 变换段：去掉自身绝对定位与阴影，只作为 qbar 的一段 */
.qbar .colorbar {
  position: static;
  transform: none;
  top: auto;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  gap: 8px;
}
/* 条内的形状参数：控件固定尺寸，不再随元素拉伸 */
.qbar .shapebar__ico,
.qbar .shapebar__btn,
.qbar .shapebar__num,
.qbar .shapebar__sw { flex: 0 0 auto; width: 26px; height: 26px; }
.qbar .shapebar__ico { width: 34px; }
.qbar .shapebar__step { flex: 0 0 auto; }
/* 弹层从顶部条向下弹 */
.qbar .shapebar__pop { top: calc(100% + 8px); bottom: auto; }

/* ---- 顶部条属性控件：色块 / 滑块 / 步进 ---- */
.qsw {
  width: 26px; height: 26px;
  padding: 0;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.14s;
}
.qsw:hover { border-color: var(--clay); }
.qsw i {
  width: 16px; height: 16px;
  display: block;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(12, 11, 10, 0.14);
}
.qsw i.is-none {
  background: repeating-linear-gradient(45deg, #fff 0 3px, var(--paper-2) 3px 6px) !important;
  box-shadow: inset 0 0 0 1px rgba(12, 11, 10, 0.14);
}
/* 字体选择：显示当前字体名，点击弹出字体列表 */
.qfont {
  height: 26px;
  max-width: 118px;
  padding: 0 18px 0 9px;
  position: relative;
  display: block;
  line-height: 24px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.14s, color 0.14s;
}
.qfont:hover { border-color: var(--clay); color: var(--clay); }
.qfont::after {
  content: ''; position: absolute; right: 7px; top: 50%; margin-top: -2px;
  border-left: 3.5px solid transparent; border-right: 3.5px solid transparent;
  border-top: 4px solid var(--muted);
}
.qpop[data-fontkey] { width: 168px; padding: 5px; }
/* 字体下拉项多（系统字体 + 在线字体库）时给足高度，并显示细滚动条 */
.qpop[data-fontkey] .qdrop__list {
  max-height: 372px;
  scrollbar-width: thin;
}
.qpop[data-fontkey] .qdrop__list::-webkit-scrollbar { width: 6px; }
.qpop[data-fontkey] .qdrop__list::-webkit-scrollbar-track { background: transparent; }
.qpop[data-fontkey] .qdrop__list::-webkit-scrollbar-thumb { background: rgba(12, 11, 10, 0.16); border-radius: 3px; }
.qfontitem {
  display: block; width: 100%;
  padding: 6px 9px;
  font-size: 15px; line-height: 1.25; color: var(--ink); text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: transparent; border: 0; border-radius: 6px;
  cursor: pointer;
}
.qfontitem + .qfontitem { margin-top: 1px; }
.qfontitem:hover { background: var(--paper-2); color: var(--clay); }
.qfontitem.is-active { background: var(--ink); color: var(--cream); }
/* 字体下拉的分组标题（我的字体库 / 系统字体） */
.qdrop__grp {
  padding: 7px 9px 4px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-top: 1px solid var(--line);
  margin-top: 3px;
}
.qdrop__grp:first-child { border-top: none; margin-top: 0; padding-top: 3px; }
/* 加粗 / 倾斜图标按钮 */
.qbtn--ico {
  width: 26px; padding: 0; justify-content: center;
  font-family: 'Times New Roman', var(--serif); font-size: 15px; line-height: 1;
  color: var(--ink);
}
.qbtn--ico svg { width: 15px; height: 15px; display: block; }
.qbtn--ico:hover { background: var(--paper-2); color: var(--blue); }
.qbtn--ico.is-active { background: rgba(201, 165, 87, 0.2); color: var(--clay); }
.qlabel { font-size: 12px; color: var(--muted); }
.qrange {
  width: 78px; height: 26px;
  accent-color: var(--clay);
  cursor: pointer;
}
.qval {
  min-width: 26px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--clay);
  text-align: center;
}
.qstep { display: flex; align-items: center; gap: 2px; }
.qstep button {
  width: 24px; height: 24px;
  padding: 0;
  display: grid; place-items: center;
  background: transparent; border: none; border-radius: 6px;
  font-size: 14px; line-height: 1; color: var(--ink); cursor: pointer;
}
.qstep button:hover { background: var(--paper-2); color: var(--blue); }
.qstep .qval { font-size: 13px; }

/* 数值控件：可直接输入 + 右侧下拉取预设 */
.qnum { position: relative; display: inline-flex; align-items: center; flex: 0 0 auto; }
.qnum__in {
  width: 44px; height: 24px;
  padding: 0 15px 0 4px;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--clay); text-align: center;
  background: #fff;
  border: 1px solid var(--line); border-radius: 7px;
  outline: none;
  -moz-appearance: textfield;
}
.qnum__in::-webkit-outer-spin-button,
.qnum__in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qnum__in:hover { border-color: rgba(140, 74, 47, 0.34); }
.qnum__in:focus { border-color: var(--clay); color: var(--ink); box-shadow: 0 0 0 2px rgba(201, 165, 87, 0.22); }
.qnum__caret {
  position: absolute; right: 1px; top: 1px;
  width: 14px; height: 22px; padding: 0;
  display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 0 6px 6px 0;
  cursor: pointer;
}
.qnum__caret i {
  width: 0; height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4.5px solid var(--muted);
}
.qnum__caret:hover { background: var(--paper-2); }
.qnum__caret:hover i { border-top-color: var(--clay); }
.qnum--sb .qnum__in { width: 42px; }

/* 数值下拉列表（放在 .qpop 容器里） */
.qpop[data-numkey] { width: 44px; min-width: 0; padding: 4px; }   /* 宽度与顶部条数值框一致 */
.qdrop__head { display: none; }
.qdrop__list {
  display: block; max-height: 258px; overflow-y: auto;
  scrollbar-width: none;                    /* 隐藏滚动条，避免吃掉 5px 宽度 */
}
.qdrop__list::-webkit-scrollbar { width: 0; height: 0; }
.qdrop__item {
  display: block; width: 100%;
  padding: 4px 0;
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  color: var(--ink); text-align: center; line-height: 1.35;
  background: transparent; border: 0; border-radius: 4px;
  cursor: pointer;
}
.qdrop__item + .qdrop__item { margin-top: 1px; }
.qdrop__item:hover { background: var(--paper-2); color: var(--clay); }
.qdrop__item.is-active { background: var(--ink); color: var(--cream); }
/* 顶部条弹层（色板 / 数值下拉）：fixed 定位，坐标由 placeQPop() 按锚点算出 */
.qpop {
  position: fixed;
  top: 0; left: 0;
  display: none;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(12, 11, 10, 0.18);
  z-index: 90;
}
.qpop.is-on { display: block; }
.qpop__custom {
  display: flex; align-items: center; gap: 6px;
  margin-top: 6px;
  font-size: 11px; color: var(--muted);
}
.qpop__custom input {
  width: 34px; height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
.qpop__none {
  width: 100%;
  margin-top: 6px;
  padding: 4px 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit; font-size: 11px; color: var(--muted);
  cursor: pointer;
}
.qpop__none:hover { border-color: var(--clay); color: var(--clay); }

/* ---- 形状参数控件（原元素导航条，现作为 qbar 的一段）---- */
.shapebar__step { display: flex; align-items: center; gap: 2px; }
.shapebar__ico,
.shapebar__btn,
.shapebar__num,
.shapebar__sw {
  flex: 1; min-width: 0;
  height: 30px;
  display: grid; place-items: center;
  background: transparent; border: none; border-radius: 7px;
  color: var(--ink); cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.shapebar__ico:hover,
.shapebar__btn:hover,
.shapebar__num:hover,
.shapebar__sw:hover { background: var(--paper-2); color: var(--blue); }
.shapebar__ico .ico { width: 16px; height: 16px; }
.shapebar__caret { width: 9px; height: 9px; opacity: 0.55; }
.shapebar__btn { font-size: 15px; line-height: 1; }
.shapebar__num { font-family: var(--mono); font-size: 13px; }
.shapebar__sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.shapebar__dot { width: 15px; height: 15px; border-radius: 4px; background: var(--gold); box-shadow: inset 0 0 0 1px rgba(12, 11, 10, 0.12); }
.shapebar__dot--ring { background: transparent; box-shadow: inset 0 0 0 2px var(--ink); }
/* 弹出层（边数网格 / 色板）—— 与编辑器弹窗一致的白底 */
.shapebar__pop {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  bottom: calc(100% + 6px);
  display: none;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(12, 11, 10, 0.18);
}
#qShape.is-pop .shapebar__pop { display: block; }
.sb-grid { display: grid; grid-template-columns: repeat(5, 26px); gap: 3px; }
.sb-grid__cell {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  background: transparent; border: none; border-radius: 6px;
  color: var(--ink); font-family: var(--mono); font-size: 12px; cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.sb-grid__cell:hover { background: var(--paper-2); color: var(--blue); }
.sb-grid__cell.is-cur { background: var(--blue); color: #fff; }
.sb-swatches { display: grid; grid-template-columns: repeat(4, 22px); gap: 5px; }
.sb-swatch {
  width: 22px; height: 22px;
  border: none; border-radius: 6px; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(12, 11, 10, 0.14);
  transition: transform 0.12s;
}
.sb-swatch:hover { transform: scale(1.14); }

/* ---- 路径文字：没有文本框，直接在路径上输入，光标沿路径走 ---- */
.tp-live-input {
  position: absolute; left: 0; top: 0;
  width: 1px; height: 1px; padding: 0; margin: 0;
  border: 0; outline: 0; background: transparent;
  opacity: 0; color: transparent; caret-color: transparent;
  pointer-events: none; font-size: 16px;
}
.tp-caret {
  stroke-width: 1.6; stroke-linecap: round; fill: none;
  animation: tpCaretBlink 1.05s steps(1, end) infinite;
}
@keyframes tpCaretBlink { 0%, 52% { opacity: 1; } 53%, 100% { opacity: 0; } }

/* ======================================================================
   手机端骨架（≤720px）
   结构：底部功能条（固定）+ 底部属性弹窗（浮层，可开合）
   桌面端：.msheet / .msheet-mask 全部隐藏，布局与原来完全一致
   ====================================================================== */
.msheet { display: none; }
.msheet-mask { display: none; }

@media (max-width: 720px) {
  :root { --dock-h: 58px; }

  /* ---------- 顶栏：返回 / 画板名 / 导出图标 ---------- */
  .app__bar { height: 50px; padding: 0 8px; gap: 6px; }
  .app__brand { min-width: 0; gap: 0; }
  .app__brand-text { display: none; }
  .app__mark { width: 26px; height: 26px; font-size: 13px; }
  .app__doc { min-width: 0; flex: 1 1 auto; }
  .app__doc-name { font-size: 13px; }
  .app__doc-size { font-size: 9.5px; }
  .app__actions { gap: 3px; flex: 0 0 auto; }
  .app__actions .app__sep { display: none; }
  .app__actions .abtn { width: 32px; height: 32px; padding: 0; justify-content: center; }
  /* 导出按钮只留图标（文字是裸节点，用 font-size:0 收掉） */
  .app__actions .abtn--primary { font-size: 0; width: 34px; gap: 0; }
  .app__actions .abtn .ico { width: 17px; height: 17px; }

  /* ---------- 画布区：铺满，底部给功能条让位 ---------- */
  .app__body { padding-bottom: var(--dock-h); }
  .stage { order: 0; height: calc(100vh - 50px - var(--dock-h)); min-height: 0; overflow: hidden; }
  .stage__hint { display: none; }
  .zoombar {
    right: 8px; bottom: calc(var(--dock-h) + 10px);
    padding: 4px 7px; gap: 3px; transform: scale(0.94); transform-origin: right bottom;
  }
  .zoombar__range { width: 62px; }

  /* ---------- 底部功能条 ---------- */
  .toolbar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: 100%;
    height: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px));
    flex-direction: row; align-items: center; justify-content: flex-start;
    padding: 0 2px env(safe-area-inset-bottom, 0px);
    gap: 0;
    border-right: none; border-top: 1px solid var(--line);
    background: #fff;
    z-index: 60;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar__sep { display: none; }
  .tool {
    flex: 0 0 46px; width: 46px; height: 50px;
    border-radius: 9px; gap: 2px; padding: 0;
  }
  .tool__img { width: 21px; height: 21px; }
  .tool__name { font-size: 9px; }
  .tool.is-active { background: rgba(201, 165, 87, 0.13); }

  /* ---------- 底部属性弹窗 ---------- */
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0;
    width: 100%; height: 56vh; max-height: none;
    flex: none;
    z-index: 55;
    border-left: none; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 34px rgba(12, 11, 10, 0.18);
    padding-bottom: var(--dock-h);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
  }
  .panel.is-open { transform: translateY(0); }

  /* 弹窗头 */
  .msheet { display: block; flex: 0 0 auto; padding-top: 6px; touch-action: none; }
  .msheet__grab {
    display: block; width: 36px; height: 3px; border-radius: 3px;
    background: #ddd3bf; margin: 0 auto 5px;
  }
  .msheet__bar { display: flex; align-items: center; padding: 0 10px 5px; }
  .msheet__title { flex: 1; font-size: 13px; letter-spacing: 0.02em; }
  .msheet__close {
    width: 30px; height: 30px; margin-right: -4px;
    border: none; background: transparent; border-radius: 8px;
    font-size: 14px; line-height: 1; color: var(--muted); cursor: pointer;
  }
  .msheet__close:active { background: var(--paper-2); }

  /* 遮罩 */
  .msheet-mask {
    display: block; position: fixed; inset: 0;
    background: rgba(12, 11, 10, 0.04);   /* 只是为了接住「点外面关闭」，不压暗画布 */
    opacity: 0; pointer-events: none;
    transition: opacity 0.24s ease;
    z-index: 50;
  }
  .msheet-mask.is-on { opacity: 1; pointer-events: auto; }

  /* 搬进弹窗的快捷参数条 */
  .panel > .qbar {
    position: static; transform: none; left: auto; right: auto; top: auto;
    width: auto; max-width: none; height: auto;
    flex: 0 0 auto;
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    margin: 0; padding: 0 10px 8px;
    border: none; border-radius: 0; box-shadow: none;
    border-bottom: 1px solid #f0ebdf;
    background: #fff;
    overflow: visible; white-space: normal;
    gap: 7px;
  }
  .panel > .qbar .qbar__seg { flex-wrap: wrap; gap: 4px; }
  .panel > .qbar .qbtn { height: 30px; padding: 0 10px; font-size: 11.5px; }
  .panel > .qbar .qbar__sep { display: none; }

  /* 页签与内容 */
  .panel__tabs { flex: 0 0 auto; }
  .panel__tab { padding: 10px 0 8px; font-size: 12.5px; }
  .panel__group { padding: 12px 14px; }
  .panel__group--layers { height: 30%; min-height: 112px; }
  .panel__tip { display: none; }
}

/* ===== 手机端补充：工具行 / 浮层抑制 / 层级修正 ===== */
@media (max-width: 720px) {
  /* 功能条必须压住弹窗 */
  .toolbar { z-index: 70; }

  /* 提示语在手机弹窗里纯占地方 */
  .panel > .qbar .qlabel { display: none; }

  /* 这些子菜单已搬进弹窗顶部，手机上不再弹浮层 */
  #selectMenu, #shapeMenu, #drawMenu, #penMenu,
  #pathMenu, #textMenu, #colorMenu, #transformMenu { display: none !important; }

  /* 弹窗顶部工具行 */
  .msheet__tools {
    display: flex; gap: 6px;
    padding: 0 10px 8px;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none;
    flex: 0 0 auto;
  }
  .msheet__tools::-webkit-scrollbar { display: none; }
  .msheet__tools:empty { display: none; }
  .mtool {
    flex: 0 0 auto;
    min-width: 52px; height: 46px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 0 8px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 9px;
    font-family: var(--sans);
    font-size: 10px;
    color: var(--ink-2, #2a2723);
    cursor: pointer;
  }
  .mtool .ico { width: 17px; height: 17px; stroke-width: 1.7; }
  .mtool.is-on {
    background: rgba(201, 165, 87, 0.14);
    border-color: rgba(201, 165, 87, 0.62);
    color: var(--clay);
    font-weight: 600;
  }
  .mtool__kbd { display: none; }
}

/* 手机端：弹窗打开时把画板上推到可视区上半部分 */
@media (max-width: 720px) {
  .stage.is-sheet .stage__scroll { padding-bottom: 62vh; min-height: 0; }
}

/* ===== 颜色工具：顶部快选色带（拾色器 / 无色 / 红橙黄绿青蓝紫） ===== */
.qsw--pick { position: relative; overflow: hidden; }
.qsw--pick input[type="color"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; padding: 0; cursor: pointer;
}
.qsw__rainbow {
  width: 16px; height: 16px;
  border-radius: 50% !important;
  background: conic-gradient(#d33a2c, #e8730c, #e8b40a, #2e9e4f, #12a3a3, #2b6cf6, #7c4ddb, #d33a2c) !important;
  box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 3px rgba(12, 11, 10, 0.16) !important;
}
.qsw.is-active {
  border-color: var(--clay);
  box-shadow: 0 0 0 1px var(--clay);
}
.qsw--preset i { transition: transform 0.12s ease; }
.qsw--preset:hover i { transform: scale(1.1); }
