/*
 * Hamrah Phase D — Mobile Shell Polish R1
 * Target: the physically-approved mobile visual direction for Chats / Contacts /
 * Profile / shared Bottom Navigation.
 *
 * Scope is deliberately mobile-only (<= 767px). Desktop Phase D remains frozen.
 */

@media (max-width: 767px) {
  html[data-hamrah-mobile-polish="r2"] {
    --mup-bg: #070b11;
    --mup-surface: #0d131c;
    --mup-surface-2: #111a26;
    --mup-surface-3: #152131;
    --mup-border: rgba(255,255,255,.075);
    --mup-divider: rgba(255,255,255,.060);
    --mup-text: #f4f7fb;
    --mup-muted: #8c98aa;
    --mup-muted-2: #687487;
    --mup-accent: var(--primary, #28a8ff);
    --mup-accent-soft: color-mix(in srgb, var(--mup-accent) 14%, transparent);
    --mup-accent-soft-2: color-mix(in srgb, var(--mup-accent) 8%, transparent);
    --mup-success: #24c98b;
    --mup-radius-control: 18px;
    --mup-radius-card: 24px;
    --mup-nav-height: 70px;
    --mup-ease: cubic-bezier(.2,.72,.24,1);
    --mup-ease-out: cubic-bezier(.16,1,.3,1);
  }

  body.amoled {
    --mup-bg: #000;
    --mup-surface: #080b10;
    --mup-surface-2: #0d1219;
    --mup-surface-3: #111923;
    --mup-border: rgba(255,255,255,.085);
    --mup-divider: rgba(255,255,255,.065);
  }

  body:not(.dark):not(.amoled) {
    --mup-bg: #f4f7fb;
    --mup-surface: #ffffff;
    --mup-surface-2: #f0f4f8;
    --mup-surface-3: #eaf0f6;
    --mup-border: rgba(15,28,45,.09);
    --mup-divider: rgba(15,28,45,.07);
    --mup-text: #132033;
    --mup-muted: #66748a;
    --mup-muted-2: #8793a5;
  }

  html[data-hamrah-mobile-polish="r2"] body {
    background: var(--mup-bg) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app {
    background: var(--mup-bg) !important;
    color: var(--mup-text);
  }

  /* --------------------------------------------------------------------- */
  /* Shared compact mobile header                                          */
  /* --------------------------------------------------------------------- */

  html[data-hamrah-mobile-polish="r2"] #app > .topbar {
    position: relative;
    display: block !important;
    min-height: 64px !important;
    block-size: 64px;
    margin: 0 !important;
    padding: calc(7px + env(safe-area-inset-top)) 18px 7px !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: var(--mup-bg) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    overflow: visible;
    isolation: isolate;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar .topbar-copy {
    display: contents !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar .topbar-copy > div:last-child {
    position: absolute;
    inset-inline-start: 50%;
    inset-block-start: calc(9px + env(safe-area-inset-top));
    transform: translateX(-50%);
    display: grid;
    justify-items: center;
    min-inline-size: 0;
    pointer-events: none;
    z-index: 1;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #viewTitle {
    margin: 0;
    color: var(--mup-text) !important;
    font-size: 1.16rem !important;
    font-weight: 820 !important;
    line-height: 1.25;
    letter-spacing: -.035em !important;
    white-space: nowrap;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionStatus {
    min-block-size: 9px;
    margin-block-start: 1px;
    font-size: 0 !important;
    opacity: 1 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionStatus > span,
  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionStatus > button {
    position: absolute !important;
    inline-size: 1px !important;
    block-size: 1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionStatus > i {
    inline-size: 6px !important;
    block-size: 6px !important;
    margin: 0 !important;
    border-radius: 50%;
    background: var(--mup-success);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mup-success) 12%, transparent);
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar .mini-brand {
    position: absolute !important;
    inset-inline-end: 18px;
    inset-block-start: calc(9px + env(safe-area-inset-top));
    inline-size: 42px !important;
    block-size: 42px !important;
    margin: 0 !important;
    border: 1px solid var(--mup-border);
    border-radius: 50% !important;
    overflow: visible !important;
    opacity: 1 !important;
    box-shadow: 0 5px 18px rgba(0,0,0,.18);
    z-index: 2;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar .mini-brand img {
    inline-size: 100%;
    block-size: 100%;
    border-radius: inherit;
    object-fit: cover;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar .mini-brand::after {
    content: "";
    position: absolute;
    inset-inline-start: -1px;
    inset-block-end: 1px;
    inline-size: 9px;
    block-size: 9px;
    border: 2px solid var(--mup-bg);
    border-radius: 50%;
    background: var(--mup-success);
    transform: scale(.92);
    transition: transform 160ms var(--mup-ease-out), background 160ms ease;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar:has(#connectionStatus[data-state="offline"]) .mini-brand::after,
  html[data-hamrah-mobile-polish="r2"] #app > .topbar:has(#connectionStatus[data-state="error"]) .mini-brand::after {
    background: #7a8797;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #topAction {
    position: absolute !important;
    inset-inline-start: 18px;
    inset-block-start: calc(8px + env(safe-area-inset-top));
    inline-size: 44px !important;
    block-size: 44px !important;
    min-inline-size: 44px;
    min-block-size: 44px;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid color-mix(in srgb, var(--mup-accent) 25%, var(--mup-border)) !important;
    border-radius: 16px !important;
    color: #fff !important;
    background:
      linear-gradient(145deg,
        color-mix(in srgb, var(--mup-accent) 76%, #4568d9),
        color-mix(in srgb, var(--mup-accent) 58%, #12678e)
      ) !important;
    box-shadow: 0 8px 24px color-mix(in srgb, var(--mup-accent) 16%, transparent) !important;
    z-index: 3;
    transition:
      transform 145ms var(--mup-ease),
      box-shadow 170ms ease,
      filter 170ms ease !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #topAction:active {
    transform: scale(.92) !important;
    box-shadow: 0 3px 12px color-mix(in srgb, var(--mup-accent) 10%, transparent) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #topAction svg {
    inline-size: 23px;
    block-size: 23px;
    stroke-width: 1.9;
  }

  /* Tiny Hamrah identity mark beside the Chats title only. */
  html[data-hamrah-mobile-polish="r2"] .mup-brand-mark {
    display: none;
    position: absolute;
    inset-inline-end: -24px;
    inset-block-start: 3px;
    inline-size: 17px;
    block-size: 22px;
    transform: rotate(7deg);
  }

  html[data-hamrah-mobile-polish="r2"] #app[data-mobile-view="chats"] .mup-brand-mark {
    display: block;
  }

  html[data-hamrah-mobile-polish="r2"] .mup-brand-mark::before,
  html[data-hamrah-mobile-polish="r2"] .mup-brand-mark::after {
    content: "";
    position: absolute;
    inset-block-end: 0;
    inline-size: 8px;
    block-size: 22px;
    border-radius: 8px 2px 8px 2px;
    transform-origin: bottom center;
  }

  html[data-hamrah-mobile-polish="r2"] .mup-brand-mark::before {
    inset-inline-end: 1px;
    background: linear-gradient(180deg, #24d2d6, #168ff0);
    transform: skewY(-22deg);
  }

  html[data-hamrah-mobile-polish="r2"] .mup-brand-mark::after {
    inset-inline-start: 1px;
    block-size: 16px;
    background: linear-gradient(180deg, #3a90ff, #4659df);
    transform: skewY(22deg);
  }

  /* --------------------------------------------------------------------- */
  /* Shared view geometry                                                   */
  /* --------------------------------------------------------------------- */

  html[data-hamrah-mobile-polish="r2"] #app > .view {
    color: var(--mup-text);
    background: var(--mup-bg) !important;
    scrollbar-color: color-mix(in srgb, var(--mup-accent) 34%, transparent) transparent;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .view.mup-view-enter {
    animation: mupViewEnter 215ms var(--mup-ease-out) both;
  }

  @keyframes mupViewEnter {
    from { opacity: .55; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
  }

  /* --------------------------------------------------------------------- */
  /* Chats / Home                                                           */
  /* --------------------------------------------------------------------- */

  html[data-hamrah-mobile-polish="r2"] #chatsView {
    padding-inline: 0 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatsView .chat-tools,
  html[data-hamrah-mobile-polish="r2"] #chatsView .home-toolbar {
    position: sticky;
    inset-block-start: 0;
    z-index: 4;
    display: grid;
    gap: 10px !important;
    margin: 0 !important;
    padding: 10px 16px 8px !important;
    border: 0 !important;
    background:
      linear-gradient(180deg,
        var(--mup-bg) 0%,
        color-mix(in srgb, var(--mup-bg) 96%, transparent) 72%,
        color-mix(in srgb, var(--mup-bg) 82%, transparent) 100%
      ) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatsView .search-box,
  html[data-hamrah-mobile-polish="r2"] #contactsView .search-box {
    min-block-size: 50px !important;
    block-size: 50px;
    padding-inline: 15px 12px !important;
    border: 1px solid var(--mup-border) !important;
    border-radius: 19px !important;
    background:
      linear-gradient(145deg,
        color-mix(in srgb, var(--mup-surface-2) 92%, transparent),
        color-mix(in srgb, var(--mup-surface) 96%, transparent)
      ) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.018) !important;
    transition:
      transform 150ms var(--mup-ease),
      border-color 170ms ease,
      background 170ms ease,
      box-shadow 170ms ease !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatsView .search-box:focus-within,
  html[data-hamrah-mobile-polish="r2"] #contactsView .search-box:focus-within {
    transform: translateY(-1px) !important;
    border-color: color-mix(in srgb, var(--mup-accent) 35%, transparent) !important;
    background: var(--mup-surface-2) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mup-accent) 7%, transparent) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatsView .search-box > svg,
  html[data-hamrah-mobile-polish="r2"] #contactsView .search-box > svg {
    inline-size: 21px !important;
    block-size: 21px !important;
    color: var(--mup-muted) !important;
    opacity: .9;
  }

  html[data-hamrah-mobile-polish="r2"] #chatsView .search-box input,
  html[data-hamrah-mobile-polish="r2"] #contactsView .search-box input {
    color: var(--mup-text) !important;
    font-size: .83rem !important;
    font-weight: 540;
  }

  html[data-hamrah-mobile-polish="r2"] #chatsView .search-box input::placeholder,
  html[data-hamrah-mobile-polish="r2"] #contactsView .search-box input::placeholder {
    color: var(--mup-muted) !important;
    opacity: .9;
  }

  html[data-hamrah-mobile-polish="r2"] #chatsView .clear-search {
    inline-size: 30px !important;
    block-size: 30px !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 10px !important;
    color: var(--mup-muted) !important;
    background: var(--mup-accent-soft-2) !important;
    font-size: .95rem !important;
    transition: transform 120ms var(--mup-ease), background 150ms ease !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatsView .clear-search:active {
    transform: scale(.9) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomFilters {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 7px !important;
    inline-size: 100%;
    min-inline-size: 0;
    padding: 0 0 2px !important;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline proximity;
  }

  html[data-hamrah-mobile-polish="r2"] #roomFilters::-webkit-scrollbar {
    display: none;
  }

  html[data-hamrah-mobile-polish="r2"] #roomFilters .filter-pill {
    flex: 0 0 auto;
    min-block-size: 36px !important;
    block-size: 36px;
    padding: 6px 13px !important;
    border: 1px solid var(--mup-border) !important;
    border-radius: 15px !important;
    color: var(--mup-muted) !important;
    background: color-mix(in srgb, var(--mup-surface) 82%, transparent) !important;
    font-size: .70rem !important;
    font-weight: 690 !important;
    white-space: nowrap;
    scroll-snap-align: center;
    transition:
      color 160ms ease,
      border-color 160ms ease,
      background 180ms ease,
      transform 130ms var(--mup-ease),
      box-shadow 180ms ease !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomFilters .filter-pill svg {
    inline-size: 15px;
    block-size: 15px;
    opacity: .78;
  }

  html[data-hamrah-mobile-polish="r2"] #roomFilters .filter-pill.active {
    color: #eaf4ff !important;
    border-color: color-mix(in srgb, var(--mup-accent) 30%, transparent) !important;
    background:
      linear-gradient(145deg,
        color-mix(in srgb, var(--mup-accent) 18%, var(--mup-surface-2)),
        color-mix(in srgb, var(--mup-accent) 10%, var(--mup-surface))
      ) !important;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mup-accent) 5%, transparent) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomFilters .filter-pill:active {
    transform: scale(.95) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList {
    gap: 0 !important;
    padding: 0 16px calc(10px + env(safe-area-inset-bottom)) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .room-shell {
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    transition: background 145ms ease, transform 125ms var(--mup-ease) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .room-shell + .room-shell {
    border-block-start: 1px solid var(--mup-divider) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .room-shell:has(.unread-badge) {
    background: transparent !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .room-shell:active {
    transform: scale(.988) !important;
    background: var(--mup-accent-soft-2) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .list-row {
    min-block-size: 72px !important;
    block-size: auto;
    padding: 9px 2px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .avatar {
    inline-size: 50px !important;
    block-size: 50px !important;
    border-radius: 17px !important;
    border: 1px solid color-mix(in srgb, var(--mup-border) 75%, transparent);
    box-shadow: none !important;
    font-size: 1rem;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .room-channel .avatar,
  html[data-hamrah-mobile-polish="r2"] #roomList .avatar[data-photo] {
    border-radius: 50% !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .row-main {
    gap: 0 !important;
    min-inline-size: 0;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .row-title {
    gap: 6px !important;
    align-items: baseline !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .row-title b {
    color: var(--mup-text) !important;
    font-size: .88rem !important;
    font-weight: 770 !important;
    letter-spacing: -.018em !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .row-title time {
    color: var(--mup-muted-2) !important;
    font-size: .59rem !important;
    font-weight: 560 !important;
    opacity: 1 !important;
    font-variant-numeric: tabular-nums;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .row-sub {
    margin-block-start: 3px !important;
    max-inline-size: 100%;
    color: var(--mup-muted) !important;
    font-size: .70rem !important;
    line-height: 1.48 !important;
    font-weight: 480;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .unread-badge {
    min-inline-size: 21px !important;
    block-size: 21px !important;
    padding-inline: 6px !important;
    border-radius: 11px !important;
    color: #fff !important;
    background: linear-gradient(145deg, #2e85ff, #4565d9) !important;
    box-shadow: none !important;
    font-size: .59rem !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .online-dot {
    inline-size: 9px !important;
    block-size: 9px !important;
    background: var(--mup-success) !important;
    box-shadow: 0 0 0 2.5px var(--mup-bg) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .room-flags {
    color: var(--mup-muted-2);
    opacity: .78 !important;
  }

  /* --------------------------------------------------------------------- */
  /* Contacts                                                               */
  /* --------------------------------------------------------------------- */

  html[data-hamrah-mobile-polish="r2"] #contactsView {
    padding: 8px 16px calc(14px + env(safe-area-inset-bottom)) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #contactsView .sticky-search {
    position: sticky;
    inset-block-start: 0;
    z-index: 3;
    margin: 1px 0 12px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #contactsView .section-heading {
    display: flex !important;
    align-items: end !important;
    justify-content: space-between !important;
    gap: 12px;
    margin: 0 !important;
    padding: 7px 2px 10px !important;
    border: 0 !important;
    background: transparent !important;
  }

  html[data-hamrah-mobile-polish="r2"] #contactsView .section-heading h2 {
    margin: 0;
    color: var(--mup-text) !important;
    font-size: .88rem !important;
    font-weight: 780 !important;
    letter-spacing: -.02em;
  }

  html[data-hamrah-mobile-polish="r2"] #contactsView .section-heading small {
    margin-block-start: 1px;
    color: var(--mup-muted-2) !important;
    font-size: .60rem !important;
  }

  html[data-hamrah-mobile-polish="r2"] #contactsView .online-legend {
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    min-block-size: 28px;
    padding: 4px 9px !important;
    border: 1px solid color-mix(in srgb, var(--mup-success) 16%, transparent);
    border-radius: 11px;
    color: var(--mup-success) !important;
    background: color-mix(in srgb, var(--mup-success) 6%, transparent) !important;
    font-size: .62rem !important;
    font-weight: 650;
  }

  html[data-hamrah-mobile-polish="r2"] #contactsView .online-legend i {
    inline-size: 7px;
    block-size: 7px;
    border-radius: 50%;
    background: var(--mup-success);
  }

  html[data-hamrah-mobile-polish="r2"] #contactList {
    gap: 0 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #contactList .contact-row {
    position: relative;
    min-block-size: 70px !important;
    inline-size: 100%;
    margin: 0 !important;
    padding: 9px 2px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: inherit;
    transition: background 145ms ease, transform 125ms var(--mup-ease) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #contactList .contact-row + .contact-row {
    border-block-start: 1px solid var(--mup-divider) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #contactList .contact-row:active {
    transform: scale(.989);
    background: var(--mup-accent-soft-2) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #contactList .avatar {
    inline-size: 48px !important;
    block-size: 48px !important;
    border-radius: 50% !important;
    border: 1px solid color-mix(in srgb, var(--mup-border) 75%, transparent);
    box-shadow: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #contactList .row-title b {
    color: var(--mup-text) !important;
    font-size: .84rem !important;
    font-weight: 760 !important;
    letter-spacing: -.015em;
  }

  html[data-hamrah-mobile-polish="r2"] #contactList .row-sub {
    margin-block-start: 3px !important;
    color: var(--mup-muted) !important;
    font-size: .68rem !important;
    line-height: 1.4 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #contactList .contact-row:has(.online-dot) .row-sub {
    color: var(--mup-success) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #contactList .online-dot {
    inline-size: 9px !important;
    block-size: 9px !important;
    background: var(--mup-success) !important;
    box-shadow: 0 0 0 2.5px var(--mup-bg) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #contactList .contact-action {
    display: inline-grid !important;
    place-items: center;
    flex: 0 0 auto;
    inline-size: 38px !important;
    block-size: 38px !important;
    min-inline-size: 38px;
    padding: 0 !important;
    border: 1px solid transparent !important;
    border-radius: 13px !important;
    color: var(--mup-muted) !important;
    background: transparent !important;
    font-size: 0 !important;
    opacity: .88;
    transition:
      color 150ms ease,
      background 150ms ease,
      transform 120ms var(--mup-ease) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #contactList .contact-action svg {
    inline-size: 19px !important;
    block-size: 19px !important;
    margin: 0 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #contactList .contact-row:active .contact-action {
    color: var(--mup-accent) !important;
    background: var(--mup-accent-soft) !important;
  }

  /* --------------------------------------------------------------------- */
  /* Profile                                                                */
  /* --------------------------------------------------------------------- */

  html[data-hamrah-mobile-polish="r2"] #profileView {
    padding: 8px 16px calc(18px + env(safe-area-inset-bottom)) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-hero {
    position: relative;
    display: grid !important;
    grid-template-columns: auto minmax(0,1fr) 78px;
    grid-template-areas:
      "action name avatar"
      "action badges avatar"
      "action username avatar"
      "bio bio bio";
    column-gap: 12px;
    row-gap: 4px;
    min-block-size: 178px !important;
    margin: 1px 0 12px !important;
    padding: 18px !important;
    border: 1px solid var(--mup-border) !important;
    border-radius: var(--mup-radius-card) !important;
    overflow: hidden;
    color: var(--mup-text) !important;
    background:
      radial-gradient(circle at 86% 20%, color-mix(in srgb, var(--mup-accent) 10%, transparent), transparent 34%),
      linear-gradient(145deg, var(--mup-surface-2), var(--mup-surface)) !important;
    box-shadow: 0 10px 32px rgba(0,0,0,.13) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-pattern {
    display: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-avatar-wrap {
    grid-area: avatar;
    align-self: center;
    justify-self: end;
    margin: 0 !important;
    padding: 0 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #avatarButton {
    inline-size: 74px !important;
    block-size: 74px !important;
    min-inline-size: 74px;
    min-block-size: 74px;
    margin: 0 !important;
    border: 1px solid color-mix(in srgb, var(--mup-border) 85%, transparent) !important;
    border-radius: 50% !important;
    box-shadow: 0 7px 22px rgba(0,0,0,.20) !important;
    font-size: 1.55rem !important;
    transition: transform 150ms var(--mup-ease), box-shadow 170ms ease !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #avatarButton:active {
    transform: scale(.95);
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #profileDisplayName {
    grid-area: name;
    align-self: end;
    justify-self: end;
    min-inline-size: 0;
    margin: 0 !important;
    color: var(--mup-text) !important;
    font-size: 1.13rem !important;
    font-weight: 830 !important;
    letter-spacing: -.03em;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-hero-badges {
    grid-area: badges;
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px !important;
    margin: 0 !important;
    min-inline-size: 0;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-role-badge,
  html[data-hamrah-mobile-polish="r2"] #profileView .profile-status,
  html[data-hamrah-mobile-polish="r2"] #profileView .g10-owner-badge {
    min-block-size: 24px !important;
    padding: 3px 8px !important;
    border: 1px solid var(--mup-border) !important;
    border-radius: 10px !important;
    background: color-mix(in srgb, var(--mup-surface-3) 80%, transparent) !important;
    font-size: .60rem !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    box-shadow: none !important;
    animation: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-status {
    color: color-mix(in srgb, var(--mup-text) 88%, var(--mup-muted)) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-status i {
    background: var(--mup-success) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #profileDisplayUsername {
    grid-area: username;
    justify-self: end;
    min-inline-size: 0;
    margin: 0 !important;
    color: var(--mup-muted) !important;
    font-size: .72rem !important;
    font-weight: 520;
    direction: ltr;
    text-align: right;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #profileDisplayBio {
    grid-area: bio;
    justify-self: stretch;
    align-self: end;
    min-inline-size: 0;
    margin: 8px 0 0 !important;
    padding-block-start: 11px;
    border-block-start: 1px solid var(--mup-divider);
    color: var(--mup-muted) !important;
    font-size: .69rem !important;
    line-height: 1.55;
    text-align: start;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-hero-actions {
    grid-area: action;
    align-self: center;
    justify-self: start;
    margin: 0 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #editMyProfileButton {
    min-block-size: 42px !important;
    padding: 8px 11px !important;
    border: 1px solid color-mix(in srgb, var(--mup-accent) 23%, var(--mup-border)) !important;
    border-radius: 15px !important;
    color: var(--mup-text) !important;
    background: color-mix(in srgb, var(--mup-accent) 7%, var(--mup-surface)) !important;
    box-shadow: none !important;
    font-size: .67rem !important;
    font-weight: 720 !important;
    white-space: nowrap;
    transition:
      transform 130ms var(--mup-ease),
      color 150ms ease,
      background 160ms ease,
      border-color 160ms ease !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #editMyProfileButton svg {
    inline-size: 17px;
    block-size: 17px;
    color: var(--mup-accent);
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #editMyProfileButton:active {
    transform: scale(.96);
    background: var(--mup-accent-soft) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-card {
    margin: 0 0 12px !important;
    padding: 15px !important;
    border: 1px solid var(--mup-border) !important;
    border-radius: var(--mup-radius-card) !important;
    color: var(--mup-text) !important;
    background:
      linear-gradient(145deg, var(--mup-surface-2), var(--mup-surface)) !important;
    box-shadow: 0 8px 28px rgba(0,0,0,.10) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-overview-heading {
    align-items: start !important;
    gap: 10px;
    margin: 0 0 8px !important;
    padding: 0 1px 11px !important;
    border-block-end: 1px solid var(--mup-divider);
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-overview-heading h3 {
    margin: 0;
    color: var(--mup-text) !important;
    font-size: .89rem !important;
    font-weight: 790 !important;
    letter-spacing: -.02em;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-overview-heading p {
    margin: 2px 0 0 !important;
    color: var(--mup-muted) !important;
    font-size: .61rem !important;
    line-height: 1.5;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-safe-chip {
    display: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid > div {
    display: grid !important;
    grid-template-columns: 42px minmax(0,1fr);
    grid-template-rows: auto auto;
    grid-template-areas:
      "icon label"
      "icon value";
    align-items: center;
    min-block-size: 65px;
    gap: 1px 10px;
    padding: 8px 2px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid > div + div {
    border-block-start: 1px solid var(--mup-divider) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid > div > span {
    grid-area: icon;
    display: grid;
    place-items: center;
    inline-size: 38px !important;
    block-size: 38px !important;
    margin: 0 !important;
    border: 1px solid var(--mup-border);
    border-radius: 13px !important;
    color: var(--mup-accent) !important;
    background: var(--mup-accent-soft-2) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid > div > span svg {
    inline-size: 18px;
    block-size: 18px;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid > div > small {
    grid-area: label;
    align-self: end;
    color: var(--mup-text) !important;
    font-size: .69rem !important;
    font-weight: 680 !important;
    opacity: 1 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid > div > b {
    grid-area: value;
    align-self: start;
    min-inline-size: 0;
    color: var(--mup-muted) !important;
    font-size: .64rem !important;
    font-weight: 520 !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-privacy-row,
  html[data-hamrah-mobile-polish="r2"] #profileView .profile-account-actions .plain-row {
    min-block-size: 62px !important;
    margin: 0 !important;
    padding: 8px 2px !important;
    border: 0 !important;
    border-block-start: 1px solid var(--mup-divider) !important;
    border-radius: 0 !important;
    color: var(--mup-text) !important;
    background: transparent !important;
    box-shadow: none !important;
    transition: background 145ms ease, transform 120ms var(--mup-ease) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-privacy-row:active,
  html[data-hamrah-mobile-polish="r2"] #profileView .profile-account-actions .plain-row:active {
    transform: scale(.992);
    background: var(--mup-accent-soft-2) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .setting-icon {
    inline-size: 38px !important;
    block-size: 38px !important;
    border: 1px solid var(--mup-border);
    border-radius: 13px !important;
    color: var(--mup-accent) !important;
    background: var(--mup-accent-soft-2) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .plain-row b {
    color: var(--mup-text) !important;
    font-size: .70rem !important;
    font-weight: 700 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .plain-row small {
    margin-block-start: 2px;
    color: var(--mup-muted) !important;
    font-size: .61rem !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .chevron {
    color: var(--mup-muted-2) !important;
    inline-size: 17px !important;
    block-size: 17px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-form {
    animation: mupProfileEditorIn 210ms var(--mup-ease-out) both;
  }

  @keyframes mupProfileEditorIn {
    from { opacity: .45; transform: translateY(8px) scale(.995); }
    to   { opacity: 1; transform: none; }
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-form input,
  html[data-hamrah-mobile-polish="r2"] #profileView .profile-form textarea,
  html[data-hamrah-mobile-polish="r2"] #profileView .profile-form .input-wrap {
    border-color: var(--mup-border) !important;
    border-radius: 15px !important;
    background: var(--mup-surface-3) !important;
    color: var(--mup-text) !important;
  }

  /* --------------------------------------------------------------------- */
  /* Shared Bottom Navigation                                               */
  /* --------------------------------------------------------------------- */

  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav {
    z-index: var(--g10-z-nav, 40) !important;
    inline-size: calc(100% - 24px) !important;
    min-block-size: var(--mup-nav-height) !important;
    margin: 6px 12px calc(8px + env(safe-area-inset-bottom)) !important;
    padding: 6px !important;
    gap: 3px !important;
    border: 1px solid var(--mup-border) !important;
    border-radius: 26px !important;
    color: var(--mup-muted);
    background:
      linear-gradient(145deg,
        color-mix(in srgb, var(--mup-surface-2) 96%, transparent),
        color-mix(in srgb, var(--mup-surface) 96%, transparent)
      ) !important;
    box-shadow:
      0 12px 36px rgba(0,0,0,.22),
      inset 0 1px 0 rgba(255,255,255,.018) !important;
    backdrop-filter: blur(18px) !important;
    -webkit-backdrop-filter: blur(18px) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav button {
    position: relative;
    flex: 1 1 0 !important;
    min-inline-size: 0;
    min-block-size: 56px !important;
    block-size: 56px;
    margin: 0 !important;
    padding: 5px 2px !important;
    gap: 2px !important;
    border: 0 !important;
    border-radius: 19px !important;
    color: var(--mup-muted) !important;
    background: transparent !important;
    box-shadow: none !important;
    transition:
      color 170ms ease,
      background 190ms var(--mup-ease),
      transform 130ms var(--mup-ease) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav button:active {
    transform: scale(.94) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav button.active {
    color: #eaf5ff !important;
    background:
      linear-gradient(145deg,
        color-mix(in srgb, var(--mup-accent) 20%, var(--mup-surface-3)),
        color-mix(in srgb, var(--mup-accent) 10%, var(--mup-surface-2))
      ) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav button .nav-icon,
  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav button.active .nav-icon {
    display: inline-grid !important;
    place-items: center;
    inline-size: 32px !important;
    block-size: 27px !important;
    min-inline-size: 32px !important;
    margin: 0 auto !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 10px !important;
    color: inherit !important;
    background: transparent !important;
    transform: none !important;
    transition: transform 170ms var(--mup-ease-out), color 170ms ease !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav button.active .nav-icon {
    color: var(--mup-accent) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav button.active .nav-icon svg {
    transform: translateY(-1px) scale(1.045) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav button small {
    max-inline-size: 100%;
    color: inherit !important;
    font-size: .56rem !important;
    font-weight: 650 !important;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav button.active small {
    color: var(--mup-accent) !important;
    font-weight: 760 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav .g115f-nav-badge {
    transform: scale(.86);
  }

  /* Keep the old floating compose control hidden; the dedicated top action is
     the single creation affordance on this new mobile shell. */
  html[data-hamrah-mobile-polish="r2"] #newChatFab {
    display: none !important;
  }

  /* --------------------------------------------------------------------- */
  /* Micro states                                                           */
  /* --------------------------------------------------------------------- */

  html[data-hamrah-mobile-polish="r2"] .mup-pressable {
    -webkit-tap-highlight-color: transparent;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .room-shell,
  html[data-hamrah-mobile-polish="r2"] #contactList .contact-row,
  html[data-hamrah-mobile-polish="r2"] #profileView .plain-row,
  html[data-hamrah-mobile-polish="r2"] #roomFilters .filter-pill,
  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav button {
    -webkit-tap-highlight-color: transparent;
  }

  @media (max-width: 390px) {
    html[data-hamrah-mobile-polish="r2"] #profileView .profile-hero {
      grid-template-columns: minmax(0,1fr) 70px;
      grid-template-areas:
        "name avatar"
        "badges avatar"
        "username avatar"
        "bio bio"
        "action action";
    }

    html[data-hamrah-mobile-polish="r2"] #profileView .profile-hero-actions {
      justify-self: stretch;
      margin-block-start: 5px !important;
    }

    html[data-hamrah-mobile-polish="r2"] #profileView #editMyProfileButton {
      inline-size: 100%;
      justify-content: center;
    }

    html[data-hamrah-mobile-polish="r2"] #profileView #avatarButton {
      inline-size: 66px !important;
      block-size: 66px !important;
      min-inline-size: 66px;
      min-block-size: 66px;
    }

    html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav button small {
      font-size: .51rem !important;
    }
  }
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
  html[data-hamrah-mobile-polish="r2"] #app > .view.mup-view-enter,
  html[data-hamrah-mobile-polish="r2"] #profileView .profile-form {
    animation: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #topAction,
  html[data-hamrah-mobile-polish="r2"] #roomFilters .filter-pill,
  html[data-hamrah-mobile-polish="r2"] #roomList .room-shell,
  html[data-hamrah-mobile-polish="r2"] #contactList .contact-row,
  html[data-hamrah-mobile-polish="r2"] #profileView #editMyProfileButton,
  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav button,
  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav button .nav-icon {
    transition: none !important;
    transform: none !important;
  }
}

html[data-motion="off"][data-hamrah-mobile-polish="r2"] * {
  animation-duration: .01ms !important;
  transition-duration: .01ms !important;
}


/* -------------------------------------------------------------------------
 * R2 Geometry / alignment correction after Android Physical QA
 *
 * Physical coordinates are used intentionally for the topbar. R1 used
 * logical inline offsets; under RTL that mirrored the avatar/action/title
 * geometry and made the header look backwards and off-centre.
 * ------------------------------------------------------------------------- */

@media (max-width: 767px) {
  html[data-hamrah-mobile-polish="r2"] {
    --topbar-height: 58px;
  }

  html[data-hamrah-mobile-polish="r2"],
  html[data-hamrah-mobile-polish="r2"] body,
  html[data-hamrah-mobile-polish="r2"] #app {
    background: var(--mup-bg) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app,
  html[data-hamrah-mobile-polish="r2"] #app > .topbar,
  html[data-hamrah-mobile-polish="r2"] #app > .view,
  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav {
    box-sizing: border-box !important;
    max-inline-size: 100% !important;
  }

  /* Header: avatar physically right, action physically left, title truly centered. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar {
    inline-size: 100% !important;
    block-size: 58px !important;
    min-block-size: 58px !important;
    padding: 7px 16px !important;
    border-block-end: 1px solid var(--mup-divider) !important;
    background: var(--mup-bg) !important;
    box-shadow: none !important;
    overflow: hidden;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar .topbar-copy > div:last-child {
    left: 50% !important;
    right: auto !important;
    top: 50% !important;
    bottom: auto !important;
    inset-inline: auto !important;
    inset-block: auto !important;
    transform: translate(-50%, -50%) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar .mini-brand {
    right: 16px !important;
    left: auto !important;
    top: 7px !important;
    bottom: auto !important;
    inset-inline: auto !important;
    inset-block: auto !important;
    inline-size: 44px !important;
    block-size: 44px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar .mini-brand::after {
    right: -1px !important;
    left: auto !important;
    bottom: 1px !important;
    inset-inline: auto !important;
    inset-block: auto !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #topAction {
    left: 16px !important;
    right: auto !important;
    top: 7px !important;
    bottom: auto !important;
    inset-inline: auto !important;
    inset-block: auto !important;
  }

  /* Group10's c22 display:...!important was overriding .hidden, so the New Chat
     + button leaked into Calls / Contacts / Profile / Settings in the QA video. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar #topAction.hidden {
    display: none !important;
  }

  /* Presence already lives on the avatar. The second dot below every page title
     looked like a stray alignment artifact. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionStatus {
    display: none !important;
  }

  /* R1's logical end put the Hamrah mark on the wrong physical side in RTL. */
  html[data-hamrah-mobile-polish="r2"] .mup-brand-mark {
    right: -24px !important;
    left: auto !important;
    inset-inline: auto !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .view {
    inline-size: 100% !important;
    max-inline-size: 100% !important;
    overflow-x: hidden !important;
  }

  /* Chats:
     app.css still contributed 22px top padding to the View. During list scroll
     that left a transparent band above the sticky toolbar, which is the cropped
     "floating row" visible around 4-5 seconds in the physical QA video. */
  html[data-hamrah-mobile-polish="r2"] #chatsView {
    padding: 0 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatsView .chat-tools,
  html[data-hamrah-mobile-polish="r2"] #chatsView .home-toolbar {
    inset-block-start: 0 !important;
    margin: 0 !important;
    padding: 10px 16px 8px !important;
    border-block-end: 1px solid var(--mup-divider) !important;
    background: var(--mup-bg) !important;
    box-shadow: 0 7px 18px color-mix(in srgb, #000 24%, transparent) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatsView .search-box,
  html[data-hamrah-mobile-polish="r2"] #contactsView .search-box {
    box-sizing: border-box !important;
    inline-size: 100% !important;
    max-inline-size: 100% !important;
  }

  /* R1 accidentally resurrected the clear-X even for an empty query because
     the high-specificity display rule beat .hidden. */
  html[data-hamrah-mobile-polish="r2"] #chatsView .clear-search {
    flex: 0 0 30px !important;
    inline-size: 30px !important;
    min-inline-size: 30px !important;
    max-inline-size: 30px !important;
    block-size: 30px !important;
    display: grid !important;
    place-items: center;
    margin: 0 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatsView .clear-search.hidden {
    display: none !important;
  }

  /* Four existing filters share one rail evenly. No fake/unsupported filter
     is introduced just to imitate the reference mockup. */
  html[data-hamrah-mobile-polish="r2"] #roomFilters {
    inline-size: 100% !important;
    display: flex !important;
    align-items: stretch;
    justify-content: stretch;
    gap: 7px !important;
    overflow: visible !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomFilters .filter-pill {
    flex: 1 1 0 !important;
    min-inline-size: 0 !important;
    max-inline-size: none !important;
    justify-content: center !important;
    padding-inline: 7px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList {
    box-sizing: border-box !important;
    inline-size: 100% !important;
    margin: 0 !important;
    padding: 0 16px calc(16px + env(safe-area-inset-bottom)) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomList .room-shell,
  html[data-hamrah-mobile-polish="r2"] #roomList .list-row {
    box-sizing: border-box !important;
    inline-size: 100% !important;
    max-inline-size: 100% !important;
  }

  /* Contacts: every visible surface uses the same 16px rail. */
  html[data-hamrah-mobile-polish="r2"] #contactsView {
    box-sizing: border-box !important;
    padding: 10px 16px calc(92px + env(safe-area-inset-bottom)) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #contactsView .sticky-search,
  html[data-hamrah-mobile-polish="r2"] #contactsView .section-heading,
  html[data-hamrah-mobile-polish="r2"] #contactList,
  html[data-hamrah-mobile-polish="r2"] #contactList .contact-row {
    box-sizing: border-box !important;
    inline-size: 100% !important;
    max-inline-size: 100% !important;
    margin-inline: 0 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #contactsView .section-heading {
    padding-inline: 2px !important;
  }

  /* Profile: the QA video exposed three separate cascade/geometry bugs:
     1) content-box cards overflowing one side,
     2) RTL grid auto-placement scattering identity elements,
     3) Group10 injecting a second owner chip as an unnamed grid child. */
  html[data-hamrah-mobile-polish="r2"] #profileView {
    box-sizing: border-box !important;
    padding: 10px 16px calc(96px + env(safe-area-inset-bottom)) !important;
    overflow-x: hidden !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView > .profile-hero,
  html[data-hamrah-mobile-polish="r2"] #profileView > .profile-card {
    box-sizing: border-box !important;
    inline-size: 100% !important;
    max-inline-size: 100% !important;
    margin: 0 0 12px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-hero {
    min-block-size: 0 !important;
    padding: 16px !important;
    direction: ltr;
    grid-template-columns: 72px minmax(0, 1fr) !important;
    grid-template-areas:
      "avatar name"
      "avatar badges"
      "avatar username"
      "bio bio"
      "action action" !important;
    column-gap: 13px !important;
    row-gap: 4px !important;
    align-items: center;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-avatar-wrap {
    inline-size: 72px !important;
    max-inline-size: 72px !important;
    align-self: start !important;
    justify-self: start !important;
    direction: rtl;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #avatarButton {
    inline-size: 72px !important;
    block-size: 72px !important;
    min-inline-size: 72px !important;
    min-block-size: 72px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #profileDisplayName {
    align-self: end !important;
    justify-self: stretch !important;
    direction: rtl;
    text-align: right;
    inline-size: 100%;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-hero-badges {
    justify-self: stretch !important;
    justify-content: flex-start !important;
    direction: rtl;
    inline-size: 100%;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-role-badge,
  html[data-hamrah-mobile-polish="r2"] #profileView .profile-status {
    flex: 0 0 auto !important;
    inline-size: max-content !important;
    max-inline-size: 100% !important;
    white-space: nowrap;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #profileDisplayUsername {
    justify-self: stretch !important;
    direction: ltr;
    text-align: right !important;
    inline-size: 100%;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #profileDisplayBio {
    direction: rtl;
    text-align: right !important;
    inline-size: 100%;
    margin-block-start: 8px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-hero-actions {
    justify-self: end !important;
    align-self: center !important;
    direction: rtl;
    inline-size: auto !important;
    max-inline-size: 100% !important;
    margin-block-start: 2px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #editMyProfileButton {
    inline-size: auto !important;
    min-inline-size: 0 !important;
    max-inline-size: 100% !important;
    min-block-size: 40px !important;
    padding: 7px 12px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .g10-owner-badge[data-owner-context="profile"] {
    display: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-card {
    padding: 15px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-overview-heading,
  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid {
    box-sizing: border-box !important;
    inline-size: 100% !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-overview-heading {
    min-block-size: 46px;
  }

  /* Use physical LTR grid placement for geometry, then restore RTL to text.
     Icon boxes now form one straight column instead of jumping to the right. */
  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid > div {
    box-sizing: border-box !important;
    inline-size: 100% !important;
    min-block-size: 64px !important;
    direction: ltr;
    grid-template-columns: 42px minmax(0, 1fr) !important;
    grid-template-areas:
      "icon label"
      "icon value" !important;
    column-gap: 11px !important;
    padding-inline: 2px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid > div > span {
    justify-self: start;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid > div > small,
  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid > div > b {
    justify-self: stretch;
    direction: rtl;
    text-align: right;
    inline-size: 100%;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-privacy-row,
  html[data-hamrah-mobile-polish="r2"] #profileView .profile-account-actions,
  html[data-hamrah-mobile-polish="r2"] #profileView .profile-account-actions .plain-row {
    box-sizing: border-box !important;
    inline-size: 100% !important;
    max-inline-size: 100% !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-account-actions {
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Bottom nav: force exactly five equal tracks. Older layers still carry
     four-column/flex assumptions. */
  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav {
    box-sizing: border-box !important;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    align-items: stretch !important;
    inline-size: calc(100% - 24px) !important;
    block-size: auto !important;
    min-block-size: 68px !important;
    margin: 6px 12px calc(8px + env(safe-area-inset-bottom)) !important;
    padding: 6px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav > button {
    box-sizing: border-box !important;
    inline-size: 100% !important;
    min-inline-size: 0 !important;
    max-inline-size: 100% !important;
  }
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
  html[data-hamrah-mobile-polish="r2"] #chatsView .chat-tools,
  html[data-hamrah-mobile-polish="r2"] #chatsView .home-toolbar {
    box-shadow: none !important;
  }
}


/* -------------------------------------------------------------------------
 * R3 — Mobile Header Geometry Hotfix
 * Android physical QA: the avatar, Hamrah mark/title and + action were sharing
 * the same absolute-positioning plane and could visually collide under RTL /
 * WebView insets. R3 gives the topbar one explicit 3-column grid.
 * ------------------------------------------------------------------------- */

@media (max-width: 767px) {
  html[data-hamrah-mobile-polish="r2"] #app > .topbar {
    box-sizing: border-box !important;
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr) 44px !important;
    grid-template-rows: 44px !important;
    column-gap: 12px !important;
    align-items: center !important;
    justify-items: stretch !important;

    /* Physical grid ordering must not mirror with the Persian document. */
    direction: ltr !important;

    inline-size: 100% !important;
    block-size: auto !important;
    min-block-size: calc(58px + env(safe-area-inset-top)) !important;
    margin: 0 !important;
    padding:
      calc(7px + env(safe-area-inset-top))
      16px
      7px !important;

    border: 0 !important;
    border-block-end: 1px solid var(--mup-divider) !important;
    border-radius: 0 !important;
    background: var(--mup-bg) !important;
    box-shadow: none !important;
    overflow: visible !important;
    isolation: isolate;
  }

  /* Make the existing two children of .topbar-copy participate directly in
     the topbar grid. No DOM rewrite and no duplicated controls. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar .topbar-copy {
    display: contents !important;
  }

  /* Left: New Chat action — exactly one 44x44 cell. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar #topAction {
    grid-column: 1 !important;
    grid-row: 1 !important;

    position: relative !important;
    inset: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    inset-inline: auto !important;
    inset-block: auto !important;

    justify-self: start !important;
    align-self: center !important;

    inline-size: 44px !important;
    block-size: 44px !important;
    min-inline-size: 44px !important;
    min-block-size: 44px !important;
    max-inline-size: 44px !important;
    max-block-size: 44px !important;

    margin: 0 !important;
    transform: none !important;
    z-index: 2 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #topAction.hidden {
    display: none !important;
  }

  /* Centre: title + the small Hamrah mark as one bounded flex unit. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar .topbar-copy > div:last-child {
    grid-column: 2 !important;
    grid-row: 1 !important;

    position: relative !important;
    inset: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    inset-inline: auto !important;
    inset-block: auto !important;

    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 7px !important;

    inline-size: 100% !important;
    min-inline-size: 0 !important;
    max-inline-size: 100% !important;
    block-size: 44px !important;

    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
    overflow: hidden !important;
    direction: ltr !important;
    pointer-events: none !important;
    z-index: 1 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #viewTitle {
    flex: 0 1 auto !important;
    min-inline-size: 0 !important;
    max-inline-size: calc(100% - 24px) !important;

    margin: 0 !important;
    padding: 0 !important;

    color: var(--mup-text) !important;
    text-align: center !important;
    direction: rtl !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.2 !important;
  }

  html[data-hamrah-mobile-polish="r2"] .mup-brand-mark {
    display: block !important;
    position: relative !important;

    inset: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    inset-inline: auto !important;
    inset-block: auto !important;

    flex: 0 0 17px !important;
    inline-size: 17px !important;
    block-size: 22px !important;
    margin: 0 !important;
    transform: rotate(7deg) !important;
  }

  /* Right: account avatar / mini-brand — exactly one 44x44 cell. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar .mini-brand {
    grid-column: 3 !important;
    grid-row: 1 !important;

    position: relative !important;
    inset: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    inset-inline: auto !important;
    inset-block: auto !important;

    justify-self: end !important;
    align-self: center !important;

    inline-size: 44px !important;
    block-size: 44px !important;
    min-inline-size: 44px !important;
    min-block-size: 44px !important;
    max-inline-size: 44px !important;
    max-block-size: 44px !important;

    margin: 0 !important;
    transform: none !important;
    z-index: 2 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar .mini-brand::after {
    right: -1px !important;
    left: auto !important;
    bottom: 1px !important;
    top: auto !important;
    inset: auto !important;
    inset-inline: auto !important;
    inset-block: auto !important;
  }

  /* The connection state is represented by the avatar presence dot; never
     let its old inline box steal header geometry. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionStatus {
    display: none !important;
  }

  /* Chats content must start immediately after this single header row. */
  html[data-hamrah-mobile-polish="r2"] #chatsView {
    margin-block-start: 0 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatsView .chat-tools,
  html[data-hamrah-mobile-polish="r2"] #chatsView .home-toolbar {
    margin-block-start: 0 !important;
  }
}

@media (max-width: 360px) {
  html[data-hamrah-mobile-polish="r2"] #app > .topbar {
    grid-template-columns: 42px minmax(0, 1fr) 42px !important;
    column-gap: 9px !important;
    padding-inline: 12px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #topAction,
  html[data-hamrah-mobile-polish="r2"] #app > .topbar .mini-brand {
    inline-size: 42px !important;
    block-size: 42px !important;
    min-inline-size: 42px !important;
    min-block-size: 42px !important;
    max-inline-size: 42px !important;
    max-block-size: 42px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar .topbar-copy > div:last-child {
    gap: 5px !important;
  }
}


/* -------------------------------------------------------------------------
 * R4 — Mobile Connection Header State
 *
 * Physical QA target:
 * - ONLINE: compact Header; title/brand is vertically centered.
 * - CONNECTING / RECONNECTING / DEGRADED / OFFLINE / FAILED:
 *   center brand cluster glides slightly down, a compact status line appears,
 *   and the Header grows only enough to contain that state.
 * - Returning ONLINE reverses the motion and collapses the status line.
 *
 * No connection logic is reimplemented here. app.js already owns the state
 * machine and updates #connectionStatus[data-state] / label text.
 * ------------------------------------------------------------------------- */

@media (max-width: 767px) {
  html[data-hamrah-mobile-polish="r2"] #app > .topbar {
    --mup-header-row: 44px;
    --mup-header-state-row: 0px;

    grid-template-rows: calc(var(--mup-header-row) + var(--mup-header-state-row)) !important;
    min-block-size:
      calc(
        var(--mup-header-row) +
        var(--mup-header-state-row) +
        14px +
        env(safe-area-inset-top)
      ) !important;

    transition:
      min-block-size 220ms var(--mup-ease-out),
      grid-template-rows 220ms var(--mup-ease-out),
      background 180ms ease !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar:has(
    #connectionStatus:not([data-state="connected"])
  ) {
    --mup-header-state-row: 18px;
  }

  /* The centre slot becomes a tiny two-row brand/status component.
     + and avatar remain in their own fixed side cells. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar .topbar-copy > div:last-child {
    display: grid !important;
    grid-template-columns: minmax(0, auto) 17px !important;
    grid-template-rows: 28px 0px !important;
    column-gap: 7px !important;
    row-gap: 0 !important;
    place-content: center !important;
    align-items: center !important;
    justify-content: center !important;

    block-size: 44px !important;
    overflow: visible !important;

    transform: translateY(0) !important;
    transition:
      block-size 220ms var(--mup-ease-out),
      transform 220ms var(--mup-ease-out) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar:has(
    #connectionStatus:not([data-state="connected"])
  ) .topbar-copy > div:last-child {
    grid-template-rows: 28px 18px !important;
    block-size: 62px !important;
    transform: translateY(3px) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #viewTitle {
    grid-column: 1 !important;
    grid-row: 1 !important;

    align-self: center !important;
    justify-self: end !important;
    max-inline-size: 100% !important;
    line-height: 1.15 !important;

    transform: translateY(0) !important;
    transition:
      transform 210ms var(--mup-ease-out),
      opacity 160ms ease !important;
  }

  html[data-hamrah-mobile-polish="r2"] .mup-brand-mark {
    grid-column: 2 !important;
    grid-row: 1 !important;

    align-self: center !important;
    justify-self: start !important;

    transform: rotate(7deg) translateY(0) !important;
    transition:
      transform 220ms var(--mup-ease-out),
      filter 180ms ease !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar:has(
    #connectionStatus:not([data-state="connected"])
  ) #viewTitle {
    transform: translateY(2px) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar:has(
    #connectionStatus:not([data-state="connected"])
  ) .mup-brand-mark {
    transform: rotate(7deg) translateY(3px) !important;
    filter: saturate(.92) brightness(.98);
  }

  /* Connection caption: existing app-owned status node, now visible only
     when useful. It does not become a second source of truth. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionStatus {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;

    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    justify-self: center !important;
    align-self: center !important;
    gap: 5px !important;

    inline-size: auto !important;
    max-inline-size: min(68vw, 260px) !important;
    min-block-size: 16px !important;
    block-size: 16px !important;

    margin: 0 !important;
    padding: 0 !important;

    color: var(--mup-muted) !important;
    font-size: .58rem !important;
    font-weight: 650 !important;
    line-height: 1 !important;
    text-align: center !important;
    direction: rtl !important;

    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateY(-5px) scale(.98) !important;
    pointer-events: none !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;

    transition:
      opacity 150ms ease,
      transform 220ms var(--mup-ease-out),
      visibility 0s linear 220ms !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionStatus:not(
    [data-state="connected"]
  ) {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) scale(1) !important;
    transition:
      opacity 160ms ease 55ms,
      transform 220ms var(--mup-ease-out),
      visibility 0s linear 0s !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionStatusLabel {
    display: block !important;
    min-inline-size: 0 !important;
    max-inline-size: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionStatusMeta,
  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionRetryButton {
    display: none !important;
  }

  /* A compact spinner replaces the old stray dot while connecting. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionStatus > i {
    position: relative !important;
    flex: 0 0 9px !important;

    inline-size: 9px !important;
    block-size: 9px !important;
    min-inline-size: 9px !important;
    min-block-size: 9px !important;

    margin: 0 !important;
    border: 1.5px solid color-mix(in srgb, var(--mup-accent) 32%, transparent) !important;
    border-block-start-color: var(--mup-accent) !important;
    border-radius: 50% !important;

    background: transparent !important;
    box-shadow: none !important;

    animation: mupConnectionSpin 780ms linear infinite;
  }

  @keyframes mupConnectionSpin {
    to { transform: rotate(360deg); }
  }

  /* Offline/failure states are static, not an endlessly spinning affordance. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionStatus:is(
    [data-state="offline"],
    [data-state="failed"],
    [data-state="permanently-failed"],
    [data-state="authentication-required"],
    [data-state="revoked"],
    [data-state="stopped"]
  ) > i {
    animation: none !important;
    border: 0 !important;
    background: var(--mup-muted-2) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionStatus:is(
    [data-state="failed"],
    [data-state="permanently-failed"],
    [data-state="authentication-required"],
    [data-state="revoked"]
  ) {
    color: color-mix(in srgb, #ffb46a 78%, var(--mup-muted)) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionStatus:is(
    [data-state="failed"],
    [data-state="permanently-failed"],
    [data-state="authentication-required"],
    [data-state="revoked"]
  ) > i {
    background: #ffad61 !important;
  }

  /* Avatar presence now tells the truth:
     green = ONLINE, blue animated ring = transient connection state,
     muted = offline/stopped, warm = auth/failure. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar .mini-brand::after {
    background: var(--mup-success) !important;
    border-color: var(--mup-bg) !important;
    box-shadow: none !important;
    transform: scale(1) !important;

    transition:
      background 170ms ease,
      border-color 170ms ease,
      transform 180ms var(--mup-ease-out),
      box-shadow 180ms ease !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar:has(
    #connectionStatus:is(
      [data-state="initializing"],
      [data-state="connecting"],
      [data-state="reconnecting"],
      [data-state="degraded"]
    )
  ) .mini-brand::after {
    background: var(--mup-bg) !important;
    border: 2px solid var(--mup-accent) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mup-accent) 9%, transparent) !important;
    animation: mupAvatarConnectionPulse 980ms ease-in-out infinite;
  }

  @keyframes mupAvatarConnectionPulse {
    0%, 100% {
      transform: scale(.78);
      box-shadow: 0 0 0 2px color-mix(in srgb, var(--mup-accent) 7%, transparent);
    }
    50% {
      transform: scale(1);
      box-shadow: 0 0 0 5px color-mix(in srgb, var(--mup-accent) 4%, transparent);
    }
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar:has(
    #connectionStatus:is(
      [data-state="offline"],
      [data-state="stopped"]
    )
  ) .mini-brand::after {
    background: var(--mup-muted-2) !important;
    border-color: var(--mup-bg) !important;
    animation: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar:has(
    #connectionStatus:is(
      [data-state="failed"],
      [data-state="permanently-failed"],
      [data-state="authentication-required"],
      [data-state="revoked"]
    )
  ) .mini-brand::after {
    background: #ffad61 !important;
    border-color: var(--mup-bg) !important;
    animation: none !important;
  }

  /* Keep the expanded header visually attached to the Chats toolbar. */
  html[data-hamrah-mobile-polish="r2"] #chatsView .chat-tools,
  html[data-hamrah-mobile-polish="r2"] #chatsView .home-toolbar {
    transition:
      border-color 180ms ease,
      background 180ms ease,
      box-shadow 180ms ease !important;
  }
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
  html[data-hamrah-mobile-polish="r2"] #app > .topbar,
  html[data-hamrah-mobile-polish="r2"] #app > .topbar .topbar-copy > div:last-child,
  html[data-hamrah-mobile-polish="r2"] #app > .topbar #viewTitle,
  html[data-hamrah-mobile-polish="r2"] .mup-brand-mark,
  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionStatus,
  html[data-hamrah-mobile-polish="r2"] #app > .topbar .mini-brand::after {
    transition: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #connectionStatus > i,
  html[data-hamrah-mobile-polish="r2"] #app > .topbar .mini-brand::after {
    animation: none !important;
  }
}


/* -------------------------------------------------------------------------
 * R5 — Mobile Header Brand / Presence Polish
 *
 * Physical QA request:
 * - move the ONLINE presence dot slightly lower beside the profile avatar
 * - add a very soft connected-state blink/pulse
 * - make the Hamrah brand cluster more legible without breaking true centering
 * ------------------------------------------------------------------------- */

@media (max-width: 767px) {
  /* The centre column already owns the exact visual midpoint from R3/R4.
     Increase the brand scale inside that bounded centre cell only. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar .topbar-copy > div:last-child {
    grid-template-columns: minmax(0, auto) 22px !important;
    column-gap: 8px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #viewTitle {
    font-size: 1.24rem !important;
    font-weight: 840 !important;
    letter-spacing: -.035em !important;
    line-height: 1.1 !important;
  }

  html[data-hamrah-mobile-polish="r2"] .mup-brand-mark {
    flex-basis: 22px !important;
    inline-size: 22px !important;
    block-size: 28px !important;
    transform: rotate(7deg) translateY(0) !important;
  }

  html[data-hamrah-mobile-polish="r2"] .mup-brand-mark::before {
    inline-size: 10px !important;
    block-size: 28px !important;
  }

  html[data-hamrah-mobile-polish="r2"] .mup-brand-mark::after {
    inline-size: 10px !important;
    block-size: 20px !important;
  }

  /* Presence dot sits lower and slightly inward, visually attached to avatar
     instead of floating over its face. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar .mini-brand::after {
    right: 2px !important;
    left: auto !important;
    bottom: -4px !important;
    top: auto !important;

    inline-size: 10px !important;
    block-size: 10px !important;

    border-width: 2px !important;
    transform-origin: center !important;
  }

  /* ONLINE only: a calm pulse, not an attention-grabbing flash. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar:has(
    #connectionStatus[data-state="connected"]
  ) .mini-brand::after {
    animation: mupConnectedPresenceSoftPulse 2200ms ease-in-out infinite !important;
  }

  @keyframes mupConnectedPresenceSoftPulse {
    0%, 100% {
      opacity: .76;
      transform: scale(.92);
      box-shadow: 0 0 0 0 color-mix(in srgb, var(--mup-success) 0%, transparent);
    }
    50% {
      opacity: 1;
      transform: scale(1.05);
      box-shadow: 0 0 0 4px color-mix(in srgb, var(--mup-success) 8%, transparent);
    }
  }

  /* Connection-state animations continue to own the dot while not connected. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar:has(
    #connectionStatus:is(
      [data-state="initializing"],
      [data-state="connecting"],
      [data-state="reconnecting"],
      [data-state="degraded"]
    )
  ) .mini-brand::after {
    animation: mupAvatarConnectionPulse 980ms ease-in-out infinite !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar:has(
    #connectionStatus:is(
      [data-state="offline"],
      [data-state="stopped"],
      [data-state="failed"],
      [data-state="permanently-failed"],
      [data-state="authentication-required"],
      [data-state="revoked"]
    )
  ) .mini-brand::after {
    animation: none !important;
  }
}

@media (max-width: 360px) {
  html[data-hamrah-mobile-polish="r2"] #app > .topbar .topbar-copy > div:last-child {
    grid-template-columns: minmax(0, auto) 20px !important;
    column-gap: 6px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar #viewTitle {
    font-size: 1.16rem !important;
  }

  html[data-hamrah-mobile-polish="r2"] .mup-brand-mark {
    flex-basis: 20px !important;
    inline-size: 20px !important;
    block-size: 25px !important;
  }
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
  html[data-hamrah-mobile-polish="r2"] #app > .topbar .mini-brand::after {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    box-shadow: none !important;
  }
}


/* -------------------------------------------------------------------------
 * R6 — Mobile Header Viewport + Settings Scroll Stability
 *
 * Android physical QA:
 * 1) The native Android status bar already owns the top inset. The web topbar
 *    was still reserving env(safe-area-inset-top), effectively double-counting
 *    top chrome and making Chats look vertically cramped.
 * 2) The connected-state status ornament could leave a tiny orphan glyph in
 *    the otherwise-empty header area.
 * 3) Settings entrance transforms made section headers/cards appear to drift
 *    while returning to / scrolling the Settings surface.
 * ------------------------------------------------------------------------- */

@media (max-width: 767px) {
  /* --------------------------------------------------------------- */
  /* Header: compact exact physical height on Android WebView         */
  /* --------------------------------------------------------------- */

  html[data-hamrah-mobile-polish="r2"] #app > .topbar {
    /* Native MainActivity/status bar already supplies the system top inset. */
    height: 52px !important;
    block-size: 52px !important;
    min-height: 52px !important;
    min-block-size: 52px !important;
    max-height: 52px !important;
    max-block-size: 52px !important;

    grid-template-rows: 44px !important;
    padding: 4px 16px !important;

    overflow: visible !important;
  }

  /* The legacy app.css header wave is no longer part of the new mobile shell.
     Removing it also prevents an animated pseudo-element from extending the
     visual header below the real grid. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar::after {
    content: none !important;
    display: none !important;
    animation: none !important;
  }

  /* R4 still gets a small second row while connection is not healthy. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar:has(
    #connectionStatus:not([data-state="connected"])
  ) {
    height: 70px !important;
    block-size: 70px !important;
    min-height: 70px !important;
    min-block-size: 70px !important;
    max-height: 70px !important;
    max-block-size: 70px !important;

    grid-template-rows: 62px !important;
    padding-block: 4px !important;
  }

  /* ONLINE must be completely collapsed — including its child indicator.
     This explicitly removes the tiny orphan magnifier/ring seen below the
     header in physical QA. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar
  #connectionStatus[data-state="connected"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    inline-size: 0 !important;
    block-size: 0 !important;
    min-inline-size: 0 !important;
    min-block-size: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  html[data-hamrah-mobile-polish="r2"] #app > .topbar
  #connectionStatus[data-state="connected"] > * {
    display: none !important;
    visibility: hidden !important;
    animation: none !important;
  }

  /* Keep the three approved R5 header cells visually centred in the new,
     shorter physical header. */
  html[data-hamrah-mobile-polish="r2"] #app > .topbar #topAction,
  html[data-hamrah-mobile-polish="r2"] #app > .topbar .mini-brand,
  html[data-hamrah-mobile-polish="r2"] #app > .topbar .topbar-copy > div:last-child {
    align-self: center !important;
    margin-block: 0 !important;
  }

  /* Search/filter rail attaches directly to the compact header. */
  html[data-hamrah-mobile-polish="r2"] #chatsView .chat-tools,
  html[data-hamrah-mobile-polish="r2"] #chatsView .home-toolbar {
    margin-block-start: 0 !important;
    padding-block-start: 8px !important;
  }

  /* --------------------------------------------------------------- */
  /* Settings: stop header/card drift during scroll / route return    */
  /* --------------------------------------------------------------- */

  html[data-hamrah-mobile-polish="r2"] #settingsView {
    padding-block-start: 8px !important;
    scroll-padding-block-start: 0 !important;
    overscroll-behavior-y: contain;
  }

  /* Settings is a normal document-flow surface on mobile. Old entrance
     animations used translateY and could make its headings/cards appear to
     slide down again when the view was reactivated after a nested screen. */
  html[data-hamrah-mobile-polish="r2"] #settingsView .settings-intro,
  html[data-hamrah-mobile-polish="r2"] #settingsView .settings-group,
  html[data-hamrah-mobile-polish="r2"] #settingsView .settings-title,
  html[data-hamrah-mobile-polish="r2"] #settingsView .settings-category-card,
  html[data-hamrah-mobile-polish="r2"] #settingsView .settings-category-header,
  html[data-hamrah-mobile-polish="r2"] #settingsView .section-heading,
  html[data-hamrah-mobile-polish="r2"] #settingsView .section-head {
    position: relative !important;
    inset: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;

    transform: none !important;
    translate: none !important;
    animation: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #settingsView .settings-group {
    opacity: 1 !important;
  }

  /* The global topbar itself must never acquire sticky/transform state from
     Settings-specific scrolling. It stays in the shell's first layout row. */
  html[data-hamrah-mobile-polish="r2"] #app[data-mobile-view="settings"] > .topbar {
    position: relative !important;
    inset: auto !important;
    transform: none !important;
  }
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
  html[data-hamrah-mobile-polish="r2"] #settingsView .settings-intro,
  html[data-hamrah-mobile-polish="r2"] #settingsView .settings-group,
  html[data-hamrah-mobile-polish="r2"] #settingsView .settings-title {
    animation: none !important;
    transform: none !important;
  }
}


/* -------------------------------------------------------------------------
 * R7 — Mobile Settings Internal Header Scroll Hotfix
 *
 * Android physical QA video showed that nested Settings headers such as
 * "حساب" and "ظاهر" were sticky. While the page content scrolled underneath,
 * those headers remained pinned below the global "تنظیمات" app header, which
 * looked like the header was moving/down-floating during scroll.
 *
 * R7 removes sticky behavior from the INTERNAL Settings page headers only.
 * The global app topbar and all Home/Header R6 work remain untouched.
 * ------------------------------------------------------------------------- */

@media (max-width: 767px) {
  /* G8 nested Settings page header: flow with the page, never stick. */
  html[data-hamrah-mobile-polish="r2"] #settingsView .g8-page-header {
    position: relative !important;

    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    inset: auto !important;
    inset-block: auto !important;
    inset-inline: auto !important;

    z-index: auto !important;

    margin-block: 0 10px !important;
    padding-block: 0 10px !important;

    transform: none !important;
    translate: none !important;
    animation: none !important;

    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
  }

  /* The currently active nested page itself owns the scroll. Do not let a
     page/header wrapper establish another sticky containing block. */
  html[data-hamrah-mobile-polish="r2"] #settingsView .g8-settings-page,
  html[data-hamrah-mobile-polish="r2"] #settingsView .g8-page-content {
    position: relative !important;
    top: auto !important;
    inset-block-start: auto !important;
    transform: none !important;
  }

  /* Main Settings landing header also remains ordinary flow if the G8 shell
     is active on mobile. This prevents any category header from inheriting
     sticky desktop semantics. */
  html[data-hamrah-mobile-polish="r2"] #settingsView .g8-settings-hero,
  html[data-hamrah-mobile-polish="r2"] #settingsView .g8-settings-home {
    position: relative !important;
    top: auto !important;
    inset: auto !important;
    transform: none !important;
  }

  /* Kill any sticky positioning accidentally inherited by a Settings heading
     class from another layer without touching ordinary cards/rows. */
  html[data-hamrah-mobile-polish="r2"] #settingsView :is(
    .g8-page-header,
    .settings-title,
    .settings-category-header,
    .section-heading,
    .section-head
  ) {
    scroll-margin-block-start: 0 !important;
  }
}


/* -------------------------------------------------------------------------
 * P1 — Android Profile Composition Polish
 *
 * Goal: keep Hamrah's current dark visual identity while fixing mobile
 * composition/density. Telegram is a UX-density reference only, not a visual
 * template.
 * ------------------------------------------------------------------------- */

@media (max-width: 767px) {
  /* --------------------------------------------------------------- */
  /* Profile page rhythm                                             */
  /* --------------------------------------------------------------- */

  html[data-hamrah-mobile-polish="r2"] #profileView {
    box-sizing: border-box !important;
    inline-size: 100% !important;
    padding: 8px 14px calc(96px + env(safe-area-inset-bottom)) !important;
    overflow-x: hidden !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView > .profile-hero,
  html[data-hamrah-mobile-polish="r2"] #profileView > .profile-card {
    box-sizing: border-box !important;
    inline-size: 100% !important;
    max-inline-size: 100% !important;
    margin-inline: 0 !important;
  }

  /* --------------------------------------------------------------- */
  /* Identity hero — compact, centred, personal                      */
  /* --------------------------------------------------------------- */

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-hero {
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-areas:
      "avatar"
      "name"
      "badges"
      "username"
      "bio"
      "action" !important;
    justify-items: center !important;
    align-items: center !important;

    min-block-size: 0 !important;
    padding: 16px 16px 15px !important;
    gap: 0 !important;

    border: 1px solid var(--mup-border) !important;
    border-radius: 22px !important;

    direction: rtl !important;
    text-align: center !important;

    background:
      radial-gradient(
        circle at 50% 12%,
        color-mix(in srgb, var(--profile-accent, var(--mup-accent)) 16%, transparent) 0%,
        color-mix(in srgb, var(--profile-accent, var(--mup-accent)) 6%, transparent) 28%,
        transparent 53%
      ),
      linear-gradient(160deg, var(--mup-surface-2), var(--mup-surface)) !important;

    box-shadow:
      0 9px 28px rgba(0,0,0,.14),
      inset 0 1px 0 rgba(255,255,255,.018) !important;
    overflow: hidden !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-pattern {
    display: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-hero::after {
    content: "" !important;
    position: absolute !important;
    inset: auto auto -74px -66px !important;
    inline-size: 150px !important;
    block-size: 150px !important;
    border-radius: 50% !important;
    background:
      radial-gradient(
        circle,
        color-mix(in srgb, var(--profile-accent, var(--mup-accent)) 9%, transparent),
        transparent 68%
      ) !important;
    pointer-events: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-avatar-wrap {
    grid-area: avatar !important;
    inline-size: 82px !important;
    max-inline-size: 82px !important;
    margin: 0 0 8px !important;
    justify-self: center !important;
    align-self: center !important;
    direction: rtl !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #avatarButton {
    inline-size: 82px !important;
    block-size: 82px !important;
    min-inline-size: 82px !important;
    min-block-size: 82px !important;
    max-inline-size: 82px !important;
    max-block-size: 82px !important;

    border: 2px solid color-mix(in srgb, var(--profile-accent, var(--mup-accent)) 24%, var(--mup-border)) !important;
    border-radius: 50% !important;

    box-shadow:
      0 9px 24px rgba(0,0,0,.24),
      0 0 0 5px color-mix(in srgb, var(--profile-accent, var(--mup-accent)) 6%, transparent) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #profileDisplayName {
    grid-area: name !important;
    justify-self: center !important;
    inline-size: auto !important;
    max-inline-size: 100% !important;
    margin: 0 !important;

    color: var(--mup-text) !important;
    font-size: 1.08rem !important;
    font-weight: 840 !important;
    line-height: 1.25 !important;
    letter-spacing: -.028em !important;
    text-align: center !important;
    direction: rtl !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-hero-badges {
    grid-area: badges !important;
    justify-self: center !important;
    inline-size: auto !important;
    max-inline-size: 100% !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
    gap: 6px !important;

    margin: 7px 0 0 !important;
    direction: rtl !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-role-badge,
  html[data-hamrah-mobile-polish="r2"] #profileView .profile-status {
    min-block-size: 23px !important;
    inline-size: max-content !important;
    max-inline-size: 100% !important;
    padding: 3px 8px !important;

    border: 1px solid var(--mup-border) !important;
    border-radius: 10px !important;

    background: color-mix(in srgb, var(--mup-surface-3) 82%, transparent) !important;
    box-shadow: none !important;

    font-size: .59rem !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-status i {
    inline-size: 7px !important;
    block-size: 7px !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mup-success) 8%, transparent) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .g10-owner-badge[data-owner-context="profile"] {
    display: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #profileDisplayUsername {
    grid-area: username !important;
    justify-self: center !important;
    inline-size: auto !important;
    max-inline-size: 100% !important;

    margin: 6px 0 0 !important;

    color: var(--mup-muted) !important;
    font-size: .67rem !important;
    font-weight: 550 !important;
    line-height: 1.3 !important;
    direction: ltr !important;
    text-align: center !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #profileDisplayBio {
    grid-area: bio !important;
    justify-self: center !important;
    inline-size: min(100%, 300px) !important;
    max-inline-size: 300px !important;

    margin: 8px 0 0 !important;
    padding: 9px 8px 0 !important;

    border-block-start: 1px solid var(--mup-divider) !important;

    color: var(--mup-muted) !important;
    font-size: .66rem !important;
    line-height: 1.48 !important;
    text-align: center !important;
    direction: rtl !important;

    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-hero-actions {
    grid-area: action !important;
    justify-self: center !important;
    inline-size: auto !important;
    max-inline-size: 100% !important;

    margin: 11px 0 0 !important;
    direction: rtl !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #editMyProfileButton {
    inline-size: auto !important;
    min-inline-size: 0 !important;
    min-block-size: 38px !important;

    padding: 7px 13px !important;

    border: 1px solid color-mix(in srgb, var(--mup-accent) 24%, var(--mup-border)) !important;
    border-radius: 14px !important;

    color: var(--mup-text) !important;
    background: color-mix(in srgb, var(--mup-accent) 7%, var(--mup-surface-2)) !important;

    font-size: .66rem !important;
    font-weight: 740 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView #editMyProfileButton svg {
    inline-size: 16px !important;
    block-size: 16px !important;
  }

  /* --------------------------------------------------------------- */
  /* Account facts — dense, scan-friendly                            */
  /* --------------------------------------------------------------- */

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-overview-card {
    margin-block-start: 11px !important;
    padding: 13px !important;

    border-radius: 21px !important;
    background:
      linear-gradient(155deg, var(--mup-surface-2), var(--mup-surface)) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-overview-heading {
    min-block-size: 0 !important;
    margin: 0 !important;
    padding: 0 2px 10px !important;

    border-block-end: 1px solid var(--mup-divider) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-overview-heading h3 {
    margin: 0 !important;
    font-size: .84rem !important;
    font-weight: 800 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-overview-heading p {
    margin: 2px 0 0 !important;
    font-size: .59rem !important;
    line-height: 1.35 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-safe-chip {
    display: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid {
    margin: 0 !important;
    padding: 0 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid > div {
    box-sizing: border-box !important;
    inline-size: 100% !important;
    min-block-size: 54px !important;

    grid-template-columns: 36px minmax(0, 1fr) !important;
    grid-template-areas:
      "icon label"
      "icon value" !important;

    column-gap: 9px !important;
    row-gap: 0 !important;

    padding: 7px 2px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid > div > span {
    inline-size: 34px !important;
    block-size: 34px !important;

    border-radius: 12px !important;
    background: color-mix(in srgb, var(--mup-accent) 7%, var(--mup-surface-3)) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid > div > span svg {
    inline-size: 16px !important;
    block-size: 16px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid > div > small {
    font-size: .64rem !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-fact-grid > div > b {
    margin-block-start: 2px !important;

    color: var(--mup-muted) !important;
    font-size: .58rem !important;
    font-weight: 540 !important;
    line-height: 1.25 !important;
  }

  /* --------------------------------------------------------------- */
  /* Account / privacy actions — one clear second group              */
  /* --------------------------------------------------------------- */

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-settings-block {
    margin-block-start: 11px !important;
    padding-block-start: 11px !important;

    border-block-start: 1px solid var(--mup-divider) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-settings-heading {
    margin: 0 !important;
    padding: 0 2px 9px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-settings-heading h3 {
    margin: 0 !important;

    color: var(--mup-text) !important;
    font-size: .76rem !important;
    font-weight: 780 !important;
    letter-spacing: -.015em !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-settings-heading p {
    margin: 2px 0 0 !important;

    color: var(--mup-muted) !important;
    font-size: .56rem !important;
    line-height: 1.35 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-settings-block > .profile-privacy-row,
  html[data-hamrah-mobile-polish="r2"] #profileView .profile-account-actions .plain-row {
    box-sizing: border-box !important;
    inline-size: 100% !important;
    min-block-size: 55px !important;

    margin: 0 !important;
    padding: 7px 3px !important;

    border: 0 !important;
    border-block-start: 1px solid var(--mup-divider) !important;
    border-radius: 0 !important;

    background: transparent !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-settings-block > .profile-privacy-row {
    border-block-start-color: transparent !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-account-actions {
    margin: 0 !important;
    padding: 0 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-settings-block .setting-icon {
    inline-size: 34px !important;
    block-size: 34px !important;
    flex-basis: 34px !important;

    border-radius: 12px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-settings-block .setting-icon svg {
    inline-size: 16px !important;
    block-size: 16px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-settings-block .plain-row b {
    font-size: .65rem !important;
    font-weight: 720 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-settings-block .plain-row small {
    margin-block-start: 2px !important;
    font-size: .56rem !important;
    line-height: 1.3 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-settings-block .chevron {
    inline-size: 15px !important;
    block-size: 15px !important;
  }

  /* Edit card remains functional but inherits the same tighter mobile rhythm. */
  html[data-hamrah-mobile-polish="r2"] #profileView .profile-form {
    margin-block-start: 11px !important;
    border-radius: 21px !important;
  }
}

@media (max-width: 380px) {
  html[data-hamrah-mobile-polish="r2"] #profileView {
    padding-inline: 12px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-hero {
    padding-inline: 13px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #profileView .profile-avatar-wrap,
  html[data-hamrah-mobile-polish="r2"] #profileView #avatarButton {
    inline-size: 76px !important;
    block-size: 76px !important;
    min-inline-size: 76px !important;
    min-block-size: 76px !important;
    max-inline-size: 76px !important;
    max-block-size: 76px !important;
  }
}


/* -------------------------------------------------------------------------
 * Phase E2 P1 — Android chat focused mode
 * The primary app navigation must never overlap chat composer/emoji/attachment.
 * ------------------------------------------------------------------------- */
@media (max-width:767px) {
  html[data-hamrah-mobile-polish="r2"] #app > .bottom-nav {
    transition:
      opacity 150ms ease,
      transform 190ms var(--mup-ease-out),
      filter 190ms ease !important;
    transform-origin: center bottom !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) ~ .bottom-nav {
    opacity: 0 !important;
    transform: translate3d(0, calc(100% + 18px), 0) !important;
    filter: blur(4px) !important;
    pointer-events: none !important;
    z-index: 18 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) ~ #newChatFab {
    opacity: 0 !important;
    transform: translate3d(0, 18px, 0) scale(.94) !important;
    pointer-events: none !important;
    visibility: hidden !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) {
    z-index: 80 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .composer {
    position: relative !important;
    z-index: 6 !important;
    padding-block-end: calc(7px + env(safe-area-inset-bottom)) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .emoji-panel,
  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .edit-banner,
  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .reply-banner {
    z-index: 7 !important;
  }
}

/* -------------------------------------------------------------------------
 * E4 Hotfix3 — Android chat composer safe-bottom geometry
 * Physical Android QA showed the focused-chat composer sitting too close to
 * the system navigation area after the app bottom-nav is hidden.
 *
 * Keep the whole composer above the system edge with a real outer clearance.
 * Do not inflate the inside of the composer; keyboard-open behavior remains
 * intentionally compact.
 * ------------------------------------------------------------------------- */
@media (max-width:767px) {
  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .composer {
    margin-block-end: max(16px, env(safe-area-inset-bottom)) !important;
    padding-block-end: 7px !important;
  }

  html[data-hamrah-mobile-polish="r2"][data-keyboard-open="true"] #chatScreen:not(.hidden) .composer {
    margin-block-end: 4px !important;
    padding-block-end: 6px !important;
  }
}

/* -------------------------------------------------------------------------
 * E4 Hotfix4 — Android Composer Dock Redesign
 * Final physical QA redesign: make the mobile composer a deliberate floating
 * dock instead of a full-width bottom slab. Keep it in normal chat flex flow
 * so keyboard, emoji, reply/edit and message viewport geometry remain native.
 * ------------------------------------------------------------------------- */
@media (max-width:767px) {
  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) {
    --e4-composer-edge: 12px;
    --e4-composer-floor: 18px;
    --e4-composer-control: 44px;
    --e4-composer-radius: 24px;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .composer {
    box-sizing: border-box !important;
    inline-size: calc(100% - (var(--e4-composer-edge) * 2)) !important;
    min-inline-size: 0 !important;
    min-block-size: 60px !important;
    margin:
      8px
      var(--e4-composer-edge)
      max(var(--e4-composer-floor), env(safe-area-inset-bottom)) !important;
    padding: 7px !important;
    gap: 4px !important;
    align-items: center !important;
    border: 1px solid color-mix(in srgb, var(--line) 76%, var(--primary) 24%) !important;
    border-radius: var(--e4-composer-radius) !important;
    background:
      linear-gradient(
        145deg,
        color-mix(in srgb, var(--surface) 93%, var(--primary) 7%),
        color-mix(in srgb, var(--surface-2) 96%, transparent)
      ) !important;
    box-shadow:
      0 12px 30px rgba(0, 0, 0, .16),
      0 2px 8px color-mix(in srgb, var(--primary) 8%, transparent),
      inset 0 1px 0 color-mix(in srgb, white 7%, transparent) !important;
    backdrop-filter: blur(16px) saturate(1.08) !important;
    -webkit-backdrop-filter: blur(16px) saturate(1.08) !important;
    isolation: isolate !important;
    transform: none !important;
    transition:
      border-color 150ms ease,
      box-shadow 180ms ease,
      background-color 180ms ease !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .composer:focus-within {
    border-color: color-mix(in srgb, var(--primary) 42%, var(--line)) !important;
    box-shadow:
      0 14px 34px rgba(0, 0, 0, .18),
      0 0 0 3px color-mix(in srgb, var(--primary) 10%, transparent),
      inset 0 1px 0 color-mix(in srgb, white 8%, transparent) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .composer .icon-btn {
    inline-size: var(--e4-composer-control) !important;
    block-size: var(--e4-composer-control) !important;
    min-inline-size: var(--e4-composer-control) !important;
    min-block-size: var(--e4-composer-control) !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 15px !important;
    background: transparent !important;
    color: color-mix(in srgb, var(--muted) 88%, var(--text) 12%) !important;
    display: grid !important;
    place-items: center !important;
    transition:
      background-color 120ms ease,
      color 120ms ease,
      transform 90ms ease !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .composer .icon-btn:active {
    transform: scale(.92) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) #attachButton,
  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) #emojiButton {
    background: color-mix(in srgb, var(--surface-2) 78%, transparent) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) #attachButton[aria-expanded="true"],
  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) #emojiButton[aria-expanded="true"],
  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) #emojiButton.active {
    color: var(--primary) !important;
    background: color-mix(in srgb, var(--primary-soft) 84%, var(--surface-2)) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .composer textarea {
    min-block-size: 46px !important;
    max-block-size: 116px !important;
    padding: 11px 14px !important;
    border: 1px solid color-mix(in srgb, var(--line) 72%, transparent) !important;
    border-radius: 18px !important;
    background: color-mix(in srgb, var(--surface-2) 90%, transparent) !important;
    color: var(--text) !important;
    box-shadow: inset 0 1px 0 color-mix(in srgb, white 3%, transparent) !important;
    line-height: 1.5 !important;
    resize: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .composer textarea::placeholder {
    color: color-mix(in srgb, var(--muted) 86%, transparent) !important;
    opacity: 1 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .composer textarea:focus {
    border-color: color-mix(in srgb, var(--primary) 30%, var(--line)) !important;
    background: color-mix(in srgb, var(--surface-2) 96%, var(--primary) 4%) !important;
    outline: 0 !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) #voiceButton,
  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) #sendButton {
    inline-size: 48px !important;
    block-size: 48px !important;
    min-inline-size: 48px !important;
    min-block-size: 48px !important;
    border-radius: 50% !important;
    border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent) !important;
    color: #fff !important;
    background:
      linear-gradient(
        145deg,
        color-mix(in srgb, var(--primary) 88%, white 12%),
        color-mix(in srgb, var(--primary-2, var(--primary)) 86%, black 14%)
      ) !important;
    box-shadow:
      0 7px 17px color-mix(in srgb, var(--primary) 20%, transparent),
      inset 0 1px 0 rgba(255, 255, 255, .18) !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) #voiceButton svg,
  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) #sendButton svg {
    inline-size: 22px !important;
    block-size: 22px !important;
  }

  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .reply-banner,
  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .edit-banner {
    margin-inline: var(--e4-composer-edge) !important;
    margin-block-end: 2px !important;
    border-radius: 16px !important;
  }

  html[data-hamrah-mobile-polish="r2"][data-keyboard-open="true"] #chatScreen:not(.hidden) {
    --e4-composer-edge: 8px;
    --e4-composer-floor: 4px;
    --e4-composer-radius: 20px;
  }

  html[data-hamrah-mobile-polish="r2"][data-keyboard-open="true"] #chatScreen:not(.hidden) .composer {
    min-block-size: 56px !important;
    margin-block-start: 4px !important;
    margin-block-end: 4px !important;
    padding: 5px !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
  }

  html[data-hamrah-mobile-polish="r2"][data-keyboard-open="true"] #chatScreen:not(.hidden) .composer textarea {
    min-block-size: 44px !important;
    padding-block: 10px !important;
  }

  html[data-hamrah-mobile-polish="r2"][data-keyboard-open="true"] #chatScreen:not(.hidden) #voiceButton,
  html[data-hamrah-mobile-polish="r2"][data-keyboard-open="true"] #chatScreen:not(.hidden) #sendButton {
    inline-size: 44px !important;
    block-size: 44px !important;
    min-inline-size: 44px !important;
    min-block-size: 44px !important;
  }

  @media (max-width:370px) {
    html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) {
      --e4-composer-edge: 7px;
      --e4-composer-control: 40px;
    }

    html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .composer {
      gap: 2px !important;
      padding: 5px !important;
    }

    html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) #voiceButton,
    html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) #sendButton {
      inline-size: 44px !important;
      block-size: 44px !important;
      min-inline-size: 44px !important;
      min-block-size: 44px !important;
    }
  }
}

@media (max-width:767px) and (prefers-reduced-motion:reduce) {
  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .composer,
  html[data-hamrah-mobile-polish="r2"] #chatScreen:not(.hidden) .composer .icon-btn {
    transition: none !important;
  }
}



/* -------------------------------------------------------------------------
 * Android Profile Redesign R1 — 2026-08-14
 * ------------------------------------------------------------------------- */
html[data-hamrah-profile-platform="android"]
#profileView[data-android-profile-r1="ready"] > .profile-hero-v473,
html[data-hamrah-profile-platform="android"]
#profileView[data-android-profile-r1="ready"] > .profile-overview-card {
  display:none!important;
}
html[data-hamrah-profile-platform="android"]
#profileView[data-android-profile-r1="ready"] {
  padding:0 16px calc(100px + env(safe-area-inset-bottom))!important;
  background:transparent!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-shell {
  box-sizing:border-box;inline-size:min(100%,620px)!important;max-inline-size:620px!important;
  min-inline-size:0;margin:0 auto!important;padding:28px 0 18px;color:var(--mup-text,var(--text));
  direction:inherit;text-align:start;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-hero {
  display:flex;flex-direction:column;align-items:center;min-inline-size:0;padding:0 8px;text-align:center;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-avatar {
  position:relative;display:grid;place-items:center;inline-size:136px;block-size:136px;min-inline-size:136px;
  min-block-size:136px;padding:0;border:2px solid color-mix(in srgb,var(--profile-accent,var(--mup-accent,#8b5cf6)) 62%,rgba(255,255,255,.72));
  border-radius:50%;overflow:visible;isolation:isolate;color:#fff;
  background:linear-gradient(145deg,color-mix(in srgb,var(--profile-accent,var(--mup-accent,#7c4dff)) 88%,#2d65ff),color-mix(in srgb,var(--profile-accent,var(--mup-accent,#7c4dff)) 58%,#ef54bf));
  background-size:cover;background-position:center;
  box-shadow:0 0 0 6px color-mix(in srgb,var(--profile-accent,var(--mup-accent,#7c4dff)) 14%,transparent),0 16px 42px rgba(0,0,0,.28);
  touch-action:manipulation;-webkit-tap-highlight-color:transparent;contain:layout paint style;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-avatar::before {
  content:"";position:absolute;z-index:-1;inset:-24px;border-radius:50%;
  background:radial-gradient(circle,color-mix(in srgb,var(--profile-accent,var(--mup-accent,#7c4dff)) 20%,transparent),transparent 68%);
  pointer-events:none;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-avatar:active { transform:scale(.985); }
html[data-hamrah-profile-platform="android"] #profileView .aprr1-avatar-initial {
  font-size:2.5rem;font-weight:820;line-height:1;text-shadow:0 2px 12px rgba(0,0,0,.14);
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-avatar-presence {
  position:absolute;inset-inline-end:3px;inset-block-end:8px;inline-size:22px;block-size:22px;
  border:3px solid color-mix(in srgb,var(--mup-bg,#07111f) 88%,transparent);border-radius:50%;
  background:#16d69b;box-shadow:0 0 0 2px color-mix(in srgb,#16d69b 18%,transparent);
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-avatar-presence.is-offline {
  background:var(--mup-muted,#8792a8);box-shadow:none;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-name {
  max-inline-size:min(100%,430px);margin:22px 0 0;color:var(--mup-text,var(--text));
  font-size:clamp(1.65rem,7vw,2rem);font-weight:850;line-height:1.18;letter-spacing:-.035em;overflow-wrap:anywhere;
}
html[dir="rtl"][data-hamrah-profile-platform="android"] #profileView .aprr1-name { letter-spacing:0; }
html[data-hamrah-profile-platform="android"] #profileView .aprr1-username {
  max-inline-size:100%;margin:7px 0 0;color:var(--mup-muted,var(--muted));font-size:.9rem;font-weight:530;
  line-height:1.35;direction:ltr;unicode-bidi:plaintext;overflow-wrap:anywhere;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-presence {
  display:inline-flex;align-items:center;justify-content:center;gap:8px;max-inline-size:100%;margin:13px 0 0;
  color:color-mix(in srgb,var(--mup-muted,var(--muted)) 92%,#fff);font-size:.82rem;font-weight:520;line-height:1.4;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-presence>i {
  inline-size:8px;block-size:8px;flex:0 0 auto;border-radius:50%;background:#16d69b;
  box-shadow:0 0 0 4px color-mix(in srgb,#16d69b 10%,transparent);
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-presence.is-offline>i {
  background:var(--mup-muted,#8792a8);box-shadow:none;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-badges {
  display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:8px;max-inline-size:100%;margin:17px 0 0;direction:ltr;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-badge {
  display:inline-flex;align-items:center;justify-content:center;gap:8px;min-block-size:38px;max-inline-size:min(100%,210px);
  padding:7px 16px;border:1px solid color-mix(in srgb,var(--mup-border,var(--line)) 88%,transparent);border-radius:999px;
  color:var(--mup-text,var(--text));background:color-mix(in srgb,var(--mup-surface-2,var(--surface-2)) 72%,transparent);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.015);font-size:.77rem;font-weight:650;white-space:nowrap;
}
html[dir="rtl"][data-hamrah-profile-platform="android"] #profileView .aprr1-badge>span { direction:rtl; }
html[data-hamrah-profile-platform="android"] #profileView .aprr1-status-badge>i {
  inline-size:9px;block-size:9px;border-radius:50%;background:#16d69b;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-owner-badge svg {
  inline-size:18px;block-size:18px;color:#ffd45d;stroke-width:2;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-bio {
  max-inline-size:min(100%,470px);margin:25px 0 0;color:color-mix(in srgb,var(--mup-muted,var(--muted)) 94%,#fff);
  font-size:.86rem;font-weight:470;line-height:1.75;overflow-wrap:anywhere;white-space:pre-wrap;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-bio.is-placeholder { opacity:.72; }
html[data-hamrah-profile-platform="android"] #profileView .aprr1-actions {
  display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;inline-size:100%;margin:27px 0 0;direction:ltr;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-action {
  display:flex;min-inline-size:0;min-block-size:106px;padding:14px 7px 12px;
  border:1px solid color-mix(in srgb,var(--mup-border,var(--line)) 92%,transparent);border-radius:20px;
  align-items:center;justify-content:center;flex-direction:column;gap:10px;color:var(--mup-text,var(--text));
  background:color-mix(in srgb,var(--mup-surface-2,var(--surface-2)) 82%,transparent);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.015);touch-action:manipulation;-webkit-tap-highlight-color:transparent;
  transition:transform 120ms ease,border-color 120ms ease,background-color 120ms ease;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-action:active {
  transform:scale(.975);border-color:color-mix(in srgb,var(--profile-accent,var(--mup-accent,#8b5cf6)) 28%,var(--mup-border,var(--line)));
  background:color-mix(in srgb,var(--profile-accent,var(--mup-accent,#8b5cf6)) 7%,var(--mup-surface-2,var(--surface-2)));
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-action-icon {
  display:grid;place-items:center;inline-size:34px;block-size:34px;color:var(--profile-accent,var(--mup-accent,#9b66ff));
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-action-icon svg {
  inline-size:31px;block-size:31px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-action-label {
  display:block;max-inline-size:100%;color:var(--mup-text,var(--text));font-size:.75rem;font-weight:610;line-height:1.35;
  text-align:center;overflow-wrap:anywhere;
}
html[dir="rtl"][data-hamrah-profile-platform="android"] #profileView .aprr1-action-label { direction:rtl; }
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info {
  inline-size:100%;margin:17px 0 0;padding:7px 18px;
  border:1px solid color-mix(in srgb,var(--mup-border,var(--line)) 92%,transparent);border-radius:22px;overflow:hidden;
  background:color-mix(in srgb,var(--mup-surface-2,var(--surface-2)) 78%,transparent);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.014);
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-row {
  display:grid;grid-template-columns:48px minmax(0,1fr) 20px;align-items:center;gap:12px;min-inline-size:0;min-block-size:82px;padding:9px 0;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-row+.aprr1-info-row {
  border-block-start:1px solid color-mix(in srgb,var(--mup-border,var(--line)) 68%,transparent);
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-icon {
  display:grid;place-items:center;inline-size:44px;block-size:44px;
  border:1px solid color-mix(in srgb,var(--mup-border,var(--line)) 88%,transparent);border-radius:50%;
  color:var(--profile-accent,var(--mup-accent,#9b66ff));background:color-mix(in srgb,var(--mup-surface-3,var(--surface-2)) 78%,transparent);
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-icon svg { inline-size:22px;block-size:22px; }
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-copy { min-inline-size:0; }
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-copy b,
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-copy small {
  display:block;min-inline-size:0;overflow-wrap:anywhere;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-copy b {
  color:var(--mup-text,var(--text));font-size:.82rem;font-weight:660;line-height:1.32;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-copy small {
  margin-block-start:4px;color:var(--mup-muted,var(--muted));font-size:.74rem;font-weight:500;line-height:1.35;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-copy .aprr1-ltr { direction:ltr;unicode-bidi:plaintext; }
html[dir="rtl"][data-hamrah-profile-platform="android"] #profileView .aprr1-info-copy .aprr1-ltr { text-align:right; }
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-row>svg {
  inline-size:18px;block-size:18px;color:var(--mup-muted,var(--muted));opacity:.78;
}
html[dir="rtl"][data-hamrah-profile-platform="android"] #profileView .aprr1-info-row>svg { transform:scaleX(-1); }
html[data-hamrah-profile-platform="android"] .aprr1-qr-sheet {
  inline-size:min(calc(100vw - 24px),390px);padding:12px 18px calc(24px + env(safe-area-inset-bottom));border-radius:26px 26px 0 0;
}
html[data-hamrah-profile-platform="android"] .aprr1-qr-head {
  display:flex;align-items:flex-start;justify-content:space-between;gap:14px;margin-block-start:8px;
}
html[data-hamrah-profile-platform="android"] .aprr1-qr-head h2 { margin:0;font-size:1rem; }
html[data-hamrah-profile-platform="android"] .aprr1-qr-head p {
  margin:4px 0 0;color:var(--mup-muted,var(--muted));font-size:.68rem;line-height:1.55;
}
html[data-hamrah-profile-platform="android"] .aprr1-qr-canvas {
  display:grid;place-items:center;inline-size:240px;min-block-size:240px;margin:22px auto 0;padding:12px;border-radius:22px;
  overflow:hidden;color:#111827;background:#fff;
}
html[data-hamrah-profile-platform="android"] .aprr1-qr-canvas img,
html[data-hamrah-profile-platform="android"] .aprr1-qr-canvas canvas {
  display:block;max-inline-size:216px!important;block-size:auto!important;
}
html[data-hamrah-profile-platform="android"] .aprr1-qr-canvas.is-fallback {
  color:#101726;font-weight:700;text-align:center;overflow-wrap:anywhere;
}
html[data-hamrah-profile-platform="android"] .aprr1-qr-identity {
  margin:12px auto 0;color:var(--mup-muted,var(--muted));font-size:.78rem;text-align:center;
}
@media (max-width:380px) {
  html[data-hamrah-profile-platform="android"] #profileView[data-android-profile-r1="ready"] {
    padding-inline:12px!important;
  }
  html[data-hamrah-profile-platform="android"] #profileView .aprr1-shell { padding-block-start:22px; }
  html[data-hamrah-profile-platform="android"] #profileView .aprr1-avatar {
    inline-size:122px;block-size:122px;min-inline-size:122px;min-block-size:122px;
  }
  html[data-hamrah-profile-platform="android"] #profileView .aprr1-action { min-block-size:96px;padding-inline:5px; }
  html[data-hamrah-profile-platform="android"] #profileView .aprr1-action-label { font-size:.69rem; }
  html[data-hamrah-profile-platform="android"] #profileView .aprr1-info { padding-inline:14px; }
}
@media (prefers-reduced-motion:reduce) {
  html[data-hamrah-profile-platform="android"] #profileView .aprr1-avatar,
  html[data-hamrah-profile-platform="android"] #profileView .aprr1-action { transition:none!important; }
}

/* -------------------------------------------------------------------------
 * Android Profile + Settings Hotfix2 — 2026-08-14
 * Target: approved compact messenger profile + panel-owned editing.
 * ------------------------------------------------------------------------- */
html[data-hamrah-profile-platform="android"] #profileView > .profile-overview-card,
html[data-hamrah-profile-platform="android"] #profileView .profile-settings-block {
  display:none!important;
}

/* My Information is no longer an inline profile card. It is mounted into the
   editor panel by mobile-shell-polish.js. */
html[data-hamrah-profile-platform="android"] #profileView > #profileEditCard {
  display:none!important;
}

html[data-hamrah-profile-platform="android"] #profileView .aprr1-shell {
  inline-size:min(100%,600px)!important;
  max-inline-size:600px!important;
  padding:18px 0 14px!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-hero {
  padding-inline:6px!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-avatar {
  inline-size:140px!important;
  block-size:140px!important;
  min-inline-size:140px!important;
  min-block-size:140px!important;
  border-width:2px!important;
  box-shadow:
    0 0 0 5px color-mix(in srgb,var(--profile-accent,var(--mup-accent,#7c4dff)) 13%,transparent),
    0 14px 36px rgba(0,0,0,.24)!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-avatar::before {
  inset:-20px!important;
  background:radial-gradient(circle,color-mix(in srgb,var(--profile-accent,var(--mup-accent,#7c4dff)) 15%,transparent),transparent 70%)!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-name {
  margin-block-start:19px!important;
  font-size:clamp(1.55rem,7vw,1.9rem)!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-username {
  margin-block-start:5px!important;
  font-size:.86rem!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-presence {
  margin-block-start:11px!important;
  font-size:.79rem!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-badges {
  margin-block-start:15px!important;
  gap:7px!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-badge {
  min-block-size:36px!important;
  padding:6px 14px!important;
  font-size:.74rem!important;
  background:color-mix(in srgb,var(--mup-surface-2,var(--surface-2)) 64%,transparent)!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-bio {
  margin-block-start:23px!important;
  max-inline-size:min(100%,440px)!important;
  font-size:.83rem!important;
  line-height:1.72!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-actions {
  margin-block-start:23px!important;
  gap:8px!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-action {
  min-block-size:96px!important;
  padding:12px 6px 11px!important;
  border-radius:18px!important;
  background:color-mix(in srgb,var(--mup-surface-2,var(--surface-2)) 76%,transparent)!important;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.012)!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-action-icon {
  inline-size:32px!important;
  block-size:32px!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-action-icon svg {
  inline-size:29px!important;
  block-size:29px!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info {
  margin-block-start:16px!important;
  padding:6px 18px!important;
  border-radius:21px!important;
  background:color-mix(in srgb,var(--mup-surface-2,var(--surface-2)) 74%,transparent)!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-row {
  appearance:none;
  -webkit-appearance:none;
  inline-size:100%;
  display:grid!important;
  grid-template-columns:minmax(0,1fr) 20px!important;
  align-items:center!important;
  gap:12px!important;
  min-block-size:77px!important;
  margin:0!important;
  padding:10px 0!important;
  border:0;
  border-radius:0;
  color:inherit;
  background:transparent;
  font:inherit;
  text-align:start;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-row+.aprr1-info-row {
  border-block-start:1px solid color-mix(in srgb,var(--mup-border,var(--line)) 64%,transparent)!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-button {
  cursor:pointer;
  touch-action:manipulation;
  -webkit-tap-highlight-color:transparent;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-button:active {
  opacity:.78;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-copy {
  min-inline-size:0;
  text-align:start;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-copy b {
  color:var(--mup-text,var(--text))!important;
  font-size:.82rem!important;
  font-weight:650!important;
  line-height:1.32!important;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-copy small {
  margin-block-start:5px!important;
  color:var(--mup-muted,var(--muted))!important;
  font-size:.72rem!important;
  font-weight:480!important;
  line-height:1.35!important;
}
html[dir="rtl"][data-hamrah-profile-platform="android"] #profileView .aprr1-info-copy {
  text-align:right;
}
html[dir="ltr"][data-hamrah-profile-platform="android"] #profileView .aprr1-info-copy {
  text-align:left;
}
html[dir="rtl"][data-hamrah-profile-platform="android"] #profileView .aprr1-info-copy .aprr1-ltr {
  direction:ltr;
  unicode-bidi:isolate;
  text-align:right;
}
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-row > svg {
  inline-size:17px!important;
  block-size:17px!important;
  color:var(--mup-muted,var(--muted))!important;
  opacity:.72!important;
}

/* Real profile editor, moved into a modal bottom panel without duplicating its
   fields or save/avatar handlers. */
html[data-hamrah-profile-platform="android"] .aprr2-editor-layer {
  z-index:calc(var(--g10-z-dialog,900) + 36);
  align-items:flex-end;
  justify-content:center;
  padding:0;
  background:rgba(1,7,16,.64);
  backdrop-filter:blur(9px);
  -webkit-backdrop-filter:blur(9px);
}
html[data-hamrah-profile-platform="android"] .aprr2-editor-sheet {
  box-sizing:border-box;
  inline-size:min(100%,600px);
  max-inline-size:600px;
  max-block-size:min(90dvh,820px);
  padding:9px 14px calc(18px + env(safe-area-inset-bottom));
  overflow-y:auto;
  overscroll-behavior:contain;
  border:1px solid color-mix(in srgb,var(--mup-border,var(--line)) 88%,transparent);
  border-block-end:0;
  border-radius:27px 27px 0 0;
  background:color-mix(in srgb,var(--mup-bg,var(--background,#07111f)) 96%,var(--mup-surface-2,var(--surface-2)));
  box-shadow:0 -22px 60px rgba(0,0,0,.32);
}
html[data-hamrah-profile-platform="android"] .aprr2-editor-head {
  position:sticky;
  z-index:3;
  inset-block-start:-9px;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin:0 -2px 10px;
  padding:10px 4px 12px;
  background:linear-gradient(to bottom,
    color-mix(in srgb,var(--mup-bg,var(--background,#07111f)) 98%,transparent) 78%,
    transparent);
}
html[data-hamrah-profile-platform="android"] .aprr2-editor-head h2 {
  margin:0;
  color:var(--mup-text,var(--text));
  font-size:1rem;
  font-weight:820;
}
html[data-hamrah-profile-platform="android"] .aprr2-editor-head p {
  margin:4px 0 0;
  color:var(--mup-muted,var(--muted));
  font-size:.68rem;
  line-height:1.5;
}
html[data-hamrah-profile-platform="android"] .aprr2-editor-close {
  flex:0 0 auto;
}
html[data-hamrah-profile-platform="android"] .aprr2-editor-mount {
  min-inline-size:0;
}
html[data-hamrah-profile-platform="android"] .aprr2-editor-mount > #profileEditCard {
  display:block!important;
  box-sizing:border-box!important;
  inline-size:100%!important;
  max-inline-size:none!important;
  margin:0!important;
  padding:8px 2px 2px!important;
  border:0!important;
  border-radius:0!important;
  background:transparent!important;
  box-shadow:none!important;
  animation:none!important;
  transform:none!important;
}
html[data-hamrah-profile-platform="android"] .aprr2-editor-mount > #profileEditCard > .card-heading {
  display:none!important;
}
html[data-hamrah-profile-platform="android"] .aprr2-editor-mount #profileEditCard label,
html[data-hamrah-profile-platform="android"] .aprr2-editor-mount #profileEditCard .field-label {
  min-inline-size:0;
  overflow-wrap:anywhere;
}
html[data-hamrah-profile-platform="android"] .aprr2-editor-mount #profileEditCard :is(input,textarea) {
  max-inline-size:100%;
}
html[data-hamrah-profile-platform="android"] .aprr2-editor-mount #profileEditCard .profile-photo-editor {
  margin-block-start:2px;
}
html[data-hamrah-profile-platform="android"] .aprr2-editor-mount #profileEditCard .two-fields {
  grid-template-columns:1fr;
}
html[data-hamrah-profile-platform="android"] .aprr2-editor-mount #profileEditCard :is(#saveProfile,#cancelProfileEditButton) {
  min-block-size:48px;
}

@media (max-width:380px) {
  html[data-hamrah-profile-platform="android"] #profileView .aprr1-shell {
    padding-block-start:14px!important;
  }
  html[data-hamrah-profile-platform="android"] #profileView .aprr1-avatar {
    inline-size:126px!important;
    block-size:126px!important;
    min-inline-size:126px!important;
    min-block-size:126px!important;
  }
  html[data-hamrah-profile-platform="android"] #profileView .aprr1-action {
    min-block-size:90px!important;
  }
  html[data-hamrah-profile-platform="android"] #profileView .aprr1-info {
    padding-inline:14px!important;
  }
  html[data-hamrah-profile-platform="android"] .aprr2-editor-sheet {
    padding-inline:12px;
  }
}
@media (prefers-reduced-motion:reduce) {
  html[data-hamrah-profile-platform="android"] .aprr2-editor-layer,
  html[data-hamrah-profile-platform="android"] .aprr2-editor-sheet {
    animation:none!important;
    transition:none!important;
  }
}
/* -------------------------------------------------------------------------
 * Hotfix3 — Android Home Header language geometry + Saved Messages overflow
 *
 * Persian keeps the approved physical header ordering. English swaps the
 * account avatar with the (+ / Space) action side. The new overflow control
 * is intentionally tiny and owns one destination only: Saved Messages.
 * ------------------------------------------------------------------------- */
@media (max-width: 767px) {
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar #mupHomeMore {
    position: absolute !important;
    inset: auto !important;
    top: 8px !important;
    inline-size: 36px !important;
    block-size: 36px !important;
    min-inline-size: 36px !important;
    min-block-size: 36px !important;
    max-inline-size: 36px !important;
    max-block-size: 36px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: grid !important;
    place-items: center !important;
    border: 0 !important;
    border-radius: 12px !important;
    background: transparent !important;
    color: var(--mup-muted) !important;
    box-shadow: none !important;
    transform: none !important;
    z-index: 6 !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar #mupHomeMore.hidden {
    display: none !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar #mupHomeMore svg {
    inline-size: 22px !important;
    block-size: 22px !important;
    transform: rotate(90deg);
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar #mupHomeMore:active,
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar #mupHomeMore[aria-expanded="true"] {
    background: var(--mup-accent-soft) !important;
    color: var(--mup-accent) !important;
  }

  /* Persian: preserve the approved (+ / Space) left side and avatar right. */
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]:not([lang="en"])
  #app[data-mobile-view="chats"] > .topbar #mupHomeMore {
    left: auto !important;
    right: 70px !important;
  }

  /* English: avatar moves left; + and Space move to the physical right. */
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"]
  #app[data-mobile-view="chats"] > .topbar .mini-brand {
    grid-column: 1 !important;
    justify-self: start !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"]
  #app[data-mobile-view="chats"] > .topbar #topAction {
    grid-column: 3 !important;
    justify-self: end !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"]
  #app[data-mobile-view="chats"] > .topbar .g124-space-button {
    inset: auto !important;
    inset-inline: auto !important;
    inset-block: auto !important;
    left: auto !important;
    right: 66px !important;
    top: 6px !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"]
  #app[data-mobile-view="chats"] > .topbar #mupHomeMore {
    left: auto !important;
    right: 112px !important;
  }
}

html[data-hamrah-profile-platform="android"] .mup-home-more-menu {
  position: fixed;
  z-index: 220;
  inline-size: min(188px, calc(100vw - 24px));
  min-block-size: 52px;
  padding: 6px;
  border: 1px solid var(--mup-border, rgba(255,255,255,.08));
  border-radius: 15px;
  background: color-mix(in srgb, var(--mup-surface-2, #111a26) 96%, transparent);
  box-shadow: 0 14px 36px rgba(0,0,0,.34);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px) scale(.965);
  transition:
    opacity 140ms ease,
    transform 180ms cubic-bezier(.2,.78,.2,1),
    visibility 0s linear 180ms;
}

html[data-hamrah-profile-platform="android"] .mup-home-more-menu.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition-delay: 0s;
}

html[data-hamrah-profile-platform="android"] .mup-home-more-menu > button {
  inline-size: 100%;
  min-block-size: 40px;
  margin: 0;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--mup-text, #f4f7fb);
  font: inherit;
  font-size: .88rem;
  font-weight: 650;
  text-align: start;
  cursor: pointer;
  transition: background-color 120ms ease, transform 120ms ease;
}

html[data-hamrah-profile-platform="android"] .mup-home-more-menu > button svg {
  inline-size: 20px;
  block-size: 20px;
  flex: 0 0 20px;
  color: var(--mup-accent, var(--primary));
}

html[data-hamrah-profile-platform="android"] .mup-home-more-menu > button:active {
  background: var(--mup-accent-soft, rgba(139,92,246,.12));
  transform: scale(.985);
}

html[data-hamrah-profile-platform="android"][dir="rtl"] .mup-home-more-menu > button {
  direction: rtl;
}

@media (prefers-reduced-motion: reduce) {
  html[data-hamrah-profile-platform="android"] .mup-home-more-menu,
  html[data-hamrah-profile-platform="android"] .mup-home-more-menu > button {
    transition: none !important;
  }
}

/* ==========================================================================
 * Telegram-style Message UX R1
 * Compact anchored message actions, selection-state motion, permanent-delete
 * collapse, and outermost Saved Messages overflow geometry.
 * ========================================================================== */

@keyframes hamrahMessagePermanentRemoveR1 {
  0% {
    opacity: 1;
    max-block-size: var(--hamrah-remove-height, 180px);
    transform: translateY(0) scale(1);
  }
  55% {
    opacity: .18;
    transform: translateY(-2px) scale(.972);
  }
  100% {
    opacity: 0;
    max-block-size: 0;
    margin-block: 0;
    padding-block: 0;
    transform: translateY(-5px) scale(.94);
  }
}

.message.message-removing {
  overflow: hidden !important;
  transform-origin: center !important;
  animation: hamrahMessagePermanentRemoveR1 240ms cubic-bezier(.22,.78,.22,1) both !important;
  pointer-events: none !important;
}

/* Saved Messages overflow is the OUTERMOST control in the action cluster.
   Persian keeps actions on the physical left; English keeps them on the
   physical right. Avatar remains on the opposite side. */
@media (max-width: 767px) {
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]:not([lang="en"])
  #app[data-mobile-view="chats"] > .topbar #mupHomeMore {
    left: 6px !important;
    right: auto !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]:not([lang="en"])
  #app[data-mobile-view="chats"] > .topbar #topAction {
    position: absolute !important;
    grid-column: auto !important;
    inset: auto !important;
    left: 46px !important;
    right: auto !important;
    top: calc(7px + env(safe-area-inset-top)) !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]:not([lang="en"])
  #app[data-mobile-view="chats"] > .topbar .g124-space-button {
    inset: auto !important;
    left: 94px !important;
    right: auto !important;
    top: calc(6px + env(safe-area-inset-top)) !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"]
  #app[data-mobile-view="chats"] > .topbar #mupHomeMore {
    left: auto !important;
    right: 6px !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"]
  #app[data-mobile-view="chats"] > .topbar #topAction {
    position: absolute !important;
    grid-column: auto !important;
    inset: auto !important;
    right: 46px !important;
    left: auto !important;
    top: calc(7px + env(safe-area-inset-top)) !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"]
  #app[data-mobile-view="chats"] > .topbar .g124-space-button {
    inset: auto !important;
    right: 94px !important;
    left: auto !important;
    top: calc(6px + env(safe-area-inset-top)) !important;
  }
}

/* Compact message context menu. The existing functional action buttons are
   reused; only their presentation and geometry change. */
@media (max-width: 767px) {
  #messageActionSheet[data-mup-message-context="telegram-r1"].sheet-backdrop {
    align-items: stretch !important;
    justify-content: stretch !important;
    padding: 0 !important;
    background: rgba(3,8,16,.16) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] > .action-sheet {
    position: fixed !important;
    inset: auto !important;
    inline-size: min(276px, calc(100vw - 20px)) !important;
    max-inline-size: min(276px, calc(100vw - 20px)) !important;
    min-inline-size: 220px !important;
    block-size: auto !important;
    max-block-size: min(520px, calc(100dvh - 28px)) !important;
    margin: 0 !important;
    padding: 6px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-width: none;
    border: 1px solid color-mix(in srgb, var(--mup-border, var(--line)) 86%, transparent) !important;
    border-radius: 17px !important;
    background: color-mix(in srgb, var(--mup-surface-2, var(--surface)) 96%, transparent) !important;
    box-shadow:
      0 18px 48px rgba(0,0,0,.38),
      0 2px 10px rgba(0,0,0,.18) !important;
    backdrop-filter: blur(18px) saturate(1.08) !important;
    -webkit-backdrop-filter: blur(18px) saturate(1.08) !important;
    transform-origin: var(--mup-context-origin-x, 50%) var(--mup-context-origin-y, 50%) !important;
    animation: mupTelegramMessageContextIn 190ms cubic-bezier(.2,.82,.22,1) both !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] > .action-sheet::-webkit-scrollbar {
    display: none;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] .sheet-handle,
  #messageActionSheet[data-mup-message-context="telegram-r1"] .sheet-title {
    display: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] #v4ReactionPicker {
    order: 1 !important;
    position: sticky !important;
    inset-block-start: 0 !important;
    z-index: 2 !important;
    min-block-size: 46px !important;
    margin: 0 0 4px !important;
    padding: 4px 3px 7px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-around !important;
    gap: 2px !important;
    border-block-end: 1px solid color-mix(in srgb, var(--line) 78%, transparent) !important;
    background: inherit !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] #v4ReactionPicker button {
    inline-size: 34px !important;
    block-size: 34px !important;
    min-inline-size: 34px !important;
    min-block-size: 34px !important;
    padding: 0 !important;
    display: grid !important;
    place-items: center !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    font-size: 1.18rem !important;
    transition: transform 140ms cubic-bezier(.2,.8,.2,1), background-color 120ms ease !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] #v4ReactionPicker button:active {
    transform: scale(.82) !important;
    background: var(--mup-accent-soft, var(--primary-soft)) !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] .action-row {
    order: 30;
    inline-size: 100% !important;
    min-block-size: 39px !important;
    margin: 0 !important;
    padding: 5px 7px !important;
    display: flex !important;
    align-items: center !important;
    gap: 9px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: transparent !important;
    box-shadow: none !important;
    text-align: start !important;
    transition: background-color 110ms ease, transform 110ms ease !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] .action-row.hidden {
    display: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] .action-row:hover,
  #messageActionSheet[data-mup-message-context="telegram-r1"] .action-row:active {
    background: color-mix(in srgb, var(--primary) 9%, transparent) !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] .action-row:active {
    transform: scale(.985) !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] .action-row .round-icon {
    inline-size: 28px !important;
    block-size: 28px !important;
    min-inline-size: 28px !important;
    min-block-size: 28px !important;
    border-radius: 9px !important;
    box-shadow: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] .action-row .round-icon svg {
    inline-size: 17px !important;
    block-size: 17px !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] .action-row > span:nth-child(2) {
    min-inline-size: 0 !important;
    flex: 1 1 auto !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] .action-row b {
    display: block !important;
    font-size: .76rem !important;
    line-height: 1.25 !important;
    font-weight: 690 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] .action-row small,
  #messageActionSheet[data-mup-message-context="telegram-r1"] .action-row .chevron {
    display: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] .action-row.mup-group-start {
    margin-block-start: 4px !important;
    border-block-start: 1px solid color-mix(in srgb, var(--line) 74%, transparent) !important;
    border-start-start-radius: 0 !important;
    border-start-end-radius: 0 !important;
    padding-block-start: 8px !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] #replyMessageAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #copyMessageAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #editMessageAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #group7ReactionAction {
    order: 10;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] #bookmarkMessageAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #savedQuickTagMessageAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #savedTagsMessageAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #savedNoteMessageAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #savedFavoriteMessageAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #savedSourceMessageAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #pcForwardMessageAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #group7ForwardAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #pcSelectMessageAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #group7SelectAction {
    order: 20;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] #pinMessageAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #pcMessageInfoAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #group7MessageInfoAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #pcCopyLinkAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #pcDownloadMessageAction {
    order: 30;
  }

  #messageActionSheet[data-mup-message-context="telegram-r1"] #pcReportMessageAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #deleteForMeAction,
  #messageActionSheet[data-mup-message-context="telegram-r1"] #deleteForEveryoneAction {
    order: 40;
  }

  /* Telegram-like multi-select: the normal chat header softly yields to a
     compact selection app-bar, while every message remains directly tappable. */
  body.pc-selection-mode #chatScreen .chat-header {
    opacity: 0 !important;
    transform: translateY(-8px) scale(.985) !important;
    pointer-events: none !important;
    transition: opacity 150ms ease, transform 190ms cubic-bezier(.2,.8,.2,1) !important;
  }

  #chatScreen #pcSelectionToolbar.pc-selection-toolbar {
    position: fixed !important;
    inset-inline: 7px !important;
    inset-block-start: calc(6px + env(safe-area-inset-top)) !important;
    z-index: 96 !important;
    min-block-size: 50px !important;
    margin: 0 !important;
    padding: 5px 6px !important;
    grid-template-columns: 38px minmax(56px, 1fr) repeat(5, 36px) !important;
    gap: 4px !important;
    border: 1px solid color-mix(in srgb, var(--pc-line) 88%, transparent) !important;
    border-radius: 16px !important;
    background: color-mix(in srgb, var(--pc-surface) 96%, transparent) !important;
    box-shadow: 0 11px 30px rgba(0,0,0,.24) !important;
    backdrop-filter: blur(16px) saturate(1.06) !important;
    -webkit-backdrop-filter: blur(16px) saturate(1.06) !important;
    animation: mupTelegramSelectionBarIn 190ms cubic-bezier(.2,.82,.22,1) both !important;
  }

  #chatScreen #pcSelectionToolbar.pc-selection-toolbar > b {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    font-size: .75rem !important;
    white-space: nowrap !important;
  }

  #chatScreen #pcSelectionToolbar .pc-selection-count {
    min-inline-size: 27px !important;
    block-size: 27px !important;
    padding-inline: 6px !important;
    border-radius: 9px !important;
    font-size: .7rem !important;
  }

  #chatScreen #pcSelectionToolbar button {
    inline-size: 36px !important;
    block-size: 36px !important;
    border-radius: 11px !important;
    background: transparent !important;
    transition: background-color 120ms ease, transform 120ms cubic-bezier(.2,.8,.2,1) !important;
  }

  #chatScreen #pcSelectionToolbar button:active {
    background: var(--pc-soft) !important;
    transform: scale(.88) !important;
  }

  body.pc-selection-mode #messageList .message {
    transition:
      padding-inline-start 180ms cubic-bezier(.2,.8,.2,1),
      padding-inline-end 180ms cubic-bezier(.2,.8,.2,1),
      opacity 140ms ease !important;
  }

  body.pc-selection-mode #messageList .message .message-select-indicator {
    opacity: 1 !important;
    transform: scale(1) !important;
  }

  body.pc-selection-mode #messageList .message.is-selected .bubble {
    box-shadow:
      0 0 0 2px color-mix(in srgb, var(--primary) 38%, transparent),
      var(--shadow-sm) !important;
    transform: scale(.985) !important;
  }
}

@keyframes mupTelegramMessageContextIn {
  from { opacity: 0; transform: scale(.90) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes mupTelegramSelectionBarIn {
  from { opacity: 0; transform: translateY(-10px) scale(.975); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .message.message-removing,
  #messageActionSheet[data-mup-message-context="telegram-r1"] > .action-sheet,
  #chatScreen #pcSelectionToolbar.pc-selection-toolbar {
    animation: none !important;
  }
}



/* -------------------------------------------------------------------------
   Telegram-style Message UX R2
   - normal tap => compact anchored action menu
   - long press => direct multi-select
   - top selection controls + bottom reply/forward dock
   ------------------------------------------------------------------------- */
@media (max-width: 767px) {
  #messageActionSheet[data-mup-message-context="telegram-r2"].sheet-backdrop {
    align-items: stretch !important;
    justify-content: stretch !important;
    padding: 0 !important;
    background: rgba(3,8,16,.10) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] > .action-sheet {
    position: fixed !important;
    inset: auto !important;
    inline-size: min(244px, calc(100vw - 20px)) !important;
    max-inline-size: min(244px, calc(100vw - 20px)) !important;
    min-inline-size: 208px !important;
    block-size: auto !important;
    max-block-size: min(420px, calc(100dvh - 28px)) !important;
    margin: 0 !important;
    padding: 5px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-width: none;
    border: 1px solid color-mix(in srgb, var(--mup-border, var(--line)) 84%, transparent) !important;
    border-radius: 16px !important;
    background: color-mix(in srgb, var(--mup-surface-2, var(--surface)) 97%, transparent) !important;
    box-shadow: 0 14px 38px rgba(0,0,0,.34), 0 2px 8px rgba(0,0,0,.16) !important;
    backdrop-filter: blur(18px) saturate(1.06) !important;
    -webkit-backdrop-filter: blur(18px) saturate(1.06) !important;
    transform-origin: var(--mup-context-origin-x, 50%) var(--mup-context-origin-y, 50%) !important;
    animation: mupTelegramMessageContextR2In 160ms cubic-bezier(.2,.82,.22,1) both !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] > .action-sheet::-webkit-scrollbar {
    display: none;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .sheet-handle,
  #messageActionSheet[data-mup-message-context="telegram-r2"] .sheet-title {
    display: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] #v4ReactionPicker {
    order: 1 !important;
    min-block-size: 42px !important;
    margin: 0 0 3px !important;
    padding: 3px 2px 5px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-around !important;
    gap: 1px !important;
    border-block-end: 1px solid color-mix(in srgb, var(--line) 68%, transparent) !important;
    background: transparent !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] #v4ReactionPicker button {
    inline-size: 32px !important;
    block-size: 32px !important;
    min-inline-size: 32px !important;
    min-block-size: 32px !important;
    padding: 0 !important;
    display: grid !important;
    place-items: center !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    font-size: 1.1rem !important;
    transition: transform 120ms cubic-bezier(.2,.8,.2,1), background-color 110ms ease !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] #v4ReactionPicker button:active {
    transform: scale(.82) !important;
    background: var(--mup-accent-soft, var(--primary-soft)) !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .mup-message-seen-summary {
    order: 3 !important;
    inline-size: 100%;
    min-block-size: 40px;
    margin: 0 0 3px;
    padding: 5px 7px;
    display: flex;
    align-items: center;
    gap: 7px;
    border: 0;
    border-block-end: 1px solid color-mix(in srgb, var(--line) 68%, transparent);
    border-radius: 9px 9px 0 0;
    background: transparent;
    color: var(--text);
    text-align: start;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .mup-message-seen-summary.hidden {
    display: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .mup-seen-copy {
    min-inline-size: 0;
    display: grid;
    gap: 1px;
    margin-inline-end: auto;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .mup-seen-copy small {
    color: var(--muted);
    font-size: .58rem;
    line-height: 1.1;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .mup-seen-copy b {
    color: var(--text);
    font-size: .68rem;
    line-height: 1.1;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .mup-seen-avatars {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    padding-inline-start: 7px;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .mup-seen-avatar {
    inline-size: 25px;
    block-size: 25px;
    display: grid;
    place-items: center;
    margin-inline-start: -7px;
    border: 2px solid var(--mup-surface-2, var(--surface));
    border-radius: 50%;
    color: #fff;
    font-size: .58rem;
    font-weight: 760;
    box-sizing: border-box;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .mup-seen-overflow {
    min-inline-size: 23px;
    color: var(--muted);
    font-weight: 800;
    letter-spacing: 1px;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .mup-seen-overflow.hidden {
    display: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .action-row {
    order: 20;
    inline-size: 100% !important;
    min-block-size: 36px !important;
    margin: 0 !important;
    padding: 4px 6px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    border: 0 !important;
    border-radius: 9px !important;
    background: transparent !important;
    box-shadow: none !important;
    text-align: start !important;
    transition: background-color 105ms ease, transform 105ms ease !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .action-row.hidden,
  #messageActionSheet[data-mup-message-context="telegram-r2"] .action-row.mup-r2-suppressed {
    display: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .action-row:hover,
  #messageActionSheet[data-mup-message-context="telegram-r2"] .action-row:active {
    background: color-mix(in srgb, var(--primary) 8%, transparent) !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .action-row:active {
    transform: scale(.982) !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .action-row .round-icon {
    inline-size: 25px !important;
    block-size: 25px !important;
    min-inline-size: 25px !important;
    min-block-size: 25px !important;
    border-radius: 8px !important;
    box-shadow: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .action-row .round-icon svg {
    inline-size: 15px !important;
    block-size: 15px !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .action-row > span:nth-child(2) {
    min-inline-size: 0 !important;
    flex: 1 1 auto !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .action-row b {
    display: block !important;
    font-size: .71rem !important;
    line-height: 1.2 !important;
    font-weight: 680 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .action-row small,
  #messageActionSheet[data-mup-message-context="telegram-r2"] .action-row .chevron {
    display: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] .action-row.mup-group-start {
    margin-block-start: 3px !important;
    padding-block-start: 7px !important;
    border-block-start: 1px solid color-mix(in srgb, var(--line) 67%, transparent) !important;
    border-start-start-radius: 0 !important;
    border-start-end-radius: 0 !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r2"] #deleteForMeAction,
  #messageActionSheet[data-mup-message-context="telegram-r2"] #deleteForEveryoneAction,
  #messageActionSheet[data-mup-message-context="telegram-r2"] #pcReportMessageAction {
    color: var(--danger) !important;
  }

  /* Long press now enters selection directly. The app-bar carries high-value
     icon actions while reply/forward stay reachable at the bottom. */
  body.pc-selection-mode #chatScreen .chat-header {
    opacity: 0 !important;
    transform: translateY(-8px) scale(.985) !important;
    pointer-events: none !important;
    transition: opacity 140ms ease, transform 180ms cubic-bezier(.2,.8,.2,1) !important;
  }

  #chatScreen #pcSelectionToolbar.pc-selection-toolbar-r2 {
    position: fixed !important;
    inset-inline: 7px !important;
    inset-block-start: calc(6px + env(safe-area-inset-top)) !important;
    z-index: 98 !important;
    min-block-size: 50px !important;
    margin: 0 !important;
    padding: 5px 6px !important;
    display: grid !important;
    grid-template-columns: 38px minmax(82px, 1fr) auto !important;
    align-items: center !important;
    gap: 5px !important;
    border: 1px solid color-mix(in srgb, var(--pc-line) 88%, transparent) !important;
    border-radius: 16px !important;
    background: color-mix(in srgb, var(--pc-surface) 96%, transparent) !important;
    box-shadow: 0 10px 28px rgba(0,0,0,.22) !important;
    backdrop-filter: blur(16px) saturate(1.05) !important;
    -webkit-backdrop-filter: blur(16px) saturate(1.05) !important;
    animation: mupTelegramSelectionBarR2In 180ms cubic-bezier(.2,.82,.22,1) both !important;
  }

  #chatScreen #pcSelectionToolbar.pc-selection-toolbar-r2.hidden {
    display: none !important;
  }

  #chatScreen #pcSelectionToolbar .pc-selection-label {
    min-inline-size: 0;
    color: var(--text);
    font-size: .76rem !important;
    font-weight: 740;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #chatScreen #pcSelectionToolbar .pc-selection-top-actions {
    display: flex;
    align-items: center;
    gap: 2px;
  }

  #chatScreen #pcSelectionToolbar button {
    inline-size: 36px !important;
    block-size: 36px !important;
    min-inline-size: 36px !important;
    padding: 0 !important;
    display: grid !important;
    place-items: center !important;
    border: 0 !important;
    border-radius: 11px !important;
    background: transparent !important;
    color: var(--text);
    transition: background-color 110ms ease, transform 110ms cubic-bezier(.2,.8,.2,1), opacity 110ms ease !important;
  }

  #chatScreen #pcSelectionToolbar button:active:not(:disabled) {
    background: var(--pc-soft) !important;
    transform: scale(.86) !important;
  }

  #chatScreen #pcSelectionToolbar button:disabled,
  #chatScreen #pcSelectionDock button:disabled {
    opacity: .34 !important;
  }

  #chatScreen #pcSelectionToolbar button.danger {
    color: var(--danger) !important;
  }

  #chatScreen #pcSelectionToolbar svg {
    inline-size: 19px !important;
    block-size: 19px !important;
  }

  #chatScreen #pcSelectionMoreMenu.pc-selection-more-menu {
    position: absolute !important;
    inset-block-start: calc(100% + 5px) !important;
    inset-inline-end: 5px !important;
    z-index: 3 !important;
    min-inline-size: 145px !important;
    padding: 4px !important;
    border: 1px solid color-mix(in srgb, var(--pc-line) 88%, transparent) !important;
    border-radius: 13px !important;
    background: color-mix(in srgb, var(--pc-surface) 98%, transparent) !important;
    box-shadow: 0 12px 28px rgba(0,0,0,.26) !important;
    animation: mupTelegramMiniMenuIn 130ms cubic-bezier(.2,.82,.22,1) both !important;
  }

  #chatScreen #pcSelectionMoreMenu.pc-selection-more-menu.hidden {
    display: none !important;
  }

  #chatScreen #pcSelectionMoreMenu button {
    inline-size: 100% !important;
    block-size: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    padding-inline: 8px !important;
    border-radius: 9px !important;
    font-size: .7rem !important;
  }

  #chatScreen #pcSelectionDock.pc-selection-dock {
    position: fixed !important;
    inset-inline-start: 50% !important;
    inset-block-end: calc(9px + env(safe-area-inset-bottom)) !important;
    z-index: 98 !important;
    inline-size: min(264px, calc(100vw - 28px)) !important;
    min-block-size: 48px !important;
    translate: -50% 0 !important;
    margin: 0 !important;
    padding: 5px !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 5px !important;
    border: 1px solid color-mix(in srgb, var(--pc-line) 88%, transparent) !important;
    border-radius: 16px !important;
    background: color-mix(in srgb, var(--pc-surface) 96%, transparent) !important;
    box-shadow: 0 12px 34px rgba(0,0,0,.25) !important;
    backdrop-filter: blur(16px) saturate(1.04) !important;
    -webkit-backdrop-filter: blur(16px) saturate(1.04) !important;
    animation: mupTelegramSelectionDockIn 180ms cubic-bezier(.2,.82,.22,1) both !important;
  }

  #chatScreen #pcSelectionDock.pc-selection-dock.hidden {
    display: none !important;
  }

  #chatScreen #pcSelectionDock button {
    min-block-size: 38px !important;
    padding-inline: 10px !important;
    border: 0 !important;
    border-radius: 11px !important;
    background: color-mix(in srgb, var(--primary) 8%, var(--pc-raised)) !important;
    color: var(--text) !important;
    font-size: .7rem !important;
    font-weight: 690 !important;
    transition: transform 110ms cubic-bezier(.2,.8,.2,1), background-color 110ms ease !important;
  }

  #chatScreen #pcSelectionDock button:active:not(:disabled) {
    transform: scale(.96) !important;
    background: color-mix(in srgb, var(--primary) 15%, var(--pc-raised)) !important;
  }

  body.pc-selection-mode #messageList .message {
    padding-inline-start: 38px !important;
    transition:
      padding-inline-start 170ms cubic-bezier(.2,.8,.2,1),
      padding-inline-end 170ms cubic-bezier(.2,.8,.2,1),
      opacity 130ms ease !important;
  }

  body.pc-selection-mode #messageList .message .message-select-indicator {
    opacity: 1 !important;
    transform: scale(1) !important;
  }

  body.pc-selection-mode #messageList .message.is-selected .bubble {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 38%, transparent), var(--shadow-sm) !important;
    transform: scale(.985) !important;
  }
}

@keyframes mupTelegramMessageContextR2In {
  from { opacity: 0; transform: scale(.92) translateY(3px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes mupTelegramSelectionBarR2In {
  from { opacity: 0; transform: translateY(-9px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes mupTelegramSelectionDockIn {
  from { opacity: 0; translate: -50% 8px; transform: scale(.98); }
  to { opacity: 1; translate: -50% 0; transform: scale(1); }
}

@keyframes mupTelegramMiniMenuIn {
  from { opacity: 0; transform: translateY(-3px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  #messageActionSheet[data-mup-message-context="telegram-r2"] > .action-sheet,
  #chatScreen #pcSelectionToolbar.pc-selection-toolbar-r2,
  #chatScreen #pcSelectionDock.pc-selection-dock,
  #chatScreen #pcSelectionMoreMenu.pc-selection-more-menu {
    animation: none !important;
  }
}


/* ==========================================================================
 * Telegram-style Message UX R3 — polish pass
 * - anchored side popover next to the selected message
 * - softer Telegram-like fade + translate + scale motion
 * - leaner action menu for normal tap
 * - tidier Android home header cluster spacing/alignment
 * ========================================================================== */
@media (max-width: 767px) {
  #messageActionSheet[data-mup-message-context="telegram-r3"].sheet-backdrop {
    align-items: stretch !important;
    justify-content: stretch !important;
    padding: 0 !important;
    background: rgba(4, 9, 16, .12) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] > .action-sheet {
    position: fixed !important;
    inset: auto !important;
    inline-size: min(210px, calc(100vw - 16px)) !important;
    max-inline-size: min(210px, calc(100vw - 16px)) !important;
    min-inline-size: 176px !important;
    block-size: auto !important;
    max-block-size: min(300px, calc(100dvh - 18px)) !important;
    margin: 0 !important;
    padding: 6px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 3px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-width: none;
    border: 1px solid color-mix(in srgb, var(--mup-border, var(--line)) 88%, transparent) !important;
    border-radius: 16px !important;
    background: color-mix(in srgb, var(--mup-surface-2, var(--surface)) 97%, transparent) !important;
    box-shadow: 0 14px 34px rgba(0,0,0,.22), 0 2px 8px rgba(0,0,0,.11) !important;
    backdrop-filter: blur(13px) saturate(1.02) !important;
    -webkit-backdrop-filter: blur(13px) saturate(1.02) !important;
    transform-origin: var(--mup-context-origin-x, 50%) var(--mup-context-origin-y, 50%) !important;
    animation: mupTelegramMessageContextR5In 190ms cubic-bezier(.2,.82,.22,1) both !important;
    will-change: transform, opacity;
    contain: layout style paint;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] > .action-sheet::-webkit-scrollbar {
    display: none;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .sheet-handle,
  #messageActionSheet[data-mup-message-context="telegram-r3"] .sheet-title,
  #messageActionSheet[data-mup-message-context="telegram-r3"] #v4ReactionPicker {
    display: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .mup-message-meta-summary {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 2px 2px 4px !important;
    order: 0 !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .mup-message-meta-summary.hidden {
    display: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .mup-meta-pill {
    min-block-size: 28px !important;
    padding: 0 9px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 999px !important;
    background: color-mix(in srgb, var(--pc-soft, rgba(255,255,255,.08)) 88%, transparent) !important;
    color: var(--text) !important;
    font-size: .68rem !important;
    font-weight: 690 !important;
    line-height: 1 !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .mup-meta-more {
    margin-inline-start: auto !important;
    border: 0 !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .mup-message-seen-summary {
    order: 1 !important;
    inline-size: 100% !important;
    min-block-size: 34px !important;
    margin: 0 0 2px !important;
    padding: 6px 9px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    border: 0 !important;
    border-radius: 12px !important;
    background: color-mix(in srgb, var(--primary) 9%, var(--mup-surface-2, var(--surface))) !important;
    color: var(--text) !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .mup-message-seen-summary.hidden {
    display: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .mup-seen-copy {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    min-inline-size: 0 !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .mup-seen-copy small {
    color: var(--muted) !important;
    font-size: .62rem !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .mup-seen-copy b {
    color: var(--text) !important;
    font-size: .72rem !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .mup-seen-avatars {
    display: inline-flex !important;
    align-items: center !important;
    margin-inline-start: auto !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .mup-seen-avatar {
    inline-size: 22px !important;
    block-size: 22px !important;
    margin-inline-start: -6px !important;
    border-radius: 50% !important;
    border: 2px solid color-mix(in srgb, var(--mup-surface-2, var(--surface)) 88%, transparent) !important;
    display: inline-grid !important;
    place-items: center !important;
    color: #fff !important;
    font-size: .6rem !important;
    font-weight: 750 !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .mup-seen-overflow {
    min-inline-size: 22px !important;
    block-size: 22px !important;
    padding: 0 6px !important;
    display: inline-grid !important;
    place-items: center !important;
    border-radius: 999px !important;
    background: color-mix(in srgb, var(--pc-soft, rgba(255,255,255,.08)) 90%, transparent) !important;
    color: var(--text) !important;
    font-size: .64rem !important;
    font-weight: 720 !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .mup-seen-overflow.hidden {
    display: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .action-row {
    order: 10;
    inline-size: 100% !important;
    min-block-size: 35px !important;
    margin: 0 !important;
    padding: 4px 8px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: transparent !important;
    box-shadow: none !important;
    text-align: start !important;
    transition: background-color 110ms ease, transform 120ms cubic-bezier(.2,.8,.2,1), opacity 100ms ease !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .action-row.hidden,
  #messageActionSheet[data-mup-message-context="telegram-r3"] .action-row.mup-r3-suppressed {
    display: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .action-row:hover,
  #messageActionSheet[data-mup-message-context="telegram-r3"] .action-row:active {
    background: color-mix(in srgb, var(--primary) 8%, transparent) !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .action-row:active {
    transform: scale(.984) !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .action-row .round-icon {
    inline-size: 24px !important;
    block-size: 24px !important;
    min-inline-size: 24px !important;
    min-block-size: 24px !important;
    border-radius: 8px !important;
    box-shadow: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .action-row .round-icon svg {
    inline-size: 14px !important;
    block-size: 14px !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .action-row > span:nth-child(2) {
    min-inline-size: 0 !important;
    flex: 1 1 auto !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .action-row b {
    display: block !important;
    font-size: .72rem !important;
    line-height: 1.2 !important;
    font-weight: 690 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .action-row small,
  #messageActionSheet[data-mup-message-context="telegram-r3"] .action-row .chevron {
    display: none !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] .action-row.mup-group-start {
    margin-block-start: 4px !important;
    padding-block-start: 8px !important;
    border-block-start: 1px solid color-mix(in srgb, var(--line) 70%, transparent) !important;
    border-start-start-radius: 0 !important;
    border-start-end-radius: 0 !important;
  }

  #messageActionSheet[data-mup-message-context="telegram-r3"] #deleteForMeAction,
  #messageActionSheet[data-mup-message-context="telegram-r3"] #deleteForEveryoneAction {
    color: var(--danger) !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"] #app[data-mobile-view="chats"] > .topbar {
    min-block-size: calc(58px + env(safe-area-inset-top)) !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"] #app[data-mobile-view="chats"] > .topbar #mupHomeMore,
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"] #app[data-mobile-view="chats"] > .topbar #topAction,
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"] #app[data-mobile-view="chats"] > .topbar .g124-space-button,
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"] #app[data-mobile-view="chats"] > .topbar .mini-brand {
    position: absolute !important;
    top: calc(7px + env(safe-area-inset-top)) !important;
    inline-size: 40px !important;
    block-size: 40px !important;
    min-inline-size: 40px !important;
    min-block-size: 40px !important;
    margin: 0 !important;
    display: grid !important;
    place-items: center !important;
    z-index: 6 !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"] #app[data-mobile-view="chats"] > .topbar .g124-space-button {
    padding: 4px !important;
    border-radius: 14px !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"] #app[data-mobile-view="chats"] > .topbar .g124-space-button-copy,
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"] #app[data-mobile-view="chats"] > .topbar .g124-space-button > svg {
    display: none !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"] #app[data-mobile-view="chats"] > .topbar .g124-space-button-icon {
    inline-size: 30px !important;
    block-size: 30px !important;
    flex-basis: 30px !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"] #app[data-mobile-view="chats"] > .topbar .mup-hidden-extra-header-action {
    display: none !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]:not([lang="en"]) #app[data-mobile-view="chats"] > .topbar #mupHomeMore {
    left: 8px !important;
    right: auto !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]:not([lang="en"]) #app[data-mobile-view="chats"] > .topbar #topAction {
    left: 56px !important;
    right: auto !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]:not([lang="en"]) #app[data-mobile-view="chats"] > .topbar .g124-space-button {
    left: 104px !important;
    right: auto !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]:not([lang="en"]) #app[data-mobile-view="chats"] > .topbar .mini-brand {
    right: 8px !important;
    left: auto !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"] #app[data-mobile-view="chats"] > .topbar .mini-brand {
    left: 8px !important;
    right: auto !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"] #app[data-mobile-view="chats"] > .topbar .g124-space-button {
    right: 104px !important;
    left: auto !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"] #app[data-mobile-view="chats"] > .topbar #topAction {
    right: 56px !important;
    left: auto !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"] #app[data-mobile-view="chats"] > .topbar #mupHomeMore {
    right: 8px !important;
    left: auto !important;
  }
}

@keyframes mupTelegramMessageContextR5In {
  from { opacity: 0; transform: translate3d(0, 8px, 0) scale(.94); }
  58% { opacity: 1; transform: translate3d(0, -1px, 0) scale(1.008); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  #messageActionSheet[data-mup-message-context="telegram-r3"] > .action-sheet {
    animation: none !important;
  }
}


/* ==========================================================================
 * Telegram-style Message UX R4 — physical QA repair
 * Strict touch long-press separation, native-selection suppression, centered
 * selection dock, and collision-free Chats header geometry.
 * ========================================================================== */
@media (max-width: 767px) {
  /* Touch messages behave like native messenger rows: long press selects the
     message, never browser text. Explicit Copy remains available in actions. */
  #messageList .message,
  #messageList .g7-message,
  #messageList .message .bubble,
  #messageList .g7-message .g7-bubble,
  body.pc-selection-mode #messageList,
  body.pc-selection-mode #messageList *:not(input):not(textarea) {
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
  }

  /* A long press owns selection exclusively. Even if a stale context surface
     was already visible, it cannot coexist with selection mode. */
  body.pc-selection-mode #messageActionSheet,
  body[data-hamrah-message-long-press="1"] #messageActionSheet {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  /* R2 used logical inline-start + a physical negative translate. In RTL this
     offset the dock to the left. R4 centers it in physical viewport space. */
  #chatScreen #pcSelectionDock.pc-selection-dock {
    inset: auto !important;
    left: 50% !important;
    right: auto !important;
    bottom: calc(10px + env(safe-area-inset-bottom)) !important;
    inline-size: min(292px, calc(100vw - 24px)) !important;
    width: min(292px, calc(100vw - 24px)) !important;
    min-block-size: 50px !important;
    translate: none !important;
    transform: translate3d(-50%, 0, 0) !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    padding: 5px !important;
    border-radius: 16px !important;
    animation: mupTelegramSelectionDockR4In 170ms cubic-bezier(.22,.82,.22,1) both !important;
    will-change: transform, opacity;
  }

  #chatScreen #pcSelectionDock.pc-selection-dock > button {
    inline-size: 100% !important;
    width: 100% !important;
    min-inline-size: 0 !important;
    min-block-size: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 7px !important;
    padding-inline: 10px !important;
    font-size: .72rem !important;
    white-space: nowrap !important;
  }

  #chatScreen #pcSelectionDock.pc-selection-dock > button svg {
    inline-size: 17px !important;
    block-size: 17px !important;
    flex: 0 0 17px !important;
  }

  /* Selection app-bar is one stable row. Count stays flexible; action icons
     are equal 36px cells instead of appearing at unrelated offsets. */
  #chatScreen #pcSelectionToolbar.pc-selection-toolbar-r2 {
    left: 7px !important;
    right: 7px !important;
    inset-inline: auto !important;
    top: calc(6px + env(safe-area-inset-top)) !important;
    grid-template-columns: minmax(118px, 1fr) auto 38px !important;
    grid-template-areas: "count actions close" !important;
    min-block-size: 52px !important;
    align-items: center !important;
    gap: 6px !important;
  }

  html[dir="ltr"] #chatScreen #pcSelectionToolbar.pc-selection-toolbar-r2 {
    grid-template-columns: 38px auto minmax(118px, 1fr) !important;
    grid-template-areas: "close actions count" !important;
  }

  #chatScreen #pcSelectionToolbar > [data-pc-selection-close] {
    grid-area: close !important;
    justify-self: end !important;
  }

  #chatScreen #pcSelectionToolbar .pc-selection-label {
    grid-area: count !important;
    justify-self: stretch !important;
    align-self: stretch !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    min-inline-size: 0 !important;
    min-block-size: 38px !important;
    padding-inline: 12px !important;
    border-radius: 13px !important;
    background: color-mix(in srgb, var(--primary) 10%, var(--pc-soft)) !important;
    color: var(--text) !important;
    font-size: .96rem !important;
    line-height: 1 !important;
    font-weight: 820 !important;
    letter-spacing: -.01em !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  html[dir="rtl"] #chatScreen #pcSelectionToolbar .pc-selection-label {
    justify-content: flex-end !important;
    text-align: right !important;
  }

  html[dir="ltr"] #chatScreen #pcSelectionToolbar .pc-selection-label {
    justify-content: flex-start !important;
    text-align: left !important;
  }

  #chatScreen #pcSelectionToolbar .pc-selection-top-actions {
    grid-area: actions !important;
    display: grid !important;
    grid-auto-flow: column !important;
    grid-auto-columns: 36px !important;
    align-items: center !important;
    gap: 3px !important;
  }

  #chatScreen #pcSelectionToolbar .pc-selection-top-actions > button,
  #chatScreen #pcSelectionToolbar > [data-pc-selection-close] {
    inline-size: 36px !important;
    block-size: 36px !important;
    min-inline-size: 36px !important;
    min-block-size: 36px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Chats header: three equal action cells + one equal avatar cell. The title
     gets a dedicated safe middle region, so Space can never overlap the name. */
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar {
    position: relative !important;
    display: block !important;
    direction: ltr !important;
    box-sizing: border-box !important;
    height: 58px !important;
    block-size: 58px !important;
    min-height: 58px !important;
    min-block-size: 58px !important;
    max-height: 58px !important;
    max-block-size: 58px !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar .topbar-copy {
    display: contents !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar #mupHomeMore,
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar #topAction,
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar .g124-space-button,
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar .mini-brand {
    position: absolute !important;
    inset: auto !important;
    top: 7px !important;
    inline-size: 40px !important;
    width: 40px !important;
    block-size: 40px !important;
    height: 40px !important;
    min-inline-size: 40px !important;
    min-block-size: 40px !important;
    max-inline-size: 40px !important;
    max-block-size: 40px !important;
    margin: 0 !important;
    padding: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    place-items: center !important;
    transform: none !important;
    z-index: 7 !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar #topAction {
    border-radius: 13px !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar #topAction svg,
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar #mupHomeMore svg {
    inline-size: 20px !important;
    width: 20px !important;
    block-size: 20px !important;
    height: 20px !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar .g124-space-button {
    padding: 4px !important;
    border-radius: 13px !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar .g124-space-button-icon {
    inline-size: 30px !important;
    width: 30px !important;
    block-size: 30px !important;
    height: 30px !important;
    flex: 0 0 30px !important;
    margin: 0 !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar .mini-brand img {
    inline-size: 40px !important;
    width: 40px !important;
    block-size: 40px !important;
    height: 40px !important;
    object-fit: cover !important;
  }

  /* Persian: actions occupy physical left, avatar physical right. */
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]:not([lang="en"])
  #app[data-mobile-view="chats"] > .topbar #mupHomeMore { left: 8px !important; right: auto !important; }
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]:not([lang="en"])
  #app[data-mobile-view="chats"] > .topbar #topAction { left: 56px !important; right: auto !important; }
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]:not([lang="en"])
  #app[data-mobile-view="chats"] > .topbar .g124-space-button { left: 104px !important; right: auto !important; }
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]:not([lang="en"])
  #app[data-mobile-view="chats"] > .topbar .mini-brand { right: 8px !important; left: auto !important; }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]:not([lang="en"])
  #app[data-mobile-view="chats"] > .topbar .topbar-copy > div:last-child {
    position: absolute !important;
    inset: auto !important;
    left: 156px !important;
    right: 56px !important;
    top: 7px !important;
    inline-size: auto !important;
    width: auto !important;
    block-size: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 7px !important;
    overflow: hidden !important;
    transform: none !important;
    pointer-events: none !important;
  }

  /* English mirrors the physical ownership without changing component order. */
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"]
  #app[data-mobile-view="chats"] > .topbar .mini-brand { left: 8px !important; right: auto !important; }
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"]
  #app[data-mobile-view="chats"] > .topbar .g124-space-button { right: 104px !important; left: auto !important; }
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"]
  #app[data-mobile-view="chats"] > .topbar #topAction { right: 56px !important; left: auto !important; }
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"]
  #app[data-mobile-view="chats"] > .topbar #mupHomeMore { right: 8px !important; left: auto !important; }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"]
  #app[data-mobile-view="chats"] > .topbar .topbar-copy > div:last-child {
    position: absolute !important;
    inset: auto !important;
    left: 56px !important;
    right: 156px !important;
    top: 7px !important;
    inline-size: auto !important;
    width: auto !important;
    block-size: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 7px !important;
    overflow: hidden !important;
    transform: none !important;
    pointer-events: none !important;
  }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar #viewTitle {
    min-inline-size: 0 !important;
    max-inline-size: calc(100% - 28px) !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: center !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.1 !important;
  }
}

@keyframes mupTelegramSelectionDockR4In {
  from { opacity: 0; transform: translate3d(-50%, 7px, 0) scale(.985); }
  to   { opacity: 1; transform: translate3d(-50%, 0, 0) scale(1); }
}

@media (max-width: 360px) {
  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]:not([lang="en"])
  #app[data-mobile-view="chats"] > .topbar .topbar-copy > div:last-child { left: 152px !important; right: 52px !important; }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"][lang="en"][dir="ltr"]
  #app[data-mobile-view="chats"] > .topbar .topbar-copy > div:last-child { left: 52px !important; right: 152px !important; }

  html[data-hamrah-profile-platform="android"][data-hamrah-mobile-polish="r2"]
  #app[data-mobile-view="chats"] > .topbar #viewTitle {
    font-size: 1.08rem !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  #chatScreen #pcSelectionDock.pc-selection-dock { animation: none !important; }
}

/* ==========================================================================
 * Telegram-style Message UX R5.4 — compact anchored tap menu
 * - dedicated portal, never the legacy bottom sheet
 * - JS inline left/top are authoritative (no !important inset shorthand)
 * - small Telegram-like action list with minimal metadata
 * ========================================================================== */
@media (max-width: 767px) {
  #mupTelegramTapContext.mup-tap-context {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147480200 !important;
    pointer-events: auto !important;
    contain: layout style paint;
  }

  #mupTelegramTapContext.mup-tap-context.hidden { display: none !important; }

  #mupTelegramTapContext .mup-tap-context-backdrop {
    position: absolute !important;
    inset: 0 !important;
    background: rgba(1, 7, 14, .12) !important;
    opacity: 1 !important;
    transition: opacity 120ms ease !important;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  #mupTelegramTapContext .mup-tap-context-panel {
    position: fixed !important;
    inline-size: min(188px, calc(100vw - 20px)) !important;
    min-inline-size: 164px !important;
    max-inline-size: min(188px, calc(100vw - 20px)) !important;
    max-block-size: min(310px, calc(100dvh - 20px)) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    scrollbar-width: none !important;
    padding: 4px !important;
    border: 1px solid color-mix(in srgb, var(--line) 78%, transparent) !important;
    border-radius: 14px !important;
    background: color-mix(in srgb, var(--surface-2) 98%, #0b111b 2%) !important;
    box-shadow: 0 13px 28px rgba(0,0,0,.26), 0 2px 7px rgba(0,0,0,.12) !important;
    transform-origin: var(--mup-tap-origin-x, 50%) var(--mup-tap-origin-y, 30%) !important;
    opacity: 1;
    transform: translate3d(0,0,0) scale(1);
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
  }

  #mupTelegramTapContext .mup-tap-context-panel::-webkit-scrollbar { display: none !important; }

  #mupTelegramTapContext.measuring .mup-tap-context-backdrop,
  #mupTelegramTapContext.measuring .mup-tap-context-panel {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  #mupTelegramTapContext.opening .mup-tap-context-panel { animation: mupTelegramTapContextR54In 172ms cubic-bezier(.20,.82,.22,1) both !important; }
  #mupTelegramTapContext.opening .mup-tap-context-backdrop { animation: mupTelegramTapBackdropR54In 120ms ease-out both !important; }
  #mupTelegramTapContext.closing .mup-tap-context-panel { animation: mupTelegramTapContextR54Out 118ms cubic-bezier(.4,0,.8,.2) both !important; pointer-events: none !important; }
  #mupTelegramTapContext.closing .mup-tap-context-backdrop { animation: mupTelegramTapBackdropR54Out 118ms ease-in both !important; pointer-events: none !important; }

  #mupTelegramTapContext .mup-tap-context-meta {
    min-block-size: 25px !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 2px 6px 4px !important;
  }

  #mupTelegramTapContext .mup-tap-meta-time,
  #mupTelegramTapContext .mup-tap-meta-edited {
    display: inline-flex !important;
    align-items: center !important;
    min-block-size: 20px !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    color: var(--muted) !important;
    font-size: .61rem !important;
    font-weight: 650 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }

  #mupTelegramTapContext .mup-tap-meta-more {
    margin-inline-start: auto !important;
    inline-size: 28px !important;
    min-inline-size: 28px !important;
    block-size: 24px !important;
    padding: 0 !important;
    display: grid !important;
    place-items: center !important;
    border: 0 !important;
    border-radius: 9px !important;
    background: transparent !important;
    color: var(--muted) !important;
    font-size: .72rem !important;
  }

  #mupTelegramTapContext .mup-tap-meta-edited.hidden,
  #mupTelegramTapContext .mup-tap-meta-more.hidden,
  #mupTelegramTapContext .mup-tap-seen { display: none !important; }

  #mupTelegramTapContext .mup-tap-context-actions { display: flex !important; flex-direction: column !important; gap: 0 !important; }

  #mupTelegramTapContext .mup-tap-action {
    inline-size: 100% !important;
    min-block-size: 35px !important;
    margin: 0 !important;
    padding: 4px 7px !important;
    display: grid !important;
    grid-template-columns: 23px minmax(0,1fr) !important;
    align-items: center !important;
    gap: 7px !important;
    border: 0 !important;
    border-radius: 9px !important;
    background: transparent !important;
    color: var(--text) !important;
    text-align: start !important;
    -webkit-tap-highlight-color: transparent !important;
    transition: background-color 90ms ease, transform 90ms ease !important;
  }
  #mupTelegramTapContext .mup-tap-action:active { background: color-mix(in srgb, var(--primary) 9%, transparent) !important; transform: scale(.985) !important; }
  #mupTelegramTapContext .mup-tap-action-icon { inline-size: 23px !important; block-size: 23px !important; display: grid !important; place-items: center !important; color: var(--muted) !important; }
  #mupTelegramTapContext .mup-tap-action-icon svg { inline-size: 16px !important; block-size: 16px !important; fill: none !important; stroke: currentColor !important; }
  #mupTelegramTapContext .mup-tap-action-label { min-inline-size: 0 !important; overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; font-size: .70rem !important; line-height: 1.15 !important; font-weight: 680 !important; }
  #mupTelegramTapContext .mup-tap-action.danger, #mupTelegramTapContext .mup-tap-action.danger .mup-tap-action-icon { color: var(--danger) !important; }
  #mupTelegramTapContext .mup-tap-action.group-start { margin-block-start: 3px !important; padding-block-start: 7px !important; border-block-start: 1px solid color-mix(in srgb, var(--line) 66%, transparent) !important; border-start-start-radius: 0 !important; border-start-end-radius: 0 !important; }

  #messageActionSheet[data-mup-message-context="telegram-r3"] { visibility: hidden !important; pointer-events: none !important; }

  #chatScreen #pcSelectionToolbar .pc-selection-label {
    justify-content: center !important;
    text-align: center !important;
    min-block-size: 40px !important;
    padding-inline: 14px !important;
    font-size: 1.02rem !important;
    font-weight: 820 !important;
  }
}

@keyframes mupTelegramTapContextR54In { from { opacity: 0; transform: translate3d(0,5px,0) scale(.955); } 64% { opacity: 1; transform: translate3d(0,-.5px,0) scale(1.004); } to { opacity: 1; transform: translate3d(0,0,0) scale(1); } }
@keyframes mupTelegramTapContextR54Out { from { opacity: 1; transform: translate3d(0,0,0) scale(1); } to { opacity: 0; transform: translate3d(0,3px,0) scale(.975); } }
@keyframes mupTelegramTapBackdropR54In { from { opacity: 0; } to { opacity: 1; } }
@keyframes mupTelegramTapBackdropR54Out { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #mupTelegramTapContext .mup-tap-context-panel, #mupTelegramTapContext .mup-tap-context-backdrop { animation: none !important; transition: none !important; } }


#chatScreen #pcDesktopSelectionBar.pc-desktop-selection-bar {
  display: none !important;
}

/* ==========================================================================
 * Windows Message UX R1 — Telegram-style desktop context + selection
 * ========================================================================== */
@media (min-width: 768px) and (hover: hover) {
  #mupTelegramTapContext.mup-tap-context {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147480200 !important;
    pointer-events: auto !important;
  }

  #mupTelegramTapContext.mup-tap-context.hidden { display: none !important; }

  #mupTelegramTapContext .mup-tap-context-backdrop {
    position: absolute !important;
    inset: 0 !important;
    background: transparent !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  #mupTelegramTapContext .mup-tap-context-panel {
    position: fixed !important;
    inset: auto;
    inline-size: min(236px, calc(100vw - 24px)) !important;
    min-inline-size: 204px !important;
    max-inline-size: min(236px, calc(100vw - 24px)) !important;
    max-block-size: min(520px, calc(100vh - 24px)) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    scrollbar-width: none !important;
    padding: 6px !important;
    border: 1px solid color-mix(in srgb, var(--line) 82%, transparent) !important;
    border-radius: 13px !important;
    background: color-mix(in srgb, var(--surface-2) 97%, #10151d 3%) !important;
    box-shadow: 0 18px 46px rgba(0,0,0,.34), 0 3px 10px rgba(0,0,0,.18) !important;
    transform-origin: var(--mup-tap-origin-x, 22px) var(--mup-tap-origin-y, 18px) !important;
    opacity: 1;
    transform: translate3d(0,0,0) scale(1);
    will-change: transform, opacity;
    backface-visibility: hidden;
  }

  #mupTelegramTapContext .mup-tap-context-panel::-webkit-scrollbar { display: none !important; }
  #mupTelegramTapContext .mup-tap-context-meta,
  #mupTelegramTapContext .mup-tap-seen { display: none !important; }

  #mupTelegramTapContext.measuring .mup-tap-context-panel,
  #mupTelegramTapContext.measuring .mup-desktop-reaction-strip {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  #mupTelegramTapContext.opening .mup-tap-context-panel {
    animation: mupTelegramDesktopContextIn 168ms cubic-bezier(.2,.82,.22,1) both !important;
  }

  #mupTelegramTapContext.closing .mup-tap-context-panel {
    animation: mupTelegramDesktopContextOut 118ms cubic-bezier(.4,0,.8,.2) both !important;
    pointer-events: none !important;
  }

  #mupTelegramTapContext .mup-tap-context-actions {
    display: flex !important;
    flex-direction: column !important;
    gap: 1px !important;
  }

  #mupTelegramTapContext .mup-tap-action {
    inline-size: 100% !important;
    min-block-size: 36px !important;
    margin: 0 !important;
    padding: 5px 8px !important;
    display: grid !important;
    grid-template-columns: 25px minmax(0,1fr) !important;
    align-items: center !important;
    gap: 8px !important;
    border: 0 !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: var(--text) !important;
    text-align: start !important;
    cursor: default !important;
    transition: background-color 90ms ease, transform 90ms ease !important;
  }

  #mupTelegramTapContext .mup-tap-action:hover {
    background: color-mix(in srgb, var(--text) 7%, transparent) !important;
  }

  #mupTelegramTapContext .mup-tap-action:active {
    background: color-mix(in srgb, var(--primary) 13%, transparent) !important;
    transform: scale(.985) !important;
  }

  #mupTelegramTapContext .mup-tap-action-icon {
    inline-size: 25px !important;
    block-size: 25px !important;
    display: grid !important;
    place-items: center !important;
    color: color-mix(in srgb, var(--text) 65%, var(--muted)) !important;
  }

  #mupTelegramTapContext .mup-tap-action-icon svg {
    inline-size: 17px !important;
    block-size: 17px !important;
    fill: none !important;
    stroke: currentColor !important;
  }

  #mupTelegramTapContext .mup-tap-action-label {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: .76rem !important;
    line-height: 1.2 !important;
    font-weight: 680 !important;
  }

  #mupTelegramTapContext .mup-tap-action.danger,
  #mupTelegramTapContext .mup-tap-action.danger .mup-tap-action-icon { color: var(--danger) !important; }

  #mupTelegramTapContext .mup-tap-action.group-start {
    margin-block-start: 4px !important;
    padding-block-start: 8px !important;
    border-block-start: 1px solid color-mix(in srgb, var(--line) 72%, transparent) !important;
    border-start-start-radius: 0 !important;
    border-start-end-radius: 0 !important;
  }

  #mupTelegramTapContext .mup-desktop-reaction-strip {
    position: fixed !important;
    inset: auto;
    z-index: 1 !important;
    display: flex !important;
    align-items: center !important;
    gap: 2px !important;
    min-block-size: 40px !important;
    padding: 4px 6px !important;
    border: 1px solid color-mix(in srgb, var(--line) 78%, transparent) !important;
    border-radius: 999px !important;
    background: color-mix(in srgb, var(--surface-2) 97%, #10151d 3%) !important;
    box-shadow: 0 12px 34px rgba(0,0,0,.28), 0 2px 8px rgba(0,0,0,.16) !important;
    transform-origin: var(--mup-reaction-origin-x, 24px) 100% !important;
    will-change: transform, opacity;
  }

  #mupTelegramTapContext .mup-desktop-reaction-strip.hidden { display: none !important; }

  #mupTelegramTapContext.opening .mup-desktop-reaction-strip:not(.hidden) {
    animation: mupTelegramDesktopReactionIn 184ms cubic-bezier(.2,.82,.22,1) both !important;
  }

  #mupTelegramTapContext.closing .mup-desktop-reaction-strip:not(.hidden) {
    animation: mupTelegramDesktopReactionOut 108ms ease-in both !important;
    pointer-events: none !important;
  }

  #mupTelegramTapContext .mup-desktop-reaction {
    inline-size: 30px !important;
    block-size: 30px !important;
    display: grid !important;
    place-items: center !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    font-size: 1.05rem !important;
    line-height: 1 !important;
    cursor: default !important;
    transition: background-color 90ms ease, transform 110ms cubic-bezier(.2,.82,.22,1) !important;
  }

  #mupTelegramTapContext .mup-desktop-reaction:hover {
    background: color-mix(in srgb, var(--text) 9%, transparent) !important;
    transform: translateY(-2px) scale(1.08) !important;
  }

  #mupTelegramTapContext .mup-desktop-reaction:active { transform: scale(.92) !important; }

  body.mup-tap-context-open #messageActionSheet {
    visibility: hidden !important;
    pointer-events: none !important;
  }

  #chatScreen #pcDesktopSelectionBar.pc-desktop-selection-bar {
    position: relative !important;
    z-index: calc(var(--g10-z-sticky, 80) + 5) !important;
    flex: 0 0 auto !important;
    inline-size: calc(100% - 18px) !important;
    min-block-size: 52px !important;
    margin: 6px 9px 8px !important;
    padding: 5px 9px !important;
    display: grid !important;
    grid-template-columns: minmax(112px,1fr) auto minmax(112px,1fr) !important;
    align-items: center !important;
    gap: 8px !important;
    border: 1px solid color-mix(in srgb, var(--line) 82%, transparent) !important;
    border-radius: 14px !important;
    background: color-mix(in srgb, var(--surface-2) 96%, transparent) !important;
    box-shadow: 0 12px 34px rgba(0,0,0,.22) !important;
    backdrop-filter: blur(16px) !important;
    animation: mupTelegramDesktopSelectionBarIn 185ms cubic-bezier(.2,.82,.22,1) both !important;
  }

  #chatScreen #pcDesktopSelectionBar.pc-desktop-selection-bar.hidden { display: none !important; }

  body.pc-selection-mode #chatScreen #pcSelectionToolbar,
  body.pc-selection-mode #chatScreen #pcSelectionDock { display: none !important; }

  #chatScreen #pcDesktopSelectionBar .pc-desktop-selection-left,
  #chatScreen #pcDesktopSelectionBar .pc-desktop-selection-actions {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
  }

  #chatScreen #pcDesktopSelectionBar .pc-desktop-selection-left { justify-self: start !important; }
  #chatScreen #pcDesktopSelectionBar .pc-desktop-selection-actions { justify-self: end !important; }

  #chatScreen #pcDesktopSelectionBar .pc-desktop-selection-label {
    justify-self: center !important;
    min-inline-size: 0 !important;
    max-inline-size: min(42vw, 360px) !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    color: var(--text) !important;
    font-size: .76rem !important;
    font-weight: 720 !important;
    text-align: center !important;
  }

  #chatScreen #pcDesktopSelectionBar button {
    inline-size: 38px !important;
    block-size: 38px !important;
    display: grid !important;
    place-items: center !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: transparent !important;
    color: color-mix(in srgb, var(--text) 72%, var(--muted)) !important;
    cursor: default !important;
    transition: background-color 90ms ease, color 90ms ease, transform 90ms ease !important;
  }

  #chatScreen #pcDesktopSelectionBar button:hover:not(:disabled) {
    background: color-mix(in srgb, var(--text) 8%, transparent) !important;
    color: var(--text) !important;
  }

  #chatScreen #pcDesktopSelectionBar button:active:not(:disabled) {
    background: color-mix(in srgb, var(--primary) 12%, transparent) !important;
    transform: scale(.94) !important;
  }

  #chatScreen #pcDesktopSelectionBar button:disabled { opacity: .34 !important; }
  #chatScreen #pcDesktopSelectionBar button.danger { color: var(--danger) !important; }

  #chatScreen #pcDesktopSelectionBar button svg {
    inline-size: 20px !important;
    block-size: 20px !important;
  }

  body.pc-selection-mode #messageList .message {
    padding-left: 36px !important;
    transition: padding-left 170ms cubic-bezier(.2,.82,.22,1) !important;
  }

  body.pc-selection-mode #messageList .message .message-select-indicator {
    left: 7px !important;
    right: auto !important;
    inset-inline-start: auto !important;
    opacity: 1 !important;
    transform: scale(1) !important;
    animation: mupTelegramDesktopSelectionCheckIn 170ms cubic-bezier(.2,.82,.22,1) both !important;
  }

  body.pc-selection-mode #messageList .message.is-selected .bubble {
    transform: none !important;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 26%, transparent), var(--shadow-sm) !important;
  }

  body.pc-selection-mode #messageList .message.is-selected .message-select-indicator {
    animation: mupTelegramDesktopSelectionCheckSelected 190ms cubic-bezier(.2,.82,.22,1) both !important;
  }
}

@keyframes mupTelegramDesktopContextIn {
  from { opacity: 0; transform: translate3d(0,-4px,0) scale(.94); }
  70% { opacity: 1; transform: translate3d(0,0,0) scale(1.008); }
  to { opacity: 1; transform: translate3d(0,0,0) scale(1); }
}

@keyframes mupTelegramDesktopContextOut {
  from { opacity: 1; transform: translate3d(0,0,0) scale(1); }
  to { opacity: 0; transform: translate3d(0,-2px,0) scale(.97); }
}

@keyframes mupTelegramDesktopReactionIn {
  from { opacity: 0; transform: translate3d(0,5px,0) scale(.92); }
  68% { opacity: 1; transform: translate3d(0,0,0) scale(1.012); }
  to { opacity: 1; transform: translate3d(0,0,0) scale(1); }
}

@keyframes mupTelegramDesktopReactionOut {
  from { opacity: 1; transform: translate3d(0,0,0) scale(1); }
  to { opacity: 0; transform: translate3d(0,3px,0) scale(.96); }
}

@keyframes mupTelegramDesktopSelectionBarIn {
  from { opacity: 0; transform: translate3d(0,12px,0) scale(.985); }
  to { opacity: 1; transform: translate3d(0,0,0) scale(1); }
}

@keyframes mupTelegramDesktopSelectionCheckIn {
  from { opacity: 0; transform: translate3d(-7px,0,0) scale(.68); }
  to { opacity: 1; transform: translate3d(0,0,0) scale(1); }
}

@keyframes mupTelegramDesktopSelectionCheckSelected {
  0% { transform: scale(.84); }
  62% { transform: scale(1.10); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  #mupTelegramTapContext .mup-tap-context-panel,
  #mupTelegramTapContext .mup-desktop-reaction-strip,
  #chatScreen #pcDesktopSelectionBar.pc-desktop-selection-bar,
  body.pc-selection-mode #messageList .message .message-select-indicator {
    animation: none !important;
    transition: none !important;
  }
}

/* -------------------------------------------------------------------------
 * R4 PROFILE ISOLATION HOTFIX1 — final cascade owner
 *
 * group118b-profile-hotfix.css is intentionally loaded before this file.
 * Keep the final width/overflow guarantees here so later mobile composition
 * rules cannot compress or push Profile outside the viewport.
 * ------------------------------------------------------------------------- */
#profileView.profile-view {
  box-sizing: border-box;
  inline-size: 100%;
  min-inline-size: 0;
  max-inline-size: 100%;
  overflow-x: clip;
  overscroll-behavior-x: none;
}

@supports not (overflow: clip) {
  #profileView.profile-view {
    overflow-x: hidden;
  }
}

#profileView.profile-view > *,
#profileView.profile-view :is(
  .profile-hero-v473,
  .profile-overview-card,
  #profileEditCard,
  .profile-form,
  .profile-photo-editor
) {
  box-sizing: border-box;
  min-inline-size: 0;
  max-inline-size: 100%;
}

html[data-hamrah-profile-platform="android"] #profileView.profile-view[data-android-profile-r1="ready"] {
  inline-size: 100% !important;
  min-inline-size: 0 !important;
  max-inline-size: 100% !important;
  overflow-x: clip !important;
  contain: inline-size;
}

@supports not (overflow: clip) {
  html[data-hamrah-profile-platform="android"] #profileView.profile-view[data-android-profile-r1="ready"] {
    overflow-x: hidden !important;
  }
}

html[data-hamrah-profile-platform="android"] #profileView[data-android-profile-r1="ready"] > .aprr1-shell {
  display: block;
  box-sizing: border-box;
  inline-size: min(100%, 600px) !important;
  min-inline-size: 0 !important;
  max-inline-size: 600px !important;
  margin-inline: auto !important;
  flex: none;
  overflow: visible;
}

html[data-hamrah-profile-platform="android"] #profileView .aprr1-shell :is(
  .aprr1-hero,
  .aprr1-actions,
  .aprr1-info
) {
  box-sizing: border-box;
  inline-size: 100%;
  min-inline-size: 0;
  max-inline-size: 100%;
}

html[data-hamrah-profile-platform="android"] #profileView .aprr1-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

html[data-hamrah-profile-platform="android"] #profileView .aprr1-actions > *,
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info > *,
html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-row > * {
  min-inline-size: 0;
  max-inline-size: 100%;
}

html[data-hamrah-profile-platform="android"] #profileView .aprr1-info-row {
  box-sizing: border-box;
  grid-template-columns: minmax(0, 1fr) auto;
  min-inline-size: 0;
  max-inline-size: 100%;
}

html[data-hamrah-profile-platform="android"] .aprr2-editor-sheet {
  box-sizing: border-box;
  inline-size: min(calc(100vw - 16px), 600px) !important;
  min-inline-size: 0 !important;
  max-inline-size: 600px !important;
  margin-inline: auto;
}

html[data-hamrah-profile-platform="android"] .aprr2-editor-mount,
html[data-hamrah-profile-platform="android"] .aprr2-editor-mount #profileEditCard,
html[data-hamrah-profile-platform="android"] .aprr2-editor-mount #profileEditCard :is(
  form,
  label,
  input,
  textarea,
  button,
  .two-fields,
  .profile-photo-editor
) {
  box-sizing: border-box;
  min-inline-size: 0;
  max-inline-size: 100%;
}

@media (prefers-reduced-motion: reduce) {
  #profileView.profile-view,
  #profileView.profile-view *,
  html[data-hamrah-profile-platform="android"] .aprr2-editor-sheet {
    scroll-behavior: auto !important;
  }
}

/* -------------------------------------------------------------------------
 * R4 ANDROID PROFILE LAYOUT REPAIR HOTFIX2
 *
 * Physical QA on a modern Android flagship exposed two profile-only failures:
 * 1) APRR1 action cards were visually shrink-wrapping instead of filling their
 *    three grid tracks.
 * 2) `overflow-wrap:anywhere` allowed Persian labels and the LTR username to
 *    break character-by-character when a track became narrow.
 *
 * This final cascade owner is intentionally Android/APRR1-only. It does not
 * touch Member Panel, Tag Studio, Windows profile, backend, or profile data.
 * ------------------------------------------------------------------------- */

html[data-hamrah-profile-platform="android"]
#profileView[data-android-profile-r1="ready"] > .aprr1-shell {
  box-sizing: border-box !important;
  inline-size: 100% !important;
  min-inline-size: 0 !important;
  max-inline-size: 600px !important;
  margin-inline: auto !important;
}

/* Three equal real tracks. Every button explicitly stretches into its track. */
html[data-hamrah-profile-platform="android"]
#profileView .aprr1-actions {
  box-sizing: border-box !important;
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  align-items: stretch !important;
  justify-items: stretch !important;
  inline-size: 100% !important;
  min-inline-size: 0 !important;
  max-inline-size: 100% !important;
  gap: 8px !important;
}

html[data-hamrah-profile-platform="android"]
#profileView .aprr1-actions > .aprr1-action {
  box-sizing: border-box !important;
  inline-size: 100% !important;
  width: 100% !important;
  min-inline-size: 0 !important;
  min-width: 0 !important;
  max-inline-size: none !important;
  max-width: none !important;
  justify-self: stretch !important;
  align-self: stretch !important;
}

/* Persian/English action labels may wrap at word boundaries, never per glyph. */
html[data-hamrah-profile-platform="android"]
#profileView .aprr1-action-label {
  box-sizing: border-box !important;
  display: block !important;
  inline-size: 100% !important;
  min-inline-size: 0 !important;
  max-inline-size: 100% !important;
  white-space: normal !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
  hyphens: none !important;
  text-align: center !important;
}

html[dir="rtl"][data-hamrah-profile-platform="android"]
#profileView .aprr1-action-label {
  direction: rtl !important;
  unicode-bidi: plaintext;
}

/* Information rows keep one fluid text column plus one fixed chevron column. */
html[data-hamrah-profile-platform="android"]
#profileView .aprr1-info-row {
  box-sizing: border-box !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 20px !important;
  align-items: center !important;
  inline-size: 100% !important;
  width: 100% !important;
  min-inline-size: 0 !important;
  max-inline-size: 100% !important;
  gap: 12px !important;
  direction: inherit !important;
}

html[data-hamrah-profile-platform="android"]
#profileView .aprr1-info-row > .aprr1-info-copy {
  grid-column: 1 !important;
  box-sizing: border-box !important;
  inline-size: 100% !important;
  width: 100% !important;
  min-inline-size: 0 !important;
  min-width: 0 !important;
  max-inline-size: 100% !important;
}

html[data-hamrah-profile-platform="android"]
#profileView .aprr1-info-row > svg {
  grid-column: 2 !important;
  justify-self: center !important;
  inline-size: 18px !important;
  width: 18px !important;
  min-inline-size: 18px !important;
  max-inline-size: 18px !important;
}

/* Usernames are identifiers: never render them as a vertical character stack. */
html[data-hamrah-profile-platform="android"]
#profileView .aprr1-info-copy .aprr1-ltr {
  display: block !important;
  inline-size: 100% !important;
  min-inline-size: 0 !important;
  max-inline-size: 100% !important;
  direction: ltr !important;
  unicode-bidi: isolate !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
}

/* Labels may wrap naturally but must not break inside Persian words. */
html[data-hamrah-profile-platform="android"]
#profileView .aprr1-info-copy :is(b, small):not(.aprr1-ltr) {
  min-inline-size: 0 !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
  hyphens: none !important;
}

/* Keep the profile above the fixed mobile navigation while scrolling. */
html[data-hamrah-profile-platform="android"]
#profileView[data-android-profile-r1="ready"] {
  scroll-padding-block-end: calc(96px + env(safe-area-inset-bottom)) !important;
}

html[data-hamrah-profile-platform="android"]
#profileView[data-android-profile-r1="ready"] > .aprr1-shell {
  padding-block-end: calc(104px + env(safe-area-inset-bottom)) !important;
}

/* -------------------------------------------------------------------------
 * R4 ANDROID PROFILE POLISH HOTFIX3
 * Physical QA final polish:
 * - non-interactive Birthday / Member-since rows do not show navigation arrows
 * - interactive Username row keeps its arrow
 * - LTR username value is end-aligned as intrinsic content so it cannot lose
 *   its final glyph at the card edge.
 * ------------------------------------------------------------------------- */

/* Birthday + Member-since are informational, not navigation targets. */
html[data-hamrah-profile-platform="android"]
#profileView .aprr1-info-row:not(.aprr1-info-button) {
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 0 !important;
}

html[data-hamrah-profile-platform="android"]
#profileView .aprr1-info-row:not(.aprr1-info-button) > svg {
  display: none !important;
}

/* Username remains interactive, but its value should sit flush with the
   information lane rather than becoming a full-width LTR clipping box. */
html[dir="rtl"][data-hamrah-profile-platform="android"]
#profileView .aprr1-info-button > .aprr1-info-copy {
  padding-inline: 0 !important;
  margin-inline: 0 !important;
  text-align: right !important;
}

html[dir="rtl"][data-hamrah-profile-platform="android"]
#profileView .aprr1-info-button .aprr1-ltr {
  display: inline-block !important;
  inline-size: auto !important;
  width: auto !important;
  max-inline-size: 100% !important;
  max-width: 100% !important;
  direction: ltr !important;
  unicode-bidi: isolate !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
  text-align: left !important;
  vertical-align: bottom !important;
}
/* R5_MOBILE_FILTER_ACTIVE_CONTRAST_HF1
   The selected home filter pill must remain readable in light mode and still
   look correct in dark/AMOLED. Use the theme text token instead of a fixed
   pale color, and keep the icon/label fully legible.
*/
@media (max-width: 767px) {
  html[data-hamrah-mobile-polish="r2"] #roomFilters .filter-pill.active {
    color: var(--mup-text) !important;
    font-weight: 800 !important;
    text-shadow: none !important;
  }

  html[data-hamrah-mobile-polish="r2"] #roomFilters .filter-pill.active svg {
    color: currentColor !important;
    opacity: 1 !important;
  }
}
