/* ──────────────────────────────────────────
   PSICOLOCO — style.css
   Dirección visual: "santuario nocturno".
   Cielo índigo profundo con aurora lenta, vidrio esmerilado, tipografía
   serif cálida (Fraunces) + sans legible (Manrope), acentos lavanda y
   durazno. Las animaciones viven en app.js (GSAP); aquí solo estados.
────────────────────────────────────────── */

/* ══ TOKENS ══ */
:root {
  --bg: #0b0a1a;
  --bg-2: #110f24;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.075);
  --surface-3: rgba(255, 255, 255, 0.11);
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-2: rgba(255, 255, 255, 0.14);

  --lavender: #b9a8ff;
  --lavender-2: #8f7cf6;
  --peach: #ffb8a8;
  --mint: #8fe3cf;
  --rose: #ff8fa3;
  --gold: #ffd59e;

  --grad: linear-gradient(135deg, #cbbcff 0%, #a996ff 45%, #ffb8a8 100%);
  --grad-soft: linear-gradient(135deg, rgba(185, 168, 255, .18), rgba(255, 184, 168, .14));

  --text-1: #f4f1ff;
  --text-2: #b7b2d1;
  --text-3: #7d7899;

  --font-serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-sans: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --r-xl: 30px;
  --r-pill: 999px;

  --sidebar-w: 280px;
  --topbar-h: 68px;

  --shadow-1: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 10px 30px -12px rgba(0, 0, 0, .6);
  --shadow-glow: 0 10px 40px -10px rgba(169, 150, 255, .55);
  --blur: saturate(140%) blur(18px);

  --ease: cubic-bezier(.22, 1, .36, 1);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: var(--lavender);
}

img {
  display: block;
  max-width: 100%;
}

::selection {
  background: rgba(185, 168, 255, .35);
}

:focus-visible {
  outline: 2px solid var(--lavender);
  outline-offset: 3px;
  border-radius: 8px;
}

.hidden,
[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

em {
  font-style: italic;
}

/* Scrollbars discretos */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .12) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .1);
  border-radius: 8px;
}

/* ══ FONDO (aurora + estrellas + grano) ══ */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(1200px 700px at 50% 120%, #1b1640 0%, transparent 60%),
    linear-gradient(180deg, #0b0a1a 0%, #0e0c22 100%);
}

.aurora {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .55;
  will-change: transform;
}

.aurora-1 {
  width: 60vmax;
  height: 60vmax;
  left: -18vmax;
  top: -22vmax;
  background: radial-gradient(circle, #5a46c9 0%, transparent 65%);
}

.aurora-2 {
  width: 50vmax;
  height: 50vmax;
  right: -16vmax;
  top: 10vh;
  background: radial-gradient(circle, #b3577f 0%, transparent 65%);
  opacity: .35;
}

.aurora-3 {
  width: 45vmax;
  height: 45vmax;
  left: 25vw;
  bottom: -26vmax;
  background: radial-gradient(circle, #2f7f8f 0%, transparent 65%);
  opacity: .3;
}

.stars {
  position: absolute;
  inset: 0;
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fff;
  opacity: .5;
}

.grain {
  position: absolute;
  inset: -50%;
  opacity: .06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ══ MARCA ══ */
.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -.01em;
}

.brand-small .brand-name {
  font-size: 1.15rem;
}

.brand-mark {
  filter: drop-shadow(0 4px 18px rgba(185, 168, 255, .45));
}

.eyebrow {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--lavender);
  opacity: .9;
}

/* ══ BOTONES BASE ══ */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  padding: .8rem 1.4rem;
  border-radius: var(--r-pill);
  background: var(--grad);
  color: #1a1533;
  font-weight: 700;
  font-size: .92rem;
  letter-spacing: .01em;
  box-shadow: var(--shadow-glow);
  transition: filter .25s var(--ease), box-shadow .25s var(--ease);
}

.primary-btn:hover {
  filter: brightness(1.06);
  box-shadow: 0 14px 50px -10px rgba(169, 150, 255, .75);
}

.primary-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1.25rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--stroke-2);
  background: var(--surface);
  color: var(--text-1);
  font-weight: 600;
  font-size: .9rem;
  transition: background .2s, border-color .2s;
}

.ghost-btn:hover {
  background: var(--surface-2);
  border-color: rgba(255, 255, 255, .22);
}

