.chat-shell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100%;
  min-height: 0;
  padding: 4px 6px 0;
  box-sizing: border-box;
  overflow-x: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 4px 8px;
  border: 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  min-width: 0;
}

.chat-head-main {
  min-width: 0;
  flex: 1;
}

.chat-title {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
}

.chat-subtitle {
  margin-top: 2px;
  font-size: 9px;
  color: #64748b;
  line-height: 1.25;
}

.chat-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-head-btn,
.chat-send-btn,
.chat-more-btn {
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.chat-head-btn-compact {
  min-width: 44px;
  padding: 7px 10px;
}

.chat-head-btn,
.chat-more-btn {
  background: #eef3f8;
  color: #334155;
}

.chat-send-btn {
  background: #229ed9;
  color: #fff;
  box-shadow: 0 8px 16px rgba(34, 158, 217, 0.22);
}

.chat-status {
  display: block;
  min-height: 20px;
  padding: 2px 4px 4px;
  border-radius: 0;
  background: transparent;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  visibility: hidden;
}

.chat-status.is-error {
  color: #b91c1c;
}

.chat-link-input {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: #0f172a;
  font: inherit;
}

.chat-filter-row,
.chat-context-row,
.chat-link-types,
.chat-link-actions,
.chat-message-actions,
.chat-pins-track {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-context-row {
  min-height: 0;
}

.chat-filter-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.chat-filter-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 15;
  min-width: 160px;
  gap: 4px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.chat-filter-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #334155;
  text-align: left;
  padding: 9px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.chat-filter-menu-item.is-active {
  background: #ecfeff;
  color: #0f766e;
}

.chat-filter-menu-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: inherit;
  font-size: 11px;
  font-weight: 800;
}

.chat-filter-caret {
  font-size: 11px;
  line-height: 1;
}

.chat-mini-chip,
.chat-mini-btn,
.chat-action-btn,
.chat-inline-link,
.chat-reply-preview {
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
  color: #334155;
  border-radius: 999px;
  font: inherit;
}

.chat-mini-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  flex: 0 0 auto;
}

