:root {
  --outside: #0e2a50; /* azul-marinho da marca (brandbook) */
  --chat: #0b141a;
  --header: #1f2c34;
  --in: #202c33;
  --out: #005c4b;
  --tray: #111b21;
  --field: #2a3942;
  --line: #2f3b43;
  --text: #e9edef;
  --muted: #8696a0;
  --meta: #a2b0b8;
  --accent: #21c063;
  --accent-ink: #06240f;
  --brand: #008487; /* verde-petróleo da marca (brandbook) */
  --ticks: #53bdeb;
  --error: #ff8f86;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--outside);
  color: var(--text);
  font: 15.5px/1.38 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--ticks); }
.is-hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { text-align: center; padding: 24px; }

/* ---------- moldura ---------- */
.shell { min-height: 100dvh; display: grid; place-items: center; }
.phone {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 440px;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--chat);
  /* papel de parede: rabiscos discretos em SVG */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' fill='none' stroke='%23ffffff' stroke-opacity='.045' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M30 40c-6-8-20-4-18 6 2 9 18 18 18 18s16-9 18-18c2-10-12-14-18-6Z'/%3E%3Ccircle cx='130' cy='34' r='12'/%3E%3Cpath d='M130 16v-6M130 58v-6M148 34h6M106 34h6'/%3E%3Cpath d='M70 110l14-14 14 14-14 14Z'/%3E%3Cpath d='M150 120c-10 0-18 8-18 18h36c0-10-8-18-18-18Z'/%3E%3Cpath d='M20 150h28M34 136v28'/%3E%3Cpath d='M92 160q8-10 16 0t16 0'/%3E%3C/svg%3E");
  background-size: 180px;
}
@media (min-width: 821px) {
  .phone {
    height: min(880px, calc(100dvh - 48px));
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  }
}

/* ---------- cabeçalho ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 4px;
  background: var(--header);
  z-index: 2;
}
.back { display: flex; align-items: center; gap: 2px; padding: 4px; border: 0; background: none; border-radius: 22px; }
.back:focus-visible { outline: 2px solid var(--accent); }
.chevron { width: 24px; height: 24px; fill: none; stroke: var(--text); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.avatar { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: #fff; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.contact { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.contact strong { font-size: 16.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact span { font-size: 12.5px; color: var(--muted); }
.actions { display: flex; gap: 18px; padding-right: 6px; }
.actions svg { width: 22px; height: 22px; fill: none; stroke: var(--text); stroke-width: 1.7; stroke-linejoin: round; }

.progress { height: 3px; background: rgba(255, 255, 255, .06); }
.progress span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .45s ease; }

/* ---------- conversa ---------- */
.chat { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px 18px; display: flex; flex-direction: column; gap: 3px; }
.pill {
  align-self: center;
  margin: 4px 0 10px;
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--header);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.row { display: flex; margin-top: 3px; }
.row.out { justify-content: flex-end; }
.bubble {
  position: relative;
  max-width: 84%;
  padding: 7px 9px 6px;
  border-radius: var(--radius);
  box-shadow: 0 1px .5px rgba(0, 0, 0, .25);
  animation: pop .22s ease-out;
  overflow-wrap: anywhere;
}
.in .bubble { background: var(--in); border-top-left-radius: 3px; }
.out .bubble { background: var(--out); border-top-right-radius: 3px; }
.bubble p { margin: 0; }
.bubble p + p { margin-top: 6px; }
.question { font-weight: 600; }
.helper { color: var(--muted); font-size: 14px; }
.result-title { font-size: 18px; }
.meta { float: right; margin: 7px 0 -4px 12px; font-size: 11px; color: var(--meta); white-space: nowrap; }
.ticks { margin-left: 3px; font-style: normal; letter-spacing: -4px; color: var(--ticks); }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

