:root {
  --green: #16a34a;
  --green-dark: #15803d;
  --green-light: #dcfce7;
  --red: #dc2626;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

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

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic",
               "맑은 고딕", "Noto Sans KR", sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  background: #fff;
  display: flex;
  flex-direction: column;
}

/* ---- 헤더 / 진행바 ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 14px 18px 10px;
}
.topbar h1 { margin: 0; font-size: 16px; font-weight: 800; color: var(--green-dark); }
.topbar .sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* ---- 언어 전환 (KO/EN/DE) ---- */
.lang-switch {
  flex: 0 0 auto; display: flex; gap: 2px;
  background: var(--gray-100); border-radius: 999px; padding: 3px;
}
.lang-switch button {
  border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 11.5px; font-weight: 700; color: var(--gray-500);
  padding: 5px 9px; border-radius: 999px; line-height: 1; white-space: nowrap;
  transition: all .12s ease;
}
.lang-switch button.on { background: var(--green); color: #fff; }
.lang-switch button:not(.on):active { background: var(--gray-200); }
.progress-track { height: 6px; background: var(--gray-200); border-radius: 999px; margin-top: 10px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); width: 0; transition: width .3s ease; }
.autosave { font-size: 11px; color: var(--gray-400); margin-top: 6px; height: 14px; }

/* ---- 본문 ---- */
.content { flex: 1; padding: 20px 18px 24px; }
.section-title { font-size: 20px; font-weight: 800; margin: 0 0 6px; }
.section-intro {
  font-size: 13.5px; color: var(--gray-700); background: var(--gray-50);
  border: 1px solid var(--gray-200); border-radius: var(--radius);
  padding: 14px; margin-bottom: 20px; white-space: pre-line;
}

/* ---- 질문 카드 ---- */
.q { margin-bottom: 26px; }
.q-title { font-size: 15.5px; font-weight: 700; margin-bottom: 4px; }
.q-title .req { color: var(--red); margin-left: 3px; }
.q-desc { font-size: 13px; color: var(--gray-500); white-space: pre-line; margin-bottom: 12px; }

