:root {
  --anlene-green: #00693e;
  --anlene-green-dark: #00522f;
  --anlene-green-light: #e7f3ed;
  --anlene-red: #d0021b;
  --ink: #1c2b26;
  --muted: #6b7c74;
  --border: #d8e4de;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 20% 0%, #12365e 0%, #0b1f3f 60%, #081733 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--ink);
}

.stage { text-align: center; }

/* ── Phone frame ─────────────────────────────────────────────── */
.phone {
  position: relative;
  width: 390px;
  height: min(760px, calc(100vh - 48px));
  background: #fff;
  border-radius: 36px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5), 0 0 0 10px #111a2e;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  text-align: left;
}

.phone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.phone-header .burger { font-size: 18px; color: var(--muted); }
.phone-header .logo { color: var(--anlene-red); font-weight: 800; font-size: 20px; font-style: italic; }
.lang-switch button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  margin-left: 3px;
}
.lang-switch button.active { background: var(--anlene-green); color: #fff; border-color: var(--anlene-green); }

.phone-screen {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 18px;
  background: #fff;
}

/* ── Shared screen elements ──────────────────────────────────── */
.step-tag {
  align-self: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--anlene-green);
  background: var(--anlene-green-light);
  border-radius: 14px;
  padding: 3px 12px;
  margin-bottom: 12px;
}

