/* ============================================
   CDS — Estilo amigable (inspirado en mockups)
   ============================================ */

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

:root {
  --teal-900: #1f5f5b;
  --teal-700: #2c8378;
  --teal-500: #3aa494;
  --teal-300: #7ec8b9;
  --mint-100: #d8f0e8;
  --bg-100:   #eef3f3;
  --bg-200:   #e2eceb;
  --text-900: #1c2a2a;
  --text-700: #4a5d5d;
  --text-500: #7d8c8c;
  --white:    #ffffff;
  --shadow-lg: 0 25px 50px -12px rgba(28, 90, 80, 0.25);
  --shadow-md: 0 10px 30px -10px rgba(28, 90, 80, 0.2);
  --radius-lg: 28px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

html, body {
  height: 100%;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-900);
  background: linear-gradient(135deg, #f0f5f4 0%, #e2eceb 50%, #d8f0e8 100%);
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  align-items: safe center; /* en pantallas largas no recorta el contenido por arriba */
  justify-content: center;
  padding: 32px 24px;
  position: relative;
}

/* Manchas decorativas de fondo */
.bg-shape {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  z-index: 0;
  pointer-events: none;
}
.shape-1 { width: 400px; height: 400px; background: var(--teal-300); top: -100px; left: -100px; }
.shape-2 { width: 350px; height: 350px; background: #c4e4dc; bottom: -100px; right: -100px; }
.shape-3 { width: 250px; height: 250px; background: #b4dbd0; top: 50%; left: 60%; }

.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1100px;
}

/* ============================================
   Card y pantallas
   ============================================ */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.card:not(.card-single) { min-height: 580px; }

.card.card-single { grid-template-columns: 1fr; max-width: 820px; margin: 0 auto; }

.screen { display: none; animation: fadeIn 0.5s ease; }
.screen.active { display: grid; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Lado izquierdo decorativo (welcome) */
.card-left {
  position: relative;
  background: linear-gradient(160deg, #a8dccc 0%, #6cb5a3 50%, #2c8378 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card-left::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(255,255,255,0.2) 0%, transparent 30%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.15) 0%, transparent 40%);
}
.welcome-text {
  position: relative;
  text-align: center;
  color: var(--white);
  padding: 40px;
}
.welcome-text h2 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 4px;
  margin-bottom: 14px;
}
.welcome-text p {
  font-size: 16px;
  font-weight: 300;
  opacity: 0.95;
  line-height: 1.6;
}

/* Lado derecho (formularios) */
.card-right {
  padding: 48px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* En pantallas con mucho contenido (resultados) no centrar verticalmente */
.card-single .card-right { justify-content: flex-start; padding: 44px 44px; }

.step-tag {
  display: inline-block;
  background: var(--mint-100);
  color: var(--teal-700);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}

/* Botón flecha de regreso */
.btn-back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--teal-700);
  border: 1.5px solid #d4e2e0;
  border-radius: 999px;
  padding: 8px 16px 8px 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 18px;
}
.btn-back:hover {
  background: var(--mint-100);
  border-color: var(--teal-500);
  transform: translateX(-3px);
}
.btn-back svg { transition: transform 0.2s; }
.btn-back:hover svg { transform: translateX(-2px); }

h1 {
  font-size: 32px;
  font-weight: 600;
  color: var(--text-900);
  margin-bottom: 8px;
}

h3.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-900);
  margin: 28px 0 14px;
}

.subtitle {
  font-size: 15px;
  color: var(--text-500);
  margin-bottom: 28px;
}

.footnote {
  font-size: 12px;
  color: var(--text-500);
  margin-top: 16px;
}

/* ============================================
   Forms
   ============================================ */
.form { display: flex; flex-direction: column; gap: 18px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }

.hidden { display: none !important; }

.section-divider {
  font-size: 11px;
  font-weight: 600;
  color: var(--teal-700);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 8px 0 4px;
  padding-bottom: 6px;
  border-bottom: 1px dashed #d4e2e0;
}

