/* pulso · estilos. Base: pulso_demo_app.html. Un solo canvas (#cv) a pantalla completa compartido por inicio y resultados. */
:root {
  --bg: #FFF4E8; --bg2: #FFFAF4; --card: rgba(255,255,255,.74); --ink: #1A1F3A; --mute: #5A6075; --line: rgba(26,31,58,.12);
  --coral: #F0442E; --coralInk: #C7351D; --orange: #FF8A1F; --blue: #3E7CB1; --grey: #A9AEC0;
  --ok: #1D8653;
  --f-display: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --top: 64px; --ease: cubic-bezier(.2,.9,.3,1);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-display); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
.c { color: var(--coral); }
.mono { font-family: var(--f-mono); }

/* ---------- atmósfera ---------- */
.aura { position: fixed; inset: -20%; pointer-events: none; z-index: 0; }
.aura i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; animation: drift 18s ease-in-out infinite alternate; }
.aura i:nth-child(1) { width: 52vw; height: 52vw; left: 52%; top: 4%; background: radial-gradient(circle, rgba(255,138,31,.5), transparent 65%); }
.aura i:nth-child(2) { width: 46vw; height: 46vw; left: 8%; top: 48%; background: radial-gradient(circle, rgba(240,68,46,.32), transparent 65%); animation-duration: 24s; animation-delay: -6s; }
.aura i:nth-child(3) { width: 36vw; height: 36vw; left: 34%; top: -6%; background: radial-gradient(circle, rgba(255,194,75,.45), transparent 65%); animation-duration: 21s; animation-delay: -11s; }
@keyframes drift { 0% { transform: translate(0,0) scale(1); } 50% { transform: translate(4vw,-3vw) scale(1.08); } 100% { transform: translate(-3vw,4vw) scale(.96); } }
.grain { position: fixed; inset: 0; pointer-events: none; z-index: 60; opacity: .05; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; }

/* ---------- logo ---------- */
.logo { display: inline-flex; align-items: baseline; font-weight: 700; letter-spacing: -.045em; line-height: 1; color: var(--ink); font-size: 32px; }
.logo .dot { position: relative; display: inline-block; width: .4em; height: .4em; margin-left: .28em; border-radius: 50%; background: var(--coral); }
.logo .dot::before, .logo .dot::after { content: ""; position: absolute; inset: -.1em; border-radius: 50%; border: .04em solid var(--coral); opacity: .5; }
.logo .dot::after { inset: -.2em; border-width: .03em; opacity: .25; }
.logo .dot.beat { animation: beat .55s var(--ease); }
@keyframes beat { 0% { transform: scale(1); } 18% { transform: scale(1.18); } 34% { transform: scale(.96); } 50% { transform: scale(1.08); } 100% { transform: scale(1); } }

/* ---------- cabecera ---------- */
.top { position: fixed; z-index: 20; top: 0; left: 0; right: 0; height: var(--top); display: flex; align-items: center; gap: 14px;
  padding: env(safe-area-inset-top, 0px) max(22px, env(safe-area-inset-right, 0px)) 0 max(22px, env(safe-area-inset-left, 0px));
  transition: background .6s, border-color .6s; border-bottom: 1px solid transparent; }
.app .top { background: rgba(255,248,240,.92); border-bottom-color: var(--line); }
.top .sp { flex: 1; }
.link { border: 0; background: transparent; font-size: 14px; font-weight: 500; color: var(--ink); padding: 8px 10px; border-radius: 10px; transition: background .2s, color .2s; white-space: nowrap; }
.lbl-s { display: none; }
.link:hover { background: rgba(240,68,46,.08); color: var(--coralInk); }
.ibtn { border: 1px solid var(--line); background: var(--bg2); border-radius: 12px; height: 38px; min-width: 38px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; font-weight: 500; transition: background .2s, border-color .2s, opacity .4s; }
.ibtn:hover { border-color: rgba(240,68,46,.5); background: #fff; }
.only-app { opacity: 0; pointer-events: none; transition: opacity .5s .2s; }
.app .only-app { opacity: 1; pointer-events: auto; }
#cfgBtn.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.nfil { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--coral); color: #fff; font-family: var(--f-mono); font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; }
#disBtn { background: var(--coral); border-color: var(--coral); color: #fff; }
#disBtn:hover { background: var(--coralInk); border-color: var(--coralInk); }
.app .badge { bottom: auto; right: auto; top: calc(env(safe-area-inset-top, 0px) + 22px); left: 132px; }
.badge { position: fixed; z-index: 21; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(14px, env(safe-area-inset-bottom, 0px));
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .06em; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--mute); background: rgba(255,250,244,.85); pointer-events: none; }

