:root {
  --primary: #2563eb;
  --button: #2563eb;
  --shadow: #000000;
  --bg: #ffffff;
  --fg: #10151b;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body[data-font="friendly"] { font-family: ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif; }
body[data-font="editorial"] { font-family: Georgia, "Times New Roman", serif; }

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 18px 64px;
}

.state { color: var(--muted); text-align: center; padding: 48px 0; }

.brand { text-align: center; margin-bottom: 20px; }
.brand img { max-height: 64px; max-width: 70%; object-fit: contain; }

h1 { font-size: 1.5rem; line-height: 1.25; margin: 8px 0 4px; text-align: center; }
.subtitle { color: var(--muted); text-align: center; margin: 0 0 24px; }

.block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

/* Variantes de composición: solo presentación; conservan el mismo formulario y validación. */
body[data-layout="focused"] .app { max-width: 620px; }
body[data-layout="focused"] .page:not(.hidden) { display: grid; min-height: 42vh; align-content: center; }
body[data-layout="focused"] .block { padding: 22px; border-left: 4px solid var(--primary); }
body[data-layout="visual_options"] .app { max-width: 680px; }
body[data-layout="visual_options"] .block[data-type="choice"] .chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
body[data-layout="visual_options"] .block[data-type="choice"] .chip { min-height: 72px; border-radius: var(--radius); white-space: normal; }
.block > label.title { display: block; font-weight: 600; margin-bottom: 10px; }
.req { color: #dc2626; margin-left: 3px; }

input[type="text"], input[type="email"], input[type="tel"], textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--fg);
}
textarea { min-height: 110px; resize: vertical; }
.field + .field { margin-top: 10px; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }

.stars { display: flex; gap: 6px; }
.star {
  border: 0;
  background: transparent;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  color: var(--border);
  padding: 0;
}
.star[aria-pressed="true"], .star.on { color: var(--primary); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--fg);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: .95rem;
  cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); font-weight: 600; }

.hint { color: var(--muted); font-size: .8rem; margin-top: 8px; }

.submit {
  width: 100%;
  border: 0;
  border-radius: 999px;
  background: var(--button);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 15px;
  margin-top: 8px;
  cursor: pointer;
}
.submit[disabled] { opacity: .55; cursor: not-allowed; }

.error { color: #dc2626; font-size: .85rem; margin-top: 6px; }
.footer-note { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 18px; }

/* Paso 4: verificación, estados de error y pantalla de agradecimiento */
.turnstile { display: flex; justify-content: center; margin: 12px 0; }
.block.invalid { outline: 2px solid #e11d48; outline-offset: 6px; border-radius: 12px; }
.submit.dest {
  display: block;
  text-align: center;
  text-decoration: none;
  margin-top: 12px;
}
.thanks { text-align: center; padding: 24px 0; }
.thanks h1 { margin-bottom: 8px; }

/* Portada / imagen superior de la plantilla */
.cover { margin: -24px -18px 16px; }
.cover img { width: 100%; max-height: 200px; object-fit: cover; display: block; }

/* Secciones informativas */
.block.section { border: none; padding: 8px 0; margin-bottom: 8px; }
.section-title { font-size: 1.1rem; margin: 0 0 4px; }

/* Lista desplegable */
.block select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  font-size: 1rem;
}

/* Matriz de opción única (tipo Google Forms) */
.grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grid-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.grid-table th,
.grid-table td { padding: 10px 8px; text-align: center; }
.grid-table thead th { font-weight: 600; color: var(--fg); opacity: 0.75; white-space: nowrap; }
.grid-table th[scope="row"] { text-align: left; font-weight: 500; white-space: nowrap; }
.grid-table tbody tr:nth-child(odd) { background: color-mix(in srgb, var(--fg) 5%, transparent); }
.grid-table tbody tr td:first-of-type,
.grid-table tbody tr th:first-child { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.grid-radio { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.grid-radio input[type="radio"] { width: 20px; height: 20px; accent-color: var(--primary); margin: 0; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}


/* Teléfono con indicativo de país */
.phone-row { display: flex; gap: 8px; }
.phone-row .phone-dial {
  width: auto;
  min-width: 104px;
  flex: 0 0 auto;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  font-size: 1rem;
}
.phone-row .phone-number { flex: 1 1 auto; min-width: 0; }

/* Botones de ayuda / abreviación bajo campos de texto */
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.suggestion {
  border: 1px solid var(--primary);
  color: var(--primary);
  background: transparent;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.9rem;
  cursor: pointer;
}
.suggestion:active { background: color-mix(in srgb, var(--primary) 12%, transparent); }

/* Aspectos con estrellas (varias filas) */
.rating-grid { display: flex; flex-direction: column; gap: 6px; }
.rating-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}
.rating-row-label { display: inline-flex; align-items: center; gap: 8px; font-size: 0.95rem; }
.rating-icon { font-size: 1.1rem; line-height: 1; }
.rating-row .stars { display: inline-flex; gap: 4px; }

/* Paginación, condiciones y fichas repetibles */
.hidden { display: none !important; }
.page { display: block; }
.step { text-align: right; margin: 0 0 8px; }
.pager { display: flex; gap: 10px; align-items: center; }
.pager .submit { flex: 1; }
.submit.ghost { background: transparent; color: var(--fg); border: 1px solid rgba(127, 127, 127, .4); }
.repeat-item {
  border: 1px solid rgba(127, 127, 127, .25);
  border-radius: 10px;
  padding: 10px;
  margin-top: 10px;
}
.repeat-item-title { margin: 0 0 8px; font-weight: 600; font-size: .9rem; }

/* La imagen nunca invade la superficie legible ni captura interacciones. */
body.has-background-image { background-size: cover; background-position: center; background-repeat: no-repeat; min-height: 100vh; }
.has-background-image .app { background: var(--bg); min-height: calc(100vh - 32px); max-width: min(520px, calc(100% - 24px)); margin: 16px auto; box-shadow: 0 18px 48px color-mix(in srgb, var(--shadow) 28%, transparent); }
.policy { margin: 20px 0; border-top: 1px solid var(--border); padding-top: 16px; overflow-wrap: anywhere; }
.policy-content { white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 16px; }
.policy-accept { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; }
.policy-message { white-space: pre-wrap; overflow-wrap: anywhere; }
.policy-accept input { flex: 0 0 auto; width: 20px; height: 20px; accent-color: var(--primary); }
.policy a, .policy-link { color: var(--primary); }
.policy-link { background: none; border: 0; padding: 0; text-decoration: underline; font: inherit; cursor: pointer; }
#policy-dialog { width: min(560px, calc(100% - 32px)); max-height: 80vh; overflow: auto; background: var(--bg); color: var(--fg); border: 1px solid var(--border); padding: 24px; }

@media (max-width: 520px) {
  body[data-layout="visual_options"] .block[data-type="choice"] .chips { grid-template-columns: 1fr; }
}

/* Opción "Otra…" con texto libre (equivalente a Google Forms). */
.chip-other { font-style: italic; }
.other-wrap { margin-top: 10px; }
.other-wrap[hidden] { display: none; }
.other-input { width: 100%; }

.redirect-note { margin-top: 12px; font-size: 13px; color: var(--muted, inherit); }
.redirect-note #redirect-count { font-variant-numeric: tabular-nums; font-weight: 600; }
