/* ===== 遮罩编辑器 (Mask Editor) ===== */
/* 基于 gpt_image_playground 的 MaskEditorModal 适配 */

/* 编辑预览项中的编辑操作按钮（铅笔图标） */
.edit-preview-item { position: relative; }
.edit-preview-item .edit-mask-button {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: #fff;
  background: rgba(59, 130, 246, 85%);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background-color 0.15s, transform 0.15s;
}
.edit-preview-item .edit-mask-button svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.edit-preview-item:hover .edit-mask-button { opacity: 1; }
.edit-preview-item:hover .edit-mask-button:hover { background: rgba(59, 130, 246, 100%); transform: scale(1.05); }
.edit-preview-item .edit-mask-button.has-mask {
  opacity: 1;
  background: rgba(37, 99, 235, 95%);
}
.edit-preview-item .edit-mask-button.has-mask::after {
  content: '';
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  background: #4ade80;
  border-radius: 50%;
  border: 1.5px solid #fff;
}

/* 遮罩编辑器弹窗遮罩层 */
.mask-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  background: #f5f5f5;
  animation: maskEditorIn 0.2s ease-out;
}
[data-theme="dark"] .mask-editor-overlay,
html[data-theme="dark"] .mask-editor-overlay { background: #111827; }

@keyframes maskEditorIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* 头部 */
.mask-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  z-index: 10;
}
[data-theme="dark"] .mask-editor-header,
html[data-theme="dark"] .mask-editor-header {
  background: #0a0a0a;
  border-bottom-color: rgba(255,255,255,0.08);
}
.mask-editor-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mask-editor-header-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
[data-theme="dark"] .mask-editor-header-title,
html[data-theme="dark"] .mask-editor-header-title { color: #e5e7eb; }
.mask-editor-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 按钮基础样式 */
.me-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.me-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.me-btn-icon {
  padding: 6px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}
.me-btn-icon:hover { background: var(--surface-soft); color: var(--text); }
[data-theme="dark"] .me-btn-icon:hover,
html[data-theme="dark"] .me-btn-icon:hover { background: rgba(255,255,255,0.08); }

.me-btn-primary {
  background: #3b82f6;
  color: #fff;
}
.me-btn-primary:hover:not(:disabled) { background: #2563eb; }
.me-btn-danger {
  background: #ef4444;
  color: #fff;
}
.me-btn-danger:hover:not(:disabled) { background: #dc2626; }

/* 工作区 */
.mask-editor-workspace {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: transparent;
  padding: 20px;
  box-sizing: border-box;
}

/* 加载状态 */
.mask-editor-loading {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(4px);
  font-size: 14px;
  color: var(--muted);
}
[data-theme="dark"] .mask-editor-loading,
html[data-theme="dark"] .mask-editor-loading { background: rgba(0,0,0,0.5); }

/* 画布容器 */
.mask-editor-canvas-frame {
  position: relative;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  touch-action: none;
  overflow: hidden;
  background: transparent; /* 无背景色，避免黑边 */
  max-width: 100%;
  max-height: 100%;
}
@media (min-width: 640px) {
  .mask-editor-canvas-frame { box-shadow: 0 4px 24px rgba(0,0,0,0.1); }
}

.mask-editor-canvas-inner {
  position: relative;
  width: 100%;
  height: 100%;
}
.mask-editor-canvas-inner canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
}
.mask-editor-canvas-inner .mask-canvas-draw {
  touch-action: none;
  user-select: none;
  opacity: 0;
  cursor: crosshair;
  z-index: 5;
  pointer-events: auto;
}
.mask-editor-canvas-inner .mask-canvas-draw.is-panning { cursor: grabbing; }
.mask-editor-canvas-inner .mask-canvas-draw.is-alt { cursor: grab; }
.mask-editor-canvas-inner .mask-canvas-preview { pointer-events: none; z-index: 2; }
.mask-editor-cursor-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 10;
}

/* 底部工具栏 */
.mask-editor-toolbar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  white-space: nowrap;
  max-width: calc(100vw - 16px);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 640px) {
  .mask-editor-toolbar {
    bottom: 24px;
    padding: 8px 16px;
    border-radius: 20px;
    gap: 12px;
  }
}
@media (max-width: 639px) {
  .mask-editor-toolbar {
    gap: 4px;
    padding: 5px 10px;
    border-radius: 12px;
  }
  .mask-editor-toolbar .me-brush-size-btn {
    width: 30px;
    height: 30px;
    font-size: 11px;
    border-radius: 8px;
  }
  .mask-editor-toolbar .me-tool-btn {
    width: 28px;
    height: 28px;
  }
  .mask-editor-toolbar .me-tool-btn svg { width: 15px; height: 15px; }
  .mask-editor-toolbar .me-action-btn {
    width: 26px;
    height: 26px;
  }
  .mask-editor-toolbar .me-action-btn svg { width: 15px; height: 15px; }
}
[data-theme="dark"] .mask-editor-toolbar,
html[data-theme="dark"] .mask-editor-toolbar {
  background: rgba(15,15,15,0.95);
  border-color: rgba(255,255,255,0.06);
}

