:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --text: #1f1b16;
  --text-muted: #6b6055;
  --accent: #8a4b2f;
  --accent-soft: #f1e3d8;
  --border: #e7ddd1;
  --danger: #b3402f;
  --shadow: 0 10px 30px rgba(50, 30, 10, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16130f;
    --surface: #221d17;
    --text: #f2ece3;
    --text-muted: #b8ab9b;
    --accent: #d99a6c;
    --accent-soft: #362a1e;
    --border: #3a3025;
    --danger: #e2796a;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

:root[data-theme="light"] {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --text: #1f1b16;
  --text-muted: #6b6055;
  --accent: #8a4b2f;
  --accent-soft: #f1e3d8;
  --border: #e7ddd1;
  --danger: #b3402f;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #16130f;
  --surface: #221d17;
  --text: #f2ece3;
  --text-muted: #b8ab9b;
  --accent: #d99a6c;
  --accent-soft: #362a1e;
  --border: #3a3025;
  --danger: #e2796a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", sans-serif;
  line-height: 1.6;
  overscroll-behavior-y: none;
}

body {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 16px 20px 8px;
}

.app-title { font-weight: 800; font-size: 1.55rem; }
.app-subtitle { font-size: 0.74rem; color: var(--text-muted); line-height: 1.4; }

main {
  flex: 1;
  padding: 8px 20px 24px;
}

.app-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 14px 20px 24px;
}

.screen { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px 20px;
  box-shadow: var(--shadow);
}

.card.center { text-align: center; }

h1 { font-size: 1.4rem; line-height: 1.4; margin: 0 0 14px; }
h2 { font-size: 1.2rem; margin: 0 0 14px; }
h3 { font-size: 1rem; margin: 0 0 8px; }

.lead { color: var(--text-muted); margin: 0 0 16px; font-size: 0.94rem; }

.feature-list {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.9rem;
}

.consent-list {
  padding-left: 20px;
  margin: 0 0 18px;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.disclaimer-inline {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 12px 0 18px;
}

.disclaimer-inline a { color: var(--accent); }

.btn-primary {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  padding: 13px;
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.92rem;
  cursor: pointer;
}

.btn-secondary-link {
  display: block;
  text-align: center;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
}

.consent-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9rem;
  margin-bottom: 18px;
}
.consent-checkbox-row input { margin-top: 3px; width: 18px; height: 18px; }

/* --- 촬영 화면 --- */
.capture-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #000;
  border-radius: 20px;
  overflow: hidden;
  margin-top: 8px;
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* 셀피 미리보기용 좌우 반전(표시만, 실제 인식 프레임에는 영향 없음) */
}

.face-guide-oval {
  position: absolute;
  inset: 12% 20%;
  border: 2px dashed rgba(255, 255, 255, 0.55);
  border-radius: 50% / 40%;
  pointer-events: none;
}

.hold-ring {
  position: absolute;
  bottom: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--progress, 0) * 360deg), rgba(255,255,255,0.25) 0);
  transition: background 0.05s linear;
}

.step-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 6px;
}
.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}
.step-dot.active { background: var(--accent); transform: scale(1.3); }
.step-dot.done { background: var(--accent); opacity: 0.5; }

.step-instruction {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  margin: 8px 0 2px;
}
.step-sub {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 10px;
}
.no-face-hint {
  text-align: center;
  font-size: 0.85rem;
  color: var(--danger);
  margin: 0 0 10px;
}

.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid var(--accent-soft);
  border-top-color: var(--accent);
  margin: 0 auto 16px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- 리포트 --- */
.report-head { padding: 4px 2px 10px; }
.report-coverage { font-size: 0.8rem; color: var(--text-muted); }

.report-sections {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 18px 16px;
}
.report-card.qualitative { border-style: dashed; }

.report-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.source-badge {
  font-size: 0.7rem;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.report-desc {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin: 6px 0 10px;
}

.report-text-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.92rem;
}

.ear-photo-row {
  display: flex;
  gap: 10px;
  margin: 10px 0 4px;
  overflow-x: auto;
}
.ear-photo-fig {
  margin: 0;
  flex: 1 0 auto;
  min-width: 45%;
  text-align: center;
}
.ear-photo-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.ear-photo-fig figcaption {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.ear-checklist {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
}
.ear-checklist-item strong {
  color: var(--accent);
  margin-right: 4px;
}

.samjeong-bar {
  display: flex;
  height: 14px;
  border-radius: 8px;
  overflow: hidden;
  margin: 4px 0 12px;
}
.samjeong-upper { background: #cf9c6d; }
.samjeong-middle { background: #a9673f; }
.samjeong-lower { background: #7a4527; }

.infographic-card { margin-top: 14px; }
.infographic-preview-wrap {
  margin: 10px 0 14px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
}
.infographic-canvas {
  display: block;
  width: 100%;
  height: auto;
}

.disclaimer-card { margin-top: 18px; }
.disclaimer-card p { font-size: 0.8rem; color: var(--text-muted); margin: 0 0 8px; }

.report-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}
