/* Slack-inspired Messages workspace — full-bleed content area */

#portal-shell:has([data-panel-content="messages"]:not(.hidden)) {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

#portal-shell:has([data-panel-content="messages"]:not(.hidden)) > header {
  flex-shrink: 0;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

#portal-shell:has([data-panel-content="messages"]:not(.hidden)) > header #page-title {
  display: none;
}

#portal-shell:has([data-panel-content="messages"]:not(.hidden)) > main {
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

[data-panel-content="messages"]:not(.hidden) {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

[data-panel-content="messages"] > #messages-alert:not(.hidden) {
  margin: 0;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
}

.msg-workspace {
  display: grid;
  grid-template-columns: minmax(17.5rem, 20.5rem) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  transition: grid-template-columns 0.2s ease;
}

.msg-workspace.is-sidebar-collapsed {
  grid-template-columns: 3.25rem 1fr;
}

.msg-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: linear-gradient(180deg, rgb(var(--color-footer-bg-rgb)) 0%, #071510 100%);
  color: #e8eee9;
  border-right: 1px solid rgb(255 255 255 / 0.06);
}

.msg-sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.85rem 0.65rem 0.75rem 1rem;
  border-bottom: 1px solid rgb(255 255 255 / 0.08);
}

.msg-sidebar-head-text {
  min-width: 0;
  flex: 1;
}

.msg-sidebar-head h2 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-sidebar-head p {
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: rgb(255 255 255 / 0.55);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-sidebar-toggle {
  flex-shrink: 0;
  width: 1.85rem;
  height: 1.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: rgb(255 255 255 / 0.08);
  color: rgb(255 255 255 / 0.75);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.msg-sidebar-toggle:hover {
  background: rgb(255 255 255 / 0.16);
  color: #fff;
}

.msg-sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid rgb(255 255 255 / 0.08);
}

.msg-sidebar-actions button,
.msg-sidebar-actions select {
  width: 100%;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 0;
  padding: 0.45rem 0.65rem;
  border: 0;
  cursor: pointer;
  transition: background 0.15s ease;
}

.msg-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: rgb(255 255 255 / 0.08);
  color: #fff;
}

.msg-action-btn:hover {
  background: rgb(255 255 255 / 0.14);
}

.msg-action-icon {
  width: 1rem;
  text-align: center;
  opacity: 0.85;
  flex-shrink: 0;
}

.msg-sidebar-actions select {
  background: rgb(255 255 255 / 0.08);
  color: rgb(255 255 255 / 0.85);
}

.msg-sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.35rem 0 0.75rem;
}

.msg-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.65rem 0.75rem 0.3rem 1rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgb(255 255 255 / 0.45);
}

.msg-section-label-text {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.msg-section-label-text > i {
  font-size: 0.72rem;
  opacity: 0.85;
  width: 0.85rem;
  text-align: center;
}

.msg-section-action {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 0;
  background: transparent;
  color: rgb(255 255 255 / 0.45);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0.15rem 0.25rem;
}

.msg-section-action:hover {
  color: rgb(255 255 255 / 0.9);
}

.msg-nav-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  padding: 0.45rem 1rem;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgb(255 255 255 / 0.82);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.msg-nav-item:hover {
  background: rgb(255 255 255 / 0.08);
  color: #fff;
}

.msg-nav-item.is-active {
  background: rgb(var(--color-primary-rgb) / 0.9);
  color: #fff;
}

.msg-nav-icon {
  width: 1.15rem;
  flex-shrink: 0;
  text-align: center;
  opacity: 0.75;
  font-size: 0.78rem;
}

.msg-nav-item.is-active .msg-nav-icon {
  opacity: 1;
}

.msg-nav-avatar {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 0;
  background: rgb(255 255 255 / 0.16);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Collapsed icon rail */
.msg-workspace.is-sidebar-collapsed .msg-sidebar-head {
  justify-content: center;
  padding: 0.65rem 0.35rem;
}

.msg-workspace.is-sidebar-collapsed .msg-sidebar-head-text,
.msg-workspace.is-sidebar-collapsed .msg-action-label,
.msg-workspace.is-sidebar-collapsed .msg-filter-select,
.msg-workspace.is-sidebar-collapsed .msg-section-label-copy,
.msg-workspace.is-sidebar-collapsed .msg-section-action-label,
.msg-workspace.is-sidebar-collapsed .msg-nav-text,
.msg-workspace.is-sidebar-collapsed .msg-empty-side {
  display: none;
}

.msg-workspace.is-sidebar-collapsed .msg-sidebar-head {
  flex-direction: column;
  align-items: center;
}

.msg-workspace.is-sidebar-collapsed .msg-sidebar-toggle i {
  transform: rotate(180deg);
}

.msg-workspace.is-sidebar-collapsed .msg-sidebar-actions {
  padding: 0.5rem 0.35rem;
  align-items: center;
}

.msg-workspace.is-sidebar-collapsed .msg-action-btn {
  justify-content: center;
  padding: 0.55rem 0;
  width: 2.35rem;
}

.msg-workspace.is-sidebar-collapsed .msg-section-label {
  justify-content: center;
  padding: 0.65rem 0.25rem 0.25rem;
}

.msg-workspace.is-sidebar-collapsed .msg-section-action {
  display: none;
}

.msg-workspace.is-sidebar-collapsed .msg-nav-item {
  justify-content: center;
  padding: 0.55rem 0;
}

.msg-workspace.is-sidebar-collapsed .msg-nav-avatar {
  margin: 0 auto;
}

.msg-nav-text {
  min-width: 0;
  flex: 1;
}

.msg-nav-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
  white-space: normal;
  word-break: break-word;
}

.msg-nav-hash {
  opacity: 0.55;
  font-weight: 600;
  margin-right: 0.12em;
}

.msg-nav-sub {
  font-size: 0.68rem;
  opacity: 0.55;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-nav-item.is-active .msg-nav-sub {
  opacity: 0.8;
}

.msg-empty-side {
  padding: 0.5rem 1rem 0.75rem;
  font-size: 0.75rem;
  color: rgb(255 255 255 / 0.4);
}

.msg-main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: #fff;
}

.msg-thread {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
  height: 100%;
}

.msg-main.is-open .msg-stream-empty {
  display: none !important;
}

.msg-main.is-open .msg-thread {
  display: flex;
}

.msg-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1.15rem;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
}

