* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: #000000;
  color: white;
  font-family: 'Montserrat', sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  /* Centered vertically */
  padding: 0;
  /* Removed padding to fit viewport exactly */
  height: 100vh;
  /* dynamic viewport height for mobile */
  height: 100dvh;
  overflow: hidden;
  /* Prevent page scrolling */
}

#bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: -2;
  pointer-events: none;
  opacity: 0.25;
  /* Adjusted as requested */
  filter: blur(0.5px);
  /* Sharpened slightly */
}

.bg-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: radial-gradient(circle, rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0.6) 100%);
  z-index: -1;
  pointer-events: none;
}

/* Energy Sphere / Nebula Animation (Matching User Image) */
.nebula-glow {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 550px;
  height: 550px;
  background: radial-gradient(circle,
      rgba(0, 255, 170, 0.4) 0%,
      rgba(0, 180, 255, 0.2) 30%,
      rgba(0, 255, 120, 0.1) 50%,
      transparent 75%);
  filter: blur(80px);
  border-radius: 50%;
  z-index: 1;
  animation: energyMorph 12s infinite alternate ease-in-out;
  pointer-events: none;
  mix-blend-mode: screen;
}

.nebula-glow::before {
  content: '';
  position: absolute;
  top: 15%;
  left: 15%;
  width: 70%;
  height: 70%;
  background: radial-gradient(circle,
      rgba(255, 255, 255, 0.15) 0%,
      rgba(0, 255, 180, 0.25) 40%,
      transparent 70%);
  filter: blur(40px);
  border-radius: 50%;
  animation: corePulse 5s infinite alternate ease-in-out;
}

@keyframes energyMorph {
  0% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    opacity: 0.8;
  }

  50% {
    transform: translate(-55%, -45%) scale(1.1) rotate(15deg);
    border-radius: 40% 60% 70% 30% / 50% 60% 30% 50%;
    opacity: 1;
  }

  100% {
    transform: translate(-45%, -55%) scale(0.9) rotate(-15deg);
    border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    opacity: 0.8;
  }
}

@keyframes corePulse {
  0% {
    transform: scale(0.8) rotate(0deg);
    border-radius: 50% 50% 50% 50%;
    opacity: 0.4;
  }

  100% {
    transform: scale(1.2) rotate(180deg);
    border-radius: 30% 70% 50% 50%;
    opacity: 0.8;
  }
}

.chat-wrapper {
  max-width: 900px;
  width: 100%;
  text-align: center;
}

.chat-title {
  color: #00ffaa;
  font-size: 2.8rem;
  margin-bottom: 10px;
  text-shadow: 0 0 20px rgba(0, 255, 170, 0.4);
}

.chat-subtitle {
  font-size: 1.1rem;
  color: #cccccc;
  margin-bottom: 30px;
}

/* FIXED: .chat-box display property from 'fixed' (invalid) to 'flex' */
.chat-box {
  display: flex;
  flex-direction: column;
  height: clamp(400px, 75vh, 850px);
  /* dynamic viewport height */
  height: clamp(400px, 75dvh, 850px);
  background: transparent;
  /* Invisible borders */
  border: none;
  border-radius: 0;
  padding: 1rem;
  box-shadow: none;
  /* Removed cardholder look */
  position: relative;
  z-index: 10;
  gap: 0.75rem;
  width: 100%;
  margin: 0 auto;
}

.placeholder {
  font-size: 1rem;
  color: #aaaaaa;
  text-align: center;
  line-height: 1.6;
}

/* Responsive tweaks */
@media (max-width: 768px) {
  .chat-title {
    font-size: 2rem;
  }

  .chat-subtitle {
    font-size: 1rem;
    padding: 0 20px;
  }

  .chat-box {
    width: 92%;
    padding: 1rem;
    height: 75vh;
    margin: 10px auto;
  }
}

@media (max-width: 480px) {
  .chat-box {
    width: 90%;
    padding: 0.8rem;
    border-radius: 15px;
    height: 80vh;
    height: 80dvh;
    /* ensure proper spacing from bottom browser UI */
    padding-bottom: max(0.8rem, env(safe-area-inset-bottom));
  }

  .chat-message {
    max-width: 90%;
  }

  .home-float-btn {
    top: 20px;
    right: 20px;
  }
}