.danger-btn {
  padding: .75rem 1.35rem;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, #ff8fa3, #ff6b81);
  color: #2a0d14;
  font-weight: 700;
  font-size: .9rem;
  box-shadow: 0 10px 30px -10px rgba(255, 107, 129, .6);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--text-2);
  transition: background .2s, color .2s;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text-1);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow-1);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.panel-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.15rem;
  margin-bottom: 1rem;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  padding: .35rem;
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, .25);
  border: 1px solid var(--stroke);
}

.segmented>button {
  flex: 1 1 auto;
  padding: .6rem 1rem;
  border-radius: var(--r-pill);
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  transition: color .25s, background .25s;
}

.segmented>button:hover {
  color: var(--text-1);
}

.segmented>button.active {
  background: var(--surface-3);
  color: var(--text-1);
  box-shadow: inset 0 0 0 1px var(--stroke-2);
}

.empty-state {
  color: var(--text-3);
  font-size: .9rem;
}

kbd {
  font-family: inherit;
  font-size: .72rem;
  padding: .05rem .4rem;
  border-radius: 6px;
  border: 1px solid var(--stroke-2);
  background: var(--surface);
}

/* ══ BIENVENIDA ══ */
.welcome-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 3rem 1.25rem;
}

.welcome-content {
  max-width: 640px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
}

.welcome-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(2.8rem, 8vw, 5.2rem);
  line-height: 1.02;
  letter-spacing: -.03em;
  font-variation-settings: 'opsz' 144;
}

.welcome-title em {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 300;
  padding-right: .08em;
}

/* SplitText: el degradado se aplica a cada palabra para que sobreviva a la animación */
.welcome-title em .word {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-right: .06em;
}

/* Con animaciones activas, el título espera a GSAP para no "parpadear" */
.js-motion .welcome-title,
.js-motion [data-anim="welcome"] {
  visibility: hidden;
}

.welcome-sub {
  color: var(--text-2);
  font-size: 1.08rem;
  max-width: 30rem;
}

.login-actions {
  margin-top: .6rem;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.8rem;
  border-radius: var(--r-pill);
  background: #fff;
  color: #1f1d2b;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .4), 0 18px 60px -12px rgba(185, 168, 255, .7);
  transition: box-shadow .3s var(--ease);
}

.google-btn:hover {
  box-shadow: 0 0 0 4px rgba(185, 168, 255, .35), 0 24px 70px -10px rgba(185, 168, 255, .9);
}

.google-btn:disabled {
  opacity: .7;
  cursor: progress;
}

.trust-row {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .6rem;
}

.trust-row li {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .45rem .9rem;
  border-radius: var(--r-pill);
  font-size: .8rem;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--stroke);
}

.trust-row svg {
  color: var(--lavender);
}

.welcome-footer {
  margin-top: .6rem;
  font-size: .78rem;
  color: var(--text-3);
  max-width: 28rem;
}

/* ══ LAYOUT APP ══ */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100dvh;
}

/* ══ SIDEBAR ══ */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem 1rem 1rem;
  background: rgba(14, 12, 32, .55);
  border-right: 1px solid var(--stroke);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  min-height: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 .4rem;
}

.sidebar-close {
  display: none;
}

.sidebar-nav {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.nav-indicator {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 44px;
  border-radius: 14px;
  background: var(--grad-soft);
  box-shadow: inset 0 0 0 1px rgba(185, 168, 255, .25);
  opacity: 0;
  pointer-events: none;
}

.nav-item {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: .8rem;
  height: 44px;
  padding: 0 .9rem;
  border-radius: 14px;
  color: var(--text-2);
  font-weight: 600;
  font-size: .92rem;
  text-align: left;
  transition: color .25s;
}

.nav-item:hover {
  color: var(--text-1);
}

.nav-item.active {
  color: var(--text-1);
}

.nav-item.active svg {
  color: var(--lavender);
}

.chat-sessions-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--stroke);
  padding-top: 1rem;
}

.sessions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 .4rem .5rem .9rem;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-3);
}

.add-session-btn {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--stroke);
}

.sessions-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding-right: .2rem;
}

.session-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .5rem .6rem .9rem;
  border-radius: 12px;
  color: var(--text-2);
  font-size: .87rem;
  cursor: pointer;
  transition: background .2s, color .2s;
}

