:root {
  --bg: #fafaf9;
  --bg-card: #ffffff;
  --text-primary: #1c1917;
  --text-secondary: #78716c;
  --text-tertiary: #a8a29e;
  --border: #e7e5e4;
  --border-hover: #d6d3d1;
  --accent: #0ea5e9;
  --accent-hover: #0284c7;
  --accent-light: #e0f2fe;
  --success: #22c55e;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 15px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: saturate(180%) blur(8px);
  background: rgba(255,255,255,.85);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 16px;
}

.logo-icon {
  font-size: 20px;
  color: var(--accent);
}

.main-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

.main-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all .2s;
}

.main-nav a:hover {
  color: var(--text-primary);
  background: var(--bg);
}

.main-nav a.active {
  color: var(--accent);
  background: var(--accent-light);
}

.privacy-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--success);
  background: #f0fdf4;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.privacy-badge .lock { font-size: 14px; }

/* Hero */
.hero {
  text-align: center;
  padding: 64px 0 48px;
}

.hero h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 16px;
}

.hero-sub {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.hero-badges {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Tool Grid */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  padding: 32px 0 64px;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all .25s;
  position: relative;
}

.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-hover);
}

.tool-card.featured {
  border-color: var(--accent-light);
  background: linear-gradient(135deg, #f0f9ff 0%, #ffffff 100%);
}

.tool-icon {
  font-size: 36px;
  margin-bottom: 16px;
}

.tool-card h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.tool-card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.tool-tag {
  display: inline-block;
  font-size: 12px;
  padding: 3px 10px;
  background: #f0fdf4;
  color: var(--success);
  border-radius: 999px;
}

.tool-tag.tag-new {
  background: var(--accent-light);
  color: var(--accent);
}

/* Features Section */
.features-section {
  padding: 48px 0 80px;
  border-top: 1px solid var(--border);
}

.features-section h2 {
  text-align: center;
  font-size: 24px;
  margin-bottom: 40px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 32px;
}

.feature-item {
  text-align: center;
}

.feature-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.feature-item h4 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.feature-item p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Footer */
.site-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 24px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ====== Tool Page Layout ====== */
.tool-page {
  padding: 32px 0 64px;
}

.tool-header {
  margin-bottom: 32px;
}

.tool-header h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.tool-header p {
  color: var(--text-secondary);
  font-size: 15px;
}

.tool-main {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}

.preview-area {
  max-width: 760px;
}

@media (max-width: 900px) {
  .tool-main {
    grid-template-columns: 1fr;
  }
}

/* Drop Zone */
.drop-zone {
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.drop-zone:hover {
  border-color: var(--accent);
  background: #f0f9ff;
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: #e0f2fe;
}

.drop-zone-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.drop-zone h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.drop-zone p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
}

.drop-zone-hint {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Preview Area */
.preview-area {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.preview-area img {
  max-width: 100%;
  max-height: 480px;
  border-radius: var(--radius-sm);
}

.preview-area canvas {
  max-width: 100%;
  max-height: 480px;
  border-radius: var(--radius-sm);
}

.preview-info {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(0,0,0,.7);
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
}

/* Controls Panel */
.controls-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: sticky;
  top: 80px;
}

.controls-panel h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.control-group {
  margin-bottom: 16px;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.control-group input[type="number"],
.control-group input[type="text"],
.control-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg);
  transition: border-color .2s;
}

.control-group input[type="number"]:focus,
.control-group input[type="text"]:focus,
.control-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.control-group input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.range-value {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  float: right;
}

.size-inputs {
  display: flex;
  gap: 8px;
  align-items: center;
}

.size-inputs input {
  flex: 1;
}

.size-inputs span {
  color: var(--text-tertiary);
  font-size: 18px;
}

.lock-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all .2s;
}

.lock-btn.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  background: var(--text-tertiary);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
  width: 100%;
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  background: #f5f5f4;
}

.btn-ghost {
  background: none;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 6px 14px;
  font-size: 13px;
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* Result info */
.result-info {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 16px;
  font-size: 13px;
  color: #166534;
}

.result-info .highlight {
  font-weight: 600;
  color: #15803d;
}

/* Loading */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  z-index: 10;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.loading-progress {
  width: 200px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}

.loading-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width .3s;
}

/* Batch area */
.batch-thumbnails {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  padding: 16px;
}

.batch-thumbnails .thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
}

.batch-thumbnails .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.batch-thumbnails .thumb .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: rgba(0,0,0,.5);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  border: none;
}

/* Watermark position grid */
.position-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 8px;
}

.position-grid button {
  padding: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  transition: all .2s;
}

.position-grid button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Privacy note */
.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px;
  background: #f0fdf4;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #166534;
  margin-bottom: 16px;
}

.privacy-note .icon {
  font-size: 16px;
  flex-shrink: 0;
}

/* hidden */
.hidden { display: none !important; }

/* cropper specific */
.crop-container {
  width: 100%;
  height: 480px;
  max-height: 70vh;
  background: #1a1a1a;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* When crop is active, neutralize preview-area flex/padding */
.preview-area.cropping {
  display: block;
  padding: 0;
}

/* Override preview-area img/canvas constraints inside cropper */
.crop-container img,
.crop-container canvas {
  max-width: none !important;
  max-height: none !important;
  border-radius: 0 !important;
  display: block;
}

/* Cropper.js internal elements must not be constrained */
.crop-container .cropper-container,
.crop-container .cropper-canvas,
.crop-container .cropper-crop-box,
.crop-container .cropper-modal,
.crop-container .cropper-view-box,
.crop-container .cropper-face,
.crop-container .cropper-line,
.crop-container .cropper-point {
  max-width: none !important;
  max-height: none !important;
}

.preset-ratios {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-ratios button {
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  transition: all .2s;
}

.preset-ratios button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* format chips */
.format-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.format-chip {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg);
  transition: all .2s;
  flex: 1;
  text-align: center;
}

.format-chip.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Download all */
.download-all {
  width: 100%;
  margin-top: 8px;
}

/* Before/After comparison slider */
.compare-container {
  position: relative;
  width: 100%;
  max-height: 480px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  user-select: none;
}

.compare-container img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 480px;
  object-fit: contain;
  pointer-events: none;
}

.compare-before {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  overflow: hidden;
}

.compare-before img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.compare-slider-handle {
  position: absolute;
  top: 0;
  left: 50%;
  width: 4px;
  height: 100%;
  background: white;
  box-shadow: 0 0 6px rgba(0,0,0,.4);
  cursor: ew-resize;
  transform: translateX(-50%);
}

.compare-slider-handle::after {
  content: '⇄';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.compare-label {
  position: absolute;
  top: 12px;
  padding: 4px 10px;
  background: rgba(0,0,0,.6);
  color: white;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
}

.compare-label-before { left: 12px; }
.compare-label-after { right: 12px; }

/* ====== 去水印画笔编辑器 ====== */
.canvas-editor {
  position: relative;
  width: 100%;
  background: #1a1a1a;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: crosshair;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.canvas-editor canvas {
  display: block;
  max-width: 100%;
  max-height: 480px;
}

.tool-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.tool-tab {
  flex: 1;
  padding: 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .2s;
  text-align: center;
}

.tool-tab.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

.brush-cursor {
  position: absolute;
  border: 2px solid rgba(255,255,255,.8);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(0,0,0,.5);
  display: none;
}
