/* Final release density and safety workflows. */
.safe-dialog.store-dialog .store-tiers {
  grid-auto-rows: 1fr;
}

.safe-dialog.store-dialog .store-tier {
  height: 100% !important;
}
.chat-app .right-panel.panel-members .panel-scroll {
  padding: 7px 9px;
  gap: 6px;
}
.chat-app .right-panel.panel-members .panel-card-grid {
  gap: 4px;
}
.chat-app .right-panel.panel-members .member-card {
  min-height: 47px;
  padding: 2px 7px;
  border-radius: 10px;
}
.chat-app .right-panel.panel-members .member-card-main {
  gap: 7px;
  min-height: 47px;
}
.chat-app .right-panel.panel-members .member-avatar {
  width: 33px;
  height: 33px;
  flex: 0 0 33px;
  border-radius: 10px;
}
.chat-app .right-panel.panel-members .member-card-main strong {
  font-size: 11px;
  line-height: 1.1;
}
.chat-app .right-panel.panel-members .member-popularity,
.chat-app .right-panel.panel-members .member-card-main p {
  margin: 1px 0 0;
  font-size: 8px;
  line-height: 1.15;
}

.chat-app .right-panel.panel-members .member-presence {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
  color: #368f75;
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
}

.chat-app .right-panel.panel-members .member-presence i,
.follow-presence i {
  display: block;
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #28bd91;
}

.follow-presence.is-offline i {
  background: #aaa2b5;
}
.chat-app .right-panel.panel-members .member-card-main p {
  display: none;
}

/* People cards and profile surfaces use the shared theme palette all the way
   through their interactive states. Keep these rules in the final layer so
   older, light-only panel styles cannot win the cascade. */
