/* ─── 桃子工具 公共 ─── */
.tp-detail {
  max-width: var(--max-w, 1440px);
  margin: 0 auto;
  padding: 32px 24px 60px;
}

.tp-bread {
  font-size: 13px;
  color: var(--slate-400);
  margin-bottom: 16px;
}
.tp-bread a { color: var(--slate-400); text-decoration: none; }
.tp-bread a:hover { color: var(--accent); }
.tp-bread::before { content: "🍑 "; }

.tpd-h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
  line-height: 1.3;
}
.tpd-desc {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 28px;
}

/* ─── Upload Area ─── */
.tpd-upload {
  border: 2px dashed var(--slate-300);
  border-radius: var(--radius-lg);
  padding: 60px 20px;
  text-align: center;
  background: #fafbfc;
  cursor: pointer;
  transition: all 0.2s;
}
.tpd-upload:hover,
.tpd-upload.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}
.tpd-upload-icon { font-size: 48px; margin-bottom: 12px; }
.tpd-upload-text { font-size: 16px; color: var(--text); margin-bottom: 6px; }
.tpd-upload-hint { font-size: 13px; color: var(--text-light); margin-bottom: 16px; }
.tpd-note {
  font-size: 13px;
  color: var(--text-secondary);
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 12px;
  text-align: left;
  line-height: 1.5;
}

.tpd-btn {
  display: inline-block;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s;
  text-decoration: none;
}
.tpd-btn:hover { background: var(--accent-dark); color: #fff; }
.tpd-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.tpd-btn-sm { padding: 6px 14px; font-size: 13px; }
.tpd-btn-warn { background: var(--slate-500); }
.tpd-btn-warn:hover { background: var(--slate-600); }

/* ─── Processing ─── */
.tpd-processing {
  text-align: center;
  padding: 60px 20px;
}
.tpd-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--slate-200);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.tpd-processing-text { font-size: 15px; color: var(--text-secondary); }

/* ─── Split Option Bar ─── */
.tpd-split-option {
  background: #f6f9fc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  margin-bottom: 12px;
}
.tpd-split-option label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #4a5568;
  cursor: pointer;
  user-select: none;
}
.tpd-split-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.tpd-split-option .tpd-split-hint {
  font-size: 12px;
  color: #a0aec0;
  margin-left: 24px;
}

/* ─── Result ─── */
.tpd-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.tpd-result-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tpd-countdown {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding: 8px 12px;
  background: #fff8e1;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.tpd-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.tpd-sortable .tpd-preview-item {
  cursor: grab;
}
.tpd-sortable .tpd-preview-item.dragging {
  opacity: 0.5;
  border-color: var(--accent);
}
.tpd-preview-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.2s;
}
.tpd-preview-item:hover { box-shadow: var(--shadow-sm); }

.tpd-sort-handle {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 14px;
  color: var(--text-light);
  cursor: grab;
  padding: 2px 6px;
  background: rgba(255,255,255,0.85);
  border-radius: 4px;
  z-index: 1;
}
.tpd-preview-img {
  width: 100%;
  height: 160px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
}
.tpd-preview-img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.tpd-preview-name {
  padding: 6px 8px;
  font-size: 11px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tpd-preview-order {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tpd-preview-dl {
  display: block;
  padding: 6px 8px;
  text-align: center;
  background: var(--slate-100);
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
}
.tpd-preview-dl:hover { background: var(--accent); color: #fff; }
.tpd-preview-rm {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,87,34,0.85);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

/* ─── Error ─── */
.tpd-error {
  text-align: center;
  padding: 40px 20px;
}
.tpd-error-icon { font-size: 36px; margin-bottom: 12px; }
.tpd-error-text {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* ─── List page (Index) ─── */
.tools-page {
  max-width: var(--max-w, 1440px);
  margin: 0 auto;
  padding: 32px 24px 60px;
}
.tp-h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}
.tp-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 4px 0 28px;
}

.tp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.tp-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  text-decoration: none;
  transition: box-shadow 0.25s, transform 0.2s, border-color 0.2s;
  position: relative;
}
.tp-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: var(--accent);
}

.tpc-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  overflow: hidden;
  background: var(--slate-100, #f0f0f0);
}
.tpc-icon img { width: 44px; height: 44px; object-fit: contain; }

.tpc-body { flex: 1; min-width: 0; }

.tpc-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  line-height: 1.4;
}

.tpc-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 5px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tpd-body {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text);
  margin-top: 24px;
}
.tpd-body h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--slate-200);
}
.tpd-body h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 24px 0 8px;
}
.tpd-body p {
  margin: 0 0 14px;
}
.tpd-body ul, .tpd-body ol {
  margin: 0 0 14px;
  padding-left: 22px;
}
.tpd-body li {
  margin-bottom: 4px;
}
.tpd-body code {
  background: #f4f4f5;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
  font-family: Consolas, Monaco, 'Courier New', monospace;
}
.tpd-body pre {
  background: #f4f4f5;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
  font-family: Consolas, Monaco, 'Courier New', monospace;
  margin: 0 0 14px;
  border: 1px solid var(--slate-200);
}
.tpd-body a {
  color: var(--accent);
  text-decoration: underline;
}
.tpd-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 8px 0;
}
.tp-pages {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 32px;
}
.tp-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
  transition: all 0.15s;
}
.tp-page:hover,
.tp-page.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tp-empty {
  text-align: center;
  padding: 60px;
  color: var(--text-light);
  font-size: 16px;
}