.chat-mini-chip.is-active {
  background: linear-gradient(180deg, #ecfeff, #cffafe);
  color: #0f766e;
  border-color: rgba(13, 148, 136, 0.24);
  box-shadow: 0 6px 14px rgba(13, 148, 136, 0.08);
}

.chat-mini-chip-count {
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: inherit;
  font-size: 11px;
  font-weight: 800;
}

.chat-pins {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 0 6px;
  border-radius: 0;
  border: 0;
  background: transparent;
}

.chat-pins-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-pins-title {
  font-size: 11px;
  font-weight: 800;
  color: #0f172a;
}

.chat-pins-count {
  font-size: 11px;
  font-weight: 800;
  color: #475569;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 3px 8px;
}

.chat-pins-track {
  flex-wrap: wrap;
  overflow: hidden;
  padding-bottom: 2px;
}

.chat-pin-card {
  min-width: 150px;
  max-width: 210px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 8px 10px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.chat-pin-author {
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
}

.chat-pin-text,
.chat-pin-link {
  font-size: 12px;
  color: #475569;
  line-height: 1.3;
}

.chat-pin-link {
  color: #0f766e;
  font-weight: 700;
}

.chat-history-wrap {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-x: hidden;
}

.chat-history {
  min-height: 0;
  flex: 1;
  overflow: auto;
  overflow-x: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 8px 0 6px;
  box-shadow: none;
  overscroll-behavior: contain;
  contain: layout paint style;
}

.chat-row {
  display: flex;
  margin-bottom: 6px;
}

.chat-row.other {
  justify-content: flex-start;
}

.chat-row.mine {
  justify-content: flex-end;
}

.chat-row.ai {
  justify-content: flex-start;
}

.chat-empty {
  height: 100%;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #94a3b8;
  font-weight: 600;
}

.chat-message {
  width: min(720px, 100%);
  max-width: 720px;
  padding: 8px 10px;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.04);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  box-sizing: border-box;
  min-width: 0;
  overflow: hidden;
}

.chat-row.other .chat-message,
.chat-row.ai .chat-message {
  width: auto;
  max-width: min(74%, 440px);
  border-top-left-radius: 10px;
}

.chat-row.mine .chat-message {
  width: auto;
  max-width: min(72%, 440px);
  border-bottom-right-radius: 10px;
}

.chat-message.mine {
  background: linear-gradient(180deg, #e8f5ff, #d8eeff);
  border-color: rgba(34, 158, 217, 0.2);
  box-shadow: 0 4px 14px rgba(34, 158, 217, 0.1);
}

.chat-message.guest {
  border-left: 4px solid #fb923c;
}

.chat-message.ai {
  background: linear-gradient(180deg, #f8fafc, #eef2ff);
  border-color: rgba(99, 102, 241, 0.22);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.08);
}

.chat-message.is-pinned {
  border-color: rgba(245, 158, 11, 0.24);
  box-shadow: 0 12px 30px rgba(245, 158, 11, 0.08);
}

.chat-message.is-pending {
  opacity: 0.78;
}

.chat-row.is-mentioned .chat-message {
  border-color: rgba(16, 185, 129, 0.28);
}

.chat-row.has-card {
  justify-content: stretch;
}

.chat-row.has-card .chat-message {
  width: 100%;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.chat-message-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 5px;
}

.chat-author {
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
}

.chat-message.mine .chat-author {
  color: #047857;
}

.chat-message.ai .chat-author {
  color: #3730a3;
}

.chat-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-badge.staff {
  background: #dbeafe;
  color: #1d4ed8;
}

.chat-badge.admin {
  background: #ede9fe;
  color: #6d28d9;
}

.chat-badge.guest {
  background: #ffedd5;
  color: #c2410c;
}

.chat-badge.ai {
  background: #e0e7ff;
  color: #4338ca;
}

.chat-ts {
  font-size: 10px;
  color: #94a3b8;
}

.chat-pin-mark {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff7ed;
  color: #c2410c;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: #1e293b;
  line-height: 1.45;
  font-size: 13px;
}

.chat-reply-preview {
  width: 100%;
  margin-bottom: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  cursor: pointer;
  text-align: left;
  background: #f8fafc;
  border-radius: 12px;
}

.chat-reply-preview-author {
  font-size: 11px;
  font-weight: 800;
  color: #0f172a;
}

.chat-reply-preview-text {
  font-size: 12px;
  color: #64748b;
  line-height: 1.3;
}

.chat-inline-link {
  margin-top: 8px;
  padding: 7px 11px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: #0f766e;
  background: #ecfeff;
  border-color: rgba(13, 148, 136, 0.18);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-card-preview {
  width: 100%;
  margin-top: 8px;
  padding: 0;
  display: grid;
  gap: 0;
  border-radius: 20px;
  border: 1px solid #d8e0eb;
  background: #fff;
  box-shadow: 0 8px 18px rgba(13, 32, 66, 0.06);
  box-sizing: border-box;
  min-width: 0;
}

.chat-card-preview.is-red {
  border-color: rgba(220, 38, 38, 0.38);
  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.08);
}

.chat-card-preview.is-yellow {
  border-color: rgba(217, 119, 6, 0.34);
  box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.08);
}

.chat-card-preview.is-green {
  border-color: rgba(5, 150, 105, 0.34);
  box-shadow: inset 0 0 0 1px rgba(5, 150, 105, 0.08);
}

.chat-card-preview-main {
  width: 100%;
  padding: 0;
  display: block;
  text-align: left;
  cursor: pointer;
  border: 0;
  background: transparent;
}

.chat-work-card {
  width: 100%;
  margin-top: 0;
}

.chat-work-card .card-body {
  cursor: pointer;
}

.chat-work-card .card-name {
  -webkit-line-clamp: 3;
}

.chat-card-bottom-bar.bottom-bar {
  margin: 0 14px 14px;
}

.chat-card-bottom-bar .qty-control {
  width: auto;
  min-width: 0;
  flex: 1 1 0;
}

.chat-card-bottom-bar .chat-card-fact-input {
  min-width: 0;
}

.chat-card-bottom-bar .chat-card-fact-save {
  flex: 1 1 0;
}

.chat-card-preview-media {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
}

.chat-card-preview-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

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

.chat-card-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.chat-card-preview-sku {
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
}

.chat-card-preview-name {
  font-size: 12px;
  color: #475569;
  line-height: 1.35;
}

.chat-card-preview-meta,
.chat-card-preview-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-card-preview-meta span,
.chat-card-preview-stats span {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

.chat-card-preview-meta span {
  background: #fff;
  color: #334155;
}

.chat-card-preview-stats span {
  background: #ecfeff;
  color: #0f766e;
}

.chat-card-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.chat-card-status.is-red {
  background: rgba(254, 226, 226, 0.96);
  color: #b91c1c;
}

.chat-card-status.is-yellow {
  background: rgba(254, 249, 195, 0.96);
  color: #a16207;
}

.chat-card-status.is-green {
  background: rgba(209, 250, 229, 0.96);
  color: #047857;
}

.chat-card-status.is-gray {
  background: rgba(226, 232, 240, 0.92);
  color: #475569;
}

.chat-card-fact-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px auto;
  gap: 8px;
}

.chat-card-fact-step {
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #eef2ff;
  color: #1e3a8a;
  font: inherit;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
}

.chat-card-fact-input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-size: 13px;
}

