:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #2b2d33;
  --muted: #6b6f78;
  --line: #d8dbe1;
  --accent: #0a7cc1;
  --accent-dark: #075f94;
  --accent-soft: #e6f2fa;
  --error: #c62828;
  --error-soft: #fdecec;
  --radius: 12px;
  --tap: 52px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.brand { text-align: center; padding: 16px 0 20px; }
.brand img { width: 200px; max-width: 60%; height: auto; }

.card {
  background: var(--card);
  border-radius: 18px;
  padding: 24px 20px;
  box-shadow: 0 1px 2px rgba(20, 24, 33, .05), 0 8px 24px rgba(20, 24, 33, .06);
}
@media (min-width: 600px) { .card { padding: 36px 40px; } }

h1 { font-size: 1.5rem; font-weight: 650; margin: 0 0 4px; letter-spacing: -.01em; }
.muted { color: var(--muted); margin: 0 0 24px; }
.small { font-size: .875rem; }
.req { color: var(--accent); font-weight: 600; }
.hint { display: block; color: var(--muted); font-size: .875rem; font-weight: 400; margin-top: 2px; }

.field { margin: 0 0 20px; padding: 0; border: 0; min-width: 0; }
.field[hidden] { display: none; }
.row { display: grid; gap: 0 16px; }
@media (min-width: 520px) { .row { grid-template-columns: repeat(2, minmax(0, 1fr)); } .narrow { max-width: 50%; } }

label, legend { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 8px; padding: 0; }

input[type=text], input[type=email], input[type=tel], input[type=password], select {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  font: inherit;
  font-size: 16px; /* evita lo zoom automatico su iOS */
  color: var(--text);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236b6f78' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input::placeholder { color: #a3a7af; }
[aria-invalid=true] { border-color: var(--error) !important; }

/* Telefono: prefisso + numero */
.phone { display: flex; gap: 8px; }
.prefix { position: relative; flex: 0 0 116px; }
.prefix select { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 100%; }
.prefix-view {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  height: 100%; min-height: var(--tap);
  padding: 0 12px;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: #fff; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.prefix-view::after {
  content: ""; width: 10px; height: 10px; flex: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236b6f78' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/10px no-repeat;
}
.prefix:focus-within .prefix-view { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.phone input { flex: 1; min-width: 0; }

/* Yes / No */
.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.segmented input, .chips input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label, .chips label {
  display: flex; align-items: center; justify-content: center;
  min-height: var(--tap); margin: 0; padding: 10px 14px;
  font-weight: 500; text-align: center;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: #fff; cursor: pointer; user-select: none;
  transition: background .15s, border-color .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.segmented input:checked + label, .chips input:checked + label {
  border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); font-weight: 600;
}
.segmented input:focus-visible + label, .chips input:focus-visible + label { box-shadow: 0 0 0 4px var(--accent-soft); }

/* Interessi (multi-selezione) */
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.chips label { gap: 8px; }
.chips label::before {
  content: ""; width: 18px; height: 18px; flex: none;
  border: 1.5px solid var(--line); border-radius: 5px; background: #fff;
}
.chips input:checked + label::before {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/14px no-repeat;
}

/* Consenso privacy */
.consent { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; font-size: .92rem; line-height: 1.45; cursor: pointer; }
.consent input {
  flex: none; width: 24px; height: 24px; margin: 1px 0 0;
  border: 1.5px solid var(--line); border-radius: 6px; background: #fff;
  -webkit-appearance: none; appearance: none; cursor: pointer;
}
.consent input:checked {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/16px no-repeat;
}
.consent input:focus-visible { box-shadow: 0 0 0 4px var(--accent-soft); }
a { color: var(--accent); }

/* Errori */
.error { color: var(--error); font-size: .875rem; margin: 6px 0 0; }
.alert { background: var(--error-soft); color: var(--error); padding: 12px 14px; border-radius: var(--radius); margin: 0 0 20px; font-weight: 500; }
fieldset.field.invalid .segmented label, fieldset.field.invalid .chips label { border-color: var(--error); }

/* Pulsanti */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 12px 28px;
  font: inherit; font-weight: 600; font-size: 1.05rem;
  color: #fff; background: var(--accent);
  border: 0; border-radius: var(--radius);
  text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: scale(.99); }
.btn[disabled] { opacity: .6; cursor: default; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--line); }
.btn-ghost:hover { background: var(--accent-soft); }

/* Honeypot anti-spam */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Ringraziamento */
.thanks { text-align: center; padding: 48px 24px; }
.thanks .check {
  width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.thanks p { margin: 0 0 24px; }
.thanks .small { margin: 20px 0 0; }
