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

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f9fafb;
  --card-bg: #ffffff;
  --text: #111827;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* Top bar */
.top-bar { padding: 12px 0; border-bottom: 1px solid var(--border); background: white; margin-bottom: 16px; }
.top-bar .container { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top-bar h1 { font-size: 1.2em; font-weight: 700; color: var(--primary); }
.top-controls { display: flex; align-items: center; gap: 8px; font-size: 0.9em; color: var(--text-secondary); }
.top-controls select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9em; background: white; }

/* Upload */
.upload-section { background: white; border: 2px dashed var(--border); border-radius: 12px; padding: 48px 24px; text-align: center; cursor: pointer; transition: all 0.2s; margin-bottom: 24px; }
.upload-section:hover { border-color: var(--primary); background: #f0f9ff; }
.upload-section.drag-over { border-color: var(--primary); background: #dbeafe; transform: scale(1.01); }
.upload-icon { font-size: 3em; margin-bottom: 16px; }
.upload-text { font-size: 1.2em; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.upload-hint { color: var(--text-secondary); font-size: 0.9em; }
#fileInput { display: none; }

/* Batch actions */
.batch-actions { display: none; gap: 12px; margin-bottom: 24px; justify-content: center; }
.batch-actions.show { display: flex; }
.export-controls { display: flex; align-items: center; gap: 8px; font-size: 0.9em; color: var(--text-secondary); }
.export-controls select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9em; background: white; }
.batch-btn { padding: 12px 24px; border: none; border-radius: 8px; font-size: 0.95em; font-weight: 600; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 8px; }
.batch-btn-primary { background: var(--primary); color: white; }
.batch-btn-primary:hover { background: var(--primary-hover); }
.batch-btn-success { background: var(--success); color: white; }
.batch-btn-success:hover { background: #059669; }
.batch-btn-danger { background: white; color: var(--danger); border: 1px solid var(--border); }
.batch-btn-danger:hover { background: #fef2f2; }

/* Grid */
.images-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; margin-bottom: 40px; }
.image-card { background: white; border-radius: 12px; padding: 16px; box-shadow: var(--shadow); transition: all 0.2s; position: relative; }
.image-card:hover { box-shadow: var(--shadow-lg); }

/* Comparison */
.comparison-container { position: relative; width: 100%; height: 240px; border-radius: 8px; overflow: hidden; background: var(--bg); margin-bottom: 12px; user-select: none; }
.comparison-image { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; }
.compressed-side { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; clip-path: inset(0 50% 0 0); }
.comparison-slider { position: absolute; top: 0; left: 50%; width: 4px; height: 100%; background: white; cursor: ew-resize; z-index: 10; box-shadow: 0 0 10px rgba(0,0,0,0.3); }
.slider-button { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; background: white; border-radius: 50%; box-shadow: 0 2px 8px rgba(0,0,0,0.2); display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--text-secondary); }
.comparison-labels { position: absolute; top: 8px; width: 100%; display: flex; justify-content: space-between; padding: 0 12px; pointer-events: none; z-index: 5; }
.label { background: rgba(0, 0, 0, 0.6); color: white; padding: 4px 10px; border-radius: 4px; font-size: 0.8em; font-weight: 600; }

.image-info { margin-bottom: 12px; }
.image-name { font-weight: 600; font-size: 0.9em; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.size-comparison { display: flex; justify-content: space-between; font-size: 0.85em; color: var(--text-secondary); margin-bottom: 4px; }
.compression-badge { display: inline-block; background: var(--success); color: white; padding: 4px 10px; border-radius: 12px; font-size: 0.8em; font-weight: 700; }

.status-badge { display: inline-block; padding: 6px 12px; border-radius: 6px; font-size: 0.85em; font-weight: 600; margin-bottom: 12px; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-compressing { background: #dbeafe; color: #1e40af; }
.status-compressed { background: #d1fae5; color: #065f46; }
.status-error { background: #fee2e2; color: #991b1b; }

.card-actions { display: flex; gap: 8px; }
.btn { flex: 1; padding: 10px 16px; border: none; border-radius: 6px; font-size: 0.9em; font-weight: 600; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-outline { background: white; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-remove { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%; background: rgba(0, 0, 0, 0.5); color: white; border: none; cursor: pointer; font-size: 20px; display: flex; align-items: center; justify-content: center; opacity: 0; transition: all 0.2s; z-index: 10; }
.image-card:hover .btn-remove { opacity: 1; }
.btn-remove:hover { background: var(--danger); }

.spinner { border: 2px solid rgba(255, 255, 255, 0.3); border-radius: 50%; border-top-color: white; width: 14px; height: 14px; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { grid-column: 1 / -1; text-align: center; padding: 80px 20px; color: var(--text-secondary); }
.empty-state-icon { font-size: 4em; margin-bottom: 16px; opacity: 0.3; }

/* SEO section */
.seo-section { background: white; border-radius: 12px; padding: 40px; margin-top: 60px; margin-bottom: 40px; box-shadow: var(--shadow); }
.seo-section h2 { font-size: 1.8em; margin-bottom: 16px; color: var(--text); }
.seo-section h3 { font-size: 1.3em; margin-top: 32px; margin-bottom: 12px; color: var(--text); }
.seo-section p { margin-bottom: 16px; line-height: 1.8; color: var(--text-secondary); }
.seo-section ul { margin-left: 24px; margin-bottom: 16px; }
.seo-section li { margin-bottom: 8px; color: var(--text-secondary); }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 24px; margin-top: 32px; }
.feature-card { padding: 20px; background: var(--bg); border-radius: 8px; }
.feature-card h4 { font-size: 1.1em; margin-bottom: 8px; color: var(--text); }
.feature-card p { font-size: 0.9em; margin-bottom: 0; }

footer { text-align: center; padding: 32px 0; color: var(--text-secondary); font-size: 0.9em; border-top: 1px solid var(--border); }

@media (max-width: 768px) {
  .upload-section { padding: 32px 16px; }
  .images-grid { grid-template-columns: 1fr; }
  .batch-actions { flex-direction: column; }
  .batch-btn { width: 100%; }
  .seo-section { padding: 24px; }
}

