/* Accounts stay scoped to the platform shown in the inbox. */
#inboxAccountShortcuts:empty { display: none; }
#inboxAccountShortcuts {
  border-top: 1px solid var(--ui-border);
  margin-top: 4px;
  padding-top: 4px;
}
.inbox-account-shortcut {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.inbox-account-shortcut[aria-current='true'] {
  background: var(--ui-accent-surface);
  color: var(--ui-accent);
  font-weight: 700;
}
.switch-account-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 18px 16px;
}

/* Show actual media proportions and place controls close to their content. */
#telegramMessages > .telegram-visual-media {
  position: relative;
  width: fit-content;
  max-width: min(86%, 460px);
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}
#telegramMessages > .telegram-visual-media > a:first-child { display: block; width: fit-content; max-width: 100%; }
#telegramMessages > .telegram-visual-media > a > img,
#telegramMessages > .telegram-visual-media > video {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(56dvh, 460px);
  border-radius: 15px;
  background: transparent;
  object-fit: contain;
}
#telegramMessages .telegram-visual-media:not(:has(.telegram-caption, video)) > time {
  position: absolute;
  right: 6px;
  bottom: 6px;
  margin: 0;
  padding: 2px 6px;
  color: #fff;
  background: #10151dbb;
  border-radius: 9px;
  pointer-events: none;
}
#telegramMessages .telegram-visual-media :is(.telegram-caption, a:not(:first-child)) {
  margin: 5px 0 0;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--ui-pane);
}
#telegramMessages .telegram-compact-media {
  width: fit-content;
  padding: 7px 9px;
}
#telegramMessages .telegram-compact-media > audio { width: min(250px, 62vw); height: 36px; }
#telegramMessages .telegram-compact-media > a { font-size: .875rem; }

/* Keep WhatsApp gallery and loading interactions while removing fixed media frames. */
#app[data-view='chats'] #messages .bubble[data-media-kind] .media-frame:is(.media-ready, .has-thumbnail) {
  display: block;
  width: fit-content;
  max-width: 100%;
  height: auto;
  aspect-ratio: auto;
  background: transparent;
}
#app[data-view='chats'] #messages .bubble[data-media-kind] .media-frame:is(.media-ready, .has-thumbnail) > img {
  width: auto;
  height: auto;
  max-width: min(100%, 435px);
  max-height: min(56dvh, 460px);
  object-fit: contain;
}
#app[data-view='chats'] #messages .bubble > audio {
  width: min(250px, 65vw);
  height: 36px;
}


#app[data-view='chats'][data-platform='telegram'] .telegram-composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
}
#app[data-view='chats'][data-platform='telegram'] .telegram-composer > input[name='text'] { width: 100%; }
.telegram-attach {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 1.1rem;
}
.telegram-attachment-draft {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: 12px;
  background: var(--ui-raised);
}
.telegram-attachment-draft img { width: 44px; height: 44px; object-fit: cover; border-radius: 7px; }
#telegramAttachmentName { grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#telegramRemoveAttachment { grid-column: 3; padding: 4px 9px; }

#app[data-view='chats'][data-platform='telegram'] .telegram-main > .telegram-composer {
  grid-template-columns: 36px minmax(0, 1fr) 36px 42px;
  column-gap: 4px;
  row-gap: 6px;
  min-height: 52px;
  padding: 5px 6px 5px 8px;
  border-radius: 24px;
}
#telegramComposer > #telegramAttach { grid-column: 1; }
#telegramComposer > input[name='text'] { grid-column: 2; padding: 7px 5px; }
#telegramComposer > #telegramEmojiButton { grid-column: 3; }
#telegramComposer > :is(#telegramVoiceStart, #telegramSendMessage) {
  grid-column: 4;
  justify-self: end;
}
#telegramComposer > :is(button, input[name='text']) { grid-row: 1; }
#telegramComposer:has(.telegram-attachment-draft:not([hidden])) > :is(button, input[name='text']) { grid-row: 2; }
#telegramComposer .telegram-attach span {
  position: relative;
  display: block;
  width: 11px;
  height: 19px;
  border: 1.8px solid currentColor;
  border-radius: 7px 7px 6px 6px;
  transform: rotate(37deg);
}
#telegramComposer .telegram-attach span::after {
  content: '';
  position: absolute;
  width: 3.8px;
  height: 10px;
  top: 3px;
  left: 1.6px;
  border: 1.5px solid currentColor;
  border-top: 0;
  border-radius: 0 0 5px 5px;
}
#telegramComposer .telegram-emoji-icon span { font: 25px/1 "Segoe UI Symbol", sans-serif; }
@media (max-width: 400px) {
  #app[data-view='chats'][data-platform='telegram'] .telegram-main > .telegram-composer {
    grid-template-columns: 33px minmax(0, 1fr) 33px 40px;
    column-gap: 2px;
  }
}
