/* ==============================================================================
 * STUDIO GHIBLI ANIME MEADOW & DOKODEMO MAGIC DOOR ENTRANCE (MINDLOOP 360)
 * Authentic Hayao Miyazaki / Kazuo Oga Watercolor & Feature Film Aesthetic
 * ============================================================================== */

/* 1. SCENE CONTAINER: FULLSCREEN MASTER GHIBLI MEADOW */
#scene-meadow {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  overflow: hidden;
  background: radial-gradient(circle at 72% 18%, rgba(254, 240, 138, 0.32) 0%, rgba(254, 240, 138, 0) 45%),
              url('../assets/ghibli/meadow_bg.jpg') center bottom / cover no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  transition: opacity 0.85s ease, transform 0.95s cubic-bezier(0.16, 1, 0.3, 1), filter 0.85s ease;
  pointer-events: auto;
  user-select: none;
}

#scene-meadow.portal-warping {
  transform: scale(8.5);
  filter: brightness(1.7) blur(4px);
  opacity: 0;
  pointer-events: none;
}

#scene-meadow.hidden {
  display: none !important;
}

/* ==============================================================================
 * CINEMATIC DRIFTING CLOUDS SYSTEM (STUDIO GHIBLI SKY FILM SHOT)
 * Authentic Hayao Miyazaki / Kazuo Oga Multi-Layer Parallax Drift
 * ============================================================================== */
.meadow-sky-stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 60%;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 1) 60%, rgba(0, 0, 0, 0) 100%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 1) 60%, rgba(0, 0, 0, 0) 100%);
}

.cloud-drift-layer {
  position: absolute;
  top: 0;
  left: 0;
  background-repeat: no-repeat;
  background-size: contain;
  pointer-events: none;
  will-change: transform;
}

/* Layer 1: Distant High Wisps (High-altitude, delicate, very slow) */
.layer-wisps {
  height: 280px;
  width: 650px;
  background-image: url('../assets/ghibli/ghibli_cloud_whisps.png');
  opacity: 0.72;
  filter: drop-shadow(0 10px 25px rgba(125, 211, 252, 0.22));
}

.cloud-wisp-1 {
  top: 2%;
  animation: cloudDriftSlow 110s linear infinite;
}

.cloud-wisp-2 {
  top: 8%;
  animation: cloudDriftSlow 110s linear infinite;
  animation-delay: -55s;
}

/* Layer 2: Main Majestic Cumulus (Ghibli Signature Summer Sky) */
.layer-grand {
  height: 480px;
  width: 950px;
  background-image: url('../assets/ghibli/ghibli_cloud_grand.png');
  opacity: 0.92;
  filter: drop-shadow(0 16px 40px rgba(30, 58, 138, 0.16));
}

.cloud-grand-1 {
  top: -4%;
  animation: cloudDriftMedium 75s linear infinite;
}

.cloud-grand-2 {
  top: 2%;
  animation: cloudDriftMedium 75s linear infinite;
  animation-delay: -37.5s;
}

/* Layer 3: Floating Mid-Altitude Cumulus Billows */
.layer-medium {
  height: 380px;
  width: 620px;
  background-image: url('../assets/ghibli/ghibli_cloud_medium.png');
  opacity: 0.85;
  filter: drop-shadow(0 12px 30px rgba(30, 58, 138, 0.14));
}

.cloud-med-1 {
  top: 14%;
  animation: cloudDriftBreeze 52s linear infinite;
}

.cloud-med-2 {
  top: 10%;
  animation: cloudDriftBreeze 52s linear infinite;
  animation-delay: -26s;
}

/* Cinematic horizontal drift with gentle vertical undulating breathing */
@keyframes cloudDriftSlow {
  0% {
    transform: translate3d(-700px, 0, 0) scale(0.95);
  }
  50% {
    transform: translate3d(calc(50vw - 350px), -12px, 0) scale(1);
  }
  100% {
    transform: translate3d(calc(100vw + 100px), 0, 0) scale(0.95);
  }
}

