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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  min-height: 100vh;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
  padding: 1.5rem 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.sidebar-header h1 {
  font-size: 1.25rem;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tool-menu {
  padding: 1rem 0;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.875rem 1.5rem;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.tool-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.tool-btn.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.1), transparent);
  color: #3b82f6;
  border-right: 3px solid #3b82f6;
}

.tool-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem 1.5rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-link {
  color: #64748b;
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}

.footer-link:hover {
  color: #3b82f6;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

.tool-panel {
  display: none;
}

.tool-panel.active {
  display: block;
}

.tool-panel h2 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: #64748b;
  margin-bottom: 2rem;
}

/* Compress Layout */
.compress-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 2rem;
  align-items: start;
}

.compress-left {
  position: sticky;
  top: 2rem;
}

.compress-right {
  min-height: 400px;
  position: relative;
}

.loading-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  border-radius: 1rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.loading-overlay.active {
  display: flex;
}

.loading-overlay .spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

.loading-overlay p {
  color: #64748b;
  font-weight: 500;
}

.empty-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  background: #ffffff;
  border-radius: 1rem;
  border: 2px dashed #e2e8f0;
  color: #94a3b8;
}

.empty-result svg {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  color: #cbd5e1;
}

/* Resize Layout */
.resize-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 2rem;
  align-items: start;
}

.resize-left {
  position: sticky;
  top: 2rem;
}

.resize-right {
  min-height: 400px;
  position: relative;
}

.setting-row input[type="number"] {
  flex: 1;
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #1e293b;
  font-size: 1rem;
}

.setting-row input[type="number"]:disabled {
  background: #e2e8f0;
  color: #64748b;
  cursor: not-allowed;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.toggle input[type="checkbox"] {
  display: none;
}

.toggle-slider {
  width: 40px;
  height: 22px;
  background: #cbd5e1;
  border-radius: 11px;
  position: relative;
  transition: background 0.3s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
}

.toggle input:checked + .toggle-slider {
  background: #3b82f6;
}

.toggle input:checked + .toggle-slider::after {
  transform: translateX(18px);
}

.toggle-label {
  font-size: 0.95rem;
  color: #64748b;
}

/* Remove BG Layout */
.remove-bg-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 2rem;
  align-items: start;
}

.remove-bg-left {
  position: sticky;
  top: 2rem;
}

.remove-bg-right {
  min-height: 400px;
  position: relative;
}

.checkerboard {
  background-image:
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
    linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.preview-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.preview-box {
  text-align: center;
}

.preview-box img {
  max-width: 100%;
  max-height: 400px;
  border-radius: 0.5rem;
  object-fit: contain;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.preview-box p {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #64748b;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed #3b82f6;
  border-radius: 1rem;
  padding: 3rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #ffffff;
  margin-bottom: 1.5rem;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: #8b5cf6;
  background: #faf5ff;
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.15);
}

.drop-zone svg {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  color: #3b82f6;
}

.drop-zone p {
  font-size: 1.1rem;
  color: #64748b;
}

.drop-zone .highlight {
  color: #3b82f6;
  font-weight: 600;
  word-wrap: break-word;
}

.drop-zone .formats {
  font-size: 0.85rem !important;
  margin-top: 0.5rem;
}

/* Settings */
.settings {
  background: #ffffff;
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
}

.setting-row:last-child {
  margin-bottom: 0;
}

.setting-row label {
  font-weight: 500;
  min-width: 120px;
}

.setting-row select,
.setting-row input[type="range"] {
  flex: 1;
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #1e293b;
  font-size: 1rem;
}

.setting-row select {
  max-width: 200px;
}

input[type="range"] {
  -webkit-appearance: none;
  height: 8px;
  border-radius: 4px;
  background: #e2e8f0;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #3b82f6;
  cursor: pointer;
}

.quality-value {
  min-width: 50px;
  text-align: right;
  font-weight: 600;
  color: #3b82f6;
}

/* Buttons */
.btn {
  width: 100%;
  padding: 1rem;
  border: none;
  border-radius: 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(59, 130, 246, 0.25);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-download {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  margin-top: 1.5rem;
}

.btn-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(34, 197, 94, 0.25);
}

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

/* Preview */
.preview {
  display: none;
  background: #ffffff;
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.preview.active {
  display: block;
}

.preview h3 {
  margin-bottom: 1rem;
  color: #64748b;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.stat {
  background: #f8fafc;
  padding: 1rem;
  border-radius: 0.75rem;
  text-align: center;
  border: 1px solid #e2e8f0;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #3b82f6;
}

.stat-label {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 0.25rem;
}

.reduction-positive {
  color: #22c55e;
}

.reduction-negative {
  color: #ef4444;
}

.hidden {
  display: none;
}

#fileInput,
#resizeFileInput,
#removeBgFileInput {
  display: none;
}

.seo-content {
  max-width: 800px;
  margin: 3rem auto 0;
  padding: 2rem 0;
  border-top: 1px solid #e2e8f0;
}

.seo-content h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: #1e293b;
}

.seo-content h3 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.5rem;
  color: #334155;
}

.seo-content p,
.seo-content li {
  color: #64748b;
  line-height: 1.7;
  margin-bottom: 0.75rem;
}

.seo-content ul {
  padding-left: 1.5rem;
}

.seo-content li {
  margin-bottom: 0.5rem;
}
