:root {
  --bg: #f2f7f4;
  --card: #ffffff;
  --ink: #1f2d29;
  --muted: #6b7d76;
  --brand: #2fa679;
  --brand-dark: #23825f;
  --brand-soft: #e4f3ec;
  --line: #e2ebe6;
  --accent: #ff8a5c;
  --shadow: 0 10px 30px rgba(31, 45, 41, .08);
  --radius: 18px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.top {
  text-align: center;
  padding: 8px 0 18px;
}
.top .logo { font-size: 40px; line-height: 1; }
.top h1 {
  font-size: 22px;
  margin: 10px 0 4px;
  letter-spacing: -.3px;
}
.top p { color: var(--muted); margin: 0; font-size: 14.5px; }

/* Progress */
.progress {
  height: 8px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  margin: 6px 0 20px;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
  border-radius: 99px;
  transition: width .35s ease;
}

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px;
}

.step-count {
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .4px;
  text-transform: uppercase;
}
.q-text {
  font-size: 20px;
  font-weight: 700;
  margin: 8px 0 4px;
  letter-spacing: -.2px;
}
.q-note { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

/* Options */
.options { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 14px 15px;
  cursor: pointer;
  background: #fff;
  font-size: 15.5px;
  text-align: left;
  transition: border-color .15s, background .15s, transform .05s;
}
.opt:hover { border-color: var(--brand); }
.opt:active { transform: scale(.99); }
.opt .dot {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid; place-items: center;
  transition: border-color .15s;
}
.opt.selected { border-color: var(--brand); background: var(--brand-soft); }
.opt.selected .dot { border-color: var(--brand); }
.opt.selected .dot::after {
  content: ""; width: 11px; height: 11px; border-radius: 50%;
  background: var(--brand);
}

/* Nav buttons */
.nav {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}
.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .05s, opacity .15s, background .15s;
  font-family: inherit;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); color: #fff; flex: 1; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--line); }
.btn-ghost:hover { color: var(--ink); }

/* Result */
.result-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--brand-soft); color: var(--brand-dark);
  padding: 6px 12px; border-radius: 99px; font-size: 13px; font-weight: 700;
}
.result-icon { font-size: 46px; }
.result-title { font-size: 24px; font-weight: 800; margin: 10px 0 6px; letter-spacing: -.4px; }
.result-desc { color: var(--muted); font-size: 15.5px; }
.result-sub {
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line);
  font-size: 14.5px; color: var(--muted);
}
.result-sub b { color: var(--ink); }

.sev {
  display: inline-block; padding: 3px 10px; border-radius: 99px;
  font-size: 12.5px; font-weight: 700; margin-left: 4px;
}
.sev-1 { background: #e4f3ec; color: #23825f; }
.sev-2 { background: #fff2e0; color: #b26a2a; }
.sev-3 { background: #fde4e4; color: #c0392b; }

/* Code box */
.code-box {
  margin-top: 20px;
  background: linear-gradient(135deg, #1f2d29, #23403a);
  color: #fff;
  border-radius: 16px;
  padding: 18px;
  text-align: center;
}
.code-box .label { font-size: 12.5px; opacity: .75; letter-spacing: .5px; text-transform: uppercase; }
.code-value {
  font-size: 30px; font-weight: 800; letter-spacing: 3px;
  margin: 6px 0 12px; font-family: "SF Mono", ui-monospace, Menlo, monospace;
}
.copy-btn {
  background: rgba(255,255,255,.14); color: #fff; border: none;
  padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.copy-btn:hover { background: rgba(255,255,255,.24); }

/* Messenger CTA */
.cta { margin-top: 16px; }
.cta-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  background: #0084ff; color: #fff; text-decoration: none;
  padding: 16px; border-radius: 14px; font-weight: 700; font-size: 16px;
  transition: background .15s;
}
.cta-btn:hover { background: #0071db; }
.cta-hint { text-align: center; color: var(--muted); font-size: 13.5px; margin-top: 10px; }

.disclaimer {
  margin-top: 22px; font-size: 12.5px; color: var(--muted);
  text-align: center; line-height: 1.5;
}

.retake {
  display: block; text-align: center; margin-top: 16px;
  color: var(--brand-dark); font-size: 14px; font-weight: 600;
  text-decoration: none; cursor: pointer; background: none; border: none; width: 100%;
}

.footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: auto; padding-top: 28px; }

.hidden { display: none !important; }

/* Info form */
.field-label { display: block; font-weight: 700; font-size: 14.5px; margin: 16px 0 8px; }
.field-row { display: flex; gap: 12px; }
.field { position: relative; flex: 1; }
.field input {
  width: 100%; padding: 14px 46px 14px 15px; font-size: 17px;
  border: 1.5px solid var(--line); border-radius: 14px; background: #fff;
  font-family: inherit; color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--brand); }
.field .unit {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14px; pointer-events: none;
}
/* ẩn mũi tên tăng/giảm của input number */
.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field input[type=number] { -moz-appearance: textfield; }

/* Fade */
.fade-in { animation: fade .28s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Decoder page specific */
.decoder-input {
  width: 100%; padding: 15px; font-size: 18px; text-align: center;
  border: 1.5px solid var(--line); border-radius: 14px; text-transform: uppercase;
  letter-spacing: 2px; font-family: "SF Mono", ui-monospace, Menlo, monospace;
  margin-bottom: 12px;
}
.decoder-input:focus { outline: none; border-color: var(--brand); }
.dec-section { font-weight: 800; font-size: 13px; letter-spacing: .3px; text-transform: uppercase; color: var(--brand-dark); margin: 20px 0 4px; }
.dec-row { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.dec-row:last-child { border-bottom: none; }
.dec-row .k { color: var(--muted); }
.dec-row .v { font-weight: 700; text-align: right; }
.dec-camnang {
  margin-top: 16px; background: var(--brand-soft); color: var(--brand-dark);
  padding: 14px 16px; border-radius: 14px; font-weight: 700; text-align: center; font-size: 16px;
}
.dec-error { color: #c0392b; text-align: center; font-weight: 600; margin-top: 10px; }
.reply-area {
  width: 100%; border: 1.5px solid var(--line); border-radius: 14px;
  padding: 14px; font-size: 14.5px; line-height: 1.6; color: var(--ink);
  font-family: inherit; background: #fbfdfc; resize: vertical; min-height: 260px;
}
.reply-area:focus { outline: none; border-color: var(--brand); }
