* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Unified avatar scale/shape/fallback used by profile, group, and channel
     avatars everywhere -- xs for inline chips, sm for message/list rows,
     md for member rows, lg for the picker/info-page preview circle. */
  --avatar-xs: 24px;
  --avatar-sm: 32px;
  --avatar-md: 40px;
  --avatar-lg: 96px;
  --avatar-gradient: linear-gradient(135deg, #007aff 0%, #0051d5 100%);
}

html, body {
  height: 100%;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: #f5f5f5;
  color: #333;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

#page-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 20px;
}

.page h1 {
  font-size: 2.5rem;
  color: #222;
}

/* Bottom Navigation */
#bottom-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  background-color: #fff;
  border-top: 1px solid #e0e0e0;
  padding: 8px 0;
  flex-shrink: 0;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
  position: relative;
  z-index: 12;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  font-size: 12px;
  font-family: inherit;
  transition: color 0.2s ease;
  flex: 1;
  max-width: 80px;
}

.nav-tab .nav-icon {
  font-size: 18px;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.nav-tab .nav-label {
  font-size: 11px;
  white-space: nowrap;
}

.nav-tab.active {
  color: #007aff;
}

.nav-tab.active .nav-icon {
  opacity: 1;
}

/* Messages Page */
.messages-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: #f5f5f5;
}

.messages-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.messages-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #222;
  margin: 0;
}

.messages-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-icon {
  font-size: 20px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.search-icon:active {
  opacity: 1;
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.conversation-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  background-color: #fff;
  position: relative;
  gap: 12px;
}

.conversation-item:active {
  background-color: #f9f9f9;
}

.conversation-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #007aff 0%, #0051d5 100%);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.conversation-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conversation-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.conversation-username-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.conversation-username {
  font-weight: 500;
  color: #222;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Small pin icon shown on a pinned conversation's row in the Messages list */
.conversation-pin-icon {
  font-size: 10px;
  line-height: 1;
  flex-shrink: 0;
}

/* Small muted-bell icon shown on a muted conversation's row */
.conversation-mute-icon {
  font-size: 11px;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.6;
}

.conversation-timestamp {
  font-size: 13px;
  color: #999;
  white-space: nowrap;
  flex-shrink: 0;
}

.conversation-message {
  font-size: 13px;
  color: #666;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background-color: #ff3b30;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
}

.unread-badge.unread-dot {
  min-width: 0;
  width: 10px;
  height: 10px;
  padding: 0;
  border-radius: 50%;
}

/* Conversation Screen */
.conversation-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: #1a1a1a;
}

.conversation-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
  height: 60px;
  position: relative;
  z-index: 10;
}

.back-button {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  color: #007aff;
  font-weight: bold;
}

.back-button:active {
  opacity: 0.6;
}

.conversation-header-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.conversation-avatar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--avatar-sm);
  height: var(--avatar-sm);
  border-radius: 50%;
  background: var(--avatar-gradient);
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
  overflow: hidden;
}

.conversation-avatar-header img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.header-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.header-username {
  font-weight: 600;
  color: #222;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
  line-height: 1.2;
}


.menu-button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  color: #666;
}

.menu-button:active {
  opacity: 0.6;
}

.info-header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.header-icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background-color: #1c1c1e;
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.header-icon-button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.header-icon-button:active {
  opacity: 0.7;
}

.pending-request-banner {
  flex-shrink: 0;
  padding: 8px 16px;
  background-color: #fff8e1;
  border-bottom: 1px solid #f0e0b0;
  color: #8a6d1e;
  font-size: 12px;
  text-align: center;
}

/* Wraps the scrolling message list so the scroll-to-latest FAB can be
   anchored to the bottom-right of the list area, above the composer. */
.messages-area {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Sits in a fixed spot right above the composer, patched in place by
   renderTypingIndicator rather than re-rendered -- collapses to nothing when
   no one is typing so it never reserves layout space it isn't using. */
.typing-indicator-bar {
  flex-shrink: 0;
  height: 0;
  padding: 0 16px;
  overflow: hidden;
  color: #8a8a8e;
  font-size: 12px;
  font-style: italic;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: height 0.15s ease, padding 0.15s ease;
}

.typing-indicator-bar.is-visible {
  height: 20px;
  padding: 6px 16px;
}

.scroll-to-latest-fab {
  position: absolute;
  right: 16px;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background-color: #2c2c2e;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  z-index: 9;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.9);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}

.scroll-to-latest-fab.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.scroll-to-latest-fab:active {
  transform: translateY(0) scale(0.94);
}

.scroll-to-latest-fab svg {
  display: block;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .scroll-to-latest-fab {
    transition: opacity 0.01s linear;
    transform: none;
  }

  .scroll-to-latest-fab.is-visible {
    transform: none;
  }
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: #1a1a1a;
  padding: 12px 16px;
  padding-bottom: 80px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  min-width: 0;
  overflow-wrap: anywhere;
  word-wrap: break-word;
  transition: transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.message.swiping {
  transition: none;
}

.message.has-avatar {
  flex-direction: row;
  align-items: flex-start;
}

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

.message.incoming .message-bubble {
  background-color: #e8e8e8;
  color: #222;
  border-radius: 18px 18px 18px 4px;
}

.message.outgoing {
  align-self: flex-end;
}

.message.outgoing .message-bubble {
  background-color: #007aff;
  color: #fff;
  border-radius: 18px 18px 4px 18px;
}

.message-bubble {
  padding: 8px 12px;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  word-wrap: break-word;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.4;
}

.message-timestamp {
  font-size: 12px;
  color: #999;
  padding: 4px 12px 0 12px;
}

.message.outgoing .message-timestamp {
  text-align: right;
}

.message-timestamp.message-failed {
  color: #ff3b30;
  cursor: pointer;
}

.post-card-time.post-failed {
  color: #ff3b30;
  cursor: pointer;
}

.session-expired-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background-color: #ff3b30;
  color: #fff;
  text-align: center;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.update-available-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background-color: #007aff;
  color: #fff;
  text-align: center;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.message-swipe-wrapper {
  position: relative;
  display: flex;
  width: 100%;
  touch-action: pan-y;
}

.message-swipe-wrapper.wrapper-incoming {
  justify-content: flex-start;
}

.message-swipe-wrapper.wrapper-outgoing {
  justify-content: flex-end;
}

.message-reply-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%) scale(0.6);
  opacity: 0;
  font-size: 18px;
  pointer-events: none;
  z-index: 0;
}

.message-swipe-wrapper.wrapper-incoming .message-reply-icon {
  left: 10px;
}

.message-swipe-wrapper.wrapper-outgoing .message-reply-icon {
  right: 10px;
}

.message-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--avatar-sm);
  height: var(--avatar-sm);
  border-radius: 50%;
  background: var(--avatar-gradient);
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
  margin-right: 8px;
  overflow: hidden;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  min-width: 0;
}

