/* Chat follows Telegram's solid working surfaces, independent pane scrolling. */
.chat-content {
  --chat-wall: #dce6ed;
  --chat-in: #fff;
  --chat-out: #e1ffc7;
  --chat-text: #18222d;
  --chat-meta: #526775;
  --chat-accent: #2488cf;
  --chat-pane: #fff;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 16px 24px;
  width: 100%;
}
:root[data-theme="dark"] .chat-content {
  --chat-wall: #0e1621;
  --chat-in: #182533;
  --chat-out: #2b5278;
  --chat-text: #f1f5f8;
  --chat-meta: #a3b6c6;
  --chat-accent: #6cb8ed;
  --chat-pane: #17212b;
}
html:has(.chat-content),
body:has(.chat-content) {
  height: 100%;
  overflow: hidden;
}
.platform-shell:has(.chat-content) {
  height: 100dvh;
  min-height: 0;
}
.workspace:has(.chat-content) {
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.workspace:has(.chat-content) .workspace-header {
  flex: none;
}
.chat-content .chat-layout {
  position: relative;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  background: var(--chat-pane);
  box-shadow: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.chat-content .chat-layout.profile-open {
  grid-template-columns: 280px minmax(0, 1fr) 280px;
}
.chat-content .chat-list {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--chat-pane);
}
.chat-content .chat-list > header {
  height: 60px;
  min-height: 60px;
  padding: 10px 16px;
}
.chat-content .chat-list h2 {
  font-family: inherit;
  font-size: 20px;
  font-weight: 650;
}
.chat-content .chat-tabs {
  flex: none;
  display: flex;
  width: 100%;
  padding: 0 12px;
  gap: 4px;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.chat-content .chat-tabs button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
  min-width: max-content;
  background: transparent;
  border-radius: 0;
  padding: 10px 4px 9px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.chat-content .chat-tabs button.active {
  border-color: var(--chat-accent);
  color: var(--chat-accent);
}
.chat-content .folder-label {
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-content .folder-metrics {
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: 3px;
}
.chat-content .chat-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  font-size: 10px;
  padding: 2px 4px;
  background: var(--soft);
  border-radius: 6px;
  color: inherit;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.chat-content .chat-search {
  padding: 12px;
  flex: none;
}
.chat-content .chat-search input {
  border: 0;
  border-radius: 20px;
  min-height: 38px;
  background: var(--soft);
  font-size: 14px;
}
.chat-content .chat-people {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.chat-content .person {
  grid-template-columns: 42px minmax(0, 1fr) auto;
  padding: 12px;
  gap: 10px;
  border: 0;
  align-items: center;
  min-height: 72px;
}
.chat-content .person.selected {
  background: #287bb5;
  color: #fff;
}
.chat-content .person.selected small,
.chat-content .person.selected time {
  color: #fff;
}
.chat-content .person .avatar,
.chat-content .profile-title .avatar {
  width: 42px;
  height: 42px;
  background: #579ac9;
  color: #fff;
  font-size: 18px;
  flex: none;
}
.chat-content .person-copy {
  min-width: 0;
}
.chat-content .person b {
  font-size: 14px;
  font-weight: 650;
}
.chat-content .person small {
  font-size: 12px;
  margin-top: 3px;
  color: var(--muted);
}
.chat-content .person-meta {
  display: grid;
  justify-items: end;
  gap: 6px;
  font-size: 11px;
  white-space: nowrap;
}
.chat-content .person time {
  grid-column: auto;
  font-size: 11px;
  color: var(--muted);
}
.chat-content .person-meta small {
  font-size: 10px;
}
.chat-content .conversation {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--chat-wall);
}
.chat-content .conversation-head {
  height: 64px;
  min-height: 64px;
  flex: none;
  background: var(--chat-pane);
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
}
.chat-content .profile-title {
  flex: 1;
  min-width: 0;
  color: var(--chat-text);
}
.chat-content .profile-title b {
  font-size: 15px;
  font-weight: 650;
}
.chat-content .profile-title small {
  font-size: 12px;
}
.chat-content .profile-title span:last-child {
  min-width: 0;
}
.chat-content .profile-title b {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-content .icon-button {
  background: transparent;
  color: var(--muted);
  min-width: 38px;
}
.chat-content .messages {
  display: block;
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 16px 24px;
  scroll-behavior: auto;
}
.chat-content .messages:focus-visible {
  outline: 2px solid var(--chat-accent);
  outline-offset: -3px;
}
.chat-content .message {
  display: flex;
  margin: 5px 0;
}
.chat-content .message-bubble {
  max-width: min(80%, 560px);
  padding: 8px 11px 6px;
  border-radius: 12px 12px 12px 3px;
  background: var(--chat-in);
  color: var(--chat-text);
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
.chat-content .message.out .message-bubble {
  background: var(--chat-out);
  color: var(--chat-text);
  border-radius: 12px 12px 3px 12px;
}
.chat-content .message p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  margin: 0;
}
.chat-content .message-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  font-size: 11px;
  line-height: 15px;
  color: var(--chat-meta);
}
.chat-content .delivery {
  display: flex;
  align-items: center;
}
.chat-content .delivery.sent {
  color: #287849;
}
:root[data-theme="dark"] .chat-content .delivery.sent {
  color: #89cefb;
}
.chat-content .delivery.failed {
  color: var(--red);
}
.chat-content .delivery svg {
  width: 16px;
  height: 16px;
}
.chat-content .chat-date {
  display: flex;
  justify-content: center;
  margin: 14px 0;
}
.chat-content .chat-date span {
  padding: 3px 10px;
  background: var(--chat-pane);
  color: var(--chat-meta);
  border-radius: 12px;
  font-size: 11px;
}
.chat-content .chat-photo {
  display: block;
  max-width: 320px;
  margin: 0 0 7px;
}
.chat-content .chat-photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4/3;
  max-height: 320px;
  object-fit: contain;
  background: var(--chat-wall);
  border-radius: 7px;
}
.chat-content .message-file {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  text-decoration: none;
  align-items: center;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.chat-content .message-file svg {
  flex: none;
}
.chat-content .composer {
  flex: none;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  gap: 10px;
  background: var(--chat-pane);
  padding: 12px 16px;
  border: 0;
  align-items: end;
}
.chat-content .composer textarea {
  min-height: 40px;
  max-height: 140px;
  resize: none;
  background: transparent;
  color: var(--chat-text);
  border: 0;
  border-radius: 0;
  padding: 10px 2px;
  line-height: 20px;
  overflow-y: auto;
  font-size: 14px;
}
.chat-content .composer textarea:focus-visible {
  outline: none;
  box-shadow: inset 0 -2px var(--chat-accent);
}
.chat-content .file-button {
  position: relative;
  background: transparent;
  color: var(--muted);
  border: 0;
  height: 40px;
  cursor: pointer;
}
.chat-content .file-button svg {
  width: 24px;
  height: 24px;
}
.chat-content .file-button:focus-visible {
  outline: 2px solid var(--chat-accent);
}
.chat-content .chat-send {
  border-radius: 50%;
  background: #2488cf;
  color: #fff;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}
.chat-content .chat-send svg {
  width: 21px;
  height: 21px;
}
.chat-content .chat-send:hover {
  background: #1876b6;
}
.chat-content .attachment-preview {
  grid-column: 1/-1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px 10px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.chat-content .attachment-preview[hidden] {
  display: none;
}
.chat-content .attachment-preview img {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--soft);
}
.chat-content .attachment-preview > div {
  flex: 1;
  min-width: 0;
}
.chat-content .attachment-preview b,
.chat-content .attachment-preview small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-content .attachment-preview small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}
.chat-content .attachment-preview button {
  background: transparent;
  color: var(--muted);
  width: 38px;
  height: 38px;
}
.chat-content .chat-to-bottom {
  position: absolute;
  right: 24px;
  bottom: 88px;
  background: var(--chat-pane);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border-radius: 50%;
  font-size: 20px;
}
.chat-content .chat-to-bottom[hidden] {
  display: none;
}
.chat-content .older-messages {
  width: auto;
  margin: 0 auto 12px;
  display: block;
  background: var(--chat-pane);
  color: var(--chat-accent);
  border: 0;
  font-size: 12px;
}
.chat-content .profile-panel {
  display: none;
  min-height: 0;
  min-width: 0;
  background: var(--chat-pane);
  padding: 16px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
}
.chat-content .profile-open .profile-panel {
  display: block;
}
.chat-content .profile-panel > header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
}
.chat-content .profile-panel h3 {
  font-family: inherit;
  font-size: 16px;
  font-weight: 650;
}
.chat-content .profile-avatar {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin: 22px 0;
}
.chat-content .profile-avatar .avatar {
  width: 72px;
  height: 72px;
  font-size: 28px;
  background: #579ac9;
  color: #fff;
}
.chat-content .profile-panel dl {
  font-size: 13px;
}
.chat-content .profile-panel dt {
  font-size: 12px;
  margin-top: 16px;
}
.chat-content .profile-panel dd {
  font-size: 13px;
}
.chat-content .amo-sync-detail {
  display: grid;
  gap: 6px;
}
.chat-content .amo-sync-detail a {
  color: var(--chat-accent);
  text-underline-offset: 3px;
}
.chat-content .chat-back {
  display: none;
  transform: none;
}
.chat-content .chat-placeholder {
  color: var(--muted);
}
@media (max-width: 1100px) {
  .chat-content .chat-layout,
  .chat-content .chat-layout.profile-open {
    grid-template-columns: 260px minmax(0, 1fr);
  }
  .chat-content .profile-open .profile-panel {
    position: absolute;
    inset: 0 0 0 auto;
    width: 290px;
    max-width: 100%;
    z-index: 8;
  }
  .chat-content .messages {
    padding: 12px 14px;
  }
}
@media (max-width: 680px) {
  .chat-content {
    padding: 0;
  }
  .workspace:has(.chat-content) {
    padding-bottom: 68px;
  }
  .chat-content .chat-layout,
  .chat-content .chat-layout.profile-open {
    display: block;
    border: 0;
    border-radius: 0;
  }
  .chat-content .chat-list {
    height: 100%;
  }
  .chat-content .conversation {
    position: absolute;
    inset: 0;
    display: none;
    z-index: 2;
  }
  .chat-content .has-chat .conversation {
    display: flex;
  }
  .chat-content .conversation-head {
    min-height: 60px;
    height: 60px;
    padding: 8px 12px;
    gap: 8px;
  }
  .chat-content .chat-back {
    display: grid;
  }
  .chat-content .profile-title .avatar {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
  .chat-content .messages {
    padding: 8px 12px 14px;
  }
  .chat-content .message-bubble {
    max-width: 88%;
  }
  .chat-content .message p {
    font-size: 14px;
  }
  .chat-content .composer {
    grid-template-columns: 34px minmax(0, 1fr) 40px;
    padding: 10px;
    gap: 6px;
  }
  .chat-content .profile-open .profile-panel {
    inset: 0;
    width: 100%;
    border: 0;
    z-index: 9;
  }
  .chat-content .chat-to-bottom {
    right: 14px;
  }
}

.chat-content .unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 50px;
  background: #287bb5;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.chat-content .folder-unread {
  min-width: 22px;
  height: 22px;
}
.chat-content .person.selected .unread-badge {
  background: #fff;
  color: #185c8c;
}
.chat-content .person-meta {
  justify-items: end;
}
