body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #f4f5f7;
  color: #111827;
  margin: 0;
  padding: 0;
}

/* App Containers */
.app-container {
  max-width: 900px;
  margin: 40px auto;
  padding: 0 20px;
}

.editor-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px;
}

.editor-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 524px;
  margin-bottom: 16px;
}

.sprite-title-input {
  font-size: 16px;
  font-weight: 600;
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 10px;
  border-radius: 6px;
  text-align: right;
}

.sprite-title-input:hover, .sprite-title-input:focus {
  background: #ffffff;
  border-color: #dcdcdc;
  outline: none;
}

/* Gallery Styles */
.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.gallery-header h1 {
  margin: 0;
  font-size: 28px;
}

.subtitle {
  margin: 4px 0 0 0;
  color: #6b7280;
  font-size: 14px;
}

.sprite-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

.sprite-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sprite-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.sprite-card canvas {
  border: 1px solid #eee;
  border-radius: 6px;
  image-rendering: pixelated;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
}

.card-info {
  width: 100%;
  margin-top: 10px;
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sprite-name,
.sprite-name-input {
  font-weight: 600;
  font-size: 14px;
}

.sprite-name-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  border-radius: 6px;
  color: #111827;
  min-width: 0;
}

.sprite-name-input:hover,
.sprite-name-input:focus {
  border-color: #d1d5db;
  background: #ffffff;
  outline: none;
}

.card-name-input {
  flex: 1;
}

.sprite-date {
  font-size: 11px;
  color: #9ca3af;
}

.btn-delete {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.btn-delete:hover {
  background: #fee2e2;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 0;
  color: #6b7280;
}

.preset-section {
  margin-bottom: 32px;
}

.preset-header {
  margin-bottom: 14px;
}

.preset-header h2 {
  margin: 0 0 4px 0;
  font-size: 22px;
}

.preset-header p {
  margin: 0;
  color: #6b7280;
  font-size: 14px;
}

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

.preset-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px 10px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s, box-shadow 0.15s;
  color: #111827;
}

.preset-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.preset-card canvas {
  width: 72px;
  height: 72px;
  border: 1px solid #eee;
  border-radius: 8px;
  background: linear-gradient(45deg, #f3f4f6 25%, transparent 25%), linear-gradient(-45deg, #f3f4f6 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f3f4f6 75%), linear-gradient(-45deg, transparent 75%, #f3f4f6 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  image-rendering: pixelated;
}

.preset-name {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

/* Editor Container */
.editor-container {
  display: flex;
  gap: 24px;
  background: #ffffff;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

canvas {
  border: 1px solid #dcdcdc;
  cursor: crosshair;
  border-radius: 4px;
  image-rendering: pixelated;
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: 180px;
  gap: 20px;
}

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #2e7d32;
  background: #edf7ed;
  padding: 6px 12px;
  border-radius: 20px;
  width: fit-content;
}

.status-badge.saving {
  color: #d97706;
  background: #fef3c7;
}

/* Palette Grid */
.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 8px;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.swatch {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid #e5e7eb;
  cursor: pointer;
  position: relative;
  box-sizing: border-box;
  transition: transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.swatch:hover {
  transform: scale(1.05);
}

.swatch.active {
  border-color: #111827;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.custom-swatch {
  overflow: hidden;
}

.swatch-picker-icon {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: rgba(255, 255, 255, 0.9);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
  pointer-events: none;
}

.swatch-picker-icon svg {
  width: 100%;
  height: 100%;
}

.swatch-color-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.tool-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.tool-btn,
.size-btn {
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #374151;
  border-radius: 6px;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tool-btn:hover,
.size-btn:hover {
  background: #f3f4f6;
}

.tool-btn.active,
.size-btn.active {
  background: #111827;
  color: white;
  border-color: #111827;
}

.size-presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.size-btn:hover {
  background: #f3f4f6;
}

.size-btn.active {
  background: #111827;
  color: white;
  border-color: #111827;
}

.custom-size-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.custom-size-input {
  flex: 1;
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  box-sizing: border-box;
}

.size-multiplier {
  color: #6b7280;
  font-weight: 700;
}

.btn-small {
  padding: 8px 10px;
  font-size: 12px;
}

.full-width {
  width: 100%;
  margin-top: 4px;
}

/* Buttons */
.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  display: inline-block;
}

.btn-primary {
  background: #3b82f6;
  color: white;
}

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

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
}

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