/* ══ Reset & Base ═══════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%; height: 100dvh;
  overflow: hidden;
  font-family: 'Nunito', sans-serif;
  background: #1a0a2e;
  color: #f0e6ff;
  -webkit-tap-highlight-color: transparent;
}

/* ══ Screens ════════════════════════════════════════════════════════ */
.screen {
  display: none;
  position: fixed;
  inset: 0;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ══ ONBOARDING ══════════════════════════════════════════════════════ */
#screen-onboarding {
  background: linear-gradient(180deg, #1a0a2e 0%, #2d1b4e 100%);
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.step {
  display: none;
  width: 100%;
  max-width: 420px;
  animation: fadeSlideUp 0.3s ease;
}

.step.active { display: block; }

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

/* ── Welcome ─────────────────────────────────────────────────────── */
.welcome { text-align: center; padding: 2rem 1rem; }

.welcome-cat {
  font-size: 5.5rem;
  display: block;
  margin-bottom: 1rem;
  animation: catBounce 2.2s ease-in-out infinite;
}

@keyframes catBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  45%       { transform: translateY(-14px) rotate(-3deg); }
  55%       { transform: translateY(-14px) rotate(3deg); }
}

.welcome-title {
  font-family: 'Fredoka One', cursive;
  font-size: 3.2rem;
  color: #FF6B9D;
  text-shadow: 0 0 32px rgba(255,107,157,0.55);
  line-height: 1;
  margin-bottom: 0.35rem;
}

.welcome-sub {
  font-size: 1.05rem;
  color: #A29BFE;
  margin-bottom: 1rem;
}

.welcome-desc {
  color: #c0b0dd;
  margin-bottom: 2rem;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ── Step shell ──────────────────────────────────────────────────── */
.step-content { text-align: center; padding: 0.5rem 0.25rem; }

.step-cat {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 0.4rem;
}

.step-num {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #A29BFE;
  margin-bottom: 0.5rem;
}

.step-title {
  font-family: 'Fredoka One', cursive;
  font-size: 1.65rem;
  color: #FF6B9D;
  margin-bottom: 0.4rem;
  line-height: 1.2;
}

.step-hint {
  color: #c0b0dd;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

/* ── Text input ──────────────────────────────────────────────────── */
.text-input {
  width: 100%;
  background: rgba(255,255,255,0.07);
  border: 2px solid rgba(162,155,254,0.3);
  border-radius: 18px;
  padding: 0.85rem 1.2rem;
  color: #f0e6ff;
  font-size: 1.1rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 1.25rem;
}

.text-input:focus {
  border-color: #FF6B9D;
  box-shadow: 0 0 0 3px rgba(255,107,157,0.15);
}

.text-input::placeholder { color: rgba(192,176,221,0.45); }

/* ── Option cards ────────────────────────────────────────────────── */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin-bottom: 1.25rem;
}

.options-grid.single-col { grid-template-columns: 1fr; }

.option-card { cursor: pointer; display: block; }

.option-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0; height: 0;
}

.option-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.85rem 0.6rem;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(162,155,254,0.18);
  border-radius: 18px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.1s;
  user-select: none;
}

.option-inner.horiz {
  flex-direction: row;
  justify-content: flex-start;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
}

.option-card input:checked + .option-inner {
  background: rgba(255,107,157,0.14);
  border-color: #FF6B9D;
  box-shadow: 0 0 18px rgba(255,107,157,0.22);
}

.option-card:active .option-inner { transform: scale(0.97); }

.option-emoji { font-size: 1.9rem; line-height: 1; }
.option-inner.horiz .option-emoji { font-size: 1.5rem; }

.option-label {
  font-weight: 800;
  font-size: 0.82rem;
  color: #f0e6ff;
}

.option-desc {
  font-size: 0.7rem;
  color: #a090cc;
  line-height: 1.3;
}

/* ── Control feedback ────────────────────────────────────────────── */
.control-feedback {
  padding: 0.7rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.4;
}

.control-feedback.hidden { display: none; }

.control-feedback.error {
  background: rgba(232,67,147,0.12);
  border: 1.5px solid rgba(232,67,147,0.35);
  color: #FF6B9D;
}

.control-feedback.success {
  background: rgba(85,239,196,0.12);
  border: 1.5px solid rgba(85,239,196,0.35);
  color: #55EFC4;
}

