/* ============================================================================
 * public/imgeditor.css —— 「图片编辑」（画布式编辑器）样式
 *
 * 🔴 三条自定规则
 *   ① **绝不改 style.css**（站内铁律：改别人的样式会波及整站）→ 全部样式在本文件，
 *      由 index.html 排在 style.css **之后**加载。
 *   ② 类名一律 `ie-` 前缀（已全局查重，无冲突）。
 *   ③ 本页大量用 `hidden` 控制显隐，且容器是 flex → 作者样式会盖掉 UA 的 [hidden]，
 *      **必须显式兜底**（站内已因这个踩过 7 批）。
 *
 * ── 布局策略（一套代码两种形态）────────────────────────────────────────────
 *   默认（手机）：竖排 —— 顶部工具条 → 画布 → 底部工具栏 → 面板（可滚动）。
 *   ≥900px（桌面）：横排 —— 左侧图标栏 / 画布 / 右侧参数面板（与参考产品一致）。
 * ========================================================================== */

#sub-imgeditor [hidden] { display: none !important; }

/* ---------- 顶部工具条 ---------- */
.ie-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 2px 10px;
}
.ie-bar-sp { flex: 1; }
.ie-ico {
  width: 34px; height: 34px; border-radius: 10px; cursor: pointer;
  border: 1px solid #eae0d6; background: #fff; color: var(--text);
  font-size: 16px; line-height: 1; font-family: inherit;
}
.ie-ico:disabled { opacity: .38; cursor: default; }
.ie-ico:not(:disabled):active { transform: translateY(1px); }
.ie-btn {
  border: none; cursor: pointer; font-family: inherit;
  font-size: 13px; font-weight: 700; padding: 9px 14px; border-radius: 999px;
  background: linear-gradient(135deg, #14b8a6, #0f766e); color: #fff;
  white-space: nowrap;
}
.ie-btn:disabled { opacity: .45; cursor: default; }
.ie-btn-ghost { background: #fff; color: var(--text); border: 1px solid #eae0d6; }
.ie-btn:active { transform: translateY(1px); }
.ie-full { width: 100%; margin-top: 10px; }

/* ---------- 主体 ---------- */
.ie-main { display: flex; flex-direction: column; gap: 10px; }

/* ---------- 画布区 ---------- */
.ie-stage {
  position: relative;                 /* ⚠️ absolute 子元素（canvas/空态/缩放条）必须有定位祖先 */
  height: 52vh; min-height: 260px;
  border-radius: 16px; overflow: hidden;
  background:
    linear-gradient(45deg, #f3f3f5 25%, transparent 25%, transparent 75%, #f3f3f5 75%) 0 0 / 18px 18px,
    linear-gradient(45deg, #f3f3f5 25%, transparent 25%, transparent 75%, #f3f3f5 75%) 9px 9px / 18px 18px,
    #fafafa;
  border: 1px solid #eee6dd;
  touch-action: none;                 /* 拖图层/涂抹时不要触发页面滚动 */
}
.ie-stage canvas { position: absolute; left: 0; top: 0; display: block; }
.ie-maskcvs { pointer-events: none; }  /* 涂抹层只负责显示，事件由主画布收 */

.ie-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; padding: 20px; text-align: center;
}
.ie-empty-t { font-size: 15.5px; font-weight: 800; }
.ie-empty-s { font-size: 12.5px; color: var(--text2); }
.ie-empty-x { font-size: 11.5px; color: var(--text2); margin-top: 4px; }
.ie-open {
  display: inline-block; margin-top: 6px; cursor: pointer;
  font-size: 14px; font-weight: 700; padding: 11px 22px; border-radius: 999px;
  background: linear-gradient(135deg, #14b8a6, #0f766e); color: #fff;
}
.ie-open-sm { padding: 9px 16px; font-size: 13px; margin-top: 0; }
.ie-open:active { transform: translateY(1px); }

.ie-zoombar {
  position: absolute; right: 10px; bottom: 10px;
  display: flex; align-items: center; gap: 2px;
  background: rgba(255, 255, 255, .94); border: 1px solid #eae0d6;
  border-radius: 999px; padding: 3px 5px; box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}
.ie-zbtn {
  min-width: 26px; height: 26px; border: none; background: transparent; cursor: pointer;
  font-size: 14px; color: var(--text); border-radius: 999px; font-family: inherit;
}
.ie-zbtn:active { background: #f3ece5; }
.ie-zval { font-size: 11.5px; color: var(--text2); min-width: 38px; text-align: center; }
.ie-zfit { width: auto; padding: 0 8px; font-size: 11.5px; }

.ie-busy {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  gap: 10px; background: rgba(255, 255, 255, .82); font-size: 13.5px; font-weight: 700;
}
.ie-spin {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #d8cfc4; border-top-color: #0f766e;
  animation: ie-spin .8s linear infinite;
}
@keyframes ie-spin { to { transform: rotate(360deg); } }

/* ---------- 工具栏（手机：横向滚动） ---------- */
.ie-tools {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.ie-tools::-webkit-scrollbar { display: none; }
.ie-tool {
  flex: 0 0 auto; width: 60px; padding: 8px 2px; border-radius: 14px; cursor: pointer;
  border: 1px solid #eee6dd; background: #fff; color: var(--text2);
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-family: inherit;
}
.ie-tool i { font-size: 17px; font-style: normal; line-height: 1; }
.ie-tool span { font-size: 11px; font-weight: 600; }
.ie-tool.on { background: #eefaf8; border-color: #8fd9cd; color: #0f766e; }
.ie-tool.on span { color: #0f766e; }

/* ---------- 面板 ---------- */
.ie-panel {
  border: 1px solid #eee6dd; border-radius: 16px; background: #fff;
  padding: 12px 13px; max-height: 46vh; overflow-y: auto;
}
.ie-phd { font-size: 14px; font-weight: 800; margin-bottom: 8px; }
.ie-ph { font-size: 13px; color: var(--text2); padding: 8px 2px; }
.ie-target { font-size: 12px; color: var(--text2); margin-bottom: 8px; }
.ie-sec { margin-top: 12px; }
.ie-sec:first-of-type { margin-top: 0; }
.ie-lab { font-size: 12.5px; font-weight: 700; margin-bottom: 6px; display: flex; justify-content: space-between; }
.ie-lab b { color: #0f766e; font-weight: 800; }
.ie-rng { width: 100%; accent-color: #0f766e; }
.ie-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.ie-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ie-chip {
  border: 1px solid #eee6dd; background: #fff; color: var(--text); cursor: pointer;
  font-size: 12.5px; font-weight: 600; padding: 8px 11px; border-radius: 10px; font-family: inherit;
}
.ie-chip.on { background: #eefaf8; border-color: #8fd9cd; color: #0f766e; }
.ie-chip:active { transform: translateY(1px); }
.ie-ta, .ie-inp {
  width: 100%; box-sizing: border-box; border: 1px solid #eee6dd; border-radius: 10px;
  padding: 9px 10px; font-size: 13px; font-family: inherit; resize: vertical;
  background: #fffdfb; color: var(--text);
}
.ie-inp { margin-bottom: 6px; }
.ie-note { font-size: 11.5px; line-height: 1.7; color: var(--text2); margin-top: 9px; }
.ie-hint { font-size: 11.5px; color: #0f766e; margin-top: 5px; }
/* 面板底部的关键动作条（裁剪的「应用/取消」）。
   窄屏 .ie-panel 是 max-height:46vh 且内部可滚 —— 按钮跟着内容滚出去，用户就找不到「应用」。
   钉在面板底部 + 上缘渐隐，既始终可见又不生硬切断内容。 */
.ie-sticky {
  position: sticky; bottom: -12px;
  margin: 2px -13px -12px; padding: 12px 13px 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 40%);
}
.ie-dims { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.ie-num {
  width: 74px; box-sizing: border-box; border: 1px solid #eee6dd; border-radius: 8px;
  padding: 6px 8px; font-size: 13px; font-family: inherit; text-align: center;
}
.ie-swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.ie-sw {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: 2px solid #eae0d6; padding: 0;
}
.ie-sw.on { border-color: #0f766e; box-shadow: 0 0 0 2px rgba(15, 118, 110, .18); }

/* 滤镜缩略图 */
.ie-filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ie-filter {
  border: 1px solid #eee6dd; border-radius: 12px; background: #fff; cursor: pointer;
  padding: 5px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: inherit;
}
.ie-filter-prev {
  width: 100%; aspect-ratio: 1; border-radius: 8px; background-size: cover; background-position: center;
  background-color: #f3f3f5;
}
.ie-filter-n { font-size: 11px; color: var(--text2); }
.ie-filter.on { border-color: #8fd9cd; background: #eefaf8; }

/* ---------- 底部图层面板 ---------- */
.ie-layerbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 10px; padding: 9px 10px; border-radius: 14px;
  background: #fffdfb; border: 1px dashed #eee6dd; min-height: 20px;
}
.ie-lb-t { font-size: 11.5px; color: var(--text2); font-weight: 700; }
.ie-lb-empty { font-size: 11.5px; color: var(--text2); }
.ie-lb {
  border: 1px solid #eee6dd; background: #fff; cursor: pointer; font-family: inherit;
  font-size: 12px; padding: 5px 9px; border-radius: 999px; color: var(--text);
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ie-lb.on { background: #eefaf8; border-color: #8fd9cd; color: #0f766e; font-weight: 700; }
.ie-lb b { color: var(--text2); font-weight: 700; margin-right: 2px; }
.ie-lb-ops { display: flex; gap: 4px; margin-left: auto; }
.ie-lbs {
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
  border: 1px solid #eee6dd; background: #fff; color: var(--text); font-size: 13px; font-family: inherit;
}
.ie-lbs-del { color: #b91c1c; border-color: #f2d6d6; }

/* ---------- toast ---------- */
.ie-toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 10px);
  max-width: 82vw; padding: 10px 16px; border-radius: 12px;
  background: rgba(28, 25, 23, .93); color: #fff; font-size: 13px; line-height: 1.6;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
  z-index: 60;
}
.ie-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================================
 * 桌面（≥900px）：横排 —— 左图标栏 / 画布 / 右参数面板（与参考产品一致）
 * ========================================================================== */
@media (min-width: 900px) {
  .ie-main { flex-direction: row; align-items: stretch; }
  .ie-tools { flex-direction: column; overflow: visible; width: 72px; flex: 0 0 72px; }
  .ie-tool { width: 100%; }
  .ie-stage { flex: 1; height: 66vh; min-height: 420px; }
  .ie-panel { width: 300px; flex: 0 0 300px; max-height: none; }
  .ie-filters { grid-template-columns: repeat(4, 1fr); }
}

/* 图标底色（与编辑器主题同族的青玉色；新功能自己带，不去改 style.css） */
.f-teal { background: linear-gradient(135deg, #2dd4bf 0%, #0f766e 100%); }

/* ============================================================================
 * v2 新增：贴纸 / 导出弹窗 / 色点 / 小号打开按钮
 *   （对标后补的能力：打码、画笔、标注形状、文字排版、特效、导出格式）
 * ========================================================================== */

/* ---------- 贴纸：emoji 网格 ---------- */
.ie-stickers {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px;
}
.ie-sticker {
  aspect-ratio: 1; border: 1px solid #eee6dd; border-radius: 10px; background: #fff;
  cursor: pointer; font-size: 19px; line-height: 1; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.ie-sticker:active { transform: scale(.92); background: #eefaf8; }

/* ---------- 色点（用在 chip 里表示颜色，比整块色块更省地方）---------- */
.ie-dot {
  display: inline-block; width: 15px; height: 15px; border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .14); vertical-align: -2px;
}
.ie-chip:disabled { opacity: .42; cursor: default; }
.ie-open-sm { font-size: 12.5px; padding: 8px 16px; margin-top: 0; }

/* ---------- 导出弹窗 ---------- */
#sub-imgeditor .ie-modal {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(20, 18, 16, .42);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
#sub-imgeditor .ie-modal-b {
  width: 100%; max-width: 420px; max-height: 84vh; overflow-y: auto;
  background: #fff; border-radius: 18px; padding: 16px 16px 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .26);
}
#sub-imgeditor .ie-modal-t { font-size: 15.5px; font-weight: 800; margin-bottom: 10px; }
#sub-imgeditor .ie-modal-f { display: flex; gap: 10px; margin-top: 16px; }
#sub-imgeditor .ie-modal-f .ie-btn { flex: 1; }
