/* Tokens */
:root {
  --ground: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #e9ece7;
  --ink: #1c2422;
  --muted: #5d6663;
  --line: #d5d9d4;
  --line-strong: #a9b1ac;
  --accent: #1f6f5f;
  --accent-ink: #ffffff;
  --accent-soft: #dcede7;
  --danger: #b4432f;
  --danger-soft: #f8e5e0;
  --focus: #2d8f7b;
  --shadow: 0 8px 24px rgba(28, 36, 34, 0.08);

  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", sans-serif;
  --font-body: "Public Sans", "Helvetica Neue", Arial, sans-serif;

  --text-12: 12px;
  --text-16: 16px;
  --text-20: 20px;
  --text-24: 24px;
  --text-28: 28px;

  --s-1: 8px;
  --s-2: 16px;
  --s-3: 24px;
  --s-4: 32px;
  --s-5: 40px;
  --s-6: 48px;
  --s-8: 64px;

  --radius: 12px;
  --radius-sm: 8px;
  --tap: 48px;
  --actions-h: 80px;
  --motion: 220ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #141917;
    --surface: #1d2421;
    --surface-2: #232b28;
    --ink: #eaedea;
    --muted: #9aa39f;
    --line: #2e3733;
    --line-strong: #4a554f;
    --accent: #5cc2a8;
    --accent-ink: #0f1f1a;
    --accent-soft: #1f342e;
    --danger: #e27a66;
    --danger-soft: #3a2420;
    --focus: #7ad4bd;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  --ground: #141917;
  --surface: #1d2421;
  --surface-2: #232b28;
  --ink: #eaedea;
  --muted: #9aa39f;
  --line: #2e3733;
  --line-strong: #4a554f;
  --accent: #5cc2a8;
  --accent-ink: #0f1f1a;
  --accent-soft: #1f342e;
  --danger: #e27a66;
  --danger-soft: #3a2420;
  --focus: #7ad4bd;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* Base */
* { box-sizing: border-box; }
html { color-scheme: light dark; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-16);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
p { margin: 0 0 var(--s-2); }
.muted { color: var(--muted); }

.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--line);
  z-index: 20;
}
.progress__bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width var(--motion) var(--ease);
}

.eyebrow {
  margin: 0 0 var(--s-2);
  font-size: var(--text-12);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.title, h1, h2 {
  margin: 0 0 var(--s-3);
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  text-wrap: balance;
}
.title, h1 { font-size: var(--text-28); }
h2 { font-size: var(--text-24); }
.title:focus, h2:focus { outline: none; }

/* Telas */
.app {
  max-width: 640px;
  margin: 0 auto;
  padding-block: var(--s-6) calc(var(--actions-h) + var(--s-4) + env(safe-area-inset-bottom));
  padding-inline: var(--s-2);
}
.screen { animation: screenIn var(--motion) var(--ease) both; }
.screen--center { text-align: center; padding-top: var(--s-6); }
.screen--center p { margin-inline: auto; max-width: 42ch; }

.step-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-2);
  margin: 0 0 var(--s-3);
  font-size: var(--text-12);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.step-context {
  padding: 0 var(--s-1);
  line-height: 24px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-host { position: relative; }
.step { will-change: transform, opacity; }
.step--fwd { animation: stepFwd var(--motion) var(--ease) both; }
.step--back { animation: stepBack var(--motion) var(--ease) both; }
.step--shake { animation: shake 360ms var(--ease); }

.question__label {
  display: block;
  margin: 0 0 var(--s-1);
  font-family: var(--font-display);
  font-size: var(--text-24);
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
}
.question__help { margin: 0 0 var(--s-3); color: var(--muted); }
.question__optional {
  display: inline-block;
  margin-left: var(--s-1);
  vertical-align: middle;
  font-family: var(--font-body);
  font-size: var(--text-12);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Opções: alvos grandes, uma por linha */
.options {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  margin: 0;
  padding: 0;
  border: 0;
}
.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 56px;
  padding: var(--s-2);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 120ms ease, background-color 120ms ease, transform 120ms ease;
  animation: optionIn var(--motion) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 30ms);
}
.option:active { transform: scale(0.99); }
.option:hover { border-color: var(--line-strong); }
.option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.option:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }
.option:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.option__mark {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent-ink);
  transition: background-color 120ms ease, border-color 120ms ease;
}
.option--check .option__mark { border-radius: 6px; }
.option__mark svg { width: 14px; height: 14px; opacity: 0; transform: scale(0.6); transition: opacity 120ms ease, transform 120ms var(--ease); }
.option:has(input:checked) .option__mark { background: var(--accent); border-color: var(--accent); }
.option:has(input:checked) .option__mark svg { opacity: 1; transform: scale(1); }
.option__text { flex: 1 1 auto; }
.scale .option__text { font-variant-numeric: tabular-nums; }

.other-input { margin-top: var(--s-1); animation: screenIn var(--motion) var(--ease) both; }

/* Campos */
textarea, input[type="text"], input[type="email"] {
  width: 100%;
  min-height: var(--tap);
  padding: var(--s-2);
  font: inherit;
  font-size: var(--text-16);
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 120ms ease;
}
textarea { min-height: 160px; resize: vertical; line-height: 1.5; }
textarea:focus-visible, input:focus-visible, button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.field--invalid textarea, .field--invalid input { border-color: var(--danger); }