/* ---------- inicio ---------- */
.hero { position: fixed; z-index: 3; left: 0; right: 0; top: calc(var(--top) + 3vh); text-align: center; pointer-events: none; padding-inline: 16px; transition: opacity .45s, transform .6s var(--ease); }
.hero h1 { margin: 0; font-size: clamp(34px, 4.6vw, 64px); letter-spacing: -.035em; line-height: 1; font-weight: 700; }
.hero p { margin: 10px 0 0; font-family: var(--f-mono); font-size: clamp(11px, 1vw, 13px); color: var(--mute); letter-spacing: .02em; }
.app .hero { opacity: 0; transform: translateY(-24px); }
.rise { opacity: 0; transform: translateY(18px); filter: blur(6px); animation: rise .9s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes rise { to { opacity: 1; transform: none; filter: none; } }
.home-below { position: fixed; z-index: 3; left: 50%; transform: translateX(-50%); bottom: max(22px, env(safe-area-inset-bottom, 0px)); width: min(760px, calc(100vw - 32px));
  display: flex; flex-direction: column; align-items: center; gap: 12px; transition: opacity .35s, transform .6s var(--ease); }
.home-below { pointer-events: none; }
.home-below .chips { justify-content: center; padding: 2px 0; pointer-events: auto; flex-wrap: wrap; max-height: 42px; overflow: hidden; }
.home-below .chip { white-space: nowrap; }
.home-below small { font-family: var(--f-mono); font-size: 11px; color: var(--mute); letter-spacing: .04em; }
.app .home-below { opacity: 0; transform: translate(-50%, 30px); pointer-events: none; }
.app .home-below .chips { pointer-events: none; }
.home-gap { height: 66px; flex: none; } /* hueco reservado para la barra de pregunta */

/* barra de pregunta (la misma en inicio y en el chat) */
#ask { position: relative; z-index: 4; display: flex; gap: 8px; align-items: flex-end; padding: 8px 8px 8px 16px; border-radius: 22px; border: 1.5px solid var(--line); background: #fff;
  box-shadow: 0 12px 34px rgba(26,31,58,.08); transition: border-color .2s, box-shadow .25s; margin: 0 14px 14px; }
#ask:focus-within { border-color: var(--coral); box-shadow: 0 12px 34px rgba(240,68,46,.18), 0 0 0 6px rgba(240,68,46,.08); }
#q { flex: 1; border: 0; outline: 0; resize: none; background: transparent; font-size: 15px; line-height: 1.4; padding: 9px 0; max-height: 120px; min-width: 0; }
#send { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--coral); color: #fff; display: grid; place-items: center; transition: transform .2s, box-shadow .2s; box-shadow: 0 8px 20px rgba(240,68,46,.35); }
#send:hover { transform: scale(1.08); }
#send:disabled { opacity: .45; transform: none; box-shadow: none; }
.home #ask { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(max(22px, env(safe-area-inset-bottom, 0px)) + 96px); width: min(760px, calc(100vw - 32px)); margin: 0;
  padding: 10px 10px 10px 24px; border-radius: 999px; }
.home #q { font-size: 18px; padding: 12px 0; }
.home #send { width: 52px; height: 52px; }

/* ---------- app ---------- */
.grid { position: fixed; z-index: 2; top: var(--top); left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: minmax(320px, 380px) minmax(0, 1fr) 0px; pointer-events: none;
  transition: grid-template-columns .45s var(--ease); }
/* «Diseña tu encuesta» empieza plegado; el botón de la cabecera lo abre como columna */
body.cfg-abierto .grid { grid-template-columns: minmax(300px, 340px) minmax(0, 1fr) minmax(280px, 300px); }
body:not(.cfg-abierto) .grid > .cfg { opacity: 0; pointer-events: none; padding-inline: 0; overflow: hidden; border-left-color: transparent; }
.app .grid > * { pointer-events: auto; }
.app .grid > .stage { pointer-events: none; }
.app .stage > * { pointer-events: auto; }
.app .stage > .canvas-wrap { pointer-events: none; }
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1px solid var(--line); background: rgba(255,248,240,.9);
  transition: opacity .6s var(--ease), transform .6s var(--ease), background .6s; }