/* Video introduction styling */
.intro-video {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 999;
  overflow: hidden;
}

.intro-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Hide chat content until video ends */
.hidden {
  display: none;
  opacity: 0;
}

/* Fade chat in after intro */
.fade-in {
  opacity: 0;
  animation: fadeInSmooth 1s ease forwards;
}

.fade-in.delay-1 {
  animation-delay: 0.5s;
}

.fade-in.delay-2 {
  animation-delay: 1s;
}

.fade-in.delay-3 {
  animation-delay: 1.5s;
}

.fade-in.delay-4 {
  animation-delay: 2s;
}

@keyframes fadeInSmooth {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Static home icon on every page */
.home-float-btn {
  position: fixed;
  top: 40px;
  right: 40px;
  background: rgba(255, 255, 255, 0.05);
  /* Glassmorphism */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #00ffaa;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  text-decoration: none;
  z-index: 1000;
  transition: all 0.3s ease;
}

.home-float-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(0, 255, 170, 0.5);
  color: #ffffff;
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(0, 255, 170, 0.4);
}

.chat-thread {
  flex: 1;
  overflow-y: auto;
  max-width: 100%;
  width: 100%;
  padding: 1rem;
  background-color: transparent;
  /* Fully invisible thread background */
  border-radius: 0;
  margin-bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scrollbar-width: none;
  /* Invisible scrollbar */
  -ms-overflow-style: none;
}

.chat-thread::-webkit-scrollbar {
  display: none;
  /* Invisible scrollbar for Chrome/Safari */
}

.chat-message {
  margin: 0.5rem 0;
  padding: 0.8rem 1.2rem;
  border-radius: 15px;
  max-width: 85%;
  font-family: 'Montserrat', sans-serif;
  animation: fadeIn 0.4s ease-out;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-sizing: border-box;
  text-align: left;
  line-height: 1.6;
  /* Better readability */
}

.chat-message.user {
  background: rgba(255, 255, 255, 0.03);
  /* Glassy style matching bot */
  color: #eee;
  align-self: flex-end;
  margin-left: auto;
  box-shadow: none;
  border-right: 3px solid #00ffaa;
  /* Accent on right */
  border-radius: 20px 4px 20px 20px;
}

.chat-message.bot {
  background: rgba(255, 255, 255, 0.03);
  /* Subtle hint of a bubble */
  color: #eee;
  align-self: flex-start;
  border-left: 3px solid #00ffaa;
  /* Accent line instead of full border */
  border-radius: 4px 20px 20px 20px;
}

/* Markdown specific styles for professional look */
.chat-message.bot h1,
.chat-message.bot h2,
.chat-message.bot h3 {
  color: #00ffaa;
  margin: 1rem 0 0.5rem 0;
  font-weight: 700;
  line-height: 1.2;
}

.chat-message.bot h1 {
  font-size: 1.4rem;
}

.chat-message.bot h2 {
  font-size: 1.2rem;
}

.chat-message.bot h3 {
  font-size: 1.1rem;
}

.chat-message.bot p {
  margin: 0.4rem 0;
  line-height: 1.5;
}

.chat-message.bot ul,
.chat-message.bot ol {
  margin: 0.4rem 0;
  padding-left: 1.2rem;
}

.chat-message.bot li {
  margin: 0.2rem 0;
}

.chat-message.bot strong {
  color: #00ffaa;
  font-weight: 700;
}

.chat-message.bot em {
  color: #cccccc;
  font-style: italic;
}

/* Chat input */
.chat-input {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  height: 60px;
  width: 100%;
  margin-top: 1rem;
  padding: 0 10px;
}

.chat-input input {
  flex: 1;
  padding: 0 1.2rem;
  height: 100%;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 1rem;
  background-color: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  color: #fff;
  transition: all 0.3s ease;
}

.chat-input input:focus {
  outline: none;
  border-color: rgba(0, 255, 170, 0.5);
  background-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 15px rgba(0, 255, 170, 0.2);
}

.chat-input button {
  width: 50px;
  height: 50px;
  cursor: pointer;
  background-color: #00d98b;
  color: white;
  border: none;
  border-radius: 50%;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 15px rgba(0, 217, 139, 0.3);
}

.chat-input button:hover {
  background-color: #00ffaa;
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(0, 255, 170, 0.5);
}


/* Fade in animation for messages */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}