.msg-topbar-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #111827;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-topbar-meta {
  margin-top: 0.1rem;
  font-size: 0.78rem;
  color: #6b7280;
}

.msg-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.28rem 0.5rem;
  border-radius: 999px;
  background: #f3f4f6;
  color: #4b5563;
}

.msg-chip.is-open {
  background: rgb(var(--color-primary-rgb) / 0.12);
  color: rgb(var(--color-primary-rgb));
}

.msg-chip.is-team,
.msg-chip.is-channel {
  background: #eef2ff;
  color: #3730a3;
}

.msg-chip.is-captains {
  background: #fff7ed;
  color: #9a3412;
}

.msg-chip.is-players {
  background: #f0f9ff;
  color: #075985;
}

.msg-chip.is-support {
  background: #f3f4f6;
  color: #374151;
}

.msg-chip.is-slack {
  background: #f5edf6;
  color: #4a154b;
}

.msg-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.msg-stream {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem 1.15rem 1rem;
  background: #fff;
}

.msg-stream-empty {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #6b7280;
  padding: 2rem;
  background: #fff;
}

.msg-stream-empty i {
  font-size: 2rem;
  color: #d1d5db;
  margin-bottom: 0.75rem;
}

.msg-day {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.85rem 0 0.55rem;
  color: #6b7280;
  font-size: 0.72rem;
  font-weight: 700;
}

.msg-day::before,
.msg-day::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

.msg-day span {
  flex-shrink: 0;
}

.msg-row {
  display: grid;
  grid-template-columns: 2.25rem 1fr;
  gap: 0.65rem;
  padding: 0.28rem 0.35rem;
  border-radius: 6px;
}

.msg-row-content {
  min-width: 0;
}

.msg-row:hover {
  background: #f8faf9;
}

.msg-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
  color: #fff;
  background: rgb(var(--color-primary-rgb));
}

.msg-avatar.is-slack {
  background: #4a154b;
}

.msg-avatar.is-admin {
  background: #1f2937;
}

.msg-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.55rem;
  margin-bottom: 0.15rem;
}

.msg-author {
  font-size: 0.9rem;
  font-weight: 700;
  color: #111827;
}

.msg-time {
  font-size: 0.72rem;
  color: #9ca3af;
}

.msg-body {
  font-size: 0.92rem;
  line-height: 1.45;
  color: #1f2937;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-composer {
  border-top: 0;
  padding: 0.55rem 1.15rem 0.95rem;
  background: #fff;
  flex-shrink: 0;
}

.msg-composer.hidden {
  display: none !important;
}

.msg-composer-box {
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 0.55rem 0.75rem 0.45rem;
  background: #fff;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
}

