/* ============ iglú M&T · Nuk — tema claro ============ */
:root {
  --cyan: #35e0ff;
  --blue: #4d7cfe;
  --royal: #2e63e7;
  --violet: #9d8cff;
  --green: #22c98d;
  --navy: #0b2545;
  --ink: #17395e;
  --muted: #6b87a5;
  --line: #e3edf7;
  --bg-1: #fdfeff;
  --bg-2: #eef5fc;
  --grad: linear-gradient(135deg, #35e0ff, #4d7cfe 60%, #9d8cff);
  --radius: 18px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  color: var(--navy);
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
  overflow: hidden;
}

.hidden { display: none !important; }
.grad-text {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ═══════════ INTRO / LOGIN ═══════════ */
.intro {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 12% 18%, rgba(53, 224, 255, .07), transparent 42%),
    radial-gradient(circle at 88% 78%, rgba(157, 140, 255, .08), transparent 45%),
    radial-gradient(1.5px 1.5px at 18% 30%, rgba(46, 99, 231, .18), transparent),
    radial-gradient(1.5px 1.5px at 72% 12%, rgba(46, 99, 231, .14), transparent),
    radial-gradient(1.5px 1.5px at 85% 55%, rgba(46, 99, 231, .16), transparent),
    radial-gradient(1.5px 1.5px at 32% 82%, rgba(46, 99, 231, .12), transparent),
    linear-gradient(180deg, #fdfeff 0%, #eaf3fc 100%);
  transition: opacity .7s ease, transform .7s cubic-bezier(.55, 0, .8, .4);
  overflow: hidden;
}
.intro.exit { opacity: 0; transform: scale(1.6); pointer-events: none; }

.aurora {
  position: absolute; pointer-events: none; filter: blur(46px);
  animation: aurora 10s ease-in-out infinite;
}
.aurora.a1 { top: -160px; left: -120px; width: 620px; height: 400px;
  background: radial-gradient(ellipse at center, rgba(53, 224, 255, .16), transparent 70%); }
.aurora.a2 { bottom: -160px; right: -120px; width: 560px; height: 380px;
  background: radial-gradient(ellipse at center, rgba(157, 140, 255, .15), transparent 70%);
  animation-delay: 3s; }
@keyframes aurora { 0%, 100% { opacity: .55; transform: translateX(0) scale(1); }
  50% { opacity: 1; transform: translateX(28px) scale(1.06); } }

.intro-inner {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  width: min(430px, 92vw);
  padding: 12px 0 28px;
  animation: fadeUp .7s ease both .15s;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

/* — Planeta 3D — */
.planet-stage {
  position: relative;
  width: min(340px, 82vw); height: min(340px, 82vw);
  display: flex; align-items: center; justify-content: center;
  animation: floaty 7s ease-in-out infinite;
}
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.planet-halo {
  position: absolute; inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(53, 224, 255, .22), rgba(77, 124, 254, .1) 55%, transparent 72%);
  filter: blur(10px);
  animation: halo 4.5s ease-in-out infinite;
}
@keyframes halo { 0%, 100% { opacity: .75; } 50% { opacity: 1; } }

.planet-core {
  position: absolute; inset: 21%;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #ffffff 0%, #d9f4ff 30%, #b7d9ff 62%, #96b8f5 100%);
  box-shadow:
    0 24px 60px rgba(46, 99, 231, .22),
    inset -18px -24px 48px rgba(77, 124, 254, .28),
    inset 10px 12px 30px rgba(255, 255, 255, .9);
}

#planet { position: absolute; inset: 0; width: 100%; height: 100%; }

/* — Órbitas con chips — */
.orbit { position: absolute; border: 1.5px dashed rgba(77, 124, 254, .3); border-radius: 50%; }
.orbit.o1 { inset: 7%; animation: spin 22s linear infinite; }
.orbit.o2 { inset: -3%; border-color: rgba(77, 124, 254, .18); animation: spin 34s linear infinite reverse; }

.orb-chip {
  position: absolute;
  display: flex; align-items: center; gap: 5px;
  background: rgba(255, 255, 255, .94);
  border: 1.5px solid; border-radius: 999px;
  padding: 4px 11px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .3px;
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 18px rgba(23, 57, 94, .12);
}
.orb-chip i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.orbit.o1 .orb-chip { animation: spinRev 22s linear infinite; }
.orbit.o2 .orb-chip { animation: spinRev 34s linear infinite reverse; }
.c-cyan   { color: #00a7cc; border-color: rgba(53, 224, 255, .55); }
.c-violet { color: #7a63f2; border-color: rgba(157, 140, 255, .6); }
.c-blue   { color: var(--royal); border-color: rgba(77, 124, 254, .55); }
.c-green  { color: #109c6d; border-color: rgba(34, 201, 141, .55); }

.orb-dot {
  position: absolute; width: 7px; height: 7px; border-radius: 50%;
  background: var(--cyan); box-shadow: 0 0 10px var(--cyan);
}
.orb-dot.violet { background: var(--violet); box-shadow: 0 0 10px var(--violet); }

@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes spinRev { from { transform: rotate(0); } to { transform: rotate(-360deg); } }

/* — Marca — */
.brand-lockup { display: flex; align-items: center; gap: 13px; margin-top: 10px; }
.logo8 { display: flex; flex-direction: column; align-items: center; }
.logo8 .ring { border-radius: 50%; border: 3.5px solid; }
.logo8 .r1 { width: 15px; height: 15px; border-color: var(--cyan); box-shadow: 0 0 10px rgba(53, 224, 255, .45); }
.logo8 .r2 { width: 19px; height: 19px; border-color: var(--blue); margin-top: -5px; box-shadow: 0 0 10px rgba(77, 124, 254, .4); }
.logo8.mini .r1 { width: 8px; height: 8px; border-width: 2px; box-shadow: none; }
.logo8.mini .r2 { width: 10px; height: 10px; border-width: 2px; margin-top: -3px; box-shadow: none; }

.brand-name { font-size: 33px; font-weight: 800; letter-spacing: -.5px; line-height: 1; }
.brand-sub {
  font-size: 11px; font-weight: 600; color: var(--muted);
  letter-spacing: 2.6px; text-transform: uppercase; margin-top: 5px;
}

/* — Acceso — */
.login-box { width: 100%; margin-top: 34px; display: flex; flex-direction: column; gap: 14px; padding: 0 8px; }
.phone-field {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1.5px solid var(--line);
  border-radius: 16px; padding: 15px 18px;
  box-shadow: 0 10px 30px rgba(23, 57, 94, .07);
  transition: border-color .2s, box-shadow .2s;
}
.phone-field:focus-within { border-color: var(--blue); box-shadow: 0 10px 34px rgba(77, 124, 254, .18); }
.phone-field .cc { font-size: 15px; font-weight: 700; color: var(--muted); }
.phone-field input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 16px; font-weight: 600; letter-spacing: .5px; color: var(--navy);
}
.phone-field input::placeholder { color: #a9c1d8; }

.cta {
  padding: 17px; border: none; border-radius: 16px;
  background: var(--grad);
  color: #04101f; font-family: inherit; font-size: 16px; font-weight: 800;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(77, 124, 254, .35);
  transition: transform .15s, box-shadow .2s;
}
.cta:hover { box-shadow: 0 16px 44px rgba(53, 224, 255, .5); transform: translateY(-1px); }
.cta:active { transform: scale(.97); }

.login-note { font-size: 11.5px; color: var(--muted); text-align: center; }
.access-error { font-size: 12.5px; font-weight: 600; color: #e5484d; text-align: center; margin-top: -6px; }
.phone-field.access-field.shake { animation: shake .4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

/* ═══════════ CHAT ═══════════ */
.app {
  width: 100%; max-width: 820px;
  height: 100dvh;
  margin: 0 auto;
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
  animation: appIn .6s ease both;
}
@keyframes appIn { from { opacity: 0; transform: scale(.98) translateY(10px); } to { opacity: 1; transform: none; } }

body { display: flex; justify-content: center; }

@media (min-width: 860px) {
  .app {
    height: 94dvh; margin: 3dvh auto;
    border-radius: 26px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .55);
    box-shadow: 0 40px 90px rgba(23, 57, 94, .14);
    backdrop-filter: blur(6px);
  }
}

/* planeta asomando */
.peek-planet {
  position: absolute; top: -130px; right: -100px;
  width: 270px; height: 270px; border-radius: 50%;
  background: radial-gradient(circle at 36% 62%, #ffffff 0%, #d9f4ff 28%, #b7d9ff 60%, #96b8f5 100%);
  box-shadow: 0 26px 70px rgba(46, 99, 231, .18), inset -16px -20px 44px rgba(77, 124, 254, .25);
  opacity: .8; pointer-events: none; z-index: 0;
  animation: floaty 9s ease-in-out infinite;
}
.peek-orbit {
  position: absolute; top: -30px; right: -130px;
  width: 330px; height: 74px;
  border: 1.5px dashed rgba(77, 124, 254, .28); border-radius: 50%;
  transform: rotate(-18deg);
  pointer-events: none; z-index: 0;
}

.chat-header {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, .82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
@media (min-width: 860px) { .chat-header { border-radius: 26px 26px 0 0; } }

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.avatar { position: relative; width: 46px; height: 46px; flex-shrink: 0; }
.avatar-planet {
  width: 100%; height: 100%; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 32% 28%, #b6f2ff, #38c6f4 40%, #2e63e7 85%);
  color: #04101f; font-weight: 800; font-size: 17px;
  box-shadow: 0 6px 18px rgba(56, 198, 244, .45);
}
.avatar .pulse {
  position: absolute; right: 0; bottom: 0;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--green); border: 2px solid #fff;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 201, 141, .55); }
  70% { box-shadow: 0 0 0 8px rgba(34, 201, 141, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 201, 141, 0); }
}

.brand-text h1 { font-size: 1.06rem; font-weight: 800; letter-spacing: -.2px; white-space: nowrap; }
.brand-text p {
  font-size: .75rem; font-weight: 600; color: var(--green);
  display: flex; align-items: center; gap: 5px; white-space: nowrap;
}
.brand-text .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; }

.header-actions { flex-shrink: 0; }
.badge-brand {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .74rem; font-weight: 800; color: var(--royal);
  background: rgba(77, 124, 254, .08);
  border: 1px solid rgba(77, 124, 254, .3);
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
  text-decoration: none; cursor: pointer; transition: all .18s;
}
.badge-brand:hover { background: rgba(77, 124, 254, .16); border-color: var(--blue); }

/* — Mensajes — */
.chat-area {
  flex: 1; overflow-y: auto;
  padding: 18px 16px 10px;
  display: flex; flex-direction: column; gap: 11px;
  scroll-behavior: smooth;
  position: relative; z-index: 1;
}

.day-divider { text-align: center; margin: 2px 0 6px; }
.day-divider span {
  font-size: .7rem; font-weight: 700; color: var(--muted);
  background: #fff; border: 1px solid var(--line);
  padding: 4px 14px; border-radius: 999px;
  box-shadow: 0 3px 10px rgba(23, 57, 94, .06);
}

.msg {
  max-width: 78%;
  padding: 11px 15px;
  font-size: .93rem; line-height: 1.5;
  position: relative; word-wrap: break-word;
  animation: pop .28s ease both;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } }

.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--royal), var(--blue));
  color: #f4f8fd;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 8px 20px rgba(46, 99, 231, .28);
}
.msg.bot {
  align-self: flex-start;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 8px 24px rgba(23, 57, 94, .08);
}

.msg .time { display: block; font-size: .66rem; text-align: right; margin-top: 4px; opacity: .65; }
.msg.user .time { color: #dbe9ff; }
.msg.user .time::after { content: ' ✓✓'; color: #9be7ff; }
.msg.bot .time { color: var(--muted); }

.msg img.photo { max-width: 100%; border-radius: 12px; display: block; margin-bottom: 6px; }
.msg audio { width: 230px; max-width: 100%; margin-top: 2px; }
.msg .audio-label { font-size: .76rem; opacity: .8; display: block; margin-bottom: 4px; }
.msg ul { margin: 6px 0 6px 18px; }
.msg.bot b { color: var(--royal); }

.typing {
  align-self: flex-start;
  background: #fff; border: 1px solid var(--line);
  border-radius: 18px 18px 18px 4px;
  padding: 15px 18px;
  display: flex; gap: 5px;
  box-shadow: 0 8px 24px rgba(23, 57, 94, .08);
}
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--blue);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

/* — Sugerencias — */
.quick-row {
  display: flex; gap: 8px;
  padding: 8px 14px 4px;
  overflow-x: auto;
  scrollbar-width: none;
  position: relative; z-index: 1;
}
.quick-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  font-family: inherit; font-size: .8rem; font-weight: 700;
  color: var(--ink);
  background: #fff; border: 1.5px solid rgba(77, 124, 254, .3);
  border-radius: 999px; padding: 9px 14px;
  cursor: pointer; transition: all .18s;
  box-shadow: 0 4px 12px rgba(23, 57, 94, .06);
}
.chip:hover, .chip:active {
  background: var(--grad); color: #04101f; border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(77, 124, 254, .35);
}

/* — Preview / grabación — */
.preview-bar, .record-bar {
  display: flex; align-items: center; gap: 12px;
  margin: 6px 14px 0;
  background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 9px 12px;
  box-shadow: 0 10px 26px rgba(23, 57, 94, .1);
  animation: pop .25s ease both;
  position: relative; z-index: 1;
}
.preview-bar img { width: 54px; height: 54px; object-fit: cover; border-radius: 10px; }
.preview-info { flex: 1; display: flex; flex-direction: column; }
.preview-info b { font-size: .85rem; color: var(--navy); }
.preview-info span { font-size: .74rem; color: var(--muted); }

.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #ff3b30; animation: recPulse 1s infinite; }
@keyframes recPulse { 50% { opacity: .35; } }
#rec-time { font-weight: 800; font-size: .95rem; color: var(--navy); min-width: 40px; }
.waves { flex: 1; display: flex; align-items: center; gap: 3px; height: 26px; }
.waves i {
  flex: 1; max-width: 6px; border-radius: 3px;
  background: var(--grad);
  animation: wave 1s ease-in-out infinite;
}
.waves i:nth-child(odd) { animation-delay: .15s; }
.waves i:nth-child(3n) { animation-delay: .3s; }
@keyframes wave { 0%, 100% { height: 8px; } 50% { height: 24px; } }

/* — Entrada — */
.input-bar {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  position: relative; z-index: 1;
}

.text-wrap {
  flex: 1;
  display: flex; align-items: flex-end;
  background: #fff; border: 1.5px solid var(--line);
  border-radius: 24px;
  padding: 5px 6px 5px 18px;
  min-height: 48px;
  box-shadow: 0 8px 24px rgba(23, 57, 94, .08);
  transition: border-color .2s;
}
.text-wrap:focus-within { border-color: rgba(77, 124, 254, .55); }
#text-input {
  flex: 1; width: 100%;
  border: none; outline: none; resize: none; background: transparent;
  font-family: inherit; font-size: .95rem; font-weight: 500; color: var(--navy);
  max-height: 110px; line-height: 1.45;
  padding: 9px 0;
}
#text-input::placeholder { color: #a9c1d8; }

.icon-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  border: none; border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
  background: transparent; color: var(--muted);
  transition: all .18s;
}
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn:hover { background: rgba(77, 124, 254, .1); color: var(--royal); }
.icon-btn.attach { background: #fff; border: 1.5px solid var(--line); box-shadow: 0 8px 24px rgba(23, 57, 94, .08); }
.icon-btn.attach:hover { color: var(--royal); border-color: rgba(77, 124, 254, .45); }
.icon-btn.mic { width: 38px; height: 38px; }
.icon-btn.danger { background: rgba(255, 59, 48, .08); color: #ff5148; font-size: 1.05rem; }
.icon-btn.danger:hover { background: rgba(255, 59, 48, .18); }
.mic.recording { background: #ff3b30; color: #fff; }

.send-btn {
  width: 48px; height: 48px; flex-shrink: 0;
  border: none; border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
  background: var(--grad);
  color: #04101f;
  box-shadow: 0 10px 26px rgba(77, 124, 254, .4);
  transition: all .18s;
}
.send-btn svg { width: 20px; height: 20px; }
.send-btn:hover { transform: scale(1.07); box-shadow: 0 12px 32px rgba(53, 224, 255, .55); }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { opacity: .5; cursor: default; transform: none; }

.chat-area::-webkit-scrollbar { width: 5px; }
.chat-area::-webkit-scrollbar-thumb { background: rgba(77, 124, 254, .25); border-radius: 3px; }

@media (max-width: 480px) {
  .msg { max-width: 86%; }
  .brand-text h1 { font-size: .98rem; }
  .badge-brand { font-size: .68rem; padding: 5px 10px; }
  .peek-planet { width: 210px; height: 210px; top: -110px; right: -85px; }
}