@keyframes cloudDriftMedium {
  0% {
    transform: translate3d(-1050px, 0, 0) scale(1);
  }
  30% {
    transform: translate3d(calc(30vw - 300px), -8px, 0) scale(1.03);
  }
  70% {
    transform: translate3d(calc(70vw - 300px), 6px, 0) scale(0.98);
  }
  100% {
    transform: translate3d(calc(100vw + 200px), 0, 0) scale(1);
  }
}

@keyframes cloudDriftBreeze {
  0% {
    transform: translate3d(-700px, 0, 0) scale(0.98);
  }
  50% {
    transform: translate3d(calc(50vw - 300px), -15px, 0) scale(1.04);
  }
  100% {
    transform: translate3d(calc(100vw + 150px), 0, 0) scale(0.98);
  }
}

/* Atmospheric Floating Dandelion Seeds, Petals & Wind Motifs */
.meadow-wind-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}

/* Cinematic Wind Streaks (Anime Breeze lines) */
.wind-breeze-streak {
  position: absolute;
  height: 2px;
  border-radius: 9999px;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.55) 40%, rgba(255, 255, 255, 0.85) 70%, transparent 100%);
  pointer-events: none;
  filter: blur(0.5px);
  will-change: transform;
}

.streak-1 {
  top: 32%;
  width: 140px;
  animation: windStreakDrift 8s cubic-bezier(0.25, 1, 0.5, 1) infinite;
}

.streak-2 {
  top: 58%;
  width: 220px;
  animation: windStreakDrift 11s cubic-bezier(0.25, 1, 0.5, 1) infinite 3.5s;
}

@keyframes windStreakDrift {
  0% {
    transform: translate3d(-250px, 0, 0) skewX(-20deg);
    opacity: 0;
  }
  20% {
    opacity: 0.85;
  }
  75% {
    opacity: 0.7;
  }
  100% {
    transform: translate3d(calc(100vw + 200px), -40px, 0) skewX(-20deg);
    opacity: 0;
  }
}

/* Drifting Wildflower Petals */
.flower-petal {
  position: absolute;
  width: 8px;
  height: 12px;
  border-radius: 50% 50% 50% 0;
  background: linear-gradient(135deg, #fef08a 0%, #fbbf24 100%);
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

.petal-1 { top: 40%; left: -20px; animation: petalDrift 13s ease-in-out infinite 2s; }
.petal-2 { top: 62%; left: -20px; animation: petalDrift 17s ease-in-out infinite 6s; }

@keyframes petalDrift {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  15% { opacity: 0.85; }
  85% { opacity: 0.8; }
  100% { transform: translate(calc(100vw + 40px), -45px) rotate(420deg); opacity: 0; }
}

.dandelion-seed {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.9);
  pointer-events: none;
  will-change: transform;
}

.seed-1 { top: 35%; left: -20px; animation: seedDrift 14s linear infinite; }
.seed-2 { top: 55%; left: -20px; animation: seedDrift 18s linear infinite 3s; }
.seed-3 { top: 70%; left: -20px; animation: seedDrift 12s linear infinite 7s; }
.seed-4 { top: 45%; left: -20px; animation: seedDrift 16s linear infinite 5s; }
.seed-5 { top: 25%; left: -20px; animation: seedDrift 20s linear infinite 10s; }

@keyframes seedDrift {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  15% { opacity: 0.9; }
  85% { opacity: 0.8; }
  100% { transform: translate(calc(100vw + 60px), -60px) rotate(360deg); opacity: 0; }
}

/* Sunbeam God-Rays Shimmer */
.meadow-sunbeams {
  position: absolute;
  top: 0;
  right: 15%;
  width: 500px;
  height: 650px;
  background: radial-gradient(ellipse at 80% 0%, rgba(254, 240, 138, 0.25) 0%, rgba(254, 240, 138, 0.08) 45%, transparent 70%);
  pointer-events: none;
  mix-blend-mode: screen;
  animation: sunbeamPulse 7s ease-in-out infinite alternate;
}

@keyframes sunbeamPulse {
  0% { opacity: 0.75; transform: scale(1); }
  100% { opacity: 1; transform: scale(1.06); }
}

/* 2. THE DORAEMON DOKODEMO MAGIC DOOR (STUDIO GHIBLI EDITION) */
.doraemon-door-stage {
  position: absolute;
  bottom: 6%;
  left: 50%;
  transform: translateX(-50%);
  width: 290px;
  height: 388px;
  perspective: 1200px;
  z-index: 10;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  filter: drop-shadow(0 14px 28px rgba(18, 55, 25, 0.45));
  transition: transform 0.25s ease;
}

.doraemon-door-stage:hover {
  transform: translateX(-50%) translateY(-3px);
}

/* Ground Contact Shadow (Soft Gouache Cast Shadow on Meadow Grass) */
.door-ground-shadow {
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-52%);
  width: 310px;
  height: 38px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(10, 36, 14, 0.72) 0%, rgba(10, 36, 14, 0.4) 45%, transparent 75%);
  filter: blur(5px);
  pointer-events: none;
  z-index: 1;
}