.msg-composer-box:focus-within {
  border-color: rgb(var(--color-primary-rgb));
}

.msg-composer-box textarea,
.msg-composer-box input {
  width: 100%;
  border: 0;
  outline: none;
  resize: none;
  font-size: 0.92rem;
  color: #111827;
  background: transparent;
  min-height: 2.4rem;
  max-height: 8rem;
}

.msg-composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.msg-send-btn {
  background: rgb(var(--color-primary-rgb));
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  border: 0;
  border-radius: 6px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
}

.msg-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.msg-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.msg-modal.is-open {
  display: flex;
}

.msg-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(15 23 42 / 0.5);
}

.msg-modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 32rem;
  background: #fff;
  border-radius: 0;
  border: 1px solid #e5e7eb;
  box-shadow: 0 25px 50px -20px rgb(15 23 42 / 0.45);
  padding: 1.25rem;
}

.msg-topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
}

.msg-topbar-btn.hidden,
#messages-close-btn.hidden,
#messages-reopen-btn.hidden,
#messages-members-btn.hidden,
#messages-archive-btn.hidden {
  display: none !important;
}

.msg-topbar-btn:hover {
  background: #f3f4f6;
}

.msg-topbar-btn-danger {
  color: #b91c1c;
  border-color: #fecaca;
}

.msg-topbar-btn-danger:hover {
  background: #fef2f2;
}

.msg-thread-split {
  display: flex;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.msg-thread-split .msg-stream {
  flex: 1;
}

.msg-members-panel {
  width: 16.5rem;
  border-left: 1px solid #e5e7eb;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.msg-members-panel.hidden {
  display: none;
}

.msg-members-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
}

.msg-members-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.35rem 0;
}

.msg-member-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.85rem;
}

.msg-member-row:hover {
  background: #f3f4f6;
}

.msg-member-avatar {
  width: 1.75rem;
  height: 1.75rem;
  background: #e5e7eb;
  color: #374151;
  font-size: 0.65rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  object-fit: cover;
}

.msg-member-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msg-member-text {
  min-width: 0;
  flex: 1;
}

.msg-member-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-member-sub {
  font-size: 0.68rem;
  color: #6b7280;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-member-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  background: #ecfdf5;
  color: rgb(var(--color-primary-rgb));
  flex-shrink: 0;
}

.msg-member-badge.is-unlinked {
  background: #f3f4f6;
  color: #6b7280;
}

.msg-attach {
  margin-top: 0.4rem;
  max-width: min(20rem, 100%);
}

.msg-attach img {
  display: block;
  max-width: 100%;
  max-height: 16rem;
  border: 1px solid #e5e7eb;
  cursor: zoom-in;
}

.msg-attach-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: rgb(var(--color-primary-rgb));
  font-weight: 600;
  text-decoration: underline;
}

.msg-attach-preview {
  position: relative;
  display: inline-block;
  margin: 0 0 0.5rem;
}

.msg-attach-preview.hidden {
  display: none;
}

.msg-attach-preview img {
  display: block;
  max-height: 5rem;
  max-width: 8rem;
  border: 1px solid #d1d5db;
}

.msg-attach-clear {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  width: 1.25rem;
  height: 1.25rem;
  border: 0;
  background: #111827;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
}

.msg-composer-actions {
  justify-content: space-between;
}

.msg-attach-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  color: #6b7280;
  cursor: pointer;
  border-radius: 6px;
}

.msg-attach-btn:hover {
  color: #111827;
  background: #f3f4f6;
}

.msg-composer-hint {
  margin: 0.4rem 0.2rem 0;
  font-size: 0.68rem;
  color: #9ca3af;
}

.msg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgb(15 23 42 / 0.75);
  padding: 1.5rem;
  cursor: zoom-out;
}

.msg-lightbox.is-open {
  display: flex;
}

.msg-lightbox img {
  max-width: min(56rem, 100%);
  max-height: 90vh;
  box-shadow: 0 25px 50px -20px rgb(0 0 0 / 0.5);
}

.msg-mobile-back {
  display: none;
}

.msg-slack-banner {
  margin: 0;
  border-bottom: 1px solid #fde68a;
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
}

.msg-slack-banner.hidden {
  display: none;
}

.msg-slack-banner-inner {
  display: flex;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  align-items: flex-start;
}

.msg-slack-banner-icon {
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #4a154b;
  color: #fff;
  font-size: 1.15rem;
}

.msg-slack-banner-copy h3 {
  font-size: 1rem;
  font-weight: 800;
  color: #78350f;
  letter-spacing: -0.02em;
}

