/* Mobile-only WhatsApp-style shell across app pages */
/* Design tokens: 12-16px list padding, 48px touch targets, bubble 16-18px radius, ~78% width, brand green #00a884 */
/*
 * App Shell Layout Contract (all tabs):
 * - One scroll container per screen: .main for app tabs, while chats keeps list/thread internal scroll regions.
 * - Bottom nav is always a sibling of .main, fixed to viewport; never inside the scroll container.
 * - Bottom reserved space = nav height + env(safe-area-inset-bottom), applied only to the scroll container.
 */
@media (max-width: 1024px) {
  html {
    -webkit-tap-highlight-color: transparent;
    height: 100%;
  }

  body {
    overscroll-behavior-y: none;
    overflow: hidden;
    height: var(--app-viewport-height, 100dvh);
    min-height: var(--app-viewport-height, 100dvh);
    background: #0b141a;
    color: #e9edef;
  }

  .btn,
  .chat-item,
  .bottom-nav-link,
  .chat-row,
  .person .btn,
  .group-item .btn {
    min-height: 48px;
    touch-action: manipulation;
  }

  .sidebar {
    display: none;
  }

  /* Reserve space for fixed bottom nav so main content area ends above it (no overlap). */
  .app-shell {
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
    min-height: var(--app-viewport-height, 100dvh);
    height: var(--app-viewport-height, 100dvh);
    padding-bottom: max(
      var(--mobile-bottom-nav-space),
      calc(var(--mobile-bottom-nav-height, 62px) + env(safe-area-inset-bottom, 0px))
    );
    box-sizing: border-box;
  }

  /* Single scrollable area: only .main scrolls; top bar and bottom nav are separate fixed layers. */
  .main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0 0 max(
      var(--mobile-bottom-nav-space),
      calc(var(--mobile-bottom-nav-height, 62px) + env(safe-area-inset-bottom, 0px))
    );
    background: #0b141a;
  }

  .app-native-shell .main,
  .app-native-shell .main.people-main,
  .app-native-shell .chat-list,
  .app-native-shell .messages,
  .app-native-shell .feed-list {
    overscroll-behavior-y: contain;
  }

  /* Keyboard open: Strategy A - nav hidden, main expands; focused input kept visible via JS scrollIntoView. */
  body.keyboard-open .main {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .main:not(.feed-page):not(.chats-main) {
    padding-top: 0;
  }

  /* Feed: override feed.css fixed 72px so list clears the bottom nav (nav + safe-area). */
  .main.feed-page {
    padding-bottom: max(
      var(--mobile-bottom-nav-space),
      calc(var(--mobile-bottom-nav-height, 62px) + env(safe-area-inset-bottom, 0px))
    );
  }

  .topbar {
    position: static;
    z-index: 30;
    margin: 0;
    padding: calc(10px + env(safe-area-inset-top, 0)) 14px 10px;
    min-height: 58px;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0;
    box-shadow: none;
    background: #202c33;
    color: #e9edef;
  }

  .topbar .page-title,
  .topbar h1 {
    font-family: "Manrope", "Trebuchet MS", sans-serif;
    font-size: 1.08rem;
    font-weight: 700;
    color: #e9edef;
    letter-spacing: 0;
  }

  .topbar .btn-primary {
    padding: 8px 11px;
    font-size: 0.87rem;
  }

  .topbar-actions {
    gap: 8px;
  }

  .notification-bell-mobile {
    display: block;
  }

  .notification-bell-mobile .notification-bell-btn {
    width: 36px;
    height: 36px;
    background: #2a3942;
    border-color: rgba(255, 255, 255, 0.1);
  }

  .notification-bell-mobile .notification-dropdown {
    position: fixed;
    top: calc(64px + env(safe-area-inset-top, 0px));
    left: 8px;
    right: 8px;
    bottom: calc(var(--mobile-bottom-nav-space, 72px) + 10px);
    margin-top: 0;
    min-width: 0;
    max-width: none;
    max-height: none;
    border-radius: 14px;
    z-index: 220;
  }

  .notification-bell-mobile .notification-dropdown .notification-dropdown-list {
    max-height: none;
    flex: 1;
  }

  body.notification-dropdown-open .main {
    pointer-events: none;
  }

  .input,
  textarea,
  select {
    font-size: 16px;
    color: #e9edef;
    background: #2a3942;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
  }

  .input::placeholder,
  textarea::placeholder {
    color: #8696a0;
  }

  .btn-primary {
    background: #00a884;
    border-color: #00a884;
  }

  .btn-primary:hover,
  .btn-primary:focus-visible {
    background: #06cf9c;
    border-color: #06cf9c;
  }

  .btn-secondary,
  .btn-ghost {
    background: #2a3942;
    border-color: rgba(255, 255, 255, 0.08);
    color: #e9edef;
  }

  .card,
  .form-card,
  .profile-account,
  .group-modal,
  .modal-content {
    border-radius: 10px;
    box-shadow: none;
    border-color: rgba(255, 255, 255, 0.08);
    background: #111b21;
  }

  .card,
  .form-card {
    margin-left: 10px;
    margin-right: 10px;
  }

  .feed-header {
    position: static;
    top: auto;
    z-index: 40;
    min-height: 58px;
    padding: calc(10px + env(safe-area-inset-top, 0)) 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: #202c33;
    backdrop-filter: none;
  }

  .feed-brand {
    font-family: "Manrope", "Trebuchet MS", sans-serif;
    font-size: 1rem;
    font-weight: 700;
  }

  .feed-header .feed-tabs,
  .feed-header .feed-tabs-single {
    gap: 12px;
    justify-content: flex-end;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .feed-tab {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.04);
    color: #8696a0;
    font-size: 0.85rem;
    font-weight: 700;
  }

  .feed-tab.active {
    background: rgba(0, 168, 132, 0.25);
    color: #e9edef;
    border-color: #00a884;
  }

  .feed-sort-wrap,
  .pro-feed-filter-wrap,
  .local-pulse-section {
    padding-left: 10px;
    padding-right: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: #0b141a;
  }

  .feed-sort-btn,
  .pro-feed-filter-btn,
  .network-tab,
  .jobs-tab,
  .events-tab,
  .chat-filter-btn,
  .inbox-filter-btn {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    background: #2a3942;
    color: #e9edef;
  }

  .feed-sort-btn.active,
  .pro-feed-filter-btn.active,
  .network-tab.active,
  .jobs-tab.active,
  .events-tab.active,
  .chat-filter-btn.active,
  .inbox-filter-btn.active {
    background: rgba(0, 168, 132, 0.22);
    border-color: #00a884;
    color: #e9edef;
  }

  .post,
  .local-pulse-card,
  .jobs-list .card,
  .network-panel > .card,
  .teams-landing-card,
  .profile-view-card,
  .profile-music-section,
  .professional-section,
  .professional-panel {
    max-width: none;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: none;
    background: #111b21;
  }

  .feed-page .post {
    padding: 14px 16px;
    margin: 0;
  }

  .feed-page .feed-fab {
    bottom: calc(72px + env(safe-area-inset-bottom, 0) + 8px);
    right: 20px;
  }

  .people-toolbar,
  .network-toolbar,
  .jobs-toolbar {
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    box-shadow: none;
    background: #111b21;
  }

  .people-toolbar,
  .jobs-toolbar,
  .network-toolbar,
  .group-form,
  .compose,
  .profile-card,
  .profile-preview-card {
    margin-left: 0;
    margin-right: 0;
  }

  .people-list,
  .group-list,
  .network-list,
  .jobs-list,
  #peopleList,
  #networkList,
  #discoverList,
  #followingList,
  #eventsList,
  #jobsList {
    padding: 0;
    margin: 0;
    gap: 0;
  }

  .person,
  .group-item,
  .network-card,
  .job-card,
  .event-card {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: none;
    margin: 0;
    padding: 12px 12px;
    background: #111b21;
  }

  .person:hover,
  .group-item:hover {
    transform: none;
    box-shadow: none;
  }

  .mobile-logout-wrap {
    display: block;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .mobile-logout-wrap .btn {
    width: 100%;
  }

  .main.chats-main {
    padding: 0;
  }

  /* People page: use the same single-scroll-container pattern as other tabs. */
  .main.people-main {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: max(
      var(--mobile-bottom-nav-space),
      calc(var(--mobile-bottom-nav-height, 62px) + env(safe-area-inset-bottom, 0px))
    );
  }

  .main.people-main .topbar,
  .main.people-main .people-toolbar {
    flex-shrink: 0;
  }

  /* Inner list follows normal document flow so header scrolls with page content. */
  .main.people-main .people-list-container {
    flex: none;
    min-height: auto;
    overflow: visible;
    padding-bottom: 0;
  }

  body.keyboard-open .main.people-main {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .dm-shell {
    border-radius: 0;
    min-height: calc(var(--app-viewport-height) - var(--mobile-bottom-nav-space));
    background: #0b141a;
  }

  .dm-list,
  .list-header,
  .thread-header,
  .composer {
    border-radius: 0;
  }

  .list-header,
  .thread-header {
    min-height: 58px;
    padding: calc(10px + env(safe-area-inset-top, 0)) 14px 10px;
    padding-left: 12px;
    padding-right: 14px;
    background: transparent;
    border-bottom: 1px solid transparent;
    flex-shrink: 0;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    transition: none;
  }

  .list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .list-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .list-header span {
    font-size: 1.2rem;
    font-weight: 700;
    color: #e9edef;
  }

  .chats-search-toggle {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #e9edef;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background 0.15s;
  }

  .chats-search-toggle:hover,
  .chats-search-toggle:active {
    background: rgba(255, 255, 255, 0.08);
  }

  .chat-list-toolbar {
    padding: 12px 14px;
    background: #111b21;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    max-height: 120px;
    overflow: hidden;
    transition: max-height 0.2s ease, padding 0.2s ease, opacity 0.2s ease;
  }

  .chat-list-toolbar.mobile-search-hidden {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    border-bottom-width: 0;
  }

  .chats-fab {
    position: fixed;
    bottom: calc(72px + env(safe-area-inset-bottom, 0));
    right: 20px;
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    border-radius: 50%;
    background: #00a884;
    color: #111b21;
    border: none;
    box-shadow: 0 4px 14px rgba(0, 168, 132, 0.4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    line-height: 1;
    cursor: pointer;
    z-index: 50;
    text-decoration: none;
    transition: background 0.15s, transform 0.15s;
  }

  .chats-fab .ui-icon,
  .groups-create-btn .ui-icon {
    width: 1.2rem;
    height: 1.2rem;
  }

  .chats-fab:hover,
  .chats-fab:active {
    background: #06cf9c;
    transform: scale(1.05);
  }

  body.conversation-view .chats-fab {
    display: none;
  }

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

  .thread-header-avatar {
    display: inline-flex;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 600;
    background: var(--wa-surface);
    color: var(--wa-text);
    flex-shrink: 0;
  }

  .thread-header-actions {
    display: inline-flex;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
  }

  .thread-header-actions .thread-action-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #e9edef;
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.15s;
  }

  .thread-header-actions .thread-action-btn:hover,
  .thread-header-actions .thread-action-btn:active {
    background: rgba(255, 255, 255, 0.08);
  }

  .chat-row .avatar-wrap {
    position: relative;
  }

  .chat-row .presence-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #00a884;
    border: 2px solid #111b21;
  }

  .chat-context-menu {
    position: fixed;
    left: 50%;
    bottom: calc(80px + env(safe-area-inset-bottom, 0));
    transform: translateX(-50%);
    min-width: 200px;
    padding: 8px 0;
    background: #202c33;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 200;
    list-style: none;
    margin: 0;
  }

  .chat-context-menu button,
  .chat-context-menu a {
    display: block;
    width: 100%;
    padding: 14px 18px;
    text-align: left;
    background: none;
    border: none;
    color: #e9edef;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
  }

  .chat-context-menu button:hover,
  .chat-context-menu button:active,
  .chat-context-menu a:hover,
  .chat-context-menu a:active {
    background: rgba(255, 255, 255, 0.08);
  }

  .new-messages-pill {
    padding: 10px 18px;
    background: #00a884;
    color: #111b21;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0, 168, 132, 0.35);
    z-index: 15;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
  }

  .new-messages-pill:hover,
  .new-messages-pill:active {
    background: #06cf9c;
  }

  .new-messages-pill.hidden {
    display: none !important;
  }

  .groups-create-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #e9edef;
    font-size: 0;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s;
  }

  .groups-create-btn:hover,
  .groups-create-btn:active {
    background: rgba(255, 255, 255, 0.08);
  }

  .groups-main .group-form.form-card.channel-create-card {
    display: none;
  }

  .groups-main .group-status {
    display: none;
  }

  .groups-create-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    pointer-events: none;
  }

  .groups-create-modal:not(.hidden) {
    pointer-events: auto;
  }

  .groups-create-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
  }

  .groups-create-panel {
    position: relative;
    width: 100%;
    max-width: 360px;
    padding: 20px;
  }

  .groups-create-title {
    font-size: 1.15rem;
    margin: 0 0 16px;
    color: #e9edef;
  }

  .group-form-modal .input {
    margin-bottom: 12px;
  }

  .groups-create-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
  }

  .groups-create-actions .btn {
    flex: 1;
  }

  .profile-view-actions {
    display: none;
  }

  .profile-top-edit-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #e9edef;
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.15s;
  }

  .profile-top-edit-btn:hover,
  .profile-top-edit-btn:active {
    background: rgba(255, 255, 255, 0.08);
  }

  .profile-collapsible {
    margin-bottom: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .profile-collapsible summary.profile-collapsible-title {
    list-style: none;
    padding: 14px 16px;
    min-height: 48px;
    display: flex;
    align-items: center;
    cursor: pointer;
  }

  .profile-collapsible summary.profile-collapsible-title::-webkit-details-marker {
    display: none;
  }

  .profile-collapsible summary.profile-collapsible-title::after {
    content: ">";
    margin-left: auto;
    font-size: 1.2rem;
    color: #8696a0;
    transform: rotate(90deg);
    transition: transform 0.2s ease;
  }

  .profile-collapsible[open] summary.profile-collapsible-title::after {
    transform: rotate(-90deg);
  }

  .profile-collapsible .profile-music-title,
  .profile-collapsible .profile-account-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #e9edef;
  }

  .profile-music-section .profile-music-slots,
  .profile-account .profile-account-items,
  .profile-account .profile-danger-zone {
    padding: 12px 16px;
  }

  .chat-search-input {
    background: #2a3942;
  }

  .chat-row {
    padding: 14px 16px;
    min-height: 72px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: #111b21;
  }

  .chat-row.active,
  .chat-row:hover,
  .chat-row:active {
    background: #202c33;
  }

  .dm-thread .messages {
    padding: 12px 10px;
    gap: 6px;
    background: #0b141a;
    scroll-padding-bottom: 132px;
  }

  .message {
    max-width: 78%;
    border-radius: 18px;
  }

  .message.outgoing {
    border-top-right-radius: 4px;
  }

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

  .msg-media-img,
  .msg-media-video {
    max-width: 100%;
  }

  .composer {
    padding: 8px 10px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    background: #202c33;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .composer .attach,
  .composer .send {
    background: #2a3942;
  }

  .composer .send {
    background: #00a884;
  }

  /* Legacy mobile chat selector support */
  .chat-messages,
  .dm-thread .messages {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-message-group {
    display: flex;
    color: #fff;
    align-items: flex-start;
    column-gap: 8px;
    margin-bottom: 10px;
  }

  .chat-message-group .chat-message,
  .chat-message {
    padding: 10px;
    margin-bottom: 2px;
    background-color: var(--primary, #202c33);
    border-radius: var(--border-radius, 12px);
  }

  .chat-message-time,
  .message .msg-time {
    font-size: 11px;
    color: #ffffff99;
    position: relative;
    bottom: -2px;
    right: -2px;
  }

  .chat-message-avatar {
    height: 30px;
    border-radius: 50%;
  }

  .emoji-toolbar {
    position: relative;
  }

  .reaction-emoji-selector {
    position: absolute;
    top: -40px;
    height: 60px;
    display: none;
    justify-content: space-between;
    align-items: center;
    font-size: 24px;
    z-index: 10;
    border-radius: 50px;
    background-color: var(--primary, #202c33);
  }

  .chat-tile,
  .chat-row {
    display: flex;
    color: var(--text-secondary, #8696a0);
    height: 72px;
    position: relative;
    margin-bottom: 0;
    column-gap: 10px;
    align-items: center;
  }

  .chat-tile:hover,
  .chat-row:hover {
    background-color: var(--primary, #202c33);
    cursor: pointer;
  }

  .chat-tile::after,
  .chat-row::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 0.1px;
    background-color: var(--border-color, rgba(255, 255, 255, 0.1));
  }

  .connectivity-notification {
    padding: 12px 15px;
    background-color: var(--bg-color-secondary, #182229);
    display: flex;
    align-items: center;
    column-gap: 15px;
    color: var(--text-secondary, #8696a0);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .connectivity-notification-title {
    color: var(--text-primary-strong, #e9edef);
    font-size: 16px;
  }

  .connectivity-notification > img {
    filter: invert(82%) sepia(49%) saturate(1077%) hue-rotate(328deg)
      brightness(103%) contrast(103%);
  }

  body {
    background-color: var(--bg-color, #0b141a);
  }

  .main.chats-main {
    display: flex;
    align-items: stretch;
    height: 100%;
  }

  #sidebar {
    flex-grow: 1;
    max-width: 40%;
    display: flex;
    flex-direction: column;
    border-right: solid 1px var(--border-color, rgba(255, 255, 255, 0.1));
  }

  .new-messages-pill.shrink {
    transform: scale(0.92);
    opacity: 0.6;
  }

  .compose-actions,
  .group-form-row,
  .form-actions,
  .profile-save-row,
  .modal-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .compose-actions .input,
  .compose-actions .btn,
  .group-form-row .input,
  .group-form-row .btn,
  .form-actions .btn,
  .profile-save-row .btn,
  .profile-save-row .form-status,
  .modal-actions .btn {
    width: 100%;
    max-width: none;
  }

  .people-section,
  .section-title {
    margin: 14px 10px 8px;
  }

  .people-toolbar {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .people-search-toggle {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
  }

  .people-search-toggle .ui-icon,
  .profile-top-edit-btn .ui-icon {
    width: 1.1rem;
    height: 1.1rem;
  }

  .people-search-input {
    min-height: 48px;
    padding: 12px 16px;
  }

  .people-accordion-section {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .people-accordion-section summary.people-accordion-title {
    list-style: none;
    padding: 14px 16px;
    min-height: 48px;
    font-size: 1rem;
    font-weight: 700;
    color: #e9edef;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .people-accordion-section summary.people-accordion-title::-webkit-details-marker {
    display: none;
  }

  .people-accordion-section summary.people-accordion-title::after {
    content: ">";
    font-size: 1.2rem;
    color: #8696a0;
    transform: rotate(90deg);
    transition: transform 0.2s ease;
  }

  .people-accordion-section[open] summary.people-accordion-title::after {
    transform: rotate(-90deg);
  }

  .people-accordion-section .people-list {
    padding: 0;
    margin: 0;
    list-style: none;
  }

  .people-accordion-section .person {
    padding: 14px 16px;
    min-height: 72px;
  }

  .people-accordion-section .person .person-actions .btn {
    min-height: 44px;
  }

  /* Bottom nav: separate layer, fixed; never inside the scroll container. Safe-area for iPhone home indicator. */
  .bottom-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-bottom-nav-height);
    min-height: var(--mobile-bottom-nav-space);
    padding-left: calc(10px + env(safe-area-inset-left, 0px));
    padding-right: calc(10px + env(safe-area-inset-right, 0px));
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 6px);
    box-sizing: border-box;
    background: rgba(17, 27, 33, 0.94);
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.42), 0 -1px 0 rgba(255, 255, 255, 0.06);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    z-index: 100;
    flex-shrink: 0;
    transform: translateY(0);
    opacity: 1;
    transition: transform 180ms ease, opacity 160ms ease;
  }

  .bottom-nav::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 1px;
    background: linear-gradient(90deg, rgba(0, 168, 132, 0.08), rgba(255, 255, 255, 0.22), rgba(0, 168, 132, 0.08));
    pointer-events: none;
  }

  body.keyboard-open .bottom-nav {
    transform: translateY(calc(100% + env(safe-area-inset-bottom, 0px)));
    opacity: 0;
    pointer-events: none;
  }

  .bottom-nav-link {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 56px;
    padding: 8px 4px 7px;
    color: #d3dde2;
    font-size: 0.68rem;
    font-weight: 800;
    text-decoration: none;
    gap: 4px;
    transition: color var(--motion-fast) ease, transform 140ms ease, opacity var(--motion-fast) ease;
  }

  .bottom-nav-link:hover,
  .bottom-nav-link.active,
  .bottom-nav-link[aria-current="page"] {
    color: #f1f7fa;
  }

  .bottom-nav-link:focus-visible {
    outline: 2px solid rgba(0, 168, 132, 0.7);
    outline-offset: -2px;
    border-radius: 10px;
  }

  .bottom-nav-unread {
    position: absolute;
    top: 2px;
    left: 50%;
    margin-left: 10px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    color: #111b21;
    background: #00a884;
    border-radius: 9px;
  }

  .bottom-nav-unread.hidden {
    display: none;
  }

  .bottom-nav-link:active {
    transform: scale(0.95);
  }

  .bottom-nav-link .nav-dot {
    position: absolute;
    top: 2px;
    left: 50%;
    margin-left: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff5252;
  }

  .bottom-nav-link .nav-dot.nav-dot-pulse {
    animation: navDotPulse 1.7s ease-in-out 1;
  }

  .bottom-nav-link .nav-dot.hidden {
    display: none;
  }

  .bottom-nav-link span.icon {
    width: 1.4rem;
    height: 1.4rem;
    padding: 7px;
    border: none;
    border-radius: 999px;
    color: #e7eef1;
    background: rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    line-height: 1;
    transition: transform 140ms ease, background-color 140ms ease, color 140ms ease;
  }

  .bottom-nav-link .icon.ui-icon {
    width: 1.2rem;
    height: 1.2rem;
  }

  .bottom-nav-link.active span.icon,
  .bottom-nav-link[aria-current="page"] span.icon {
    background: #00a884;
    color: #ffffff;
    box-shadow: 0 0 0 1px rgba(0, 168, 132, 0.35), 0 4px 12px rgba(0, 168, 132, 0.28);
  }

  .bottom-nav-link:active span.icon {
    transform: scale(0.95);
  }
}

@keyframes navDotPulse {
  0% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 0.85; }
}

@media (max-width: 480px) {
  .bottom-nav-link {
    font-size: 0.62rem;
    gap: 2px;
  }

  .bottom-nav-link span.icon {
    margin: 0;
  }
}

@media (max-width: 1024px) {
  .chats-container {
    display: flex;
    flex-direction: column;
    height: calc(var(--app-viewport-height) - 132px);
    min-height: 300px;
    overflow: hidden;
    margin: 0;
    position: relative;
  }

  .chats-container.mobile-chat-active {
    height: calc(var(--app-viewport-height) - var(--mobile-bottom-nav-space));
  }

  .chats-container .chat-list-panel {
    flex: 1;
    overflow: auto;
    min-height: 0;
    border-radius: 0;
  }

  .chats-container .chat-window {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    border-radius: 0;
    transform: translateX(108%);
    transition: transform 0.2s ease;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
  }

  .chats-container.mobile-chat-active .chat-list-panel {
    display: none;
  }

  .chats-container.mobile-chat-active .chat-window {
    height: auto;
    bottom: calc(56px + env(safe-area-inset-bottom, 0) + 8px);
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .chat-back-btn {
    display: inline-block;
  }

  .main.mobile-chat-open > .topbar,
  .main:has(.chats-container.mobile-chat-active) > .topbar {
    display: none;
  }

  .chat-input {
    padding: 10px;
    flex-wrap: nowrap;
    gap: 8px;
    flex-shrink: 0;
  }

  .chat-input .input[type="text"] {
    flex: 1;
    min-width: 0;
  }

  .chat-input .chat-attach-btn {
    min-width: 44px;
    width: 44px;
    padding: 0;
  }

  .chat-input .btn-primary {
    flex-shrink: 0;
    min-width: 68px;
  }

  .local-pulse-panel .local-pulse-cards,
  .local-pulse-card {
    width: 100%;
    max-width: 100%;
  }
}

/* Desktop only: hide bottom nav and mobile-only UI */
@media (min-width: 1025px) {
  .mobile-logout-wrap {
    display: none;
  }

  .notification-bell-mobile {
    display: none;
  }

  .bottom-nav {
    display: none;
  }

  .chats-search-toggle {
    display: none;
  }

  .chats-fab {
    display: none;
  }

  .thread-header-actions {
    display: none;
  }

  .chat-context-menu {
    display: none;
  }

  .groups-create-btn {
    display: none;
  }

  .profile-top-edit-btn {
    display: none;
  }
}

@media (display-mode: standalone) and (max-width: 1024px) {
  .topbar,
  .feed-header,
  .list-header,
  .thread-header {
    top: 0;
  }

  .main {
    padding-top: 0;
  }

  /* Installed app: use same header style as Groups page (topbar) on all pages */
  .feed-header,
  .main .feed-header {
    position: static;
    top: auto;
    z-index: 30;
    margin: 0;
    padding: calc(10px + env(safe-area-inset-top, 0)) 14px 10px;
    min-height: 58px;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0;
    box-shadow: none;
    background: #202c33;
    color: #e9edef;
    backdrop-filter: none;
  }

  .feed-header .feed-brand,
  .main .feed-header .feed-brand {
    font-family: "Manrope", "Trebuchet MS", sans-serif;
    font-size: 1.08rem;
    font-weight: 700;
    color: #e9edef;
    letter-spacing: 0;
  }

  .feed-header .feed-tabs .feed-tab,
  .main .feed-header .feed-tabs .feed-tab {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: #8696a0;
  }

  .feed-header .feed-tabs .feed-tab.active,
  .main .feed-header .feed-tabs .feed-tab.active {
    background: rgba(0, 168, 132, 0.25);
    border-color: #00a884;
    color: #e9edef;
  }
}
