.chat-view {
  position: relative;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr) auto auto auto;
}

.chat-view.drag-active::after {
  content: "松开以添加图片或文件";
  position: absolute;
  inset: 82px 18px 82px;
  z-index: 12;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: rgba(17, 19, 21, .9);
  color: var(--accent-strong);
  font-size: calc(16px + var(--font-size-delta));
  pointer-events: none;
}

.chat-header {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 16px 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.chat-header > .avatar {
  width: 40px;
  height: 40px;
  flex-basis: 40px;
}

.connection-status {
  min-height: 30px;
  display: grid;
  place-items: center;
  border-bottom: 1px solid rgba(231, 184, 92, .28);
  background: #29261e;
  color: #e7c982;
  font-size: calc(11px + var(--font-size-delta));
  cursor: pointer;
}

.connection-status.connecting { border-color: rgba(142, 181, 230, .28); background: #202731; color: #a9c9f0; }

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

.chat-heading h2,
.chat-heading p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-heading h2 {
  font-size: calc(16px + var(--font-size-delta));
}

.chat-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: calc(11px + var(--font-size-delta));
}

.messages {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 24px clamp(18px, 4vw, 54px) 18px;
  scroll-behavior: auto;
}

.messages > * { overflow-anchor: none; }

.message-bottom-anchor {
  width: 1px;
  height: 1px;
  overflow-anchor: auto;
  pointer-events: none;
}

.message-row {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 620px);
  align-items: start;
  gap: 10px;
  margin-bottom: 17px;
  touch-action: pan-y;
}

.message-wrap.swipe-resetting { transition: transform .16s ease-out; }

.message-swipe-reply {
  position: absolute;
  top: 50%;
  left: 43px;
  display: none;
  place-items: center;
  color: var(--accent-strong);
  opacity: var(--swipe-progress, 0);
  pointer-events: none;
  transform: translateY(-50%) scale(calc(.72 + var(--swipe-progress, 0) * .28));
}

.message-swipe-reply.right {
  right: 43px;
  left: auto;
}

.message-swipe-reply .lucide { width: 19px; height: 19px; }

.message-row:has(+ .message-row.grouped),
.message-row.grouped {
  margin-bottom: 5px;
}

.message-row.grouped .grouped-avatar {
  visibility: hidden;
}

.message-row.grouped .message-author {
  display: none;
}

.message-row.failed .message-bubble {
  border-color: rgba(237, 109, 102, .55);
}

.message-date-divider,
.unread-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 20px;
  color: var(--faint);
  font-size: calc(10px + var(--font-size-delta));
  text-align: center;
}

.message-date-divider::before,
.message-date-divider::after,
.unread-divider::before,
.unread-divider::after {
  height: 1px;
  flex: 1;
  background: var(--line-soft);
  content: '';
}

.unread-divider {
  color: var(--accent-strong);
}

.unread-divider::before,
.unread-divider::after {
  background: rgba(36, 167, 181, .32);
}

.message-row.own {
  grid-template-columns: minmax(0, 620px) 36px;
  justify-content: end;
}

.message-row > .avatar {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
  font-size: calc(12px + var(--font-size-delta));
}

.message-row.own > .avatar {
  grid-column: 2;
}

.message-wrap {
  min-width: 0;
  position: relative;
}

.message-row.own .message-wrap {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
}

.message-author {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 5px 2px;
  color: var(--muted);
  font-size: calc(11px + var(--font-size-delta));
}

.message-row.own .message-author {
  justify-content: flex-end;
  margin-right: 2px;
}

.message-bubble {
  position: relative;
  width: fit-content;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-3);
  color: #f0f2f3;
  font-size: calc(14px + var(--font-size-delta));
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-row.own .message-bubble {
  margin-left: auto;
  border-color: #286168;
  background: #1e4e54;
}

.message-bubble-line {
  position: relative;
  width: fit-content;
  max-width: 100%;
}

.message-row.own .message-bubble-line {
  margin-left: auto;
}

.message-row .message-bubble-line > .message-bubble {
  max-width: 100%;
  margin-left: 0;
}

.message-collapse-count {
  position: absolute;
  bottom: 4px;
  left: calc(100% + 7px);
  color: var(--muted);
  font-size: calc(11px + var(--font-size-delta));
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  white-space: nowrap;
  user-select: none;
}

.message-row.own .message-collapse-count {
  right: calc(100% + 7px);
  left: auto;
}

.message-repeat-button {
  min-width: 34px;
  min-height: 25px;
  margin-top: 5px;
  border: 1px solid rgba(89, 199, 206, .32);
  border-radius: 13px;
  padding: 1px 9px;
  background: rgba(24, 56, 60, .76);
  color: var(--accent-strong);
  cursor: pointer;
  font-size: calc(11px + var(--font-size-delta));
  line-height: 1;
}