.home .chat { background: transparent; border-color: transparent; backdrop-filter: none; }
body.home .chat > :not(#ask), body.home .cfg, body.home .stage > *, body.home .results.wait { opacity: 0; pointer-events: none; }
.home #ask { pointer-events: auto; }
.home .chat > :not(#ask) { transform: translateX(-30px); }
.home .cfg { transform: translateX(30px); }
.home .results { transform: translateY(30px); }
.msgs, .chat .chips, .stage-top, .results, .cfg { transition: opacity .6s var(--ease), transform .6s var(--ease); }
.msgs { flex: 1; overflow-y: auto; padding: 22px 18px 10px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.msg { max-width: 92%; font-size: 15px; line-height: 1.5; animation: pop .45s cubic-bezier(.2,.9,.3,1.2); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.msg.bot { align-self: flex-start; display: flex; gap: 10px; }
.msg.bot .av { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--coral); position: relative; margin-top: 3px; }
.msg.bot .av::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid rgba(240,68,46,.28); }
.msg.bot .tx { background: #fff; border-radius: 4px 18px 18px 18px; padding: 11px 14px; box-shadow: 0 6px 20px rgba(26,31,58,.06); min-width: 0; }
.msg.bot .tx b { color: var(--coralInk); }
.msg.bot .tx .note { display: block; margin-top: 8px; font-family: var(--f-mono); font-size: 11px; line-height: 1.5; color: var(--mute); }
.msg.user { align-self: flex-end; background: var(--ink); color: #fff; border-radius: 18px 4px 18px 18px; padding: 11px 15px; }
.msg.err .tx { border-left: 3px solid var(--coral); }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--coral); animation: bounce 1s ease-in-out infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .35; } 40% { transform: translateY(-5px); opacity: 1; } }
.quote { margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--coral); background: #fff; border-radius: 0 12px 12px 0; font-size: 14px; box-shadow: 0 4px 14px rgba(26,31,58,.05); }
.quote small { display: block; font-family: var(--f-mono); font-size: 11px; color: var(--mute); margin-top: 4px; }
.factores { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(26,31,58,.04); font-size: 13.5px; line-height: 1.4; display: flex; flex-direction: column; gap: 6px; }
.factores small { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); }
.factores div { display: flex; gap: 8px; align-items: baseline; }
.factores i { width: 7px; height: 7px; border-radius: 50%; flex: none; transform: translateY(-1px); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 18px 12px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 13px; font-size: 13px; line-height: 1.25; text-align: left; transition: transform .2s, border-color .2s, background .2s; animation: pop .4s cubic-bezier(.2,.9,.3,1.2) backwards; }
.chip:hover { border-color: var(--coral); background: rgba(240,68,46,.05); transform: translateY(-2px); }

