:root {
  color-scheme: light;
  --royal: #3f5ba3;
  --blue: #5d8fd2;
  --blue-strong: #386fc0;
  --sky: #c7e3f7;
  --sky-soft: #edf7fd;
  --ink: #231f20;
  --muted: #687487;
  --line: #dce6ee;
  --surface: #ffffff;
  --background: #f1f7fb;
  --danger: #b42318;
  --success: #198754;
  --shadow: 0 18px 48px rgba(42, 74, 113, 0.12);
  --radius-lg: 24px;
  --radius-md: 17px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--background); }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(199, 227, 247, 0.78), transparent 30rem),
    linear-gradient(180deg, #fbfdff 0, var(--background) 28rem);
}

button, input, select, textarea { font: inherit; }
button, summary, label { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.app-shell {
  width: min(100%, 780px);
  min-height: 100vh;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 80px rgba(53, 89, 126, 0.07);
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  padding: max(14px, env(safe-area-inset-top)) 20px 14px;
  border-bottom: 1px solid rgba(93, 143, 210, 0.16);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.brand-row, .progress-head, .action-bar, .study-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand-logo {
  display: block;
  width: 186px;
  height: 56px;
  object-fit: contain;
  object-position: left center;
}

.prototype-badge {
  padding: 6px 9px;
  border: 1px solid #c9dcef;
  border-radius: 999px;
  color: var(--royal);
  background: #f6faff;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.progress-head { margin-top: 13px; }
.progress-head p { margin: 0; }
.eyebrow {
  color: var(--blue-strong);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.progress-label { margin-top: 3px !important; font-size: 0.93rem; font-weight: 750; }
.progress-percent { color: var(--royal); font-size: 0.87rem; font-weight: 800; }

.progress-track {
  height: 5px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eff5;
}
.progress-fill {
  display: block;
  width: 25%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--royal), #70b4e4);
  transition: width 260ms ease;
}

.step-dots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.step-dots li { display: grid; justify-items: center; gap: 4px; color: #8794a5; }
.step-dots span {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border: 1px solid #d4dfea;
  border-radius: 50%;
  background: white;
  font-size: 0.75rem;
  font-weight: 800;
}
.step-dots small { font-size: 0.67rem; }
.step-dots li.is-active, .step-dots li.is-complete { color: var(--royal); }
.step-dots li.is-active span { border-color: var(--royal); color: white; background: var(--royal); box-shadow: 0 0 0 5px rgba(93, 143, 210, 0.14); }
.step-dots li.is-complete span { border-color: var(--blue); color: var(--royal); background: var(--sky-soft); }

main { padding: 26px 16px 120px; }
.step-panel { animation: panel-in 280ms ease both; }
.step-panel[hidden] { display: none; }
@keyframes panel-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.section-heading {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 13px;
  align-items: start;
  margin: 0 4px 20px;
}
.section-number {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px 5px 14px 14px;
  color: white;
  background: linear-gradient(145deg, var(--royal), var(--blue));
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.05em;
  box-shadow: 0 8px 20px rgba(63, 91, 163, 0.22);
}
h1 { margin: 0; font-size: clamp(1.5rem, 7vw, 2rem); line-height: 1.08; letter-spacing: -0.03em; }
.section-heading p { margin: 6px 0 0; color: var(--muted); font-size: 0.96rem; line-height: 1.45; }

.form-card, .calm-note, .study-group, .review-card, .consent-row, .folio-card {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.form-card { padding: 19px; border-radius: var(--radius-lg); }
.field-grid { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; }
.field > span, fieldset legend { font-size: 0.88rem; font-weight: 760; }
.field b { color: var(--blue-strong); }
.field small { color: var(--muted); font-size: 0.75rem; line-height: 1.35; }

input, select, textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid #cfdbe6;
  border-radius: 13px;
  outline: none;
  color: var(--ink);
  background: #fbfdff;
  font-size: 1rem;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
input, select { padding: 0 14px; }
textarea { min-height: 112px; padding: 13px 14px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #8b97a6; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); background: white; box-shadow: 0 0 0 4px rgba(93, 143, 210, 0.15); }
input:user-invalid, select:user-invalid { border-color: #e28a84; }

.privacy-note { margin: 14px 8px 0; color: var(--muted); font-size: 0.77rem; line-height: 1.45; }
.calm-note {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 11px;
  align-items: start;
  margin-top: 15px;
  padding: 15px;
  border-color: #cfe3f3;
  border-radius: var(--radius-md);
  color: #38516a;
  background: var(--sky-soft);
  box-shadow: none;
}
.calm-note p { margin: 1px 0 0; font-size: 0.86rem; line-height: 1.45; }
.note-icon { display: grid; width: 26px; height: 26px; place-items: center; border-radius: 50%; color: white; background: var(--blue); font-weight: 850; }

.study-toolbar { align-items: stretch; margin-bottom: 13px; }
.search-field { position: relative; flex: 1; }
.search-field svg { position: absolute; top: 15px; left: 14px; width: 20px; fill: none; stroke: var(--muted); stroke-linecap: round; stroke-width: 1.8; }
.search-field input { padding-left: 43px; }
.selection-count { display: grid; min-width: 100px; place-items: center; padding: 0 10px; border-radius: 13px; color: var(--royal); background: var(--sky); font-size: 0.75rem; font-weight: 800; text-align: center; }
.validation-message { margin: 0 2px 12px; color: var(--danger); font-size: 0.84rem; font-weight: 700; }
.submission-error {
  margin: 18px 0 0;
  padding: 14px 16px;
  border: 1px solid #efb5ae;
  border-radius: 13px;
  color: #8f2018;
  background: #fff4f2;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.45;
}
.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.primary-button:disabled { cursor: wait; opacity: .72; }

.study-groups { display: grid; gap: 11px; }
.study-group { overflow: hidden; border-radius: var(--radius-md); box-shadow: 0 8px 28px rgba(42, 74, 113, 0.08); }
.study-group[hidden] { display: none; }
.study-group summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 70px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  background: linear-gradient(90deg, #fff, #f8fbfe);
}
.study-group summary::-webkit-details-marker { display: none; }
.study-group summary > span:first-child { display: grid; gap: 3px; }
.study-group summary b { font-size: 0.98rem; }
.study-group summary small { color: var(--muted); font-size: 0.76rem; }
.group-count { display: grid; width: 29px; height: 29px; place-items: center; border-radius: 50%; color: var(--royal); background: var(--sky); font-size: 0.75rem; font-weight: 850; }
.study-group[open] summary { border-bottom: 1px solid var(--line); background: linear-gradient(90deg, var(--sky-soft), #fff); }
.option-list { display: grid; gap: 9px; padding: 12px; }

.check-row {
  display: flex;
  min-height: 49px;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #f8fafc;
  font-size: 0.93rem;
  font-weight: 620;
  line-height: 1.35;
  transition: background 160ms ease, border-color 160ms ease;
}
.check-row:has(input:checked) { border-color: #9dc7e7; color: #243f72; background: #eef8fe; }
.check-row input, .sub-check input, .inline-choice input, .consent-row input {
  width: 21px;
  height: 21px;
  min-height: 0;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--royal);
  box-shadow: none;
}
.compound-option { display: grid; gap: 4px; }
.sub-check { display: flex; align-items: center; gap: 8px; margin-left: 42px; color: var(--muted); font-size: 0.82rem; }
.sub-check input { width: 17px; height: 17px; }

.inline-choice { display: flex; flex-wrap: wrap; gap: 9px; margin: 4px 0 0; padding: 12px; border: 1px dashed #bfd1df; border-radius: 13px; }
.inline-choice legend { padding: 0 5px; color: #526174; font-size: 0.78rem; }
.inline-choice legend b { color: var(--blue-strong); }
.inline-choice label { display: flex; align-items: center; gap: 7px; min-height: 40px; padding: 8px 11px; border-radius: 10px; background: #f4f8fb; font-size: 0.84rem; font-weight: 700; }
.inline-choice label:has(input:checked) { color: #233e72; background: var(--sky); }
.compact-field { margin: 3px 0; padding: 10px 12px; border-radius: 12px; background: #f8fafc; }
.compact-field input { min-height: 44px; background: white; }
.other-analysis { flex-wrap: wrap; }
.other-analysis > input[type="text"] { min-height: 42px; flex: 1 1 170px; }
.notes-card { display: grid; gap: 17px; margin-top: 14px; }
.branch-card { margin-bottom: 14px; }

.review-stack { display: grid; gap: 12px; }
.review-card { overflow: hidden; border-radius: var(--radius-md); box-shadow: 0 8px 28px rgba(42, 74, 113, 0.08); }
.review-card header { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; border-bottom: 1px solid var(--line); background: var(--sky-soft); }
.review-card h2 { margin: 0; font-size: 0.95rem; }
.review-card button { border: 0; color: var(--royal); background: transparent; font-size: 0.78rem; font-weight: 800; }
.review-body { display: grid; gap: 11px; padding: 15px; }
.review-row { display: grid; gap: 2px; }
.review-row span { color: var(--muted); font-size: 0.74rem; }
.review-row strong { font-size: 0.91rem; line-height: 1.45; }
.study-review-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.study-review-list li { position: relative; padding-left: 20px; font-size: 0.88rem; line-height: 1.4; }
.study-review-list li::before { content: ""; position: absolute; top: 0.45em; left: 1px; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }

.consent-row { display: grid; grid-template-columns: auto 1fr; gap: 11px; align-items: start; margin-top: 14px; padding: 15px; border-radius: var(--radius-md); box-shadow: none; font-size: 0.8rem; line-height: 1.48; }
.consent-row input { margin-top: 2px; }

.success-screen { padding: 22px 6px; text-align: center; }
.success-mark { display: grid; width: 76px; height: 76px; margin: 0 auto 22px; place-items: center; border-radius: 50%; color: white; background: linear-gradient(145deg, var(--royal), #68b3dc); box-shadow: 0 14px 30px rgba(63, 91, 163, 0.24); }
.success-mark svg { width: 40px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.1; }
.success-screen h1 { margin-top: 7px; }
.success-screen > p:not(.eyebrow) { max-width: 470px; margin: 14px auto; color: var(--muted); line-height: 1.55; }
.folio-card { display: grid; gap: 5px; max-width: 360px; margin: 24px auto; padding: 18px; border-radius: var(--radius-md); background: var(--sky-soft); box-shadow: none; }
.folio-card span { color: var(--muted); font-size: 0.76rem; }
.folio-card strong { color: var(--royal); font-size: 1.15rem; letter-spacing: 0.06em; }

.action-bar {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  width: min(100%, 780px);
  margin: 0 auto;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -12px 34px rgba(42, 74, 113, 0.1);
  backdrop-filter: blur(16px);
}
.primary-button, .secondary-button, .back-button {
  min-height: 52px;
  border-radius: 14px;
  font-weight: 800;
}
.primary-button { display: inline-flex; flex: 1; align-items: center; justify-content: center; gap: 7px; border: 0; color: white; background: linear-gradient(110deg, var(--royal), var(--blue-strong)); box-shadow: 0 10px 24px rgba(63, 91, 163, 0.25); }
.finish-button { display: none; }
.action-bar.is-complete { justify-content: flex-end; }
.action-bar.is-complete .back-button, .action-bar.is-complete #nextButton { display: none; }
.action-bar.is-complete .finish-button { display: inline-flex; }
.primary-button svg, .back-button svg { width: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.back-button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 100px; border: 1px solid #cbd9e5; color: var(--royal); background: white; }
.secondary-button { border: 1px solid var(--royal); color: var(--royal); background: white; }
.full-button { width: 100%; max-width: 360px; }
.text-button { margin-top: 13px; border: 0; color: var(--royal); background: transparent; font-size: 0.86rem; font-weight: 800; }
.site-footer { padding: 4px 20px 118px; color: var(--muted); font-size: 0.76rem; line-height: 1.35; text-align: center; }
.site-footer p { margin: 4px 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; }
.print-only { display: none; }

@media (min-width: 700px) {
  .app-header { padding-right: 34px; padding-left: 34px; }
  main { padding-right: 34px; padding-left: 34px; }
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-wide { grid-column: 1 / -1; }
  .step-dots small { font-size: 0.72rem; }
  .option-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compound-option, .compact-field, .inline-choice { grid-column: 1 / -1; }
  .notes-card { grid-template-columns: 1.4fr 1fr; align-items: start; }
  .delivery-choice { margin-top: 0; }
  .review-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-row-wide, .study-review-list { grid-column: 1 / -1; }
}

@media (max-width: 375px) {
  .brand-logo { width: 162px; }
  .prototype-badge { font-size: 0.64rem; }
  .step-dots small { display: none; }
  .study-toolbar { flex-direction: column; }
  .selection-count { min-height: 36px; }
}

@media print {
  @page { size: Letter portrait; margin: 9mm; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  html, body { background: white; }
  body { color: #231f20; font-size: 10pt; }
  .app-header, .action-bar, .site-footer, .prototype-badge, .review-card button, .consent-row, .screen-only { display: none !important; }
  .print-only { display: block !important; }
  .app-shell { width: 100%; min-height: 0; margin: 0; overflow: visible; border: 0; border-radius: 0; background: white; box-shadow: none; }
  main { padding: 0; }
  .step-panel { display: none !important; }
  .step-panel[data-step="4"] { display: block !important; }
  #successScreen { display: none !important; }
  #reviewScreen { display: block !important; }
  .print-document-header {
    position: relative;
    display: grid !important;
    grid-template-columns: 145px 1fr 185px;
    align-items: center;
    gap: 18px;
    margin-bottom: 13px;
    padding: 17px 15px 15px;
    overflow: hidden;
    border-top: 9px solid #3f5ba3;
    border-bottom: 1px solid #c7d9e8;
  }
  .print-document-header::before {
    position: absolute;
    top: 0;
    right: -40px;
    width: 44%;
    height: 9px;
    background: #b9dcf3;
    content: "";
    transform: skewX(-34deg);
    transform-origin: right top;
  }
  .print-document-header img { width: 145px; height: auto; }
  .print-title-group { text-align: center; }
  .print-title-group p { margin: 0 0 4px; color: #5d8fd2; font-size: 8pt; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
  .print-title-group h1 { margin: 0; color: #2f4d85; font-size: 22pt; line-height: 1.05; letter-spacing: -.035em; }
  .print-metadata { display: grid; gap: 7px; margin: 0; padding: 10px 12px; border-radius: 10px; background: #edf7fd; }
  .print-metadata div { display: grid; gap: 2px; }
  .print-metadata dt { color: #5d7087; font-size: 7pt; font-weight: 700; text-transform: uppercase; }
  .print-metadata dd { margin: 0; color: #243f72; font-size: 8.3pt; font-weight: 800; line-height: 1.25; }
  .review-stack { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .review-stack > .review-card:last-child { grid-column: 1 / -1; }
  .review-card { overflow: hidden; break-inside: avoid; border: 1px solid #bed5e7; border-radius: 11px; background: white; box-shadow: none; }
  .review-card header { min-height: 32px; padding: 7px 11px; border-bottom: 1px solid #bed5e7; background: #c7e3f7; }
  .review-card h2 { color: #294b86; font-size: 10pt; }
  .review-body { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 18px; padding: 10px 12px 12px; }
  .review-row span { color: #67788d; font-size: 7pt; }
  .review-row strong { font-size: 8.5pt; line-height: 1.28; }
  .review-row-wide, .study-review-list { grid-column: 1 / -1; }
  .study-review-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 18px; }
  .study-review-list li { padding-left: 14px; font-size: 8.2pt; line-height: 1.25; }
  .study-review-list li::before { top: .38em; width: 5px; height: 5px; }
  .print-document-footer { margin-top: 12px; overflow: hidden; border-radius: 10px; color: white; text-align: center; background: #3f5ba3; }
  .print-document-footer p { margin: 0; padding: 6px 13px; font-size: 7.2pt; line-height: 1.3; }
  .print-document-footer p:first-child { font-size: 8pt; background: #2f4d85; }
  .print-document-footer p + p { border-top: 1px solid rgba(255,255,255,.22); }
  .print-document-footer span { padding: 0 8px; color: #bfe2f7; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Composición responsive: amplia y controlada en escritorio, compacta en móvil. */
.app-shell {
  width: min(100%, 1180px);
}

.action-bar {
  width: min(100%, 1180px);
}

@media (min-width: 960px) {
  .app-shell {
    width: min(calc(100% - 56px), 1180px);
    margin: 28px auto;
    overflow: hidden;
    border: 1px solid rgba(93, 143, 210, 0.13);
    border-radius: 28px;
    box-shadow: 0 28px 90px rgba(42, 74, 113, 0.12);
  }

  .app-header {
    padding: 20px 48px 16px;
  }

  main {
    padding: 42px 48px 138px;
  }

  .section-heading {
    margin-bottom: 28px;
  }

  .form-card {
    padding: 28px;
  }

  .field-grid {
    column-gap: 24px;
    row-gap: 21px;
  }

  .study-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 16px;
  }

  .study-groups > .study-group:first-child {
    grid-column: 1 / -1;
  }

  .study-groups > .study-group:not(:first-child) .option-list {
    grid-template-columns: 1fr;
  }

  .notes-card {
    margin-top: 20px;
    padding: 28px;
  }

  .review-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .review-stack > .review-card:last-child {
    grid-column: 1 / -1;
  }

  .action-bar {
    width: min(calc(100% - 56px), 1180px);
    padding-right: 48px;
    padding-left: 48px;
    border-radius: 0 0 28px 28px;
  }

  .site-footer {
    padding-bottom: 126px;
  }
}
