.chat-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.chat-window {
  width: 100%;
  height: 100%;
  max-height: none;
  min-width: 0;
  min-height: 0;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: #101923;
  border-radius: 26px;
}

#chat-back {
  display: none;
  font-size: 20px;
  line-height: 1;
}

.chat-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--tg-border-color);
  background: linear-gradient(180deg, #223242, #1d2b38);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

#mark-resolved,
#mark-waiting {
  width: auto;
  min-width: 108px;
  justify-self: end;
  position: relative;
  z-index: 2;
  touch-action: manipulation;
}

#chat-profile-trigger.chat-user-btn {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  text-align: left;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

#chat-profile-trigger.chat-user-btn:hover {
  filter: none;
}

.chat-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #ef7f5a, #e2644d);
}

.chat-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chat-header-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

#chat-header-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 700;
}

.chat-header-subtitle {
  font-size: 12px;
  color: #7f94a8;
}

.chat-body {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.messages {
  min-width: 0;
  min-height: 0;
  block-size: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 16px;
  scroll-padding-bottom: calc(var(--composer-height) + 8px);
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.018), transparent 18%),
    radial-gradient(circle at 72% 76%, rgba(255, 255, 255, 0.018), transparent 22%),
    linear-gradient(180deg, rgba(11, 22, 34, 0.98), rgba(13, 22, 33, 0.98));
}

.messages > * {
  min-width: 0;
  flex: 0 0 auto;
}

.messages.is-short {
  justify-content: flex-end;
}

.user-detail-view {
  position: absolute;
  inset: 0;
  z-index: 96;
  display: grid;
  grid-template-rows: auto 1fr;
  background:
    radial-gradient(circle at top left, rgba(100, 168, 232, 0.08), transparent 24%),
    linear-gradient(180deg, #16212c, #111b24);
  transition: transform 180ms ease;
  border-radius: inherit;
  overflow: hidden;
}

.user-detail-view.is-dragging {
  transition: none;
}

.user-detail-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--tg-border-color);
  background: linear-gradient(180deg, #223242, #1c2a38);
}

.user-detail-header-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.user-detail-header-copy strong {
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-detail-content {
  overflow: auto;
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 0 0 20px;
}

.tg-profile-hero {
  position: relative;
  min-height: 220px;
  padding: 24px 18px 18px;
  background: linear-gradient(180deg, #8a5b3d, #b97244);
  overflow: hidden;
}

.tg-profile-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 18%, rgba(255,255,255,0.08), transparent 10%),
    radial-gradient(circle at 70% 14%, rgba(255,255,255,0.08), transparent 10%),
    radial-gradient(circle at 80% 40%, rgba(255,255,255,0.06), transparent 14%);
  opacity: 0.55;
  pointer-events: none;
}

.tg-profile-top {
  position: relative;
  min-height: 178px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.tg-profile-avatar-wrap {
  width: 104px;
  height: 104px;
}

.user-card-avatar,
.user-card-avatar-fallback {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
}

.user-card-avatar {
  object-fit: cover;
}

.user-card-avatar-fallback {
  display: grid;
  place-items: center;
  font-size: 36px;
  font-weight: 700;
  color: #fff;
}

.tg-profile-name {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
}

.tg-profile-status {
  font-size: 14px;
  color: rgba(255,255,255,0.8);
}

.tg-profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.profile-actions-row {
  display: flex;
  padding: 0 10px;
}

.profile-action-btn {
  min-height: 42px;
}

.tg-profile-section {
  margin: 0 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: #1f2c39;
  border: 1px solid rgba(255,255,255,0.04);
}

.tg-profile-stat {
  border-radius: 14px;
  background: #22303d;
  border: 1px solid rgba(255,255,255,0.04);
  padding: 10px;
}

.tg-profile-stat strong {
  display: block;
  font-size: 15px;
  margin-top: 2px;
  color: #fff;
}

.tg-profile-section-title {
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--tg-hint-color);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tg-profile-row {
  display: grid;
  gap: 3px;
  padding: 8px 0;
  border-top: 1px solid rgba(255,255,255,0.04);
}

.tg-profile-copy-row {
  width: 100%;
  border: none;
  border-top: 1px solid rgba(255,255,255,0.04);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: left;
  padding: 10px 0;
}

.tg-profile-copy-row:hover {
  filter: none;
  background: rgba(255, 255, 255, 0.02);
}

.tg-profile-row:first-of-type {
  border-top: none;
  padding-top: 0;
}

.tg-profile-row span {
  font-size: 11px;
  color: var(--tg-hint-color);
}

.tg-profile-row b {
  font-size: 13px;
  color: #fff;
  word-break: break-word;
}

.profile-error {
  color: #f0b7bf;
}

.msg {
  width: fit-content;
  max-width: min(74%, 560px);
  position: relative;
  padding: 9px 14px 7px;
  border-radius: 18px;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid rgba(255, 255, 255, 0.03);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.14);
}