.message-system {
  text-align: center;
  color: #8a8a8e;
  font-size: 12px;
  padding: 4px 16px;
  margin: 8px auto;
  max-width: 80%;
}

.message-sender-name {
  font-size: 12px;
  color: #007aff;
  padding: 4px 0 2px 0;
  font-weight: 500;
}

/* Small pin badge shown above a pinned message's bubble */
.message-pin-badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 3px;
  margin-bottom: 3px;
  padding: 2px 7px;
  border-radius: 8px;
  background-color: rgba(0, 122, 255, 0.1);
  color: #007aff;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.2px;
}

.message.outgoing .message-pin-badge {
  align-self: flex-end;
}

.message-pin-icon {
  font-size: 9px;
  line-height: 1;
}

.header-member-count {
  font-size: 11px;
  color: #999;
  line-height: 1.2;
}

.composer-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background-color: #fff;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
  position: relative;
  z-index: 11;
}

.emoji-button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
}

.emoji-button:active {
  opacity: 0.6;
}

.composer-input {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 22px;
  padding: 12px 18px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  min-height: 48px;
  max-height: 120px;
  resize: none;
  overflow-y: auto;
  transition: height 0.2s ease, min-height 0.2s ease;
  line-height: 1.4;
}

.composer-input:focus {
  border-color: #007aff;
}

.composer-input::placeholder {
  color: #999;
}

.send-button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  color: #007aff;
  font-weight: bold;
  flex-shrink: 0;
}

.send-button:active {
  opacity: 0.6;
}

/* Message Context Menu */
.message-menu-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 100;
  animation: fadeIn 250ms ease-out;
}

.message-menu-overlay.closing {
  animation: fadeOut 150ms ease-in forwards;
}

.context-menu {
  position: fixed;
  display: flex;
  flex-direction: column;
  background-color: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  z-index: 101;
  animation: menuScaleIn 250ms ease-out;
  backdrop-filter: blur(4px);
  min-width: 160px;
  overflow: hidden;
}

.context-menu.closing {
  animation: menuScaleOut 150ms ease-in forwards;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: #222;
  font-family: inherit;
  transition: background-color 100ms ease;
  text-align: left;
  min-height: 44px;
}

.menu-item:not(:last-child) {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.menu-item:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.menu-item:active {
  background-color: rgba(0, 0, 0, 0.1);
}

.menu-item.tapped {
  animation: menuItemTap 150ms ease-out;
}

.menu-item.destructive {
  color: #ff3b30;
}

.menu-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.menu-label {
  flex: 1;
}

@keyframes menuItemTap {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
  100% {
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes menuScaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes menuScaleOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

.message-bubble.selected {
  box-shadow: 0 0 0 3px #007aff, 0 0 8px rgba(0, 122, 255, 0.3);
  border-radius: inherit;
}

/* Messages list multi-select mode (WhatsApp/Telegram-style): a long-press on
   a conversation row enters selection mode, replacing the normal header with
   a toolbar (cancel / count / bulk delete). */
.messages-selection-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.selection-cancel-btn,
.selection-delete-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.selection-count {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 600;
  color: #222;
}

.selection-delete-btn {
  color: #ff3b30;
}

.conversation-item.selection-mode {
  padding-left: 12px;
}

.conversation-select-indicator {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #c7c7cc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #fff;
}

.conversation-select-indicator.checked {
  background-color: #007aff;
  border-color: #007aff;
}

.conversation-item.selected {
  background-color: #eaf3ff;
}

/* Reply Preview Bar */
.reply-preview-bar {
  flex: 0 0 100%;
  order: -1;
  width: 100%;
  box-sizing: border-box;
  margin: -12px -16px 0;
  border-top: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
  background-color: #f9f9f9;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  animation: slideDown 200ms ease-out;
}

.reply-preview-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  gap: 8px;
}

.reply-quote {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.reply-sender {
  font-size: 12px;
  font-weight: 500;
  color: #666;
}

.reply-text {
  font-size: 13px;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-close-button {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  color: #999;
  flex-shrink: 0;
  transition: color 200ms ease;
}

.reply-close-button:active {
  color: #666;
  opacity: 0.7;
}

/* Quoted Message Section in Bubbles */
.message-quote {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px 0 8px 8px;
  cursor: pointer;
  transition: opacity 200ms ease;
}

.message-quote:active {
  opacity: 0.7;
}

.quote-border {
  width: 2px;
  background-color: #ddd;
  min-height: 32px;
  flex-shrink: 0;
}

.message.outgoing .quote-border {
  background-color: rgba(255, 255, 255, 0.3);
}

.quote-content {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.quote-sender {
  font-size: 11px;
  font-weight: 500;
  color: #999;
  opacity: 0.8;
}

.quote-text {
  font-size: 12px;
  color: #aaa;
  line-height: 1.3;
  word-wrap: break-word;
  white-space: normal;
}

.message.outgoing .quote-text {
  color: rgba(255, 255, 255, 0.7);
}

/* Highlight Pulse Animation */
@keyframes highlightPulse {
  0% {
    box-shadow: 0 0 0 0 #007aff;
  }
  50% {
    box-shadow: 0 0 12px 4px rgba(0, 122, 255, 0.4);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 122, 255, 0);
  }
}

.message-bubble.highlight-pulse {
  animation: highlightPulse 1.5s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* New Message Page */
.new-message-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: #f5f5f5;
}

.search-container {
  padding: 12px 16px;
  background-color: #fff;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}

.search-field {
  width: 100%;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  height: 40px;
  transition: border-color 0.2s ease;
}

.search-field:focus {
  border-color: #007aff;
}

.search-field::placeholder {
  color: #999;
}

.search-field[readonly] {
  cursor: pointer;
  background-color: #fff;
  caret-color: transparent;
}

.create-group-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background-color: #fff;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  flex-shrink: 0;
}

.create-group-card:active {
  background-color: #f9f9f9;
}

.group-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.group-label {
  font-size: 15px;
  font-weight: 500;
  color: #222;
  flex: 1;
}

.group-chevron {
  font-size: 18px;
  color: #999;
  flex-shrink: 0;
}

/* Single scroll container for everything below the search field: the create
   cards + their managed lists + suggested users. Without this the create
   options get squashed on a phone-sized viewport once the lists render. */
.create-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.suggested-users-section {
  flex: 1 0 auto;
  overflow-x: hidden;
  background-color: #f5f5f5;
}

.section-header {
  font-size: 12px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 16px 16px 8px 16px;
  background-color: #f5f5f5;
  flex-shrink: 0;
}

.users-list {
  background-color: #fff;
}

.suggested-user-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  background-color: #fff;
  position: relative;
  gap: 12px;
  cursor: pointer;
}

.suggested-user-item:active {
  background-color: #f9f9f9;
}

.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--avatar-gradient);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.user-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-username {
  font-weight: 500;
  color: #222;
  font-size: 14px;
}

.user-domain {
  font-size: 13px;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  padding: 40px 16px;
  text-align: center;
  color: #999;
  font-size: 15px;
  background-color: #fff;
}

/* Create Group Page */
.create-group-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: #f5f5f5;
}

.create-group-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
  height: 60px;
  position: relative;
  z-index: 10;
}

