:root {
  --brand: #1e3a8a;
  --brand-2: #2563eb;
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f172a; --card: #1e293b; --text: #e5e7eb; --muted: #94a3b8; }
  .form-control { background: #0f172a; color: var(--text); border-color: #334155; }
  .form-control:focus { background: #0f172a; color: var(--text); }
}
* { -webkit-tap-highlight-color: transparent; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.text-muted { color: var(--muted) !important; }

.portal-top {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  padding: calc(.75rem + env(safe-area-inset-top)) 0 .75rem;
  position: sticky; top: 0; z-index: 10;
}
.portal-brand { font-weight: 700; letter-spacing: .2px; }
.portal-main { max-width: 760px; padding-top: 1.25rem; padding-bottom: 2rem; }

/* Autenticación: ilustración cálida + tarjeta tranquila */
:root { --teal: #0f766e; --teal-2: #14b8a6; --sun: #ffb347; }
.auth-page {
  min-height: 100vh; display: flex; flex-direction: column;
  background: #fff7ec;
}
.auth-hero {
  position: relative; height: 40vh; min-height: 250px; overflow: hidden;
  background: #ffe3b8;
}
.hero-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero-text { position: absolute; left: 0; right: 0; top: 0; padding: calc(1.1rem + env(safe-area-inset-top)) 1.25rem 0; color: #5b2a0e; text-align: center; }
.hero-kicker { font-size: .75rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; margin: 0 0 .25rem; color: #9a4a1a; }
.hero-text h2 { font-size: 1.45rem; font-weight: 800; margin: 0 0 .25rem; line-height: 1.2; }
.hero-text p:last-child { margin: 0; font-size: .92rem; opacity: .85; }

.auth-panel { position: relative; z-index: 2; padding: 0 1rem 2rem; margin-top: -2.5rem; }
.auth-card {
  background: #fff; color: #1f2937;
  border-radius: 22px;
  box-shadow: 0 18px 45px rgba(120, 60, 20, .16);
  padding: 1.5rem 1.25rem 1.25rem;
  max-width: 430px; margin: 0 auto;
}
.auth-steps { display: flex; justify-content: center; gap: .4rem; margin-bottom: 1rem; }
.auth-steps span { width: 26px; height: 5px; border-radius: 5px; background: #e5e7eb; }
.auth-steps span.on { background: linear-gradient(90deg, var(--sun), #ff8a4c); }
.auth-title { font-size: 1.6rem; font-weight: 800; text-align: center; margin-bottom: .4rem; color: #1f2937; }
.wave { display: inline-block; transform-origin: 70% 70%; animation: wave 2.4s ease-in-out 1; }
.auth-sub { text-align: center; color: #5b6472; font-size: .95rem; margin-bottom: 1.25rem; line-height: 1.5; }
.auth-help { text-align: center; color: #6b7280; font-size: .8rem; margin: 1.25rem 0 0; line-height: 1.45; }
.field-label { font-size: .85rem; font-weight: 600; color: #374151; margin-bottom: .35rem; }
.auth-card .form-control {
  background: #fffaf3; color: #1f2937; border: 2px solid #f3dcc2; border-radius: 14px;
  text-align: center; font-size: 1.2rem; font-weight: 600;
}
.auth-card .form-control:focus { border-color: var(--teal-2); box-shadow: 0 0 0 .22rem rgba(20, 184, 166, .22); background: #fff; }
.auth-card .form-control::placeholder { color: #b9a58c; font-weight: 400; }
.otp-input { font-size: 1.9rem !important; letter-spacing: .6rem; height: 64px; }
.form-control-lg { min-height: 54px; }
.btn-lg { min-height: 54px; border-radius: 14px; font-weight: 700; }
.btn-primary {
  background: linear-gradient(135deg, var(--teal), var(--teal-2)); border: 0;
  box-shadow: 0 8px 18px rgba(15, 118, 110, .28);
}
.btn-primary:hover, .btn-primary:focus { background: linear-gradient(135deg, #0d645d, var(--teal)); }
.auth-card .btn-link { color: var(--teal); font-weight: 600; }

/* Movimiento sutil (se desactiva si la persona lo pidió así) */
.sol-brillo { animation: pulso 6s ease-in-out infinite; transform-origin: 560px 250px; }
.nube { animation: deriva 40s linear infinite alternate; }
.n2 { animation-duration: 55s; }
.ave { animation: vuela 7s ease-in-out infinite alternate; }
.a2 { animation-delay: -2s; } .a3 { animation-delay: -4s; }
.per { animation: salto 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
.p2 { animation-delay: -.5s; } .p3 { animation-delay: -1s; } .p4 { animation-delay: -1.5s; } .p5 { animation-delay: -2s; }
.confeti { animation: confeti 3.2s ease-in-out infinite alternate; }
@keyframes pulso { 50% { transform: scale(1.06); opacity: .85; } }
@keyframes deriva { to { transform: translateX(40px); } }
@keyframes vuela { to { transform: translate(14px, -6px); } }
@keyframes salto { 50% { transform: translateY(-7px); } }
@keyframes confeti { to { transform: translateY(8px); } }
@keyframes wave { 0%,60%,100% { transform: rotate(0); } 10%,30% { transform: rotate(16deg); } 20%,40% { transform: rotate(-8deg); } 50% { transform: rotate(10deg); } }
@media (prefers-reduced-motion: reduce) {
  .sol-brillo, .nube, .ave, .per, .confeti, .wave { animation: none; }
}

/* Escritorio: ilustración a la izquierda, formulario a la derecha */
@media (min-width: 900px) {
  .auth-page { flex-direction: row; }
  .auth-hero { height: auto; min-height: 100vh; flex: 1 1 58%; }
  .hero-text { top: 9vh; padding: 0 3rem; }
  .hero-text h2 { font-size: 2.3rem; }
  .hero-text p:last-child { font-size: 1.05rem; }
  .auth-panel { flex: 1 1 42%; margin: 0; padding: 2rem; display: flex; align-items: center; justify-content: center; background: #fff7ec; }
  .auth-card { box-shadow: 0 10px 36px rgba(120, 60, 20, .10); padding: 2.25rem 2rem 1.75rem; }
}

/* Inicio */
.greeting h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: .1rem; }
.greeting { margin-bottom: 1.25rem; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-bottom: .6rem; }
.card-link {
  display: block; background: var(--card); color: inherit; border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .08); margin-bottom: .75rem; overflow: hidden;
  text-decoration: none !important; transition: transform .1s ease;
}
.card-link:active { transform: scale(.99); }
.card-link.pending { padding: .9rem 1rem; border-left: 4px solid #f59e0b; }
.feed-img { width: 100%; max-height: 190px; object-fit: cover; display: block; }
.feed-body { padding: .9rem 1rem 1rem; }
.feed-body h3 { font-size: 1.05rem; font-weight: 700; margin: .5rem 0 .25rem; }
.feed-body p { color: var(--muted); font-size: .9rem; margin-bottom: .4rem; }
.empty-state { background: var(--card); border-radius: var(--radius); padding: 1.5rem; text-align: center; color: var(--muted); }

/* Encuestas */
.enc-badge { display: block; width: max-content; margin: 0 auto .6rem; color: #9a4a1a; background: #fff1de; font-weight: 700; }
.enc-body-page { background: #fff7ec; }
.enc-top { background: linear-gradient(135deg, var(--teal), var(--teal-2)); color: #fff; padding: calc(.7rem + env(safe-area-inset-top)) 0 .7rem; position: sticky; top: 0; z-index: 10; }
.enc-wrap { max-width: 640px; }
.enc-top-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: .75rem; }
.enc-main { padding-top: 1rem; padding-bottom: 2.5rem; }
.enc-intro { color: #5b6472; }
.enc-card { background: #fff; border-radius: 18px; box-shadow: 0 10px 30px rgba(120,60,20,.10); padding: 1.25rem 1.15rem 1.15rem; }
.enc-prog { height: 6px; background: #f1e4d2; border-radius: 6px; overflow: hidden; margin-bottom: 1rem; }
.enc-prog > div { height: 100%; background: linear-gradient(90deg, var(--sun), #ff8a4c); border-radius: 6px; transition: width .25s ease; }
.enc-count { font-size: .78rem; font-weight: 700; color: #9a4a1a; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .5rem; }
.enc-sec { background: #fff7ec; border-left: 4px solid var(--sun); padding: .6rem .8rem; border-radius: 8px; margin-bottom: .9rem; font-size: .9rem; color: #5b2a0e; }
.enc-h { font-size: 1.25rem; font-weight: 800; line-height: 1.3; margin: 0 0 .5rem; color: #1f2937; }
.enc-h .req { color: #dc2626; }
.enc-help { color: #6b7280; font-size: .92rem; }
.enc-body { margin: .75rem 0 .4rem; }
.enc-err { color: #b91c1c; font-size: .9rem; min-height: 1.3rem; font-weight: 600; }
.enc-nav { display: flex; justify-content: space-between; gap: .75rem; margin-top: .8rem; }
.enc-nav .btn { flex: 1; }
.enc-priv { text-align: center; color: #8a7a68; font-size: .76rem; margin: 1rem .5rem 0; }
.enc-body .form-control, .enc-body .custom-select { border: 2px solid #f3dcc2; border-radius: 14px; background: #fffaf3; color: #1f2937; text-align: left; font-weight: 500; font-size: 1.05rem; }
.enc-body .form-control:focus, .enc-body .custom-select:focus { border-color: var(--teal-2); box-shadow: 0 0 0 .2rem rgba(20,184,166,.22); background: #fff; }

/* Opciones táctiles */
.choice { display: flex; align-items: center; gap: .7rem; padding: .8rem .9rem; margin: 0 0 .55rem; border: 2px solid #f3dcc2; border-radius: 14px; background: #fffaf3; cursor: pointer; min-height: 52px; transition: border-color .12s, background .12s; }
.choice input { width: 20px; height: 20px; accent-color: var(--teal); flex: 0 0 auto; }
.choice span { flex: 1; font-weight: 500; }
.choice:has(input:checked) { border-color: var(--teal-2); background: #e8faf7; }
.yn { display: flex; gap: .7rem; } .yn .yn-opt { flex: 1; justify-content: center; margin: 0; }
.yn .yn-opt input { display: none; } .yn .yn-opt span { text-align: center; font-size: 1.1rem; font-weight: 700; }
.scale { display: flex; gap: .45rem; flex-wrap: wrap; }
.pill { margin: 0; cursor: pointer; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill span { display: flex; align-items: center; justify-content: center; min-width: 48px; height: 48px; padding: 0 .8rem; border: 2px solid #f3dcc2; border-radius: 14px; background: #fffaf3; font-weight: 700; transition: all .12s; }
.pill input:checked + span { background: var(--teal); border-color: var(--teal); color: #fff; }
.pill input:focus-visible + span { box-shadow: 0 0 0 .2rem rgba(20,184,166,.35); }
.scale-lbl { display: flex; justify-content: space-between; font-size: .8rem; color: #6b7280; margin-top: .4rem; }
.stars { display: flex; gap: .25rem; }
.star { border: 0; background: none; font-size: 2.6rem; line-height: 1; color: #e5d5bf; padding: .1rem .15rem; cursor: pointer; }
.star.on { color: #f59e0b; }
.mx-row { padding: .6rem 0; border-bottom: 1px solid #f3e8d8; } .mx-row:last-child { border-bottom: 0; }
.mx-q { font-weight: 700; margin-bottom: .45rem; }
.mx-opts { display: flex; flex-wrap: wrap; gap: .4rem; }
.pill-txt span { min-width: 0; height: 42px; font-size: .9rem; font-weight: 600; }
.rank { display: flex; flex-direction: column; gap: .5rem; }
.rank-opt { display: flex; align-items: center; gap: .75rem; text-align: left; border: 2px solid #f3dcc2; border-radius: 14px; background: #fffaf3; padding: .7rem .9rem; min-height: 52px; font-weight: 500; }
.rank-opt b { width: 30px; height: 30px; border-radius: 50%; background: #f1e4d2; display: flex; align-items: center; justify-content: center; font-size: .9rem; flex: 0 0 auto; }
.rank-opt.on { border-color: var(--teal-2); background: #e8faf7; } .rank-opt.on b { background: var(--teal); color: #fff; }
.enc-sum .sum-item { padding: .65rem 0; border-bottom: 1px solid #f3e8d8; }
.sum-q { font-weight: 700; font-size: .92rem; } .sum-a { color: #374151; margin-top: .15rem; }
.enc-gracias { padding: 2rem 1.25rem; } .gracias-ico { font-size: 3rem; }
.mensaje-final { margin-top: 1rem; padding: .9rem 1rem; background: #fff7ec; border-radius: 12px; text-align: left; }
.enc-card .btn-primary { background: linear-gradient(135deg, var(--teal), var(--teal-2)); border: 0; }

/* Filtros y detalle */
.chips { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .5rem; margin: 0 -1rem .5rem; padding-left: 1rem; padding-right: 1rem; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; padding: .45rem .95rem; border-radius: 999px; background: var(--card); color: var(--text); font-size: .88rem; font-weight: 600; box-shadow: 0 1px 2px rgba(15,23,42,.1); text-decoration: none !important; min-height: 38px; display: flex; align-items: center; }
.chip.on { background: var(--teal); color: #fff; }
.back-link { display: inline-block; margin-bottom: .75rem; font-weight: 600; color: var(--teal); text-decoration: none; padding: .4rem 0; }
.detalle { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(15,23,42,.08); overflow: hidden; }
.detalle-img { width: 100%; max-height: 360px; object-fit: cover; display: block; }
.detalle-body { padding: 1.1rem 1.1rem 1.4rem; }
.detalle-body h1 { font-size: 1.45rem; font-weight: 800; margin: .6rem 0 .5rem; line-height: 1.25; }
.evento-datos { list-style: none; padding: 0; margin: .25rem 0 1rem; }
.evento-datos li { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .75rem; background: #fff7ec; color: #5b2a0e; border-radius: 12px; margin-bottom: .4rem; font-weight: 600; }
.lead-resumen { font-size: 1.05rem; color: var(--muted); }
.cuerpo { line-height: 1.65; font-size: 1rem; word-wrap: break-word; }
.cuerpo a { color: var(--teal); text-decoration: underline; }

@media (min-width: 768px) {
  .portal-main { padding-top: 2rem; }
  .auth-card { padding: 2.5rem 2rem; margin-top: 12vh; }
  .feed { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
  .feed .card-link { margin-bottom: 0; }
}