.chat-app .right-panel.people-density .panel-card {
  border-color: var(--ui-line);
  color: var(--ui-text);
  background: var(--ui-surface);
}
.chat-app .right-panel.people-density .member-card-main,
.chat-app .right-panel.people-density .member-card-main strong,
.chat-app .right-panel.people-density .friend-card strong {
  color: var(--ui-text);
}
.chat-app .right-panel.people-density .member-popularity,
.chat-app .right-panel.people-density .member-card-main p,
.chat-app .right-panel.people-density .friend-card p {
  color: var(--ui-muted);
}
.chat-app .right-panel.people-density .panel-card:is(:hover, :focus-within),
.chat-app .right-panel.people-density .panel-card:is(.active, .selected),
.chat-app .right-panel.people-density .panel-card:has([aria-current='true']),
.chat-app .right-panel.people-density .panel-card:has([aria-pressed='true']) {
  border-color: color-mix(in srgb, var(--tw-accent) 48%, var(--ui-line));
  background: var(--ui-tint);
  box-shadow: 0 7px 20px color-mix(in srgb, var(--tw-accent) 10%, transparent);
}
.chat-app .right-panel.people-density .member-card-main:focus-visible,
.chat-app .right-panel.people-density .friend-card:focus-visible {
  outline: 2px solid var(--tw-accent);
  outline-offset: 2px;
  border-radius: 9px;
}
.chat-app .right-panel.people-density .self-member-tag,
.chat-app .right-panel.people-density .global-status,
.chat-app .profile-hub .global-status {
  border-color: color-mix(in srgb, var(--tw-accent) 35%, var(--ui-line));
  color: var(--ui-text);
  background: color-mix(in srgb, var(--tw-accent) 14%, var(--ui-surface));
}
.chat-app .right-panel.people-density .member-manage-button {
  border: 1px solid color-mix(in srgb, var(--tw-accent) 28%, var(--ui-line));
  color: var(--tw-accent);
  background: var(--ui-tint);
}
.chat-app .right-panel.people-density .member-manage-button:hover,
.chat-app .right-panel.people-density .member-manage-button:focus-visible {
  color: var(--ui-surface);
  background: var(--tw-accent);
}
.chat-app .right-panel .profile-hero {
  border-color: var(--ui-line);
  color: var(--ui-text);
  background: linear-gradient(165deg, var(--ui-tint), var(--ui-surface) 75%);
}
.chat-app .right-panel .profile-hero > strong {
  color: var(--ui-text);
}
.chat-app .right-panel .profile-hero > p {
  color: var(--ui-muted);
}
.chat-app .right-panel .profile-hero > button {
  border-color: var(--ui-line);
  color: var(--tw-accent);
  background: var(--ui-surface);
}
.chat-app .right-panel .profile-hero > button:is(:hover, :focus-visible) {
  border-color: color-mix(in srgb, var(--tw-accent) 48%, var(--ui-line));
  background: var(--ui-tint);
}
[data-twetty-theme='dark'] .member-profile-offline-note {
  border-color: var(--ui-line);
  color: var(--ui-muted);
  background: var(--ui-soft);
}
.chat-app .presence-system-message {
  grid-template-columns: 28px minmax(0, 1fr) 28px;
  width: 275px;
  min-height: 34px;
  height: auto;
  gap: 7px;
  margin: 0 0 0 12px;
  padding: 3px 0 !important;
}
.chat-app .presence-system-message .system-message-avatar.message-avatar {
  width: 24px;
  height: 24px;
}
.chat-app .presence-system-message > span:nth-child(2) {
  font-size: 9px;
  line-height: 1.25;
}
.report-field,
.report-evidence {
  display: grid;
  gap: 7px;
  margin: 0 0 12px;
  color: var(--ui-text);
  font-weight: 700;
}
.report-field select {
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--ui-line);
  border-radius: 11px;
  background: var(--ui-surface);
  color: var(--ui-text);
}
.report-evidence {
  grid-template-columns: 22px 1fr;
  align-items: center;
  padding: 12px;
  border: 1px dashed var(--tw-accent);
  border-radius: 12px;
  background: var(--ui-soft);
  cursor: pointer;
}
.report-evidence input {
  grid-column: 1 / -1;
}
.staff-warning-form {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}
.staff-warning-form textarea {
  min-height: 70px;
  resize: vertical;
  padding: 9px;
  border: 1px solid var(--ui-line);
  border-radius: 10px;
}
.safe-dialog.image-crop-dialog {
  width: min(560px, calc(100vw - 24px));
  overflow: hidden;
  border-color: color-mix(in srgb, var(--tw-accent) 24%, var(--ui-line));
  background:
    radial-gradient(circle at 8% 0%, rgb(122 91 255 / 10%), transparent 32%),
    var(--ui-surface);
  box-shadow:
    0 32px 90px rgb(34 20 76 / 28%),
    0 0 0 1px rgb(255 255 255 / 62%) inset;
}
.safe-dialog.image-crop-dialog.is-crop-editor {
  width: min(780px, calc(100vw - 24px));
}
.image-crop-dialog .dialog-heading {
  border-bottom-color: color-mix(in srgb, var(--tw-accent) 18%, var(--ui-line));
  background: linear-gradient(
    112deg,
    color-mix(in srgb, var(--tw-accent) 9%, var(--ui-surface)),
    var(--ui-surface) 58%,
    color-mix(in srgb, var(--tw-accent-2) 7%, var(--ui-surface))
  );
}
.image-crop-dialog .dialog-heading-icon {
  color: #fff;
  background: linear-gradient(135deg, var(--tw-accent), var(--tw-accent-2));
  box-shadow: 0 9px 24px rgb(112 77 242 / 28%);
}
.image-crop-dialog > div:last-child {
  display: grid;
  gap: 10px;
  max-height: calc(100dvh - 90px);
  overflow: auto;
  padding: 16px;
}
.image-editor-stage {
  position: relative;
  width: 100%;
  height: min(500px, 58dvh);
  min-height: 300px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  border: 1px solid color-mix(in srgb, var(--tw-accent) 28%, var(--ui-line));
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 40%, rgb(119 89 255 / 16%), transparent 55%),
    linear-gradient(145deg, #12101a, #201a31);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 4%);
}
.image-editor-source {
  position: absolute;
  display: block;
  max-width: none;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 18px 28px rgb(0 0 0 / 32%));
}
.image-editor-crop-window {
  position: absolute;
  z-index: 2;
  display: block;
  padding: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  border: 2px solid #8c72ff;
  border-radius: 12px;
  outline: 1px solid rgb(255 255 255 / 72%);
  background: transparent;
  box-shadow: 0 0 0 9999px rgb(5 4 10 / 58%);
}
.image-editor-crop-window.is-avatar {
  border-radius: 50%;
}
.image-editor-crop-window:active {
  cursor: grabbing;
}
.image-editor-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 33.1%, rgb(255 255 255 / 32%) 33.3%, transparent 33.6%, transparent 66.3%, rgb(255 255 255 / 32%) 66.6%, transparent 66.9%),
    linear-gradient(transparent 33.1%, rgb(255 255 255 / 32%) 33.3%, transparent 33.6%, transparent 66.3%, rgb(255 255 255 / 32%) 66.6%, transparent 66.9%);
  opacity: 0.7;
}
.image-editor-resizer {
  position: absolute;
  z-index: 3;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  padding: 0;
  touch-action: none;
  cursor: nwse-resize;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 14px rgb(0 0 0 / 38%);
}
.image-editor-resizer > span {
  width: 12px;
  height: 12px;
  border-right: 3px solid #7356f5;
  border-bottom: 3px solid #7356f5;
}
.image-editor-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: -2px;
  padding: 8px 11px;
  color: var(--ui-muted);
  border: 1px solid color-mix(in srgb, var(--tw-accent) 12%, var(--ui-line));
  border-radius: 11px;
  background: color-mix(in srgb, var(--tw-accent) 4%, var(--ui-soft));
  font-size: 12px;
  font-weight: 750;
}
.image-editor-mode {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}
.image-editor-mode button,
.image-editor-aspects button {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--ui-line);
  border-radius: 12px;
  color: var(--ui-muted);
  background: var(--ui-soft);
  font-weight: 800;
}
.image-editor-mode button svg {
  width: 17px;
}
.image-editor-mode button.is-active,
.image-editor-aspects button.is-active {
  color: var(--tw-accent);
  border-color: color-mix(in srgb, var(--tw-accent) 55%, var(--ui-line));
  background: color-mix(in srgb, var(--tw-accent) 11%, var(--ui-surface));
  box-shadow: 0 7px 20px rgb(112 77 242 / 12%);
}
.image-editor-mode button:hover:not(:disabled),
.image-editor-aspects button:hover:not(:disabled) {
  color: var(--ui-text);
  border-color: color-mix(in srgb, var(--tw-accent) 35%, var(--ui-line));
  transform: translateY(-1px);
}
.image-editor-aspects {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.image-editor-aspects button {
  min-width: 58px;
  min-height: 34px;
  padding: 6px 10px;
}
.image-editor-help {
  margin: 0;
  color: var(--ui-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
}
.image-crop-preview {
  display: grid;
  place-items: center;
  width: min(520px, 82vw);
  min-height: 260px;
  max-height: 58dvh;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--ui-line);
  border-radius: 18px;
  background: #15121f;
}
.image-crop-preview img {
  width: 100%;
  height: 100%;
  max-height: 58dvh;
  object-fit: contain;
}
.image-process-progress {
  display: grid;
  gap: 6px;
}
.image-process-progress progress {
  width: 100%;
}
.image-crop-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr);
  gap: 8px;
  width: 100%;
  margin-top: 2px;
}
.image-crop-actions button {
  display: inline-flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 12px;
  border: 1px solid var(--ui-line);
  border-radius: 12px;
  font-weight: 850;
}
.image-crop-actions button svg {
  width: 17px;
}
.image-crop-actions .image-crop-cancel {
  color: #b7365d;
  background: color-mix(in srgb, #e54879 9%, var(--ui-surface));
}
.image-crop-actions .image-crop-submit {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(120deg, var(--tw-accent), var(--tw-accent-2));
  box-shadow: 0 10px 24px rgb(112 77 242 / 22%);
}
.image-crop-actions .image-crop-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgb(112 77 242 / 30%);
}
@media (max-width: 520px) {
  .safe-dialog.image-crop-dialog.is-crop-editor {
    width: calc(100vw - 12px);
  }
  .image-editor-stage {
    height: min(430px, 52dvh);
    min-height: 250px;
  }
  .image-editor-mode {
    grid-template-columns: 1fr 1fr;
  }
  .image-editor-mode button:last-child {
    grid-column: 1 / -1;
  }
  .image-editor-summary {
    flex-wrap: wrap;
  }
  .image-crop-preview {
    width: min(300px, 76vw);
  }
  .image-crop-actions {
    grid-template-columns: 1fr 1.35fr;
  }
  .image-crop-actions button {
    justify-content: center;
  }
  .chat-app .presence-system-message {
    margin-left: 5px;
    max-width: calc(100% - 10px);
  }
}