/* 工具组：画笔/橡皮 + 大小 */
.me-tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
@media (min-width: 640px) { .me-tool-group { gap: 8px; } }

.me-tool-switch {
  display: flex;
  background: rgba(0,0,0,0.06);
  border-radius: 10px;
  padding: 3px;
}
@media (min-width: 640px) { .me-tool-switch { border-radius: 12px; padding: 4px; } }
[data-theme="dark"] .me-tool-switch,
html[data-theme="dark"] .me-tool-switch { background: rgba(255,255,255,0.06); }

.me-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s ease;
}
@media (min-width: 640px) {
  .me-tool-btn { width: 38px; height: 38px; border-radius: 10px; }
}
.me-tool-btn:hover:not(:disabled) {
  color: var(--text);
  background: rgba(0, 0, 0, 0.06);
}
.me-tool-btn:active:not(:disabled) {
  transform: scale(0.94);
  background: rgba(0, 0, 0, 0.1);
}
[data-theme="dark"] .me-tool-btn:hover:not(:disabled),
html[data-theme="dark"] .me-tool-btn:hover:not(:disabled) { background: rgba(255,255,255,0.1); }
[data-theme="dark"] .me-tool-btn:active:not(:disabled),
html[data-theme="dark"] .me-tool-btn:active:not(:disabled) { background: rgba(255,255,255,0.16); }
.me-tool-btn.active {
  background: #eef2ff;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.2), 0 1px 3px rgba(0,0,0,0.08);
  color: #2563eb;
}
.me-tool-btn.active:hover {
  background: #e0e7ff;
}
.me-tool-btn.active:active {
  transform: scale(0.94);
  background: #c7d2fe;
}
[data-theme="dark"] .me-tool-btn.active,
html[data-theme="dark"] .me-tool-btn.active {
  background: rgba(59, 130, 246, 0.18);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.25);
  color: #93c5fd;
}
[data-theme="dark"] .me-tool-btn.active:hover,
html[data-theme="dark"] .me-tool-btn.active:hover { background: rgba(59, 130, 246, 0.26); }
[data-theme="dark"] .me-tool-btn.active:active,
html[data-theme="dark"] .me-tool-btn.active:active { background: rgba(59, 130, 246, 0.32); }
.me-tool-btn svg { width: 18px; height: 18px; }

