/* ==========================================================================
   USMS Chat CSS
   File: public/assets/css/chat.css
   ========================================================================== */

.app-shell {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: var(--usms-left-panel-width) minmax(0, 1fr);
  overflow: hidden;
  color: var(--usms-text);
  background: var(--usms-bg);
}

.left-panel {
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: var(--usms-header-height) 58px 48px auto 1fr;
  border-right: 1px solid var(--usms-border);
  background: var(--usms-panel);
}

.left-header {
  height: var(--usms-header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 16px;
  background: var(--usms-panel-2);
  border-bottom: 1px solid var(--usms-border);
}

.current-user {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.current-user-info {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.current-user-info strong {
  overflow: hidden;
  color: var(--usms-text);
  font-size: 15px;
  line-height: 1.15;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.current-user-info span {
  overflow: hidden;
  color: var(--usms-muted);
  font-size: 12px;
  line-height: 1.15;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.left-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.search-area {
  padding: 8px 12px;
  border-bottom: 1px solid var(--usms-border);
  background: var(--usms-panel);
}

.quick-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--usms-border);
  background: var(--usms-panel);
}

.quick-tab {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--usms-muted);
  background: rgba(134, 150, 160, 0.08);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.quick-tab:hover {
  color: var(--usms-text);
  background: rgba(134, 150, 160, 0.13);
}

.quick-tab.active {
  color: #031d17;
  background: var(--usms-primary);
}

.stories-strip {
  min-height: 94px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--usms-border);
  background: var(--usms-panel);
}

.story-mini {
  width: 62px;
  display: grid;
  justify-items: center;
  gap: 6px;
  border: 0;
  color: var(--usms-muted);
  background: transparent;
  flex: 0 0 auto;
}

.story-mini small {
  width: 100%;
  overflow: hidden;
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.story-avatar {
  position: relative;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  padding: 2px;
  background: linear-gradient(135deg, var(--usms-primary), var(--usms-info));
}

.story-avatar img {
  width: 100%;
  height: 100%;
  border: 3px solid var(--usms-panel);
  border-radius: 999px;
}

.story-avatar b {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 2px solid var(--usms-panel);
  border-radius: 999px;
  color: #031d17;
  background: var(--usms-primary);
  font-size: 14px;
  line-height: 1;
}

.stories-mini-list {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==========================================================================
   Chat list
   ========================================================================== */

.chat-list {
  min-height: 0;
  overflow-y: auto;
  background: var(--usms-panel);
}

.chat-list-loading {
  min-height: 160px;
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 24px;
  color: var(--usms-muted);
  text-align: center;
  font-size: 13px;
}

.chat-list-loading span {
  width: 26px;
  height: 26px;
  border: 3px solid rgba(134, 150, 160, 0.2);
  border-top-color: var(--usms-primary);
  border-radius: 999px;
  animation: usmsSpin 0.8s linear infinite;
}

.chat-item {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid rgba(134, 150, 160, 0.08);
  color: var(--usms-text);
  background: transparent;
  text-align: left;
  transition: background var(--usms-transition-fast);
}

.chat-item:hover {
  background: rgba(134, 150, 160, 0.08);
}

.chat-item.active {
  background: rgba(134, 150, 160, 0.14);
}

.chat-avatar-wrap {
  width: 54px;
  height: 54px;
  border-radius: 999px;
}

.chat-avatar {
  width: 54px;
  height: 54px;
  border-radius: 999px;
}

.chat-item-main {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.chat-item-top,
.chat-item-bottom {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-name {
  min-width: 0;
  overflow: hidden;
  color: var(--usms-text);
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-time {
  flex: 0 0 auto;
  color: var(--usms-muted);
  font-size: 11px;
}

.chat-last-message {
  min-width: 0;
  overflow: hidden;
  color: var(--usms-muted);
  font-size: 13px;
  line-height: 1.25;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-unread {
  min-width: 21px;
  height: 21px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0 6px;
  border-radius: 999px;
  color: #031d17;
  background: var(--usms-primary);
  font-size: 11px;
  font-weight: 900;
}

/* ==========================================================================
   Chat panel
   ========================================================================== */

.chat-panel {
  min-width: 0;
  height: 100vh;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 15%, rgba(0, 168, 132, 0.07), transparent 28%),
    linear-gradient(180deg, var(--usms-bg), #071016);
}

.chat-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.08;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 18px 18px, rgba(233, 237, 239, 0.24) 1px, transparent 1px);
  background-size: 32px 32px;
}

.empty-chat-state {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 28px;
}

.empty-chat-card {
  width: min(460px, 100%);
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 28px;
  text-align: center;
}

.empty-chat-card img {
  width: 180px;
  max-width: 70%;
  opacity: 0.88;
}

.empty-chat-card h2 {
  color: var(--usms-text);
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.05em;
}

.empty-chat-card p {
  max-width: 400px;
  color: var(--usms-muted);
  font-size: 15px;
  line-height: 1.55;
}

.empty-chat-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

.empty-chat-pills span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  border: 1px solid var(--usms-border);
  border-radius: 999px;
  color: var(--usms-muted);
  background: rgba(134, 150, 160, 0.08);
  font-size: 12px;
  font-weight: 800;
}

.active-chat {
  position: relative;
  z-index: 1;
  height: 100%;
  min-width: 0;
  display: grid;
  grid-template-rows: var(--usms-header-height) auto auto minmax(0, 1fr) auto;
}

/* ==========================================================================
   Chat header
   ========================================================================== */

.chat-header {
  height: var(--usms-header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--usms-border);
  background: var(--usms-panel-2);
}

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

.chat-peer {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.chat-peer-avatar-wrap {
  width: 44px;
  height: 44px;
  border-radius: 999px;
}

.chat-peer-avatar-wrap img {
  width: 44px;
  height: 44px;
  border-radius: 999px;
}

.chat-peer-text {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.chat-peer-text strong {
  min-width: 0;
  overflow: hidden;
  color: var(--usms-text);
  font-size: 15px;
  line-height: 1.15;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-peer-text small {
  min-width: 0;
  overflow: hidden;
  color: var(--usms-muted);
  font-size: 12px;
  line-height: 1.15;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

/* ==========================================================================
   Pinned/search bars
   ========================================================================== */

.pinned-message-bar {
  min-height: 46px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--usms-border);
  background: rgba(32, 44, 51, 0.86);
  backdrop-filter: blur(16px);
}

.pinned-message-bar > button:first-child {
  min-width: 0;
  display: grid;
  grid-template-columns: 24px auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border: 0;
  color: var(--usms-text);
  background: transparent;
  text-align: left;
}

.pinned-message-bar strong {
  color: var(--usms-primary-2);
  font-size: 13px;
}

.pinned-message-bar small {
  overflow: hidden;
  color: var(--usms-muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-search-panel {
  padding: 8px 12px;
  border-bottom: 1px solid var(--usms-border);
  background: var(--usms-panel);
}

/* ==========================================================================
   Messages
   ========================================================================== */

.messages-viewport {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 0;
  scroll-behavior: smooth;
}

.messages-list {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 0 36px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.load-older {
  display: block;
  min-height: 34px;
  margin: 0 auto 12px;
  padding: 0 14px;
  border: 1px solid var(--usms-border);
  border-radius: 999px;
  color: var(--usms-muted);
  background: rgba(32, 44, 51, 0.84);
}

.load-older:hover {
  color: var(--usms-text);
  background: rgba(32, 44, 51, 0.96);
}

.message {
  position: relative;
  max-width: 72%;
  display: flex;
  margin: 1px 0;
}

.message.in {
  align-self: flex-start;
}

.message.out {
  align-self: flex-end;
  margin-left: auto;
}

.message.center {
  align-self: center;
  max-width: min(520px, 92%);
  justify-content: center;
}

.message-bubble {
  position: relative;
  min-width: 72px;
  max-width: 100%;
  padding: 7px 8px 6px;
  border-radius: 12px;
  color: var(--usms-text);
  background: #202c33;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.14);
}

.message.in .message-bubble {
  border-top-left-radius: 4px;
}

.message.out .message-bubble {
  border-top-right-radius: 4px;
  background: #005c4b;
}

html[data-theme="light"] .message-bubble {
  background: #ffffff;
}

html[data-theme="light"] .message.out .message-bubble {
  background: #d9fdd3;
}

.message.center .message-bubble {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--usms-muted);
  background: rgba(32, 44, 51, 0.78);
  text-align: center;
  font-size: 12px;
}

.message-content {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  color: inherit;
  font-size: 14.5px;
  line-height: 1.42;
}

.message-content a {
  color: var(--usms-info);
  text-decoration: underline;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 3px;
  color: rgba(233, 237, 239, 0.58);
  font-size: 11px;
  line-height: 1;
}

html[data-theme="light"] .message-meta {
  color: rgba(17, 27, 33, 0.55);
}

.message-status {
  min-width: 16px;
  color: rgba(233, 237, 239, 0.62);
  font-weight: 900;
  letter-spacing: -0.08em;
}

html[data-theme="light"] .message-status {
  color: rgba(17, 27, 33, 0.55);
}

.message-status.read {
  color: #53bdeb;
}

.message-edited {
  color: inherit;
}

.message-reply {
  max-width: 100%;
  margin-bottom: 5px;
  padding: 7px 9px;
  border-left: 3px solid var(--usms-primary);
  border-radius: 8px;
  color: var(--usms-muted);
  background: rgba(0, 0, 0, 0.13);
  font-size: 12px;
  line-height: 1.35;
}

.message-media {
  overflow: hidden;
  margin-bottom: 4px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.16);
}

.message-media img,
.message-media video {
  max-width: 320px;
  max-height: 360px;
  border-radius: 10px;
  object-fit: cover;
}

.message-file {
  min-width: 240px;
  max-width: 320px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.12);
}

.message-file-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--usms-info);
  background: var(--usms-info-soft);
}

.message-file-info {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.message-file-info strong,
.message-file-info span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.message-file-info strong {
  font-size: 13px;
}

.message-file-info span {
  color: var(--usms-muted);
  font-size: 11px;
}

.message-reactions {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(11, 20, 26, 0.55);
  font-size: 12px;
}

.message.highlight .message-bubble {
  box-shadow:
    0 0 0 2px rgba(0, 168, 132, 0.3),
    0 0 34px rgba(0, 168, 132, 0.18);
}

.typing-indicator {
  width: min(980px, 100%);
  margin: 8px auto 0;
  padding: 0 36px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--usms-muted);
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--usms-muted);
  animation: usmsTyping 1s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.12s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.24s;
}

.typing-indicator small {
  margin-left: 5px;
  font-size: 12px;
}

.scroll-bottom {
  position: absolute;
  right: 22px;
  bottom: 22px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: var(--usms-text);
  background: rgba(32, 44, 51, 0.9);
  box-shadow: var(--usms-shadow-md);
  backdrop-filter: blur(16px);
}

/* ==========================================================================
   Composer
   ========================================================================== */

.composer {
  position: relative;
  border-top: 1px solid var(--usms-border);
  background: var(--usms-panel-2);
}

.composer-row {
  min-height: var(--usms-composer-height);
  display: grid;
  grid-template-columns: 44px 44px minmax(0, 1fr) 44px 44px;
  gap: 6px;
  align-items: end;
  padding: 10px 14px;
}

.message-input-wrap {
  min-height: 46px;
  display: flex;
  align-items: center;
  border-radius: 24px;
  background: var(--usms-bg-3);
}

.message-input-wrap textarea {
  width: 100%;
  max-height: 148px;
  min-height: 46px;
  padding: 13px 15px;
  border: 0;
  outline: none;
  resize: none;
  color: var(--usms-text);
  background: transparent;
  line-height: 1.35;
}

.message-input-wrap textarea::placeholder {
  color: var(--usms-muted);
}

.send-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: #031d17;
  background: var(--usms-primary);
  box-shadow: 0 10px 26px rgba(0, 168, 132, 0.25);
}

.send-btn span {
  transform: translateX(1px);
}

.reply-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
  margin: 10px 14px 0;
  padding: 9px 10px 9px 12px;
  border-left: 3px solid var(--usms-primary);
  border-radius: 12px;
  background: rgba(11, 20, 26, 0.32);
}

.reply-preview strong {
  color: var(--usms-primary-2);
  font-size: 13px;
}

.reply-preview p {
  overflow: hidden;
  margin-top: 2px;
  color: var(--usms-muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.reply-preview button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  color: var(--usms-muted);
  background: transparent;
}

.reply-preview button:hover {
  color: var(--usms-text);
  background: rgba(134, 150, 160, 0.12);
}

.edit-preview {
  border-left-color: var(--usms-warning);
}

.edit-preview strong {
  color: var(--usms-warning);
}

.attachment-panel {
  position: absolute;
  left: 58px;
  bottom: calc(var(--usms-composer-height) + 10px);
  z-index: 15;
  width: 280px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--usms-border);
  border-radius: 18px;
  background: rgba(32, 44, 51, 0.96);
  box-shadow: var(--usms-shadow-lg);
  backdrop-filter: blur(20px);
}

html[data-theme="light"] .attachment-panel {
  background: rgba(255, 255, 255, 0.96);
}

.attachment-panel button {
  min-height: 62px;
  display: grid;
  justify-items: center;
  gap: 6px;
  border: 0;
  border-radius: 14px;
  color: var(--usms-text);
  background: rgba(134, 150, 160, 0.08);
  font-size: 12px;
  font-weight: 800;
}

.attachment-panel button:hover {
  background: rgba(134, 150, 160, 0.14);
}

.attachment-panel button span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #031d17;
  background: var(--usms-primary);
}

.emoji-panel {
  position: absolute;
  left: 14px;
  bottom: calc(var(--usms-composer-height) + 10px);
  z-index: 16;
  width: min(360px, calc(100vw - 28px));
  overflow: hidden;
  border: 1px solid var(--usms-border);
  border-radius: 18px;
  background: rgba(32, 44, 51, 0.96);
  box-shadow: var(--usms-shadow-lg);
  backdrop-filter: blur(20px);
}

html[data-theme="light"] .emoji-panel {
  background: rgba(255, 255, 255, 0.96);
}

.emoji-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--usms-border);
}