.chat-card-fact-save {
  min-width: 92px;
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: #229ed9;
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.chat-photo-link {
  display: block;
  margin-top: 10px;
  position: relative;
  cursor: zoom-in;
}

.chat-photo {
  display: block;
  width: 100%;
  max-width: 320px;
  min-height: 88px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #f8fafc;
}

.chat-photo.is-loading {
  min-height: 120px;
  background:
    linear-gradient(90deg, rgba(226, 232, 240, 0.9), rgba(241, 245, 249, 0.9), rgba(226, 232, 240, 0.9));
  background-size: 220px 100%;
  animation: chat-photo-shimmer 1.3s linear infinite;
}

.chat-photo-link.is-error::after {
  content: "Не удалось загрузить фото";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 700;
  border-radius: 14px;
}

.chat-photo.is-error {
  min-height: 120px;
  background: #f8fafc;
}

@keyframes chat-photo-shimmer {
  from {
    background-position: -220px 0;
  }
  to {
    background-position: 220px 0;
  }
}

.chat-compose {
  position: sticky;
  bottom: calc(var(--chat-keyboard-offset, 0px) + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0 10px;
  border: 0;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 0;
  background: rgba(247, 246, 243, 0.98);
  overflow: visible;
  z-index: 20;
}

.chat-target-row {
  display: flex;
  align-items: center;
  min-height: 0;
}

.chat-target-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 11px;
  font-weight: 800;
}

.chat-reply-chip {
  background: #f8fafc;
  color: #334155;
}

.chat-link-chip {
  background: #ecfeff;
  color: #0f766e;
}

.chat-target-chip-close {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.chat-target-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.chat-target-label-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.chat-target-label-text {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
}

.chat-mention-popup {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.1);
  overflow: hidden;
}

.chat-mention-list {
  display: flex;
  flex-direction: column;
}

.chat-mention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.chat-mention-item + .chat-mention-item {
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}

.chat-mention-item.is-selected,
.chat-mention-item:hover {
  background: #f8fafc;
}

.chat-mention-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-mention-name {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.chat-mention-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.chat-mention-badge.staff {
  background: #dbeafe;
  color: #1d4ed8;
}

.chat-mention-badge.admin {
  background: #ede9fe;
  color: #6d28d9;
}

.chat-mention-badge.ai {
  background: #e0e7ff;
  color: #4338ca;
}

.chat-mention-id {
  font-size: 12px;
  color: #94a3b8;
}

.chat-compose-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  background: #f8fafc;
  min-width: 0;
  margin: 0 6px;
}

.chat-compose-preview-img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
}

.chat-compose-preview-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
  cursor: pointer;
}

.chat-file-btn-icon {
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
  color: #475569;
  box-shadow: none;
}

.chat-file-btn-icon.is-active,
.chat-attach-btn.is-active {
  background: #eef3f8;
  box-shadow: none;
}

.chat-file-btn-icon svg {
  width: 18px;
  height: 18px;
}

.chat-compose input[type="file"] {
  display: none;
}

.chat-text {
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 22px;
  padding: 12px 16px;
  font: inherit;
  color: #0f172a;
  background: #fff;
  box-sizing: border-box;
}

.chat-compose-main {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
}

.chat-compose-input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.chat-compose-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  align-self: flex-end;
}

.chat-attach-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 40;
  min-width: 176px;
  gap: 4px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.14);
}

.chat-attach-menu-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #0f172a;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.chat-attach-menu-btn:hover {
  background: #f8fafc;
}

.chat-attach-menu-icon {
  font-size: 16px;
  line-height: 1;
}

.chat-compose-actions .chat-send-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  border-radius: 50%;
  margin-left: 0;
  font-size: 18px;
  line-height: 1;
  background: #229ed9;
  color: #fff;
}