/* 笔刷大小按钮 */
.me-brush-size-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1.5px solid rgba(0,0,0,0.1);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s ease;
}
@media (min-width: 640px) { .me-brush-size-btn { width: 42px; height: 42px; } }
[data-theme="dark"] .me-brush-size-btn,
html[data-theme="dark"] .me-brush-size-btn {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.1);
  color: #e0e0e0;
}
.me-brush-size-btn:hover:not(:disabled) {
  border-color: #93c5fd;
  background: #f0f6ff;
}
.me-brush-size-btn:active:not(:disabled) {
  transform: scale(0.94);
  background: #dbeafe;
}
[data-theme="dark"] .me-brush-size-btn:hover:not(:disabled),
html[data-theme="dark"] .me-brush-size-btn:hover:not(:disabled) { border-color: #60a5fa; background: rgba(59,130,246,0.12); }
[data-theme="dark"] .me-brush-size-btn:active:not(:disabled),
html[data-theme="dark"] .me-brush-size-btn:active:not(:disabled) { transform: scale(0.94); background: rgba(59,130,246,0.2); }
.me-brush-size-btn.active {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #2563eb;
  font-weight: 700;
}
.me-brush-size-btn.active:hover {
  background: #dbeafe;
  border-color: #2563eb;
}
.me-brush-size-btn.active:active {
  transform: scale(0.94);
  background: #bfdbfe;
}
[data-theme="dark"] .me-brush-size-btn.active,
html[data-theme="dark"] .me-brush-size-btn.active {
  background: rgba(59,130,246,0.2);
  border-color: #60a5fa;
  color: #93c5fd;
}
[data-theme="dark"] .me-brush-size-btn.active:hover,
html[data-theme="dark"] .me-brush-size-btn.active:hover { background: rgba(59,130,246,0.28); }
[data-theme="dark"] .me-brush-size-btn.active:active,
html[data-theme="dark"] .me-brush-size-btn.active:active { transform: scale(0.94); background: rgba(59,130,246,0.35); }

/* 操作组：撤销/重做/重置/清空 */
.me-action-group {
  display: flex;
  align-items: center;
  gap: 2px;
  border-left: 1px solid rgba(0,0,0,0.1);
  padding-left: 8px;
  margin-left: 2px;
}
@media (min-width: 640px) {
  .me-action-group { gap: 6px; padding-left: 12px; margin-left: 4px; }
}
[data-theme="dark"] .me-action-group,
html[data-theme="dark"] .me-action-group { border-left-color: rgba(255,255,255,0.08); }

.me-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s ease;
}
@media (min-width: 640px) { .me-action-btn { width: 36px; height: 36px; border-radius: 10px; } }
.me-action-btn:hover:not(:disabled) { background: rgba(0,0,0,0.06); color: var(--text); }
.me-action-btn:active:not(:disabled) {
  transform: scale(0.94);
  background: rgba(0,0,0,0.1);
}
[data-theme="dark"] .me-action-btn:hover:not(:disabled),
html[data-theme="dark"] .me-action-btn:hover:not(:disabled) { background: rgba(255,255,255,0.1); }
[data-theme="dark"] .me-action-btn:active:not(:disabled),
html[data-theme="dark"] .me-action-btn:active:not(:disabled) { transform: scale(0.94); background: rgba(255,255,255,0.16); }
.me-action-btn:disabled { opacity: 0.3; pointer-events: none; }
.me-action-btn svg { width: 18px; height: 18px; }

.me-action-divider {
  width: 1px;
  height: 18px;
  background: rgba(0,0,0,0.15);
}
@media (min-width: 640px) { .me-action-divider { height: 20px; } }
[data-theme="dark"] .me-action-divider,
html[data-theme="dark"] .me-action-divider { background: rgba(255,255,255,0.12); }

