@view-transition {
  navigation: auto;
}

:root {
  view-transition-name: none;
}

::view-transition-old(chat-sidebar),
::view-transition-new(chat-sidebar),
::view-transition-group(chat-sidebar) {
  animation: none;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Roboto, sans-serif;
  min-height: 100dvh;
  background-image:
    linear-gradient(135deg, #3b70a4, #32b8d5, #f9d960, #f1dfcb),
    url(/pattern.svg);
  background-position: center center, center center;
  background-size: cover, 420px;
  background-repeat: no-repeat, repeat;
  overflow: hidden;
}

.tgme_background_wrap {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.tgme_background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: linear-gradient(135deg, #3b70a4, #32b8d5, #f9d960, #f1dfcb);
}

.tgme_background_pattern {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  mix-blend-mode: overlay;
  opacity: 0.3;
  background: url(/pattern.svg) center center / 420px repeat;
}

.tgme_head_wrap {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 54px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
}

.tgme_head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 34px;
  max-width: 1024px;
  margin: 0 auto;
}

.tgme_head_brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #0088cc;
}

.tgme_head_brand svg {
  width: 34px;
  height: 34px;
}

.tgme_head_brand_name {
  font-size: 18px;
  font-weight: 700;
  color: #000;
}

.tgme_page_wrap {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 54px 16px 16px;
}

.tgme_page {
  background: #fff;
  border-radius: 16px;
  padding: 32px 0;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  width: 400px;
  max-width: 100%;
}

.tgme_page_photo {
  padding: 0 0 16px;
}

.tgme_page_photo_image {
  width: 122px;
  height: 122px;
  border-radius: 61px;
  object-fit: cover;
}

.tgme_page_title {
  font-size: 26px;
  font-weight: 700;
  line-height: 32px;
  color: #000;
  padding: 0 10px;
  margin: 0 30px;
}

.tgme_page_extra {
  font-size: 15px;
  color: #7d7f81;
  padding: 6px 16px 0;
}

.tgme_page_description {
  font-size: 16px;
  line-height: 25px;
  color: #000;
  margin: 10px 16px 0;
}

.tgme_page_action {
  margin: 24px 0 0;
}

@keyframes bg-move {
  0% { background-position: -500px 0; }
  100% { background-position: 1000px 0; }
}

.tgme_action_button_new {
  display: inline-block;
  padding: 13px 24px;
  border-radius: 22px;
  border: none;
  background-color: #2481cc;
  background-image: linear-gradient(270deg, rgba(100, 181, 239, 0) 48.44%, rgb(100, 181, 239) 75.52%, rgba(100, 181, 239, 0) 100%);
  background-repeat: no-repeat;
  animation: bg-move 5s linear infinite;
  color: #fff;
  font-family: Roboto, sans-serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 17px;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
}

.tgme_action_button_new:hover {
  background-color: #1d6fad;
}

@media (max-width: 480px) {
  .tgme_page {
    width: 100%;
    border-radius: 12px;
  }
}

/* ── Chat layout ── */

.chat-sidebar {
  width: 400px;
  max-width: 100%;
  height: 100dvh;
  background: #fff;
  display: flex;
  flex-direction: column;
  view-transition-name: chat-sidebar;
}

.chat-sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  height: 54px;
  flex-shrink: 0;
}