/* ─── Background Remove 增强 ─── */
/* 透明棋盘格 */
.br-checkerboard {
  background-image:
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

/* 裁剪画布容器 */
.br-crop-container {
  margin: 12px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  user-select: none;
  display: flex;
  justify-content: center;
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}
.br-crop-canvas-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
}
.br-crop-canvas-wrap canvas {
  display: block;
  max-width: 100%;
  max-height: 480px;
}
.br-crop-source-canvas {
  pointer-events: none;
}
.br-crop-overlay-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* 裁剪工具栏 */
.br-crop-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
}
.br-crop-mode-btn {
  padding: 5px 14px;
  border: 1px solid var(--slate-300);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  background: #fff;
  transition: all 0.15s;
}
.br-crop-mode-btn:hover { border-color: var(--accent); }
.br-crop-mode-btn.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); font-weight: 600; }
.br-crop-coords {
  font-size: 12px;
  color: var(--text-light);
  margin-left: auto;
}

/* 子图库 */
.br-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.br-gallery-empty {
  text-align: center;
  padding: 30px;
  color: var(--text-light);
  font-size: 14px;
  border: 1px dashed var(--slate-300);
  border-radius: var(--radius-sm);
}
.br-gallery-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.2s;
}
.br-gallery-item:hover { box-shadow: var(--shadow-sm); }
.br-gallery-thumb {
  width: 100%;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.br-gallery-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.br-gallery-index {
  position: absolute;
  top: 4px; left: 4px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.br-gallery-actions { display: flex; flex-direction: column; gap: 1px; }
.br-gallery-action {
  flex: 0 0 auto;
  padding: 3px 4px;
  text-align: center;
  font-size: 11px;
  cursor: pointer;
  border: none;
  background: var(--slate-100);
  color: var(--text-secondary);
  transition: background 0.15s;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.br-gallery-action:hover { background: var(--accent); color: #fff; }
.br-gallery-action.act-del:hover { background: #ef4444; color: #fff; }

/* 已处理图片列表 */
.br-image-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0;
  padding: 8px;
  background: #fafbfc;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  min-height: 48px;
}
.br-image-list-item {
  width: 48px; height: 48px;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
  flex-shrink: 0;
}
.br-image-list-item:hover { border-color: var(--slate-400); }
.br-image-list-item.active { border-color: var(--accent); }
.br-image-list-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* 合成画板 */
.br-comp-canvas-wrap {
  position: relative;
  margin: 12px 0;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.br-comp-canvas {
  display: block;
  max-width: 100%;
  cursor: default;
}
.br-comp-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin: 12px 0;
}
.br-comp-layout .br-comp-canvas-wrap {
  flex: 1;
  min-width: 0;
  margin: 0;
}
.br-comp-tips {
  flex: 0 0 220px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
}
.br-comp-tips-title {
  font-weight: 700;
  font-size: 13px;
  color: #0369a1;
  margin-bottom: 8px;
}
.br-comp-tips-list {
  margin: 0;
  padding-left: 16px;
  color: #0c4a6e;
}
.br-comp-tips-list li {
  margin-bottom: 6px;
}
.br-comp-tips-list li:last-child {
  margin-bottom: 0;
}
.br-comp-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 8px 0;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
.br-comp-bg {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding-left: 6px;
}
.br-comp-bg-label {
  font-size: 12px;
  color: var(--text-light);
}
.br-comp-bg-btn {
  min-width: 34px;
  padding: 3px 8px;
  font-size: 12px;
  line-height: 1;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  color: var(--text);
}
.br-comp-bg-btn:hover {
  border-color: #94a3b8;
}
.br-comp-bg-btn.active {
  border-color: #f97316;
  background: #fff7ed;
  color: #ea580c;
  font-weight: 600;
}
#compBgColor {
  width: 34px;
  height: 28px;
  padding: 2px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.br-comp-size-input {
  width: 60px;
  padding: 3px 6px;
  border: 1px solid #d2d2d2;
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
}
.br-comp-label {
  font-size: 12px;
  color: var(--text-light);
  margin: 0 2px;
}

/* 页面区块标题 */
.br-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 8px;
}
.br-section-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

/* ─── 去背景主布局（左右分栏） ─── */
.br-wrap.br-wrap-wide {
  max-width: 1200px;
}
.br-main-row {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.br-left-panel {
  flex: 1;
  min-width: 0;
}
.br-right-panel {
  width: 260px;
  flex-shrink: 0;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 18px 16px 16px;
  background: var(--card);
  position: sticky;
  top: 80px;
  box-shadow: var(--shadow-sm);
}
.br-right-panel .tpd-settings-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--slate-200);
}
.br-right-panel .tpd-settings-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.br-right-panel .tpd-settings-group {
  padding: 0;
}
.br-right-panel .tpd-settings-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
  display: block;
}
.br-right-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--slate-200);
}
.br-right-actions .tpd-btn {
  text-align: center;
}

/* 裁剪区在 always-visible 模式下 */
.br-section-container {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--slate-200);
}
.br-crop-inner { display: none; }
.br-crop-inner.active { display: block; }
.br-crop-placeholder { display: block; }
.br-crop-placeholder.hidden { display: none; }

/* 左侧面板内部内容切换 */
.br-left-content { display: block; }
.br-left-content.hidden { display: none; }

/* 响应式 */
@media (max-width: 860px) {
  .br-main-row { flex-direction: column; }
  .br-right-panel { width: 100%; position: static; }
}