/* Final message rhythm: media breathes and system rows use the chat grid. */
.chat-app .message-content > p + .chat-uploaded-image,
.chat-app .message-content > p + .chat-emoji-asset,
.chat-app .message-content > p + .sent-gif {
  margin-top: 6px;
}
.chat-app .presence-system-message {
  grid-template-columns: 32px minmax(0, 1fr) 28px;
  width: 100%;
  max-width: none;
  min-height: 42px;
  gap: 8px;
  margin-inline: 0 !important;
  padding: 5px 0 !important;
}
.chat-app .presence-system-message .system-message-avatar.message-avatar {
  width: 32px;
  height: 32px;
}
.chat-app .presence-system-message > span:nth-child(2) {
  font-size: 11px;
}
@media (max-width: 760px) {
  .chat-app .chat-message {
    grid-template-columns: 32px minmax(0, 1fr) 28px;
    gap: 8px;
  }
  .chat-app .chat-message > .message-avatar {
    justify-self: center;
  }
  .chat-app .presence-system-message {
    grid-template-columns: 28px minmax(0, 1fr) 28px;
    min-height: 38px;
    gap: 6px;
  }
  .chat-app .presence-system-message .system-message-avatar.message-avatar {
    width: 28px;
    height: 28px;
  }
}

/* OWNER frames are wider than regular membership frames. Reserve space only
   for those messages and remove the avatar button's square backing layer. */