/* 옵션(라디오/체크) */
.opt {
  display: flex; align-items: center; gap: 12px;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer;
  font-size: 14.5px; transition: all .12s ease; background: #fff;
}
.opt:hover { border-color: var(--gray-400); }
.opt.checked { border-color: var(--green); background: var(--green-light); font-weight: 600; }
.opt input { display: none; }
.opt .mark {
  flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--gray-400); display: grid; place-items: center;
}
.opt.is-multi .mark { border-radius: 6px; }
.opt.checked .mark { border-color: var(--green); background: var(--green); }
.opt.checked .mark::after { content: "✓"; color: #fff; font-size: 13px; font-weight: 900; }
.opt .label { flex: 1; }

/* 입력 필드 */
.field {
  width: 100%; padding: 14px 16px; font-size: 15px;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius);
  font-family: inherit; background: #fff;
}
.field:focus { outline: none; border-color: var(--green); }
textarea.field { min-height: 90px; resize: vertical; }
.addr-row { display: flex; gap: 8px; }
.addr-row .field { flex: 1; background: var(--gray-50); }
.btn-addr {
  flex: 0 0 92px; border: none; border-radius: var(--radius);
  background: var(--gray-900); color: #fff; font-weight: 700; font-size: 14px;
  cursor: pointer; font-family: inherit;
}
.btn-addr:active { opacity: .85; }
/* ---- 서명 패드 ---- */
.sig-wrap {
  border: 1.5px solid var(--gray-200); border-radius: var(--radius);
  padding: 8px; background: #fff;
}
.sig-canvas {
  width: 100%; height: 170px; display: block;
  border: 1px dashed var(--gray-200); border-radius: 8px;
  background: #fcfcfd; touch-action: none; cursor: crosshair;
}
.sig-tools { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.sig-hint { font-size: 12px; color: var(--gray-400); }
.sig-clear {
  border: none; background: var(--gray-100); color: var(--gray-700);
  border-radius: 8px; padding: 6px 12px; font-weight: 700; font-size: 13px;
  cursor: pointer; font-family: inherit;
}
.q.invalid .sig-canvas { border-color: var(--red); }

.field-err { color: var(--red); font-size: 12.5px; margin-top: 6px; display: none; }
.q.invalid .field-err { display: block; }
.q.invalid .field, .q.invalid .opt { border-color: var(--red); }

/* ---- 하단 버튼 ---- */
.footer {
  position: sticky; bottom: 0; background: #fff;
  border-top: 1px solid var(--gray-200); padding: 14px 18px;
  display: flex; gap: 10px;
}
.btn {
  flex: 1; padding: 15px; border: none; border-radius: var(--radius);
  font-size: 15.5px; font-weight: 700; cursor: pointer; font-family: inherit;
  white-space: nowrap; word-break: keep-all;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:active { background: var(--green-dark); }
.btn-ghost { background: var(--gray-100); color: var(--gray-700); flex: 0 0 auto; min-width: 96px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- 결과 화면 ---- */
.result { text-align: center; padding: 40px 24px; }
.result .emoji { font-size: 60px; margin-bottom: 8px; }
.result h2 { font-size: 24px; margin: 0 0 8px; }
.result.pass h2 { color: var(--green-dark); }
.result.fail h2 { color: var(--red); }
.score-box {
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 18px; margin: 20px 0; text-align: left;
}
.score-row { display: flex; justify-content: space-between; font-size: 14px; padding: 5px 0; }
.score-row.total { font-weight: 800; font-size: 16px; border-top: 1px solid var(--gray-200); margin-top: 6px; padding-top: 10px; }
.result p { color: var(--gray-700); font-size: 14px; }
.flags { text-align: left; font-size: 13px; color: var(--gray-500); margin-top: 10px; }
.banner {
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  border-radius: var(--radius); padding: 12px 14px; font-size: 13px; margin-bottom: 16px;
}
.hidden { display: none !important; }

/* ---- 주소 검색 오버레이 (embed) ---- */
.pc-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center; padding: 12px;
}
.pc-modal {
  background: #fff; width: 100%; max-width: 520px;
  height: 88vh; max-height: 680px; border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.pc-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--gray-200); font-weight: 700;
}
.pc-close {
  border: none; background: var(--gray-100); color: var(--gray-700);
  border-radius: 8px; padding: 8px 12px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.pc-embed { flex: 1; min-height: 0; }

/* ── 본인 인증 블록 ── */
.vbox { border: 1.5px solid #16336e; background: #f5f8ff; border-radius: 14px;
  padding: 16px 16px 18px; box-shadow: 0 2px 10px rgba(22,51,110,.06); }
.vbox .q-desc { margin-bottom: 4px; }
.vres { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 6px; }
.vopt { display: flex; align-items: center; gap: 8px; padding: 11px 13px; border: 1px solid #cdd8ea;
  border-radius: 10px; background: #fff; cursor: pointer; font-weight: 600; }
.vopt.on { border-color: #16336e; background: #eaf1ff; }
.vopt input { width: 17px; height: 17px; accent-color: #16336e; }
.vrow { display: flex; gap: 8px; margin-top: 9px; }
.vinput { flex: 1; padding: 12px 13px; border: 1px solid #cbd5e1; border-radius: 9px;
  font-size: 15px; font-family: inherit; min-width: 0; }
.vbtn { padding: 0 16px; border: 0; border-radius: 9px; background: #16336e; color: #fff;
  font-weight: 700; cursor: pointer; white-space: nowrap; font-family: inherit; font-size: 14px; }
.vbtn.ok { background: #1f8a4c; }
.vbtn:disabled { opacity: .6; cursor: default; }
.vmsg { margin-top: 9px; font-size: 13px; line-height: 1.5; }
.vmsg.ok { color: #1f6b3a; }
.vmsg.err { color: #c0392b; }
.vdone { margin-top: 11px; padding: 12px; border-radius: 10px; background: #e7f6ec;
  color: #1f8a4c; font-weight: 800; text-align: center; }