/* escenario */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; padding: 20px 26px 6px; flex-wrap: wrap; }
.home .stage-top { transform: translateY(-16px); }
.qtitle { min-width: 0; flex: 1 1 340px; }
.eyebrow { font-family: var(--f-mono); font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--mute); display: inline-flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.eyebrow i { width: 8px; height: 8px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 4px rgba(240,68,46,.16); }
#qt { margin: 0; font-size: clamp(20px, 2vw, 28px); line-height: 1.15; letter-spacing: -.02em; font-weight: 600; text-wrap: balance; }
.views { display: inline-flex; padding: 4px; border-radius: 14px; background: rgba(26,31,58,.06); position: relative; flex: none; }
.views button { position: relative; z-index: 1; border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--mute); transition: color .25s; white-space: nowrap; }
.views button.on { color: var(--ink); }
.views .pill { position: absolute; z-index: 0; top: 4px; bottom: 4px; border-radius: 10px; background: #fff; box-shadow: 0 4px 14px rgba(26,31,58,.1); transition: left .4s cubic-bezier(.2,.9,.3,1.2), width .4s cubic-bezier(.2,.9,.3,1.2); }
.dims { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.dims button { border: 1px solid var(--line); background: rgba(255,255,255,.7); border-radius: 999px; padding: 5px 11px; font-size: 12.5px; color: var(--mute); transition: all .2s; }
.dims button:hover { border-color: rgba(240,68,46,.5); color: var(--ink); }
.dims button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.canvas-wrap { position: relative; flex: 1; min-height: 300px; }
.steps { position: absolute; left: 24px; top: 10px; display: flex; flex-direction: column; gap: 7px; font-size: 13px; pointer-events: none; opacity: 0; transition: opacity .5s; }
.steps div { display: flex; align-items: center; gap: 10px; color: var(--mute); opacity: .35; transition: opacity .3s, color .3s; }
.steps div.on, .steps div.done { opacity: 1; }
.steps div.on { color: var(--ink); font-weight: 500; }
.steps div i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; }
.steps div.on i { border-color: var(--coral); border-top-color: transparent; animation: spin .7s linear infinite; }
.steps div.done i { border-color: var(--ok); background: var(--ok); }
.steps div.done i::after { content: ""; width: 6px; height: 3px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px,-1px); }
.steps em { font-style: normal; font-family: var(--f-mono); font-size: 11px; color: var(--mute); margin-left: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
/* botón para salir del zoom de una comunidad */
.volver { position: absolute; left: 20px; top: 50px; z-index: 2; display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 10px 16px 10px 13px;
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 600; box-shadow: 0 10px 26px rgba(26,31,58,.22); pointer-events: auto;
  opacity: 0; visibility: hidden; transform: translateY(-6px); transition: opacity .3s var(--ease), transform .3s var(--ease), visibility .3s, background .2s; }
.volver.on { opacity: 1; visibility: visible; transform: none; }
.volver:hover { background: var(--coral); }
/* panel de la vista Comunidades (clasificación o detalle de la comunidad elegida) */
.ccp { position: absolute; right: 20px; display: flex; flex-direction: column; gap: 8px; padding: 16px 16px 14px; border-radius: 18px; background: rgba(255,255,255,.9); box-shadow: 0 18px 50px rgba(26,31,58,.08);
  overflow-y: auto; pointer-events: auto; opacity: 0; visibility: hidden; transform: translateX(16px); transition: opacity .35s var(--ease), transform .35s var(--ease), visibility .35s; }
.ccp.on { opacity: 1; visibility: visible; transform: none; }
.ccp .ey { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); }
.ccp .hint { margin: 0; font-size: 13px; line-height: 1.4; color: var(--mute); }
.ccp .rank { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.ccp .rank button { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 70px 42px; align-items: center; gap: 8px; border: 0; background: transparent; padding: 4px 6px; border-radius: 8px; font: inherit; font-size: 13px; color: var(--ink); text-align: left; transition: background .15s; }
.ccp .rank button:hover { background: rgba(240,68,46,.07); }
.ccp .rank .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ccp .rank .br { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.ccp .rank .br i { display: block; height: 100%; border-radius: 3px; }
.ccp .rank b { font-family: var(--f-mono); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.ccp sup { color: var(--mute); font-size: .8em; }
.ccp .nota { margin: 0; font-family: var(--f-mono); font-size: 10.5px; line-height: 1.5; color: var(--mute); }
.ccp .back { align-self: flex-start; border: 0; background: transparent; padding: 2px 0; font: inherit; font-size: 12.5px; color: var(--mute); }
.ccp .back:hover { color: var(--coralInk); }
.ccp h4 { margin: 2px 0 0; font-size: 22px; letter-spacing: -.02em; }
.ccp .big { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; }
.ccp .big b { white-space: nowrap; font-size: 40px; letter-spacing: -.04em; line-height: 1; color: var(--coral); }
.ccp .big span { font-size: 13px; color: var(--mute); }
.ccp .vs { margin: 0; font-size: 13px; color: var(--mute); }
.ccp .vs b { color: var(--ink); }
.ccp .stack { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 1.5px; }
.ccp table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ccp th { font-family: var(--f-mono); font-size: 10px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--mute); text-align: right; padding: 0 0 4px; }
.ccp td { padding: 3px 0; border-top: 1px solid var(--line); }
.ccp td i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
.ccp td.n { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-weight: 700; padding-left: 8px; }
.ccp td.m { color: var(--mute); font-weight: 400; }
.ccp .filtrar { margin-top: 4px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 12px; font: inherit; font-size: 12.5px; color: var(--ink); transition: border-color .2s, background .2s; }
.ccp .filtrar:hover { border-color: var(--coral); background: rgba(240,68,46,.05); }
.count { position: absolute; right: 24px; top: 6px; text-align: right; pointer-events: none; opacity: 0; transition: opacity .4s; }
.count small { font-family: var(--f-mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--mute); display: block; }
.count b { font-size: 46px; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1.05; display: block; }
.count span { font-family: var(--f-mono); font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums; }
.count .pb { width: 190px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px 0 0 auto; overflow: hidden; }
.count .pb i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--orange), var(--coral)); }
.tip { position: fixed; z-index: 30; pointer-events: none; width: 256px; background: #fff; border-radius: 16px; padding: 14px; box-shadow: 0 20px 50px rgba(26,31,58,.18); opacity: 0; transform: translateY(6px) scale(.97); transition: opacity .15s, transform .15s; font-size: 13px; }
.tip.on { opacity: 1; transform: none; }
.tip .who { display: flex; align-items: center; gap: 10px; }
.tip .ini { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; flex: none; }
.tip .who b { display: block; font-size: 15px; }
.tip .who span { color: var(--mute); font-size: 12px; }
.tip .tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0 8px; }
.tip .tags span { font-family: var(--f-mono); font-size: 10.5px; padding: 3px 7px; border-radius: 6px; background: rgba(26,31,58,.06); color: var(--mute); }
.tip .ans { font-weight: 600; display: flex; align-items: center; gap: 7px; }
.tip .ans i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.tip q { display: block; margin-top: 6px; color: var(--mute); font-style: italic; line-height: 1.4; }
.tip .fake { margin-top: 10px; font-family: var(--f-mono); font-size: 10px; color: var(--coralInk); letter-spacing: .06em; text-transform: uppercase; }