.chat-compose-actions .chat-send-btn svg {
  width: 18px;
  height: 18px;
}

.chat-message-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 1220;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.28);
}

.chat-message-menu {
  width: min(320px, 100%);
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
}

.chat-message-menu-btn {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  background: #f8fafc;
  color: #0f172a;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.chat-message-menu-btn-cancel {
  background: #eef2ff;
  color: #334155;
}

.chat-link-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #f8fafc;
}

.chat-link-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.chat-mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.chat-mini-btn.is-primary {
  background: #10b981;
  color: #052e26;
  border-color: rgba(16, 185, 129, 0.18);
}

.chat-message-actions {
  margin-top: 10px;
}

.chat-action-btn {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  color: #475569;
  background: #f8fafc;
}

.chat-row.is-flash .chat-message {
  animation: chat-row-flash 1.2s ease;
}

@keyframes chat-row-flash {
  0% { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.28); }
  30% { box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.18); }
  100% { box-shadow: none; }
}

.chat-file-name {
  max-width: 100%;
  color: #64748b;
  font-size: 13px;
  line-height: 1.3;
  word-break: break-word;
}

.chat-preview-clear {
  align-self: flex-start;
  border: 0;
  background: transparent;
  color: #2563eb;
  font-size: 12px;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
}

.chat-photo-overlay {
  position: fixed;
  inset: 0;
  z-index: 1250;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 6, 23, 0.78);
}

.chat-photo-viewer {
  width: min(960px, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-photo-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #fff;
}

.chat-photo-viewer-title {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
}

.chat-photo-viewer-close {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.chat-photo-viewer-stage {
  position: relative;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  background: rgba(15, 23, 42, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.chat-photo-viewer-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.chat-photo-overlay:not(.is-loading) .chat-photo-viewer-loading {
  display: none;
}

.chat-photo-viewer-img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
}

.chat-photo-viewer-img.is-error {
  opacity: 0.2;
}

.chat-qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  padding: 20px;
}

.chat-qr-modal {
  width: min(420px, 100%);
  border-radius: 22px;
  background: #fff;
  padding: 22px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-qr-title {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
}

#chatQrImg {
  width: 220px;
  height: 220px;
  object-fit: contain;
  align-self: center;
  background: #fff;
}

.chat-qr-link {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 14px;
  padding: 12px 14px;
  background: #f8fafc;
  color: #334155;
  font: inherit;
}

.chat-qr-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

body.guest-chat-only .tab:not([data-tab="Chat"]) {
  display: none;
}

body.guest-chat-only .topbar-profile,
body.guest-chat-only #desktopSectionActions,
body.guest-chat-only #desktopSectionActionsDynamic {
  display: none !important;
}

@media (max-width: 1024px) {
  .chat-shell {
    padding: 2px 4px 0;
  }

  .chat-head {
    align-items: center;
    flex-direction: row;
    padding: 2px 2px 8px;
  }

  .chat-head-actions {
    justify-content: flex-end;
  }

  .chat-photo {
    max-width: 100%;
  }

  .chat-message {
    width: auto;
    max-width: 80%;
  }

  .chat-row.mine .chat-message {
    border-bottom-right-radius: 8px;
  }

  .chat-row.other .chat-message {
    border-top-left-radius: 8px;
  }

  .chat-compose-preview {
    margin: 0 4px;
    padding: 8px 10px;
  }

  .chat-compose-preview-img {
    width: 56px;
    height: 56px;
  }

  .chat-compose-main {
    align-items: flex-end;
  }

  .chat-compose-actions {
    flex-direction: row;
    justify-content: flex-end;
  }

  .chat-attach-menu {
    right: 0;
    min-width: 168px;
  }

  .chat-link-fields {
    grid-template-columns: 1fr;
  }

  .chat-target-chip {
    max-width: 100%;
  }

  .chat-target-chip span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chat-photo-viewer {
    max-height: calc(100vh - 24px);
  }

  .chat-photo-viewer-stage {
    min-height: 180px;
    border-radius: 18px;
  }

  .chat-photo-viewer-img {
    max-height: calc(100vh - 112px);
  }

  .chat-subtitle {
    font-size: 11px;
  }

  .chat-shell.chat-keyboard-open .chat-compose {
    box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.08);
  }

  .chat-row.has-card .chat-message {
    max-width: 100%;
  }

  .chat-card-bottom-bar.bottom-bar {
    margin: 0 12px 12px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
  }
}
