/* ============================================================
   图片编辑工作台 — 四种工具的样式
   局部重绘（涂抹）/ 去水印（涂抹）/ 批注修改（箭头圈文字）/ 多图融合
   ============================================================ */

/* ---------------- 顶部工具切换 ---------------- */
.tool-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid var(--line-200);
  background: var(--canvas-50);
  padding: 0.375rem;
  gap: 0.25rem;
}

.tool-tab {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 2.25rem;
  padding: 0 0.625rem;
  border-radius: 0.4375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-600);
  transition: background 0.16s, color 0.16s;
}

.tool-tab:hover {
  background: var(--white);
}

.tool-tab[data-active='true'] {
  background: var(--white);
  color: var(--brand-800);
  box-shadow: var(--shadow-control), inset 0 0 0 1px var(--brand-100);
}

.tool-tab__num {
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--ink-400);
}

.tool-tab[data-active='true'] .tool-tab__num {
  color: var(--brand-600);
}

.tool-desc {
  margin: 0;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  background: var(--canvas-50);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--ink-500);
}

/* ---------------- 编辑画布 ---------------- */
.preview-canvas--dark {
  background: #f7f8f9;
}

.preview-empty--dark {
  border-color: #e5e5e5;
  background: var(--white);
  color: #a1a1a1;
}

.preview-empty__tags {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.mini-tag {
  padding: 0.1875rem 0.5rem;
  border: 1px solid var(--line-200);
  border-radius: 999px;
  background: var(--canvas-50);
  font-size: 0.625rem;
  color: var(--ink-500);
}

.edit-stage {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow: auto;
}

.edit-stage[hidden] {
  display: none;
}

.edit-stage__inner {
  position: relative;
  display: inline-block;
  max-width: 100%;
  max-height: 100%;
  line-height: 0;
  box-shadow: 0 16px 40px rgba(18, 30, 28, 0.14);
  border-radius: 0.5rem;
  overflow: hidden;
  touch-action: none;
}

.edit-stage__img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

.edit-stage__paint {
  position: absolute;
  inset: 0;
  /* 画布内部尺寸 = 原图分辨率，这里只负责铺满图片区域；
     用 100% 宽高 + 与 img 同比例的容器，缩放时自动对齐 */
  width: 100%;
  height: 100%;
  cursor: crosshair;
  /* touch-action 不会从父元素继承，必须直接写在画布上，
     否则手机涂抹会被浏览器当成页面滚动，pointermove 中途被取消 */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.edit-stage__inner[data-tool='annotate'] .edit-stage__paint {
  cursor: crosshair;
}

/* ---------------- 画笔大小 ---------------- */
.brush-size {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.brush-size[hidden] {
  display: none;
}

.brush-size .btn-secondary {
  min-height: 1.875rem;
  padding: 0 0.5rem;
  font-size: 0.8125rem;
  line-height: 1;
}

.brush-size__val {
  min-width: 1.75rem;
  text-align: center;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-600);
}

/* ---------------- 批注工具条 ---------------- */
.annotate-bar {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.625rem 1rem;
  border-top: 1px solid var(--line-200);
  background: var(--canvas-50);
  flex-wrap: wrap;
}

.annotate-bar[hidden] {
  display: none;
}

.annotate-tool {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  height: 2rem;
  padding: 0 0.625rem;
  border: 1px solid var(--line-200);
  border-radius: 0.4375rem;
  background: var(--white);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-600);
  transition: border-color 0.16s, color 0.16s;
}

.annotate-tool svg {
  width: 14px;
  height: 14px;
}

.annotate-tool:hover {
  border-color: var(--brand-600);
  color: var(--brand-700);
}

.annotate-tool[data-active='true'] {
  border-color: var(--brand-600);
  background: var(--brand-50);
  color: var(--brand-800);
}

.annotate-bar__hint {
  margin-left: auto;
  font-size: 0.6875rem;
  color: var(--ink-400);
}

/* ---------------- 短文本框 ---------------- */
.prompt-area--sm {
  min-height: 5.5rem;
}

@media (max-width: 767px) {
  .tool-tabs {
    grid-template-columns: 1fr;
  }
  .edit-stage {
    padding: 0.75rem;
  }
}

/* 缩略图加载失败的兜底样式：不要显示浏览器默认的裂图标 */
.ref-thumb.is-broken {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--canvas-100);
  border-style: dashed;
}

.ref-thumb.is-broken img {
  display: none;
}

.ref-thumb.is-broken::after {
  content: '已载入';
  font-size: 0.5625rem;
  color: var(--ink-500);
  text-align: center;
  line-height: 1.2;
}


/* 加载遮罩不能把底图糊成一片白：原来是 0.86 白 + 模糊，手机上看着像图片丢了。
   改成只在顶部一条窄提示，画布保持可见 */
.preview-canvas .preview-loading {
  inset: auto 0 0 0;
  flex-direction: row;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: rgba(16, 18, 23, 0.86);
  backdrop-filter: none;
  color: #fff;
  font-size: 0.75rem;
  border-radius: 0 0 0.5rem 0.5rem;
}

.preview-canvas .preview-loading .spinner {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
}
