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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f5f4f0;
  color: #1a1a1a;
  min-height: 100vh;
}

header {
  background: #1a1a2e;
  color: #fff;
  padding: 2rem;
  text-align: center;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.subtitle {
  margin-top: 0.4rem;
  color: #a0aec0;
  font-size: 1rem;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

/* Upload zone */
.upload-section {
  margin-bottom: 1.5rem;
}

.drop-zone {
  border: 2.5px dashed #cbd5e0;
  border-radius: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 3.5rem 2rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  text-align: center;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: #4f46e5;
  background: #eef2ff;
}

.drop-zone svg {
  width: 48px;
  height: 48px;
  color: #a0aec0;
}

.drop-zone p {
  font-size: 1.1rem;
  font-weight: 600;
  color: #4a5568;
}

.drop-zone span {
  font-size: 0.85rem;
  color: #a0aec0;
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* Controls */
.controls-section {
  margin-bottom: 1.5rem;
}

.controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: #fff;
  border-radius: 10px;
  padding: 1rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.controls label {
  font-weight: 600;
  font-size: 0.95rem;
}

.controls select {
  padding: 0.4rem 0.75rem;
  border: 1.5px solid #cbd5e0;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  background: #f7f8fa;
}

.btn-primary {
  margin-left: auto;
  padding: 0.5rem 1.25rem;
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: #4338ca;
}

/* Preview */
.preview-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
  .preview-section {
    grid-template-columns: 1fr;
  }
}

.preview-pane {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.preview-pane h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #718096;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.preview-pane img,
.preview-pane canvas {
  width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
  image-rendering: pixelated;
}

/* Legend */
.legend-section {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.legend-section h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #718096;
  font-weight: 700;
  margin-bottom: 1rem;
}

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  background: #f7f8fa;
  border-radius: 20px;
  padding: 0.3rem 0.75rem 0.3rem 0.45rem;
}

.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.12);
  flex-shrink: 0;
}

.legend-count {
  color: #718096;
  font-size: 0.8rem;
}