/* Selector de tipo (Niño / Adulto) */
.type-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 22px;
}
.type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 12px;
  background: #f6faf9;
  border: 2px solid #e0e7e6;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.18s;
  text-align: center;
}
.type-card:hover { border-color: var(--teal-500); transform: translateY(-2px); }
.type-card.active {
  border-color: var(--teal-500);
  background: linear-gradient(135deg, #d8f0e8, #b8e0d4);
  box-shadow: 0 8px 20px -8px rgba(58, 164, 148, 0.5);
}
.type-card .type-emoji { font-size: 32px; }
.type-card .type-title { font-weight: 600; color: var(--text-900); font-size: 14px; }
.type-card .type-desc { font-size: 11px; color: var(--text-500); }

/* Tarjeta "Test de Raven" en pantalla de bienvenida */
.raven-card {
  display: flex; align-items: center; gap: 14px;
  margin-top: 14px; padding: 14px 18px;
  border: 1.5px solid #c8e0f8;
  border-radius: 16px;
  background: linear-gradient(135deg, #e8f4ff, #d4e8ff);
  color: inherit; text-decoration: none;
  transition: all 0.18s; cursor: pointer;
}
.raven-card:hover { border-color: #3a8ac4; transform: translateY(-2px); box-shadow: 0 8px 20px -8px rgba(58,138,196,0.4); }
.raven-card-emoji { font-size: 28px; flex-shrink: 0; }
.raven-card-text { display: flex; flex-direction: column; flex: 1; }
.raven-card-title { font-weight: 600; font-size: 14px; color: #1a3a5c; }
.raven-card-desc { font-size: 11px; color: #4a6a8a; }
.raven-card-arrow { font-size: 20px; color: #3a8ac4; font-weight: 700; }

/* ── Selector de prueba (pantalla home) ── */
.test-picker {
  display: flex; flex-direction: column; gap: 14px;
  margin-top: 28px;
}
.test-pick-card {
  display: flex; align-items: center; gap: 18px;
  padding: 18px 22px;
  border: 1.5px solid #d8ede8;
  border-radius: 18px;
  background: #f6faf9;
  cursor: pointer; text-decoration: none; color: inherit;
  font-family: inherit;
  transition: all 0.18s;
  width: 100%;
}
.test-pick-card:hover:not(.test-pick-soon) {
  border-color: var(--teal-500);
  background: var(--mint-100);
  transform: translateY(-2px);
  box-shadow: 0 8px 22px -8px rgba(58,164,148,0.4);
}
.test-pick-card.test-pick-soon {
  opacity: 0.55; cursor: default; pointer-events: none;
}
.test-pick-emoji { font-size: 36px; flex-shrink: 0; }
.test-pick-text { display: flex; flex-direction: column; flex: 1; text-align: left; }
.test-pick-title { font-weight: 700; font-size: 17px; color: var(--text-900); }
.test-pick-desc { font-size: 12px; color: var(--text-500); margin-top: 2px; }
.test-pick-arrow { font-size: 22px; color: var(--teal-500); font-weight: 700; flex-shrink: 0; }

/* Pantalla "lo lograste" / "gracias" */
.big-emoji {
  font-size: 80px;
  line-height: 1;
  margin-bottom: 12px;
  animation: pop 0.6s ease;
}
@keyframes pop {
  0%   { transform: scale(0.3); opacity: 0; }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
.finish-text {
  font-size: 16px;
  color: var(--text-700);
  line-height: 1.7;
  margin-bottom: 12px;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-700);
}

.field input, .field select {
  padding: 14px 18px;
  border: 1.5px solid #e0e7e6;
  border-radius: 999px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-900);
  background: var(--white);
  outline: none;
  transition: all 0.2s;
}

.field input:focus, .field select:focus {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 4px rgba(58, 164, 148, 0.15);
}

/* ============================================
   Botones
   ============================================ */
.btn-primary {
  margin-top: 8px;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
  color: var(--white);
  border: none;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: var(--shadow-md);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 15px 35px -10px rgba(58, 164, 148, 0.5);
}
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  padding: 14px 28px;
  background: transparent;
  color: var(--teal-700);
  border: 1.5px solid #d4e2e0;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover:not(:disabled) {
  background: var(--mint-100);
  border-color: var(--teal-500);
}
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================
   Instrucciones
   ============================================ */
.instructions-text {
  font-size: 15px;
  color: var(--text-700);
  line-height: 1.7;
  margin-bottom: 22px;
}

.legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #f6faf9;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-700);
}
.legend strong { color: var(--text-900); margin-right: 6px; }

.dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
}
.dot-5 { background: #2c8378; }
.dot-4 { background: #5fb3a4; }
.dot-3 { background: #a8c8c4; }
.dot-2 { background: #d4a574; }
.dot-1 { background: #c97a6b; }

/* ============================================
   Cuestionario
   ============================================ */
.progress-row { margin-bottom: 24px; }

.progress-bar {
  margin-top: 8px;
  height: 6px;
  background: #e6efee;
  border-radius: 999px;
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal-500), var(--teal-700));
  width: 0%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.question-text {
  font-size: 22px;
  font-weight: 500;
  color: var(--text-900);
  line-height: 1.5;
  margin: 16px 0 28px;
  min-height: 70px;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

.option {
  padding: 16px 22px;
  border: 1.5px solid #e0e7e6;
  border-radius: var(--radius-md);
  background: var(--white);
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  color: var(--text-700);
  user-select: none;
}
.option:hover {
  border-color: var(--teal-500);
  background: #f6faf9;
  transform: translateX(2px);
}
.option.selected {
  border-color: var(--teal-500);
  background: linear-gradient(135deg, #d8f0e8, #b8e0d4);
  color: var(--text-900);
  font-weight: 500;
  box-shadow: 0 4px 12px -4px rgba(58, 164, 148, 0.4);
}
.option .radio {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid #c4d3d1;
  flex-shrink: 0;
  display: grid; place-items: center;
  transition: all 0.2s;
}
.option.selected .radio {
  border-color: var(--teal-700);
  background: var(--teal-700);
}
.option.selected .radio::after {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--white);
}

.nav-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}
.nav-row .btn-primary, .nav-row .btn-secondary { margin-top: 0; flex: 1; max-width: 200px; }

/* ============================================
   Resultados
   ============================================ */
.result-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 18px 0 8px;
}

.result-pill {
  padding: 22px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--white);
}
.pill-td { background: linear-gradient(135deg, #c97a6b, #a85a4d); }
.pill-tp { background: linear-gradient(135deg, var(--teal-500), var(--teal-700)); }

.pill-label { font-size: 12px; font-weight: 500; opacity: 0.9; }
.pill-value { font-size: 32px; font-weight: 700; }
.pill-extra { font-size: 13px; opacity: 0.95; }

.subscales {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.sub-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f6faf9;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.sub-item .name { color: var(--text-700); font-weight: 500; }
.sub-item .score { color: var(--text-900); font-weight: 600; }
.sub-item .pc { color: var(--teal-700); font-size: 12px; margin-left: 6px; }

.interpretation {
  margin-top: 24px;
  padding: 18px;
  background: #fff8f0;
  border-radius: var(--radius-md);
  border-left: 4px solid #e0a878;
  font-size: 14px;
  color: var(--text-700);
  line-height: 1.6;
}

/* Bloque didáctico: cómo se obtuvo el resultado */
.calc-explainer {
  margin-top: 24px;
  padding: 20px 22px;
  background: #f6faf9;
  border-radius: var(--radius-md);
  border: 1px solid #e1ece9;
  font-size: 13.5px;
  color: var(--text-700);
  line-height: 1.65;
}
.calc-explainer h3 { color: var(--teal-700); font-size: 15px; margin-bottom: 10px; }
.calc-explainer ol { margin: 8px 0 0 18px; }
.calc-explainer ol li { margin-bottom: 6px; }
.calc-explainer .formula {
  display: inline-block;
  background: #fff;
  border: 1px solid #d8e6e3;
  border-radius: 6px;
  padding: 2px 8px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12.5px;
  color: var(--teal-700);
  margin: 0 2px;
}
.calc-explainer .scale-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.calc-explainer .scale-row > div {
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid #e1ece9;
}
.calc-explainer .scale-row strong { color: var(--text-900); display: block; margin-bottom: 4px; font-size: 13px; }
.calc-explainer .scale-row small { font-size: 12px; color: var(--text-500); }
@media (max-width: 600px) {
  .calc-explainer .scale-row { grid-template-columns: 1fr; }
}

/* === Detalle paso a paso del cálculo === */
.calc-detail { margin-top: 12px; }

/* ====== Loading overlay ====== */
#loading-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
#loading-overlay[hidden] { display: none; }
.loading-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.14);
  padding: 36px 44px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  min-width: 200px;
}
.loading-card p {
  margin: 0; font-size: 15px; font-weight: 500;
  color: var(--teal-700); text-align: center;
}
.spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--mint-100);
  border-top-color: var(--teal-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Banner de progreso guardado === */
.resume-banner {
  display: none;
}
.resume-banner:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff8e6;
  border: 1px solid #f0c674;
  border-left: 4px solid #d99a2b;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.resume-icon { font-size: 22px; flex-shrink: 0; }
.resume-info {
  display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0;
}
.resume-info strong { font-size: 13.5px; color: var(--text-900); }
.resume-info span { font-size: 12.5px; color: var(--text-700); }
.resume-prog { color: var(--teal-700) !important; font-weight: 500; }
.resume-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-sm { padding: 6px 14px !important; font-size: 13px !important; min-height: unset !important; }
.btn-ghost {
  background: transparent;
  color: var(--text-700);
  border: 1.5px solid var(--text-500);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  padding: 8px 18px;
  transition: background 0.15s, color 0.15s;
}
.btn-ghost:hover { background: var(--bg-200); color: var(--text-900); }
@media (max-width: 500px) {
  .resume-banner { flex-direction: column; align-items: flex-start; }
  .resume-actions { width: 100%; }
  .resume-actions button { flex: 1; }
}

.calc-step {
  margin-top: 18px;
  padding: 14px 16px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e1ece9;
}
.calc-step h4 {
  font-size: 14px;
  color: var(--teal-700);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.calc-step .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--teal-500);
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
}
.calc-step .step-desc { font-size: 12.5px; color: var(--text-700); margin: 6px 0; line-height: 1.55; }
.calc-step .step-list { font-size: 12.5px; color: var(--text-700); line-height: 1.55; padding-left: 22px; margin: 6px 0; }
.calc-step .step-list li { margin: 4px 0; }

.baremo-extra {
  margin-top: 14px;
  padding: 12px;
  background: var(--mint-100);
  border: 1px dashed var(--teal-500);
  border-radius: 8px;
}
.baremo-extra h5 {
  margin: 0 0 6px 0;
  font-size: 13px;
  color: var(--teal-700);
}

.note-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: #fff8e6;
  border: 1px solid #f0c674;
  border-left: 4px solid #d99a2b;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-700);
  line-height: 1.55;
}
.note-box p { margin: 0; }
.note-box code {
  background: #fff;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--text-900);
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin: 8px 0;
}
.mini-table th, .mini-table td {
  padding: 7px 9px;
  border-bottom: 1px solid #eef4f3;
  text-align: left;
}
.mini-table th { background: #f6faf9; color: var(--teal-700); font-weight: 600; font-size: 11.5px; }
.mini-table td.num { text-align: center; font-variant-numeric: tabular-nums; }
.mini-table tfoot td { background: #f6faf9; }
.mini-table tr.row-total td { background: #fff8f0; font-weight: 600; }

.pts {
  display: inline-block;
  min-width: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
}
.pts.dep { background: #fde2dc; color: #a85a4d; }
.pts.pos { background: #d8f0e8; color: var(--teal-700); }

.sub-detail {
  margin: 8px 0;
  border: 1px solid #e1ece9;
  border-radius: 10px;
  overflow: hidden;
  background: #fafdfc;
}
.sub-detail summary {
  cursor: pointer;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  list-style: none;
  user-select: none;
}
.sub-detail summary::-webkit-details-marker { display: none; }
.sub-detail summary::before {
  content: '▶';
  font-size: 9px;
  color: var(--teal-500);
  transition: transform 0.2s;
}
.sub-detail[open] summary::before { transform: rotate(90deg); }
.sub-detail summary:hover { background: #f0f7f5; }
.sub-tag-type {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.sub-tag-type.dep { background: #fde2dc; color: #a85a4d; }
.sub-tag-type.pos { background: #d8f0e8; color: var(--teal-700); }
.sub-pd {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-700);
  font-weight: 600;
}
.sub-detail[open] .calc-sub-table { padding: 0 14px 12px; }
.calc-sub-table { width: calc(100% - 28px); margin: 0 14px 8px; }
.calc-sub-table .reactivo { font-size: 12px; color: var(--text-700); }
.sub-detail[open] > p { margin: 0 14px 12px; }

@media (max-width: 600px) {
  .mini-table { font-size: 11.5px; }
  .mini-table th, .mini-table td { padding: 5px 6px; }
  .calc-sub-table .reactivo { font-size: 11px; }
  .sub-detail summary { font-size: 12px; flex-wrap: wrap; }
  .sub-pd { margin-left: 0; }
}

/* ============================================
   Responsive
   ============================================ */

/* Pantallas medianas (laptops 13"-14", ~1366x768) */
@media (max-width: 1200px) {
  .container { max-width: 960px; }
  .card-right { padding: 40px 40px; }
  .card-single .card-right { padding: 36px 36px; }
  h1 { font-size: 26px; }
  .welcome-text h2 { font-size: 32px; letter-spacing: 6px; }
  .pill-value { font-size: 28px; }
  .question-text { font-size: 19px; }
}

/* Tablet / laptop pequeño */
@media (max-width: 980px) {
  body { padding: 16px 12px; }
  .container { max-width: 720px; }
  .card { grid-template-columns: 1fr; min-height: auto; }
  .card-left { min-height: 180px; }
  .card-left .welcome-text { padding: 28px; }
  .welcome-text h2 { font-size: 28px; letter-spacing: 4px; }
  .welcome-text p { font-size: 14px; }
  .card-right { padding: 32px 28px; }
  .card-single .card-right { padding: 28px 24px; }
  .row { grid-template-columns: 1fr; }
  .result-summary { grid-template-columns: 1fr 1fr; gap: 10px; }
  .subscales { grid-template-columns: 1fr 1fr; }
}

/* Móviles */
@media (max-width: 600px) {
  body { padding: 8px 6px; }
  .card { border-radius: 20px; }
  .card-left { display: none; }
  .card-right { padding: 24px 18px; }
  .card-single .card-right { padding: 22px 16px; }
  h1 { font-size: 22px; }
  .subtitle { font-size: 14px; }
  .step-tag { font-size: 11px; padding: 5px 10px; }

  /* Selector de tipo de respondiente: en móvil 1 columna */
  .type-selector { grid-template-columns: 1fr !important; gap: 10px; }
  .type-card { padding: 14px 16px !important; }
  .type-emoji { font-size: 32px !important; }

  /* Pregunta y opciones */
  .question-text { font-size: 17px; line-height: 1.4; }
  .option { padding: 12px 14px; font-size: 14px; }
  .nav-row { flex-direction: column; }
  .nav-row .btn-primary, .nav-row .btn-secondary { max-width: 100%; }

  /* Resultados */
  .result-summary { grid-template-columns: 1fr; }
  .subscales { grid-template-columns: 1fr; }
  .pill-value { font-size: 26px; }
  .sub-item { padding: 10px 14px; font-size: 13px; }
  .interpretation, .calc-explainer { padding: 14px; font-size: 13px; }
  .calc-explainer h3 { font-size: 14px; }
  .calc-explainer ol { padding-left: 18px; }
  .calc-explainer .formula { display: inline-block; margin: 2px 0; }
  .finished-screen .big-emoji { font-size: 60px; }

  /* Inputs táctiles */
  input, select, button { font-size: 16px; }  /* evita zoom auto en iOS */
}

@media (max-width: 380px) {
  .card-right { padding: 20px 14px; }
  h1 { font-size: 20px; }
  .welcome-text h2 { font-size: 22px; letter-spacing: 2px; }
}

/* Tag de interpolación de centil/decatipo (manual p.32) */
.interp-tag { display: inline-block; font-size: 10px; padding: 1px 5px; margin-left: 4px; border-radius: 6px; background: #fff3cd; color: #7a5b00; border: 1px solid #f0d97a; vertical-align: middle; font-weight: 500; }

/* Notas adicionales en pantalla de resultados */
.equilibrio-note { margin-top: 8px; padding: 8px 12px; background: var(--mint-100, #d8f0e8); border-left: 4px solid var(--teal-500, #3aa494); border-radius: 4px; font-size: 14px; color: var(--text-900, #1c2a2a); }
.sexo-note { margin-top: 8px; padding: 8px 12px; background: #f3eef9; border-left: 4px solid #8862c4; border-radius: 4px; font-size: 14px; color: var(--text-900, #1c2a2a); }

/* ============================================
   SASS — Escala Autoaplicada de Adaptacion Social
   ============================================ */
.sass-score-big {
  font-size: 68px; font-weight: 700; line-height: 1; margin: 0;
  background: linear-gradient(135deg, var(--teal-500), #2c8378);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.sass-score-sub { font-size: 14px; color: var(--text-500); margin-top: 4px; }
.sass-nivel-badge {
  display: inline-block; padding: 8px 24px; border-radius: 999px;
  font-size: 15px; font-weight: 600; margin: 12px 0;
}
.nivel-bad  { background: #fde2dc; color: #a85a4d; }
.nivel-warn { background: #fff3cd; color: #6b4c00; }
.nivel-ok   { background: #d8f0e8; color: #2c8378; }
.nivel-top  { background: #d4edda; color: #1a5c2e; }

.sass-nivel-tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; margin-top: 4px;
}

/* Barras del perfil por dimension */
.sass-bar-row { margin: 12px 0; }
.sass-bar-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; font-size: 13px; color: var(--text-700); margin-bottom: 5px;
}
.sass-bar-name { flex: 1; }
.sass-bar-val { font-weight: 600; color: var(--text-900); white-space: nowrap; }
.sass-bar-track {
  height: 12px; background: #e6efee; border-radius: 999px; overflow: hidden;
}
.sass-bar-fill {
  height: 100%; border-radius: 999px; transition: width 0.5s ease;
  background: var(--teal-500);
}
.sass-bar-fill.nivel-bad  { background: linear-gradient(90deg, #e08878, #c97a6b); }
.sass-bar-fill.nivel-warn { background: linear-gradient(90deg, #f0c86a, #d4a574); }
.sass-bar-fill.nivel-ok   { background: linear-gradient(90deg, #5fb3a4, var(--teal-500)); }
.sass-bar-fill.nivel-top  { background: linear-gradient(90deg, #4fbf8e, #2c8378); }

/* Bloques informativos reutilizados en resultados SASS */
.sass-info { background: #f6faf9; border-radius: 14px; padding: 18px; margin: 16px 0; }
.sass-info h4 { margin: 0 0 10px; font-size: 14px; color: var(--teal-700); }
.sass-info p { font-size: 13.5px; line-height: 1.65; color: var(--text-700); margin: 0 0 8px; }
.sass-info p:last-child { margin-bottom: 0; }
.sass-ind-list { margin: 6px 0 0 18px; font-size: 13px; color: var(--text-700); line-height: 1.6; }
.sass-ind-list li { margin: 3px 0; }
.pill-sass  { background: linear-gradient(135deg, #7fb8d4, #3a8ac4); }
.pill-sass2 { background: linear-gradient(135deg, #9c8ad4, #6a5ab0); }
.duration-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #eaf4f1; border-radius: 999px;
  padding: 4px 12px; font-size: 13px; color: var(--teal-700); margin-top: 8px;
}
.duration-chip[hidden] { display: none; }

/* ============================================
   BDI-II — Inventario de Depresion de Beck
   ============================================ */
.nivel-severe { background: #f8d7da; color: #7d1f2b; }
.sass-bar-fill.nivel-severe { background: linear-gradient(90deg, #d4677a, #a8324a); }

.alert-box {
  background: #fde2dc;
  border-left: 4px solid #c0392b;
  border-radius: 10px;
  padding: 12px 16px;
  margin: 10px 0;
  font-size: 13px;
  color: #7d2b20;
  line-height: 1.6;
}
.alert-box p { margin: 0; }
.alert-box strong { color: #8e2b1d; }

.risk-banner {
  display: flex; gap: 12px; align-items: flex-start;
  background: #fff4f1;
  border: 1.5px solid #f0b6a8;
  border-left: 5px solid #c0392b;
  border-radius: 14px;
  padding: 16px 18px;
  margin: 16px 0;
}
.risk-banner .risk-emoji { font-size: 24px; line-height: 1; flex-shrink: 0; }
.risk-banner h4 { margin: 0 0 6px; font-size: 15px; color: #a83224; }
.risk-banner p { margin: 0 0 6px; font-size: 13.5px; color: var(--text-700); line-height: 1.6; }
.risk-banner p:last-child { margin-bottom: 0; }

.pill-beck  { background: linear-gradient(135deg, #c97a8a, #a04a63); }
.pill-beck2 { background: linear-gradient(135deg, #7d8bbf, #4a5590); }

/* Opciones del BDI (texto largo, alineado arriba) */
.beck-option { align-items: flex-start; line-height: 1.5; }
.beck-option .radio { margin-top: 2px; }
.beck-option .opt-key {
  font-weight: 700; color: var(--teal-700); min-width: 22px;
  font-variant-numeric: tabular-nums;
}
.beck-group-title { font-size: 13px; font-weight: 600; color: var(--teal-700); text-transform: uppercase; letter-spacing: 0.5px; }

/* ============================================
   CES-D
   ============================================ */
.pill-cesd  { background: linear-gradient(135deg, #6fa8c9, #3a6f96); }
.pill-cesd2 { background: linear-gradient(135deg, #86b89c, #3d7a5c); }

/* ============================================
   Barra de sesion (compartida)
   ============================================ */
.sesion-bar {
  position: fixed; top: 12px; right: 14px; z-index: 500;
  display: flex; align-items: center; gap: 14px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  border: 1px solid #e2ecea;
  border-radius: 999px;
  padding: 6px 10px 6px 8px;
  box-shadow: 0 6px 22px -10px rgba(30,70,65,0.35);
  font-size: 13px; max-width: calc(100vw - 28px);
}
.sesion-quien { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sesion-avatar {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
  color: #fff; font-weight: 700; font-size: 13px;
}
.sesion-avatar-paciente { background: linear-gradient(135deg, #7fb8d4, #3a8ac4); font-size: 14px; }
.sesion-datos { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sesion-datos strong { color: var(--text-900); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sesion-datos small { color: var(--text-500); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sesion-acciones { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.sesion-link {
  text-decoration: none; color: var(--teal-700); font-weight: 600;
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
  transition: background 0.15s;
}
.sesion-link:hover { background: var(--mint-100); }
.sesion-salir {
  border: 1.5px solid #e6d2cd; background: #fff; color: #a85a4d;
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 14px; border-radius: 999px; cursor: pointer;
  transition: all 0.15s;
}
.sesion-salir:hover { background: #fde2dc; border-color: #d9b0a7; }
@media (max-width: 620px) {
  .sesion-bar { top: 8px; right: 8px; left: 8px; justify-content: space-between; }
  .sesion-datos small { display: none; }
  .sesion-link { padding: 6px 8px; }
}

/* Accesos del pie de la pantalla de seleccion de pruebas */
.accesos-pie {
  margin-top: 22px; padding-top: 18px; border-top: 1px solid #e6efee;
  display: flex; flex-direction: column; gap: 10px;
}
.acceso-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-radius: var(--radius-md);
  border: 1.5px solid #e0e7e6; background: #fff;
  text-decoration: none; cursor: pointer; font-family: inherit;
  transition: all 0.18s; width: 100%; text-align: left;
}
.acceso-btn:hover { border-color: var(--teal-500); background: #f6faf9; transform: translateY(-1px); }
.acceso-btn .acceso-emoji { font-size: 22px; flex-shrink: 0; }
.acceso-btn .acceso-txt { display: flex; flex-direction: column; flex: 1; }
.acceso-btn .acceso-titulo { font-weight: 600; color: var(--text-900); font-size: 15px; }
.acceso-btn .acceso-desc { font-size: 12px; color: var(--text-500); margin-top: 2px; }
.acceso-btn .acceso-flecha { color: var(--teal-500); font-weight: 700; font-size: 18px; }
.acceso-btn-destacado {
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
  border-color: transparent; box-shadow: var(--shadow-md);
}
.acceso-btn-destacado .acceso-titulo,
.acceso-btn-destacado .acceso-desc,
.acceso-btn-destacado .acceso-flecha { color: #fff; }
.acceso-btn-destacado .acceso-desc { opacity: 0.9; }
.acceso-btn-destacado:hover { filter: brightness(1.05); background: linear-gradient(135deg, var(--teal-500), var(--teal-700)); }
