:root {
  --white: #ffffff;
  --ink: #111111;
  --ink-soft: #4a4a4a;
  --muted: #7a7a7a;
  --line: #e6e6e2;
  --paper: #f7f7f4;
  --olive: #5b6e3b;
  --olive-dark: #45542d;
  --olive-soft: #eef1e8;
  --danger: #b23b2e;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(17, 17, 17, .04), 0 8px 24px rgba(17, 17, 17, .05);
  --font-body: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Anton", "Archivo", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.hidden-form { display: none; }

/* ---------- Sfondi fotografici ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background: var(--paper);
  pointer-events: none;
}

.bg-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity .8s ease;
}

.bg-layer.active { opacity: 1; }

.bg-veil {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: rgba(247, 247, 244, .9);
  transition: background .6s ease;
}

body[data-bg="dark"] .bg-veil {
  background: linear-gradient(
    180deg,
    rgba(8, 10, 6, .42) 0%,
    rgba(8, 10, 6, .52) 45%,
    rgba(8, 10, 6, .80) 100%
  );
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 8px;
  text-decoration: none;
  color: var(--ink);
  max-width: 760px;
  margin: 0 auto;
}

.brand-logo {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 19px;
  letter-spacing: .06em;
  text-transform: uppercase;
  line-height: 1;
}

.progress {
  height: 4px;
  background: var(--line);
  max-width: 100%;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--olive);
  transition: width .35s ease;
}

/* ---------- Main ---------- */
.main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 26px 20px 120px;
}

.step {
  animation: fade-in .35s ease both;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.step-eyebrow {
  text-transform: uppercase;
  letter-spacing: 1.6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--olive);
  margin: 0 0 6px;
}

.step-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(30px, 7vw, 42px);
  line-height: 1.06;
  letter-spacing: .01em;
  text-transform: uppercase;
  margin: 0 0 12px;
}

.step-sub {
  color: var(--ink-soft);
  font-size: 15px;
  margin: 0 0 22px;
}

/* ---------- Intro / Outro ---------- */
.hero {
  padding-top: 20px;
}

.hero-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin-bottom: 18px;
}

.hero p {
  color: var(--ink-soft);
  font-size: 16px;
  margin: 0 0 16px;
}

.hero .step-title { font-size: clamp(40px, 12vw, 68px); line-height: 1; }

.bg-credit {
  font-size: 11px;
  letter-spacing: .3px;
  color: var(--muted);
  margin-top: 26px;
}

body[data-bg="dark"] .bg-credit { color: rgba(255, 255, 255, .55); }

/* ---------- Banner bozza in sospeso (overlay) ---------- */
.draft-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  margin: 0 auto;
  max-width: 520px;
  bottom: calc(94px + env(safe-area-inset-bottom));
  z-index: 2147483000;
  background: rgba(18, 20, 16, .95);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .38);
  backdrop-filter: blur(8px);
  text-shadow: none;
  animation: fade-in .3s ease both;
}

.draft-banner .draft-text {
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  margin: 0 28px 12px 0;
}

.draft-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, .65);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
}

.draft-close:hover { color: #fff; background: rgba(255, 255, 255, .1); }

.draft-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.draft-actions .btn {
  flex: 1 1 auto;
  padding: 11px 16px;
  font-size: 15px;
}

.draft-banner .btn-ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, .5);
}

.draft-banner .btn-ghost:hover { border-color: #fff; background: rgba(255, 255, 255, .1); }

.meta-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--olive-soft);
  color: var(--olive-dark);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 22px;
}

/* ---------- Questions ---------- */
.question {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.question-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 4px;
  line-height: 1.35;
}

.question-helper {
  font-size: 13.5px;
  color: var(--muted);
  margin: 0 0 14px;
}

.counter {
  display: inline-block;
  font-weight: 600;
  color: var(--olive);
}

.counter.full { color: var(--olive-dark); }

/* options */
.options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 15px;
  background: var(--white);
  transition: border-color .15s, background .15s, transform .1s;
}

