html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}
body {
  background-color: #151e17;
  font-family: 'Segoe UI', sans-serif;
  color: #e9f3e7;
  display: flex;
  flex-direction: column;
  height: 100vh;
}
header {
  padding: 0.8rem;
  text-align: center;
  font-size: 1.3rem;
  background-color: #29332a;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}
.powered-by {
  font-size: 0.8rem;
  color: #00e571;
  text-decoration: none;
  animation: glow 1.5s ease-in-out infinite alternate;
}
@keyframes glow {
  from { text-shadow: 0 0 5px #00e571, 0 0 10px #00e571, 0 0 15px #00e571; }
  to   { text-shadow: 0 0 10px #00e571, 0 0 20px #00e571, 0 0 30px #00e571; }
}
#chat {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 100%;
}
.message-container {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  max-width: 90%;
  opacity: 0;
  transform: translateY(10px);
  animation: fadeIn 0.3s ease-out forwards;
}
@keyframes fadeIn {
  to { opacity: 1; transform: translateY(0); }
}
.bot {
  flex-direction: row;
  justify-content: flex-start;
  margin-right: auto;
}
.user {
  flex-direction: row-reverse;
  justify-content: flex-end;
  margin-left: auto;
}
.avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  animation: pulse 0.5s ease-out;
}
@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.5; }
  100% { transform: scale(1);   opacity: 1;   }
}
.message-content {
  padding: 0.8rem;
  border-radius: 16px;
  box-sizing: border-box;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
  max-width: calc(100% - 50px);
}
.message-content img {
  display: block;
  max-width: 100%;
  height: auto;
}
@media (min-width: 1024px) {
  .message-content img {
    max-width: 600px;
  }
}
.bot .message-content {
  background-color: #29332a !important;
  color: #e9f3e7;
  border-radius: 0 16px 16px 16px;
}
.user .message-content {
  background-color: #00e571;
  color: #002c11;
  border-radius: 16px 0 16px 16px;
}
form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.8rem;
  background-color: #1a251e;
}
#micButton {
  background-color: #00e571;
  color: #002c11;
  border: none;
  padding: 0.6rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
#micButton:hover {
  transform: scale(1.1);
  box-shadow: 0 0 10px #00e571;
}
@keyframes pulseRecording {
  0%   { box-shadow: 0 0 0 0 rgba(0,229,113,0.7); }
  70%  { box-shadow: 0 0 0 10px rgba(0,229,113,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,229,113,0); }
}
.recording {
  animation: pulseRecording 1s infinite;
}
input[type="text"] {
  flex: 1;
  padding: 0.6rem;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  outline: none;
}
button[type="submit"] {
  background-color: #00e571;
  color: #002c11;
  border: none;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}
button[type="submit"]:hover {
  transform: scale(1.05);
  box-shadow: 0 0 10px #00e571;
}
@media (max-width: 768px) {
  form {
    padding: 0.5rem 0.5rem;
  }
  #micButton {
    padding: 0.5rem;
    font-size: 1.1rem;
  }
  input[type="text"] {
    padding: 0.5rem;
    font-size: 0.95rem;
  }
  button[type="submit"] {
    padding: 0.5rem 0.7rem;
    font-size: 0.95rem;
  }
}

.custom-audio-player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: #1a251e;
  padding: 0.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  max-width: 100%;
  box-sizing: border-box;
}

.custom-audio-player .play-pause-btn {
  background-color: #00e571;
  color: #002c11;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.custom-audio-player .play-pause-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 8px #00e571;
}

.custom-audio-player .play-pause-btn.playing {
  animation: pulsePlaying 1.5s infinite;
}

@keyframes pulsePlaying {
  0% { box-shadow: 0 0 0 0 rgba(0, 229, 113, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(0, 229, 113, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 229, 113, 0); }
}

.custom-audio-player .progress-container {
  flex: 1;
  position: relative;
  height: 6px;
  background-color: #29332a;
  border-radius: 3px;
  cursor: pointer;
}

.custom-audio-player .progress-bar {
  width: 0;
  height: 100%;
  background-color: #00e571;
  border-radius: 3px;
  transition: width 0.1s linear;
}

.custom-audio-player .time-display {
  font-size: 0.8rem;
  color: #e9f3e7;
  min-width: 80px;
  text-align: right;
}

@media (max-width: 768px) {
  .custom-audio-player {
    padding: 0.4rem;
  }
  .custom-audio-player .play-pause-btn {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }
  .custom-audio-player .time-display {
    font-size: 0.75rem;
    min-width: 70px;
  }
  .custom-audio-player .progress-container {
    height: 5px;
  }
}

.message-content button {
  background: none;
  border: none;
  color: #00e571;
  cursor: pointer;
  margin-left: 8px;
  font-size: 0.9rem;
  transition: transform 0.2s ease, opacity 0.2s ease, color 0.3s ease;
  position: relative;
}

.message-content button:active {
  transform: scale(1.3);
  opacity: 0.7;
}

.message-content button.copied {
  color: #4caf50;
}

.message-content button.fade-out {
  opacity: 0;
  transform: scale(0.8);
}

.message-content button.fade-in {
  opacity: 1;
  transform: scale(1);
}

.bot-text {
  opacity: 0;
  transition: opacity 0.5s ease-in;
}
.bot-text.visible {
  opacity: 1;
}

.welcome-message .message-content {
  background-color: #1a251e;
  border: 1px solid #00e571;
  border-radius: 16px;
  padding: 1rem;
}

.message-content h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: #00e571;
}

.message-content p {
  margin: 0.5rem 0;
}

.message-content ul {
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}

.message-content li {
  margin-bottom: 0.3rem;
}

.message-content a {
  color: #00e571;
  text-decoration: none;
}

.message-content a:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .welcome-message .message-content {
    padding: 0.6rem; /* Уменьшено с 1rem */
    font-size: 0.85rem; /* Уменьшен базовый размер шрифта */
  }

  .message-content h2 {
    font-size: 1.1rem; /* Уменьшено с 1.5rem */
    margin-bottom: 0.3rem; /* Уменьшено с 0.5rem */
  }

  .message-content p {
    margin: 0.3rem 0; /* Уменьшено с 0.5rem */
  }

  .message-content ul {
    padding-left: 1rem; /* Уменьшено с 1.5rem */
    margin: 0.3rem 0; /* Уменьшено с 0.5rem */
  }

  .message-content li {
    margin-bottom: 0.2rem; /* Уменьшено с 0.3rem */
  }
}