.create-group-header h1 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #222;
  margin: 0;
}

.group-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  flex-shrink: 0;
}

.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--avatar-lg);
  height: var(--avatar-lg);
  border-radius: 50%;
  background-color: #e8e8e8;
  cursor: pointer;
  transition: background-color 0.2s ease;
  overflow: hidden;
}

.avatar-placeholder:active {
  background-color: #ddd;
}

.avatar-placeholder img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-placeholder-text {
  font-size: 14px;
  color: #999;
  text-align: center;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 16px;
  background-color: #fff;
  flex-shrink: 0;
}

.form-section:not(:last-child) {
  border-bottom: 1px solid #f0f0f0;
}

.form-input {
  width: 100%;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-input:focus {
  border-color: #007aff;
}

.form-input::placeholder {
  color: #999;
}

.members-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  background-color: #fff;
  flex-shrink: 0;
  min-height: 50px;
  align-content: flex-start;
}

.member-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background-color: #e8f4ff;
  border-radius: 20px;
  font-size: 13px;
}

.chip-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--avatar-xs);
  height: var(--avatar-xs);
  border-radius: 50%;
  background: var(--avatar-gradient);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}

.chip-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.chip-remove {
  background: none;
  border: none;
  color: #007aff;
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
  flex-shrink: 0;
  transition: opacity 0.2s ease;
}

.chip-remove:active {
  opacity: 0.6;
}

.suggested-users-section-create {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: #f5f5f5;
}

.privacy-toggle {
  display: flex;
  gap: 8px;
}

.privacy-option {
  flex: 1;
  padding: 10px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background-color: #fff;
  color: #666;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.privacy-option.active {
  border-color: #007aff;
  background-color: #e8f4ff;
  color: #007aff;
}

.create-group-button {
  width: calc(100% - 32px);
  margin: 12px 16px;
  padding: 14px;
  background-color: #007aff;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.create-group-button:active:not(:disabled) {
  background-color: #0051d5;
}

.create-group-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.validation-error {
  font-size: 13px;
  color: #ff3b30;
  padding: 8px 0;
  min-height: 18px;
}

/* DM Conversation Info Screen */
.dm-info-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: #f5f5f5;
}

.dm-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
  height: 60px;
  z-index: 10;
}

.dm-info-header h1 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #222;
  margin: 0;
  flex: 1;
  text-align: center;
}

.dm-info-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.dm-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  background-color: #fff;
  border-bottom: 1px solid #f0f0f0;
}

.dm-avatar-large {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--avatar-gradient);
  color: #fff;
  font-weight: 600;
  font-size: 48px;
  flex-shrink: 0;
  overflow: hidden;
}

.dm-avatar-large img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.dm-details-section {
  display: flex;
  flex-direction: column;
  background-color: #fff;
  border-bottom: 1px solid #f0f0f0;
}

/* Group Info Screen */
.group-info-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: #f5f5f5;
}

.group-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
  height: 60px;
  z-index: 10;
}

.group-info-header h1 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #222;
  margin: 0;
  flex: 1;
  text-align: center;
}

.group-info-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.group-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  background-color: #fff;
  border-bottom: 1px solid #f0f0f0;
}

.group-avatar-large {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--avatar-gradient);
  color: #fff;
  font-weight: 600;
  font-size: 48px;
  flex-shrink: 0;
}

.group-avatar-large img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.edit-avatar-button {
  background: none;
  border: 1px solid #007aff;
  color: #007aff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.edit-avatar-button:active {
  background-color: #f0f8ff;
}

.group-details-section {
  display: flex;
  flex-direction: column;
  background-color: #fff;
  border-bottom: 1px solid #f0f0f0;
}

.detail-item {
  padding: 16px;
  border-bottom: 1px solid #f0f0f0;
  position: relative;
}

.detail-item:last-child {
  border-bottom: none;
}

.detail-label {
  font-size: 12px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.detail-value {
  font-size: 15px;
  color: #222;
  margin-bottom: 8px;
}

.detail-edit-button {
  background: none;
  border: none;
  color: #007aff;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
}

.detail-edit-button:active {
  opacity: 0.6;
}

.members-section {
  flex: 1;
  background-color: #fff;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: #222;
  padding: 16px;
  border-bottom: 1px solid #f0f0f0;
}

.add-members-button {
  background: none;
  border: none;
  color: #007aff;
  font-size: 14px;
  font-weight: 500;
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

.add-members-button:active {
  background-color: #f9f9f9;
}

.members-list {
  flex: 1;
  overflow-y: auto;
}

.group-member-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  background-color: #fff;
  gap: 12px;
}

.group-member-item:active {
  background-color: #f9f9f9;
}

.member-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--avatar-md);
  height: var(--avatar-md);
  border-radius: 50%;
  background: var(--avatar-gradient);
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
  overflow: hidden;
}

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

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

.member-name {
  font-weight: 500;
  color: #222;
  font-size: 14px;
}