/* Door Base Overgrowth (Wild Grass & Daisy Tufts wrapping base posts) */
.door-base-overgrowth {
  position: absolute;
  bottom: -6px;
  left: -8px;
  right: -8px;
  height: 34px;
  background: url('../assets/ghibli/meadow_fg_grass.png') center bottom / 100% 100% no-repeat;
  pointer-events: none;
  z-index: 6;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}
  filter: drop-shadow(0 14px 28px rgba(18, 55, 25, 0.45));
  transition: transform 0.25s ease;
}

.doraemon-door-stage:hover {
  transform: translateX(-50%) translateY(-3px);
}

/* Cosmic Viewport behind the door opening */
.door-cosmic-viewport {
  position: absolute;
  top: 15%;
  left: 29%;
  width: 41%;
  height: 66%;
  background: radial-gradient(circle at center, #1e1b4b 0%, #090d24 60%, #02040d 100%);
  overflow: hidden;
  border-radius: 2px;
  z-index: 1;
}

.door-vortex-portal {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 260px;
  height: 260px;
  margin-top: -130px;
  margin-left: -130px;
  background: conic-gradient(from 0deg, #38bdf8, #818cf8, #c084fc, #f43f5e, #fbbf24, #38bdf8);
  border-radius: 50%;
  filter: blur(20px);
  opacity: 0.72;
  animation: vortexSpin 4s linear infinite;
  mix-blend-mode: screen;
}

@keyframes vortexSpin {
  0% { transform: rotate(0deg) scale(0.9); }
  50% { transform: rotate(180deg) scale(1.15); }
  100% { transform: rotate(360deg) scale(0.9); }
}

/* Door Outer Frame & Base (Hand-painted Ghibli Artwork with ivy & daisies) */
.door-frame-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  z-index: 3;
}

/* Door Leaf (The swinging wooden door with brass knob) */
.dokodemo-leaf-wrap {
  position: absolute;
  top: 15%;
  left: 29%;
  width: 41%;
  height: 66%;
  transform-origin: left center;
  transition: transform 1.25s cubic-bezier(0.25, 1, 0.35, 1);
  z-index: 2;
  backface-visibility: hidden;
}

.door-leaf-img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
}

/* Door Open State */
.dokodemo-frame.opened .dokodemo-leaf-wrap {
  transform: perspective(1000px) rotateY(-112deg);
}