.msg-text a {
  color: #8ac7ff;
  text-decoration: underline;
}

.msg-text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  padding: 1px 4px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
}

.msg-text pre {
  margin: 6px 0 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  overflow-x: auto;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.msg-data-copy-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.msg-data-copy-btn {
  width: 100%;
  min-height: 34px;
  display: grid;
  grid-template-columns: minmax(84px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 14, 22, 0.18);
  box-shadow: none;
  text-align: left;
  color: inherit;
}

.msg-data-copy-btn:hover,
.msg-data-copy-btn:active {
  filter: none;
  transform: none;
}

.msg-data-copy-key {
  color: var(--tg-hint-color);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-data-copy-value {
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-data-copy-hint {
  font-size: 11px;
  color: #8ac7ff;
}

.msg-data-copy-btn.copied {
  border-color: rgba(86, 168, 244, 0.9);
}

.msg-data-copy-btn.copy-error {
  border-color: rgba(217, 108, 123, 0.65);
}

.msg.has-media {
  width: fit-content;
  max-width: min(74%, 560px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 0 0 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  background: #182734;
  isolation: isolate;
  z-index: 2;
}

.msg.support.has-media,
.msg.admin.has-media {
  background: #2f5f8b;
}

.msg.has-media.media-with-text > .msg-media {
  order: 1;
}

.msg.has-media.media-with-text > .msg-text {
  order: 2;
  padding: 9px 14px 2px;
}

.msg-media {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: block;
}

.msg-media-image,
.msg-media-video {
  width: 100%;
  max-width: 100%;
  display: block;
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  background: #0f1a24;
}

.msg.user {
  align-self: flex-start;
  margin-right: auto;
  background: #182734;
  border-top-left-radius: 8px;
}

.msg.support,
.msg.admin {
  align-self: flex-end;
  margin-left: auto;
  background: #2f5f8b;
  border-top-right-radius: 8px;
}

.msg.system {
  align-self: center;
  max-width: 100%;
  background: rgba(33, 49, 65, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.04);
  color: #dfe7ef;
  font-size: 12px;
  padding: 5px 12px;
  box-shadow: none;
}

.msg-media-button {
  display: block;
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
  line-height: 0;
  position: relative;
  z-index: 1;
  isolation: isolate;
}

.msg-media-button-image {
  width: 100%;
  min-width: 0;
  min-height: 120px;
}

.msg-media-button-video {
  aspect-ratio: 16 / 9;
  max-height: min(46vh, 360px);
}

.msg-media-button:hover,
.msg-media-button:active {
  filter: none;
  transform: none;
}

.msg-media-button img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: min(56vh, 520px);
  object-fit: contain;
  border-radius: 0;
  background: #0f1a24;
}

.msg-media-button video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0c1721;
}

.msg-media-button-image.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.06));
  animation: media-loading 1.15s linear infinite;
}

.msg-media-button-image.is-error {
  display: grid;
  place-items: center;
  color: #9fb4c8;
  font-size: 13px;
  min-height: 120px;
  line-height: 1.3;
}

.msg-media-button-image.is-error::before {
  content: "Не удалось загрузить изображение";
  padding: 0 16px;
  text-align: center;
}

.msg-media-button-image.is-error img {
  display: none;
}