.msg-slack-banner-copy > p {
  margin-top: 0.25rem;
  font-size: 0.88rem;
  color: #92400e;
}

.msg-slack-banner-copy ol {
  margin: 0.65rem 0 0;
  padding-left: 1.15rem;
  font-size: 0.84rem;
  color: #78350f;
  line-height: 1.45;
}

.msg-slack-banner-copy li + li {
  margin-top: 0.25rem;
}

.msg-slack-banner-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.msg-slack-connect-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #4a154b;
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  border: 0;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
}

.msg-slack-connect-btn:hover {
  background: #3a103a;
}

.msg-slack-profile-link {
  font-size: 0.82rem;
  font-weight: 700;
  color: #92400e;
  text-decoration: underline;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}

[data-panel-content="messages"].is-slack-disconnected .msg-workspace {
  opacity: 0.45;
  pointer-events: none;
  filter: grayscale(0.15);
}

@media (max-width: 900px) {
  [data-panel-content="messages"]:not(.hidden):has(#messages-slack-banner:not(.hidden)) {
    overflow-y: auto;
  }

  [data-panel-content="messages"].is-slack-disconnected .msg-workspace {
    min-height: 18rem;
  }
}

@media (max-width: 900px) {
  #portal-shell:has([data-panel-content="messages"]:not(.hidden)) {
    height: 100dvh;
    max-height: 100dvh;
  }

  #portal-shell:has([data-panel-content="messages"]:not(.hidden)) > header {
    flex-shrink: 0;
  }

  .msg-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    position: relative;
  }

  .msg-workspace.is-sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  /* List-first: hide thread until a conversation is open */
  .msg-workspace:not(.is-mobile-thread) .msg-main {
    display: none;
  }

  .msg-workspace.is-mobile-thread .msg-sidebar {
    display: none;
  }

  .msg-workspace.is-mobile-thread .msg-main {
    display: flex;
    min-height: 0;
    height: 100%;
  }

  .msg-sidebar {
    max-height: none;
    height: 100%;
    border-right: 0;
    border-bottom: 0;
  }

  .msg-sidebar-toggle {
    display: none;
  }

  .msg-sidebar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
    padding: 0.55rem;
  }

  .msg-sidebar-actions .msg-filter-select {
    grid-column: 1 / -1;
  }

  .msg-action-btn {
    justify-content: center;
    min-height: 2.5rem;
    font-size: 0.75rem;
    padding: 0.45rem 0.4rem;
  }

  .msg-nav-item {
    min-height: 2.75rem;
    padding: 0.55rem 0.9rem;
  }

  .msg-mobile-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    flex-shrink: 0;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #111827;
    cursor: pointer;
  }

  .msg-topbar {
    flex-wrap: wrap;
    gap: 0.55rem;
    padding: 0.65rem 0.75rem;
    align-items: center;
  }

  .msg-topbar-title {
    font-size: 0.95rem;
  }

  .msg-topbar-meta {
    font-size: 0.72rem;
  }

  .msg-topbar-btn span {
    display: none;
  }

  .msg-topbar-btn {
    min-width: 2.25rem;
    min-height: 2.25rem;
    justify-content: center;
    padding: 0.35rem;
  }

  .msg-stream {
    padding: 0.65rem 0.75rem 0.85rem;
    -webkit-overflow-scrolling: touch;
  }

  .msg-row {
    grid-template-columns: 2rem 1fr;
    gap: 0.55rem;
    padding: 0.45rem 0.15rem;
  }

  .msg-avatar {
    width: 2rem;
    height: 2rem;
    font-size: 0.7rem;
  }

  .msg-composer {
    padding: 0.55rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
  }

  .msg-composer-box textarea {
    font-size: 1rem; /* avoid iOS zoom */
    min-height: 2.25rem;
  }

  .msg-attach img {
    max-height: 12rem;
  }

  .msg-members-panel {
    position: absolute;
    inset: 0;
    width: auto;
    z-index: 6;
    border-left: 0;
    background: #fff;
  }

  .msg-modal {
    padding: 0;
    align-items: flex-end;
  }

  .msg-modal-card {
    max-width: none;
    width: 100%;
    max-height: min(92dvh, 100%);
    overflow-y: auto;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }

  .msg-lightbox {
    padding: 0.75rem;
  }

  .msg-thread-empty.msg-stream-empty,
  .msg-main.is-open .msg-stream-empty {
    display: none;
  }
}

@media (min-width: 901px) {
  .msg-mobile-back {
    display: none !important;
  }
}