/* 3-Second Idle Animated Pointing Arrow (Chỉ vào cánh cửa khi người dùng chưa nhấn) */
.door-hint-arrow {
  position: absolute;
  top: -62px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  pointer-events: none;
  z-index: 25;
  opacity: 0;
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.door-hint-arrow.active {
  opacity: 1;
  animation: doorHintBounceShake 1.8s ease-in-out infinite;
}

.hint-arrow-pointer {
  font-size: 26px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
  display: block;
  line-height: 1;
}

.hint-arrow-badge {
  background: rgba(255, 255, 255, 0.94);
  color: #b45309;
  font-family: var(--font-body, system-ui);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.3px;
  padding: 4px 12px;
  border-radius: 9999px;
  box-shadow: 0 6px 18px rgba(217, 119, 6, 0.22), 0 2px 6px rgba(0, 0, 0, 0.08);
  border: 1px solid #fcd34d;
  white-space: nowrap;
}

/* Bouncing & Subtle Vibration / Shaking (Rung rung & nhún nhảy) */
@keyframes doorHintBounceShake {
  0% {
    transform: translateX(-50%) translateY(0) rotate(0deg);
  }
  20% {
    transform: translateX(-50%) translateY(-10px) rotate(-2deg);
  }
  30% {
    transform: translateX(-50%) translateY(-10px) rotate(2deg);
  }
  40% {
    transform: translateX(-50%) translateY(-10px) rotate(-1.5deg);
  }
  50% {
    transform: translateX(-50%) translateY(-10px) rotate(1deg);
  }
  65% {
    transform: translateX(-50%) translateY(0) rotate(0deg);
  }
  100% {
    transform: translateX(-50%) translateY(0) rotate(0deg);
  }
}

/* Knocking Hand Animation */
.knocking-hand {
  position: absolute;
  top: 48%;
  right: -55px;
  font-size: 46px;
  transform-origin: center bottom;
  opacity: 0;
  pointer-events: none;
  z-index: 25;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.3));
}

.knocking-hand.knocking {
  animation: animeKnock 0.75s ease-in-out forwards;
}

@keyframes animeKnock {
  0% { opacity: 0; transform: translateX(40px) scale(0.8) rotate(15deg); }
  25% { opacity: 1; transform: translateX(0) scale(1) rotate(0deg); }
  45% { transform: translateX(-14px) rotate(-15deg); }
  60% { transform: translateX(-4px) rotate(0deg); }
  80% { transform: translateX(-16px) rotate(-15deg); }
  100% { opacity: 0; transform: translateX(20px) scale(0.9); }
}

/* Knock Shockwave Ripple */
.knock-shockwave {
  position: absolute;
  top: 50%;
  right: 35px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid #fbbf24;
  opacity: 0;
  pointer-events: none;
  z-index: 22;
}

.knock-shockwave.active {
  animation: shockwaveExpand 0.5s ease-out forwards;
}