.msg-media-badge {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(7, 14, 23, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}

@keyframes media-loading {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.file-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 6px 14px 0;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: #8ac7ff;
  text-decoration: none;
  box-shadow: none;
}

.msg-audio {
  width: calc(100% - 20px);
  min-width: 220px;
  margin: 8px 10px 2px;
}

.file-link:hover,
.file-link:active {
  filter: none;
  transform: none;
}

.msg small {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 6px;
  padding: 0 2px;
  font-size: 11px;
  color: rgba(230, 237, 243, 0.66);
  position: static;
  z-index: auto;
  pointer-events: auto;
  line-height: 1;
}

.msg.has-media small {
  order: 3;
  width: auto;
  min-width: 0;
  margin: 4px 10px 0 auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  position: relative;
  z-index: 2;
  pointer-events: none;
}

.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: block;
  padding: 0;
  --media-viewer-dy: 0px;
}

.media-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 14, 23, 0.86);
  backdrop-filter: blur(12px);
}

.media-viewer-card {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
  padding: 10px 12px 8px;
  background: transparent;
  transform: translateY(var(--media-viewer-dy));
  transition: transform 180ms ease;
}

.media-viewer.is-dragging .media-viewer-card {
  transition: none;
}

.media-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 0 10px;
}

.media-viewer.is-image .media-viewer-head {
  justify-content: flex-end;
}

.media-viewer-title {
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  color: #f1f6fb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-viewer-body {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 0;
}

.media-viewer-image {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 56px);
  border-radius: 0;
  object-fit: contain;
}

.media-viewer-video {
  width: min(100%, 920px);
  max-height: calc(100dvh - 120px);
  background: #000;
}

.media-viewer-audio {
  width: min(480px, 100%);
}

.media-viewer-file {
  width: min(420px, 100%);
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
}

.media-viewer-file-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(100,168,232,0.18);
  font-size: 22px;
}

.media-viewer-file-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.media-viewer-file-copy strong,
.media-viewer-file-copy span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-viewer-file-copy span {
  color: var(--tg-hint-color);
  font-size: 12px;
}

.media-viewer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.media-viewer-link,
.media-viewer-download {
  width: auto;
  min-width: 112px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.media-viewer-download {
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--tg-button-color);
  color: var(--tg-button-text-color);
}

.media-viewer-actions .ghost-btn,
.media-viewer-actions .media-viewer-download {
  min-height: 42px;
}

.msg-delivery {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  color: #8fd0ff;
  transform: translateY(-0.5px);
}

.reply-form {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  padding: 12px 14px;
  border-top: 1px solid var(--tg-border-color);
  background: #182533;
  flex: 0 0 auto;
  min-height: 56px;
}

.reply-compose {
  display: grid;
  gap: 6px;
  min-width: 0;
  position: relative;
}

.reply-form :is(textarea, #message-input) {
  min-height: 44px;
  max-height: 132px;
  padding: 11px 16px;
  line-height: 1.35;
  background: #243447;
  border-radius: 22px;
  overflow-y: auto;
}

#reply-submit {
  height: 44px;
  min-width: 96px;
  padding: 0 18px;
  background: var(--tg-button-color);
}

#reply-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.clip-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--tg-border-color);
  background: #243447;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  color: var(--tg-hint-color);
  font-size: 20px;
  line-height: 1;
}

.reply-attachment-meta {
  padding: 0 8px;
  color: #9fb4c8;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-reply-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  display: grid;
  gap: 4px;
  padding: 8px;
  border-radius: 16px;
  background: rgba(22, 35, 49, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
  max-height: 220px;
  overflow: auto;
  z-index: 24;
}

.quick-reply-suggestion {
  width: 100%;
  min-width: 0;
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(96px, 120px) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.015);
  box-shadow: none;
  text-align: left;
  color: var(--tg-text-color);
  overflow: hidden;
  isolation: isolate;
  cursor: pointer;
}

.quick-reply-suggestion:hover {
  filter: none;
  background: rgba(255, 255, 255, 0.015);
  border-color: rgba(255, 255, 255, 0.07);
}

.quick-reply-suggestion.active {
  filter: none;
  background: rgba(255, 255, 255, 0.015);
  border-color: rgba(88, 155, 221, 0.98);
  box-shadow: inset 0 0 0 1px rgba(88, 155, 221, 0.42);
}

.quick-reply-suggestion-key {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #8cc9ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.quick-reply-suggestion-text {
  display: block;
  font-size: 12px;
  color: var(--tg-hint-color);
  line-height: 1.35;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
}

.reply-upload-progress {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.reply-upload-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #56a8f4, #8fd0ff);
  transition: width 140ms linear;
}