.typing { display: flex; gap: 4px; padding: 12px 14px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- mensagem de voz ---------- */
.voice { display: flex; align-items: center; gap: 10px; width: 300px; max-width: 86%; padding: 8px 10px; }
.voice-play { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: none; padding: 0; }
.icon-play { width: 0; height: 0; border-style: solid; border-width: 9px 0 9px 15px; border-color: transparent transparent transparent var(--muted); }
.icon-pause { display: none; gap: 5px; }
.icon-pause i { width: 5px; height: 18px; border-radius: 2px; background: var(--ticks); }
.voice-play.playing .icon-play { display: none; }
.voice-play.playing .icon-pause { display: flex; }
.voice-main { flex: 1; min-width: 0; }
.voice-track { position: relative; height: 30px; display: flex; align-items: center; }
.wave { display: flex; align-items: center; justify-content: space-between; width: 100%; height: 100%; }
.wave i { width: 3px; border-radius: 2px; background: #56656e; transition: background .15s; }
.wave i.played { background: var(--ticks); }
.voice-dot { position: absolute; left: 5px; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--ticks); z-index: 1; }
.voice-meta { display: flex; justify-content: space-between; margin-top: 2px; font-size: 11px; color: var(--meta); }
.voice-avatar { position: relative; flex: none; width: 48px; height: 48px; }
.voice-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: #fff; }
.voice-avatar svg { position: absolute; left: -4px; bottom: -2px; width: 20px; height: 20px; fill: none; stroke: var(--ticks); stroke-width: 2; stroke-linecap: round; }

.voice-speed {
  display: none;
  flex: none;
  align-self: center;
  min-width: 48px;
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, .14);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}
.voice-speed:focus-visible { outline: 2px solid var(--accent); }
.voice.show-speed .voice-speed { display: block; }
.voice.show-speed .voice-avatar { display: none; }

/* ---------- opções ---------- */
.choices { margin: 8px 0 4px; }
.choices-label { display: flex; justify-content: space-between; gap: 8px; margin: 0 2px 8px; font-size: 12.5px; color: var(--muted); }
.choices-label b { color: var(--text); font-weight: 600; }
.answers { display: grid; gap: 8px; }
.answer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(17, 27, 33, .92);
  text-align: left;
  font-weight: 500;
  transition: border-color .15s, background .15s, opacity .2s;
}
.answer > span:last-child { color: var(--muted); font-size: 22px; line-height: 1; }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(17, 27, 33, .92);
  text-align: left;
  transition: border-color .15s, background .15s, opacity .2s;
}
.card:last-child:nth-child(odd) { grid-column: span 2; }
.card-art { display: grid; place-items: center; aspect-ratio: 4 / 3; background: linear-gradient(145deg, #23343e, #15222a); font-size: 40px; }
.card:last-child:nth-child(odd) .card-art { aspect-ratio: 8 / 3; }
.card-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-text { padding: 10px 11px 12px; font-size: 14px; font-weight: 500; line-height: 1.3; }
@media (hover: hover) {
  .answer:hover, .card:hover { border-color: var(--accent); }
}
.answer:focus-visible, .card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.answer.selected, .card.selected { border-color: var(--accent); background: rgba(33, 192, 99, .2); }
.card { position: relative; }
.card.selected::after {
  content: "✓";
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 800;
}
.answered { pointer-events: none; }
.confirm {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 13px 14px;
  border: 0;
  border-radius: 22px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  transition: opacity .2s;
}
.confirm:disabled { opacity: .35; cursor: default; }
.confirm:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.answered .answer:not(.selected), .answered .card:not(.selected) { opacity: .4; }

.more { position: absolute; left: 0; right: 0; bottom: 16px; display: flex; justify-content: center; pointer-events: none; z-index: 3; }
.more button {
  pointer-events: auto;
  padding: 9px 16px;
  border: 0;
  border-radius: 20px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .4);
}

.wa-button {
  display: block;
  margin-top: 10px;
  padding: 11px 14px;
  border-radius: 22px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

/* ---------- bandeja ---------- */
.tray { padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); background: var(--tray); border-top: 1px solid var(--line); z-index: 2; }
.tray-label { display: flex; justify-content: space-between; gap: 12px; margin: 0 4px 8px; font-size: 12.5px; color: var(--muted); }
.tray-label b { color: var(--text); font-weight: 600; text-align: right; }
.tray-form { display: flex; gap: 8px; }
.tray-input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 24px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16px evita o zoom automático do iOS */
  outline: none;
}
.tray-input:focus { border-color: var(--accent); }
.tray-input[aria-invalid="true"] { border-color: var(--error); }
.send { flex: none; width: 48px; height: 48px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--accent); }
.send svg { width: 22px; height: 22px; fill: var(--accent-ink); }
.tray-error { margin: 8px 6px 0; color: var(--error); font-size: 13.5px; }
.tray-note { margin: 8px 6px 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

@media (max-width: 380px) {
  body { font-size: 15px; }
  .card-text { font-size: 13px; }
  .actions { gap: 14px; }
}
@media (max-height: 640px) {
  .card-art { aspect-ratio: 2 / 1; font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- página de obrigado ---------- */
.thanks-topbar { padding-left: 12px; }
.thanks {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 28px 48px;
  text-align: center;
}
.thanks-check {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 36px;
  font-weight: 800;
}
.thanks h1 { margin: 0; font-size: 24px; line-height: 1.25; }
.thanks p { margin: 0; max-width: 320px; font-size: 16px; }
.thanks .thanks-note { color: var(--muted); font-size: 14px; }
