:root {
  --bg-color: #f8fafc;
  --text-color: #1e293b;
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --secondary-color: #64748b;
  --secondary-hover: #475569;
  --border-color: #e2e8f0;
  --panel-bg: #ffffff;
  --accent-color: #fde68a;
  --accent-text: #b45309;
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

header {
  text-align: center;
  padding: 3rem 1rem 2rem;
  background: white;
  border-bottom: 1px solid var(--border-color);
}

h1 {
  margin: 0 0 0.5rem 0;
  color: var(--primary-color);
  font-size: 1.8rem;
}

header p {
  color: var(--secondary-color);
  margin: 0;
}

.container {
  max-width: 900px;
  width: 95%;
  margin: 2rem auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* 공통 섹션 스타일 */
.step-section {
  background: var(--panel-bg);
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  border: 1px solid var(--border-color);
}

.section-title {
  margin-bottom: 1.5rem;
  text-align: center;
}

.section-title h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.3rem;
  color: var(--text-color);
}

.instruction {
  font-size: 0.9rem;
  color: var(--secondary-color);
  margin: 0;
}

/* 업로드 영역 */
.upload-section {
  text-align: center;
}

.main-label {
  display: block;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

input[type="file"] {
  border: 2px dashed var(--border-color);
  padding: 2rem;
  width: 100%;
  border-radius: 12px;
  box-sizing: border-box;
  cursor: pointer;
  background: #f1f5f9;
}

/* 설정 영역 그리드 */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
}

select, input[type="number"] {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  width: 100%;
  box-sizing: border-box;
}

.input-with-hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.input-with-hint input {
  width: 100px;
}

.hint {
  font-size: 0.9rem;
  color: var(--secondary-color);
}

.checkbox-group {
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding-top: 1rem;
}

/* 버튼 영역 */
.action-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  border-top: 1px solid var(--border-color);
  padding-top: 2rem;
}

.generator-hint {
  background-color: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  font-size: 0.85rem;
}

button {
  padding: 1rem 2.5rem;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  max-width: 400px;
}

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

.primary-btn:hover:not(:disabled) {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

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

.secondary-btn:hover:not(:disabled) {
  background-color: var(--secondary-hover);
}

.small-btn {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  width: auto;
  border-radius: 6px;
}

/* 캔버스 공통 */
.canvas-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: auto;
  padding: 1rem;
  margin-bottom: 1.5rem;
  min-height: 200px;
}

.placeholder-msg {
  color: var(--secondary-color);
  font-style: italic;
  font-size: 1rem;
}

canvas {
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  image-rendering: pixelated;
  cursor: crosshair;
}

/* 돋보기 */
.magnifier-canvas {
  position: absolute;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(0,0,0,0.4);
  pointer-events: none;
  display: none;
  z-index: 100;
  background-color: #fff;
}

/* 필수 색상 리스트 */
.seed-colors-area {
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
  width: 100%;
}

.seed-colors-area h3 {
  font-size: 1rem;
  margin: 0 0 1rem 0;
}

.color-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.color-item, .seed-color-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f8fafc;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.color-box {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.1);
  position: relative;
}

.removable-box {
  cursor: pointer;
}

.removable-box:hover::after {
  content: "×";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(239, 68, 68, 0.8);
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  border-radius: 6px;
}

/* 결과 패널 히스토리 */
.history-thumbnails {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.5rem 0 1.5rem;
}

.history-item {
  width: 70px;
  height: 70px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  object-fit: cover;
  image-rendering: pixelated;
  transition: all 0.2s;
}

.history-item.active {
  border-color: var(--primary-color);
  transform: scale(1.05);
}

.pattern-info-text {
  font-size: 0.95rem;
  color: var(--secondary-color);
  margin-top: 0;
  margin-bottom: 1rem;
}

@media (max-width: 600px) {
  header {
    padding: 2rem 1rem 1.5rem;
  }
  h1 {
    font-size: 1.5rem;
  }
  .step-section {
    padding: 1.5rem;
  }
}