/* 轻量编辑台专属样式。只在这个工具页加载，用全局 token 自动适配 dark/mid/light 三主题。 */
.ed { padding: 0; }
#ed-drop .dz { min-height: 300px; }

.ed-draft {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 12px;
  border: 1px solid var(--cyan-2); border-radius: var(--r-md);
  background: var(--brand-soft); color: var(--text); font-size: 13px;
}
.ed-dr-t { flex: 1; min-width: 160px; }
.ed-dr-b {
  height: 32px; padding: 0 14px; border: 1px solid var(--cyan-2); border-radius: var(--r-sm);
  background: var(--cyan-2); color: #04121b; font-size: 13px; font-weight: 600; cursor: pointer;
}
.ed-dr-x { background: transparent; color: var(--muted); border-color: var(--line-2); }

/* ---------- 工具栏：四个语义分组 ----------
   原来 24 个按钮平铺在一行里换行，分隔符跟着折行跑，找东西全靠悬停猜。
   现在按 绘制 / 画布 / 对齐 / 操作 各占一个圆角板块，组名写在左上。 */
.ed-top { margin-bottom: 14px; }
/* 网格而不是 flex-wrap：四组等宽落在 2×2 里，行末不会剩半截空白 */
.ed-bars { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 8px; align-items: start; }
.ed-grp {
  display: flex; flex-direction: column; gap: 6px;
  padding: 6px 8px 7px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
}
.ed-grp-l {
  display: flex; align-items: center; gap: 6px;
  padding-left: 2px;
  font-size: 10px; line-height: 1; letter-spacing: .09em; text-transform: uppercase;
  color: var(--dim);
}
.ed-grp-l em { font-style: normal; letter-spacing: 0; text-transform: none; opacity: .8; }
.ed-tools, .ed-grp-b { display: flex; gap: 5px; flex-wrap: wrap; }

