* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f5f5f5;
  color: #333;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

h1 {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.subtitle {
  text-align: center;
  color: #777;
  margin-bottom: 2rem;
}

/* ---------- 上传区 ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.upload-area {
  flex: 1 1 300px;
  border: 2px dashed #bbb;
  border-radius: 12px;
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: #fff;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: #4a90d9;
  background: #eef4fb;
}

.upload-area p {
  color: #888;
  font-size: 0.95rem;
}

.upload-preview {
  display: block;
  max-width: 100%;
  max-height: 200px;
  margin: 0 auto 0.75rem;
  border-radius: 8px;
  object-fit: contain;
}

/* ---------- 设置面板 ---------- */
.settings {
  flex: 1 1 240px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #fff;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.settings label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.settings input,
.settings select {
  padding: 0.45rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.9rem;
}

#generateBtn {
  padding: 0.6rem;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  background: #4a90d9;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

#generateBtn:disabled {
  background: #b0c4de;
  cursor: not-allowed;
}

#generateBtn:not(:disabled):hover {
  background: #357abd;
}

/* ---------- 预览 ---------- */
.preview-section {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.preview-section h2 {
  margin-bottom: 0.5rem;
}

.bead-info {
  font-size: 1rem;
  color: #444;
  background: #f0f7ff;
  border-left: 4px solid #4a90d9;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  border-radius: 4px;
}

.preview-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: center;
}

.preview-col {
  text-align: center;
}

.preview-col h3 {
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  color: #555;
}

.preview-col canvas {
  border: 1px solid #ddd;
  border-radius: 4px;
  image-rendering: pixelated;
}

.preview-col--bead {
  flex: 1 1 100%;
}

/* ---------- 缩略图 ---------- */
.thumbnail-section {
  margin-bottom: 1rem;
}

.thumbnail-section h4 {
  font-size: 0.95rem;
  color: #555;
  margin-bottom: 0.5rem;
}

.thumbnail-wrap {
  background: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1rem;
}

.thumbnail-wrap img {
  max-width: 100%;
  max-height: 50vh;
  border-radius: 4px;
  display: block;
}

.preview-col--bead h4 {
  font-size: 0.95rem;
  color: #555;
  margin-bottom: 0.5rem;
}

/* ---------- 图纸详情区 ---------- */
.detail-section {
  margin: 1rem 0;
  text-align: center;
}

.detail-section h4 {
  font-size: 0.95rem;
  color: #555;
  margin-bottom: 0.5rem;
}

.canvas-scroll-wrapper {
  overflow: auto;
  max-height: 60vh;
  border: 1px solid #ddd;
  border-radius: 4px;
  display: inline-block;
  max-width: calc(100% - 8rem);
  vertical-align: top;
}

.canvas-scroll-wrapper canvas {
  border: none;
  display: block;
}

/* ---------- 操作栏 ---------- */
.action-bar {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 1.25rem 0;
}

.btn-download,
.btn-export {
  padding: 0.6rem 1.6rem;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-download {
  background: #27ae60;
}

.btn-download:hover {
  background: #1e8e4e;
}

.btn-export {
  background: #3498db;
}

.btn-export:hover {
  background: #2980b9;
}

/* ---------- 颜色汇总 ---------- */
.color-summary {
  margin-top: 1.5rem;
}

.color-summary h3 {
  margin-bottom: 0.75rem;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.stats-table th,
.stats-table td {
  padding: 0.4rem 0.65rem;
  border: 1px solid #e5e5e5;
  text-align: center;
}

.stats-table th {
  background: #f0f0f0;
  font-weight: 600;
}

.stats-table tr:hover {
  background: #fafafa;
}

.stats-table .swatch-cell {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: inline-block;
  vertical-align: middle;
  border: 1px solid #ccc;
}

.color-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.color-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

.color-chip .swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #ccc;
  flex-shrink: 0;
}
