#chat-section {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 500px;
  width: 100%;
}

#chat-section h2 {
  margin-bottom: 1rem;
  text-align: center;
}

.chat-messages {
  flex: 1;
  width: 100%;
  /* Removed fixed height to allow flexbox to manage it */
  padding: 1rem;
  background: var(--primary-color);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  position: relative;
  margin: 0.5rem 0;
  contain: content;
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  z-index: 2; /* Ensures messages are above particles */
}

#prompt-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0 0.5rem;
}

.prompt-starter {
  background-color: transparent;
  border: 1px solid var(--accent-color);
  color: var(--accent-color);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-family: var(--main-font);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.prompt-starter:hover {
  background-color: rgba(100, 255, 218, 0.1);
  transform: translateY(-2px);
}

.message {
  position: relative;
  padding: 1rem;
  border-radius: 12px;
  max-width: 85%;
  width: fit-content;
  word-wrap: break-word;
  font-size: 0.95rem;
  line-height: 1.5;
  font-weight: 400;
  letter-spacing: 0.2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.2s var(--animation-timing);
  animation: fadeInScale 0.4s var(--animation-timing) forwards;
  margin: 0.5rem 0;
  background: var(--secondary-color);
  border: 1px solid var(--glass-border);
  transform-origin: bottom;
  will-change: transform, opacity;
  contain: content;
  z-index: 1; /* Ensure it's above other elements */
}

.message::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: var(--shimmer-gradient);
  animation: shimmer 2s infinite;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.message:hover::before {
  opacity: 1;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message-content {
  margin-top: 0.5rem;
}

.message:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px;
  background: linear-gradient(135deg,
      rgba(100, 255, 218, 0.1),
      rgba(100, 255, 218, 0.05));
  border: 1px solid rgba(100, 255, 218, 0.2);
  border-radius: 12px;
  width: fit-content;
  margin: 8px 0;
  opacity: 0;
  animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-color);
  border-radius: 50%;
  animation: typingBounce 1s infinite;
  box-shadow: 0 0 10px var(--accent-color);
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-4px);
  }
}

.badge-container {
  position: relative;
  /* Changed from absolute */
  display: flex;
  gap: 6px;
  margin-bottom: 0.3rem;
}

.badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.time-badge {
  background-color: rgba(204, 214, 246, 0.05) !important;
  color: var(--text-secondary) !important;
  border: 1px solid rgba(136, 146, 176, 0.2) !important;
}

/* Remove the old timestamp styles */
.message .timestamp {
  display: none;
}

/* Remove old position styles */
.message .badge {
  position: static;
}

.user-message .badge {
  background-color: var(--user-message-bg);
  color: var(--accent-color);
  border: 1px solid var(--accent-color);
}

.ai-message .badge {
  background-color: var(--ai-message-bg);
  color: var(--text-color);
  border: 1px solid var(--text-secondary);
}

.user-message {
  align-self: flex-end;
  background: linear-gradient(135deg,
      rgba(100, 255, 218, 0.05),
      rgba(100, 255, 218, 0.02));
  border: 1px solid rgba(100, 255, 218, 0.2);
  margin-left: auto;
  /* Changed from margin-left: 20% */
  margin-right: 0.5rem;
}

.ai-message {
  align-self: flex-start;
  background: linear-gradient(135deg,
      rgba(204, 214, 246, 0.05),
      rgba(204, 214, 246, 0.02));
  border: 1px solid rgba(136, 146, 176, 0.1);
  margin-right: auto;
  /* Changed from margin-right: 20% */
  margin-left: 0.5rem;
}

.ai-message b {
  color: var(--accent-color);
  font-weight: 500;
}

.chat-input {
  display: flex;
  gap: 0.5rem;
}

.chat-input input {
  flex-grow: 1;
  padding: 0.8rem;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  background: var(--secondary-color);
  color: var(--text-color);
  font-size: 0.9rem;
  font-family: var(--main-font);
  font-weight: 300;
  transition: all 0.3s var(--animation-timing);
  outline: none;
}

.chat-input input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 10px rgba(100, 255, 218, 0.2);
  background-color: rgba(204, 214, 246, 0.08);
  transform: translateY(-1px) scale(1.001);
  animation: inputPulse 2s infinite;
}

@keyframes inputPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(100, 255, 218, 0.4);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(100, 255, 218, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(100, 255, 218, 0);
  }
}

.chat-input input::placeholder {
  color: var(--text-secondary);
  transition: color 0.3s ease;
}

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

.chat-input button {
  padding: 0.8rem 1.2rem;
  border: 1px solid var(--accent-color);
  border-radius: 6px;
  background-color: transparent;
  color: var(--accent-color);
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
  font-size: 0.9rem;
  font-family: var(--main-font);
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transform-style: preserve-3d;
  perspective: 1000px;
}

.chat-input button:hover {
  background-color: var(--accent-color);
  color: var(--primary-color);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 4px 12px rgba(100, 255, 218, 0.2);
}

.chat-input button:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(100, 255, 218, 0.1);
}

.chat-input button:disabled {
  background-color: transparent;
  border-color: var(--secondary-color);
  color: var(--secondary-color);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.chat-input button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background-color: var(--accent-color);
  transform: translate(-50%, -50%) scale(0);
  opacity: 0.1;
  border-radius: 50%;
  transition: transform 0.5s ease;
}

.chat-input button:hover::before {
  transform: translate(-50%, -50%) scale(2);
}

.loading {
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg,
      var(--primary-color),
      var(--accent-color),
      var(--primary-color));
  background-size: 200% 100%;
  animation: gradientLoad 1.5s infinite linear;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 200%;
  height: 100%;
  background: var(--loading-gradient);
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

@keyframes gradientLoad {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: -100% 0;
  }
}

.beta-badge {
  font-size: 0.6rem;
  padding: 2px 6px;
  background-color: var(--beta-bg);
  border: 1px solid var(--beta-border);
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 8px;
  animation: pulse 2s infinite;
  color: var(--accent-color);
  font-family: var(--main-font);
  font-weight: 500;
}

@keyframes pulse {
  0% {
    opacity: 0.6;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.6;
  }
}

.disclaimer {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 1rem;
  font-style: italic;
}

.disclaimer-container {
  position: relative;
  margin-bottom: 1rem;
}

.disclaimer-icon {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  color: var(--accent-color);
  font-size: 1.2rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.disclaimer-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  right: 0;
  background: var(--secondary-color);
  border: 1px solid var(--accent-color);
  padding: 0.8rem;
  border-radius: 8px;
  width: max-content;
  max-width: 250px;
  font-size: 0.8rem;
  color: var(--text-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.message:hover::before {
  opacity: 1 !important;
}

.message:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) !important;
}
