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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  line-height: 1.6;
  min-height: 100vh;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
header {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1a1a2e;
}

header p {
  color: #6b7280;
  margin-top: 0.25rem;
  font-size: 0.95rem;
}

/* Main */
main {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

/* Card */
.card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  padding: 2rem;
  margin-bottom: 1rem;
}

.card h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: #374151;
}

/* Drop Zone */
#drop-zone {
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  padding: 3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
  position: relative;
}

#drop-zone:hover,
#drop-zone.drag-over {
  border-color: #3b82f6;
  background: #eff6ff;
}

.drop-zone-content svg {
  margin-bottom: 0.75rem;
}

.drop-zone-content p {
  font-size: 1rem;
  color: #374151;
}

.drop-zone-content .subtitle {
  color: #6b7280;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.drop-zone-content .hint {
  color: #9ca3af;
  font-size: 0.75rem;
  margin-top: 0.5rem;
}

/* Preview Row */
.preview-row {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.preview-box {
  flex: 1;
  min-width: 0;
}

.preview-label {
  font-size: 0.8rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.preview-box img {
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 8px;
  background: #f8f8f8;
  display: block;
}

.file-info {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #6b7280;
}

/* Convert Controls */
.convert-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 180px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group label {
  font-size: 0.85rem;
  color: #374151;
  font-weight: 500;
}

.form-group select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
  cursor: pointer;
  outline: none;
  transition: border-color 150ms ease;
}

.form-group select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group input[type="range"] {
  width: 100%;
  accent-color: #3b82f6;
  cursor: pointer;
}

/* Buttons */
.btn-primary {
  display: inline-block;
  padding: 0.625rem 1.5rem;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background 150ms ease;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-primary:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}

.btn-secondary {
  display: inline-block;
  padding: 0.625rem 1.5rem;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

/* Loading */
#loading-section {
  text-align: center;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e5e7eb;
  border-top: 4px solid #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

#loading-section p {
  color: #6b7280;
}

/* Result */
.result-row {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.result-info {
  min-width: 200px;
}

.size-compare {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.size-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.size-label {
  color: #6b7280;
  font-size: 0.85rem;
}

.size-value {
  font-weight: 600;
  font-size: 0.9rem;
}

.size-value.positive {
  color: #10b981;
}

.size-value.negative {
  color: #ef4444;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Error */
.error-card {
  text-align: center;
  border: 1px solid #fecaca;
}

.error-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fef2f2;
  color: #ef4444;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.75rem;
}

#error-message {
  color: #dc2626;
  margin-bottom: 1rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: #9ca3af;
  font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 768px) {
  .preview-row,
  .result-row {
    flex-direction: column;
  }

  .convert-controls {
    width: 100%;
  }

  .card {
    padding: 1.25rem;
  }

  #drop-zone {
    padding: 2rem 1rem;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 1.35rem;
  }

  header {
    padding: 1.5rem 1rem 1rem;
  }

  .card {
    padding: 1rem;
  }

  .preview-box img {
    max-height: 220px;
  }
}