.avatar { display: flex; justify-content: center; margin-bottom: 10px; position: relative; }
.avatar .avatar-img {
  width: 210px;
  height: auto;
  /* the source PNG's backdrop is slightly off-white; multiply blends it
     into the white screen so no square edge shows */
  mix-blend-mode: multiply;
}
.avatar .badge {
  position: absolute; right: calc(50% - 105px); top: 6px;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--anlene-green-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; border: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
}
.avatar .badge svg { width: 23px; height: 23px; display: block; }

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 74, 43, .06);
}
.card h2 { font-size: 18px; color: var(--ink); line-height: 1.45; font-weight: 700; }
.card .source { display: block; margin-top: 10px; font-size: 11px; color: var(--muted); }
.card ul.benefits { list-style: none; margin-top: 12px; text-align: left; display: inline-block; }
.card ul.benefits li { font-size: 14px; margin: 6px 0; font-weight: 600; }
.card ul.benefits li::before { content: "✔"; color: var(--anlene-green); margin-right: 8px; }

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn-primary { background: var(--anlene-green); color: #fff; }
.btn-outline { background: #fff; color: var(--anlene-green); border: 2px solid var(--anlene-green); }
.btn-ghost { background: none; color: var(--muted); font-weight: 500; font-size: 13px; }

.spacer { flex: 1; }

/* ── POSM screen ─────────────────────────────────────────────── */
.posm {
  background: linear-gradient(180deg, #fff, #f2f8f5);
  border: 1px solid var(--border);
  border-radius: 18px;
  text-align: center;
  padding: 26px 20px;
  margin: auto 0;
}
.posm .posm-logo { color: var(--anlene-red); font-weight: 800; font-size: 26px; font-style: italic; }
.posm h1 { font-size: 26px; margin: 12px 0 4px; color: var(--ink); }
.posm h1 .off { color: var(--anlene-green); font-size: 34px; display: block; }
.posm p { font-size: 12px; color: var(--muted); }
.posm .qr-box { margin: 16px auto 8px; width: 150px; height: 150px; display: flex; align-items: center; justify-content: center; }
.posm .qr-box canvas { border: 6px solid #fff; box-shadow: 0 2px 12px rgba(0,0,0,.12); border-radius: 8px; }
.posm .scan-hint { font-size: 12px; color: var(--anlene-green); font-weight: 700; }

/* ── Chat ────────────────────────────────────────────────────── */
.chat-area { flex: 1; overflow-y: auto; padding: 4px 0 10px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 14px; margin-bottom: 8px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; }
.msg.user { background: var(--anlene-green); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.msg.bot  { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.bot.thinking { color: var(--muted); font-style: italic; }

.chat-input { display: flex; gap: 8px; margin-top: 6px; }
.chat-input input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 11px 16px;
  font-size: 13.5px;
  outline: none;
}
.chat-input input:focus { border-color: var(--anlene-green); }
.chat-input button {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 16px;
  background: var(--anlene-green-light);
  color: var(--anlene-green);
}
.chat-input button.send { background: var(--anlene-green); color: #fff; }
.chat-input button.mic.recording { background: var(--anlene-red); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }

/* ── Form ────────────────────────────────────────────────────── */
.confetti { text-align: center; font-size: 22px; letter-spacing: 6px; margin-bottom: 6px; }
.form-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 18px; }
.form-card h2 { font-size: 16px; text-align: center; color: var(--ink); margin-bottom: 4px; }
.form-card p { font-size: 12px; text-align: center; color: var(--muted); margin-bottom: 14px; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.field input, .field select {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 13.5px; outline: none; background: #fff;
}
.field input:focus, .field select:focus { border-color: var(--anlene-green); }
.consent { display: flex; gap: 8px; font-size: 11.5px; color: var(--muted); margin: 12px 0 4px; align-items: flex-start; }
.consent a { color: var(--anlene-green); }
.form-error { color: var(--anlene-red); font-size: 12px; text-align: center; margin-top: 6px; min-height: 16px; }

/* ── SMS OTP verification ────────────────────────────────────── */
.otp-lock { text-align: center; font-size: 34px; margin-bottom: 8px; }
.otp-row { display: flex; gap: 9px; justify-content: center; margin: 14px 0 12px; }
.otp-box {
  width: 44px; height: 56px;
  border: 1px solid var(--border); border-radius: 11px;
  text-align: center; font-size: 24px; font-weight: 700;
  color: var(--ink); font-family: Consolas, monospace;
  outline: none; background: #fff;
}
.otp-box:focus { border-color: var(--anlene-green); box-shadow: 0 0 0 3px rgba(0, 105, 62, .15); }
.otp-box:not(:placeholder-shown) { border-color: var(--anlene-green); color: var(--anlene-green); }
.otp-resend { text-align: center; font-size: 12px; color: var(--muted); margin-top: 2px; }
.otp-resend a { color: var(--anlene-green); font-weight: 700; text-decoration: none; }
.otp-resend a.disabled { color: var(--muted); font-weight: 500; pointer-events: none; }

/* ── Voucher ─────────────────────────────────────────────────── */
.voucher { text-align: center; margin: auto 0; }
.voucher .posm-logo { color: var(--anlene-red); font-weight: 800; font-size: 24px; font-style: italic; }
.voucher h2 { color: var(--anlene-green); margin: 10px 0 2px; }
.voucher .code { font-family: Consolas, monospace; font-weight: 700; font-size: 15px; letter-spacing: 1px; margin-top: 8px; }
.voucher .qr-wrap { margin: 14px auto; }
.voucher .note, .voucher .contact { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.5; }

/* ── Responsive: real phones get the full screen ─────────────── */
@media (max-width: 520px) {
  body { padding: 0; background: #fff; }
  .stage { width: 100%; height: 100%; }
  .phone {
    width: 100%;
    height: 100vh;  /* fallback */
    height: 100dvh; /* tracks mobile browser chrome show/hide */
    border-radius: 0;
    box-shadow: none;
    /* keep content clear of notches / home indicator */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  /* inputs under 16px make iOS/Android auto-zoom on focus (and stay
     zoomed); 16px disables that behaviour entirely */
  .chat-input input,
  .field input,
  .field select { font-size: 16px; }
}

/* ── busy lock: while STT/chat/TTS runs, no buttons are usable ── */
.phone-screen.busy .btn,
.phone-screen.busy [data-journey],
.phone-screen.busy .chat-input .send,
.phone-screen.busy .chat-input .mic:not(.recording),
.phone-screen.busy .posm .qr-box {
  opacity: .45;
  pointer-events: none;
  cursor: wait;
}
.phone-screen.busy .chat-input input { pointer-events: none; background: #f4f7f5; }
.phone-screen.busy .otp-box { pointer-events: none; background: #f4f7f5; }

/* ── idle session-ended overlay ──────────────────────────────── */
.session-overlay {
  position: absolute;
  inset: 0;
  background: rgba(14, 31, 24, .78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 24px;
}
.session-box {
  background: #fff;
  border-radius: 18px;
  padding: 28px 22px;
  text-align: center;
  width: 100%;
}
.session-box .session-icon { font-size: 44px; margin-bottom: 8px; }
.session-box h2 { color: var(--anlene-green-dark); font-size: 20px; margin-bottom: 8px; }
.session-box p { font-size: 13.5px; color: var(--muted); line-height: 1.55; margin-bottom: 16px; }

/* ── voice failure toast ─────────────────────────────────────── */
.voice-note {
  position: absolute;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(28, 43, 38, .92);
  color: #fff;
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 18px;
  max-width: 85%;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 30;
}
.voice-note.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Modal ───────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(8, 20, 40, .8); display: flex; align-items: center; justify-content: center; z-index: 40; }
.modal.hidden { display: none; }
.modal-box { background: #fff; border-radius: 16px; padding: 20px; width: min(680px, 92vw); position: relative; }
.modal-box h3 { margin-bottom: 12px; color: var(--anlene-green); }
.modal-box video, .modal-box iframe { width: 100%; aspect-ratio: 16/9; border: none; border-radius: 10px; background: #000; }
.modal-close { position: absolute; top: 10px; right: 14px; border: none; background: none; font-size: 26px; cursor: pointer; color: var(--muted); }