.message-row.own .message-repeat-button { display: block; margin-left: auto; }
.message-repeat-button:hover { border-color: var(--accent); background: var(--accent-soft); }

.message-bubble.recalled {
  color: var(--muted);
  font-style: italic;
}

.message-link {
  color: #9ac7ff;
  text-decoration: underline;
  text-decoration-color: rgba(154, 199, 255, .48);
  text-underline-offset: 2px;
  word-break: break-all;
}

.message-link:hover {
  color: #c3dcff;
  text-decoration-color: currentColor;
}

.message-image {
  display: block;
  width: auto;
  height: auto;
  max-width: min(320px, 48vw);
  max-height: 320px;
  border-radius: 7px;
  object-fit: contain;
  cursor: zoom-in;
}

img.deferred-media {
  min-width: 1px;
  min-height: 1px;
}

img.deferred-media:not(.loaded) {
  visibility: hidden;
}

.message-image.deferred-media:not(.loaded) {
  width: min(320px, 48vw);
  height: 190px;
}

.message-gallery .message-image.deferred-media:not(.loaded) {
  width: 238px;
  height: 178px;
}

.message-gallery.count-1 .message-image.deferred-media:not(.loaded) {
  width: 308px;
  height: 190px;
}

.bot-message-card-image.deferred-media:not(.loaded) {
  height: 220px;
}

.featured-card-body > .featured-image.deferred-media:not(.loaded) {
  width: min(420px, 100%);
  height: 180px;
}

