:root {
  --primary: #4f6df5;
  --primary-dark: #3b5bdb;
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #242833;
  --border: #2d3142;
  --text: #e4e6eb;
  --text-dim: #8b909f;
  --success: #2dd4bf;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.nav-tabs { display: flex; gap: 8px; }

.tab-btn {
  padding: 8px 20px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.tab-btn:hover { color: var(--text); background: var(--surface-2); }
.tab-btn.active { color: #fff; background: var(--primary); }

/* 浮动反馈按钮 */
.float-feedback-btn {
  position: fixed;
  bottom: 140px;
  right: 24px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, #4f6df5, #7c3aed);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(79, 109, 245, 0.4);
  transition: all 0.3s;
  animation: pulse 2s ease-in-out infinite;
}
.float-feedback-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(79, 109, 245, 0.6);
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(79, 109, 245, 0.4); }
  50% { box-shadow: 0 4px 30px rgba(79, 109, 245, 0.7); }
}

/* ── Tabs ── */
.tab-panel { display: none; flex: 1; padding: 24px; }
.tab-panel.active { display: flex; }

.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* ── Upload Zone ── */
.upload-zone, .batch-zone {
  width: 100%;
  min-height: 400px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface);
}
.upload-zone.dragover, .batch-zone.dragover {
  border-color: var(--primary);
  background: rgba(79, 109, 245, 0.05);
}
.upload-inner { text-align: center; color: var(--text-dim); }
.upload-inner svg { margin-bottom: 16px; }
.upload-inner p { margin-top: 8px; }
.upload-inner .link { color: var(--primary); cursor: pointer; text-decoration: underline; }
.upload-inner .hint { font-size: 13px; opacity: 0.6; margin-top: 4px; }

/* ── Editor Area ── */
.editor-area { width: 100%; display: flex; gap: 20px; flex-wrap: wrap; }

/* canvas-container: 无背景无边框，只放图片 */
.canvas-container {
  flex: 1;
  min-width: 300px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
}

#edit-canvas {
  max-width: 100%;
  max-height: 600px;
  object-fit: contain;
}

.controls-panel {
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.controls-panel h3 { margin-bottom: 16px; font-size: 16px; }

.control-group { margin-bottom: 16px; }
.control-group label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.control-group .val { color: var(--text); font-weight: 500; }

input[type="range"] {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }

.btn-row { display: flex; gap: 8px; margin-top: 16px; }
.btn-row.center { justify-content: center; }
.btn-row button { flex: 1; }

.btn-sm {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-toggle { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }
.btn-toggle.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.btn-enhance {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: linear-gradient(135deg, #2dd4bf, #4f6df5);
  color: #fff;
  transition: all 0.2s;
  width: 100%;
}
.btn-enhance:hover { opacity: 0.9; transform: translateY(-1px); }

/* ── Cutout Result ── */
.cutout-result { width: 100%; display: flex; flex-direction: column; gap: 20px; }
.result-compare { display: flex; gap: 20px; flex-wrap: wrap; }
.img-box { flex: 1; min-width: 250px; }
.img-box h4 { margin-bottom: 8px; font-size: 14px; color: var(--text-dim); }

/* checker-bg: 不加边框不加padding，只显示棋盘格背景 */
.checker-bg {
  border-radius: var(--radius);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #2a2a2a;
  background-image:
    linear-gradient(45deg, #3a3a3a 25%, transparent 25%),
    linear-gradient(-45deg, #3a3a3a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #3a3a3a 75%),
    linear-gradient(-45deg, transparent 75%, #3a3a3a 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, 10px 0px;
}
.checker-bg img { max-width: 100%; max-height: 500px; }

/* ── Loading ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 16px;
}
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--surface-2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Batch ── */
.batch-area { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.batch-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}
.batch-toolbar span { color: var(--text-dim); }
.batch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.batch-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
.batch-item .thumb {
  width: 100%;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: #2a2a2a;
  background-image:
    linear-gradient(45deg, #3a3a3a 25%, transparent 25%),
    linear-gradient(-45deg, #3a3a3a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #3a3a3a 75%),
    linear-gradient(-45deg, transparent 75%, #3a3a3a 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, 10px 0px;
}
.batch-item .thumb img { max-width: 100%; max-height: 100%; }
.batch-item .info { padding: 8px 12px; font-size: 12px; display: flex; justify-content: space-between; align-items: center; }
.batch-item .name { color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.batch-item .status { font-size: 11px; padding: 2px 8px; border-radius: 4px; }
.status-pending { background: var(--surface-2); color: var(--text-dim); }
.status-processing { background: rgba(79,109,245,0.2); color: var(--primary); }
.status-done { background: rgba(45,212,191,0.2); color: var(--success); }
.status-error { background: rgba(239,68,68,0.2); color: var(--danger); }
.batch-item .download-btn {
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(0,0,0,0.6); border: none; color: #fff;
  cursor: pointer; display: none; align-items: center; justify-content: center;
  font-size: 16px; transition: background 0.2s;
}
.batch-item .download-btn:hover { background: var(--primary); }
.batch-item.has-result .download-btn { display: flex; }
.batch-item .remove-btn {
  position: absolute; top: 8px; left: 8px;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0,0,0,0.6); border: none; color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.batch-item .remove-btn:hover { background: var(--danger); }

/* ── 去水印 ── */
.wm-area { width: 100%; display: flex; gap: 20px; flex-wrap: wrap; }
.wm-canvas-wrapper {
  flex: 1;
  min-width: 300px;
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 400px;
}
.wm-canvas-wrapper canvas { max-width: 100%; max-height: 600px; }
.mask-overlay { position: absolute; cursor: crosshair; touch-action: none; }
.wm-controls { width: 280px; }
.wm-hint { font-size: 13px; color: var(--text-dim); margin-bottom: 16px; line-height: 1.5; }

/* ── 轮播图 ── */
.carousel {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: var(--radius);
  min-height: 120px;
}
.carousel-track {
  display: flex;
  transition: transform 0.5s ease;
}
.carousel-slide {
  min-width: 100%;
  flex-shrink: 0;
}
.carousel-content {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 60px;
  background: linear-gradient(135deg, #1a1d27, #242833);
  min-height: 120px;
}
.carousel-content img {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
}
.carousel-text h4 { font-size: 18px; color: var(--text); margin-bottom: 6px; }
.carousel-text p { font-size: 14px; color: var(--text-dim); }
.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 10;
}
.carousel-arrow:hover { background: var(--primary); }
.carousel-arrow.prev { left: 10px; }
.carousel-arrow.next { right: 10px; }

/* ── 反馈弹窗 ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 90%;
  max-width: 480px;
}
.modal-box h3 { font-size: 20px; margin-bottom: 16px; }
.modal-box textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 14px;
  resize: vertical;
  outline: none;
  font-family: inherit;
}
.modal-box textarea:focus { border-color: var(--primary); }
.modal-box .btn-row { margin-top: 16px; }

/* ── Footer ── */
.app-footer {
  padding: 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  z-index: 3000;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .app-header { flex-direction: column; padding: 12px; }
  .editor-area { flex-direction: column; }
  .controls-panel { width: 100%; }
  .result-compare { flex-direction: column; }
  .batch-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .wm-area { flex-direction: column; }
  .wm-controls { width: 100%; }
  .carousel-content { padding: 16px 50px; }
}