/* ── Primary button ──────────────────────────────────────────────── */
.btn-primary {
  display: block;
  width: 100%;
  background: linear-gradient(135deg, #FF6B9D 0%, #A29BFE 100%);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 0.9rem 2rem;
  font-size: 1.05rem;
  font-family: 'Fredoka One', cursive;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.12s;
  box-shadow: 0 4px 22px rgba(255,107,157,0.28);
}

.btn-primary:active { transform: scale(0.97); opacity: 0.88; }

/* ── Shake ───────────────────────────────────────────────────────── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}

.shake { animation: shake 0.38s ease; }

/* ══ CHAT SCREEN ════════════════════════════════════════════════════ */
#screen-chat {
  background: linear-gradient(180deg, #1a0a2e 0%, #0d0d1a 100%);
}

/* ── Header ──────────────────────────────────────────────────────── */
.chat-header {
  background: rgba(26,10,46,0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(162,155,254,0.14);
  padding: 0.7rem 1rem;
  padding-top: max(0.7rem, env(safe-area-inset-top));
  flex-shrink: 0;
}

.chat-header-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chat-avatar-big { font-size: 2.1rem; line-height: 1; }

.chat-header-info { flex: 1; }

.chat-header-title {
  font-family: 'Fredoka One', cursive;
  font-size: 1.3rem;
  color: #FF6B9D;
  line-height: 1.1;
  text-shadow: 0 0 16px rgba(255,107,157,0.4);
}

.chat-header-sub {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #A29BFE;
}

.chat-vitality { display: flex; gap: 3px; align-items: center; }

.vit-paw {
  font-size: 1rem;
  transition: opacity 0.3s, transform 0.3s;
}

.vit-paw.empty { opacity: 0.18; }

.vit-paw.refilling { animation: pawRefill 0.6s ease; }

@keyframes pawRefill {
  0%   { transform: scale(0.4); opacity: 0.18; }
  65%  { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.vit-sleep {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: #A29BFE;
  padding-top: 0.3rem;
  padding-left: 3rem;
}

/* ── Messages ────────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  overscroll-behavior: contain;
}

.chat-msg {
  display: flex;
  gap: 0.45rem;
  max-width: 86%;
  animation: msgIn 0.2s ease;
}

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

.chat-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg--bot { align-self: flex-start; }

.chat-bubble {
  padding: 0.62rem 0.95rem;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.55;
  word-break: break-word;
}

.chat-bubble--user {
  background: linear-gradient(135deg, #FF6B9D, #C44569);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.chat-bubble--bot {
  background: rgba(162,155,254,0.1);
  border: 1px solid rgba(162,155,254,0.18);
  color: #f0e6ff;
  border-bottom-left-radius: 5px;
}

.chat-avatar-sm {
  font-size: 1.2rem;
  line-height: 1;
  margin-top: 5px;
  flex-shrink: 0;
}

.chat-cursor {
  display: inline-block;
  color: #FF6B9D;
  animation: cursorBlink 0.7s step-end infinite;
}

@keyframes cursorBlink { 50% { opacity: 0; } }

.chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0.7rem 0.95rem;
  min-width: 56px;
}

.chat-typing span {
  width: 7px; height: 7px;
  background: #A29BFE;
  border-radius: 50%;
  animation: typingDot 1.2s ease-in-out infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

.chat-bubble code {
  background: rgba(0,0,0,0.28);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.84em;
  font-family: monospace;
}

/* ── Install banner ──────────────────────────────────────────────── */
.install-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  background: rgba(162,155,254,0.1);
  border-top: 1px solid rgba(162,155,254,0.18);
  font-size: 0.8rem;
  color: #c0b0dd;
  flex-shrink: 0;
}

.install-banner.hidden { display: none; }
.install-banner > span { flex: 1; }

.btn-install {
  background: linear-gradient(135deg, #FF6B9D, #A29BFE);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 0.28rem 0.85rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-dismiss {
  background: none;
  border: none;
  color: #a090cc;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.15rem 0.4rem;
  line-height: 1;
}

/* ── Chat form ───────────────────────────────────────────────────── */
.chat-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.9rem;
  padding-bottom: max(0.65rem, env(safe-area-inset-bottom));
  background: rgba(26,10,46,0.96);
  border-top: 1px solid rgba(162,155,254,0.14);
  flex-shrink: 0;
  position: relative;
}

.chat-input {
  flex: 1;
  background: rgba(255,255,255,0.07);
  border: 2px solid rgba(162,155,254,0.22);
  border-radius: 24px;
  padding: 0.6rem 1rem;
  color: #f0e6ff;
  font-size: 0.95rem;
  font-family: 'Nunito', sans-serif;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}

.chat-input:focus { border-color: rgba(255,107,157,0.5); }
.chat-input::placeholder { color: rgba(192,176,221,0.4); }

.chat-char-count {
  position: absolute;
  bottom: calc(max(0.65rem, env(safe-area-inset-bottom)) + 2.7rem);
  right: 4.5rem;
  font-size: 0.62rem;
  color: #999;
  pointer-events: none;
}

.chat-send-btn {
  background: linear-gradient(135deg, #FF6B9D, #A29BFE);
  border: none;
  border-radius: 50%;
  width: 44px; height: 44px;
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s, opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 14px rgba(255,107,157,0.28);
}

.chat-send-btn:active { transform: scale(0.9); }
.chat-send-btn:disabled { opacity: 0.45; }

/* ── Botón limpiar conversación ─────────────────────────────────── */
.btn-clear-chat {
  background: none;
  border: none;
  color: rgba(162,155,254,0.5);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: 8px;
  line-height: 1;
  transition: color 0.2s, background 0.2s;
  margin-left: 0.25rem;
}

.btn-clear-chat:hover,
.btn-clear-chat:active {
  color: #FF6B9D;
  background: rgba(255,107,157,0.1);
}

/* ── Separador de sesión ─────────────────────────────────────────── */
.chat-separator {
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(162,155,254,0.4);
  padding: 0.4rem 0;
  position: relative;
}

.chat-separator::before,
.chat-separator::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 22%;
  height: 1px;
  background: rgba(162,155,254,0.18);
}

.chat-separator::before { left: 0; }
.chat-separator::after  { right: 0; }

/* ── Burbujas sin animación de entrada (restauradas) ─────────────── */
.chat-msg.no-anim { animation: none; }

/* ══ Scrollbar ══════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(162,155,254,0.28);
  border-radius: 4px;
}