.chat-app .chat-message.is-owner-message {
  grid-template-columns: 48px minmax(0, 1fr) 28px;
  column-gap: 12px;
}
.chat-app .chat-message.is-owner-message > .message-avatar {
  justify-self: center;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
.chat-app
  .chat-message.is-owner-message
  > .message-avatar
  > img:not(.membership-frame) {
  box-shadow: none !important;
}
.chat-app
  .chat-message.is-owner-message
  > .message-avatar
  > .owner-profile-frame {
  background: transparent !important;
  box-shadow: none !important;
  object-fit: contain !important;
}

/* Paid/DJ frames also sit on a transparent avatar button. The frame artwork
   supplies its own decoration; a square gradient behind it must never show. */
.chat-app
  .chat-message:has(> .message-avatar > .membership-frame)
  > .message-avatar {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
.chat-app
  .chat-message:has(> .message-avatar > .membership-frame)
  > .message-avatar
  > img:not(.membership-frame),
.chat-app
  .chat-message:has(> .message-avatar > .membership-frame)
  > .message-avatar
  > .membership-frame {
  background: transparent !important;
  box-shadow: none !important;
}
.chat-app
  .chat-message:has(> .message-avatar > .membership-frame)
  > .message-avatar
  > .membership-frame {
  object-fit: contain !important;
}

/* Message deletion stays visible on desktop and becomes a deliberate swipe on touch. */
.chat-app .chat-message .message-content {
  position: relative;
  z-index: 1;
  transform: translateX(var(--message-swipe-x, 0));
  transition: transform 160ms ease;
  touch-action: pan-y;
}
.chat-app .chat-message.is-swiping .message-content {
  transition: none;
}
.chat-app .message-delete-action {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  display: inline-grid;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  place-items: center;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: color-mix(in srgb, #cc355d 72%, var(--ui-muted));
  background: color-mix(in srgb, #ef4774 8%, transparent);
  cursor: pointer;
}
.chat-app .chat-message.is-deletable .message-meta {
  padding-right: 24px;
}
.chat-app .message-delete-action:hover,
.chat-app .message-delete-action:focus-visible {
  color: #c62d58;
  background: color-mix(in srgb, #ef4774 16%, var(--ui-surface));
}
.chat-app .message-delete-action svg {
  width: 13px;
  height: 13px;
}
.chat-app .message-swipe-delete-cue {
  position: absolute;
  top: 50%;
  right: 38px;
  z-index: 0;
  display: none;
  align-items: center;
  gap: 4px;
  min-width: 54px;
  color: #c62d58;
  font-size: 10px;
  font-weight: 900;
  transform: translateY(-50%);
}
.chat-app .message-swipe-delete-cue svg {
  width: 15px;
  height: 15px;
}
@media (pointer: coarse), (max-width: 760px) {
  .chat-app .message-delete-action {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }
  .chat-app .message-swipe-delete-cue {
    display: inline-flex;
  }
}

/* The delete decision is intentionally small: the message remains visible
   around it and the three actions stay reachable without a second scroll. */
.chat-app .message-delete-dialog {
  width: min(292px, calc(100vw - 24px));
  gap: 6px;
  padding: 14px;
  border-radius: 16px;
}
.chat-app .message-delete-dialog h3 {
  margin: 0 0 2px;
  font-size: 16px;
  line-height: 1.25;
}
.chat-app .message-delete-dialog p {
  margin: 0 0 3px;
  font-size: 12px;
  line-height: 1.35;
}
.chat-app .message-delete-dialog button {
  min-height: 34px;
  padding-inline: 12px;
  border-radius: 10px;
  font-size: 12px;
}

/* Conversation inbox cards can be removed directly or by a touch swipe. */
.chat-app .conversation-card {
  position: relative;
  display: block;
  transform: translateX(var(--conversation-swipe-x, 0));
  transition: transform 160ms ease;
  touch-action: pan-y;
}
.chat-app .conversation-card.is-swiping {
  transition: none;
}
.chat-app .conversation-card-main {
  display: grid;
  grid-template-columns: 39px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 0 58px 0 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.chat-app .conversation-card-main > div {
  display: grid;
  min-width: 0;
}
.chat-app .conversation-card > time {
  position: absolute;
  top: 9px;
  right: 34px;
}
.chat-app .conversation-delete-action {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: #c83b62;
  background: color-mix(in srgb, #ef4774 10%, transparent);
  cursor: pointer;
}
.chat-app .conversation-delete-action:hover,
.chat-app .conversation-delete-action:focus-visible {
  background: color-mix(in srgb, #ef4774 20%, var(--ui-surface));
}
.chat-app .conversation-delete-action svg {
  width: 14px;
  height: 14px;
}
@media (pointer: coarse), (max-width: 760px) {
  .chat-app .conversation-delete-action {
    width: 32px;
    height: 32px;
  }
  .chat-app .conversation-card > time {
    right: 42px;
  }
}

/* Private message actions stay hidden until tap (mobile) or context-click
   (desktop), keeping the message surface calm and uncluttered. */
.chat-app .direct-body > p {
  position: relative;
}
.chat-app .dm-message-action-trigger {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  cursor: context-menu;
}
.chat-app
  .direct-body
  > p
  > :not(.dm-message-action-trigger, .dm-message-menu) {
  position: relative;
  z-index: 1;
}
.chat-app .direct-body > p > span:not(.dm-message-menu),
.chat-app .direct-body > p > small {
  pointer-events: none;
}
.chat-app .dm-message-menu {
  position: absolute;
  top: -34px;
  right: 0;
  z-index: 4;
}
.chat-app .dm-incoming .dm-message-menu {
  right: auto;
  left: 0;
}
.chat-app .dm-message-menu button {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid color-mix(in srgb, var(--tw-accent) 22%, var(--ui-line));
  border-radius: 9px;
  color: var(--ui-text);
  background: var(--ui-surface);
  box-shadow: 0 8px 24px rgb(31 24 62 / 18%);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.chat-app .dm-message-menu svg {
  width: 13px;
  height: 13px;
}
.chat-app .direct-message {
  display: flex;
  flex-direction: column;
}
.chat-app .direct-message > header {
  flex: 0 0 52px;
}
.chat-app .direct-message > .direct-body {
  flex: 1 1 auto;
  min-height: 0;
}
.chat-app .direct-message > form {
  flex: 0 0 auto;
}
.chat-app .dm-quoted-message {
  display: grid;
  gap: 1px;
  width: 100%;
  padding: 5px 7px;
  border: 0;
  border-left: 3px solid currentColor;
  border-radius: 6px;
  color: inherit;
  background: color-mix(in srgb, currentColor 10%, transparent);
  text-align: left;
}
.chat-app .direct-body > p.is-quote-target {
  animation: dm-quote-target 1.8s ease;
  outline: 2px solid color-mix(in srgb, var(--tw-accent) 72%, white);
  outline-offset: 3px;
}
@keyframes dm-quote-target {
  0%,
  100% {
    box-shadow: none;
  }
  28%,
  68% {
    box-shadow: 0 0 0 7px color-mix(in srgb, var(--tw-accent) 18%, transparent);
  }
}
.chat-app .dm-quoted-message strong,
.chat-app .dm-quoted-message span,
.chat-app .dm-reply-preview span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-app .dm-reply-preview {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid #e8e3f4;
  background: #f8f5ff;
  color: #6655bd;
  font-size: 10px;
}
.chat-app .dm-reply-preview > div {
  display: grid;
  min-width: 0;
}
.chat-app .dm-reply-preview button {
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: inherit;
}
.chat-app .dm-reply-preview svg {
  width: 14px;
  height: 14px;
}
.chat-app .dm-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 2px 12px;
  color: #7b718c;
  font-size: 10px;
}
.chat-app .dm-typing strong {
  color: #684de0;
}
.chat-app .dm-typing i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #8d71ec;
  animation: typing-dot 1s ease-in-out infinite;
}
.chat-app .dm-typing i:nth-last-child(2) {
  animation-delay: 0.14s;
}
.chat-app .dm-typing i:last-child {
  animation-delay: 0.28s;
}
.chat-app .dm-message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.chat-app .dm-delivery-state,
.chat-app .conversation-delivery {
  display: inline-flex;
  color: #9ba1ae;
}
.chat-app .dm-delivery-state.is-read,
.chat-app .conversation-delivery.is-read {
  color: #36a7ee;
}
.chat-app .dm-delivery-state svg,
.chat-app .conversation-delivery svg {
  width: 15px;
  height: 15px;
  stroke-width: 2.4;
}
.image-lightbox.is-profile-photo .image-lightbox-canvas img {
  width: min(88vw, 88dvh, 900px) !important;
  height: min(88vw, 88dvh, 900px) !important;
  max-width: 88vw !important;
  max-height: 88dvh !important;
  object-fit: contain !important;
}
@media (pointer: coarse), (max-width: 760px) {
  .chat-app .dm-message-menu {
    top: -38px;
  }
  .chat-app .dm-message-menu button {
    min-height: 34px;
    padding-inline: 12px;
  }
}

/* Mobile conversation alignment: keep actions discoverable without spending a
   permanent column beside every message. */
.chat-app .message-content {
  box-sizing: border-box;
  max-width: min(650px, 100%);
  overflow: hidden;
}
.chat-app .message-content p {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.chat-app .reply-line {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  align-items: center;
  gap: 1px 6px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  margin: 3px 0 4px;
  padding: 4px 6px;
  border: 0;
  border-left: 3px solid currentColor;
  border-radius: 6px;
  background: color-mix(in srgb, currentColor 8%, transparent);
  color: #8f6fdb;
  text-align: left;
}
.chat-app .reply-line > svg {
  grid-row: 1 / span 2;
  width: 12px;
  height: 12px;
}
.chat-app .reply-line > strong,
.chat-app .reply-line > span {
  grid-column: 2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-app .reply-line > strong {
  font-size: 9px;
}
.chat-app .reply-line > span {
  font-size: 8px;
  font-weight: 650;
  opacity: 0.82;
}
.chat-app .date-divider.has-room-reset {
  position: sticky;
  z-index: 12;
  top: 0;
  min-height: 34px;
  margin-top: -4px;
  padding-block: 4px;
  background: color-mix(in srgb, var(--ui-surface) 90%, transparent);
  box-shadow: 0 8px 16px color-mix(in srgb, var(--ui-text) 5%, transparent);
  backdrop-filter: blur(12px);
}
.chat-app .mobile-people-button {
  overflow: visible;
}
.chat-app .mobile-people-count {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  box-sizing: border-box;
  padding-inline: 4px;
  border: 2px solid var(--ui-surface);
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #7658ed, #379ce8);
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
}

.chat-app .conversation-swipe-delete-cue {
  position: absolute;
  top: 0;
  right: -66px;
  display: none;
  width: 62px;
  height: 100%;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #e95073, #c8325a);
  font-size: 10px;
  font-weight: 900;
}
.chat-app .conversation-swipe-delete-cue svg {
  width: 15px;
  height: 15px;
}

/* Dense private messages keep short messages and their time on one compact
   line, while quoted and media content still receive the full bubble width. */
.chat-app .direct-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  padding: 8px;
}
.chat-app .direct-body > p {
  display: flex;
  width: fit-content;
  max-width: min(82%, 480px);
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 2px 7px;
  box-sizing: border-box;
  margin: 0;
  padding: 6px 9px;
  line-height: 1.35;
}
.chat-app .direct-body > .dm-incoming {
  align-self: flex-start;
}
.chat-app .direct-body > .dm-outgoing {
  align-self: flex-end;
  margin-left: 0;
}
.chat-app .direct-body > p > .dm-message-meta {
  flex: 0 0 auto;
  align-self: flex-end;
  margin-left: auto;
  font-size: 8px;
  line-height: 1;
}
.chat-app .direct-body > p > .dm-quoted-message,
.chat-app .direct-body > p > .voice-message,
.chat-app .direct-body > p > .sent-gif,
.chat-app .direct-body > p > .dm-image-open,
.chat-app .direct-body > p > .dm-view-once-image {
  flex: 1 0 100%;
}

@media (max-width: 760px) {
  .chat-app .chat-center > .message-stage {
    padding: 7px 7px 9px;
    overflow-x: hidden;
  }
  .chat-app .chat-message {
    grid-template-columns: 28px minmax(0, 1fr) !important;
    gap: 6px !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .chat-app .message-content {
    width: fit-content;
    min-width: min(112px, 100%);
    max-width: 100%;
    padding: 6px 8px;
  }
  .chat-app .message-delete-action {
    display: inline-grid !important;
  }
  .chat-app .message-swipe-delete-cue {
    right: 5px;
    display: none;
  }
  .chat-app .chat-message.is-swiping .message-swipe-delete-cue {
    display: inline-flex;
  }
  .chat-app .message-reply-action {
    display: none !important;
  }
  .chat-app .date-divider.has-room-reset {
    margin-inline: -2px;
  }
  .chat-app .mobile-people-button {
    position: fixed;
    top: calc(var(--twetty-app-top, 0px) + var(--twetty-app-height, 100dvh) / 2);
    right: env(safe-area-inset-right, 0px);
    z-index: 18;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 52px;
    min-height: 44px;
    height: auto;
    gap: 5px;
    padding: 4px 7px;
    border-radius: 12px 0 0 12px;
    transform: translateY(-50%);
    box-shadow: 0 4px 16px color-mix(in srgb, var(--ui-text) 12%, transparent);
  }
  .chat-app:has(.right-panel.panel-open, .direct-message, .media-picker, .mention-suggestions)
    .mobile-people-button {
    pointer-events: none;
    opacity: 0;
  }
  .chat-app .media-picker,
  .chat-app .mention-suggestions {
    z-index: 24;
  }
  .chat-app .mobile-people-count {
    position: static;
    padding: 0 4px;
    border-width: 0;
  }
  .chat-app .date-divider {
    position: sticky;
    top: 0;
    z-index: 12;
    min-height: 36px;
    gap: 8px;
    background: var(--ui-surface);
  }
  .chat-app .panel-scroll {
    overflow-x: hidden;
  }
  .chat-app .right-panel {
    right: 0 !important;
    left: 0 !important;
    width: auto !important;
    max-width: none !important;
  }
  .chat-app .conversation-card {
    min-height: 64px;
    box-sizing: border-box;
  }
  .chat-app .conversation-card-main {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 9px;
    min-height: 46px;
    padding-right: 52px;
  }
  .chat-app .conversation-delete-action {
    display: none !important;
  }
  .chat-app .conversation-card > time {
    top: 9px;
    right: 9px;
  }
  .chat-app .conversation-card .message-read-state {
    right: 9px;
    bottom: 8px;
  }
  .chat-app .conversation-swipe-delete-cue {
    display: flex;
    visibility: hidden;
    opacity: 0;
    transition: opacity 120ms ease;
  }
  .chat-app .conversation-card.is-swiping .conversation-swipe-delete-cue {
    visibility: visible;
    opacity: 1;
  }
  .chat-app .direct-message > header {
    flex-basis: 52px;
    min-height: 52px;
    padding-inline: 8px;
  }
  .chat-app .direct-message header > button {
    width: 34px;
    min-width: 34px;
    height: 36px;
  }
  .chat-app .direct-body {
    gap: 3px;
    padding: 7px;
  }
  .chat-app .direct-body > p {
    max-width: 86%;
    padding: 6px 8px;
    font-size: 13px;
  }
  .chat-app .direct-message > form {
    flex-wrap: nowrap;
    padding: 6px 5px calc(6px + env(safe-area-inset-bottom, 0px));
  }
}

/* Leave a scrollable resting place for the shortcut, never over the last line. */
.chat-app:has(.radio-dock) .message-stage,
.chat-app:has(.radio-dock) .direct-body {
  padding-bottom: 76px;
}

@media (max-width: 760px) {
  .chat-app .chat-message.is-owner-message {
    grid-template-columns: 40px minmax(0, 1fr) !important;
    column-gap: 10px !important;
  }
}

/* Narrow phones keep the complete navigation on one row. The columns, icons
   and counters scale together instead of letting the profile frame overflow. */
@media (max-width: 520px) {
  .chat-app > .chat-topbar {
    grid-template-columns: minmax(68px, 1fr) minmax(0, 202px) !important;
    padding-inline: 3px !important;
    column-gap: 1px !important;
  }
  .chat-app .topbar-actions {
    grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(30px, 36px) !important;
    gap: clamp(0px, 0.45vw, 2px) !important;
  }
  .chat-app .topbar-actions:has(> .room-bulletin-slot) {
    grid-template-columns: repeat(6, minmax(0, 1fr)) minmax(30px, 36px) !important;
  }
  .chat-app .topbar-actions > button,
  .chat-app .topbar-actions > .profile-action {
    height: 42px !important;
    min-width: 0 !important;
    padding-inline: 0 !important;
    border-radius: 8px !important;
  }
  .chat-app .topbar-actions > button > svg {
    width: clamp(15px, 5.4vw, 19px) !important;
    height: clamp(15px, 5.4vw, 19px) !important;
  }
  .chat-app .profile-action > b {
    width: clamp(23px, 8vw, 27px) !important;
    height: clamp(23px, 8vw, 27px) !important;
  }
  .chat-app .topbar-actions > button i {
    top: 0 !important;
    right: 0 !important;
    min-width: 14px !important;
    height: 14px !important;
    padding-inline: 2px !important;
    border-width: 1px !important;
    font-size: 7px !important;
  }
}

@media (max-width: 340px) {
  .chat-app > .chat-topbar {
    grid-template-columns: minmax(66px, 1fr) 190px !important;
  }
  .chat-app .topbar-brand .brand-icon {
    width: 23px !important;
    height: 23px !important;
  }
  .chat-app .topbar-brand .brand > span:last-child {
    font-size: 13px !important;
  }
}

@media (max-width: 280px) {
  .chat-app > .chat-topbar {
    grid-template-columns: 28px minmax(0, 1fr) !important;
  }
  .chat-app .topbar-brand .brand > span:last-child {
    display: none !important;
  }
}

/* Final room-message geometry. Every row shares one avatar rail, so standard,
   framed and OWNER identities start their bubbles on the same vertical line. */
.chat-app .message-list {
  width: 100%;
}
.chat-app .chat-message,
.chat-app .chat-message.is-owner-message {
  grid-template-columns: 64px minmax(0, 1fr) !important;
  align-items: start;
  gap: 10px !important;
  width: 100%;
  min-height: 58px;
  box-sizing: border-box;
  padding: 8px 6px !important;
}
.chat-app .chat-message > .message-avatar,
.chat-app .chat-message.is-owner-message > .message-avatar {
  align-self: start;
  justify-self: center;
  width: 42px;
  height: 42px;
  margin-top: 2px;
}
.chat-app .chat-message > .message-content {
  align-self: start;
  justify-self: start;
  width: fit-content;
  min-width: 118px;
  max-width: min(650px, 100%);
}
.chat-app .presence-system-message {
  grid-template-columns: 64px minmax(0, 1fr) auto !important;
  align-items: center;
  gap: 10px !important;
  width: 100%;
  min-height: 52px;
  box-sizing: border-box;
  padding: 6px !important;
}
.chat-app .presence-system-message .system-message-avatar.message-avatar {
  justify-self: center;
  width: 36px;
  height: 36px;
}
.chat-app
  .presence-system-message
  .system-message-avatar.message-avatar:has(> .membership-frame) {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
.chat-app .chat-uploaded-image {
  display: block;
  width: auto;
  max-width: min(320px, 100%);
  max-height: 280px;
  border-radius: 12px;
  object-fit: contain;
}

/* Lightboxes are portaled directly under body and own the complete viewport.
   This prevents a transformed chat panel from clipping one-view images. */
body > .image-lightbox {
  position: fixed !important;
  z-index: 2147483000 !important;
  inset: 0 !important;
  width: 100dvw !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  transform: none !important;
}
body > .image-lightbox > .image-lightbox-canvas {
  width: 100dvw !important;
  height: 100dvh !important;
}

@media (max-width: 760px) {
  .chat-app .chat-message,
  .chat-app .chat-message.is-owner-message {
    grid-template-columns: 52px minmax(0, 1fr) !important;
    gap: 8px !important;
    min-height: 50px;
    padding: 6px 2px !important;
  }
  .chat-app .chat-message > .message-avatar,
  .chat-app .chat-message.is-owner-message > .message-avatar {
    width: 34px;
    height: 34px;
    margin-top: 2px;
  }
  .chat-app .chat-message > .message-content {
    min-width: min(112px, 100%);
    max-width: 100%;
  }
}
@media (min-width: 360px) and (max-width: 760px) {
  .chat-app .chat-message > .message-content {
    max-width: calc(100% - 48px);
  }
  .chat-app .presence-system-message {
    grid-template-columns: 52px minmax(0, 1fr) auto !important;
    min-height: 46px;
    gap: 8px !important;
    padding: 5px 2px !important;
  }
  .chat-app .presence-system-message .system-message-avatar.message-avatar {
    width: 32px;
    height: 32px;
  }
  .chat-app .chat-uploaded-image {
    max-width: min(260px, 100%);
    max-height: 240px;
  }
}

/* Keep the radio inside the visible viewport when the keyboard opens. */
.safe-dialog.safe-dialog.radio-dialog {
  display: flex;
  flex-direction: column;
  top: calc(var(--twetty-app-top, 0px) + var(--twetty-app-height, 100dvh) / 2) !important;
  max-height: calc(var(--twetty-app-height, 100dvh) - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) !important;
  overflow: hidden;
}
.radio-dialog > .dialog-heading {
  flex: 0 0 auto;
}
.radio-dialog > .radio-shell {
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 8px;
}
.radio-dialog .dj-track-dropdown {
  position: static;
  max-height: none;
  margin-top: 5px;
  overflow: visible;
}
.radio-dialog .dj-track-dropdown article button {
  min-height: 40px;
}
.safe-dialog.gift-picker {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: clamp(680px, 72vw, 920px) !important;
  max-width: calc(100vw - 32px) !important;
  max-height: calc(100dvh - 24px) !important;
  padding: 18px !important;
  overflow: hidden;
}
.safe-dialog.gift-picker > .dialog-heading {
  position: static;
  padding: 0;
  border: 0;
  background: transparent;
}
.safe-dialog.gift-picker .dialog-heading-copy {
  display: flex;
}
.safe-dialog.gift-picker > .dialog-heading > button {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  flex-basis: 44px;
}
.safe-dialog.gift-picker .gift-grid {
  min-height: 0;
  overscroll-behavior: contain;
}
@media (max-width: 760px) {
  .safe-dialog.gift-picker {
    width: calc(100vw - 16px) !important;
    padding: 12px !important;
  }
}
