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

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --secondary: #059669;
  --secondary-hover: #047857;
  --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;
  --border-radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

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

header {
  text-align: center;
  margin-bottom: 32px;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 8px;
}

header p {
  color: var(--gray-500);
  font-size: 1.05rem;
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--border-radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: #eef2ff;
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.dropzone-text {
  font-size: 1rem;
  color: var(--gray-600);
}

.dropzone-text .link {
  color: var(--primary);
  text-decoration: underline;
  font-weight: 500;
}

.dropzone-hint {
  font-size: 0.85rem;
  color: var(--gray-400);
}

/* Sections */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--gray-800);
}

.preview-section,
.settings-section,
.result-section {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 24px;
  margin-top: 20px;
  box-shadow: var(--shadow);
}

/* Original Preview */
.original-preview {
  display: flex;
  align-items: center;
  gap: 20px;
}

.original-preview canvas {
  max-width: 128px;
  max-height: 128px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background-image:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.image-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--gray-500);
}

/* Size Grid */
.size-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.size-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.95rem;
}

.size-checkbox:hover {
  border-color: var(--primary);
  background: #eef2ff;
}

.size-checkbox input:checked + span {
  color: var(--primary);
  font-weight: 600;
}

.size-checkbox input {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

/* Size Presets */
.size-presets {
  display: flex;
  gap: 6px;
}

/* Background Options */
.bg-options {
  margin-top: 20px;
}

.bg-options h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 12px;
}

.bg-row {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.bg-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.95rem;
}

.bg-row input[type="radio"] {
  accent-color: var(--primary);
}

.color-picker {
  width: 40px;
  height: 32px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  cursor: pointer;
  padding: 2px;
}

/* Preview Grid */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.preview-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: #fff;
}

.preview-item canvas {
  image-rendering: pixelated;
  background-image:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
}

.preview-item .size-label {
  font-size: 0.8rem;
  color: var(--gray-500);
  font-weight: 500;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
}

.btn-secondary:hover {
  background: var(--secondary-hover);
  box-shadow: var(--shadow-lg);
}

.btn-small {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-600);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #eef2ff;
}

.download-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-200);
}

footer p {
  font-size: 0.85rem;
  color: var(--gray-400);
}

/* Hidden */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 20px 16px;
  }

  header h1 {
    font-size: 1.5rem;
  }

  .dropzone {
    padding: 32px 16px;
  }

  .original-preview {
    flex-direction: column;
    text-align: center;
  }

  .download-buttons {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .preview-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .size-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
