:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #0d7d8c;
  --accent-ink: #ffffff;
  --danger: #b42318;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  padding: 0 16px calc(32px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Segoe UI", sans-serif;
  max-width: 560px;
  margin-inline: auto;
}

.top { padding: calc(24px + env(safe-area-inset-top)) 4px 16px; }
.top h1 { margin: 0; font-size: 24px; letter-spacing: -0.02em; }
.top p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 14px;
}
.card h2 {
  margin: 0 0 14px;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.num {
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px; font-weight: 700;
}

/* --- 사진 --- */
.shot {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  background: #eef1f4;
  border: 1px dashed var(--line);
  overflow: hidden;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
}
.shot img { width: 100%; height: 100%; object-fit: cover; display: none; }
.shot img.on { display: block; }
.shot-empty { color: var(--muted); font-size: 14px; padding: 0 24px; text-align: center; }

/* --- 버튼 --- */
.row { display: flex; gap: 10px; }
.row.between { justify-content: space-between; align-items: center; margin-bottom: 14px; }
.btn {
  flex: 1;
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 13px 14px;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn:active { transform: scale(0.985); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { background: #cbd5dd; border-color: #cbd5dd; cursor: not-allowed; }
.btn.ghost { flex: 0 0 auto; padding: 8px 12px; font-size: 13px; color: var(--muted); }
.btn.wide { width: 100%; }

/* --- 치아 차트 --- */
.chart { padding: 4px 0 10px; }
.arch { display: flex; justify-content: center; gap: 4px; padding: 14px 0; }
.tooth {
  flex: 1 1 0;
  min-width: 0;
  aspect-ratio: 3 / 4;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 6px 6px 9px 9px;
  color: var(--muted);
  font: 600 11px/1 inherit;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: background .12s, border-color .12s, color .12s;
}
.tooth[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.arch-label { font-size: 12px; color: var(--muted); text-align: center; font-weight: 600; }
.arch-label span { font-weight: 400; opacity: .7; }
.mid {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 6px;
}
.count { font-size: 14px; color: var(--muted); font-weight: 600; }

/* --- 진행 --- */
.spinner {
  width: 32px; height: 32px; margin: 6px auto 14px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.stage { margin: 0; text-align: center; font-weight: 600; }
.elapsed { margin: 4px 0 0; text-align: center; color: var(--muted); font-size: 13px; }

/* --- 비교 --- */
.compare {
  position: relative;
  width: 100%;
  aspect-ratio: var(--ar, 3 / 4);
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  touch-action: none;
  user-select: none;
  margin-bottom: 10px;
}
.compare img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
#imgBefore { clip-path: inset(0 calc(100% - var(--pos, 50%)) 0 0); }
.tag {
  position: absolute; top: 10px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  background: rgba(16, 24, 40, .62);
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
}
.tag.left { left: 10px; }
.tag.right { right: 10px; }
.handle {
  position: absolute; top: 0; bottom: 0;
  left: var(--pos, 50%);
  width: 2px;
  background: rgba(255, 255, 255, .9);
  transform: translateX(-1px);
  pointer-events: none;
}
.handle i {
  position: absolute; top: 50%; left: 50%;
  width: 36px; height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}
.handle i::before, .handle i::after {
  content: ""; position: absolute; top: 50%; margin-top: -4px;
  border: 4px solid transparent;
}
.handle i::before { left: 7px; border-right-color: var(--accent); }
.handle i::after { right: 7px; border-left-color: var(--accent); }

.hint { margin: 0 0 6px; text-align: center; color: var(--muted); font-size: 13px; }
.disclaimer {
  margin: 0 0 14px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 8px 10px;
}

.error {
  background: #fef3f2;
  border: 1px solid #fecdca;
  color: var(--danger);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  margin: 0 0 14px;
  white-space: pre-wrap;
}

.note {
  margin: 0 0 10px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  background: #f2f4f7;
  border-radius: 8px;
  padding: 8px 10px;
}

.btn.ghost.wide { width: 100%; margin-top: 10px; }
.samples { display: flex; gap: 8px; margin-top: 12px; }
.samples button {
  flex: 1 1 0;
  min-width: 0;
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0 0 7px;
  cursor: pointer;
  overflow: hidden;
  font: 600 11px/1.3 inherit;
  color: var(--muted);
}
.samples img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  margin-bottom: 6px;
}
.samples button:active { transform: scale(0.985); }

/* v2 표시. v1에는 이 요소가 없어 영향 없음 */
.badge {
  display: inline-block;
  vertical-align: 3px;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}

/* v2 실시간 미백. v1에는 이 요소들이 없어 영향 없음 */
.compare canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.whiten { margin: 0 0 14px; }
.whiten label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 14px; font-weight: 600; margin-bottom: 8px;
}
.whiten label b { color: var(--accent); font-variant-numeric: tabular-nums; }
.whiten input[type="range"] {
  width: 100%; margin: 0;
  accent-color: var(--accent);
}
.whiten .sub { margin: 8px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
