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

:root {
  --green-50: #ecfdf5;
  --green-100: #d1fae5;
  --green-200: #a7f3d0;
  --green-300: #6ee7b7;
  --green-400: #34d399;
  --green-500: #10b981;
  --green-600: #059669;
  --green-700: #047857;
  --green-800: #065f46;
  --green-900: #064e3b;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* Header */
.header {
  background: linear-gradient(135deg, var(--green-500), var(--green-700));
  color: white;
  padding: 40px 0 50px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
  animation: pulse 8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
  position: relative;
}

.logo-icon {
  width: 40px;
  height: 40px;
}

.logo h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.tagline {
  font-size: 1.05rem;
  opacity: 0.9;
  font-weight: 300;
  position: relative;
}

/* Upload Zone */
.upload-zone {
  margin-top: -30px;
  border: 3px dashed var(--green-300);
  border-radius: var(--radius);
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: white;
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 1;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--green-500);
  background: var(--green-50);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.upload-zone.drag-over {
  border-color: var(--green-600);
  background: var(--green-100);
}

.upload-icon {
  width: 64px;
  height: 64px;
  color: var(--green-500);
  margin-bottom: 16px;
}

.upload-content h2 {
  font-size: 1.4rem;
  color: var(--gray-800);
  margin-bottom: 8px;
}

.upload-content p {
  color: var(--gray-500);
  font-size: 0.95rem;
}

.upload-hint {
  margin-top: 8px;
  font-size: 0.85rem !important;
  color: var(--gray-400) !important;
}

/* Controls Panel */
.controls-panel {
  background: white;
  border-radius: var(--radius);
  padding: 28px;
  margin-top: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}

.control-group label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--gray-700);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.radio-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radio-label {
  display: flex !important;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-weight: 500 !important;
  color: var(--gray-600) !important;
}

.radio-label:has(input:checked) {
  border-color: var(--green-500);
  background: var(--green-50);
  color: var(--green-700) !important;
}

.radio-label input {
  display: none;
}

.dimension-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-group {
  flex: 1;
  position: relative;
}

.input-group label {
  margin-bottom: 4px;
  font-size: 0.75rem !important;
}

.input-group input {
  width: 100%;
  padding: 10px 40px 10px 12px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
  background: var(--gray-50);
}

.input-group input:focus {
  outline: none;
  border-color: var(--green-500);
  background: white;
}

.unit {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(50%);
  color: var(--gray-400);
  font-size: 0.85rem;
  pointer-events: none;
}

.aspect-lock {
  width: 40px;
  height: 40px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.aspect-lock svg {
  width: 18px;
  height: 18px;
  color: var(--gray-400);
}

.aspect-lock.active {
  border-color: var(--green-500);
  background: var(--green-50);
}

.aspect-lock.active svg {
  color: var(--green-600);
}

.percent-input {
  display: flex;
  align-items: center;
  gap: 14px;
}

.percent-input input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--gray-200);
  border-radius: 3px;
  outline: none;
}

.percent-input input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--green-500);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.percent-input span {
  font-weight: 600;
  color: var(--green-600);
  min-width: 48px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.preset-btn {
  padding: 12px 10px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.preset-btn:hover {
  border-color: var(--green-400);
  background: var(--green-50);
}

.preset-btn.active {
  border-color: var(--green-500);
  background: var(--green-50);
}

.preset-name {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--gray-800);
}

.preset-size {
  display: block;
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 2px;
}

select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: var(--gray-50);
  cursor: pointer;
  transition: border-color 0.2s;
}

select:focus {
  outline: none;
  border-color: var(--green-500);
  background: white;
}

.quality-input {
  display: flex;
  align-items: center;
  gap: 14px;
}

.quality-input input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(to right, var(--green-200), var(--green-500));
  border-radius: 3px;
  outline: none;
}

.quality-input input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--green-600);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
}

.quality-input span {
  font-weight: 600;
  color: var(--green-600);
  min-width: 40px;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 20px;
  border-top: 1px solid var(--gray-200);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--green-500), var(--green-600));
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--green-600), var(--green-700));
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
  background: var(--green-600);
  color: white;
}

.btn-secondary:hover {
  background: var(--green-700);
}

.btn-outline {
  border-color: var(--gray-300);
  background: white;
  color: var(--gray-600);
}

.btn-outline:hover {
  border-color: var(--gray-400);
  background: var(--gray-50);
}

/* Image List */
.image-list {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 40px;
}

.image-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  transition: box-shadow 0.2s;
}

.image-card:hover {
  box-shadow: var(--shadow-md);
}

.image-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.image-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-700);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}

.image-meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--gray-500);
}

.image-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--gray-200);
}

.preview-box {
  background: white;
  padding: 16px;
  text-align: center;
  position: relative;
}

.preview-box img {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 6px;
}

.preview-label {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--gray-800);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.preview-label.after {
  background: var(--green-600);
}

.size-comparison {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.size-info {
  text-align: center;
}

.size-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--gray-500);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.size-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-800);
}

.size-arrow {
  color: var(--green-500);
  font-size: 1.4rem;
}

.savings {
  background: var(--green-50);
  color: var(--green-700);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}

.savings.negative {
  background: #fef2f2;
  color: #dc2626;
}

.image-card-footer {
  padding: 12px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--gray-200);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-remove {
  border-color: var(--gray-300);
  background: white;
  color: var(--gray-500);
}

.btn-remove:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: #fef2f2;
}

/* Ad Placeholders */
.ad-placeholder {
  background: var(--gray-100);
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  overflow: hidden;
}

.top-ad {
  height: 90px;
  margin-top: 24px;
}

.bottom-ad {
  height: 250px;
  margin-top: 32px;
}

.footer-ad {
  height: 90px;
  margin-top: 20px;
}

/* Footer */
.footer {
  background: var(--gray-800);
  color: var(--gray-400);
  padding: 30px 0;
  text-align: center;
  font-size: 0.85rem;
  margin-top: 20px;
}

/* Progress */
.processing-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.processing-card {
  background: white;
  border-radius: var(--radius);
  padding: 40px 50px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--green-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

.processing-card h3 {
  font-size: 1.1rem;
  color: var(--gray-800);
}

.processing-card p {
  color: var(--gray-500);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* Responsive */
@media (max-width: 640px) {
  .header { padding: 30px 0 40px; }
  .logo h1 { font-size: 1.6rem; }
  .upload-zone { padding: 40px 20px; margin-top: -20px; }
  .controls-panel { padding: 20px; }
  .controls-grid { grid-template-columns: 1fr; }
  .dimension-inputs { flex-wrap: wrap; }
  .image-card-body { grid-template-columns: 1fr; }
  .action-buttons { flex-direction: column; }
  .btn { justify-content: center; }
  .preset-grid { grid-template-columns: repeat(2, 1fr); }
}