.member-role-badge {
  display: inline-block;
  margin-top: 2px;
  padding: 2px 8px;
  background-color: #e8f4ff;
  color: #007aff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
}

.group-preview-members {
  flex-shrink: 0;
  max-height: 160px;
  overflow-y: auto;
  border-bottom: 1px solid #f0f0f0;
  background-color: #fff;
}

.group-preview-members-title {
  padding: 10px 16px 4px;
  font-size: 12px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
}

.group-preview-members-list .group-member-item {
  padding: 8px 16px;
}

.member-admin-toggle-btn {
  background: none;
  border: 1px solid #007aff;
  color: #007aff;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}

.member-admin-toggle-btn:active {
  background-color: #f0f8ff;
}

.join-requests-button {
  background: none;
  border: none;
  color: #007aff;
  font-size: 14px;
  font-weight: 500;
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

.join-requests-button:active {
  background-color: #f9f9f9;
}

.join-requests-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: #f5f5f5;
}

.join-requests-list {
  flex: 1;
  overflow-y: auto;
}

.join-request-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  background-color: #fff;
  gap: 12px;
}

.join-request-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.join-request-actions .button-primary,
.join-request-actions .button-secondary {
  padding: 8px 14px;
  font-size: 13px;
}

.detail-value-link {
  color: #007aff;
  cursor: pointer;
}

.detail-value-link:active {
  opacity: 0.6;
}

/* Dialog Overlay */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  animation: fadeIn 250ms ease-out;
}

.dialog {
  background-color: #fff;
  width: 100%;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.15);
  z-index: 201;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 250ms ease-out;
}

/* Centered variant — used for alert-style popups (e.g. showAlertDialog) so
   the card appears mid-screen instead of as a bottom sheet. A bottom sheet
   anchored to the viewport edge can end up hidden behind the on-screen
   keyboard on mobile when it opens right after the user was typing, since
   the keyboard covers the bottom of the visual viewport without affecting
   `position: fixed` layout — centering avoids that dead zone entirely. */
.dialog-overlay.dialog-overlay-centered {
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.dialog-overlay-centered .dialog {
  width: 100%;
  max-width: 400px;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  animation: fadeIn 200ms ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.dialog-header {
  padding: 16px;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.dialog-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #222;
  margin: 0;
}

.dialog-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.dialog-footer {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.button-secondary {
  flex: 1;
  padding: 12px;
  background-color: #f0f0f0;
  color: #222;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.button-secondary:active {
  background-color: #e0e0e0;
}

.button-primary {
  flex: 1;
  padding: 12px;
  background-color: #007aff;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.button-primary:active:not(:disabled) {
  background-color: #0051d5;
}

.button-primary:disabled {
  opacity: 0.5;
  cursor: default;
}

.button-danger {
  flex: 1;
  padding: 12px;
  background-color: #ff3b30;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.button-danger:active {
  background-color: #ff2420;
}

.char-count {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
  text-align: right;
}

.avatar-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 200px;
  border-radius: 12px;
  background-color: #f0f0f0;
  margin-bottom: 12px;
  overflow: hidden;
}

.avatar-placeholder-large {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: var(--avatar-gradient);
  color: #fff;
  font-weight: 600;
  font-size: 48px;
  overflow: hidden;
}

.avatar-placeholder-large img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.member-confirm-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background-color: #f9f9f9;
  border-radius: 12px;
}

.member-confirm-info {
  flex: 1;
}

.member-confirm-info .member-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.member-text {
  font-size: 13px;
  color: #666;
}

/* Add Members Page */
.add-members-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: #f5f5f5;
}

.selection-indicator {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #007aff;
  flex-shrink: 0;
}

.suggested-user-item.selected {
  background-color: #f0f8ff;
}

.suggested-user-item.selected .selection-indicator {
  background-color: #007aff;
  border-color: #007aff;
  color: #fff;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: #222;
  color: #fff;
  padding: 12px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 300;
  transition: transform 0.3s ease;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  background-color: #34c759;
}

.toast.error {
  background-color: #ff3b30;
}

.toast.info {
  background-color: #222;
}

/* Group Header Info Clickable */
.group-header-info {
  cursor: pointer;
}

.group-header-info:active {
  opacity: 0.8;
}

/* Group Menu Dialog */
.group-menu-dialog {
  max-height: 70vh;
  width: 100%;
}

.group-menu-content {
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.menu-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: none;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  font-size: 15px;
  text-align: left;
  width: 100%;
  font-family: inherit;
  transition: background-color 100ms ease;
  color: #222;
}

.menu-option:last-child {
  border-bottom: none;
}

.menu-option:active {
  background-color: #f0f0f0;
}

.menu-option.leave-option {
  color: #ff3b30;
  font-weight: 500;
  border-top: 1px solid #f0f0f0;
  margin-top: 8px;
  padding-top: 16px;
}

.option-icon {
  font-size: 18px;
  min-width: 24px;
}

.option-label {
  flex: 1;
  text-align: left;
}

.option-chevron {
  color: #999;
  font-size: 16px;
}

/* Members Sheet Dialog */
.members-sheet-dialog {
  max-height: 70vh;
}

.members-list-container {
  padding: 0 !important;
  max-height: 60vh;
  overflow-y: auto;
}

.members-sheet-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  background-color: #fff;
  gap: 12px;
}

.members-sheet-item:last-child {
  border-bottom: none;
}

.member-remove-btn {
  background: none;
  border: none;
  color: #ff3b30;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.member-remove-btn:active {
  opacity: 0.6;
}

/* Add Members Sheet Dialog */
.add-members-sheet-dialog {
  max-height: 80vh;
}

.add-members-sheet-dialog .dialog-content {
  max-height: 70vh;
  overflow-y: auto;
  padding: 16px !important;
}

.search-members-add-sheet {
  margin-bottom: 12px;
}

.add-members-sheet-list {
  background-color: transparent;
  max-height: none !important;
}

/* User Search Modal (Create screen wallet/username search) */
.user-search-modal-dialog {
  max-height: 80vh;
}

.user-search-modal-dialog .dialog-content {
  max-height: 70vh;
  overflow-y: auto;
  padding: 16px !important;
}

.user-search-modal-dialog .form-input {
  margin-bottom: 12px;
}

.user-search-modal-dialog .users-list {
  background-color: transparent;
  max-height: none !important;
}

