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

:root {
  --teal:      #0F4C5C;
  --teal-dark: #0B3945;
  --teal-soft: #BBD3DA;
  --teal-pale: #EEF5F7;
  --coral:     #E8705A;
  --coral-pale:#FEF0ED;
  --ink:       #1F2937;
  --muted:     #5B6570;
  --faint:     #8F9BA5;
  --line:      #E3E8ED;
  --surface-1: #F4F7F9;
  --surface-2: #FFFFFF;
  --bg:        #E8EDEF;
  --ok:        #16794A;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

#app { width: 100%; max-width: 460px; }

/* Card */
.card {
  background: var(--surface-2);
  border: 0.5px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.card-header {
  background: var(--teal);
  padding: 14px 18px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
}
.logo-img { height: 22px; width: auto; filter: brightness(0) invert(1); display: block; }
.step-lbl {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--teal-soft);
}

.prog-track { height: 3px; background: var(--ink); position: relative; }
.prog-fill {
  position: absolute; top: 0; left: 0; height: 100%; width: 0;
  background: var(--coral);
  transition: width .3s ease;
}
.prog-track.full .prog-fill { width: 100%; background: var(--teal); }

/* Screens */
.screen { display: none; }
.screen.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.card-body { padding: 20px 18px 6px; }
.center-body {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 10px;
  padding: 56px 24px;
}
.muted { font-size: 13px; color: var(--muted); line-height: 1.5; }

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Question */
.q-label {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--faint); font-weight: 500; margin-bottom: 8px;
}
.q-title {
  font-family: 'Syne', sans-serif;
  font-size: 20px; font-weight: 500; line-height: 1.25;
  color: var(--ink); margin-bottom: 4px;
}
.q-sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; line-height: 1.45; }

.opts-list { display: flex; flex-direction: column; gap: 8px; }
.opt-btn {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  width: 100%; min-height: 50px;
  padding: 13px 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2);
  font: inherit; text-align: left; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .15s, background .15s;
}
.opt-btn:hover { border-color: var(--teal); }
.opt-btn.sel { border: 2px solid var(--teal); padding: 12px 15px; background: var(--teal-pale); }
.opt-text { font-size: 15px; color: var(--ink); }
.opt-btn.sel .opt-text { font-weight: 500; color: var(--teal); }
.opt-circle {
  width: 20px; height: 20px; flex-shrink: 0;
  border-radius: 50%; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
}
.opt-btn.sel .opt-circle { background: var(--teal); border-color: var(--teal); }
.opt-btn.sel .opt-circle::after {
  content: ''; width: 7px; height: 4px;
  border-left: 1.5px solid #fff; border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}

.opts-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.opt-grid-btn {
  padding: 18px 4px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2);
  font-family: 'Syne', sans-serif; font-size: 19px; font-weight: 500;
  color: var(--ink); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .15s, background .15s;
}
.opt-grid-btn:hover { border-color: var(--teal); }
.opt-grid-btn.sel { border: 2px solid var(--teal); background: var(--teal-pale); color: var(--teal); }
.grid-hint { font-size: 12px; color: var(--faint); text-align: center; margin-top: 8px; }