@keyframes shockwaveExpand {
  0% { transform: scale(0.5); opacity: 1; border-color: #fef08a; }
  100% { transform: scale(3.8); opacity: 0; border-color: #f59e0b; }
}

/* 3. STUDIO GHIBLI REALISTIC FELINE QUADRUPED CANVAS & FOREGROUND DEPTH */
.meadow-cats-canvas {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 260px;
  pointer-events: auto;
  cursor: pointer;
  z-index: 12;
}

/* Foreground Swaying Grass & Flower Layer (Paws run through the grass blades) */
.meadow-fg-grass-layer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 70px;
  background: url('../assets/ghibli/meadow_fg_grass.png') center bottom / 100% 100% no-repeat;
  pointer-events: none;
  z-index: 18;
  transform-origin: bottom center;
  animation: meadowWindSway 5s ease-in-out infinite alternate;
}

@keyframes meadowWindSway {
  0% {
    transform: skewX(0deg) scaleY(1);
  }
  33% {
    transform: skewX(1.5deg) scaleY(0.995);
  }
  66% {
    transform: skewX(-1.2deg) scaleY(1.005);
  }
  100% {
    transform: skewX(0.8deg) scaleY(1);
  }
}

/* Fallback & Helper Classes for Track / Actors */
.meadow-cats-track {
  position: absolute;
  bottom: 2%;
  left: 0;
  width: 100%;
  height: 160px;
  pointer-events: none;
  z-index: 15;
}

.ghibli-cat-actor {
  position: absolute;
  bottom: 0;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.3s ease;
  will-change: transform, left;
  filter: drop-shadow(0 8px 16px rgba(15, 60, 25, 0.4));
}

.cat-sprite-wrap {
  display: block;
  transform-origin: 35% 85%;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ghibli-cat-actor img {
  height: 120px;
  width: auto;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* Cat speech bubble for purrs & reactions */
.cat-purr-bubble {
  position: absolute;
  top: -46px;
  left: 50%;
  transform: translateX(-50%) scale(0);
  background: rgba(255, 255, 255, 0.96);
  color: #1e293b;
  font-family: var(--font-body, system-ui);
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 16px;
  border-radius: 16px;
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
  border: 1.5px solid #fbbf24;
  pointer-events: none;
  z-index: 35;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  opacity: 0;
}

.cat-purr-bubble.show {
  transform: translateX(-50%) scale(1);
  opacity: 1;
}

.cat-purr-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: #ffffff transparent transparent transparent;
}

/* Petting Hand Stroke Cursor Animation */
.petting-hand-stroke {
  position: absolute;
  top: -24px;
  left: 20px;
  font-size: 32px;
  opacity: 0;
  pointer-events: none;
  z-index: 30;
}

.ghibli-cat-actor.being-petted .petting-hand-stroke {
  animation: handStrokeAcross 1.2s ease-in-out infinite;
}

@keyframes handStrokeAcross {
  0% { opacity: 0; transform: translate(10px, 0px) rotate(-10deg); }
  20% { opacity: 1; transform: translate(25px, 8px) rotate(0deg); }
  70% { opacity: 1; transform: translate(75px, -8px) rotate(18deg); }
  100% { opacity: 0; transform: translate(95px, -18px) rotate(25deg); }
}

/* ELEVATOR BUTT POSE (CHỔNG MÔNG LÊN KHI VUỐT VE) */
.ghibli-cat-actor.elevator-butt .cat-sprite-wrap {
  animation: ghibliCatElevatorButt 0.75s ease-in-out infinite alternate !important;
}

@keyframes ghibliCatElevatorButt {
  0% { transform: translateY(0) rotate(0deg) scale(1); }
  100% { transform: translateY(-16px) rotate(-14deg) scale(1.06); }
}

/* Floating Love Hearts on Petting */
.purr-heart {
  position: absolute;
  font-size: 20px;
  color: #f43f5e;
  pointer-events: none;
  animation: floatUpHeart 1.2s ease-out forwards;
  z-index: 40;
}

@keyframes floatUpHeart {
  0% { opacity: 1; transform: translateY(0) scale(0.6); }
  100% { opacity: 0; transform: translateY(-50px) scale(1.3) rotate(20deg); }
}

/* Return to Meadow Button in Header / Corner */
.btn-return-meadow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #4ade80;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  backdrop-filter: blur(8px);
}

.btn-return-meadow:hover {
  background: rgba(34, 197, 94, 0.28);
  border-color: #4ade80;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.35);
}

/* ==============================================================================
 * SCENE 2: COSMOS & RIGHT-SIDE INTERACTIVE PANEL
 * ============================================================================== */

/* The Right-Side Interaction Glass Panel */
.astra-interaction-panel {
  position: absolute;
  top: 50%;
  right: clamp(20px, 4vw, 48px);
  transform: translateY(-50%);
  width: min(680px, 58vw);
  max-height: calc(100vh - 100px);
  z-index: 15;
  display: flex;
  flex-direction: column;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

/* Sub-panels inside Astra Interaction Panel */
.subpanel-view {
  display: none;
  flex-direction: column;
  width: 100%;
  animation: panelFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.subpanel-view.active {
  display: flex;
}

@keyframes panelFadeIn {
  0% { opacity: 0; transform: translateY(12px) scale(0.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Panel Header with Back Button */
.panel-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.btn-back-mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9999px;
  color: #94a3b8;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-back-mode:hover {
  background: rgba(56, 189, 248, 0.18);
  border-color: #38bdf8;
  color: #ffffff;
}

.panel-header-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 4. CONVERSATIONAL TỬ VI CHAT INTERFACE */
.tuvi-chat-card {
  display: flex;
  flex-direction: column;
  height: clamp(420px, 68vh, 560px);
  background: linear-gradient(145deg, rgba(10, 16, 36, 0.94) 0%, rgba(6, 10, 24, 0.96) 100%);
  border: 1.5px solid rgba(56, 189, 248, 0.35);
  border-radius: 22px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.75), 0 0 32px rgba(56, 189, 248, 0.15);
  backdrop-filter: blur(24px);
  overflow: hidden;
}

.tuvi-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(14, 23, 48, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-partner-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-partner-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle, #f59e0b 0%, #ea580c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.chat-partner-text {
  display: flex;
  flex-direction: column;
}

.chat-partner-name {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
}

.chat-partner-role {
  font-size: 10.5px;
  color: #38bdf8;
}

/* Chat Messages Feed */
.tuvi-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.tuvi-chat-messages::-webkit-scrollbar {
  width: 5px;
}

.tuvi-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.25);
  border-radius: 10px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  animation: msgSlideIn 0.3s ease-out;
}

@keyframes msgSlideIn {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

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

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

.msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.55;
}

.chat-msg.astra .msg-bubble {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.28);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.chat-msg.astra .msg-bubble strong {
  color: #f59e0b;
}

.chat-msg.user .msg-bubble {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3);
}

/* Quick Smart Birth Intake Form in Chat */
.chat-intake-card {
  background: rgba(11, 19, 43, 0.9);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 14px;
  padding: 12px 14px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.intake-title {
  font-size: 11px;
  font-weight: 700;
  color: #fbbf24;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.intake-inputs-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 8px;
}

.intake-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.intake-field label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
}

.intake-field input, .intake-field select {
  background: rgba(2, 6, 23, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11.5px;
  outline: none;
}

.intake-field input:focus, .intake-field select:focus {
  border-color: #38bdf8;
}

.btn-submit-intake {
  align-self: flex-end;
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 6px 16px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-submit-intake:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* Chat Input Bar at Bottom */
.tuvi-chat-footer {
  padding: 10px 14px;
  background: rgba(14, 23, 48, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-input-text {
  flex: 1;
  background: rgba(2, 6, 23, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9999px;
  padding: 9px 16px;
  color: #ffffff;
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.2s ease;
}

.chat-input-text:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.btn-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.btn-chat-send:hover {
  transform: scale(1.08);
}

/* 5. APIE COGNITIVE MODULES SELECTION PANEL */
.apie-modules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.apie-module-card {
  background: linear-gradient(145deg, rgba(14, 20, 38, 0.92) 0%, rgba(9, 14, 28, 0.88) 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 12px 14px;
  color: #ffffff;
  cursor: pointer;
  text-align: left;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 125px;
  position: relative;
  overflow: hidden;
}

.apie-module-card:hover {
  transform: translateY(-3px);
  border-color: var(--mod-accent, #38bdf8);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), 0 0 20px var(--mod-glow, rgba(56, 189, 248, 0.2));
}

.apie-module-card.personality { --mod-accent: #c084fc; --mod-glow: rgba(192, 132, 252, 0.3); }
.apie-module-card.aq { --mod-accent: #f87171; --mod-glow: rgba(248, 113, 113, 0.3); }
.apie-module-card.eq { --mod-accent: #34d399; --mod-glow: rgba(52, 211, 153, 0.3); }
.apie-module-card.iq { --mod-accent: #38bdf8; --mod-glow: rgba(56, 189, 248, 0.3); }

.mod-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.mod-letter-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
}

.mod-icon {
  font-size: 20px;
}

.mod-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 3px;
}

.mod-desc {
  font-size: 11px;
  color: rgba(226, 232, 240, 0.72);
  line-height: 1.35;
  margin-bottom: 8px;
}

.mod-action {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--mod-accent, #38bdf8);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Astra Bubble Left Orientation */
.astra-floating-bubble.left-anchored {
  --bubble-tx: -40%;
  transform-origin: bottom 40%;
}
.astra-floating-bubble.left-anchored .bubble-tail {
  right: auto;
  left: calc(40% - 11px);
  transform: scaleX(-1);
}


/* ==========================================================================
   SMART TỬ VI CHAT WIZARD STYLES (Astra Conversational Intake)
   ========================================================================== */
.chat-choice-chip {
  background: rgba(30, 41, 59, 0.85);
  color: #f8fafc;
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-choice-chip:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.25);
}

.dual-chart-card {
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.dual-chart-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

#intake-smart-helpers a:hover {
  text-decoration: underline !important;
  filter: brightness(1.2);
}
