* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  background: #f5f3ef;
  color: #333;
  line-height: 1.6;
}
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px;
}
header {
  text-align: center;
  margin-bottom: 32px;
}
header h1 {
  font-size: 1.8rem;
  color: #2c2c2c;
}
.subtitle {
  color: #888;
  font-size: 0.95rem;
}
.en {
  color: #999;
  font-size: 0.85em;
}
h2, h3 {
  margin: 16px 0 8px;
  color: #444;
}

/* Upload */
.drop-zone {
  border: 2px dashed #bbb;
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: #fff;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: #666;
  background: #faf8f5;
}
.drop-icon {
  font-size: 2.4rem;
  color: #aaa;
  margin-bottom: 8px;
}
.preview-row {
  margin-top: 16px;
  text-align: center;
}
.preview-canvas {
  max-width: 100%;
  max-height: 240px;
  border: 1px solid #ddd;
  border-radius: 8px;
}
.preview-label {
  color: #888;
  font-size: 0.85rem;
  margin-top: 4px;
}

/* Settings */
.settings-section {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-top: 20px;
}
.settings-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}
.setting label {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 4px;
}
.setting input[type="range"] {
  width: 100%;
}
.setting select, .setting input[type="number"] {
  width: 100%;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
}
.btn-primary {
  display: inline-block;
  background: #2a6cb6;
  color: #fff;
  border: none;
  padding: 12px 32px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover { background: #1e558f; }
.btn-primary:disabled { background: #aaa; cursor: default; }
.btn-secondary {
  display: inline-block;
  background: #eee;
  color: #333;
  border: 1px solid #ccc;
  padding: 12px 32px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-secondary:hover { background: #ddd; }

/* Progress */
.progress-section {
  text-align: center;
  padding: 48px;
}
.spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid #ddd;
  border-top-color: #2a6cb6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Results */
.results-section {
  margin-top: 24px;
}
.stitch-canvas {
  width: 100%;
  max-height: 480px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #f5f0e8;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.stat {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.stat-label {
  display: block;
  font-size: 0.8rem;
  color: #888;
}
.stat-value {
  display: block;
  font-size: 1.3rem;
  font-weight: 600;
  color: #333;
}
.color-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.color-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  padding: 8px 12px;
  border-radius: 8px;
}
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid #ccc;
  flex-shrink: 0;
}
.color-info {
  flex: 1;
  font-size: 0.9rem;
}
.color-stitches {
  color: #888;
  font-size: 0.85rem;
}
.download-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* Tips */
.tips-section {
  margin-top: 32px;
  padding: 16px;
  background: #fff;
  border-radius: 12px;
}
.tips-section ul {
  list-style: disc;
  padding-left: 24px;
}
.tips-section li {
  font-size: 0.9rem;
  margin-bottom: 4px;
}

/* Footer */
footer {
  margin-top: 32px;
  text-align: center;
  font-size: 0.8rem;
  color: #aaa;
}

@media (max-width: 480px) {
  .container { padding: 16px 12px; }
  header h1 { font-size: 1.4rem; }
  .drop-zone { padding: 32px 16px; }
}

/* --- What-works guide --- */
.guide-section { margin-bottom: 24px; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.guide-card { border-radius: 8px; padding: 12px 14px; background: #fff; border: 1px solid #e3ddd3; }
.guide-card h3 { margin: 0 0 6px; font-size: 1rem; }
.guide-card p { margin: 4px 0; font-size: 0.9rem; line-height: 1.45; }
.guide-card.good { border-left: 4px solid #3a9a5b; }
.guide-card.bad { border-left: 4px solid #c8553d; }
.guide-card.line { border-left: 4px solid #5a4636; }
.examples { margin-top: 14px; }
.examples-title { margin: 0 0 8px; font-weight: 600; }
.example-row { display: flex; gap: 12px; flex-wrap: wrap; }
.example-row figure { margin: 0; text-align: center; }
.example-row img { width: 120px; height: 120px; border: 1px solid #e3ddd3; border-radius: 6px; background: #fff; }
.example-row figcaption { font-size: 0.85rem; margin-top: 4px; }
.drop-note { font-size: 0.85rem; opacity: 0.75; margin-top: 6px; }

/* --- Mode toggle --- */
.mode-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.mode-option { flex: 1 1 220px; border: 1px solid #e3ddd3; border-radius: 8px; padding: 10px 12px; cursor: pointer; background: #fff; }
.mode-option:has(input:checked) { border-color: #5a4636; box-shadow: 0 0 0 1px #5a4636 inset; }
.mode-option small { display: block; margin-top: 4px; opacity: 0.75; }