/* Messages Tab Bar */
.messages-tabs {
  display: flex;
  gap: 0;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 9;
  -webkit-overflow-scrolling: touch;
}

.messages-tabs::-webkit-scrollbar {
  height: 0;
}

.message-tab {
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: #666;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s ease;
  position: relative;
}

.message-tab:active {
  opacity: 0.7;
}

.message-tab.active {
  color: #007aff;
  border-bottom-color: #007aff;
}

.tab-badge {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  margin-left: 4px;
  border-radius: 9px;
  background-color: #ff3b30;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  vertical-align: middle;
}

/* Messages Search */
.messages-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.search-input:focus {
  border-color: #007aff;
  box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.1);
}

.search-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #999;
  padding: 4px;
}

.search-close:active {
  opacity: 0.6;
}

/* Request Items */
.request-item {
  background-color: #fff;
  border-bottom: 1px solid #f0f0f0;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.request-item:last-child {
  border-bottom: none;
}

.request-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.request-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #007aff 0%, #0051d5 100%);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.request-content {
  flex: 1;
  min-width: 0;
}

.request-name {
  font-weight: 500;
  color: #222;
  font-size: 14px;
  margin-bottom: 4px;
}

.request-message {
  font-size: 13px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.request-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.request-accept,
.request-decline {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.request-accept {
  background-color: #007aff;
  color: #fff;
}

.request-accept:active {
  background-color: #0051d5;
}

.request-decline {
  background-color: #f0f0f0;
  color: #222;
}

.request-decline:active {
  background-color: #e0e0e0;
}

.conversation-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: #fff;
  border-bottom: 1px solid #f0f0f0;
  padding: 12px 16px;
}

.conversation-item:last-child {
  border-bottom: none;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: #999;
  font-size: 14px;
  text-align: center;
  padding: 20px;
  gap: 12px;
}

.empty-icon {
  font-size: 48px;
  opacity: 0.4;
}

.empty-message {
  font-size: 14px;
  color: #999;
}

.dialog-footer {
  position: sticky;
  bottom: 0;
  background-color: #fff;
  border-top: 1px solid #e0e0e0;
}

/* Channel-specific styles */
/* .channel-footer carries no visual styling of its own -- the inner
   .composer-container.chat-composer is the sole source of padding,
   background and the bottom-edge lift, exactly like DM/group where
   .conversation-page itself has no padding. */
.channel-footer {
  padding: 0;
}

.composer-container {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.composer-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  max-height: 120px;
  overflow-y: auto;
  height: 40px;
}

/* Publish button matches .chat-composer .send-button's circular icon
   treatment -- see the .chat-composer block below. */
.publish-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background-color: #007AFF;
  color: #fff;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.2s;
}

.publish-button svg {
  display: block;
}

.publish-button:active {
  background-color: #0056b3;
}

/* Join/Request action bar shown in place of the composer for a group's
   conversation view when the viewer isn't a member yet (reached via Discover
   or an invite link). */
.group-preview-action-button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background-color: #007AFF;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.group-preview-action-button:active {
  background-color: #0056b3;
}

.group-preview-action-button:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

/* ---- Channel feed ------------------------------------------------------- */

/* The follow affordance now lives as a pill in the header, so the feed owns the
   whole scroll area and non-owners get no bottom strip at all. */
.channel-follow-pill {
  flex-shrink: 0;
  padding: 6px 16px;
  margin-right: 4px;
  border: none;
  background-color: #007AFF;
  color: #fff;
  border-radius: 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background-color 0.2s;
}

.channel-follow-pill:active {
  background-color: #0056b3;
}

.channel-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background-color: #f2f2f7;
  padding: 12px;
  padding-bottom: 88px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.post-card {
  position: relative;
  background-color: #fff;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.post-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.post-card-avatar {
  width: var(--avatar-sm);
  height: var(--avatar-sm);
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--avatar-gradient);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.post-card-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.post-card-channel {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: #111;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-card-time {
  flex-shrink: 0;
  font-size: 12px;
  color: #999;
}

.post-content {
  font-size: 15px;
  line-height: 1.45;
  color: #111;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
}

/* ---- Reactions --------------------------------------------------------- */

.post-reaction-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

/* Empty chip strip must not add vertical space above the action row. */
.post-reaction-chips:empty {
  display: none;
}

.post-reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border: 1px solid #e0e0e0;
  border-radius: 14px;
  background-color: #f6f6f8;
  cursor: pointer;
  font-size: 13px;
  color: #444;
  min-height: 28px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s, border-color 0.15s;
}

.post-reaction-chip:active {
  background-color: #ececf0;
}

/* The user's own reactions read as selected at a glance. */
.post-reaction-chip.is-mine {
  background-color: #e5f0ff;
  border-color: #007AFF;
  color: #0056b3;
}

.chip-emoji {
  font-size: 14px;
  line-height: 1;
}

.chip-count {
  font-size: 12px;
  font-weight: 600;
}

/* One control only — ⋯ — so the row is a right-aligned single slot. Forward
   lives inside that menu and reacting is a hold on the card. */
.post-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px solid #f0f0f0;
  font-size: 13px;
  color: #555;
}

.post-menu-button {
  background: none;
  border: none;
  padding: 4px 10px;
  min-height: 32px;
  min-width: 44px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  color: #555;
  transition: color 0.2s, background-color 0.2s;
}

.post-menu-button:active {
  background-color: #f0f0f0;
  color: #007AFF;
}

/* Edit Post — a plain text editor over the standard bottom-sheet dialog shell.
   Same scoped header/close treatment as .forward-sheet-dialog, since
   .dialog-header is shared app-wide and most sheets have no close button. */
.edit-post-dialog .dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.edit-post-dialog .close-dialog-button {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: #888;
}

.edit-post-dialog .close-dialog-button:active {
  background-color: #f0f0f0;
}

.edit-post-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.45;
  color: #222;
  resize: vertical;
  min-height: 120px;
}

.edit-post-input:focus {
  outline: none;
  border-color: #007AFF;
}

/* Anchored to the card (position: relative) so it opens next to the post it
   belongs to rather than floating over the page. Sits at the card's bottom
   edge — over the thin ⋯ action row rather than over the post text, so you can
   still read what you're reacting to while the picker is open. */
