.profile-panel {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 32px;
  max-width: 850px;
}
.profile-photo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.person-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e5ebff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #3556ef;
  font-weight: 600;
  overflow: hidden;
}
.person-avatar img,
#profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
#profile-avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  overflow: hidden;
}
#my-avatar .person-avatar {
  width: 144px;
  height: 144px;
  font-size: 36px;
}
.photo-pick {
  cursor: pointer;
  background: #eef1ff;
  border-radius: 12px;
  padding: 10px;
  color: #3556ef;
}
.photo-pick input {
  max-width: 190px;
  font-size: 12px;
}
.profile-panel .hint,
.chat-layout .hint,
#chat-dock .hint,
#new-chat-dialog .hint {
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}
.chat-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 20px;
  min-height: 560px;
}
.chat-list-panel,
#conversation {
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  min-width: 0;
}
.chat-list-panel h2 {
  font-size: 18px;
  margin: 0;
}
.chat-list-panel .toolbar {
  gap: 8px;
  flex-wrap: wrap;
}
.chat-list-panel input {
  width: 100%;
}
#chat-list {
  max-height: 580px;
  overflow: auto;
  display: grid;
  gap: 6px;
  margin-top: 16px;
}
.chat-room {
  display: grid;
  gap: 5px;
  text-align: left;
  width: 100%;
  background: transparent;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.chat-room.active {
  background: #e9eeff;
  color: #2546da;
}
.chat-room small {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}
#conversation {
  height: 650px;
  max-height: calc(100vh - 150px);
  min-height: 430px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.conversation-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}
.conversation-header h2 {
  font-size: 18px;
  margin: 0;
  overflow-wrap: anywhere;
}
#chat-members {
  max-height: 48px;
  overflow: auto;
  margin: 4px 0;
}
#chat-context {
  overflow-wrap: anywhere;
  margin: 0;
}
#chat-messages {
  overflow: auto;
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}
.chat-message {
  padding: 12px;
  border-radius: 14px;
  background: #f2f4f9;
  max-width: 94%;
  align-self: flex-start;
  overflow-wrap: anywhere;
}
.chat-message.mine {
  background: #eaf0ff;
  align-self: flex-end;
}
.message-author {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  font-size: 12px;
}
.message-author time {
  font-size: 10px;
  color: var(--muted);
}
.message-author .person-avatar {
  width: 24px;
  height: 24px;
  font-size: 10px;
}
.chat-message p {
  white-space: pre-wrap;
  margin: 8px 0 0;
}
.chat-message button {
  margin-top: 8px;
  font-size: 12px;
  max-width: 100%;
  white-space: normal;
}
#chat-compose {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
#chat-compose textarea {
  width: 100%;
  max-height: 120px;
  margin: 6px 0;
  resize: vertical;
}
#chat-compose .toolbar {
  justify-content: space-between;
  margin-bottom: 0;
}
#chat-compose label {
  font-size: 12px;
}
#chat-send-error {
  font-size: 12px;
  color: #b32332;
  margin: 4px 0;
}
#chat-attach {
  width: auto;
}
#chat-attach-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
#chat-older {
  font-size: 12px;
  padding: 7px;
}
#chat-dock {
  position: fixed;
  z-index: 18;
  right: 16px;
  top: 16px;
  bottom: 16px;
  width: 390px;
  padding: 14px;
  background: #f5f7ff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 12px 70px #1c274230;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#chat-dock > .toolbar {
  margin: 0;
  gap: 6px;
}
#chat-dock > .toolbar button {
  font-size: 12px;
  padding: 7px;
}
#chat-dock > label {
  font-size: 12px;
}
#chat-dock-select {
  width: 100%;
}
#chat-dock-home {
  flex: 1;
  min-height: 0;
}
#chat-dock #conversation {
  height: 100%;
  max-height: none;
  min-height: 0;
  padding: 12px;
}
#chat-dock #chat-messages {
  min-height: 60px;
}
#chat-dock .conversation-header h2 {
  font-size: 15px;
}
#chat-dock #chat-compose textarea {
  max-height: 80px;
}
#chat-member-options {
  max-height: 280px;
  overflow: auto;
  margin: 12px 0;
}
.chat-member-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.chat-member-option input {
  width: auto;
  margin: 0;
}
.chat-member-option > span:last-child {
  display: grid;
  gap: 4px;
}
.chat-member-option small {
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}
@media (min-width: 1250px) {
  body.chat-docked #files-page {
    margin-right: 400px;
  }
}
@media (max-width: 1000px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }
  #chat-list {
    max-height: 210px;
  }
  .profile-panel {
    grid-template-columns: 1fr;
  }
  #conversation {
    max-height: none;
    height: 600px;
  }
  #chat-dock {
    width: min(390px, calc(100vw - 20px));
    right: 10px;
    top: 10px;
    bottom: 10px;
  }
  .chat-message {
    max-width: 100%;
  }
}