.session-item:hover {
  background: var(--surface);
  color: var(--text-1);
}

.session-item.active {
  background: var(--surface-2);
  color: var(--text-1);
}

.session-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-date {
  display: block;
  font-size: .7rem;
  color: var(--text-3);
  margin-top: .05rem;
}

.quick-starts {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding-left: calc(34px + .85rem);
}

.delete-session {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--text-3);
  opacity: 0;
  transition: opacity .2s, color .2s, background .2s;
}

.session-item:hover .delete-session,
.session-item.active .delete-session,
.delete-session:focus-visible {
  opacity: 1;
}

.delete-session:hover {
  color: var(--rose);
  background: rgba(255, 143, 163, .1);
}

.session-skeleton {
  height: 38px;
  margin: .15rem 0;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  border-top: 1px solid var(--stroke);
  padding-top: 1rem;
}

.memory-btn {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem .9rem;
  border-radius: 14px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--lavender);
  background: rgba(185, 168, 255, .07);
  border: 1px solid rgba(185, 168, 255, .18);
  transition: background .2s;
}

.memory-btn:hover {
  background: rgba(185, 168, 255, .13);
}

.memory-content {
  width: min(620px, 100%);
}

.memory-textarea {
  width: 100%;
  min-height: 300px;
  max-height: 55vh;
  margin-top: 1.1rem;
  padding: 1rem 1.1rem;
  border-radius: 16px;
  border: 1px solid var(--stroke-2);
  background: rgba(0, 0, 0, .25);
  resize: vertical;
  font-size: .9rem;
  line-height: 1.6;
  text-align: left;
  outline: none;
}

.memory-textarea:focus {
  border-color: rgba(185, 168, 255, .5);
}

.memory-status {
  min-height: 1.2em;
  margin-top: .5rem;
  font-size: .8rem !important;
  color: var(--text-3) !important;
}

.memory-actions {
  flex-wrap: wrap;
}

.danger-text {
  color: var(--rose);
}

.help-btn {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem .9rem;
  border-radius: 14px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--peach);
  background: rgba(255, 184, 168, .08);
  border: 1px solid rgba(255, 184, 168, .18);
  transition: background .2s;
}

.help-btn:hover {
  background: rgba(255, 184, 168, .14);
}

.user-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.user-chip {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .7rem;
  min-width: 0;
  padding: .3rem .4rem;
}

.user-avatar,
.user-photo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
}

.user-avatar {
  display: grid;
  place-items: center;
  background: var(--grad);
  color: #1a1533;
  font-weight: 700;
}

