/* ==========================================================================
   Human Pulse — software de la cabina (kiosco, horizontal, táctil)
   Tokens de /shared/human.css. --cab-light / --cab-glow los escribe cabina.js.
   ========================================================================== */
:root {
  --cab-light: #6A4FB8;
  --cab-glow: .22;
  --s-ink: #F3EFFB;
  --s-ink-2: rgba(243, 239, 251, .7);
  --s-ink-3: rgba(243, 239, 251, .58);   /* antes .45: ~4:1 sobre el fondo; ahora supera 4.5:1 (AA) para texto chico */
  --s-line: rgba(255, 255, 255, .1);
  --s-glass: rgba(255, 255, 255, .06);
  --s-glass-2: rgba(255, 255, 255, .11);
  --ease: cubic-bezier(.22, .8, .25, 1);
  --pad-key: clamp(64px, 9.5vh, 96px);
}

html, body { height: 100%; }
body {
  background: var(--h-night);
  color: var(--s-ink);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
button, input { font-family: var(--h-font); color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
.veil {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 50%, transparent 40%, rgba(11, 9, 18, .55) 100%);
}

/* ---------- Barra superior ---------- */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; gap: 20px;
  padding: clamp(14px, 2.4vh, 26px) clamp(20px, 3vw, 44px);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: clamp(15px, 1.25vw, 19px); color: var(--s-ink-2); }
.brand b { color: var(--s-ink); font-weight: 500; }
.brand img { filter: brightness(1.6) saturate(.8); }
.where { display: flex; flex-direction: column; line-height: 1.25; padding-left: 20px; border-left: 1px solid var(--s-line); }
.where b { font-weight: 500; font-size: clamp(14px, 1.1vw, 17px); }
.where span { font-size: clamp(12px, .95vw, 14px); color: var(--s-ink-3); }
.tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.net { font-size: 14px; color: #F2B840; padding: 6px 12px; border-radius: 99px; background: rgba(242, 184, 64, .12); }
.icon-btn {
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--s-line);
  background: var(--s-glass); display: grid; place-items: center; opacity: .7; transition: opacity .2s, background .2s;
}
.icon-btn:hover, .icon-btn:focus-visible { opacity: 1; background: var(--s-glass-2); }
.icon-btn svg { width: 20px; height: 20px; }
#btnSonido .x { display: none; }
#btnSonido.off .x { display: inline; }
#btnSonido.off .w1, #btnSonido.off .w2 { display: none; }

/* ---------- Vistas ---------- */
main { position: fixed; inset: 0; z-index: 2; }
.view {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: clamp(96px, 12.5vh, 124px) clamp(24px, 5vw, 80px) clamp(70px, 10vh, 110px);
  opacity: 0; visibility: hidden; transform: translateY(12px);
  transition: opacity .6s var(--ease), transform .6s var(--ease), visibility 0s linear .6s;
}
.view.on { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }

.big { margin: 0 0 .4em; font-weight: 400; letter-spacing: -.02em; font-size: clamp(32px, 3.6vw, 56px); line-height: 1.1; }
.soft { color: var(--s-ink-2); font-size: clamp(16px, 1.35vw, 21px); line-height: 1.5; margin: 0 0 1em; }
.soft.lg { font-size: clamp(19px, 1.7vw, 26px); }
.soft b { color: var(--s-ink); font-weight: 500; }
.msg-err { min-height: 1.5em; margin: .6em 0; color: #FF9EA6; font-size: clamp(15px, 1.2vw, 18px); }
.row { display: flex; gap: 14px; justify-content: center; margin-top: clamp(18px, 3vh, 34px); flex-wrap: wrap; }
.center { text-align: center; max-width: 900px; }

.primary, .ghost {
  min-height: 64px; padding: 0 clamp(28px, 3vw, 46px); border-radius: 20px; border: 0;
  font-size: clamp(18px, 1.5vw, 23px); font-weight: 500; transition: transform .12s, background .2s, opacity .2s;
}
.primary { background: var(--h-purple); color: #fff; box-shadow: 0 14px 34px -14px rgba(123, 79, 208, .9); }
.primary:hover { background: #8a5fe0; }
.primary:disabled { opacity: .35; cursor: default; box-shadow: none; }
.ghost { background: var(--s-glass); border: 1px solid var(--s-line); color: var(--s-ink); }
.ghost:hover { background: var(--s-glass-2); }
.ghost.sm { min-height: 56px; padding: 0 24px; border-radius: 16px; font-size: 17px; }
.primary:active:not(:disabled), .ghost:active, .pad button:active, .mood:active, .scale button:active { transform: scale(.97); }
.link-btn { border: 0; background: none; color: var(--s-ink-2); font-size: clamp(17px, 1.4vw, 22px); text-decoration: underline; text-underline-offset: 6px; text-decoration-color: rgba(255,255,255,.3); padding: 14px 18px; min-height: 56px; }
:focus-visible { outline: 3px solid rgba(185, 163, 234, .8); outline-offset: 3px; }

/* ---------- Emparejar / Human Key ---------- */
/* Texto + teclado forman UN bloque centrado (antes el texto quedaba pegado a la izquierda y el teclado a la derecha). */
.pair { display: grid; grid-template-columns: minmax(0, 640px) auto; justify-content: center; gap: clamp(32px, 6vw, 110px); align-items: center; width: 100%; max-width: 1400px; }
.pair-txt { min-width: 0; }
.slots { display: flex; gap: clamp(8px, .8vw, 14px); margin: clamp(16px, 3vh, 34px) 0 0; }
.slots span {
  width: clamp(54px, 5vw, 80px); height: clamp(70px, 9vh, 100px); border-radius: 16px;
  display: grid; place-items: center; font-size: clamp(34px, 3.4vw, 54px); font-weight: 500;
  background: var(--s-glass); border: 1px solid var(--s-line); transition: border-color .2s, background .2s;
}
.slots span.cur { border-color: rgba(185, 163, 234, .8); background: var(--s-glass-2); }
.slots.key span { width: clamp(44px, 3.6vw, 60px); font-size: clamp(28px, 2.7vw, 44px); }
.slots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.pad { display: grid; grid-template-columns: repeat(3, calc(var(--pad-key) * 1.2)); gap: clamp(10px, 1.4vh, 16px); }
.pad button {
  height: var(--pad-key); border-radius: 22px; border: 1px solid var(--s-line); background: var(--s-glass);
  font-size: clamp(28px, 2.6vw, 40px); font-weight: 400; transition: background .15s, transform .1s;
}
.pad button:hover { background: var(--s-glass-2); }
.pad button.fn { font-size: clamp(15px, 1.2vw, 18px); color: var(--s-ink-2); }
.pad button.ok { background: var(--h-purple); border-color: transparent; color: #fff; font-size: clamp(17px, 1.4vw, 21px); font-weight: 500; }
.pad button.ok:disabled { opacity: .35; }
/* Teclas de texto en el teclado numérico: el botón es cuadrado, la palabra tiene que caber adentro. */
.pad:not(.abc) button.fn, .pad:not(.abc) button.ok { padding: 0 4px; min-width: 0; white-space: nowrap; font-size: clamp(14px, 1.1vw, 17px); letter-spacing: -.01em; }
/* Teclado alfabético: tecla nunca menor a 56 px; Borrar (3) + Entrar (5) llenan la última fila completa. */
.pad.abc { --abc-key: max(56px, calc(var(--pad-key) * .78)); grid-template-columns: repeat(8, var(--abc-key)); }
.pad.abc button { height: var(--abc-key); font-size: clamp(22px, 2vw, 30px); border-radius: 18px; padding: 0; }
.pad.abc button.fn { grid-column: span 3; }
.pad.abc button.ok { grid-column: span 5; }

/* ---------- Reposo ---------- */
.rest { text-align: center; max-width: 1100px; }
.rest-cab { margin: 0 0 clamp(20px, 4vh, 44px); display: flex; flex-direction: column; gap: 4px; font-size: clamp(20px, 1.7vw, 28px); font-weight: 500; }
.rest-cab small { font-size: clamp(15px, 1.2vw, 19px); color: var(--s-ink-3); font-weight: 400; }
.rest-lead { font-size: clamp(26px, 2.8vw, 46px); font-weight: 400; letter-spacing: -.01em; line-height: 1.25; margin: 0; }
.rest-lead b { color: #CDB6F0; font-weight: 600; }
.rest-code {
  margin: clamp(14px, 3vh, 34px) 0 clamp(8px, 2vh, 20px);
  font-size: clamp(96px, 13vw, 210px); font-weight: 600; letter-spacing: .14em; line-height: 1; padding-left: .14em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, #F3EFFB 10%, #CDB6F0 55%, #9BEFB0 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 10px 40px rgba(142, 107, 224, .35));
}

/* ---------- Hola ---------- */
.hello { margin: 0 0 .35em; overflow-wrap: anywhere; font-weight: 400; font-size: clamp(48px, 5.4vw, 92px); letter-spacing: -.03em; line-height: 1.05; }
.hello span { color: #CDB6F0; font-weight: 500; }

/* ---------- Check-in / check-out ---------- */
.feel { width: 100%; max-width: 1180px; text-align: center; }
/* flex y no grid: con 7 emociones la última fila (3) queda centrada y no pegada a la izquierda */
.moods { --mcols: 4; --mgap: clamp(10px, 1.4vw, 18px); display: flex; flex-wrap: wrap; justify-content: center; gap: var(--mgap); margin-top: clamp(10px, 2vh, 24px); }
.moods .mood { flex: 0 0 calc((100% - (var(--mcols) - 1) * var(--mgap)) / var(--mcols)); min-width: 0; }
.mood {
  min-height: clamp(76px, 11vh, 112px); border-radius: 22px; border: 1px solid var(--s-line); background: var(--s-glass);
  display: flex; align-items: center; gap: 14px; padding: 0 clamp(16px, 1.6vw, 26px);
  font-size: clamp(19px, 1.6vw, 25px); text-align: left; transition: background .2s, border-color .2s, transform .1s;
}
.mood i { width: 18px; height: 18px; border-radius: 50%; background: var(--c); box-shadow: 0 0 18px var(--c); flex: none; }
.mood[aria-checked="true"] { background: color-mix(in srgb, var(--c) 22%, transparent); border-color: var(--c); }
.intens { margin-top: clamp(18px, 3.6vh, 40px); }
.intens .soft { margin-bottom: .6em; }
.scale { display: inline-flex; gap: clamp(10px, 1vw, 16px); align-items: center; }
.scale button {
  width: clamp(64px, 6vw, 92px); height: clamp(64px, 6vw, 92px); border-radius: 50%; border: 1px solid var(--s-line);
  background: var(--s-glass); font-size: clamp(22px, 2vw, 32px); transition: background .2s, border-color .2s, transform .1s;
}
.scale button[aria-checked="true"] { background: var(--h-purple); border-color: transparent; color: #fff; }
.scale small { font-size: clamp(13px, 1vw, 15px); color: var(--s-ink-3); width: 6em; }
.scale small:first-child { text-align: right; }
.scale small:last-child { text-align: left; }

.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(14px, 1.6vw, 24px); margin-top: clamp(12px, 3vh, 30px); }
.mode {
  border-radius: 28px; border: 1px solid var(--s-line); background: var(--s-glass);
  padding: clamp(22px, 2.4vw, 38px); text-align: left; min-height: clamp(220px, 34vh, 340px);
  display: flex; flex-direction: column; gap: 12px; transition: background .2s, border-color .2s, transform .12s;
}
.mode:hover { background: var(--s-glass-2); border-color: rgba(185, 163, 234, .45); }
.mode:disabled { opacity: .5; }
.mode .ico { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: rgba(185, 163, 234, .16); color: #CDB6F0; }
.mode .ico svg { width: 28px; height: 28px; }
.mode b { font-size: clamp(24px, 2.1vw, 34px); font-weight: 500; }
.mode p { margin: 0; color: var(--s-ink-2); font-size: clamp(16px, 1.25vw, 20px); line-height: 1.45; flex: 1; }
.mode small { color: var(--s-ink-3); font-size: clamp(14px, 1vw, 16px); }

/* ---------- Adaptativa ---------- */
.view.bare { align-items: flex-end; }
.phrase {
  position: absolute; left: 50%; bottom: clamp(140px, 22vh, 230px); transform: translate(-50%, 10px);
  width: min(90%, 900px); text-align: center; margin: 0;
  font-size: clamp(24px, 2.4vw, 40px); font-weight: 300; letter-spacing: -.01em; line-height: 1.3;
  opacity: 0; transition: opacity 1.4s var(--ease), transform 1.4s var(--ease);
}
.phrase.on { opacity: 1; transform: translate(-50%, 0); }
.breath {
  position: absolute; left: 50%; bottom: clamp(100px, 15vh, 160px); transform: translateX(-50%); margin: 0;
  font-size: clamp(14px, 1.1vw, 17px); letter-spacing: .3em; text-transform: uppercase; color: var(--s-ink-3);
}

/* ---------- Conexión ---------- */
.chat { width: 100%; max-width: 980px; height: 100%; display: flex; flex-direction: column; min-height: 0;
  background: rgba(18, 15, 28, .55); border: 1px solid var(--s-line); border-radius: 28px; padding: clamp(16px, 2vw, 26px);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.chat-head { display: flex; align-items: center; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--s-line); }
.chat-head b { display: block; font-weight: 500; font-size: clamp(18px, 1.4vw, 22px); }
.chat-head small { display: block; font-size: clamp(13px, 1vw, 15px); color: var(--s-ink-3); }
.h-pulse.mini { width: 26px; height: 26px; flex: none; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 4px; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; user-select: text; -webkit-user-select: text; }
.msg { max-width: 78%; padding: 14px 18px; border-radius: 22px; font-size: clamp(17px, 1.35vw, 21px); line-height: 1.45; animation: msgIn .45s var(--ease); white-space: pre-wrap; }
.msg.ai { align-self: flex-start; background: rgba(255,255,255,.09); border-bottom-left-radius: 6px; }
.msg.me { align-self: flex-end; background: linear-gradient(135deg, #8E6BE0, #7B4FD0); border-bottom-right-radius: 6px; }
.msg.typing { display: flex; gap: 5px; padding: 18px; }
.msg.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--s-ink-2); animation: dots 1.2s infinite; }
.msg.typing i:nth-child(2) { animation-delay: .15s; } .msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dots { 0%, 60%, 100% { opacity: .25; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }
.chat-in { display: flex; gap: 10px; padding-top: 12px; }
.chat-in input { flex: 1; min-width: 0; height: 62px; padding: 0 20px; border-radius: 18px; border: 1px solid var(--s-line); background: rgba(255,255,255,.07); font-size: clamp(17px, 1.35vw, 20px); outline: none; user-select: text; -webkit-user-select: text; }
.chat-in input:focus { border-color: rgba(205,182,240,.6); }
.chat-in input::placeholder { color: var(--s-ink-3); }
.chat-in button { width: 62px; border-radius: 18px; border: 0; background: var(--h-purple); color: #fff; display: grid; place-items: center; }
.chat-in button:disabled { opacity: .4; }
.chat-in button svg { width: 24px; height: 24px; }

/* Protocolo de cuidado */
.care {
  margin-top: 12px; padding: clamp(18px, 2vw, 28px); border-radius: 24px; animation: msgIn .5s var(--ease);
  background: linear-gradient(160deg, rgba(76, 212, 106, .16), rgba(142, 107, 224, .16)); border: 1px solid rgba(155, 239, 176, .4);
}
.care > p { margin: 0 0 14px; font-size: clamp(17px, 1.35vw, 21px); line-height: 1.5; }
.care-lines { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.care-lines li { border-radius: 20px; background: rgba(255,255,255,.08); padding: 14px 16px; text-align: center; }
.care-lines b { display: block; font-size: clamp(48px, 5vw, 80px); font-weight: 600; line-height: 1.05; color: #9BEFB0; letter-spacing: .02em; }
.care-lines b small { font-size: .38em; font-weight: 500; color: var(--s-ink); letter-spacing: 0; }
.care-lines span { display: block; font-size: clamp(13px, 1vw, 16px); color: var(--s-ink-2); margin-top: 4px; line-height: 1.3; }
.care .care-foot { margin: 14px 0 0; font-size: clamp(14px, 1.05vw, 16px); color: var(--s-ink-2); }
.care { flex: 0 1 auto; min-height: 0; overflow-y: auto; }   /* en pantallas bajas el bloque de líneas se desplaza en vez de salirse del recuadro */
.care-lines b { font-size: clamp(40px, 4.2vw, 68px); }
.chat.riesgo .chat-log { flex: 0 1 auto; max-height: 20vh; }

/* ---------- Libre ---------- */
.free { position: absolute; left: 50%; bottom: clamp(110px, 17vh, 180px); transform: translateX(-50%); width: min(92%, 760px); text-align: center; }
.free .bt { width: 48px; height: 48px; color: #8FB4EE; }
.free-t { font-size: clamp(24px, 2.3vw, 36px); margin: 8px 0 10px; font-weight: 400; }

/* ---------- Cierre ---------- */
.delta { display: flex; align-items: center; justify-content: center; gap: clamp(20px, 3vw, 54px); margin: clamp(14px, 3vh, 34px) 0; }
.delta div { display: flex; flex-direction: column; align-items: center; }
.delta small { font-size: clamp(16px, 1.3vw, 20px); color: var(--s-ink-2); }
.delta b { font-size: clamp(84px, 9vw, 150px); font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.delta div:last-child b { color: #9BEFB0; }
.delta svg { width: clamp(40px, 4vw, 64px); height: clamp(40px, 4vw, 64px); color: var(--s-ink-3); }
.motto { font-size: clamp(22px, 2vw, 32px); font-style: italic; color: #CDB6F0; margin: clamp(10px, 2vh, 22px) 0 clamp(18px, 3vh, 30px); }

/* ---------- Barra de la experiencia ---------- */
.exp-bar {
  position: fixed; left: 50%; bottom: clamp(18px, 3vh, 32px); transform: translateX(-50%); z-index: 4;
  display: flex; align-items: center; gap: 16px; padding: 8px 8px 8px 20px; border-radius: 20px;
  background: rgba(18, 15, 28, .5); border: 1px solid var(--s-line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  opacity: .7; transition: opacity .3s;
}
.exp-bar:hover { opacity: 1; }
.exp-time { font-size: 15px; color: var(--s-ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.exp-track { width: clamp(120px, 14vw, 220px); height: 4px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
.exp-track i { display: block; height: 100%; width: 0; background: var(--cab-light); border-radius: 4px; transition: width 1s linear; }

/* ---------- Avisos ---------- */
.tap-hint {
  position: fixed; left: 50%; top: clamp(100px, 13vh, 130px); transform: translateX(-50%); z-index: 6;
  padding: 10px 18px; border-radius: 99px; background: var(--s-glass-2); border: 1px solid var(--s-line);
  font-size: 15px; color: var(--s-ink-2); pointer-events: none; animation: hint 3s ease-in-out infinite;
}
@keyframes hint { 50% { opacity: .5; } }
.toast {
  position: fixed; left: 50%; bottom: clamp(104px, 14vh, 140px); transform: translate(-50%, 20px); z-index: 7;
  padding: 14px 22px; border-radius: 16px; background: rgba(30, 24, 48, .95); border: 1px solid var(--s-line);
  font-size: 17px; opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; max-width: 80vw; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Pantallas más bajitas (1280×800 y similares) ---------- */
@media (max-height: 820px) {
  .mood { min-height: 70px; }
  .mode { min-height: 200px; }
}
/* La barra de la experiencia (56 px + margen) flota abajo: el chat necesita más aire para no quedar tapado */
.view[data-view="conexion"] { padding-bottom: clamp(104px, 14vh, 140px); }
@media (max-width: 1100px) {
  .moods { --mcols: 3; }
}
/* Human Key (8 casillas + teclado de 8 columnas) necesita más ancho: apila antes que el teclado numérico */
@media (max-width: 1200px) {
  .pair.pair-key { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  .pair-key .slots { justify-content: center; }
}
/* Vertical o pantalla angosta: todo en una columna */
@media (max-width: 820px), (orientation: portrait) {
  .pair { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  .slots { justify-content: center; }
  .modes { grid-template-columns: 1fr; }
  .mode { min-height: 0; }
}
@media (max-width: 640px) { .moods { --mcols: 2; } }

@media (prefers-reduced-motion: reduce) {
  .view, .view.on { transition-duration: .2s !important; transform: none !important; }
  .phrase, .phrase.on, .toast, .toast.on { transition-duration: .2s !important; transform: translate(-50%, 0) !important; }
  .msg, .care, .slots.shake, .tap-hint { animation: none !important; }
  .msg.typing i { animation: none; opacity: .6; }
}