.emoji-tabs button {
  min-width: 36px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  color: var(--usms-muted);
  background: transparent;
}

.emoji-tabs button.active,
.emoji-tabs button:hover {
  color: var(--usms-text);
  background: rgba(134, 150, 160, 0.12);
}

.emoji-grid {
  max-height: 220px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  padding: 10px;
}

.emoji-grid button {
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 21px;
}

.emoji-grid button:hover {
  background: rgba(134, 150, 160, 0.12);
}

.recording-bar {
  min-height: 48px;
  display: grid;
  grid-template-columns: 10px auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 0 14px 12px;
  color: var(--usms-text);
}

.recording-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--usms-danger);
  animation: usmsPulse 1s ease-in-out infinite;
}

.recording-bar strong {
  color: var(--usms-danger);
  font-variant-numeric: tabular-nums;
}

.recording-bar button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  color: var(--usms-text);
  background: rgba(134, 150, 160, 0.12);
}

.recording-bar button:last-child {
  color: #031d17;
  background: var(--usms-primary);
}

/* ==========================================================================
   Right panel
   ========================================================================== */

.right-panel {
  position: fixed;
  z-index: var(--usms-z-panel);
  top: 0;
  right: 0;
  width: var(--usms-right-panel-width);
  height: 100vh;
  display: grid;
  grid-template-rows: var(--usms-header-height) minmax(0, 1fr);
  border-left: 1px solid var(--usms-border);
  background: var(--usms-panel);
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.24);
}