.user-photo {
  object-fit: cover;
  box-shadow: 0 0 0 2px rgba(185, 168, 255, .45);
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.user-name-display {
  font-weight: 700;
  font-size: .9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-status {
  font-size: .72rem;
  color: var(--mint);
}

/* ══ MAIN ══ */
.main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.75rem;
  border-bottom: 1px solid var(--stroke);
  background: rgba(11, 10, 26, .35);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.topbar-title {
  flex: 1;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.2rem;
  letter-spacing: -.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.mood-badge {
  font-size: 1.3rem;
  line-height: 1;
}

.mood-badge:empty {
  display: none;
}

.new-session-btn {
  background: var(--surface);
  border: 1px solid var(--stroke);
}

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 38px;
  height: 38px;
  padding: 0 9px;
  border-radius: 12px;
}

.hamburger span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: var(--text-1);
}

.hamburger span:nth-child(2) {
  width: 70%;
}

.section {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.section-content {
  max-width: 920px;
  margin: 0 auto;
  padding: 2.5rem 1.75rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.section-hero {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.hero-media {
  flex-shrink: 0;
  width: 104px;
  height: 104px;
  border-radius: 28px;
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--stroke-2), 0 20px 50px -18px rgba(185, 168, 255, .55);
  transform: rotate(-4deg);
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.section-head-center {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
}

.section-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.1;
  letter-spacing: -.02em;
  margin: .3rem 0 .45rem;
}

.section-title em {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.section-sub {
  color: var(--text-2);
}

/* ══ CHAT ══ */
#section-chat {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#section-chat.hidden {
  display: none !important;
}

.chat-area {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.chat-messages {
  max-width: 780px;
  margin: 0 auto;
  padding: 2rem 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.msg {
  display: flex;
  gap: .85rem;
  align-items: flex-start;
}

.msg>div:last-child {
  min-width: 0;
  max-width: 100%;
}

.user-msg {
  flex-direction: row-reverse;
}

.user-msg>div:last-child {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 82%;
}

.msg-avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .85rem;
  font-weight: 700;
}

.ai-avatar {
  background: radial-gradient(circle at 30% 30%, #e3dbff, #a996ff 55%, #ff9f8f 120%);
  box-shadow: 0 0 0 4px rgba(185, 168, 255, .12), 0 8px 24px -6px rgba(169, 150, 255, .7);
  font-size: 0;
}

.user-avatar-msg {
  background: var(--surface-3);
  color: var(--text-1);
}

.msg-bubble {
  font-size: .98rem;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.ai-bubble {
  color: #e9e5fb;
  padding-top: .2rem;
}

.ai-bubble strong {
  color: #fff;
  font-weight: 700;
}

.ai-bubble em {
  color: var(--peach);
}

.user-bubble {
  padding: .8rem 1.1rem;
  border-radius: 20px 20px 6px 20px;
  background: linear-gradient(135deg, rgba(185, 168, 255, .28), rgba(143, 124, 246, .22));
  border: 1px solid rgba(185, 168, 255, .28);
  color: #fff;
}

.msg-time {
  font-size: .7rem;
  color: var(--text-3);
  margin-top: .35rem;
}

.mood-note {
  align-self: center;
  font-size: .75rem;
  color: var(--text-3);
  padding: .35rem .9rem;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--stroke);
}

.typing-indicator {
  display: inline-flex;
  gap: 5px;
  padding: .7rem 0;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lavender);
  opacity: .4;
}

.chat-input-wrap {
  flex-shrink: 0;
  padding: .75rem 1.5rem 1.1rem;
  background: linear-gradient(180deg, transparent, rgba(11, 10, 26, .85) 40%);
}

.chat-input-box {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: .6rem;
  padding: .55rem .55rem .55rem 1.2rem;
  border-radius: 26px;
  background: rgba(30, 26, 60, .7);
  border: 1px solid var(--stroke-2);
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, .8);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  transition: border-color .25s, box-shadow .25s;
}

.chat-input-box:focus-within {
  border-color: rgba(185, 168, 255, .5);
  box-shadow: 0 0 0 4px rgba(185, 168, 255, .1), 0 20px 60px -20px rgba(0, 0, 0, .8);
}

.chat-input {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  font-size: .98rem;
  line-height: 1.5;
  padding: .55rem 0;
  max-height: 160px;
}

.chat-input::placeholder {
  color: var(--text-3);
}

.send-btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--grad);
  color: #1a1533;
  box-shadow: var(--shadow-glow);
  transition: opacity .2s, filter .2s;
}

.send-btn:hover {
  filter: brightness(1.08);
}

.send-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.input-hint {
  text-align: center;
  font-size: .72rem;
  color: var(--text-3);
  margin-top: .55rem;
}

/* ══ MOOD ══ */
.mood-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .85rem;
}

.mood-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  padding: .7rem .7rem .85rem;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--stroke);
  transition: border-color .25s, background .25s, box-shadow .25s;
}

.mood-btn:hover {
  background: var(--surface-2);
  border-color: var(--stroke-2);
}

.mood-btn.selected {
  border-color: rgba(185, 168, 255, .6);
  background: var(--grad-soft);
  box-shadow: 0 0 0 3px rgba(185, 168, 255, .15), var(--shadow-glow);
}

.mood-gif-small {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 12px;
  background: var(--surface-2);
}

.mood-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-2);
}

.mood-btn.selected .mood-label {
  color: var(--text-1);
}

.mood-suggest {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .9rem 1.2rem;
  padding: 1.1rem 1.3rem;
  border-radius: var(--r-lg);
  background: var(--grad-soft);
  border: 1px solid rgba(185, 168, 255, .3);
}

.mood-suggest p {
  font-family: var(--font-serif);
  font-size: 1.05rem;
}

.mood-suggest-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.mood-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: .6rem;
  align-items: end;
  height: 170px;
}

.mood-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: .4rem;
  height: 100%;
}

.mood-bar-track {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: 46px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .04);
  overflow: hidden;
}

.mood-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--bar-color), rgba(255, 255, 255, .05));
  transform-origin: bottom;
}