.reaction-picker {
  position: absolute;
  right: 8px;
  bottom: 4px;
  z-index: 20;
  display: flex;
  gap: 2px;
  padding: 6px;
  background-color: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  animation: reaction-picker-in 0.14s ease-out;
}

@keyframes reaction-picker-in {
  from { opacity: 0; transform: translateY(4px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* touch-action: manipulation opts these out of the browser's double-tap-zoom
   detection, which is the other place a per-tap delay comes from. The JS
   reacts on touchstart; this keeps the visual feedback just as prompt. */
.reaction-picker-option {
  width: 44px;
  height: 44px;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s, transform 0.15s;
}

.reaction-picker-option:active {
  background-color: #f0f0f0;
  transform: scale(1.15);
}

/* ---- Message reactions (DM/group bubbles) ------------------------------ */
/* Long-pressing a message bubble opens the same picker as a channel post
   (.message-reaction-picker below); chips render the result underneath the
   bubble the same way .post-reaction-chips renders under a post. */

.message-reaction-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 12px 0 12px;
}

.message-reaction-chips:empty {
  display: none;
}

.message.outgoing .message-reaction-chips {
  justify-content: flex-end;
}

.message-reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  background-color: #fff;
  cursor: pointer;
  font-size: 12px;
  color: #444;
  transition: background-color 0.15s, border-color 0.15s;
}

.message-reaction-chip:active {
  background-color: #ececf0;
}

.message-reaction-chip.is-mine {
  background-color: #e5f0ff;
  border-color: #007AFF;
  color: #0056b3;
}

/* Fixed-positioned (top/left set in JS) since a message bubble scrolls out
   from under an absolutely-positioned picker the way a post card can't. */
.message-reaction-picker {
  /* Above .context-menu (101) / .message-menu-overlay (100) — the picker is
     opened from the context menu's "React" item, and the menu/overlay take
     ~300ms to fade out after that tap, so the picker must outrank them or it
     spends that window fully covered and unclickable underneath. */
  z-index: 110;
  display: flex;
  gap: 2px;
  padding: 6px;
  background-color: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  animation: reaction-picker-in 0.14s ease-out;
}

.channel-empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #888;
}

.channel-empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.channel-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}

.channel-empty-hint {
  font-size: 14px;
  color: #999;
}

/* ---- Forward ----------------------------------------------------------- */

.forward-sheet-dialog {
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

/* Scoped rather than global: .dialog-header is shared by every sheet in the app
   and they don't all carry a close button. */
.forward-sheet-dialog .dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.forward-sheet-dialog .close-dialog-button {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: #888;
}

.forward-sheet-dialog .close-dialog-button:active {
  background-color: #f0f0f0;
}

.forward-sheet-dialog .dialog-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.forward-post-preview {
  background-color: #f6f6f8;
  border-left: 3px solid #007AFF;
  border-radius: 6px;
  padding: 8px 10px;
}

.forward-preview-channel {
  font-size: 12px;
  font-weight: 600;
  color: #007AFF;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.forward-preview-channel img {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.forward-preview-text {
  font-size: 13px;
  color: #555;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.forward-targets-list {
  max-height: 34vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.forward-section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #999;
  padding: 10px 2px 6px;
}

.forward-target-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: background-color 0.15s;
}

.forward-target-item:active {
  background-color: #f0f0f0;
}

.forward-target-item .user-content {
  flex: 1;
  min-width: 0;
}

.forward-target-item .user-name {
  font-size: 15px;
  font-weight: 600;
  color: #111;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forward-target-item .user-subtitle {
  font-size: 12px;
  color: #999;
}

.forward-note-input {
  resize: none;
  min-height: 44px;
}

/* Sits above the bubble, outside it, so incoming and outgoing bubbles keep
   their own colours untouched. */
.forward-attribution {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px 2px;
  font-size: 12px;
  font-style: italic;
  color: #8a8a8a;
  cursor: pointer;
}

.message.outgoing .forward-attribution {
  justify-content: flex-end;
  color: #7fa8d8;
}

.message.incoming .forward-attribution {
  color: #8a8a8a;
}

.forward-attribution-icon {
  font-style: normal;
}

@media (prefers-reduced-motion: reduce) {
  .reaction-picker {
    animation: none;
  }

  .reaction-picker-option:active {
    transform: none;
  }
}

.visibility-label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #333;
}

.visibility-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.visibility-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}

.visibility-option input[type="radio"] {
  cursor: pointer;
}

.visibility-option span {
  user-select: none;
}

/* Create options section */
.create-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 16px;
  flex-shrink: 0;
}

.create-section {
  display: flex;
  flex-direction: column;
}

/* Managed group/channel lists shown under each create card. Each list adopts
   its own card's treatment: the group card is a flat bordered row, the channel
   card a rounded card. */
.managed-list {
  display: flex;
  flex-direction: column;
  background-color: #fff;
}

.create-section-group .managed-list {
  border-bottom: 1px solid #f0f0f0;
}

.create-section-channel .managed-list {
  border: 1px solid #e0e0e0;
  border-top: none;
  border-radius: 0 0 8px 8px;
}

/* A managed list always follows the channel card, so the card gives up its
   bottom edge and rounding to read as one continuous card. */
.create-section-channel .create-channel-card {
  border-radius: 8px 8px 0 0;
  border-bottom: none;
}

.managed-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  border-top: 1px solid #f4f4f4;
}

.managed-list-item:active {
  background-color: #f5f5f5;
}

.managed-list-item.is-hidden {
  display: none;
}

.managed-list.is-expanded .managed-list-item.is-hidden {
  display: flex;
}

.managed-list-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #007aff;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.managed-list-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.managed-list-content {
  flex: 1;
  min-width: 0;
}

.managed-list-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.managed-list-name {
  font-size: 15px;
  font-weight: 500;
  color: #222;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.managed-role-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #007aff;
  background-color: #eaf3ff;
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}

.managed-list-meta {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
}

.managed-list-chevron {
  font-size: 16px;
  color: #ccc;
  flex-shrink: 0;
}

.managed-list-empty {
  padding: 12px 16px;
  font-size: 13px;
  color: #999;
  border-top: 1px solid #f4f4f4;
}

.managed-show-all {
  border: none;
  border-top: 1px solid #f4f4f4;
  background: none;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #007aff;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.managed-show-all:active {
  background-color: #f5f5f5;
}

.create-channel-card {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background-color: #fff;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid #e0e0e0;
  transition: background-color 0.2s ease;
  gap: 12px;
}

