.chat-messages, .chat-message-row { display: flex; flex-direction: column; min-width: 0; }
.chat-messages { gap: 7px; }
.chat-message-row .day { align-self: center; }
.chat-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .msg-meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 5px; }
.msg .msg-meta time { float: none; margin: 0; }
.chat-delivery { display: inline-flex; opacity: .8; }
.chat-delivery .ico { width: 13px; height: 13px; }
.chat-body .msg-with-media { max-width: min(94%, 520px); }
.chat-photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; width: min(65vw, 400px); max-width: 100%; }
.chat-photos[data-photo-count="1"] { display: block; width: auto; }
.chat-photos button { display: block; min-width: 0; border-radius: 9px; overflow: hidden; background: var(--surface-3); }
.chat-photos button img { display: block; margin: 0; width: 100%; aspect-ratio: 1.24; height: auto; max-height: 210px; border-radius: 0; object-fit: cover; }
.chat-photos[data-photo-count="1"] button img { width: auto; max-width: min(65vw, 400px); max-height: 288px; aspect-ratio: auto; object-fit: contain; }
.chat-panel .chat-body .msg-sticker { padding: 4px; color: var(--ink); background: transparent; border-color: transparent; box-shadow: none; }
.chat-body .msg-sticker .chat-sticker { width: 120px; height: 120px; object-fit: contain; margin: 0; }
.chat-body .msg-sticker .msg-meta { color: var(--ink-2); }
.chat-body .msg-sticker .msg-meta time { color: inherit; }
.chat-file-link { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; color: inherit; text-decoration: none; }
.chat-file-link b { display: block; overflow-wrap: anywhere; font-size: 13px; }
.chat-file-link small { display: block; margin-top: 2px; opacity: .8; font-size: 11px; }
.chat-file-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); }

.chat-lightbox {
  width: min(100% - 24px, 1120px);
  max-width: none;
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 8px;
  border: 0;
  border-radius: 18px;
  background: #11182a;
  color: #fff;
  box-shadow: 0 24px 70px #0006;
}
.chat-lightbox::backdrop { background: #050813d9; }
.chat-lightbox-head { display: flex; align-items: center; justify-content: space-between; padding: 0 5px 5px 12px; font-size: 14px; }
.chat-lightbox-content { display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; gap: 4px; align-items: center; }
.chat-lightbox-content img { display: block; grid-column: 2; justify-self: center; max-width: 100%; max-height: calc(100dvh - 100px); object-fit: contain; touch-action: pan-y pinch-zoom; }
.chat-lightbox button { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: #ffffff19; color: #fff; }
.chat-lightbox button:hover { background: #ffffff30; }
.chat-lightbox button:focus-visible { outline: 2px solid #fff; outline-offset: -3px; }

@media (max-width: 859px) {
  #device[data-route="chat"] { height: min(100%, var(--chat-viewport-height, 100%)); align-self: start; }
}
@media (max-width: 420px) {
  .chat-lightbox { width: calc(100% - 12px); }
  .chat-lightbox-content { grid-template-columns: 32px minmax(0, 1fr) 32px; }
  .chat-lightbox-content button { width: 32px; }
}