.chat-sidebar-menu {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-sidebar-menu:hover {
  background: #f0f0f0;
}

.chat-sidebar-search {
  flex: 1;
  height: 40px;
  background: #f0f2f5;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
}

.chat-sidebar-search-icon {
  flex-shrink: 0;
}

.chat-sidebar-search-text {
  font-size: 14px;
  color: #9e9e9e;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

a.chat-item {
  text-decoration: none;
  color: inherit;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-item:hover {
  background: #f0f2f5;
}

.chat-item--selected {
  background: #3390ec;
}

.chat-item--selected:hover {
  background: #3390ec;
}

.chat-item--selected .chat-item-name,
.chat-item--selected .chat-item-time,
.chat-item--selected .chat-item-preview,
.chat-item--selected .chat-item-sender {
  color: #fff;
}

.chat-item--selected .chat-item-type-icon path {
  fill: #fff;
}

.chat-item--selected .chat-item-time--unread {
  color: #fff;
}

.chat-item-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-item-name-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.chat-item-type-icon {
  flex-shrink: 0;
}

.chat-item-name {
  font-size: 15px;
  font-weight: 700;
  color: #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-time {
  font-size: 12px;
  color: #9e9e9e;
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-item-time--unread {
  color: #3390ec;
}

.chat-item-preview {
  font-size: 14px;
  color: #757575;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.chat-item-sender {
  color: #3390ec;
  font-weight: 500;
}

.chat-item--selected .chat-item-sender {
  color: #fff;
}

.chat-item-badge {
  background: #3390ec;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  flex-shrink: 0;
}

.chat-item--selected .chat-item-badge {
  background: #fff;
  color: #3390ec;
}

.chat-item-badge--muted {
  background: #9e9e9e;
}

.chat-item--selected .chat-item-badge--muted {
  background: #fff;
  color: #9e9e9e;
}

.chat-item-muted-icon {
  flex-shrink: 0;
}

.chat-layout {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

.chat-main {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #3b70a4, #32b8d5, #f9d960, #f1dfcb);
}

.chat-main-content {
  flex: 1;
  min-height: 0;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

.chat-main .tgme_background_wrap {
  position: absolute;
}

.chat-main-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.chat-main-empty-text {
  background: rgba(0, 0, 0, 0.12);
  color: #fff;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 16px;
}

.chat-main-header {
  height: 54px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.chat-main-header-back {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
}

.chat-main-header-back:hover {
  background: #f0f0f0;
}

.chat-main-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-main-header-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.chat-main-header-name {
  font-size: 15px;
  font-weight: 700;
  color: #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-main-header-status {
  font-size: 13px;
  color: #9e9e9e;
}

.chat-main-header-actions {
  display: flex;
  gap: 4px;
}

.chat-main-header-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
}

.chat-main-header-btn:hover {
  background: #f0f0f0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 0;
}

.chat-messages-inner {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-date-separator {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

.chat-date-label {
  background: rgba(0, 0, 0, 0.12);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 12px;
}

.chat-bubble {
  max-width: 480px;
  padding: 6px 10px 4px;
  border-radius: 12px;
  position: relative;
  line-height: 1.4;
  word-wrap: break-word;
}

.chat-bubble--in {
  background: #fff;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.chat-bubble--out {
  background: #eeffde;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.chat-bubble-sender {
  font-size: 13px;
  font-weight: 700;
  color: #3390ec;
  margin-bottom: 2px;
}

.chat-reply-preview {
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
}

.chat-reply-preview-stripe {
  width: 3px;
  border-radius: 999px;
  background: #3390ec;
  flex-shrink: 0;
}

.chat-reply-preview-body {
  min-width: 0;
  flex: 1;
}

.chat-reply-preview-sender {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  color: #3390ec;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-reply-preview-text {
  font-size: 14px;
  line-height: 1.2;
  color: #5f6c7b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-reply-preview-thumb {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-reply-preview-thumb--sticker {
  object-fit: contain;
}

.chat-bubble--out .chat-reply-preview-stripe {
  background: #5cb067;
}

.chat-bubble--out .chat-reply-preview-sender {
  color: #4c9b5a;
}

.chat-bubble--out .chat-reply-preview-text {
  color: #66816d;
}

.chat-bubble-text {
  font-size: 15px;
  color: #000;
}

.chat-bubble-link {
  color: #1f75cc;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  word-break: break-word;
}

.chat-bubble--out .chat-bubble-link {
  color: #0f5e2f;
}

.chat-link-previews {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.chat-link-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding-left: 10px;
  border-left: 3px solid #3390ec;
  color: inherit;
  text-decoration: none;
}

.chat-link-preview-link {
  color: inherit;
  text-decoration: none;
}

.chat-link-preview:hover {
  opacity: 0.92;
}

.chat-link-preview--loading {
  min-height: 48px;
  border-left-style: dashed;
}

.chat-bubble--out .chat-link-preview {
  border-left-color: #59b86e;
}

.chat-bubble--out .chat-link-preview:hover {
  opacity: 0.92;
}

.chat-link-preview-media {
  display: block;
  width: min(320px, 100%);
  max-height: 220px;
  object-fit: cover;
  border-radius: 10px;
  background: linear-gradient(180deg, #edf4fb, #dbe6f2);
}

.chat-link-preview-youtube-trigger {
  position: relative;
  display: block;
  width: fit-content;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.chat-link-preview-youtube-trigger::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: rgba(11, 16, 24, 0.2);
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.chat-link-preview-youtube-trigger .chat-link-preview-media {
  filter: saturate(0.6) contrast(0.92) brightness(0.88);
  transition:
    filter 0.18s ease,
    transform 0.18s ease;
}

.chat-link-preview-youtube-trigger:hover::before {
  opacity: 0;
}

.chat-link-preview-youtube-trigger:hover .chat-link-preview-media {
  filter: saturate(1) contrast(1) brightness(1);
}

.chat-link-preview-youtube-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 42px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.74);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  transition:
    transform 0.18s ease,
    background 0.18s ease;
}

.chat-link-preview-youtube-trigger:hover .chat-link-preview-youtube-play {
  transform: translate(-50%, -50%) scale(1.06);
  background: rgba(0, 0, 0, 0.84);
}

.chat-link-preview-embed {
  display: block;
  width: min(320px, 100%);
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 10px;
  background: #000;
}

.chat-link-preview-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-link-preview-site {
  color: #2b7fd0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.chat-bubble--out .chat-link-preview-site {
  color: #368f4f;
}

.chat-link-preview-title {
  color: #182230;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.chat-bubble--out .chat-link-preview-title {
  color: #1d381e;
}

.chat-link-preview-description {
  color: #4e5d6d;
  font-size: 13px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chat-bubble--out .chat-link-preview-description {
  color: #5a6d58;
}

.chat-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
}

.chat-bubble-time {
  font-size: 11px;
  color: #5cb067;
}

.chat-bubble--in .chat-bubble-time {
  color: #9e9e9e;
}

.chat-bubble-check {
  color: #5cb067;
  flex-shrink: 0;
}

.chat-bubble-image,
video.chat-bubble-image {
  display: block;
  width: 100%;
  outline: none;
}

.chat-bubble-audio {
  display: block;
  width: min(320px, 100%);
  margin: 4px 0 2px;
}

.chat-bubble-image.chat-media-fallback,
video.chat-bubble-image.chat-media-fallback,
.chat-sticker-image.chat-media-fallback {
  background: linear-gradient(180deg, #eef4f8, #d8e2ec);
  object-fit: contain;
}

.chat-bubble-image.chat-media-suspended,
video.chat-bubble-image.chat-media-suspended,
.chat-sticker-image.chat-media-suspended {
  visibility: hidden;
  pointer-events: none;
}

video.chat-bubble-image.chat-media-fallback {
  aspect-ratio: 4 / 3;
}

.chat-bubble--media {
  padding: 0;
  overflow: hidden;
  width: fit-content;
  min-width: 200px;
  max-width: 320px;
}

.chat-bubble--media .chat-bubble-meta {
  position: absolute;
  bottom: 8px;
  right: 10px;
}

.chat-bubble--media .chat-bubble-time {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.chat-bubble--media .chat-bubble-check {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.chat-bubble-caption {
  padding: 6px 10px 4px;
  width: 0;
  min-width: 100%;
  box-sizing: border-box;
}

.chat-document {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
  max-width: 320px;
  padding: 6px 0 2px;
  color: inherit;
  text-decoration: none;
}

.chat-document-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(180deg, #5ea8ff, #3975d6);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.chat-document-meta {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.chat-document-name {
  color: #000;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-document-detail {
  color: #7f8a96;
  font-size: 12px;
  line-height: 1.3;
}

.chat-bubble--captioned .chat-bubble-meta {
  position: static;
}

.chat-bubble--captioned .chat-bubble-time {
  color: inherit;
  text-shadow: none;
}

.chat-bubble--captioned .chat-bubble-check {
  color: inherit;
  text-shadow: none;
}

.chat-sticker {
  max-width: 200px;
  position: relative;
}

.chat-sticker--in {
  align-self: flex-start;
}

.chat-sticker--out {
  align-self: flex-end;
}

.chat-sticker-image {
  width: 200px;
  height: auto;
  display: block;
}

.chat-sticker-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.chat-sticker-inner > .chat-reply-preview {
  width: 100%;
  max-width: 180px;
  padding: 6px 8px;
  margin-bottom: 2px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.chat-sticker-image.chat-media-fallback {
  aspect-ratio: 1 / 1;
}

.chat-sticker-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: -2px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  padding: 2px 8px;
  width: fit-content;
  margin-left: auto;
}

.chat-sticker-meta .chat-bubble-time {
  color: #fff;
}

.chat-sticker-meta .chat-bubble-check {
  color: #fff;
}

/* Content wrapper — transparent for non-icon bubbles */
.chat-bubble-content {
  min-width: 0;
}

/* Sender icon – always visible in groups, responsive in DMs */
.chat-bubble-icon {
  display: block;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  align-self: flex-end;
}

.chat-bubble-icon--fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

.chat-bubble-icon--dm {
  display: none;
}

.chat-bubble-icon--placeholder {
  visibility: hidden;
}

.chat-bubble.chat-bubble--has-icon {
  display: flex;
  gap: 8px;
  background: none !important;
  box-shadow: none !important;
  padding: 0;
  border-radius: 0;
}

.chat-bubble--has-icon > .chat-bubble-content {
  background: #fff;
  padding: 6px 10px 4px;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  min-width: 0;
  max-width: 480px;
}

.chat-bubble--has-icon.chat-bubble--media > .chat-bubble-content {
  padding: 0;
  overflow: hidden;
  width: fit-content;
  min-width: 200px;
  max-width: 320px;
}

.chat-bubble--has-icon.chat-bubble--media > .chat-bubble-content > .chat-bubble-sender {
  padding: 6px 10px 2px;
}

.chat-bubble--has-icon.chat-bubble--captioned > .chat-bubble-content .chat-bubble-caption {
  padding: 6px 10px 4px;
}

.chat-sticker--has-icon {
  display: flex;
  gap: 8px;
}

.chat-sticker--has-icon > .chat-bubble-icon {
  align-self: flex-end;
}

.chat-sticker--has-icon > .chat-bubble-icon.chat-bubble-icon--dm {
  display: none;
}

@media (min-width: 1120px) {
  .chat-bubble-icon--dm {
    display: block;
  }
  .chat-sticker--has-icon > .chat-bubble-icon.chat-bubble-icon--dm {
    display: block;
  }
}

.chat-input-bar {
  position: relative;
  z-index: 2;
  padding: 8px;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.chat-input-bar-field {
  flex: 1;
  height: 40px;
  font-size: 15px;
  font-family: Roboto, sans-serif;
  color: #9e9e9e;
  padding: 0 8px;
  display: flex;
  align-items: center;
}

.chat-input-bar-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
}

.chat-input-bar-btn:hover {
  background: #f0f0f0;
}

.chat-channel-footer {
  position: relative;
  z-index: 2;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  text-align: center;
  cursor: pointer;
}

.chat-channel-footer-text {
  font-size: 14px;
  color: #9e9e9e;
}

.chat-scroll-loader {
  display: flex;
  justify-content: center;
  padding: 12px 0;
}

.chat-scroll-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: #3390ec;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.lightbox-trigger {
  cursor: pointer;
}

.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: background 0.25s ease, opacity 0.25s ease;
}

.lightbox-overlay--open {
  opacity: 1;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.85);
}

.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  transform: scale(0.9);
  transition: transform 0.25s ease;
}

.lightbox-overlay--open .lightbox-content {
  transform: scale(1);
}

.lightbox-content img,
.lightbox-content video {
  display: block;
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  transition: background 0.15s;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background 0.15s, opacity 0.15s;
  z-index: 1001;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-nav--prev {
  left: 16px;
}

.lightbox-nav--next {
  right: 16px;
}

.lightbox-nav-spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.lightbox-nav--loading {
  cursor: default;
  opacity: 0.5;
}

.lightbox-nav--loading .lightbox-nav-icon {
  display: none;
}

.lightbox-nav--loading .lightbox-nav-spinner {
  display: block;
}

.profile-toggle-input {
  display: none;
}

.chat-profile-panel {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  padding: 16px;
}

.chat-profile-backdrop {
  position: absolute;
  inset: 0;
  cursor: pointer;
}

.chat-profile-panel .tgme_page {
  position: relative;
  z-index: 1;
}

.profile-toggle-input:checked ~ .chat-profile-panel {
  display: flex;
}

.sidebar-toggle-input {
  display: none;
}

@media (max-width: 480px) {
  .chat-sidebar {
    width: 100%;
    border-right: none;
  }
}

@media (max-width: 900px) {
  .chat-main-header-back {
    display: flex;
    cursor: pointer;
  }

  .chat-layout:not(.chat-layout--open) .chat-main {
    display: none;
  }

  .chat-layout:not(.chat-layout--open) .chat-sidebar {
    width: 100%;
  }

  .chat-layout--open .chat-sidebar {
    display: none;
  }

  .sidebar-toggle-input:checked ~ .chat-sidebar {
    display: flex;
    width: 100%;
  }

  .sidebar-toggle-input:checked ~ .chat-main {
    display: none;
  }
}

/* ── Scroll-to-bottom button ── */

.scroll-to-bottom {
  position: absolute;
  bottom: 66px;
  right: 24px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9e9e9e;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.scroll-to-bottom--visible {
  opacity: 1;
  pointer-events: auto;
}

.scroll-to-bottom:hover {
  background: #f5f5f5;
}

.chat-scroll-gap {
  height: 0;
}

/* ── Dark mode ── */

@media (prefers-color-scheme: dark) {
  body {
    background-color: #000;
    background-image: url(/pattern.svg);
    background-blend-mode: normal;
  }

  .tgme_background_wrap {
    background: #000;
  }

  .tgme_background {
    mask-image: url(/pattern.svg);
    mask-size: 420px;
    mask-repeat: repeat;
    -webkit-mask-image: url(/pattern.svg);
    -webkit-mask-size: 420px;
    -webkit-mask-repeat: repeat;
    opacity: 0.5;
  }

  .tgme_background_pattern {
    display: none;
  }

  .tgme_head_wrap {
    background: rgba(33, 33, 33, 0.84);
  }

  .tgme_head_brand_name {
    color: #e0e0e0;
  }

  .tgme_page {
    background: #212121;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  }

  .tgme_page_title {
    color: #e0e0e0;
  }

  .tgme_page_extra {
    color: #8e8e8e;
  }

  .tgme_page_description {
    color: #ccc;
  }

  .chat-sidebar {
    background: #212121;
  }

  .chat-sidebar-menu:hover {
    background: #333;
  }

  .chat-sidebar-search {
    background: #181818;
  }

  .chat-sidebar-search-text {
    color: #757575;
  }

  .chat-item:hover {
    background: #2c2c2c;
  }

  .chat-item--selected {
    background: #766ac8;
  }

  .chat-item--selected:hover {
    background: #766ac8;
  }

  .chat-item-name {
    color: #e0e0e0;
  }

  .chat-item-time {
    color: #757575;
  }

  .chat-item-preview {
    color: #8e8e8e;
  }

  .chat-item-sender {
    color: #766ac8;
  }

  .chat-item--selected .chat-item-sender {
    color: #fff;
  }

  .chat-item-time--unread {
    color: #766ac8;
  }

  .chat-item-badge {
    background: #766ac8;
  }

  .chat-item--selected .chat-item-badge {
    background: #fff;
    color: #766ac8;
  }

  .chat-main {
    background: #000;
  }

  .chat-main .tgme_background_wrap {
    background: #000;
  }

  .chat-main .tgme_background {
    mask-image: url(/pattern.svg);
    mask-size: 420px;
    mask-repeat: repeat;
    -webkit-mask-image: url(/pattern.svg);
    -webkit-mask-size: 420px;
    -webkit-mask-repeat: repeat;
    opacity: 0.5;
  }

  .chat-main .tgme_background_pattern {
    display: none;
  }

  .chat-main-header {
    background: #212121;
    border-bottom-color: #333;
  }

  .chat-main-header-back:hover {
    background: #333;
  }

  .chat-main-header-name {
    color: #e0e0e0;
  }

  .chat-main-header-status {
    color: #757575;
  }

  .chat-main-header-btn:hover {
    background: #333;
  }

  .chat-bubble--in {
    background: #212121;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  }

  .chat-bubble--has-icon > .chat-bubble-content {
    background: #212121;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  }

  .chat-bubble--out {
    background: #2b5278;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  }

  .chat-bubble-sender {
    color: #766ac8;
  }

  .chat-reply-preview-stripe {
    background: #766ac8;
  }

  .chat-reply-preview-sender {
    color: #766ac8;
  }

  .chat-reply-preview-text {
    color: #98a6b7;
  }

  .chat-bubble--out .chat-reply-preview-stripe {
    background: #6eb4e6;
  }

  .chat-bubble--out .chat-reply-preview-sender {
    color: #8ec9f1;
  }

  .chat-bubble--out .chat-reply-preview-text {
    color: #c7d8e6;
  }

  .chat-bubble-text {
    color: #e0e0e0;
  }

  .chat-bubble-link {
    color: #7fc8ff;
  }

  .chat-bubble--out .chat-bubble-link {
    color: #93f0bc;
  }

  .chat-link-preview {
    border-left-color: #6dbaf0;
  }

  .chat-link-preview:hover {
    opacity: 0.92;
  }

  .chat-bubble--out .chat-link-preview {
    border-left-color: #8fd6a2;
  }

  .chat-bubble--out .chat-link-preview:hover {
    opacity: 0.92;
  }

  .chat-link-preview-media {
    background: linear-gradient(180deg, #31455d, #223242);
  }

  .chat-link-preview-site {
    color: #8fc8f3;
  }

  .chat-bubble--out .chat-link-preview-site {
    color: #a8dfb7;
  }

  .chat-link-preview-title {
    color: #eef6ff;
  }

  .chat-bubble--out .chat-link-preview-title {
    color: #f0fbf4;
  }

  .chat-link-preview-description {
    color: #b1c1d2;
  }

  .chat-bubble--out .chat-link-preview-description {
    color: #d3e5d8;
  }

  .chat-bubble-time {
    color: #6eb4e6;
  }

  .chat-bubble--in .chat-bubble-time {
    color: #757575;
  }

  .chat-bubble-check {
    color: #6eb4e6;
  }

  .chat-sticker-inner > .chat-reply-preview {
    background: rgba(33, 33, 33, 0.9);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  }

  .chat-bubble--captioned .chat-bubble-time {
    color: inherit;
  }

  .chat-bubble--captioned .chat-bubble-check {
    color: inherit;
  }

  .chat-document-name {
    color: #e0e0e0;
  }

  .chat-document-detail {
    color: #8e8e8e;
  }

  .chat-input-bar {
    background: #212121;
    border-top-color: #333;
  }

  .chat-input-bar-field {
    color: #757575;
  }

  .chat-input-bar-btn:hover {
    background: #333;
  }

  .chat-channel-footer {
    background: #212121;
    border-top-color: #333;
  }

  .chat-channel-footer-text {
    color: #757575;
  }

  .chat-scroll-spinner {
    border-color: rgba(255, 255, 255, 0.1);
    border-top-color: #766ac8;
  }

  .chat-profile-panel {
    background: rgba(0, 0, 0, 0.6);
  }

  .chat-profile-panel .tgme_page {
    background: #212121;
  }

  .chat-profile-panel .tgme_page_title {
    color: #e0e0e0;
  }

  .chat-profile-panel .tgme_page_extra {
    color: #8e8e8e;
  }

  .chat-profile-panel .tgme_page_description {
    color: #ccc;
  }

  .chat-sidebar-menu svg path,
  .chat-sidebar-search-icon svg path {
    fill: #8e8e8e;
  }

  .chat-main-header-back svg path,
  .chat-main-header-btn svg path {
    fill: #8e8e8e;
  }

  .chat-input-bar-btn svg path,
  .chat-input-bar-btn svg circle {
    fill: #8e8e8e;
    stroke: #8e8e8e;
  }

  .scroll-to-bottom {
    background: #212121;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    color: #8e8e8e;
  }

  .scroll-to-bottom:hover {
    background: #2c2c2c;
  }
}