.mood-day-emoji {
  font-size: 1rem;
  height: 1.3rem;
}

.mood-day-label {
  font-size: .72rem;
  color: var(--text-3);
  text-transform: capitalize;
}

.mood-day.today .mood-day-label {
  color: var(--lavender);
  font-weight: 700;
}

.mood-week-summary {
  margin-top: 1rem;
  font-size: .88rem;
  color: var(--text-2);
}

.mood-history {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-height: 420px;
  overflow-y: auto;
}

.mood-entry {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .6rem .8rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--stroke);
}

.mood-entry.optimistic {
  opacity: .7;
  border-style: dashed;
}

.mood-entry img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
}

.mood-entry-body {
  flex: 1;
  min-width: 0;
}

.mood-entry-name {
  font-weight: 700;
  font-size: .9rem;
  text-transform: capitalize;
}

.mood-entry-time {
  font-size: .74rem;
  color: var(--text-3);
}

.mood-entry-emoji {
  font-size: 1.3rem;
}

/* ══ RESPIRACIÓN ══ */
.breathe-section {
  align-items: center;
  text-align: center;
}

.breathe-selector {
  max-width: 520px;
  width: 100%;
}

.breathe-desc {
  max-width: 30rem;
  color: var(--text-2);
  font-size: .9rem;
  min-height: 2.8em;
}

.breathe-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: .9rem 1.5rem;
}

.breathe-durations>button {
  flex: 0 0 auto;
}

.switch-row.compact {
  align-items: center;
}

.switch-row.compact .switch {
  margin-top: 0;
}

.breathe-technique:disabled,
.breathe-duration:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.breathe-visual {
  position: relative;
  width: min(340px, 78vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin: 1rem 0;
}

.breathe-halo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(185, 168, 255, .35) 0%, rgba(255, 184, 168, .12) 45%, transparent 70%);
  filter: blur(10px);
}

.breathe-ripple {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  border: 1px solid rgba(185, 168, 255, .3);
}

.breathe-ripple.r2 {
  inset: 4%;
  border-color: rgba(255, 184, 168, .18);
}

.breathe-ring {
  position: relative;
  width: 58%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .55), transparent 40%),
    radial-gradient(circle at 50% 50%, #b9a8ff 0%, #8f7cf6 55%, #6c5bd6 100%);
  box-shadow:
    inset 0 -14px 40px rgba(60, 40, 140, .55),
    0 30px 80px -20px rgba(143, 124, 246, .85);
}

.breathe-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #1a1533;
}

.breathe-word {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 500;
}

.breathe-count {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.breathe-cycles {
  color: var(--text-2);
  font-size: .9rem;
}

.breathe-cycles strong {
  color: var(--text-1);
}

/* ══ DIARIO ══ */
.prompt-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: .7rem;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.prompt-chip {
  padding: .5rem .95rem;
  border-radius: var(--r-pill);
  font-size: .82rem;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--stroke);
  transition: color .2s, border-color .2s, background .2s;
}

.prompt-chip:hover {
  color: var(--text-1);
  border-color: rgba(185, 168, 255, .45);
  background: var(--grad-soft);
}

.journal-entry-wrap {
  display: flex;
  flex-direction: column;
  gap: .8rem;
}

.journal-date {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--lavender);
}

.journal-date::first-letter {
  text-transform: uppercase;
}

.journal-textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-serif);
  font-size: 1.12rem;
  line-height: 1.8;
  color: var(--text-1);
  background-image: repeating-linear-gradient(transparent 0 calc(1.8em - 1px), rgba(255, 255, 255, .05) calc(1.8em - 1px) 1.8em);
  background-attachment: local;
}

.journal-textarea::placeholder {
  color: var(--text-3);
  font-style: italic;
}

.journal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.journal-lock {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  color: var(--text-3);
}

.journal-buttons {
  display: flex;
  gap: .5rem;
}

#journal-list {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.journal-entry-item {
  padding: 1.15rem 1.3rem;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-left: 3px solid rgba(185, 168, 255, .55);
}

.journal-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .5rem;
}

.journal-entry-item-date {
  font-size: .78rem;
  font-weight: 600;
  color: var(--lavender);
}

.journal-entry-actions {
  display: flex;
  gap: .25rem;
}

.journal-action-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: var(--text-3);
  transition: color .2s, background .2s;
}