/* tira de resultados */
.results { display: grid; grid-template-columns: auto minmax(0, 1.4fr) auto minmax(0, 1fr); gap: 24px; align-items: center; margin: 0 22px 18px; padding: 16px 22px; border-radius: 22px; background: rgba(255,255,255,.88); box-shadow: 0 18px 50px rgba(26,31,58,.08); }
.results.wait { opacity: .5; }
.r-main b { display: block; font-size: 54px; line-height: .95; letter-spacing: -.05em; color: var(--coral); font-variant-numeric: tabular-nums; }
.r-main span { font-size: 13px; color: var(--mute); display: block; margin-top: 4px; max-width: 14em; }
.stack { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--line); }
.stack i { display: block; height: 100%; width: 0; transition: width 1s cubic-bezier(.2,.8,.2,1); }
.stack i + i { box-shadow: inset 2px 0 0 #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 10px; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend span i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.legend span b { font-variant-numeric: tabular-nums; }
.r-trust { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--mute); }
.sema { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; cursor: help; }
.sema .lights { display: inline-flex; gap: 3px; padding: 3px 5px; border-radius: 8px; background: var(--ink); }
.sema .lights i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.18); transition: background .3s, box-shadow .3s; }
.sema[data-l="3"] .lights i:nth-child(3) { background: #3BD27E; box-shadow: 0 0 8px #3BD27E; }
.sema[data-l="2"] .lights i:nth-child(2) { background: #FFC24B; box-shadow: 0 0 8px #FFC24B; }
.sema[data-l="1"] .lights i:nth-child(1) { background: #FF5A4A; box-shadow: 0 0 8px #FF5A4A; }
.r-trust .mono { font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.r-trust .base { font-size: 11px; color: var(--mute); white-space: normal; max-width: 17em; line-height: 1.4; }
.r-insight { font-size: 14px; line-height: 1.45; border-left: 1px solid var(--line); padding-left: 22px; min-width: 0; }
.r-insight small { display: block; font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); margin-bottom: 4px; }
.r-insight b { color: var(--coralInk); }

/* diseñador de encuesta */
.cfg { min-height: 0; min-width: 0; overflow-y: auto; border-left: 1px solid var(--line); background: rgba(255,248,240,.9); padding: 22px 20px 28px; display: flex; flex-direction: column; gap: 20px; }
.cfg h3 { margin: 0; font-size: 19px; letter-spacing: -.01em; display: flex; justify-content: space-between; align-items: center; }
.fld { display: flex; flex-direction: column; gap: 8px; }
.fld > label, .fld > .lb { font-family: var(--f-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--mute); display: flex; justify-content: space-between; gap: 8px; }
.fld > .lb em { font-style: normal; color: var(--ink); letter-spacing: 0; text-transform: none; font-size: 12px; }
#cq, #cq2 { width: 100%; resize: none; border: 1px solid var(--line); border-radius: 14px; padding: 11px 13px; background: #fff; font-size: 14px; line-height: 1.4; outline: 0; }
#cq:focus, #cq2:focus { border-color: var(--coral); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 7px 11px; font-size: 13px; transition: all .2s; }
.seg button:hover:not(:disabled) { border-color: rgba(240,68,46,.5); }
.seg button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg button:disabled { opacity: .38; cursor: not-allowed; }
.seg.coral button.on { background: var(--coral); border-color: var(--coral); }
.opts { display: flex; flex-direction: column; gap: 6px; }
.opt { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px 6px 4px 10px; }
.opt i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.opt input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 14px; padding: 6px 0; }
.opt button { border: 0; background: transparent; color: var(--mute); width: 26px; height: 26px; border-radius: 8px; font-size: 16px; }
.opt button:hover { background: rgba(240,68,46,.08); color: var(--coral); }
#addOpt { border: 1px dashed var(--line); background: transparent; border-radius: 12px; padding: 8px; font-size: 13px; color: var(--mute); }
#addOpt:hover { border-color: var(--coral); color: var(--coral); }
select { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; background: #fff; font-size: 14px; outline: 0; }
.range2 { position: relative; height: 28px; }
.range2 input { position: absolute; inset: 0; width: 100%; pointer-events: none; -webkit-appearance: none; appearance: none; background: transparent; margin: 0; }
.range2 input::-webkit-slider-thumb { pointer-events: auto; -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 3px solid var(--coral); box-shadow: 0 3px 10px rgba(240,68,46,.3); cursor: grab; }
.range2 input::-moz-range-thumb { pointer-events: auto; width: 15px; height: 15px; border-radius: 50%; background: #fff; border: 3px solid var(--coral); cursor: grab; }
.range2 .tr { position: absolute; left: 0; right: 0; top: 12px; height: 4px; border-radius: 2px; background: var(--line); }
.range2 .tr i { position: absolute; top: 0; bottom: 0; background: linear-gradient(90deg, var(--orange), var(--coral)); border-radius: 2px; }
.descarga { font-size: 13px; color: var(--coralInk); text-decoration: none; font-weight: 500; }
.descarga:hover { text-decoration: underline; }
#launch { margin-top: 4px; border: 0; border-radius: 16px; padding: 15px; background: var(--coral); color: #fff; font-size: 16px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 10px; box-shadow: 0 14px 30px rgba(240,68,46,.3); transition: transform .2s, box-shadow .2s; }
#launch:hover { transform: translateY(-2px); box-shadow: 0 18px 38px rgba(240,68,46,.4); }
#launch:disabled { opacity: .5; transform: none; }
#quitarFil { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px; font-size: 13.5px; transition: border-color .2s, color .2s; }
#quitarFil:hover { border-color: var(--coral); color: var(--coralInk); }
/* «Diseña tu encuesta»: ventana grande, centrada, que empieza vacía */
.modal { position: fixed; z-index: 40; left: 50%; top: 50%; width: min(880px, 94vw); max-height: min(92vh, 860px); overflow-y: auto; display: flex; flex-direction: column; gap: 18px;
  padding: 28px 32px 30px; border-radius: 26px; background: var(--bg2); box-shadow: 0 40px 100px rgba(26,31,58,.25);
  opacity: 0; visibility: hidden; transform: translate(-50%, -47%) scale(.98); transition: opacity .35s var(--ease), transform .45s var(--ease), visibility .35s; }
.modal.open { opacity: 1; visibility: visible; transform: translate(-50%, -50%); }
.modal h3 { margin: 0; font-size: 28px; letter-spacing: -.02em; display: flex; justify-content: space-between; align-items: center; }
.modal .sub { margin: -8px 0 4px; font-size: 14.5px; line-height: 1.45; color: var(--mute); }
.modal .cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 30px; }
.modal .col { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.modal #cq, .modal #cq2 { font-size: 17px; padding: 14px 16px; min-height: 120px; }
.modal .opt input { font-size: 15px; padding: 8px 0; }
.modal #launch { align-self: flex-end; min-width: 260px; padding: 15px 26px; }
.cfg .note { font-size: 12px; color: var(--mute); line-height: 1.5; margin: -6px 0 0; }

/* cajón de consultas anteriores */
.drawer { position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: min(380px, 92vw); background: var(--bg2); box-shadow: -30px 0 60px rgba(26,31,58,.15);
  transform: translateX(105%); visibility: hidden; transition: transform .45s var(--ease), visibility .45s; padding: max(22px, env(safe-area-inset-top, 0px)) 20px 24px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.drawer.open { transform: none; visibility: visible; }
.drawer h3 { margin: 0; font-size: 19px; display: flex; justify-content: space-between; align-items: center; }
.hist { border: 0; background: #fff; border-radius: 16px; padding: 13px 14px; text-align: left; box-shadow: 0 6px 18px rgba(26,31,58,.05); transition: transform .2s, box-shadow .2s; display: flex; flex-direction: column; gap: 6px; }
.hist:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(26,31,58,.1); }
.hist b { font-size: 14px; font-weight: 600; line-height: 1.3; }
.hist span { font-family: var(--f-mono); font-size: 11px; color: var(--mute); }
.hist span em { font-style: normal; color: var(--coralInk); font-weight: 600; }
.drawer.wide { width: min(560px, 96vw); }
.vcard { background: #fff; border-radius: 16px; padding: 14px 16px; box-shadow: 0 6px 18px rgba(26,31,58,.05); display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.45; margin-bottom: 12px; }
.vcard small { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); display: flex; align-items: center; gap: 8px; }
.vcard small i { width: 9px; height: 9px; border-radius: 50%; }
.vcard .big { font-size: 34px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.vcard table { width: 100%; border-collapse: collapse; font-size: 13px; }
.vcard td, .vcard th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; font-variant-numeric: tabular-nums; }
.vcard th { font-family: var(--f-mono); font-size: 10.5px; font-weight: 400; color: var(--mute); text-transform: uppercase; letter-spacing: .06em; }
.vcard td.n { text-align: right; font-family: var(--f-mono); }
.vcard tr.best td { font-weight: 600; color: var(--coralInk); }
.vcard .scatter-wrap { overflow-x: auto; }
#sema { cursor: pointer; }
.cbar { display: grid; grid-template-columns: 92px 1fr 52px; align-items: center; gap: 8px; font-size: 12.5px; }
.cbar span { color: var(--mute); }
.cbar div { height: 10px; border-radius: 5px; background: rgba(26,31,58,.06); overflow: hidden; }
.cbar div i { display: block; height: 100%; border-radius: 5px; }
.cbar b { font-family: var(--f-mono); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.copt { font-weight: 600; font-size: 14px; margin-top: 6px; }
.cerr { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cerr div { border-radius: 14px; padding: 12px; background: rgba(26,31,58,.04); }
.cerr div b { display: block; font-size: 30px; letter-spacing: -.03em; line-height: 1.05; }
.cerr div small { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(26,31,58,.25); opacity: 0; pointer-events: none; transition: opacity .3s; }
.scrim.on { opacity: 1; pointer-events: auto; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .grid, body.cfg-abierto .grid { grid-template-columns: minmax(280px, 330px) minmax(0, 1fr); }
  body:not(.cfg-abierto) .grid > .cfg { opacity: 1; padding-inline: 20px; overflow-y: auto; }
  .cfg { position: fixed; z-index: 36; top: 0; right: 0; bottom: 0; width: min(360px, 92vw); transform: translateX(105%); visibility: hidden; transition: transform .45s var(--ease), visibility .45s; background: var(--bg2); box-shadow: -30px 0 60px rgba(26,31,58,.15); padding-top: max(22px, env(safe-area-inset-top, 0px)); }
  .app .cfg.open { transform: none; visibility: visible; opacity: 1; }
  .results { grid-template-columns: auto minmax(0, 1fr) auto; }
  .r-insight { grid-column: 1 / -1; border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 12px; }
}
@media (max-width: 820px) {
  .app { overflow-y: auto; overflow-x: hidden; }
  .app .grid { position: relative; top: auto; bottom: auto; padding-top: var(--top); display: flex; flex-direction: column; min-height: 100%; }
  .stage { order: 1; }
  .chat { order: 2; border-right: 0; border-top: 1px solid var(--line); min-height: 480px; }
  .canvas-wrap { min-height: 360px; height: 54vh; flex: none; }
  .stage-top { padding: 16px 16px 4px; }
  .views { width: 100%; }
  .views button { flex: 1; padding: 8px 6px; font-size: 13px; }
  .results { grid-template-columns: 1fr; margin: 0 16px 16px; gap: 14px; }
  .steps { left: 14px; font-size: 12px; }
  .count { right: 14px; } .count b { font-size: 32px; } .count .pb { width: 110px; }
  .lbl-l { display: none; } .lbl-s { display: inline; }
  .badge-fecha { display: none; }
  .top { gap: 8px; }
  #cfgBtn { padding: 0 10px; }
  .badge, .app .badge { top: auto; left: 50%; right: auto; transform: translateX(-50%); bottom: max(6px, env(safe-area-inset-bottom, 0px)); font-size: 9.5px; padding: 3px 8px; }
  .home-below { bottom: max(30px, env(safe-area-inset-bottom, 0px)); }
  .home #ask { bottom: calc(max(30px, env(safe-area-inset-bottom, 0px)) + 120px); }
  .home #q { font-size: 16px; }
  .home-below .chips .chip:nth-child(n+3) { display: none; }
  .hero { top: calc(var(--top) + 1vh); }
}
@media (max-width: 820px) {
  .modal { left: 0; top: 0; width: 100vw; height: 100%; max-height: none; border-radius: 0; padding: max(22px, env(safe-area-inset-top, 0px)) 18px 26px; transform: translateY(24px); }
  .modal.open { transform: none; }
  .modal .cols { grid-template-columns: 1fr; gap: 22px; }
  .modal #launch { align-self: stretch; }
}
/* ---------- versión publicada sin LLM ---------- */
.aviso-llm { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: #FFF1D6; border: 1px solid #F5CF85; color: #6B4A0B; font-size: 13.5px; line-height: 1.45; }
.aviso-llm svg { flex: none; margin-top: 1px; }
.aviso-llm b { color: #4A3206; }
.aviso-llm.mini { display: none; margin: 0 16px 8px; padding: 8px 11px; font-size: 12px; border-radius: 12px; }
body.estatico .aviso-llm.mini { display: flex; }
body.estatico #histBtn { display: none; }
body.estatico #q { cursor: pointer; }
body.estatico #q::placeholder { color: #8A6A2A; }
body.estatico #send { width: auto; padding: 0 16px 0 13px; gap: 7px; border-radius: 999px; font-size: 14px; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; }
body.estatico.home #send { width: auto; padding: 0 20px 0 16px; font-size: 15px; }
.chip.prim { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.prim:hover { background: var(--coral); border-color: var(--coral); }
.home-below small.est { color: #8A5A00; background: #FFF1D6; border: 1px solid #F5CF85; padding: 4px 10px; border-radius: 999px; }
.badge.est { color: #8A5A00; border-color: #F5CF85; background: rgba(255,241,214,.95); }
.modal.cat { width: min(820px, 94vw); gap: 14px; padding-bottom: 22px; }
.cat-ctl { position: sticky; top: -28px; z-index: 1; margin: 0 -32px; padding: 6px 32px 10px; background: var(--bg2); display: flex; flex-direction: column; gap: 10px; }
#catBuscar { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: #fff; font-size: 15px; outline: 0; }
#catBuscar:focus { border-color: var(--coral); }
.cat-temas { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.cat-temas::-webkit-scrollbar { display: none; }
.cat-temas button { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 13px; font-size: 13px; white-space: nowrap; transition: all .2s; }
.cat-temas button em { font-style: normal; font-family: var(--f-mono); font-size: 11px; color: var(--mute); margin-left: 4px; }
.cat-temas button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.cat-temas button.on em { color: rgba(255,255,255,.7); }
.cat-ley { display: flex; flex-wrap: wrap; gap: 4px 14px; font-family: var(--f-mono); font-size: 11px; color: var(--mute); }
.cat-ley span { display: inline-flex; align-items: center; gap: 6px; }
.cat-ley i, .qi .sem { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.s-evidencia { background: #2BB673; } .s-analogia { background: #F2A900; } .s-simulacion { background: #F0442E; }
.cat-lista { display: flex; flex-direction: column; gap: 8px; }
.cat-lista h4 { margin: 10px 2px 2px; font-family: var(--f-mono); font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); }
.qi { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 1px solid transparent; background: #fff; border-radius: 16px; padding: 13px 14px; box-shadow: 0 4px 14px rgba(26,31,58,.05); transition: transform .15s, border-color .15s, box-shadow .15s; }
.qi:hover { transform: translateY(-1px); border-color: rgba(240,68,46,.4); box-shadow: 0 10px 24px rgba(26,31,58,.09); }
.qi .tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.qi .tx b { font-size: 15px; font-weight: 600; line-height: 1.3; }
.qi .tx small { font-family: var(--f-mono); font-size: 11px; color: var(--mute); }
.qi .tipo { flex: none; font-family: var(--f-mono); font-size: 10.5px; padding: 3px 8px; border-radius: 999px; background: rgba(240,68,46,.1); color: var(--coralInk); }
.qi .ir { flex: none; color: var(--mute); }
.cat-vacio { padding: 26px 8px; text-align: center; color: var(--mute); font-size: 14px; }
@media (max-width: 820px) {
  .cat-ctl { top: -22px; margin: 0 -18px; padding: 6px 18px 10px; }
  .modal.cat { gap: 12px; }
  .modal.cat h3 { font-size: 24px; }
  .qi { padding: 12px; } .qi .tx b { font-size: 14.5px; }
  body.estatico #send .lbl-l { display: none; } body.estatico #send .lbl-s { display: inline; }
  .aviso-llm.mini { margin: 0 12px 8px; }
  .modal.cat { width: 100vw; }
  .badge.est { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
