/* ══════════════════════════════════════════════════════════════
   FadeBG 图片编辑器 —— 内嵌在首页结果区下方的编辑工作台。
   只作用于 #editorSection 内部（全部 .ed-* 前缀），不影响站点其它区块。
   ══════════════════════════════════════════════════════════════ */

/* 关键：本文件多处用 display:flex/inline-block，会覆盖 HTML 的 hidden 属性
   （hidden 只是浏览器默认 display:none，作者样式优先级更高）。没有这条，
   加载遮罩 / 胶片条 / 画布容器的 hidden 会失效，导致「处理中」一直盖住画布。 */
[hidden] { display: none !important; }

/* 顶部导航是 sticky（约 62px），滚动定位时要把这段让出来，否则工具栏会被压住 */
.editor-section { scroll-margin-top: 78px; }

.editor-shell {
  background: #14161d;
  border: 1px solid #262a36;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(20, 22, 29, 0.28);
  overflow: hidden;
  color: #e8eaf2;
}

/* ── 顶部工具栏 ───────────────────────────────────────────── */
.ed-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #262a36;
  background: #1b1e27;
  flex-wrap: wrap;
}
.ed-tools { display: flex; gap: 4px; flex-wrap: wrap; }
.ed-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #a9aec2;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.ed-tool:hover { background: #262a36; color: #e8eaf2; }
.ed-tool.active { background: #2d2440; color: #c9a7ff; }
.ed-ico { font-size: 15px; line-height: 1; }
.ed-actions { display: flex; align-items: center; gap: 8px; }
.ed-icon-btn {
  width: 36px; height: 36px;
  border: 1px solid #343847;
  border-radius: 10px;
  background: #20242e;
  color: #d7dae6;
  font-size: 18px;
  cursor: pointer;
}
.ed-icon-btn:hover:not(:disabled) { background: #2b2f3c; }
.ed-icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.ed-close { font-size: 15px; margin-left: 2px; }
.ed-download {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(118deg, #d61f7a 0%, #8b2fe0 54%, #5b21b6 100%);
  color: #fff;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
}
.ed-download:hover:not(:disabled) { filter: brightness(1.08); }
.ed-download:disabled { opacity: .4; cursor: not-allowed; }
.ed-dl-caret { font-size: 11px; opacity: .85; }

/* ── 工具选项面板 ─────────────────────────────────────────── */
.ed-panel { border-bottom: 1px solid #262a36; background: #191c24; }
.ed-panel-body { padding: 14px 18px; }
.ed-panel-tip { margin: 0 0 10px; color: #a9aec2; font-size: 13px; }
.ed-hint { margin: 8px 0 0; color: #7f859b; font-size: 12px; }
.ed-primary {
  padding: 9px 18px;
  border: 0; border-radius: 9px;
  background: linear-gradient(118deg, #d61f7a, #8b2fe0);
  color: #fff; font-weight: 700; font-size: 13px;
  cursor: pointer;
}
.ed-primary:hover:not(:disabled) { filter: brightness(1.08); }
.ed-primary:disabled { opacity: .4; cursor: not-allowed; }
.ed-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ed-row-sm { margin-top: 14px; }
.ed-sep { width: 1px; height: 26px; background: #343847; margin: 0 4px; }
.ed-group-label { color: #8e94a9; font-size: 12px; font-weight: 600; }

/* 背景色块 */
.ed-swatch {
  width: 38px; height: 38px;
  border: 2px solid #3a3f4f;
  border-radius: 9px;
  cursor: pointer;
  padding: 0;
  position: relative;
  overflow: hidden;
}
.ed-swatch.active { border-color: #b98cff; box-shadow: 0 0 0 2px rgba(185,140,255,.35); }
.ed-checker, .ed-rainbow { display: block; width: 100%; height: 100%; }
.ed-checker {
  background-color: #fff;
  background-image: linear-gradient(45deg,#cfd6de 25%,transparent 25%),linear-gradient(-45deg,#cfd6de 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#cfd6de 75%),linear-gradient(-45deg,transparent 75%,#cfd6de 75%);
  background-size: 12px 12px;
  background-position: 0 0,0 6px,6px -6px,-6px 0;
}
.ed-rainbow { background: conic-gradient(#f44,#fc4,#4c4,#4cf,#44f,#c4f,#f44); }
.ed-color-wrap { width: 38px; height: 38px; border: 2px solid #3a3f4f; border-radius: 9px; overflow: hidden; cursor: pointer; }
.ed-color-wrap input { width: 100%; height: 100%; border: 0; padding: 0; cursor: pointer; background: none; }
.ed-scenes { display: flex; gap: 6px; flex-wrap: wrap; }
.ed-scene {
  width: 44px; height: 38px;
  border: 2px solid #3a3f4f; border-radius: 8px;
  background-size: cover; background-position: center;
  cursor: pointer; padding: 0;
}
.ed-scene.active { border-color: #b98cff; box-shadow: 0 0 0 2px rgba(185,140,255,.35); }

/* 调整滑块 */
.ed-sliders { display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap: 12px 22px; }
.ed-field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: #b9bece; }
.ed-field > span { display: flex; justify-content: space-between; }
.ed-field em { font-style: normal; color: #8e94a9; }
.ed-field input[type=range] { width: 100%; accent-color: #a855f7; }
.ed-field-inline { flex-direction: row; align-items: center; gap: 12px; margin-top: 14px; max-width: 420px; }
.ed-field-inline > span { white-space: nowrap; }
.ed-mini {
  padding: 8px 12px;
  border: 1px solid #343847; border-radius: 9px;
  background: #20242e; color: #d7dae6;
  font-size: 12px; cursor: pointer;
}
.ed-mini:hover { background: #2b2f3c; }
.ed-text-input {
  flex: 1; min-width: 160px;
  padding: 9px 12px; border: 1px solid #343847; border-radius: 9px;
  background: #101218; color: #e8eaf2; font-size: 14px;
}
.ed-text-input::placeholder { color: #6c7186; }
.editor-shell input[type=color] { width: 40px; height: 38px; border: 1px solid #343847; border-radius: 9px; padding: 2px; background: #20242e; cursor: pointer; }

/* ── 魔力笔刷（抠图面板） ─────────────────────────────────── */
.ed-brush { display: flex; flex-direction: column; gap: 10px; max-width: 560px; }
/* 功能卡：左边一张「刷过就露出棋盘格」的小示意图，右边标题与说明 */
.ed-brush-card { display: flex; align-items: center; gap: 12px; }
.ed-brush-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 56px; height: 56px;
  border-radius: 11px;
  overflow: hidden;
  background: repeating-conic-gradient(#dfe3ea 0 25%, #fff 0 50%) 0 0 / 12px 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
}
.ed-brush-thumb::before {
  content: '';
  position: absolute;
  inset: -12px 10px -8px -10px;
  border-radius: 52% 44% 56% 46%;
  background: radial-gradient(circle at 38% 32%, #ffd9a8, #e08a5b 58%, #a9553a 100%);
}
.ed-thumb-hole {
  position: absolute;
  right: 5px; top: 6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: repeating-conic-gradient(#dfe3ea 0 25%, #fff 0 50%) 0 0 / 8px 8px;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .16);
}
.ed-thumb-dot {
  position: absolute;
  left: 9px; bottom: 6px;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: rgba(233, 42, 112, .42);
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .32);
}
.ed-brush-copy b { display: block; font-size: 14px; color: #e8eaf2; }
.ed-brush-copy p { margin: 3px 0 0; font-size: 12px; color: #8e94a9; }

.ed-brush-modes { display: flex; gap: 10px; }
.ed-bmode {
  flex: 1 1 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 8px;
  border: 2px solid #3a3f4f;
  border-radius: 12px;
  background: #20242e;
  color: #c3c8d8;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.ed-bmode:hover { border-color: #4c5266; color: #e8eaf2; }
.ed-bmode.active { border-color: #b98cff; background: #2a2340; color: #e8d7ff; }
.ed-bmode-ico { font-size: 20px; line-height: 1; }

.ed-brush-size { max-width: 380px; }
.ed-brush-size span { font-size: 12px; color: #b9bece; }
.ed-brush-size input[type=range] { width: 100%; accent-color: #a855f7; }

/* 开关 */
.ed-switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.ed-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.ed-switch-track {
  flex: 0 0 auto;
  position: relative;
  width: 42px; height: 24px;
  border-radius: 999px;
  background: #3a3f4f;
  transition: background .18s;
}
.ed-switch-track i {
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s;
}
.ed-switch input:checked + .ed-switch-track { background: linear-gradient(118deg, #d61f7a, #8b2fe0); }
.ed-switch input:checked + .ed-switch-track i { transform: translateX(18px); }
.ed-switch input:focus-visible + .ed-switch-track { box-shadow: 0 0 0 3px rgba(185,140,255,.45); }
.ed-switch-label { font-size: 13px; font-weight: 600; color: #e8eaf2; }

.ed-divider { height: 1px; background: #2c3140; margin: 12px 0; }
.ed-cutout-row { gap: 14px; }
.ed-cutout-row .ed-hint { margin: 0; }

/* 画布上的笔刷光标：半透明实心圆盘 + 白色描边，浅色棋盘格和深色画面上都一眼可见 */
.ed-canvas-wrap.edit-brush #edCanvas { cursor: none; touch-action: none; }
.ed-brush-cursor {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 4;
  background: rgba(233, 42, 112, .44);
  border: 2px solid rgba(255, 255, 255, .95);
  box-shadow:
    0 0 0 1.5px rgba(0, 0, 0, .6),
    0 0 0 3.5px rgba(255, 255, 255, .3),
    0 0 18px rgba(233, 42, 112, .45);
}
.ed-brush-cursor::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 4px; height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .55);
}

/* 放大镜：跟随光标，3 倍放大笔刷附近的画面 */
.ed-loupe {
  position: absolute;
  width: 136px; height: 136px;
  border-radius: 50%;
  overflow: hidden;
  pointer-events: none;
  z-index: 5;
  border: 2px solid rgba(255, 255, 255, .88);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(0, 0, 0, .45);
  background: #0f1116;
}
.ed-loupe canvas { display: block; width: 100%; height: 100%; }

/* 画布工具（缩放 / 放大镜 / 按住看原图）：放在底部状态栏右侧，
   不遮挡画面，位置也永远固定 */
.ed-status-right { display: flex; align-items: center; gap: 12px; }
.ed-canvas-tools { display: flex; align-items: center; gap: 2px; }
.ed-ct-btn {
  height: 24px;
  min-width: 24px;
  padding: 0 8px;
  border: 1px solid #343a49;
  border-radius: 6px;
  background: #22262f;
  color: #cfd4e2;
  font-size: 12px; line-height: 1;
  cursor: pointer;
}
.ed-ct-btn:hover { background: #2c313d; color: #fff; }
.ed-ct-btn[aria-pressed="true"] {
  background: rgba(139, 47, 224, .32);
  border-color: rgba(139, 47, 224, .65);
  color: #fff;
}
.ed-ct-zoom {
  min-width: 42px;
  text-align: center;
  font-size: 11px;
  color: #9aa0b4;
  font-variant-numeric: tabular-nums;
}
.ed-ct-sep { width: 1px; height: 16px; background: #343a49; margin: 0 5px; }

/* 缩放后不再受容器宽度约束，交给 .ed-stage 滚动 */
#edCanvas.ed-zoomed { max-width: none; }
.ed-canvas-wrap.zoomed { max-width: none; }
.ed-stage.zoomed { align-items: flex-start; justify-content: flex-start; }

/* 滤镜 */
.ed-filters { display: flex; gap: 10px; flex-wrap: wrap; }
.ed-filter {
  width: 84px; padding: 0 0 6px;
  border: 2px solid transparent; border-radius: 10px;
  background: #20242e; color: #c3c8d8;
  font-size: 12px; cursor: pointer; overflow: hidden;
}
.ed-filter.active { border-color: #b98cff; color: #e8d7ff; }
.ed-filter canvas { display: block; width: 100%; height: 54px; object-fit: cover; }
.ed-filter span { display: block; padding-top: 4px; }

/* ── 画布区 ───────────────────────────────────────────────── */
.ed-stage {
  position: relative;
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  background:
    radial-gradient(700px 400px at 50% 30%, rgba(124,58,237,.08), transparent 70%),
    #0f1116;
  overflow: auto;
}
.ed-dropzone { width: 100%; }
.ed-drop-inner {
  border: 2px dashed #3a3f4f;
  border-radius: 16px;
  padding: 64px 20px;
  text-align: center;
  color: #b9bece;
  transition: border-color .15s, background .15s;
}
.ed-dropzone.dragover .ed-drop-inner { border-color: #b98cff; background: rgba(185,140,255,.06); }
.ed-drop-ico {
  width: 58px; height: 58px; margin: 0 auto 14px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(118deg,#d61f7a,#8b2fe0);
  color: #fff; font-size: 32px; font-weight: 300;
}
.ed-drop-inner h2 { margin: 0 0 6px; font-size: 19px; color: #e8eaf2; }
.ed-drop-inner p { margin: 4px 0; font-size: 13px; }
.ed-link { border: 0; background: none; color: #c9a7ff; font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; }
.ed-muted { color: #6c7186; font-size: 12px !important; }
.ed-canvas-wrap {
  position: relative;
  max-width: 100%;
  display: inline-block;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,.45);
}
#edCanvas { display: block; max-width: 100%; height: auto; border-radius: 10px; }
.ed-busy {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: rgba(15,17,22,.72);
  border-radius: 10px;
  font-size: 14px; color: #e8eaf2;
}
.ed-spinner {
  width: 20px; height: 20px;
  border: 3px solid rgba(185,140,255,.3);
  border-top-color: #b98cff;
  border-radius: 50%;
  animation: edspin .8s linear infinite;
}
@keyframes edspin { to { transform: rotate(360deg); } }

/* ── 状态栏 ───────────────────────────────────────────────── */
.ed-statusbar {
  display: flex; justify-content: space-between;
  padding: 9px 18px;
  border-top: 1px solid #262a36;
  background: #1b1e27;
  color: #9aa0b4; font-size: 12px;
}

/* ── 胶片条 ───────────────────────────────────────────────── */
.ed-filmstrip {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid #262a36;
  background: #191c24;
  overflow-x: auto;
}
.ed-film-add {
  flex: 0 0 auto;
  width: 58px; height: 58px;
  border: 1px dashed #4a4f61; border-radius: 10px;
  background: transparent; color: #8e94a9;
  font-size: 26px; cursor: pointer;
}
.ed-film-add:hover { border-color: #b98cff; color: #c9a7ff; }
.ed-film-items { display: flex; gap: 10px; flex: 0 0 auto; }
.ed-film-item {
  position: relative;
  flex: 0 0 auto;
  width: 58px; height: 58px;
  border: 2px solid #3a3f4f; border-radius: 10px;
  overflow: hidden; cursor: pointer; padding: 0;
  background: #101218;
}
.ed-film-item.active { border-color: #b98cff; box-shadow: 0 0 0 2px rgba(185,140,255,.4); }
.ed-film-item canvas { width: 100%; height: 100%; display: block; }
.ed-film-item .ed-film-badge {
  position: absolute; right: 2px; bottom: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #2f3542; font-size: 9px; color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.ed-film-item.done .ed-film-badge { background: #16a34a; }
.ed-film-item.err .ed-film-badge { background: #dc2626; }
.ed-film-remove {
  position: absolute; right: 1px; top: 1px;
  width: 16px; height: 16px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.6); color: #fff;
  font-size: 11px; line-height: 1; cursor: pointer;
  display: none;
}
.ed-film-item:hover .ed-film-remove { display: block; }

/* ── 下载菜单 ─────────────────────────────────────────────── */
.ed-menu {
  position: fixed;
  background: #20242e;
  border: 1px solid #3a3f4f;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  padding: 6px;
  z-index: 50;
  min-width: 180px;
}
.ed-menu button {
  display: block; width: 100%;
  padding: 9px 12px; border: 0; border-radius: 7px;
  background: transparent; color: #e8eaf2;
  font-size: 13px; text-align: left; cursor: pointer;
}
.ed-menu button:hover { background: #2d2440; }

.ed-footer-note {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 14px;
  color: var(--muted); font-size: 12px;
}
.ed-footer-note a { color: var(--accent); }

/* ── 响应式 ───────────────────────────────────────────────── */
@media (max-width: 700px) {
  .ed-toolbar { padding: 8px; }
  .ed-tool { padding: 7px 9px; font-size: 12px; }
  .ed-tool .ed-ico { display: none; }
  .ed-stage { min-height: 320px; padding: 14px; }
  .ed-drop-inner { padding: 44px 14px; }
  .ed-panel-body { padding: 12px; }
  .ed-footer-note { flex-direction: column; }
}