.create-channel-card:active {
  background-color: #f5f5f5;
}

.channel-icon {
  font-size: 20px;
  color: #007aff;
}

.channel-label {
  flex: 1;
  font-size: 16px;
  color: #333;
  font-weight: 500;
}

.channel-chevron {
  color: #ccc;
  font-size: 18px;
}

/* Channel pages */
.create-channel-page {
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
  min-height: 100vh;
}

.create-channel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.create-channel-header h1 {
  flex: 1;
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}

.create-channel-header .back-button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.channel-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.create-channel-button {
  width: calc(100% - 32px);
  margin: 12px 16px;
  padding: 14px;
  background-color: #007aff;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.create-channel-button:active:not(:disabled) {
  background-color: #0051d5;
}

.create-channel-button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Channel info page */
.channel-info-page {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.channel-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e0e0e0;
  height: 60px;
  flex-shrink: 0;
}

.channel-info-header h1 {
  flex: 1;
  text-align: center;
  font-size: 16px;
  margin: 0;
  font-weight: 600;
}

.channel-info-header .back-button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.channel-info-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.channel-avatar-large {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--avatar-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 48px;
  margin: 0 auto;
  overflow: hidden;
}

.channel-avatar-large img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.channel-details-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.channel-details-section .detail-item {
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}

.channel-details-section .detail-item:last-child {
  border-bottom: none;
}

.channel-details-section .detail-label {
  font-size: 12px;
  color: #999;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.channel-details-section .detail-value {
  font-size: 16px;
  color: #333;
  font-weight: 500;
}

.channel-details-section .detail-value-link {
  color: #007aff;
  cursor: pointer;
}

.view-only-badge {
  background-color: #f5f5f5;
  color: #666;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
}

.channel-member-item {
  display: flex;
  align-items: center;
  padding: 12px;
  gap: 12px;
  background-color: #f9f9f9;
  border-radius: 6px;
  margin-bottom: 8px;
}

.channel-member-item .member-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #007aff;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.channel-member-item .member-info {
  flex: 1;
}

.channel-member-item .member-name {
  font-size: 14px;
  color: #333;
  font-weight: 500;
}

.channel-header-info {
  cursor: pointer;
}

/* Discover Page */
.discover-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: #f5f5f5;
}

.discover-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  overflow-x: auto;
}

.discover-tab {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #666;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.discover-tab.active {
  color: #007aff;
  border-bottom-color: #007aff;
}

.discover-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.featured-carousel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  padding-bottom: 8px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.featured-card {
  flex: 0 0 112px;
  background: #fff;
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.featured-card:active {
  transform: scale(0.98);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.featured-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--avatar-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  overflow: hidden;
}

.featured-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.featured-name {
  font-size: 12px;
  font-weight: 600;
  color: #333;
  margin-bottom: 2px;
}

.featured-type {
  font-size: 10px;
  color: #999;
  margin-bottom: 2px;
}

.featured-count {
  font-size: 10px;
  color: #666;
  margin-bottom: 6px;
}

.featured-button {
  padding: 4px 10px;
  background: #007aff;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.featured-button:active {
  background: #0051d5;
}

.trending-section {
  margin-bottom: 16px;
}

.trending-section h2 {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin: 0 0 8px 0;
  padding: 0 4px;
}

.community-card {
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.community-card:active {
  background: #f5f5f5;
}

.community-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--avatar-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
  overflow: hidden;
}

.community-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.community-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.community-name {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.community-description {
  font-size: 11px;
  color: #666;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.community-count {
  font-size: 11px;
  color: #999;
}

.community-button {
  padding: 6px 12px;
  background: #007aff;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.2s;
}

.community-button:active {
  background: #0051d5;
}

.discover-joined-badge {
  padding: 4px 10px;
  background: #eef6ff;
  color: #007aff;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.featured-card .discover-joined-badge {
  font-size: 10px;
  padding: 3px 8px;
}

.community-preview,
.featured-preview {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.featured-preview {
  justify-content: center;
  margin-top: 0;
  margin-bottom: 4px;
}

.community-preview-avatars {
  display: flex;
}

.community-preview-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--avatar-gradient);
  color: white;
  font-size: 8px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1.5px solid #fff;
  margin-left: -6px;
  flex-shrink: 0;
}

.community-preview-avatar:first-child {
  margin-left: 0;
}

.community-preview-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.featured-preview .community-preview-avatar {
  width: 13px;
  height: 13px;
  font-size: 6px;
}

.community-preview-more {
  font-size: 10px;
  color: #999;
  white-space: nowrap;
}

.featured-preview-more {
  font-size: 8px;
  color: #999;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #999;
  font-size: 16px;
}

/* Profile Page */
.profile-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: #f5f5f5;
}

.profile-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-header-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 0;
  background-color: #fff;
  border-radius: 12px;
  padding: 20px;
}

.profile-avatar-large {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--avatar-lg);
  height: var(--avatar-lg);
  border-radius: 50%;
  background: var(--avatar-gradient);
  color: #fff;
  font-weight: 600;
  font-size: 36px;
  overflow: hidden;
}

.profile-avatar-large img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.profile-username {
  font-size: 18px;
  font-weight: 600;
  color: #222;
  text-align: center;
}

.profile-bio {
  font-size: 14px;
  color: #666;
  text-align: center;
}

.profile-wallet-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #fff;
  border-radius: 12px;
  padding: 16px;
  gap: 12px;
}

.wallet-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wallet-label {
  font-size: 12px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wallet-address {
  font-size: 14px;
  font-weight: 600;
  color: #222;
  font-family: 'Courier New', monospace;
}

.wallet-copy-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
}

.wallet-copy-btn:active {
  opacity: 0.6;
}

.profile-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: #fff;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.profile-menu-item:active {
  background-color: #f5f5f5;
}

.profile-menu-item .menu-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.profile-menu-item .menu-label {
  font-size: 14px;
  font-weight: 600;
  color: #222;
  flex: 1;
}

.profile-menu-item .menu-chevron {
  font-size: 18px;
  color: #999;
  flex-shrink: 0;
}

.profile-edit-bio-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: #f5f5f5;
}

.edit-bio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
  height: 60px;
  z-index: 10;
}

.edit-bio-header h1 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #222;
  margin: 0;
  flex: 1;
  text-align: center;
}