.text-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-1);
  font-size: var(--text-12);
  color: var(--muted);
}
.text-meta__count { margin-left: auto; font-variant-numeric: tabular-nums; }
.text-meta__count--over { color: var(--danger); font-weight: 600; }
.link-button {
  min-height: 32px;
  padding: 0 var(--s-1);
  font: inherit;
  font-size: var(--text-12);
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
}

.question__error {
  display: flex;
  align-items: flex-start;
  gap: var(--s-1);
  margin: var(--s-2) 0 0;
  padding: var(--s-1) var(--s-2);
  font-size: var(--text-16);
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  animation: screenIn 160ms var(--ease) both;
}
.question__error::before { content: "!"; flex: 0 0 20px; height: 20px; margin-top: 2px; display: grid; place-items: center; font-size: var(--text-12); color: var(--danger-soft); background: var(--danger); border-radius: 50%; }

/* Revisão */
.review { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-1); }
.review__item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--s-2);
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  animation: optionIn var(--motion) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 30ms);
}
.review__item:hover { border-color: var(--line-strong); }
.review__q { font-size: var(--text-12); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.review__a { white-space: pre-wrap; overflow-wrap: anywhere; }
.review__edit { font-size: var(--text-12); font-weight: 600; color: var(--accent); }

/* Conclusão */
.check {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--s-3);
  display: grid;
  place-items: center;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 50%;
  animation: popIn 420ms var(--ease) both;
}
.check__path { stroke-dasharray: 48; stroke-dashoffset: 48; animation: draw 420ms var(--ease) 200ms forwards; }

/* Barra de ações fixa */
.actions {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 10;
  display: flex;
  gap: var(--s-2);
  justify-content: space-between;
  padding: var(--s-2);
  padding-bottom: calc(var(--s-2) + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.actions > * { flex: 1 1 0; }
.actions .button--ghost { flex: 0 1 35%; }
.actions .button--ghost[hidden] + .button { flex-basis: 100%; }

.button {
  position: relative;
  min-height: var(--tap);
  padding: 0 var(--s-3);
  font: inherit;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 120ms ease, opacity 120ms ease;
}
.button:active { transform: scale(0.98); }
.button:disabled { cursor: progress; opacity: 0.7; }
.button--ghost { color: var(--ink); background: var(--surface-2); }
.button--secondary { color: var(--accent); background: var(--accent-soft); }
.button__wait { display: inline-flex; align-items: center; gap: var(--s-1); }
.button__wait::before { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 700ms linear infinite; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--actions-h) + var(--s-2) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  max-width: min(92vw, 560px);
  padding: var(--s-1) var(--s-2);
  font-weight: 600;
  color: var(--ground);
  background: var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  animation: toastIn var(--motion) var(--ease) both;
}
.toast--danger { background: var(--danger); color: #fff; }

.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Painel (admin) */
.page { max-width: 640px; margin: 0 auto; padding-block: var(--s-8); padding-inline: var(--s-2); }
.intro { margin-bottom: var(--s-6); }
.survey .question { padding-top: var(--s-4); border-top: 1px solid var(--line); }
.questions { display: flex; flex-direction: column; gap: var(--s-5); }
.questions .question { padding-top: var(--s-4); border-top: 1px solid var(--line); }
.questions .question__label { font-size: var(--text-20); }
.actions--top { position: static; display: flex; flex-direction: column; gap: var(--s-2); padding: 0; margin-bottom: var(--s-4); background: none; border: 0; backdrop-filter: none; }
.actions--top > * { flex: none; }
.survey .actions { position: static; padding: var(--s-4) 0 0; background: none; border-top: 1px solid var(--line); margin-top: var(--s-4); backdrop-filter: none; }
.button-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.report__total { margin: 0; font-family: var(--font-display); font-size: var(--text-20); font-weight: 600; }
.form-error { margin: 0; color: var(--danger); font-weight: 600; }
.tally { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--s-1); }
.tally li { display: flex; gap: var(--s-2); align-items: baseline; }
.tally__count { flex: 0 0 88px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent); }
.answers { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--s-1); }
.answers li { padding: var(--s-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.invites__links { width: 100%; min-height: 120px; font-family: ui-monospace, monospace; font-size: var(--text-12); }
.field-inline { display: flex; gap: var(--s-2); align-items: center; }
.field-inline input { max-width: 120px; }

/* Animações */
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes stepFwd { from { opacity: 0; transform: translateX(32px); } to { opacity: 1; transform: none; } }
@keyframes stepBack { from { opacity: 0; transform: translateX(-32px); } to { opacity: 1; transform: none; } }
@keyframes optionIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-6px); } 40%, 60% { transform: translateX(6px); } }
@keyframes popIn { from { opacity: 0; transform: scale(0.6); } 60% { transform: scale(1.08); } to { opacity: 1; transform: scale(1); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
  .step--shake { animation: none; }
  html { scroll-behavior: auto; }
}

@media (min-width: 720px) {
  .app { padding-block: var(--s-8) calc(var(--actions-h) + var(--s-6)); }
  footer#actions { left: 50%; right: auto; width: min(100%, 640px); transform: translateX(-50%); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
}