.option:hover { border-color: #c9cdbb; }

.option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option .marker {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border: 1.5px solid #c4c4bd;
  background: var(--white);
  display: grid;
  place-items: center;
  transition: border-color .15s, background .15s;
}

.option.radio .marker { border-radius: 50%; }
.option.checkbox .marker { border-radius: 6px; }

.option .marker svg { width: 12px; height: 12px; opacity: 0; transform: scale(.6); transition: .15s; }

.option.selected {
  border-color: var(--olive);
  background: var(--olive-soft);
}

.option.selected .marker {
  border-color: var(--olive);
  background: var(--olive);
  color: #fff;
}

.option.selected .marker svg { opacity: 1; transform: scale(1); }

.option.disabled {
  opacity: .45;
  cursor: not-allowed;
}

.option.other { }

input.other-input {
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
}

/* textarea */
.textarea-wrap { position: relative; }

textarea.field {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
}

textarea.field:focus,
input.field:focus,
input.other-input:focus {
  outline: none;
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(91, 110, 59, .12);
}

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

.char-count.over { color: var(--danger); font-weight: 600; }

/* contact */
.contact-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

input.field {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
}

.consent {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 4px;
  font-size: 13.5px;
  color: var(--ink-soft);
  cursor: pointer;
}

.consent input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--olive); flex: none; }

.consent a { color: var(--olive-dark); }

/* errors */
.error-msg {
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 600;
  margin-top: 10px;
  min-height: 0;
}

.question.has-error {
  border-color: var(--danger);
}

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2147483647;
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  isolation: isolate;
}

/* Nasconde eventuali badge/widget flottanti iniettati da Netlify
   (es. "Powered by Netlify") che altrimenti coprirebbero i pulsanti. */
#netlify-badge,
.netlify-badge,
netlify-drawer,
[data-netlify-badge] { display: none !important; }

/* Avviso di errore invio */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(98px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 2147483647;
  width: min(92vw, 540px);
  background: #1c1c1c;
  color: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .28);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.toast[hidden] { display: none; }

.toast-retry {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, .45);
  background: transparent;
  color: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.toast-retry:hover { background: rgba(255, 255, 255, .14); }

.nav-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn {
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 13px 20px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, opacity .15s;
}

.btn-primary {
  background: var(--olive);
  color: #fff;
  flex: 1;
}

.btn-primary:hover { background: var(--olive-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--line);
}

.btn-ghost:hover { border-color: var(--muted); }

.btn-block { width: 100%; }

/* ---------- Footer ---------- */
.footer {
  padding: 22px 20px 96px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

.footer p { margin: 4px 0; }
.footer a { color: var(--olive-dark); }

/* ---------- Intro/Grazie su foto scura ---------- */
body[data-bg="dark"] .hero {
  color: #fff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .6), 0 1px 3px rgba(0, 0, 0, .55);
}

body[data-bg="dark"] .hero .step-title { color: #fff; }

body[data-bg="dark"] .hero p,
body[data-bg="dark"] .hero .step-sub { color: rgba(255, 255, 255, .88); }

body[data-bg="dark"] .hero .step-eyebrow { color: rgba(255, 255, 255, .72); }

body[data-bg="dark"] .hero-logo { filter: brightness(0) invert(1); }

body[data-bg="dark"] .meta-note {
  background: rgba(255, 255, 255, .14);
  color: #fff;
}

body[data-bg="dark"] .brand-name { color: #fff; }
body[data-bg="dark"] .brand-logo { filter: brightness(0) invert(1); }

body[data-bg="dark"] .topbar {
  background: rgba(10, 12, 8, .28);
  border-bottom-color: rgba(255, 255, 255, .14);
}

body[data-bg="dark"] .progress { background: rgba(255, 255, 255, .18); }

body[data-bg="dark"] .footer { color: rgba(255, 255, 255, .72); }
body[data-bg="dark"] .footer a { color: #fff; }

/* ---------- Privacy page ---------- */
.doc { max-width: 760px; margin: 0 auto; padding: 30px 20px 80px; }
.doc h1 {
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .01em;
  font-size: 34px;
  line-height: 1.05;
}
.doc h2 { font-size: 17px; margin-top: 28px; }
.doc p, .doc li { color: var(--ink-soft); font-size: 15px; }
.doc a { color: var(--olive-dark); }

.doc table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: 12px 0 20px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 620px; margin: 0; }
.doc th, .doc td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc th { font-weight: 600; color: var(--ink); }
.doc td { color: var(--ink-soft); }
.doc .thumb { width: 96px; height: 64px; object-fit: cover; border-radius: 8px; display: block; }

@media (min-width: 640px) {
  .options { gap: 9px; }
  .main { padding-top: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-layer,
  .bg-veil,
  .progress-fill,
  .btn,
  .option { transition: none !important; }
  .step { animation: none !important; }
  .draft-banner { animation: none !important; }
  html { scroll-behavior: auto; }
}
