* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #f8fafc;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: #0f172a;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header p {
  color: #475569;
  font-size: 0.875rem;
  margin-top: 0.375rem;
}

/* Workspace Layout */
.workspace {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .workspace {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 1.5rem;
  }
}

/* Cards */
.card {
  background: #ffffff;
  border-radius: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.02);
  overflow: hidden;
}

.card-content {
  padding: 1.25rem;
}

/* Upload Area */
.upload-area {
  border: 2px dashed #cbd5e1;
  border-radius: 1rem;
  padding: 1.75rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fefefe;
  margin-bottom: 1.25rem;
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: #3b82f6;
  background: #eff6ff;
}

.upload-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 0.75rem;
  background: #f1f5f9;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-area p {
  color: #334155;
  font-size: 0.875rem;
}

.upload-hint {
  font-size: 0.6875rem;
  color: #94a3b8;
  margin-top: 0.25rem;
}

.upload-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 0.5rem 1.25rem;
  border-radius: 2rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #3b82f6;
  cursor: pointer;
  margin-top: 0.75rem;
  transition: all 0.15s;
}

.upload-btn:hover {
  background: #f8fafc;
  border-color: #3b82f6;
}

/* Mode Toggle */
.mode-toggle {
  background: #f1f5f9;
  border-radius: 0.75rem;
  padding: 0.25rem;
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
}

.mode-btn {
  flex: 1;
  text-align: center;
  padding: 0.5rem;
  border-radius: 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: transparent;
  color: #64748b;
}

.mode-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Presets */
.preset-group {
  margin-bottom: 1.25rem;
}

.preset-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.preset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preset {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 0.375rem 0.875rem;
  border-radius: 1.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.15s;
}

.preset:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  transform: translateY(-1px);
}

.preset:active {
  transform: translateY(0);
}

/* Controls */
.control-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.875rem;
}

.control-field {
  flex: 1;
}

.control-field label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  color: #64748b;
  margin-bottom: 0.25rem;
}

.control-field input,
.control-field select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.625rem;
  font-size: 0.8125rem;
  color: #0f172a;
  transition: border 0.15s;
}

.control-field input:focus,
.control-field select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.625rem 0;
}

.checkbox-item input {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.checkbox-item label {
  font-size: 0.75rem;
  color: #334155;
  cursor: pointer;
}

.quality-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.quality-row input {
  flex: 1;
}

.quality-value {
  font-size: 0.75rem;
  color: #64748b;
  min-width: 40px;
}

/* Buttons */
.btn-primary {
  width: 100%;
  background: #0f172a;
  color: white;
  border: none;
  padding: 0.625rem;
  border-radius: 0.75rem;
  font-weight: 500;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: #1e293b;
}

.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
  background: #e6edf4;
}

hr {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 1rem 0;
}

/* Comparison View */
.comparison-view {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 768px) {
  .comparison-view {
    flex-direction: row;
  }
}

.comparison-card {
  flex: 1;
  background: #ffffff;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

.comparison-header {
  background: #f8fafc;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.comparison-header h3 {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #0f172a;
}

.comparison-stats {
  font-size: 0.6875rem;
  color: #64748b;
}

.preview-container {
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  padding: 1rem;
  position: relative;
}

.preview-image {
  max-width: 100%;
  max-height: 340px;
  object-fit: contain;
  border-radius: 0.5rem;
}

.interactive-preview {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.interactive-preview:active {
  cursor: grabbing;
}

#resultCanvas {
  max-width: 100%;
  max-height: 340px;
  width: auto;
  height: auto;
  background: #0f172a;
  border-radius: 0.5rem;
  display: block;
  margin: 0 auto;
  cursor: grab;
  touch-action: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.drag-hint {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  color: white;
  font-size: 0.625rem;
  padding: 0.375rem 0.75rem;
  border-radius: 1.5rem;
  pointer-events: none;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.download-row {
  display: flex;
  gap: 0.75rem;
  margin: 1rem;
}

.feedback {
  font-size: 0.75rem;
  text-align: center;
  padding: 0.5rem;
  color: #059669;
}

/* Bulk Area */
.bulk-area {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}

.bulk-upload-area {
  border: 1px dashed #cbd5e1;
  border-radius: 0.75rem;
  padding: 0.875rem;
  text-align: center;
  cursor: pointer;
  background: #fafbfc;
  margin: 0.75rem 0;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.bulk-upload-area:hover {
  border-color: #3b82f6;
  background: #eff6ff;
}

.bulk-upload-area input {
  display: none;
}

.bulk-info {
  font-size: 0.6875rem;
  color: #64748b;
  margin: 0.5rem 0;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* SEO Content Section */
.seo-content {
  margin-top: 3rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 2.5rem;
}

.seo-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .seo-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.seo-card {
  background: #ffffff;
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid #e2e8f0;
}

.seo-card h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.seo-card p {
  font-size: 0.875rem;
  color: #334155;
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.seo-card p:last-child {
  margin-bottom: 0;
}

/* Tools Section */
.tools-section {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: #f8fafc;
  border-radius: 1rem;
  text-align: center;
}

.tools-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 1rem;
}

.tools-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.tool-link {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 2rem;
  font-size: 0.8125rem;
  color: #3b82f6;
  text-decoration: none;
  transition: all 0.15s;
}

.tool-link:hover {
  background: #eff6ff;
  border-color: #3b82f6;
  transform: translateY(-1px);
}

/* FAQ Section */
.faq-section {
  margin-bottom: 2rem;
}

.faq-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 1rem;
  text-align: center;
}

.faq-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  .faq-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.faq-item {
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 1rem;
  border: 1px solid #e2e8f0;
}

.faq-item h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 0.5rem;
}

.faq-item p {
  font-size: 0.8125rem;
  color: #475569;
  line-height: 1.5;
}

/* Mobile Optimizations */
@media (max-width: 640px) {
  .app {
    padding: 1rem;
  }
  
  .card-content {
    padding: 1rem;
  }
  
  .preset-grid {
    gap: 0.375rem;
  }
  
  .preset {
    padding: 0.25rem 0.625rem;
    font-size: 0.6875rem;
  }
  
  .comparison-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .drag-hint {
    bottom: 0.5rem;
    right: 0.5rem;
    font-size: 0.5625rem;
    padding: 0.25rem 0.5rem;
  }
  
  .seo-card {
    padding: 1rem;
  }
  
  .seo-card h2 {
    font-size: 1rem;
  }
}

/* SEO Content Section */
.seo-content {
  margin-top: 3rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 2.5rem;
}

.seo-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .seo-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.seo-card {
  background: #ffffff;
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid #e2e8f0;
}

.seo-card h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.seo-card p {
  font-size: 0.875rem;
  color: #334155;
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.seo-card p:last-child {
  margin-bottom: 0;
}

/* Tools Section */
.tools-section {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: #f8fafc;
  border-radius: 1rem;
  text-align: center;
}

.tools-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 1rem;
}

.tools-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.tool-link {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 2rem;
  font-size: 0.8125rem;
  color: #3b82f6;
  text-decoration: none;
  transition: all 0.15s;
}

.tool-link:hover {
  background: #eff6ff;
  border-color: #3b82f6;
}

/* FAQ Section */
.faq-section {
  margin-bottom: 2rem;
}

.faq-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 1rem;
  text-align: center;
}

.faq-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  .faq-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.faq-item {
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 1rem;
  border: 1px solid #e2e8f0;
}

.faq-item h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 0.5rem;
}

.faq-item p {
  font-size: 0.8125rem;
  color: #475569;
  line-height: 1.5;
}

#bulkUploadArea {
  display: none;
}