:root {
  --blue: #1c3f8f;
  --blue-dark: #0f2a63;
  --blue-soft: #eef2fb;
  --gold: #f0a825;
  --gold-soft: #fdf3e0;
  --bg: #f3f5fa;
  --text: #1e2430;
  --muted: #667085;
  --border: #dfe4ee;
  --error: #d93c33;
  --error-soft: #fdeeed;
  --radius-lg: 20px;
  --radius-md: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---- header ---- */
.topbar {
  background: #fff;
  padding: 10px 20px;
  display: flex;
  justify-content: center;
}
.logo-img { height: 56px; width: auto; display: block; }

/* ---- hero + stepper ---- */
.hero {
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 100%);
  color: #fff;
  text-align: center;
  padding: 30px 20px 84px;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.3px;
  line-height: 1.25;
}
.hero h1::after {
  content: "";
  display: block;
  width: 48px;
  height: 4px;
  border-radius: 2px;
  background: var(--gold);
  margin: 12px auto 0;
}
.hero p {
  margin: 14px auto 24px;
  max-width: 460px;
  font-size: 14.5px;
  line-height: 1.55;
  color: rgba(255, 255, 255, .88);
}

.steps {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 340px;
  display: flex;
  justify-content: space-between;
}
.step {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: rgba(255, 255, 255, .7);
}
/* đường nối giữa các bước */
.step + .step::before {
  content: "";
  position: absolute;
  top: 14px;
  right: 50%;
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, .3);
}
.step.done + .step::before,
.step.current::before { background: var(--gold); }

.dot {
  position: relative;
  z-index: 1;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .45);
  background: var(--blue);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .25s, border-color .25s, color .25s;
}
.step.current { color: #fff; font-weight: 600; }
.step.current .dot { background: #fff; border-color: #fff; color: var(--blue-dark); }
.step.done { color: #fff; }
.step.done .dot { background: var(--gold); border-color: var(--gold); color: var(--blue-dark); }

/* ---- layout ---- */
.wrap {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 44px;
  margin-top: -56px;
}

/* ---- card ---- */
.card {
  background: #fff;
  width: 100%;
  max-width: 560px;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 44px -22px rgba(15, 42, 99, .35);
  padding: 34px 32px;
}

.screen { display: none; }
.screen.active { display: block; animation: fadeIn .35s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.title {
  margin: 0 0 6px;
  font-size: 21px;
  color: var(--blue-dark);
  font-weight: 700;
  text-align: center;
  line-height: 1.35;
  letter-spacing: -.2px;
}
.title:focus { outline: none; }

.subtitle {
  margin: 0 0 26px;
  color: var(--muted);
  text-align: center;
  font-size: 14.5px;
  line-height: 1.6;
}

.greeting {
  margin: 0 0 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

/* ---- form fields ---- */
.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 7px;
  font-size: 14px;
}
.optional { font-weight: 400; color: var(--muted); }
.req { color: var(--error); }

.field input,
.field textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 16px; /* >=16px để iOS không tự phóng to khi chạm vào ô nhập */
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder,
.field textarea::placeholder { color: #9aa1b2; }

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3.5px var(--blue-soft);
}
.field textarea { resize: vertical; min-height: 96px; }

.char-count {
  display: block;
  text-align: right;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.error-msg {
  display: none;
  color: var(--error);
  font-size: 13px;
  margin-top: 6px;
  font-weight: 500;
}
.field.invalid input { border-color: var(--error); box-shadow: 0 0 0 3.5px var(--error-soft); }
.field.invalid .error-msg,
.question.invalid .error-msg { display: block; }

/* ---- tiến độ khảo sát (dính ở đầu khi cuộn) ---- */
.progress {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 -6px 22px;
  padding: 10px 6px 12px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.progress-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--blue-dark);
  margin-bottom: 7px;
}
.progress-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--blue-soft);
  overflow: hidden;
}
.progress-bar span {
  display: block;
  height: 100%;
  width: var(--p, 0%);
  border-radius: 3px;
  background: linear-gradient(90deg, var(--blue), var(--gold));
  transition: width .3s ease;
}

/* ---- câu hỏi ---- */
.question { margin-bottom: 28px; scroll-margin-top: 90px; }

.q-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}
.q-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0;
}
.q-text {
  font-weight: 600;
  font-size: 15px;
  margin: 0;
  line-height: 1.5;
}

.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  border-radius: var(--radius-md);
}
.question.invalid .options { outline: 1.5px solid var(--error); outline-offset: 5px; }

.option { position: relative; display: block; cursor: pointer; }
.option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  font-size: 14px;
  line-height: 1.3;
  user-select: none;
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
}
.box::before { font-size: 19px; line-height: 1; flex-shrink: 0; }
.option[data-tone="1"] .box::before { content: "😄"; }
.option[data-tone="2"] .box::before { content: "🙂"; }
.option[data-tone="3"] .box::before { content: "😐"; }
.option[data-tone="4"] .box::before { content: "🙁"; }

@media (hover: hover) {
  .option:hover .box { border-color: var(--blue); background: var(--blue-soft); }
}

.option input:checked + .box {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 16px -10px rgba(28, 63, 143, .8);
}
.option input:focus-visible + .box { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---- nút ---- */
.btn-primary {
  width: 100%;
  min-height: 50px;
  padding: 13px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:active { transform: scale(.99); }
.btn-primary:disabled { opacity: .75; cursor: default; transform: none; }

.btn-primary.loading::after {
  content: "";
  display: inline-block;
  width: 15px;
  height: 15px;
  margin-left: 10px;
  vertical-align: -2px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.actions { display: flex; gap: 10px; margin-top: 6px; }
.actions .btn-primary { flex: 2; }

.btn-secondary {
  flex: 1;
  min-height: 50px;
  padding: 13px;
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-secondary:hover { background: var(--blue-soft); border-color: var(--blue); }

.submit-error {
  display: none;
  background: var(--error-soft);
  color: var(--error);
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  margin: 0 0 16px;
}

/* ô bẫy bot (ẩn khỏi người dùng thật) */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---- màn hình cảm ơn ---- */
.card.thanks-card { text-align: center; padding-top: 40px; padding-bottom: 40px; }
.thanks-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 8px var(--blue-soft);
}
.thanks-card .subtitle { margin-bottom: 0; }

/* ---- footer ---- */
.foot {
  text-align: center;
  padding: 18px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---- responsive ---- */
@media (max-width: 480px) {
  .hero { padding: 22px 16px 80px; }
  .hero h1 { font-size: 22px; }
  .hero p { font-size: 14px; margin-bottom: 20px; }
  .logo-img { height: 48px; }
  .wrap { padding: 0 12px 36px; }
  .card { padding: 26px 18px; border-radius: 18px; }
  .title { font-size: 19px; }
  .box { padding: 10px; font-size: 13.5px; }
}
@media (max-width: 340px) {
  .options { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