.opt-desc {
  margin-top: 10px;
  padding: 11px 14px;
  background: var(--teal-pale);
  border: 1px solid var(--teal-soft);
  border-radius: 8px;
  font-size: 13px; line-height: 1.55; color: var(--muted);
  animation: fadeDown .2s ease;
}
@keyframes fadeDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.nav-row { display: flex; gap: 8px; padding: 18px 0 18px; }
.btn-back, .btn-next {
  min-height: 46px; padding: 11px;
  border-radius: 8px; font-family: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-back {
  flex: 1; border: 1px solid var(--line);
  background: var(--surface-1); color: var(--muted); font-size: 14px;
}
.btn-next {
  flex: 2; border: 0; background: var(--teal); color: #fff;
  font-size: 15px; font-weight: 500;
}
.btn-next:disabled { opacity: .35; cursor: default; }
.btn-next.solo { flex: 1; width: 100%; }

/* Processing */
.processing { padding: 60px 24px 56px; gap: 8px; }
.pulse { display: flex; gap: 8px; margin-bottom: 18px; height: 14px; align-items: center; }
.pulse span {
  width: 12px; height: 12px; border-radius: 3px;
  background: var(--teal);
  animation: pulse 1.2s ease-in-out infinite;
}
.pulse span:nth-child(2) { animation-delay: .15s; background: var(--coral); }
.pulse span:nth-child(3) { animation-delay: .3s; }
@keyframes pulse {
  0%, 80%, 100% { transform: scale(.55); opacity: .35; }
  40%           { transform: scale(1);   opacity: 1; }
}
.proc-title {
  font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 500;
  line-height: 1.3; color: var(--ink); max-width: 280px;
}
.proc-micro {
  margin-top: 14px; min-height: 18px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--teal);
  transition: opacity .25s;
}
.proc-micro.fade { opacity: 0; }

/* Result */
.result { padding-bottom: 20px; }
.res-label {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--teal); font-weight: 600; margin-bottom: 10px;
}
.res-objetivo {
  font-family: 'Syne', sans-serif; font-size: 26px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .02em; line-height: 1.15;
  color: var(--ink); margin-bottom: 8px; overflow-wrap: anywhere;
}
.res-line { font-size: 15px; color: var(--muted); line-height: 1.5; }
.res-line:last-of-type { margin-bottom: 20px; }

.doc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.doc-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 12px;
  border-radius: 8px; font-size: 14px; font-weight: 500;
  border: 0; font-family: inherit;
  text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .15s, background .15s;
}
.doc-btn:disabled { cursor: default; opacity: .75; }
.doc-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.doc-feedback {
  min-height: 0; font-size: 12px; color: var(--ok); font-weight: 500;
  margin-top: 0; text-align: center;
}
.doc-feedback:not(:empty) { margin-top: 8px; }

.doc-main {
  background: var(--teal);
  border-radius: 12px;
  padding: 18px 16px 16px;
  margin-bottom: 22px;
  color: #fff;
}
.doc-main-text { margin-bottom: 14px; }
.doc-main-title { font-family: 'Syne', sans-serif; font-size: 19px; font-weight: 600; }
.doc-main-sub { font-size: 13px; color: var(--teal-soft); margin-top: 2px; }
.doc-main .doc-btn.primary { background: var(--coral); color: #fff; }
.doc-main .doc-btn.secondary { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25); }
.doc-main .doc-feedback { color: #CFF3DE; }
.doc-feedback.error { color: #B4432E; }
.doc-main .doc-feedback.error { color: #FFD2C8; }

.section-title {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--faint); font-weight: 600; margin-bottom: 10px;
}
.doc-list { display: flex; flex-direction: column; gap: 8px; }
.doc-item {
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-1);
  padding: 13px 14px;
}
.doc-item-title { font-size: 15px; font-weight: 500; color: var(--ink); margin-bottom: 10px; }
.doc-item .doc-btn.secondary { background: var(--surface-2); color: var(--teal); border: 1px solid var(--line); }
.doc-item .doc-btn.primary { background: var(--teal); color: #fff; }
.doc-unavailable { font-size: 12px; color: var(--muted); margin-top: 8px; text-align: center; }
.doc-main .doc-unavailable { color: var(--teal-soft); }

/* Error */
.err-body { padding: 40px 24px 32px; text-align: center; }
.err-icon { margin-bottom: 14px; }
.err-title {
  font-family: 'Syne', sans-serif; font-size: 19px; font-weight: 500;
  color: var(--ink); margin-bottom: 8px;
}
.err-msg { font-size: 14px; color: var(--muted); line-height: 1.55; margin-bottom: 20px; }
#btn-retry { margin-bottom: 20px; }
.err-contact { font-size: 12px; color: var(--faint); line-height: 1.6; }
.err-contact a { color: var(--teal); text-decoration: none; }

button:focus-visible, a:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

[hidden] { display: none !important; }