.edit-bio-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bio-textarea {
  flex: 1;
  padding: 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  resize: none;
  box-sizing: border-box;
}

.bio-textarea:focus {
  outline: none;
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.char-count {
  font-size: 12px;
  color: #999;
  text-align: right;
  padding: 0 4px;
}

.edit-bio-footer {
  display: flex;
  gap: 12px;
  padding: 12px 16px 24px 16px;
  background-color: #fff;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.edit-bio-footer .button-secondary,
.edit-bio-footer .button-primary {
  flex: 1;
}

/* ==========================================================================
   Image messages: composer attach button, pending upload strip, image
   bubbles and the full-screen lightbox.
   ========================================================================== */

/* The composer is a flex row; the reply-preview and pending-image strips need
   to break onto their own full-width line above the input. */
.composer-container {
  flex-wrap: wrap;
}

.composer-container > .reply-preview-bar,
.composer-container > .pending-image-bar {
  flex: 0 0 100%;
  width: 100%;
  order: -1;
}

.attach-image-button {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-end;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background-color: #f0f0f0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s;
}

.attach-image-button:active {
  background-color: #e0e0e0;
  opacity: 0.6;
}

.attach-image-button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Pending image strip */
.pending-image-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background-color: #f9f9f9;
  border-top: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
}

.pending-image-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  background-color: #e0e0e0;
  flex-shrink: 0;
}

.pending-image-status {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-image-remove {
  background: none;
  border: none;
  font-size: 18px;
  color: #999;
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
}

.pending-image-remove:active {
  opacity: 0.6;
}

/* Chat composer -- dark pill restyle shared by DM, group, and channel chat
   threads (public/app.js composerMarkup(), used at the three chat-thread
   render sites) and, via the shared .composer-container / .composer-input /
   .attach-image-button base classes, by the channel's own "Publish post"
   composer once it carries this class too. */
.composer-container.chat-composer {
  background-color: #1a1a1a;
  border-top: none;
  padding: 10px 12px max(18px, calc(10px + env(safe-area-inset-bottom, 0px)));
}

/* The pill itself moved from .composer-input onto this wrapper so the
   paperclip can sit inside it, pinned to the bottom-right corner next to
   the send button rather than as a separate icon to the input's left. */
.chat-composer .composer-input-shell {
  flex: 1;
  position: relative;
  display: flex;
  align-items: flex-end;
  background-color: #2c2c2e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
}

.chat-composer .composer-input-shell:focus-within {
  border-color: rgba(255, 255, 255, 0.24);
}

.chat-composer .composer-input {
  flex: 1;
  background-color: transparent;
  border: none;
  border-radius: 0;
  color: #f2f2f2;
  min-height: 44px;
  /* Right padding clears the paperclip so typed text never underlaps it. */
  padding-right: 44px;
}

.chat-composer .composer-input::placeholder {
  color: #8e8e93;
}

.chat-composer .composer-input:focus {
  border-color: transparent;
  outline: none;
}

.chat-composer .attach-image-button {
  position: absolute;
  right: 2px;
  bottom: 2px;
  background-color: transparent;
  color: #8e8e93;
}

.chat-composer .attach-image-button svg {
  display: block;
}

.chat-composer .attach-image-button:active {
  background-color: rgba(255, 255, 255, 0.08);
  opacity: 1;
}

.chat-composer .send-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #007aff;
  color: #fff;
  padding: 0;
}

.chat-composer .send-button svg {
  display: block;
}

.chat-composer .send-button:active {
  background-color: #0051d5;
  opacity: 1;
}

.chat-composer .send-button:disabled {
  opacity: 0.4;
  cursor: default;
}

.chat-composer .reply-preview-bar {
  background-color: #2c2c2e;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-composer .reply-sender {
  color: #d0d0d0;
}

.chat-composer .reply-text {
  color: #8e8e93;
}

.chat-composer .reply-close-button {
  color: #8e8e93;
}

.chat-composer .reply-close-button:active {
  color: #d0d0d0;
}

.chat-composer .pending-image-bar {
  background-color: #2c2c2e;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-composer .pending-image-thumb {
  background-color: #3a3a3c;
}

.chat-composer .pending-image-status {
  color: #8e8e93;
}

.chat-composer .pending-image-remove {
  color: #8e8e93;
}

.chat-composer .pending-image-remove:active {
  color: #d0d0d0;
}

.chat-composer .view-only-badge {
  background-color: #2c2c2e;
  color: #8e8e93;
}

/* Image message bubbles */
.message-bubble.has-image {
  padding: 0;
  overflow: hidden;
}

.message-image {
  display: block;
  width: 100%;
  max-width: 240px;
  max-height: 320px;
  object-fit: cover;
  background-color: #2a2a2a;
  cursor: pointer;
}

/* An <img> with no height attribute is zero pixels tall until it decodes, so a
   thread full of photos grows under the reader and scrolls itself off the end.
   Hold a neutral grey box of roughly the right size open until the bytes land;
   app.js sets data-loaded to release it, so a short wide photo is never
   stretched or cropped to the placeholder's shape. */
.message-image:not([data-loaded='true']) {
  min-height: 180px;
}

/* Shown when the stored file 404s or the URL is unreachable. */
.message-image.message-image-missing {
  width: 240px;
  height: 160px;
  max-height: 160px;
  cursor: default;
  background-color: #e6e6e6;
  position: relative;
}

.message-image.message-image-missing::after {
  content: 'Image unavailable';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #888;
  background-color: #e6e6e6;
}

.message-caption {
  padding: 6px 12px 8px 12px;
}

/* Auto-linkified URLs inside a message bubble or channel post.
   Default color is tuned for the incoming bubble / channel post's light
   backgrounds; the outgoing bubble is #007aff, so a plain #007AFF link
   would be invisible against its own background — override it below. */
.message-link {
  color: #0056b3;
  text-decoration: underline;
  word-break: break-all;
}

.message.outgoing .message-link {
  color: #fff;
  text-decoration-color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
}

/* Full-screen lightbox */
.image-lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.9);
  animation: fadeIn 200ms ease-out;
}

.image-lightbox-image {
  max-width: 92vw;
  max-height: 86vh;
  object-fit: contain;
}

.image-lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.image-lightbox-close:active {
  opacity: 0.6;
}

.nav-icon-wrap {
  position: relative;
  display: inline-flex;
}
