/* Karim Academy V8 — keep chat composer usable when replying to a message.
   This stylesheet is intentionally loaded after V7 styles. */
.app .social-community .social-chat {
  display: flex !important;
  flex-direction: column !important;
  min-width: 0 !important;
  min-height: 460px !important;
  height: clamp(460px, calc(100dvh - 215px), 720px) !important;
  max-height: none !important;
  overflow: hidden;
}

/* The history scrolls; the typing area must not be pushed off the bottom. */
.app .social-community .social-chat .social-chat-head,
.app .social-community .social-chat .social-room-description {
  flex-shrink: 0;
}
.app .social-community .social-chat .social-chat-messages {
  min-width: 0;
  min-height: 0 !important;
  flex: 1 1 auto !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
}
.app .social-community .social-chat .social-chat-bottom {
  position: relative;
  z-index: 2;
  min-width: 0;
  flex: 0 0 auto !important;
  padding: 14px 18px 15px !important;
  background: #fff !important;
  border-top: 2px solid #d9def0 !important;
  box-shadow: 0 -5px 16px rgba(45, 42, 86, .05);
}

/* A reply preview spans the entire top row. The textarea + send button
   always take a NEW row instead of being squeezed alongside the preview. */
.app .social-community .social-chat .social-chat-compose {
  width: 100%;
  min-width: 0;
  display: grid !important;
  grid-template-columns: minmax(0,1fr) 56px !important;
  align-items: end !important;
  justify-items: stretch;
  column-gap: 12px !important;
  row-gap: 10px !important;
}
.app .social-community .social-chat .social-chat-compose > .kf-reply-selected {
  grid-column: 1 / -1 !important;
  width: 100% !important;
  min-width: 0 !important;
  min-height: 0;
  margin: 0 !important;
  padding: 10px 12px !important;
  border-radius: 12px;
  align-items: center;
  overflow: hidden;
}
.app .social-community .social-chat .social-chat-compose .kf-reply-selected > span {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
}
.app .social-community .social-chat .social-chat-compose .kf-reply-selected small {
  display: block;
  max-width: 100%;
  line-height: 1.4;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.app .social-community .social-chat .social-chat-compose .kf-reply-selected > button {
  flex: 0 0 34px;
  width: 34px !important;
  height: 34px !important;
  display: grid;
  place-items: center;
}
.app .social-community .social-chat .social-chat-compose > label {
  grid-column: 1 !important;
  min-width: 0 !important;
  width: 100% !important;
  margin: 0 !important;
  display: block !important;
}
.app .social-community .social-chat .social-chat-compose textarea {
  box-sizing: border-box !important;
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  height: 76px !important;
  min-height: 76px !important;
  max-height: 180px !important;
  resize: vertical;
  padding: 14px 16px !important;
  border: 2px solid #c8cbe7 !important;
  border-radius: 14px !important;
  background: #fff !important;
  color: #242b48 !important;
  font-size: 16px !important;
  line-height: 1.6 !important;
  opacity: 1 !important;
}
.app .social-community .social-chat .social-chat-compose textarea::placeholder {
  color: #787b91 !important;
  opacity: 1;
}
.app .social-community .social-chat .social-chat-compose textarea:focus {
  outline: 3px solid rgba(100,80,210,.13) !important;
  outline-offset: 0 !important;
  border-color: #6f5cd1 !important;
}
.app .social-community .social-chat .social-chat-compose > button[type="submit"] {
  grid-column: 2 !important;
  align-self: end !important;
  justify-self: stretch !important;
  width: 56px !important;
  height: 56px !important;
  min-width: 56px !important;
  min-height: 56px !important;
  border-radius: 14px !important;
  display: grid !important;
  place-items: center !important;
}
.app .social-community .social-chat .social-chat-bottom > small {
  margin-top: 10px !important;
  font-size: 12px !important;
  line-height: 1.5 !important;
}

@media (max-width: 620px) {
  .app .social-community .social-chat {
    min-height: 430px !important;
    height: clamp(430px, calc(100dvh - 190px), 670px) !important;
  }
  .app .social-community .social-chat .social-chat-bottom {
    padding: 12px 11px max(12px, env(safe-area-inset-bottom)) !important;
  }
  .app .social-community .social-chat .social-chat-compose {
    grid-template-columns: minmax(0,1fr) 50px !important;
    gap: 8px !important;
  }
  .app .social-community .social-chat .social-chat-compose textarea {
    height: 72px !important;
    min-height: 72px !important;
    padding: 12px 13px !important;
  }
  .app .social-community .social-chat .social-chat-compose > button[type="submit"] {
    width: 50px !important;
    min-width: 50px !important;
    height: 50px !important;
    min-height: 50px !important;
  }
}
