/* Paint Number Maker — 밝고 직관적인 카드형 레이아웃, 모바일 우선 */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: #f6f7fb;
  color: #222;
  line-height: 1.6;
}

main { max-width: 1240px; margin: 0 auto; padding: 0 16px 40px; }

/* PC: 업로드와 옵션을 나란히 배치해 화면을 넓게 사용 */
.setup-grid { margin: 18px 0; }
.setup-grid .card { margin: 18px 0; }
@media (min-width: 960px) {
  .setup-grid {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    gap: 18px;
    align-items: stretch;
  }
  .setup-grid .card { margin: 0; }
}

/* ---------- 히어로 ---------- */
.hero {
  text-align: center;
  padding: 44px 16px 28px;
  background: linear-gradient(160deg, #fef6e4 0%, #e8f4fd 100%);
}
.hero h1 { margin: 0 0 12px; font-size: 1.9rem; }
.hero-sub { margin: 0 0 16px; color: #555; }
.privacy-badge {
  display: inline-block;
  background: #ffffffcc;
  border: 1px solid #dbe4ee;
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 0.85rem;
  color: #33691e;
}

/* ---------- 카드 ---------- */
.card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(30, 50, 90, 0.06);
  padding: 22px 20px;
  margin: 18px 0;
}
.card h2 { margin: 0 0 14px; font-size: 1.25rem; }

/* ---------- 업로드 ---------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 2px dashed #b9c6d8;
  border-radius: 14px;
  padding: 34px 16px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.dragover { border-color: #4a90d9; background: #f0f7ff; }
.dropzone-icon { font-size: 2.2rem; }
.dropzone strong { font-size: 1.1rem; }
.dropzone span { color: #778; font-size: 0.88rem; }
.dropzone-hint { color: #99a; }

.upload-preview { margin-top: 14px; text-align: center; }
.upload-preview canvas {
  max-width: 100%;
  max-height: 320px;
  border-radius: 10px;
  border: 1px solid #e3e8ef;
}

/* ---------- 샘플 ---------- */
.samples h3 { margin: 22px 0 4px; font-size: 1.02rem; }
.samples-note { margin: 0 0 10px; font-size: 0.85rem; color: #789; }
.sample-cats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.cat-chip {
  border: 1px solid #ccd6e4;
  background: #fff;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  color: #456;
  transition: all 0.12s;
}
.cat-chip:hover { border-color: #4a90d9; }
.cat-chip.active { background: #2f6fd0; border-color: #2f6fd0; color: #fff; }
.sample-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.sample-card {
  border: 1px solid #e3e8ef;
  background: #fafbfd;
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: transform 0.12s, box-shadow 0.12s;
}
.sample-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(30,50,90,0.12); }
.sample-card.loading { opacity: 0.5; }
.sample-card img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 8px;
}
.sample-title { display: block; font-weight: 700; font-size: 0.88rem; margin-top: 6px; }
.sample-stats { display: block; font-size: 0.75rem; color: #789; }

/* ---------- 옵션 ---------- */
.opt-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.opt-row > label { width: 70px; font-weight: 700; font-size: 0.92rem; flex-shrink: 0; }
.opt-group { display: flex; gap: 6px; flex-wrap: wrap; }
.opt-group button {
  border: 1px solid #ccd6e4;
  background: #fff;
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}
.opt-group button:hover { border-color: #4a90d9; }
.opt-group button.active {
  background: #2f6fd0;
  border-color: #2f6fd0;
  color: #fff;
  font-weight: 700;
}

.primary-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  background: linear-gradient(135deg, #ff8a3d, #ff6b6b);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  font-family: inherit;
  border: none;
  border-radius: 12px;
  padding: 15px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.primary-btn:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); }
.primary-btn:disabled { background: #ccd3dd; cursor: not-allowed; }

/* ---------- 진행/에러 ---------- */
.progress-box { margin-top: 14px; text-align: center; font-size: 0.9rem; color: #567; }
.progress-bar {
  height: 10px;
  background: #e8edf4;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4a90d9, #7bc96f);
  border-radius: 999px;
  transition: width 0.3s;
}
.error-box {
  margin-top: 14px;
  background: #fdecec;
  border: 1px solid #f5b5b5;
  color: #b33;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.92rem;
}

/* ---------- 결과 ---------- */
#result-section { position: relative; }
.result-loading[hidden] { display: none; }
.result-loading {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(1.5px);
  border-radius: 16px;
  color: #456;
  font-size: 0.9rem;
  font-weight: 700;
}
.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid #dbe4ee;
  border-top-color: #2f6fd0;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result-stats { color: #678; font-size: 0.9rem; margin: -6px 0 12px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab-btn {
  border: 1px solid #ccd6e4;
  background: #fff;
  border-radius: 10px 10px 0 0;
  padding: 9px 16px;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
}
.tab-btn.active { background: #2f6fd0; color: #fff; border-color: #2f6fd0; font-weight: 700; }
/* 미리보기 탭: 완성예시+도안 나란히, 색상표 아래 */
.combo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.combo-item { margin: 0 0 14px; }
.combo-item figcaption {
  font-weight: 700;
  font-size: 0.92rem;
  color: #345;
  margin-bottom: 6px;
  text-align: center;
}
.combo-palette .canvas-host canvas { max-height: 420px; }
@media (max-width: 640px) {
  .combo-grid { grid-template-columns: 1fr; }
}

.canvas-host { text-align: center; overflow: auto; }
.canvas-host canvas {
  max-width: 100%;
  height: auto;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  background: #fff;
}
.dl-row { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.dl-btn {
  border: 1px solid #ccd6e4;
  background: #fff;
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s;
}
.dl-btn:hover { border-color: #4a90d9; background: #f0f7ff; }
.dl-btn.accent { background: #2f6fd0; border-color: #2f6fd0; color: #fff; }
.dl-btn.accent:hover { filter: brightness(1.1); }

/* ---------- 벡터 번호 도안 뷰어 + 색상표 패널 ---------- */
.sheet-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 12px;
  align-items: start;
}
.sheet-palette {
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
  max-height: min(72vh, 640px);
  border: 1px solid #e3e8ef;
  border-radius: 12px;
  padding: 8px;
  background: #fff;
  scrollbar-width: thin;
}
.swatch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px solid transparent;
  background: #fafbfd;
  border-radius: 10px;
  padding: 6px 9px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.86rem;
  text-align: left;
  transition: all 0.12s;
}
.swatch-row:hover { border-color: #b9cdea; }
.swatch-row.active { border-color: #2f6fd0; background: #eef5ff; }
.swatch-row.done { opacity: 0.45; }
.swatch-num { font-weight: 800; min-width: 20px; text-align: center; color: #345; }
.swatch-chip {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
}
.swatch-name { color: #445; }
.swatch-info { margin-left: auto; font-size: 0.76rem; color: #789; font-weight: 700; white-space: nowrap; }
@media (max-width: 860px) {
  .sheet-body { grid-template-columns: 1fr; }
  .sheet-palette {
    flex-direction: row;
    overflow-x: auto;
    max-height: none;
  }
  .swatch-row { flex-shrink: 0; }
  .swatch-name { display: none; }
}

.sheet-svg path.color-hl { fill: #ffefad; }
@keyframes paletteNudge {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 3px #ff8a3d; }
}
.sheet-palette.nudge { animation: paletteNudge 0.5s ease 2; }

.sheet-menubar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: #f4f6fa;
  border: 1px solid #e3e8ef;
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 10px;
}
.sheet-menubar button {
  border: 1px solid #ccd6e4;
  background: #fff;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s;
}
.sheet-menubar button:hover:not(:disabled) { border-color: #4a90d9; background: #f0f7ff; }
.sheet-menubar button:disabled { opacity: 0.4; cursor: default; }
.sheet-menubar button.active { background: #2f6fd0; border-color: #2f6fd0; color: #fff; }
.menubar-check {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.86rem;
  font-weight: 700;
  color: #456;
  cursor: pointer;
  padding: 0 4px;
  user-select: none;
}
.menubar-check input { accent-color: #2f6fd0; cursor: pointer; }
.menubar-gap { flex: 1; }
.sv-progress { font-size: 0.84rem; color: #567; font-weight: 700; padding: 0 4px; }

/* 완성 축하 효과 */
.confetti-canvas {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}
.congrats-banner {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 21;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid #ffd54d;
  border-radius: 999px;
  padding: 14px 34px;
  font-size: 1.5rem;
  font-weight: 800;
  color: #333;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  animation: bannerPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes bannerPop {
  from { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.sheet-viewer {
  position: relative;
  border: 1px solid #e3e8ef;
  border-radius: 12px;
  background: #fafbfd;
  overflow: hidden;
  touch-action: none;   /* 핀치/드래그를 뷰어가 직접 처리 */
  cursor: grab;
  height: min(72vh, 640px);
}
.sheet-viewer:active { cursor: grabbing; }
.sheet-svg { width: 100%; height: 100%; display: block; background: #fff; }
.sheet-svg text { user-select: none; pointer-events: none; paint-order: stroke; stroke: rgba(255,255,255,0.8); stroke-width: 0.35px; }
.sheet-svg text.painted { opacity: 0.25; }
.sheet-svg path.hint-pulse { animation: hintPulse 0.8s ease-in-out 3; }
@keyframes hintPulse {
  0%, 100% { fill: #ffffff; }
  50% { fill: #ffd54d; }
}

/* ---------- 자동 색칠 데모 ---------- */
.demo-desc { color: #678; font-size: 0.9rem; margin: 0 0 12px; }
.demo-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.order-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #456;
}
.order-box select {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px 10px;
  border: 1px solid #ccd6e4;
  border-radius: 10px;
  background: #fff;
  color: #223;
  cursor: pointer;
}
.speed-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #456;
  flex: 1;
  min-width: 220px;
}
.speed-box input[type="range"] { flex: 1; accent-color: #2f6fd0; }
.speed-box b { min-width: 42px; text-align: right; }
.demo-progress { margin-bottom: 12px; font-size: 0.85rem; color: #567; text-align: center; }

.demo-wrap { position: relative; }
.demo-palette {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 4px 12px;
  scrollbar-width: thin;
}
.demo-swatch {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.demo-swatch span {
  background: rgba(255,255,255,0.85);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 1px 7px;
  color: #223;
}
.demo-swatch.active {
  transform: scale(1.25);
  box-shadow: 0 0 0 3px #2f6fd0, 0 2px 8px rgba(0,0,0,0.3);
}
.demo-canvas-box { text-align: center; overflow: hidden; }
.demo-canvas-box canvas {
  max-width: 100%;
  height: auto;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
}
.demo-cursor {
  position: absolute;
  left: 0; top: 0;
  z-index: 5;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.35));
  will-change: transform;
}

/* ---------- 광고 placeholder ---------- */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  margin: 18px 0;
  background: repeating-linear-gradient(45deg, #f2f4f8, #f2f4f8 12px, #eceff5 12px, #eceff5 24px);
  border: 1px dashed #ccd6e4;
  border-radius: 12px;
  color: #9aa8bb;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---------- SEO ---------- */
.seo-section h3 { font-size: 1.05rem; margin: 20px 0 6px; }
.seo-section p, .seo-section li { font-size: 0.94rem; color: #445; }

footer {
  text-align: center;
  padding: 26px 16px 40px;
  color: #8a97a8;
  font-size: 0.82rem;
}

@media (max-width: 640px) {
  .hero h1 { font-size: 1.45rem; }
  .card { padding: 18px 14px; }
  .opt-row > label { width: 100%; margin-bottom: -4px; }
  .sample-grid { grid-template-columns: repeat(2, 1fr); }
}