.ed-tool, .ed-btn {
  min-width: 36px; height: 36px; padding: 0 8px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface); color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s, border-color .15s, background .15s, opacity .15s;
}
.ed-tool:hover, .ed-btn:hover { color: var(--text); border-color: var(--line-3); }
.ed-tool.on { color: #04121b; background: var(--cyan-2); border-color: var(--cyan-2); font-weight: 700; }
.ed-btn.ed-add { color: var(--cyan-2); border-color: var(--cyan-2); font-size: 13px; font-weight: 600; gap: 4px; }
.ed-btn.ed-add:hover { background: var(--brand-soft); }
.ed-btn { font-size: 19px; }
.ed-btn.ed-al { color: var(--cyan-2); font-size: 17px; }
.ed-btn.ed-tgl.on { color: #04121b; background: var(--cyan-2); border-color: var(--cyan-2); }

/* 对齐组单选时压暗：这 8 个按钮大部分时间用不上，但位置要留住 */
.ed-grp-al { border-color: var(--line); }
.ed-grp-al .ed-btn { opacity: .6; }
.ed-grp-al .ed-btn:hover { opacity: .85; }
.ed-grp-al.on { border-color: var(--line-3); }
.ed-grp-al.on .ed-btn { opacity: 1; }
.ed-grp-al.on .ed-grp-l { color: var(--cyan-2); }

.ed-body { display: grid; grid-template-columns: minmax(0, 1fr) 268px; gap: 14px; align-items: start; }
.ed-canvas-wrap {
  position: relative; overflow: auto; max-height: 66vh;
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: #1a2030;
  display: flex; align-items: flex-start; justify-content: flex-start;
  padding: 14px;
}
.ed-canvas-wrap.over { outline: 2px dashed var(--cyan-2); outline-offset: -4px; background: var(--brand-soft); }
.ed-canvas-wrap canvas {
  display: block; max-width: 100%; height: auto;
  box-shadow: 0 8px 30px -12px rgba(0, 0, 0, .55);
  /* 浅色主题下棋盘格和页面底都偏亮，用 outline 描一道边（不占布局，rect 不变，
     否则指针坐标换算会被 1px 边框带偏） */
  outline: 1px solid rgba(0, 0, 0, .22);
  outline-offset: -1px;
  touch-action: none; cursor: crosshair;
}
/* 放大后画布比容器大，按住空格拖动画布看别处 */
.ed-canvas-wrap.pan, .ed-canvas-wrap.pan canvas { cursor: grab; }
.ed-canvas-wrap.panning, .ed-canvas-wrap.panning canvas { cursor: grabbing; }

/* 画布右上角浮动缩放条：画布底色恒为深色，这里也用固定浅色，不跟主题 */
.ed-zoom {
  position: absolute; right: 10px; top: 10px; z-index: 4;
  display: flex; align-items: center; gap: 1px; padding: 3px;
  border: 1px solid rgba(255, 255, 255, .16); border-radius: 10px;
  background: rgba(10, 16, 26, .74);
}
.ed-zoom button {
  min-width: 26px; height: 26px; padding: 0 4px; border: 0; border-radius: 7px;
  background: none; color: #cfe6f5; font-size: 14px; line-height: 1; cursor: pointer;
}
.ed-zoom button:hover { background: rgba(255, 255, 255, .15); color: #fff; }
.ed-zoom .ed-zv { min-width: 46px; font-family: var(--mono); font-size: 11.5px; }
.ed-zoom .ed-zf { font-size: 11.5px; }

/* 画布内文字编辑框：浮在文字层上，字号跟随当前缩放，所见即所得 */
.ed-textedit {
  position: absolute; z-index: 14; display: none; box-sizing: border-box;
  margin: 0; padding: 2px; border: 1px dashed var(--cyan-2); border-radius: 4px;
  outline: none; resize: none; overflow: hidden; white-space: pre;
  font-family: inherit; line-height: 1.18;
  box-shadow: 0 8px 26px -10px rgba(0, 0, 0, .85);
}
.ed-textedit:focus { border-style: solid; }
/* 工程文件的存/读按钮用文字，比符号好认 */
.ed-btn.ed-proj { font-size: 13px !important; color: var(--cyan-2); }

/* 排版选项浮层：挂在「画布」分组下方 */
.ed-grp { position: relative; }
.ed-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: 252px;
  display: none; padding: 10px 11px 11px;
  border: 1px solid var(--line-2); border-radius: 12px;
  background: var(--surface); box-shadow: 0 18px 44px -18px rgba(0, 0, 0, .7);
}
.ed-pop.on { display: block; }
.ed-pop-t { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); margin-bottom: 8px; }
.ed-pop-l { display: flex; gap: 6px; margin-bottom: 10px; }
.ed-pop-l button {
  flex: 1; height: 34px; border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--surface-2); color: var(--muted); font-size: 12px; cursor: pointer;
}
.ed-pop-l button:hover { color: var(--text); border-color: var(--line-3); }
.ed-pop-l button.on { color: #04121b; background: var(--cyan-2); border-color: var(--cyan-2); font-weight: 600; }
.ed-pop-f { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.ed-pop-f input[type="range"] { flex: 1; accent-color: var(--cyan); min-width: 0; }
.ed-pop-f b { font-family: var(--mono); font-size: 11.5px; color: var(--text); font-weight: 500; min-width: 30px; text-align: right; }

/* 历史面板 */
.ed-hist { display: flex; flex-direction: column; gap: 3px; }
.ed-hi {
  display: flex; align-items: center; gap: 7px; padding: 7px 8px;
  border: 1px solid transparent; border-radius: 8px;
  font-size: 12.5px; color: var(--muted); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ed-hi:hover { background: var(--surface-2); color: var(--text); }
.ed-hi.cur { color: var(--cyan-2); border-color: var(--line-2); background: var(--brand-soft); cursor: default; font-weight: 600; }
.ed-hi.fut { opacity: .55; }
.ed-hi i { font-style: normal; font-size: 12px; flex: none; width: 12px; text-align: center; }
.ed-hist-sep { margin: 8px 2px 4px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }

.ed-side { border: 1px solid var(--line-2); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.ed-tabs { display: flex; border-bottom: 1px solid var(--line-2); }
.ed-tab {
  flex: 1; height: 42px; border: 0; background: none; color: var(--muted);
  font-size: 13px; cursor: pointer; border-bottom: 2px solid transparent;
}
.ed-tab.on { color: var(--cyan-2); border-bottom-color: var(--cyan-2); font-weight: 600; }
.ed-pane { padding: 10px; max-height: 56vh; overflow: auto; }

.ed-layer {
  display: flex; align-items: center; gap: 5px; padding: 7px 6px;
  border: 1px solid transparent; border-radius: 9px; cursor: pointer; margin-bottom: 5px;
}
.ed-layer:hover { background: var(--surface-2); }
.ed-layer.on { background: var(--brand-soft); border-color: var(--line-2); }
.ed-lt { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-lv, .ed-lb {
  flex: none; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; line-height: 1;
}
.ed-lv:hover, .ed-lb:hover { background: var(--surface-3); color: var(--text); }

.ed-hint { color: var(--dim); font-size: 12.5px; line-height: 1.7; margin: 6px 4px; }
.ed-prop-h { color: var(--cyan-2); font-size: 13px; font-weight: 600; margin: 2px 2px 12px; }
/* 属性面板里的小分区标题：调色 / 效果，避免十几个控件排成一条长龙 */
.ed-sub {
  margin: 12px 0 8px; padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 10.5px; line-height: 1; letter-spacing: .09em; text-transform: uppercase;
  color: var(--dim);
}
.ed-row2 > .ed-fck { justify-content: flex-end; }
.ed-fck .ed-ck { min-height: 30px; }
.ed-f { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; min-width: 0; }
.ed-f label { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.ed-f label b { color: var(--text); font-family: var(--mono); font-size: 11.5px; font-weight: 500; }
.ed-f input[type="range"] { width: 100%; accent-color: var(--cyan); margin: 0; }
.ed-f input[type="number"], .ed-f select, .ed-f textarea {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 9px; font-size: 13px; font-family: inherit;
}
.ed-f textarea { resize: vertical; line-height: 1.5; }
.ed-f input[type="color"] { width: 100%; height: 38px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 8px; cursor: pointer; }
.ed-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.ed-ck { flex-direction: row !important; align-items: center !important; gap: 7px !important; cursor: pointer; }
.ed-ck input { accent-color: var(--cyan); width: 16px; height: 16px; }
.ed-lock { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.ed-fname { font-size: 11.5px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 12px; }
/* 属性面板里的两个并排动作按钮：裁切 / 换图 */
.ed-acts2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.ed-acts2 button {
  height: 34px; padding: 0 6px; border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--surface-2); color: var(--muted); font-size: 12.5px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.ed-acts2 button:hover { color: var(--text); border-color: var(--cyan-2); }
.ed-mini {
  height: 30px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--surface-2); color: var(--muted); font-size: 12px; cursor: pointer; white-space: nowrap;
}
.ed-mini:hover { color: var(--text); border-color: var(--cyan-2); }

.ed-foot { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.ed-foot-in { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.ed-opts { display: flex; gap: 14px; flex-wrap: wrap; flex: 1; align-items: flex-end; }
.ed-opts label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.ed-opts .sel { min-width: 110px; }
.ed-opts input[type="range"] { width: 120px; accent-color: var(--cyan); }
.ed-dim { color: var(--dim); font-family: var(--mono); font-size: 12px; align-self: flex-end; padding-bottom: 9px; }
.ed-foot .btn-p { min-width: 160px; }

@media (max-width: 820px) {
  .ed-body { grid-template-columns: 1fr; }
  .ed-canvas-wrap { max-height: 52vh; }
  .ed-pane { max-height: none; }
  .ed-side { order: 2; }
  .ed-foot .btn-p { flex: 1; }
  /* 窄屏每组独占一行，纵向读下来就是「画什么 / 动画布 / 排图层 / 撤销删除」 */
  .ed-bars { gap: 6px; }
  .ed-grp { width: 100%; padding: 6px 7px; }
  .ed-grp-l { font-size: 10.5px; }
}

/* 430px 下 9 个绘图工具刚好差 4px 就要折行，收紧一点排成一行 */
@media (max-width: 520px) {
  .ed-tools, .ed-grp-b { gap: 4px; }
  .ed-tool, .ed-btn { min-width: 34px; padding: 0 6px; }
  .ed-btn.ed-add { padding: 0 8px; }
}