.media-load-placeholder {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.media-load-placeholder:hover { border-color: var(--accent); background: var(--surface-3); }
.media-load-placeholder > .lucide { width: 24px; height: 24px; flex: 0 0 24px; color: var(--accent-strong); }
.media-load-copy { min-width: 0; display: grid; gap: 3px; }
.media-load-copy strong,
.media-load-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-load-copy strong { font-size: calc(12px + var(--font-size-delta)); }
.media-load-copy small { color: var(--muted); font-size: calc(10px + var(--font-size-delta)); }

.message-image-placeholder {
  width: min(320px, 48vw);
  height: 190px;
}

.message-gallery .message-image-placeholder { width: 238px; height: 178px; }
.message-gallery.count-1 .message-image-placeholder { width: 308px; height: 190px; }

.desktop-image-draggable {
  -webkit-user-drag: element;
  cursor: grab;
}

.desktop-image-draggable:active { cursor: grabbing; }

.message-bubble:has(> .message-image),
.message-bubble:has(> .message-image-placeholder),
.message-bubble:has(> .message-gallery) {
  overflow: hidden;
  padding: 6px;
}

.message-bubble.media-only {
  overflow: visible;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.message-gallery {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 4px;
  width: fit-content;
  max-width: 484px;
}
.message-gallery.count-1 { display: block; max-width: 320px; }
.message-gallery .message-image {
  width: auto;
  height: auto;
  max-width: 240px;
  max-height: 280px;
  object-fit: contain;
}
.message-gallery.count-1 .message-image { max-width: 320px; max-height: 320px; }

.message-file {
  width: min(360px, 100%);
  min-height: 62px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 5px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 5px;
  background: rgba(0, 0, 0, .15);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.message-caption {
  width: auto;
  max-width: none;
  margin-top: 0;
  padding: 8px 5px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.message-row.own .message-caption {
  border-color: transparent;
  background: transparent;
}

.reply-quote {
  max-width: 100%;
  display: block;
  margin-bottom: 7px;
  padding: 7px 9px;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  border-left: 3px solid var(--accent);
  background: rgba(0, 0, 0, .18);
  color: #b9c0c5;
  font-family: inherit;
  font-size: calc(12px + var(--font-size-delta));
  line-height: 1.4;
  text-align: left;
}

button.reply-quote {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
button.reply-quote:hover { background: rgba(0, 0, 0, .28); }

.reply-quote-thumbnail,
.reply-thumbnail {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  object-fit: cover;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
  border-radius: 5px;
  background: var(--surface-3);
}

.reply-quote-copy,
.reply-bar-copy { min-width: 0; }

.reply-quote-copy {
  display: grid;
  gap: 2px;
}

.reply-quote-copy strong,
.reply-quote-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-quote-preview { display: block; }

.message-image-located {
  outline: 3px solid color-mix(in srgb, var(--accent) 86%, white 14%);
  outline-offset: 3px;
  animation: quoted-image-located 2.2s ease-out;
}

@keyframes quoted-image-located {
  0%, 30% { filter: brightness(1.18); }
  100% { outline-color: transparent; filter: none; }
}

.message-actions {
  display: flex;
  gap: 3px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity .15s ease;
}

.message-row:hover .message-actions,
.message-row:focus-within .message-actions {
  opacity: 1;
}

.message-row.own .message-actions {
  justify-content: flex-end;
}

.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}

.message-row.own .message-reactions {
  justify-content: flex-end;
}

.reaction-pill {
  min-height: 27px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 2px 9px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  font-size: calc(12px + var(--font-size-delta));
}

.reaction-pill.own {
  border-color: #32767d;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.message-delivery {
  margin-top: 4px;
  color: var(--faint);
  font-size: calc(10px + var(--font-size-delta));
}

.message-row.own .message-delivery {
  text-align: right;
}

.message-delivery.failed {
  color: var(--red);
}

.edited-label {
  color: var(--faint);
}

.quick-reactions {
  display: grid;
  grid-template-columns: repeat(6, 44px);
  justify-content: center;
  gap: 7px;
}

.reaction-choice {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: calc(21px + var(--font-size-delta));
}

.reaction-choice:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.message-actions button {
  min-height: 26px;
  border: 0;
  border-radius: 4px;
  padding: 0 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: calc(11px + var(--font-size-delta));
}

.message-actions button:hover {
  background: var(--surface-3);
  color: var(--text);
}

.load-more {
  position: absolute;
  top: 81px;
  left: 50%;
  z-index: 2;
  transform: translateX(-50%);
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 0 12px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  font-size: calc(11px + var(--font-size-delta));
}

.new-messages-button {
  position: absolute;
  right: 22px;
  bottom: 82px;
  z-index: 8;
  min-height: 34px;
  border: 1px solid rgba(115, 167, 238, .38);
  border-radius: 17px;
  padding: 0 14px;
  background: #26374d;
  color: #cce1ff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .28);
  cursor: pointer;
  font-size: calc(11px + var(--font-size-delta));
}

.reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.reply-bar-copy { flex: 1 1 auto; }

.draft-attachments {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 9px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.draft-tile {
  position: relative;
  width: 92px;
  height: 72px;
  flex: 0 0 92px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}
.draft-tile img { width: 100%; height: 100%; object-fit: cover; }
.draft-file-icon { font-size: calc(22px + var(--font-size-delta)); color: var(--accent-strong); }
.draft-name {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  padding: 3px 5px;
  background: rgba(0, 0, 0, .7);
  color: #fff;
  font-size: calc(9px + var(--font-size-delta));
  text-overflow: ellipsis;
  white-space: nowrap;
}
.draft-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .75);
  color: #fff;
  cursor: pointer;
}

.reply-bar strong,
.reply-bar p {
  margin: 0;
  font-size: calc(11px + var(--font-size-delta));
}

.reply-bar strong { color: var(--accent-strong); }
.reply-bar p {
  max-width: 600px;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-bar p:empty { display: none; }

.composer {
  position: relative;
  min-height: 68px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 11px 15px 13px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.mention-panel {
  position: absolute;
  right: 14px;
  bottom: calc(100% + 6px);
  left: 14px;
  z-index: 22;
  max-width: 380px;
  max-height: min(360px, 46vh);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  box-shadow: 0 14px 38px rgba(0, 0, 0, .42);
}

.mention-option {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.mention-option:hover,
.mention-option.active {
  background: var(--accent-soft);
}

.mention-option > .avatar {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
}

.mention-all-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
}

.mention-all-avatar svg { width: 18px; height: 18px; }

.mention-option-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.mention-option-copy strong,
.mention-option-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-option-copy strong { font-size: calc(13px + var(--font-size-delta)); }
.mention-option-copy small { color: var(--muted); font-size: calc(10px + var(--font-size-delta)); }
.mention-panel-empty { padding: 16px 12px; color: var(--muted); font-size: calc(12px + var(--font-size-delta)); text-align: center; }

.composer textarea {
  min-height: 42px;
  max-height: 130px;
  flex: 1;
  resize: none;
  background: var(--bg);
}

.composer .icon-button,
.send-button {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  padding: 0;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
.sticker-item {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
}
.sticker-send {
  width: 100%;
  height: 100%;
  display: block;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  -webkit-touch-callout: none;
}
.sticker-send:hover { border-color: var(--accent); }
.sticker-send:focus:not(:focus-visible),
.sticker-send.touching { outline: 0; }
.sticker-send img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.sticker-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 6px;
  background: rgba(12, 14, 21, .82);
  color: #b6bdcc;
  cursor: pointer;
  opacity: .82;
}
.sticker-delete:hover {
  border-color: rgba(239, 133, 141, .45);
  background: rgba(91, 35, 43, .9);
  color: #ffc1c6;
  opacity: 1;
}
.sticker-delete .lucide { width: 15px; height: 15px; }
.sticker-grid.sending .sticker-send { pointer-events: none; opacity: .55; }
