/* Главное окно чата */
.chat-window {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  max-width: 900px;    /* Было 480px — теперь 900px */
  min-width: 320px;    /* Чтоб не было слишком узко */
  width: 100%;         /* Гибко для адаптива */
  margin: 0 auto;
  background: #222;
  border-radius: 14px;
  box-shadow: 0 2px 24px #0004;
  position: relative;
  overflow: hidden;
}
/* Контейнер сообщений */
.chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 12px 100px 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  scroll-behavior: smooth;
  background: none;
}
/* Сообщение чужое */
.chat-message {
  padding: 9px 17px;
  border-radius: 16px 16px 16px 6px;
  background: #161616;
  color: #fff;
  font-size: 16.5px;
  align-self: flex-start;
  max-width: 78%;
  word-break: break-word;
  box-shadow: 0 1px 4px #0002;
  margin-bottom: 1px;
  margin-top: 1px;
  transition: background 0.22s;
}
/* Сообщение свое */
.chat-message.from-me {
  background: #2568ef;
  color: #fff;
  align-self: flex-end;
  border-radius: 16px 16px 6px 16px;
}
/* Светлая тема */
body.light-theme .chat-window {
  background: #f4f4f8;
  box-shadow: 0 2px 18px #8882;
}
body.light-theme .chat-messages {
  background: none;
}
body.light-theme .chat-message {
  background: #f3f3f3;
  color: #181818;
  box-shadow: 0 1px 4px #0001;
}
body.light-theme .chat-message.from-me {
  background: #2568ef;
  color: #fff;
}
/* Форма чата, input и кнопка отправки */
#chat-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 14px 14px;
  background: #181818;
  border-top: 1.5px solid #232323;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 100%;
  min-width: 0;
  z-index: 30;
}
body.light-theme #chat-form {
  background: #fff;
  border-top: 1.5px solid #eee;
}
.chat-input {
  flex: 1 1 auto;
  font-size: 17px;
  border: none;
  outline: none;
  background: #222;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  margin: 0;
  min-width: 0;
  box-shadow: 0 1px 6px #0001;
  transition: background 0.14s;
}
body.light-theme .chat-input {
  background: #f5f5f5;
  color: #222;
}
.chat-input::placeholder {
  color: #aaa;
  opacity: 0.88;
}
.chat-dot-btn {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.25s cubic-bezier(0.32,0.72,0.32,1);
  width: 38px;
  height: 38px;
}
.chat-dot-btn .dot-svg-wrap {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.18s;
  box-shadow: 0 1px 8px #0003;
}
body.light-theme .chat-dot-btn .dot-svg-wrap {
  background: #000;
}
.chat-dot-btn .dot-svg-wrap svg {
  display: block;
  width: 24px;
  height: 24px;
}
/* Scrollbar */
.chat-messages {
  scrollbar-width: thin;
  scrollbar-color: #232323 #1a1a1a;
}
body.light-theme .chat-messages {
  scrollbar-color: #ccc #fafafa;
}
@media (max-width: 640px) {
  .chat-window {
    border-radius: 0;
    max-width: 100vw;
    min-width: 0;
    box-shadow: none;
  }
  #chat-form {
    max-width: 100vw;
    padding: 13px 5vw 14px 5vw;
  }
  .chat-messages {
    padding-left: 5vw;
    padding-right: 5vw;
    padding-bottom: 90px;
  }
  .chat-message, .chat-message.from-me {
    font-size: 15.5px;
    max-width: 96vw;
    padding: 8px 9px;
  }
}
@media (max-width: 600px) {
  .chat-messages {
    padding-bottom: calc(90px + env(safe-area-inset-bottom));
  }
  #chat-form {
    padding-bottom: calc(13px + env(safe-area-inset-bottom));
  }
}