.journal-action-btn.edit:hover {
  color: var(--lavender);
  background: rgba(185, 168, 255, .1);
}

.journal-action-btn.delete:hover {
  color: var(--rose);
  background: rgba(255, 143, 163, .1);
}

.journal-list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem 1rem;
}

.journal-search {
  flex: 0 1 260px;
  padding: .55rem .9rem;
  border-radius: 999px;
  border: 1px solid var(--stroke-2);
  background: var(--surface);
  font-size: .85rem;
  outline: none;
}

.journal-search:focus {
  border-color: rgba(185, 168, 255, .5);
}

.journal-action-btn.reflect:hover {
  color: var(--peach);
  background: rgba(255, 184, 168, .1);
}

.journal-reflection {
  margin-top: .9rem;
  padding: .9rem 1rem;
  border-radius: 14px;
  background: var(--grad-soft);
  border: 1px solid rgba(185, 168, 255, .25);
  font-size: .93rem;
  line-height: 1.65;
  color: #ece8fb;
}

.journal-reflection strong {
  display: block;
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--lavender);
  margin-bottom: .3rem;
}

.journal-reflection.loading {
  color: var(--text-3);
  font-style: italic;
}

mark {
  background: rgba(255, 213, 158, .25);
  color: inherit;
  border-radius: 4px;
  padding: 0 .1em;
}

.journal-entry-text-full {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  line-height: 1.75;
  color: #e6e2f7;
  overflow-wrap: anywhere;
}

/* ══ CUENTOS ══ */
.stories-generator {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.story-options {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.option-group label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: .6rem;
}

.generate-story-btn {
  align-self: flex-start;
}

.story-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2.5rem 0;
}

.story-loading[hidden],
.story-display[hidden] {
  display: none;
}

.loading-orb {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, #b9a8ff 45%, #ffb8a8 100%);
  box-shadow: 0 0 40px rgba(185, 168, 255, .7);
}

.loading-text {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--text-2);
}

.story-display {
  padding-top: 1.5rem;
  border-top: 1px solid var(--stroke);
}

.story-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(1.6rem, 3.6vw, 2.2rem);
  line-height: 1.15;
  margin-bottom: 1.25rem;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.story-text {
  font-family: var(--font-serif);
  font-size: 1.14rem;
  line-height: 1.9;
  color: #e9e5fb;
}

.story-text p {
  margin: 0 0 1.1em;
  padding: .15em .6em;
  margin-left: -.6em;
  border-radius: 12px;
  transition: background .6s, color .6s, opacity .6s;
}

/* Mientras se lee, el párrafo actual resalta y los demás se atenúan */
.story-text.reading p {
  opacity: .45;
}

.story-text.reading p.speaking {
  opacity: 1;
  color: #fff;
  background: linear-gradient(90deg, rgba(185, 168, 255, .12), transparent 80%);
}

/* Controles fijos al fondo del panel mientras el cuento es largo */
.story-dock {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.5rem -1.4rem -1.4rem;
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--stroke);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  background: rgba(20, 17, 42, .92);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.story-settings {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1.25rem;
}

/* Interruptor "Inspirado en ti" */
.switch-row {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  cursor: pointer;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  flex-shrink: 0;
  position: relative;
  width: 44px;
  height: 26px;
  margin-top: .1rem;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--stroke-2);
  transition: background .25s;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform .3s var(--ease);
}

.switch-row input:checked+.switch {
  background: var(--grad);
}

.switch-row input:checked+.switch::after {
  transform: translateX(18px);
}

.switch-row input:focus-visible+.switch {
  outline: 2px solid var(--lavender);
  outline-offset: 3px;
}

.switch-text {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
  font-size: .92rem;
}

.switch-text small {
  color: var(--text-3);
  font-size: .8rem;
}

/* Modo noche */
.night-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 2rem;
  background: #020106;
  text-align: center;
  cursor: default;
}

.night-title {
  font-family: var(--font-serif);
  font-style: italic;
  color: rgba(185, 168, 255, .45);
  font-size: 1rem;
}

.night-text {
  max-width: 34rem;
  font-family: var(--font-serif);
  font-size: clamp(1.2rem, 2.6vw, 1.6rem);
  line-height: 1.8;
  color: rgba(233, 229, 251, .62);
}

.night-actions {
  display: flex;
  gap: .75rem;
}

