.chat-composer-v31 {
  position: relative !important;
  height: auto !important;
  min-height: 142px;
  padding: 10px 12px !important;
  display: grid !important;
  gap: 8px !important;
  background: #fff;
  border-top: 1px solid var(--line);
}
.chat-compose-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-compose-tools > button {
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  color: #53657b;
  display: flex;
  align-items: center;
  gap: 5px;
}
.chat-compose-tools > button:hover {
  border-color: #adc4e0;
  background: #f0f5fb;
  color: #285f98;
}
.chat-compose-tools > button span {
  font-size: 10px;
}
.chat-compose-tools em {
  margin-left: auto;
  color: #6b7889;
  font-size: 9px;
  font-style: normal;
}
.chat-compose-main {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.chat-compose-main textarea {
  flex: 1;
  min-height: 64px;
  max-height: 140px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid #cfd9e6;
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  outline: none;
  line-height: 1.5;
}
.chat-compose-main textarea:focus {
  border-color: #6f9dce;
  box-shadow: 0 0 0 3px #5f91c51c;
}
.chat-compose-main textarea:disabled {
  background: #f3f5f8;
  color: #929cab;
}
.chat-compose-main .primary {
  min-width: 76px;
}
.chat-compose-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #8995a5;
  font-size: 9px;
}
.chat-compose-foot .secondary {
  padding: 6px 10px;
}
.chat-emoji-panel,
.chat-quick-panel {
  position: absolute;
  z-index: 8;
  left: 12px;
  bottom: calc(100% - 40px);
  padding: 8px;
  border: 1px solid #ced9e6;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 35px #17283f22;
}
.chat-composer-v31 [hidden] {
  display: none !important;
}
.chat-emoji-panel {
  grid-template-columns: repeat(4, 36px);
  gap: 5px;
}
.chat-emoji-panel button {
  width: 36px;
  height: 34px;
  border: 0;
  border-radius: 7px;
  background: #f6f8fb;
  font-size: 18px;
}
.chat-quick-panel {
  width: min(380px, calc(100% - 24px));
  display: grid;
  gap: 5px;
}
.chat-quick-panel button {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: #f6f8fb;
  text-align: left;
  color: var(--text);
}
.chat-quick-panel button:hover {
  background: #edf3fa;
}
.chat-quick-panel b {
  font-size: 10px;
}
.chat-quick-panel span {
  font-size: 9px;
  color: #718095;
}
.chat-image-preview {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px;
  border: 1px solid #d8e2ee;
  border-radius: 8px;
  background: #f8fafc;
}
.chat-image-preview img {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  background: #e8edf3;
}
.chat-image-preview span {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.chat-image-preview b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9px;
}
.chat-image-preview small {
  color: #7e8b9c;
  font-size: 8px;
}
.chat-image-preview button {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: #8290a2;
  font-size: 18px;
}
.chat-composer-v31.locked,
.chat-composer-v31.readonly {
  background: #f8fafc;
}
.chat-composer-v31.locked .chat-compose-tools > button,
.chat-composer-v31.readonly .chat-compose-tools > button {
  opacity: 0.65;
}
body.theme-dark .chat-composer-v31 {
  background: #171c24;
  border-color: #34404e;
}
body.theme-dark .chat-compose-tools > button,
body.theme-dark .chat-emoji-panel,
body.theme-dark .chat-quick-panel {
  border-color: #3a4655;
  background: #202732;
  color: #dce5ef;
}
body.theme-dark .chat-compose-main textarea {
  border-color: #3a4655;
  background: #11161d;
  color: #eef3f8;
}
body.theme-dark .chat-compose-main textarea:disabled {
  background: #151a21;
  color: #778290;
}
body.theme-dark .chat-quick-panel button,
body.theme-dark .chat-emoji-panel button,
body.theme-dark .chat-image-preview {
  background: #1a212a;
  color: #eef3f8;
  border-color: #354150;
}
body.theme-dark .chat-composer-v31.locked,
body.theme-dark .chat-composer-v31.readonly {
  background: #151a21;
}
@media (max-width: 720px) {
  .chat-compose-tools > button span {
    display: none;
  }
  .chat-compose-tools em {
    display: none;
  }
  .chat-composer-v31 {
    min-height: 132px;
  }
  .chat-compose-main .primary {
    min-width: 62px;
  }
}
/* Keep the complete composer visible inside the fixed-height chat panel. */
.messages .message-body {
  min-height: 0;
}
.messages > footer.chat-composer-v31 {
  flex: 0 0 auto !important;
}
@media (min-width: 721px) {
  #chats .chat-grid {
    height: max(680px, calc(100dvh - 245px)) !important;
    min-height: 680px !important;
  }
}
#chats .chat-grid > .messages {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
/* Responsive composer: use the full conversation width and scale with viewport height. */
.messages > footer.chat-composer-v31 {
  width: 100%;
  min-width: 0;
  min-height: clamp(154px, 22vh, 250px);
  justify-content: stretch !important;
  align-items: stretch !important;
  grid-template-columns: minmax(0, 1fr) !important;
}
.chat-composer-v31 > .chat-compose-tools,
.chat-composer-v31 > .chat-compose-main,
.chat-composer-v31 > .chat-compose-foot,
.chat-composer-v31 > .chat-image-preview {
  width: 100%;
  min-width: 0;
}
.chat-compose-main textarea {
  width: 100%;
  min-width: 0;
  min-height: clamp(84px, 13vh, 150px);
}
.chat-compose-main .primary {
  flex: 0 0 clamp(82px, 8vw, 108px);
}
@media (max-width: 720px) {
  .messages > footer.chat-composer-v31 {
    min-height: 210px;
  }
  .chat-compose-main {
    flex-direction: column;
  }
  .chat-compose-main textarea {
    min-height: 110px;
  }
  .chat-compose-main .primary {
    flex: 0 0 auto;
    width: 100%;
    min-height: 42px;
  }
}
@media (min-width: 901px) and (max-width: 1100px) {
  #chats .chat-grid {
    grid-template-columns: 230px minmax(0, 1fr) !important;
  }
  #chats .chat-grid > aside:first-child {
    display: none !important;
  }
}
@media (min-width: 721px) and (max-width: 900px) {
  .sidebar {
    width: 64px;
  }
  .brand {
    padding: 0 14px;
  }
  .brand span,
  .side-foot,
  .sidebar nav .nav-label,
  .sidebar nav em {
    display: none !important;
  }
  .sidebar nav button {
    padding: 0;
    text-align: center;
    font-size: 0;
  }
  main {
    margin-left: 64px;
  }
  #chats .chat-grid {
    grid-template-columns: 210px minmax(0, 1fr) !important;
  }
  #chats .chat-grid > aside:first-child {
    display: none !important;
  }
  #chats .chat-grid > aside:nth-child(2) {
    display: flex !important;
  }
}