/* 笔刷大小滑块面板 (弹出) */
.mask-editor-size-panel {
  position: fixed;
  z-index: 910;
  width: 52px;
  height: 176px;
  margin-left: -26px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.16);
  display: flex;
  align-items: center;
  justify-content: center;
}
[data-theme="dark"] .mask-editor-size-panel,
html[data-theme="dark"] .mask-editor-size-panel {
  background: #1f2937;
  border-color: #374151;
}
.mask-editor-size-panel input[type="range"] {
  position: absolute;
  width: 128px;
  height: 20px;
  transform: rotate(-90deg);
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: ns-resize;
}
.mask-editor-size-panel input[type="range"]::-webkit-slider-track {
  height: 4px;
  background: rgba(0,0,0,0.1);
  border-radius: 2px;
}
[data-theme="dark"] .mask-editor-size-panel input[type="range"]::-webkit-slider-track,
html[data-theme="dark"] .mask-editor-size-panel input[type="range"]::-webkit-slider-track {
  background: rgba(255,255,255,0.1);
}
.mask-editor-size-panel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: grab;
  margin-top: -7px;
}
.mask-editor-size-panel input[type="range"]::-moz-range-track {
  height: 4px;
  background: rgba(0,0,0,0.1);
  border-radius: 2px;
}
.mask-editor-size-panel input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: grab;
}

/* 提示气泡 */
.mask-info-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  width: 260px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-soft);
  z-index: 30;
}
[data-theme="dark"] .mask-info-popover,
html[data-theme="dark"] .mask-info-popover {
  background: #111827;
  border-color: rgba(255,255,255,0.08);
  color: #9ca3af;
}
.mask-info-popover::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 72px;
  width: 12px;
  height: 12px;
  background: var(--bg);
  border-left: 1px solid rgba(0,0,0,0.1);
  border-top: 1px solid rgba(0,0,0,0.1);
  transform: rotate(45deg);
}
[data-theme="dark"] .mask-info-popover::before,
html[data-theme="dark"] .mask-info-popover::before {
  background: #111827;
  border-color: rgba(255,255,255,0.08);
}

/* ===== 编辑参考图选择弹窗 (Edit Image Action Dialog) ===== */
.edit-image-action-dialog {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}
[data-theme="dark"] .edit-image-action-dialog,
html[data-theme="dark"] .edit-image-action-dialog {
  background: rgba(0, 0, 0, 0.65);
}
.edit-image-action-dialog.hidden { display: none; }

.edit-image-action-panel {
  width: min(380px, calc(100vw - 48px));
  background: var(--bg);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  animation: editActionIn 0.2s ease-out;
}
[data-theme="dark"] .edit-image-action-panel,
html[data-theme="dark"] .edit-image-action-panel {
  background: #1f2937;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

@keyframes editActionIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.edit-image-action-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
}
.edit-image-action-head h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
[data-theme="dark"] .edit-image-action-head h2,
html[data-theme="dark"] .edit-image-action-head h2 { color: #e5e7eb; }

.edit-image-action-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}
.edit-image-action-close svg { width: 16px; height: 16px; }
.edit-image-action-close:hover { background: var(--surface-soft); color: var(--text); }
[data-theme="dark"] .edit-image-action-close:hover,
html[data-theme="dark"] .edit-image-action-close:hover { background: rgba(255, 255, 255, 0.06); }

.edit-image-action-desc {
  margin: 0 20px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-soft);
}
[data-theme="dark"] .edit-image-action-desc,
html[data-theme="dark"] .edit-image-action-desc { color: #9ca3af; }

/* 默认执行选择复选框 */
.edit-image-action-default-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 20px 16px;
  padding: 10px 12px;
  background: var(--surface-soft);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}
[data-theme="dark"] .edit-image-action-default-label,
html[data-theme="dark"] .edit-image-action-default-label {
  background: rgba(255, 255, 255, 0.04);
  color: #9ca3af;
}
.edit-image-action-default-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #3b82f6;
  flex-shrink: 0;
}
.edit-image-action-default-label.hidden { display: none; }