.night-btn {
  padding: .6rem 1.1rem;
  border-radius: 999px;
  font-size: .82rem;
  color: rgba(233, 229, 251, .45);
  border: 1px solid rgba(255, 255, 255, .08);
  transition: color .3s, border-color .3s;
}

.night-btn:hover {
  color: rgba(233, 229, 251, .8);
  border-color: rgba(255, 255, 255, .2);
}

.voice-selector {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .85rem;
  color: var(--text-2);
}

.voice-selector select {
  max-width: 240px;
  padding: .55rem .8rem;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--stroke-2);
  font-size: .85rem;
}

.voice-selector option {
  background: var(--bg-2);
}

.story-controls {
  display: flex;
  gap: .5rem;
}

/* ══ MODALES ══ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(6, 5, 16, .65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  width: min(420px, 100%);
  padding: 2rem 1.75rem 1.6rem;
  border-radius: var(--r-xl);
  text-align: center;
  background: linear-gradient(180deg, rgba(36, 31, 72, .95), rgba(20, 17, 42, .97));
  border: 1px solid var(--stroke-2);
  box-shadow: 0 40px 120px -30px rgba(0, 0, 0, .9);
}

.modal-content h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.4rem;
  margin: .9rem 0 .5rem;
}

.modal-content p {
  color: var(--text-2);
  font-size: .92rem;
}

.modal-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: var(--lavender);
  background: var(--grad-soft);
  box-shadow: inset 0 0 0 1px rgba(185, 168, 255, .3);
}

.modal-icon.danger {
  color: var(--rose);
  background: rgba(255, 143, 163, .1);
  box-shadow: inset 0 0 0 1px rgba(255, 143, 163, .3);
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: .6rem;
  margin-top: 1.5rem;
}

.modal-close {
  position: absolute;
  top: .8rem;
  right: .8rem;
}

.help-content {
  width: min(460px, 100%);
}

.help-lines {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  margin: 1.3rem 0 1rem;
  text-align: left;
}

.help-line {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .85rem 1rem;
  border-radius: 16px;
  text-decoration: none;
  color: var(--text-1);
  background: var(--surface);
  border: 1px solid var(--stroke-2);
  transition: background .2s, border-color .2s;
}

.help-line:hover {
  background: var(--surface-2);
  border-color: rgba(185, 168, 255, .45);
}

.help-line svg {
  color: var(--mint);
  flex-shrink: 0;
}

.help-line span {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.help-line small {
  color: var(--text-2);
  font-size: .8rem;
}

.help-line.urgent svg {
  color: var(--rose);
}

.help-note {
  font-size: .8rem !important;
  color: var(--text-3) !important;
}

/* ══ TOASTS ══ */
.toast-stack {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  pointer-events: none;
}

.toast {
  max-width: min(440px, 90vw);
  padding: .8rem 1.2rem;
  border-radius: 16px;
  font-size: .88rem;
  background: rgba(36, 31, 72, .95);
  border: 1px solid var(--stroke-2);
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, .9);
  pointer-events: auto;
}

.toast.error {
  border-color: rgba(255, 143, 163, .4);
}

/* ══ RESPONSIVE ══ */
@media (max-width: 900px) {
  .mood-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 40;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    background: rgba(14, 12, 32, .96);
    transform: translateX(-105%);
    visibility: hidden;
  }

  .sidebar.open {
    visibility: visible;
  }

  .sidebar-close {
    display: inline-grid;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(6, 5, 16, .6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  .hamburger {
    display: flex;
  }

  .topbar {
    padding: 0 1rem;
  }

  .section-content {
    padding: 1.75rem 1.1rem 3rem;
  }

  .section-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .hero-media {
    width: 80px;
    height: 80px;
    border-radius: 22px;
  }

  .mood-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: .6rem;
  }

  .chat-messages {
    padding: 1.25rem 1rem .5rem;
  }

  .chat-input-wrap {
    padding: .5rem .75rem calc(.75rem + env(safe-area-inset-bottom));
  }

  .input-hint {
    display: none;
  }

  .user-msg>div:last-child {
    max-width: 88%;
  }

  .segmented>button {
    padding: .55rem .75rem;
    font-size: .8rem;
  }
}

@media (max-width: 420px) {
  .mood-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Movimiento reducido: GSAP también se desactiva desde app.js */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
