* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: url("https://raw.githubusercontent.com/akiizryzz/s/main/vid/furina%20geol%20geol.gif") no-repeat center center/cover;
  opacity: 0.12;
  filter: blur(8px);
  z-index: -1;
}

body {
  font-family: 'Inter', sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  color: #1e293b;
}

header {
  display: flex;
  align-items: center;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, #f8fafc, #cbd5e1);
  border-bottom: 1px solid #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  user-select: none;
}

header h1 {
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 1.5rem;
  background: linear-gradient(90deg, #00ffff, #0000ff, #ff00ff, #00ffff);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  gap: 0.5rem;
  animation: gradient-slide 4s linear infinite;
}

@keyframes gradient-slide {
  0% { background-position: 0% 0%; }
  100% { background-position: -300% 0%; }
}

main {
  flex: 1 1 auto;
  max-width: 40rem;
  width: 100%;
  margin: 1.5rem auto;
  background: transparent;
  border-radius: 1rem;
  box-shadow: 0 8px 16px rgba(90, 103, 216, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#chat-container {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.5rem;
  font-size: 1rem;
  line-height: 1.6;
  color: inherit;
}

#chat-container p {
  margin-top: 2rem;
  text-align: center;
  color: #94a3b8;
  font-weight: 500;
  user-select: none;
}

.message {
  display: flex;
  flex-direction: column;
  margin-bottom: 1.25rem;
  max-width: 85%;
  word-wrap: break-word;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

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

.message.user {
  margin-left: auto;
  justify-content: flex-end;
  align-items: flex-end;
}

.message.ai {
  align-items: flex-start;
}

.bubble {
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  max-width: 100%;
  white-space: pre-wrap;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

.message.user .bubble {
  background-color: #dcf8c6;
  color: #111827;
  border-bottom-right-radius: 0.25rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.message.ai .bubble {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  border-bottom-left-radius: 0.25rem;
}

.message.error .bubble {
  background: linear-gradient(135deg, #fef2f2, #fee2e2);
  color: #b91c1c;
  border: 1px solid #f87171;
}

.message.loading .bubble {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  position: relative;
  overflow: hidden;
  opacity: 0.9;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.message.loading .bubble::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

.chat-time {
  font-size: 0.8em;
  color: #94a3b8;
  margin-top: 0.2em;
  margin-bottom: 0.1em;
  margin-left: 0.25em;
  user-select: none;
  letter-spacing: 0.3px;
}

.meta-ai-logo {
  display: flex;
  align-items: center;
  position: absolute;
  right: -2.3em;
  bottom: 0.2em;
  background: #fff;
  border-radius: 1.2em;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  padding: 1px 8px 1px 2px;
  font-size: 0.82em;
  gap: 3px;
  border: 1px solid #e0e7ef;
  z-index: 2;
}

.meta-ai-logo img {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  margin-right: 3px;
}

#input-container {
  display: flex;
  border-top: 1px solid #cbd5e1;
  padding: 1rem;
  background: linear-gradient(135deg, #f8fafc, #e2e8f0);
}

#user-input {
  flex: 1 1 auto;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 500;
  border: 1px solid #cbd5e1;
  border-radius: 0.75rem;
  background-color: #ffffff;
  color: #1e293b;
  outline: none;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#user-input::placeholder {
  color: #94a3b8;
}

#user-input:focus {
  border-color: #5a67d8;
  box-shadow: 0 0 8px rgba(90, 103, 216, 0.5);
}

#send-button {
  background: #dcf8c6;
  border: none;
  color: #000;
  width: 44px;
  height: 44px;
  margin-left: 0.75rem;
  border-radius: 50%;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background 0.3s, transform 0.2s, box-shadow 0.3s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
  padding: 0;
}

#send-button:disabled {
  background: linear-gradient(135deg, #9ca3af, #6b7280);
  cursor: not-allowed;
  color: #d1d5db;
}

#send-button:not(:disabled):hover {
  background: #dcf8c6;
  transform: scale(1.06);
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.14);
}

#send-button svg {
  width: 23px;
  height: 23px;
  display: block;
}

#chat-container::-webkit-scrollbar {
  width: 8px;
}

#chat-container::-webkit-scrollbar-track {
  background: transparent;
}

#chat-container::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #0000ff, #ff00ff);
  border-radius: 4px;
}

#chat-container::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #0000ff, #ff00ff);
}

footer {
  max-width: 40rem;
  width: 100%;
  margin: 0 auto 1.5rem auto;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 500;
  user-select: none;
  background: linear-gradient(90deg, blue, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

footer a {
  text-decoration: none;
  font-weight: 600;
}

footer a:hover,
footer a:focus {
  text-decoration: underline;
  color: #3b82f6;
  outline: none;
}

@media (max-width: 480px) {
  main {
    margin: 1rem 0.5rem;
  }

  #send-button {
    width: 38px;
    height: 38px;
  }

  header h1 {
    font-size: 1.25rem;
  }

  .meta-ai-logo {
    right: -2.6em;
  }
}