.right-panel-header {
  height: var(--usms-header-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--usms-border);
  background: var(--usms-panel-2);
}

.right-panel-header h3 {
  color: var(--usms-text);
  font-size: 16px;
}

.right-panel-body {
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
}

.room-info {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 18px 0 24px;
  text-align: center;
}

.room-info img {
  width: 118px;
  height: 118px;
  border-radius: 999px;
}

.room-info h2 {
  max-width: 100%;
  overflow: hidden;
  color: var(--usms-text);
  font-size: 22px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.room-info p {
  color: var(--usms-muted);
  font-size: 13px;
}

.room-info-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.room-info-actions button {
  min-height: 44px;
  border: 1px solid var(--usms-border);
  border-radius: 14px;
  color: var(--usms-primary-2);
  background: var(--usms-primary-soft);
  font-size: 12px;
  font-weight: 800;
}

.info-section {
  display: grid;
  gap: 8px;
  padding: 16px 0;
  border-top: 1px solid var(--usms-border);
}

.info-section h4 {
  color: var(--usms-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.info-row,
.danger-row {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-radius: 12px;
  padding: 0 12px;
  background: transparent;
  color: var(--usms-text);
  text-align: left;
}

.info-row:hover,
.danger-row:hover {
  background: rgba(134, 150, 160, 0.1);
}

.info-row b {
  color: var(--usms-muted);
  font-size: 12px;
}

.danger-row {
  color: var(--usms-danger);
}

.media-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.media-preview-grid button,
.media-preview-grid img {
  aspect-ratio: 1;
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: var(--usms-bg-3);
  object-fit: cover;
}

/* ==========================================================================
   Lightbox
   ========================================================================== */

.media-lightbox {
  position: fixed;
  z-index: calc(var(--usms-z-modal) + 10);
  inset: 0;
  display: grid;
  grid-template-rows: var(--usms-header-height) minmax(0, 1fr);
  background: rgba(0, 0, 0, 0.92);
}

.media-lightbox header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  color: #fff;
}

.media-lightbox-body {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}

.media-lightbox-body img,
.media-lightbox-body video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes usmsTyping {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  50% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 340px minmax(0, 1fr);
  }

  .messages-list {
    padding: 0 22px;
  }

  .message {
    max-width: 82%;
  }
}

@media (max-width: 760px) {
  .mobile-only {
    display: inline-grid !important;
  }

  .desktop-only {
    display: none !important;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .left-panel {
    position: absolute;
    z-index: 20;
    inset: 0;
    width: 100%;
    transform: translateX(0);
  }

  .app-shell.chat-open .left-panel {
    transform: translateX(-100%);
  }

  .chat-panel {
    position: absolute;
    inset: 0;
    z-index: 21;
    transform: translateX(100%);
    transition: transform var(--usms-transition);
  }

  .app-shell.chat-open .chat-panel {
    transform: translateX(0);
  }

  .messages-list {
    padding: 0 12px;
  }

  .message {
    max-width: 88%;
  }

  .chat-header-actions .icon-btn {
    width: 38px;
    height: 38px;
  }

  .composer-row {
    grid-template-columns: 40px 40px minmax(0, 1fr) 40px 40px;
    gap: 4px;
    padding: 8px;
  }

  .right-panel {
    width: 100%;
  }

  .attachment-panel {
    left: 8px;
    right: 8px;
    width: auto;
    bottom: calc(var(--usms-composer-height) + 8px);
  }

  .emoji-panel {
    left: 8px;
    right: 8px;
    width: auto;
  }
}

@media (max-width: 430px) {
  .left-panel {
    grid-template-rows: var(--usms-header-height) 56px 46px auto 1fr;
  }

  .current-user-info {
    display: none;
  }

  .chat-item {
    min-height: 72px;
    grid-template-columns: 50px minmax(0, 1fr);
  }

  .chat-avatar-wrap,
  .chat-avatar {
    width: 50px;
    height: 50px;
  }

  .stories-strip {
    min-height: 88px;
  }

  .story-avatar {
    width: 50px;
    height: 50px;
  }

  .message {
    max-width: 92%;
  }

  .message-content {
    font-size: 14px;
  }

  .message-media img,
  .message-media video {
    max-width: 250px;
    max-height: 310px;
  }
}