/* 操作按钮组 */
.edit-image-actions {
  display: flex;
  gap: 10px;
  padding: 0 20px 20px;
}
.edit-image-actions button {
  flex: 1;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.edit-image-action-btn-replace {
  background: #f3f4f6;
  color: #374151;
}
.edit-image-action-btn-replace:hover { background: #e5e7eb; }
[data-theme="dark"] .edit-image-action-btn-replace,
html[data-theme="dark"] .edit-image-action-btn-replace {
  background: rgba(55, 65, 81, 0.5);
  color: #d1d5db;
}
[data-theme="dark"] .edit-image-action-btn-replace:hover,
html[data-theme="dark"] .edit-image-action-btn-replace:hover { background: rgba(75, 85, 99, 0.6); }

.edit-image-action-btn-mask {
  background: #3b82f6;
  color: #fff;
}
.edit-image-action-btn-mask:hover { background: #2563eb; }

/* ===== 多区域管理面板 (Region Panel) ===== */
/* 每个区域有独立颜色、独立画布、独立提示词 */

/* 区域列表侧栏 */
.mask-editor-region-sidebar {
  position: absolute;
  top: 56px;
  right: 12px;
  z-index: 25;
  width: 280px;
  max-height: calc(100% - 200px);
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
  overflow: hidden;
}
@media (min-width: 640px) {
  .mask-editor-region-sidebar { right: 24px; }
}
[data-theme="dark"] .mask-editor-region-sidebar,
html[data-theme="dark"] .mask-editor-region-sidebar {
  background: rgba(15, 15, 15, 0.98);
  border-color: rgba(255, 255, 255, 0.06);
}

.mask-editor-region-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--line);
}
.mask-editor-region-head-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
[data-theme="dark"] .mask-editor-region-head-title,
html[data-theme="dark"] .mask-editor-region-head-title { color: #e5e7eb; }
.mask-editor-region-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.mask-editor-region-add-btn:hover { background: rgba(59, 130, 246, 0.2); }
.mask-editor-region-add-btn svg { width: 12px; height: 12px; }

.mask-editor-region-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

/* 单个区域卡片 */
.region-card {
  margin-bottom: 6px;
  padding: 10px;
  background: var(--surface-soft);
  border: 1.5px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.region-card:hover { background: rgba(0, 0, 0, 0.04); }
[data-theme="dark"] .region-card:hover,
html[data-theme="dark"] .region-card:hover { background: rgba(255, 255, 255, 0.04); }
.region-card.active {
  border-color: var(--region-color, #3b82f6);
  background: color-mix(in srgb, var(--region-color, #3b82f6) 8%, transparent);
}
.region-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.region-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--region-color, #3b82f6);
  flex-shrink: 0;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}
.region-name-input {
  flex: 1;
  min-width: 0;
  padding: 3px 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 4px;
  outline: none;
}
.region-name-input:focus { background: var(--bg); }
[data-theme="dark"] .region-name-input:focus,
html[data-theme="dark"] .region-name-input:focus { background: rgba(255, 255, 255, 0.06); }
.region-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}
.region-delete-btn:hover { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.region-delete-btn svg { width: 12px; height: 12px; }

.region-prompt-input {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  resize: vertical;
  min-height: 44px;
  max-height: 100px;
  outline: none;
  font-family: inherit;
}
.region-prompt-input:focus { border-color: var(--region-color, #3b82f6); }
.region-prompt-input::placeholder { color: var(--placeholder); font-size: 11px; }
[data-theme="dark"] .region-prompt-input,
html[data-theme="dark"] .region-prompt-input {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  color: #e5e7eb;
}

.region-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}
.region-meta-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.region-meta-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-light);
}
.region-meta-status.has-mask::before { background: #22c55e; }
.region-meta-status.has-prompt::before { background: #3b82f6; }
.region-meta-status.ready::before { background: #22c55e; }

/* 区域为空时的提示 */
.region-empty {
  padding: 24px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

/* 底部确认按钮文字（多区域模式） */
.mask-editor-confirm-multi {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mask-editor-confirm-multi .count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 9px;
}

/* 处理进度浮层（链式提交时） */
.mask-chain-progress {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
}
.mask-chain-progress-panel {
  width: min(440px, calc(100vw - 48px));
  padding: 24px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
}
[data-theme="dark"] .mask-chain-progress-panel,
html[data-theme="dark"] .mask-chain-progress-panel {
  background: #1f2937;
}
.mask-chain-progress-title {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  margin: 0 0 16px;
}
[data-theme="dark"] .mask-chain-progress-title,
html[data-theme="dark"] .mask-chain-progress-title { color: #e5e7eb; }
.mask-chain-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
}
.mask-chain-step-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  background: #f3f4f6;
  color: #6b7280;
}
[data-theme="dark"] .mask-chain-step-dot,
html[data-theme="dark"] .mask-chain-step-dot {
  background: rgba(255, 255, 255, 0.08);
  color: #9ca3af;
}
.mask-chain-step.processing .mask-chain-step-dot {
  background: #3b82f6;
  color: #fff;
}
.mask-chain-step.done .mask-chain-step-dot {
  background: #22c55e;
  color: #fff;
}
.mask-chain-step.error .mask-chain-step-dot {
  background: #ef4444;
  color: #fff;
}
.mask-chain-step-body { flex: 1; min-width: 0; }
.mask-chain-step-name {
  font-weight: 500;
  color: #111827;
  margin-bottom: 2px;
}
[data-theme="dark"] .mask-chain-step-name,
html[data-theme="dark"] .mask-chain-step-name { color: #e5e7eb; }
.mask-chain-step-prompt {
  font-size: 12px;
  color: #6b7280;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-theme="dark"] .mask-chain-step-prompt,
html[data-theme="dark"] .mask-chain-step-prompt { color: #9ca3af; }
.mask-chain-step-status {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}
.mask-chain-step.processing .mask-chain-step-status { color: #3b82f6; }
.mask-chain-step.done .mask-chain-step-status { color: #22c55e; }
.mask-chain-step.error .mask-chain-step-status { color: #ef4444; }

/* ===== 手机端响应式优化 ===== */
@media (max-width: 768px) {
  /* 头部优化 */
  .mask-editor-header {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .mask-editor-header-title {
    font-size: 13px;
    max-width: calc(100vw - 180px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .me-btn {
    padding: 5px 10px;
    font-size: 12px;
  }
  .me-btn span {
    display: none;
  }
  .me-btn svg {
    width: 16px;
    height: 16px;
  }

  /* 工作区优化 */
  .mask-editor-workspace {
    padding: 10px;
  }

  /* 侧边栏优化 - 移动端改为底部弹出 */
  .mask-editor-region-sidebar {
    position: absolute;
    top: auto;
    bottom: 80px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: 50vh;
    border-radius: 12px;
  }

  /* 工具栏优化 */
  .mask-editor-toolbar {
    bottom: 8px;
    padding: 4px 8px;
    gap: 4px;
    max-width: calc(100vw - 16px);
  }

  /* 画布容器优化 */
  .mask-editor-canvas-frame {
    border-radius: 8px;
  }
}

@media (max-width: 480px) {
  /* 小屏幕进一步优化 */
  .mask-editor-header {
    padding: 8px 10px;
  }
  .mask-editor-header-title {
    font-size: 12px;
    max-width: calc(100vw - 150px);
  }
  .me-btn-icon {
    padding: 4px;
  }
  .me-btn-icon svg {
    width: 16px;
    height: 16px;
  }

  /* 工具栏按钮更小 */
  .mask-editor-toolbar .me-tool-btn {
    width: 26px;
    height: 26px;
  }
  .mask-editor-toolbar .me-tool-btn svg {
    width: 14px;
    height: 14px;
  }
  .mask-editor-toolbar .me-action-btn {
    width: 24px;
    height: 24px;
  }
  .mask-editor-toolbar .me-action-btn svg {
    width: 14px;
    height: 14px;
  }
  .mask-editor-toolbar .me-brush-size-btn {
    width: 28px;
    height: 28px;
    font-size: 10px;
  }

  /* 侧边栏更紧凑 */
  .mask-editor-region-sidebar {
    bottom: 70px;
    max-height: 45vh;
  }
  .mask-editor-region-head {
    padding: 10px 12px 6px;
  }
  .region-card {
    padding: 8px;
    margin-bottom: 4px;
  }
}

