/* UmmahChat in-app theme — the "digital majlis": forest rail, cream floor, gold accent.
   Overrides Element v1.12.20 Compound tokens + structural classes (config custom_themes
   alone doesn't reach the modern UI). Loaded after bundle.css so it wins.
   v9 — INTERN POLISH SWEEP (Jun 18 2026, BUG-309/308/322/321):
     - SECTION 23: BUG-309 home caption un-overlap (remove ::after from mx_HomePage —
       that page shows our welcome.html which carries its own branding; the amanah caption
       stays on mx_RoomView_empty only, now properly centered).
     - SECTION 23: BUG-308 desktop collapsed avatar fix strengthened (add explicit
       attribute + class variants for SpacePanel collapsed state in Element v1.12.20).
     - SECTION 23: BUG-322 mobile — message field no longer overflows viewport bottom;
       sidebar lock (overflow-x:hidden on app root prevents horizontal scroll after
       picking a user from the people-picker); @username vertical alignment.
     - SECTION 23: BUG-321 mention-pill pointer-events — explicit pointer-events:all
       to ensure @mention pill clicks reach Element's click handler (not blocked by any
       parent overflow or pointer-events:none on related elements).
   v8 — SETTINGS BAR CONTRAST + THEME FOUC + AVATAR CLIP FIXES (Jun 16 2026):
     - SECTION 10: settings nav active-item contrast (white-on-grey → dark text on cream bg)
     - SECTION 11: theme-switch FOUC suppressor (brief broken state during link-swap)
     - SECTION 9C mobile avatar fix improved: collapsed SpacePanel avatar no longer half-clipped
   v6 — THEME-TOGGLE LIVE FIX (Jun 15 2026, @mehek bug report):
     ROOT CAUSE (v5 residual): The v5 MutationObserver watched link[data-mx-theme]
     elements' `disabled` HTML attribute. But Element switches themes by setting
     link.disabled as a DOM *property* (not setAttribute) — MutationObserver never sees it.
     Result: body[data-ummahchat-theme] was only set at page-boot (when the attr IS in the
     HTML), not on live toggle. So toggling light→dark→UmmahChat in the settings panel
     left body[data-ummahchat-theme] absent → sidebar went cream (Section 2 rules inactive)
     → broken until hard refresh (which re-boots the correct initial state).
     FIX (v6): index.html observer now watches body.class attribute changes — Element
     DOES call classList.add/remove('cpd-theme-light','cpd-theme-dark') on every toggle,
     so body class IS an attribute mutation the observer catches. syncThemeAttr() reads
     link.disabled as a DOM property (not attr), which is correct.
     Also fixes: Section 3 avatar fix — removed the `overflow:visible` override that
     fought with the inline-style `overflow:hidden` (inline style wins over external CSS).
     Avatar fix moved into the index.html inline <style> block where it has equal
     specificity to the overflow:hidden rule.
   v5 — BUG-280/282/235/244/268 ROOT-CAUSE FIX (Jun 15 2026):
     ROOT CAUSE: All prior versions used html.cpd-theme-dark / html:not(.cpd-theme-dark)
     as the theme-switch guard. BUT Element v1.12.20 puts cpd-theme-dark / cpd-theme-light
     on document.BODY, not <html>. So the guards NEVER fired: the dark sidebar stayed
     active under built-in Light theme (no hard-refresh relief), and the dark/light
     compat sections (6/7) were completely inert. Additionally, both the built-in "Light"
     theme AND our custom "UmmahChat Light-custom" theme put body.cpd-theme-light, so we
     can't distinguish them by body class alone.
     FIX: (1) body[data-ummahchat-theme="active"] — a JS MutationObserver in index.html
     watches link[data-mx-theme] elements; when "Light-custom" (our theme) is enabled it
     adds the attribute; when any other theme is enabled it removes it. This gives a
     reliable CSS hook that is ONLY true when UmmahChat custom theme is selected.
     (2) All `html.cpd-theme-dark` → `body.cpd-theme-dark` (correct element).
     (3) All `html.cpd-theme-light` → `body.cpd-theme-light` (correct element).
     (4) Section 2 sidebar guard changed from html:not(.cpd-theme-dark) →
         body[data-ummahchat-theme="active"] (scoped to OUR theme only).
     v4 history: P1 AMANAH (CompleteSecurity suppress) + P3-1/P3-2 (sidebar + empty state)
*/

/* ====================================================================
   SECTION 0 — P1 AMANAH: Suppress "Confirm your digital identity /
   Verify this device to set up secure messaging" blocking screen.
   Root cause: Element's DefaultCryptoSetupExtension has
   SHOW_ENCRYPTION_SETUP_UI=true (hardcoded); when the user has
   cross-signing keys, postLoginSetup() transitions to COMPLETE_SECURITY
   view showing a full-screen modal with a padlock icon and the words
   "secure messaging". UmmahChat v1 is NOT E2EE — this modal is an
   amanah violation (false "secure" claim) AND a login blocker.
   The JS MutationObserver in index.html auto-clicks skip; this CSS
   hides the modal body during that ~100ms interval so user never sees
   the padlock/copy. Also hides the matrix.org footer link on all auth
   pages (our auth_footer_links replaces the content, but the matrix.org
   anchor is hardcoded AFTER them in the HA component).
   ==================================================================== */

/* Hide the ENTIRE CompleteSecurity card — container AND contents — so no empty
   cream shell ever flashes or sticks while the JS dismiss runs. BUG-288 MOBILE
   follow-up (Jun 16): the old rule painted .mx_CompleteSecurity cream
   (background:#FAF8F3) and only hid the *children*, so on slower devices
   (Android Chrome) the user was stranded on an empty cream box until — or if —
   the JS fired. Now the whole card is invisible; the green auth-page background
   shows through for the brief moment before the JS transitions to the app. */
.mx_CompleteSecurity,
.mx_CompleteSecurity_body,
.mx_CompleteSecurity_header,
.mx_SetupEncryptionBody,
.mx_Dialog_border:has(.mx_CompleteSecurity),
.mx_CompleteSecurity .mx_Dialog_border,
.mx_CompleteSecurity_headerIcon,
.mx_CompleteSecurity_heroIcon {
  visibility: hidden !important;
}

/* Hide the "Powered by Matrix" / matrix.org link in the auth footer
   (HA component hardcodes it after auth_footer_links) */
footer.mx_AuthFooter a[href*="matrix.org"],
footer.mx_AuthFooter a[href*="matrix.org"] img {
  display: none !important;
}

/* SetupEncryptionToast — the dismissible toast that says "Verify this device".
   FTUE.CrossSigningSetUp:false in config.json already suppresses it, but belt+suspenders */
.mx_SetupEncryptionToast { display: none !important; }

/* BulkUnverifiedSessionsToast — similar noisy E2EE toast */
.mx_BulkUnverifiedSessionsToast { display: none !important; }

/* BUG-290 (Jun 15 2026): Element 1.12.20 uses the generic mx_Toast_toast component
   for E2EE verification prompts ("Verify this device"). The old mx_SetupEncryptionToast /
   mx_BulkUnverifiedSessionsToast class names are no longer emitted — instead all toasts
   use mx_Toast_toast. On a non-E2EE deployment the ONLY toasts shown are E2EE noise;
   room/call invites use separate in-room UI, not mx_ToastContainer.
   Suppress the entire container + any residual legacy class names. */
.mx_ToastContainer { display: none !important; }

/* Hide E2EE "encryption not set up" notices in room timeline (non-E2EE rooms, non-issue) */
.mx_EncryptionEvent { display: none !important; }

/* ====================================================================
   SECTION 1 — ALWAYS-ON (accent/brand colors apply regardless of theme)
   :root covers the default / UmmahChat custom theme (tokens injected on :root).
   body.cpd-theme-light / body.cpd-theme-light-hc re-apply for the built-in light themes
   (Element's Compound token injection uses :root,[class*="cpd-theme-"] so our overrides
   need the same specificity on the body element where the class actually lives).
   ==================================================================== */
:root,
body.cpd-theme-light,
body.cpd-theme-light-hc {
  --cpd-color-text-action-accent: #166534 !important;
  --cpd-color-bg-action-primary-rest: #166534 !important;
  --cpd-color-bg-action-primary-hovered: #124d28 !important;
  --cpd-color-bg-action-primary-pressed: #0f3f21 !important;
  --cpd-color-icon-accent-primary: #166534 !important;
  --cpd-color-text-primary: #20302a !important;
  --cpd-color-border-interactive-primary: #C8912E !important;
}

/* ---- primary buttons -> forest (always) ---- */
.mx_AccessibleButton_kind_primary { background-color: #166534 !important; border-color:#166534 !important; }
.mx_AccessibleButton_kind_primary:hover { background-color: #124d28 !important; }

/* ---- compose bar (always cream/white) ---- */
.mx_MessageComposer, .mx_BasicMessageComposer { background-color: #ffffff !important; }

/* Suppress E2EE/send-error noise icons — non-E2EE setup, these are cross-signing
   verification prompts that confuse users (red icon on every message = BUG-286).
   The mx_EventTile_msgOption e2e icon + the send-status error dot.
   v6 additions (Jun 15 @mehek): also hide the *wrapper* divs which can still consume
   layout space and show a red background even when the inner icon display:none is set,
   and the top-level mx_E2EIcon component class which covers both DM and room contexts. */
.mx_MessageComposer_e2eIcon { display: none !important; }
.mx_MessageComposer_e2eIconWrapper { display: none !important; }
.mx_EventTile_e2eIcon { display: none !important; }
/* mx_E2EIcon is the component root — covers ALL contexts (timeline, composer, panel) */
.mx_E2EIcon { display: none !important; }

/* ====================================================================
   SECTION 2 — FOREST RAIL (scoped: ONLY when UmmahChat custom theme is active)
   Guard: body[data-ummahchat-theme="active"] — set by the MutationObserver in
   index.html that watches link[data-mx-theme="Light-custom"] becoming enabled.
   This fires ONLY for our custom "UmmahChat" theme selection, not for the
   built-in Light/Dark themes (which also set body.cpd-theme-light/dark).
   Prior bug (v4): used html:not(.cpd-theme-dark) — wrong element (class is on body)
   AND wrong scope (fired for built-in Light too, so switching to Light kept dark rail).
   ==================================================================== */

/* The forest background + all text/icon colors — only active on OUR theme */
body[data-ummahchat-theme="active"] .mx_LeftPanel,
body[data-ummahchat-theme="active"] .mx_LeftPanel_outerWrapper,
body[data-ummahchat-theme="active"] .mx_SpacePanel,
body[data-ummahchat-theme="active"] .mx_RoomList,
body[data-ummahchat-theme="active"] .mx_RoomListPanel,
body[data-ummahchat-theme="active"] .mx_RoomSublist,
body[data-ummahchat-theme="active"] .mx_LeftPanel_roomListContainer,
body[data-ummahchat-theme="active"] .mx_RoomListHeader {
  background-color: #0A2C17 !important;
}

/* P3-1: Space rail = deep forest #0A2C17 (already set above for SpacePanel).
   Room-list panel = slightly lighter #0F3520 to create a visual step */
body[data-ummahchat-theme="active"] .mx_RoomListPanel,
body[data-ummahchat-theme="active"] .mx_LeftPanel_roomListContainer,
body[data-ummahchat-theme="active"] .mx_RoomList,
body[data-ummahchat-theme="active"] .mx_RoomSublist {
  background-color: #0F3520 !important;
}

/* ---- COMPLETE text coverage on dark rail ----
   Element 1.12.20 uses BOTH old mx_ classes AND new Compound module classes (hashed).
   We can't predict the hash so we target by role/attribute patterns + explicit class list. */

/* Old-style mx_ room tile text */
body[data-ummahchat-theme="active"] .mx_RoomTile_title,
body[data-ummahchat-theme="active"] .mx_RoomTile_subtitle,
body[data-ummahchat-theme="active"] .mx_LeftPanel .mx_RoomTile,
body[data-ummahchat-theme="active"] .mx_RoomSublist_showNButtonChevron,
body[data-ummahchat-theme="active"] .mx_RoomListHeader_title { color: #eaf2ec !important; }

/* Compound-style room tile text — Element uses aria-label on tiles, text in children.
   v7 (Jun 16 2026): the new mx_LeftPanel_newRoomList uses mx_RoomListItemView NOT
   mx_RoomTile as the tile wrapper, so [class*="_roomName_"] must be scoped to
   .mx_LeftPanel directly (not via .mx_RoomTile ancestor). */
body[data-ummahchat-theme="active"] .mx_RoomTile [class*="_roomName_"],
body[data-ummahchat-theme="active"] .mx_RoomTile [class*="_notifBadge_"],
body[data-ummahchat-theme="active"] .mx_RoomTile [class*="_subtitle_"],
body[data-ummahchat-theme="active"] .mx_LeftPanel [class*="_roomName_"],
body[data-ummahchat-theme="active"] .mx_LeftPanel [class*="_label_"],
body[data-ummahchat-theme="active"] .mx_LeftPanel [class*="_name_"],
body[data-ummahchat-theme="active"] .mx_LeftPanel [class*="_title_"] { color: #eaf2ec !important; }

/* mx_RoomListItemView is the new room tile wrapper (mx_LeftPanel_newRoomList) */
body[data-ummahchat-theme="active"] .mx_RoomListItemView [class*="_roomName_"],
body[data-ummahchat-theme="active"] .mx_RoomListItemView [class*="_content_"],
body[data-ummahchat-theme="active"] .mx_RoomListItemView [class*="_name_"],
body[data-ummahchat-theme="active"] .mx_RoomListItemView [class*="_subtitle_"] {
  color: #eaf2ec !important;
}

/* P3-1: Unread room name = cream #FAF8F3 weight-600; read = rgba(234,242,236,.6)
   v7: also covers mx_RoomListItemView (new room list component) */
body[data-ummahchat-theme="active"] .mx_RoomTile_notificationBadge ~ .mx_RoomTile_title,
body[data-ummahchat-theme="active"] .mx_RoomTile[data-state="unread"] .mx_RoomTile_title,
body[data-ummahchat-theme="active"] .mx_RoomTile.mx_RoomTile_hasUnreadMessages .mx_RoomTile_title,
body[data-ummahchat-theme="active"] .mx_RoomTile.mx_RoomTile_hasUnreadMessages [class*="_roomName_"],
body[data-ummahchat-theme="active"] .mx_RoomListItemView[data-notification-state="highlight"] [class*="_roomName_"],
body[data-ummahchat-theme="active"] .mx_RoomListItemView[data-notification-state="notification"] [class*="_roomName_"] {
  color: #FAF8F3 !important;
  font-weight: 600 !important;
}
body[data-ummahchat-theme="active"] .mx_RoomTile:not(.mx_RoomTile_hasUnreadMessages) .mx_RoomTile_title,
body[data-ummahchat-theme="active"] .mx_RoomTile:not(.mx_RoomTile_hasUnreadMessages) [class*="_roomName_"],
body[data-ummahchat-theme="active"] .mx_RoomListItemView[data-notification-state="none"] [class*="_roomName_"],
body[data-ummahchat-theme="active"] .mx_RoomListItemView:not([data-notification-state]) [class*="_roomName_"] {
  color: rgba(234,242,236,0.75) !important;
  font-weight: 400 !important;
}

/* SpacePanel nav items (left-most icon rail) */
body[data-ummahchat-theme="active"] .mx_SpacePanel [class*="_label_"],
body[data-ummahchat-theme="active"] .mx_SpacePanel [class*="_navItem_"] { color: #eaf2ec !important; }
body[data-ummahchat-theme="active"] .mx_SpacePanel { background-color: #0A2C17 !important; }

/* P3-1: Active space = gold ring + gold-tinted bg.
   v7 mobile (Jun 16 2026): reduced outline + bg opacity on mobile to avoid
   the oversized boxy appearance (@mehek item 5). Desktop keeps 3px. */
body[data-ummahchat-theme="active"] .mx_SpaceButton_active,
body[data-ummahchat-theme="active"] .mx_SpaceItem_activeButton,
body[data-ummahchat-theme="active"] .mx_SpacePanel [aria-current="true"] .mx_SpaceButton,
body[data-ummahchat-theme="active"] .mx_SpacePanel [class*="_spaceButton_"][aria-selected="true"] {
  outline: 2px solid #C8912E !important;
  outline-offset: 1px !important;
  background-color: rgba(200,145,46,0.15) !important;
  border-radius: 12px !important;
}
@media (max-width: 480px) {
  body[data-ummahchat-theme="active"] .mx_SpaceButton_active,
  body[data-ummahchat-theme="active"] .mx_SpaceItem_activeButton,
  body[data-ummahchat-theme="active"] .mx_SpacePanel [aria-current="true"] .mx_SpaceButton,
  body[data-ummahchat-theme="active"] .mx_SpacePanel [class*="_spaceButton_"][aria-selected="true"] {
    outline: 1.5px solid rgba(200,145,46,0.7) !important;
    outline-offset: 0 !important;
    background-color: rgba(200,145,46,0.10) !important;
    border-radius: 10px !important;
  }
}

/* SVG icons on the dark rail — fill/stroke pass through currentColor, so set color */
body[data-ummahchat-theme="active"] .mx_LeftPanel svg,
body[data-ummahchat-theme="active"] .mx_SpacePanel svg,
body[data-ummahchat-theme="active"] .mx_RoomListHeader svg,
body[data-ummahchat-theme="active"] .mx_RoomTile svg,
body[data-ummahchat-theme="active"] .mx_RoomListItemView svg { color: #c4dac9 !important; fill: currentColor; }

/* Search / filter bar at top of room list */
body[data-ummahchat-theme="active"] .mx_RoomSearch,
body[data-ummahchat-theme="active"] .mx_RoomSearch input,
body[data-ummahchat-theme="active"] .mx_RoomSearch_placeholder,
body[data-ummahchat-theme="active"] [class*="_searchBar_"],
body[data-ummahchat-theme="active"] [class*="_searchInput_"] {
  background-color: rgba(255,255,255,0.08) !important;
  color: #eaf2ec !important;
}
body[data-ummahchat-theme="active"] .mx_RoomSearch input::placeholder,
body[data-ummahchat-theme="active"] [class*="_searchInput_"]::placeholder { color: #9cc4a8 !important; }

/* P3-1: Section headers — Instrument Sans 10px uppercase gold #D4A044 (lighter at small size for AA) */
body[data-ummahchat-theme="active"] .mx_RoomSublist_headerText {
  color: #D4A044 !important;
  font-family: 'Instrument Sans', 'Inter', sans-serif !important;
  font-size: 10px !important;
  font-weight: 600 !important;
  letter-spacing: 0.12em !important;
  text-transform: uppercase !important;
}
body[data-ummahchat-theme="active"] [class*="_sectionHeader_"],
body[data-ummahchat-theme="active"] [class*="_sublistHeader_"] {
  color: #D4A044 !important;
  font-family: 'Instrument Sans', 'Inter', sans-serif !important;
  font-size: 10px !important;
  font-weight: 600 !important;
  letter-spacing: 0.12em !important;
  text-transform: uppercase !important;
}

/* P3-1: Active room = 3px left-border gold + rgba(22,101,52,.4) bg */
body[data-ummahchat-theme="active"] .mx_RoomTile_selected,
body[data-ummahchat-theme="active"] .mx_RoomTile[aria-selected="true"],
body[data-ummahchat-theme="active"] .mx_RoomTile.mx_RoomTile_selected {
  background-color: rgba(22,101,52,0.40) !important;
  border-left: 3px solid #C8912E !important;
  padding-left: 5px !important;
}
body[data-ummahchat-theme="active"] .mx_RoomTile:hover { background-color: rgba(255,255,255,0.06) !important; }

/* P3-1: Unread badge = gold bg + deep forest text */
body[data-ummahchat-theme="active"] .mx_LeftPanel .mx_NotificationBadge,
body[data-ummahchat-theme="active"] .mx_LeftPanel [class*="_badge_"] {
  background-color: #C8912E !important;
  color: #0A2C17 !important;
  font-weight: 700 !important;
}

/* ====================================================================
   SECTION 3 — AVATAR FIXES (BUG-283 / BUG-264 profile picture cut off)
   Root cause: .mx_SpacePanel .mx_UserMenu has overflow:hidden (BUG-262
   chevron fix in index.html inline style). The avatar sits INSIDE that
   wrapper. We can't remove the overflow:hidden (it prevents chevron
   overlap), so we must ensure the avatar content area has enough width
   and use clip-path or visible overflow on the avatar element itself.
   ==================================================================== */

/* BUG-283 / BUG-264 (1) — avatar clipping within UserMenu.
   NOTE: overflow:visible on .mx_UserMenu is intentionally NOT set here — the inline
   <style> in index.html sets overflow:hidden which is needed to prevent the SpacePanel
   chevron collision, and inline style beats external CSS regardless of !important.
   Instead we ensure the avatar child has a flex-shrink:0 + clip-path:circle() so it
   renders fully within the 40px min-height of the UserMenu without needing overflow:visible.
   The actual overflow:hidden fix + avatar sizing lives in the index.html inline <style>. */
.mx_SpacePanel ._triggerButton_1yvpq_57 {
  align-items: center !important;
  justify-content: flex-start !important;
}
/* The avatar element itself — ensure correct dimensions and no clipping via clip-path */
.mx_SpacePanel ._triggerButton_1yvpq_57 > [data-testid="avatar-image"],
.mx_SpacePanel ._triggerButton_1yvpq_57 > img,
.mx_SpacePanel ._triggerButton_1yvpq_57 > span:first-child,
.mx_SpacePanel ._triggerButton_1yvpq_57 > div:first-child {
  flex-shrink: 0 !important;
  min-width: 32px !important;
  width: 32px !important;
  height: 32px !important;
  border-radius: 50% !important;
  overflow: hidden !important;
  display: block !important;
}

/* Ensure the Compound Avatar component renders fully */
.mx_SpacePanel [data-testid="avatar-image"] img,
.mx_SpacePanel [data-testid="avatar-image"] {
  border-radius: 50% !important;
  width: 32px !important;
  height: 32px !important;
  object-fit: cover !important;
  display: block !important;
}

/* BUG-264 (2) — Join/View buttons on Explore room tiles are visibility:hidden by default */
.mx_SpaceHierarchy_actions .mx_AccessibleButton { visibility: visible !important; }

/* BUG-264 (3) — Profile-dropdown username centre-aligned */
._container_1yvpq_15 section._profile_1yvpq_23 { align-items: center !important; }
._container_1yvpq_15 section._profile_1yvpq_23 ._displayname_1yvpq_33 {
  text-align: center !important;
  width: 100% !important;
}

/* CD must-fix 2: avatar rings — subtle gold border on all avatars */
.mx_BaseAvatar,
.mx_BaseAvatar_image { border: 1.5px solid rgba(200,145,46,0.35) !important; box-sizing: border-box !important; }
.mx_BaseAvatar_initial {
  background-color: #15512f !important;
  color: #FAF8F3 !important;
  border: 1.5px solid rgba(200,145,46,0.35) !important;
}

/* ====================================================================
   SECTION 4 — CONVERSATION FLOOR (cream — applies with UmmahChat or Light)
   ==================================================================== */
.mx_RoomView, .mx_RoomView_body, .mx_MainSplit, .mx_ScrollPanel,
.mx_RoomView_messageListWrapper, .mx_RoomView_timeline { background-color: #FAF8F3 !important; }
.mx_RoomHeader, .mx_RoomView_header, .mx_LegacyRoomHeader {
  background-color: #FAF8F3 !important;
  border-bottom: 1px solid #e8e0d0 !important;
}

/* ====================================================================
   SECTION 4B — P3-2: EMPTY STATE
   When there are no rooms / empty room view, show a branded placeholder:
   cream background, Rub-el-Hizb khatam watermark in gold rgba(.12),
   Amiri italic tagline, "Owned by the Ummah. Not Big Tech." in Inst.Sans.
   AMANAH: NO "private/secure/encrypted" copy anywhere in this section.
   The khatam SVG is injected as a CSS background-image data: URI (inline).
   ==================================================================== */
.mx_RoomView_empty,
.mx_HomePage,
.mx_EmbeddedPage,
[class*="_emptyState_"],
[class*="_empty_"] {
  background-color: #FAF8F3 !important;
  position: relative !important;
}

/* Khatam/Rub-el-Hizb watermark — SVG inline as data URI, gold at 12% opacity */
.mx_RoomView_empty::before,
.mx_HomePage::before,
.mx_EmbeddedPage::before {
  content: '' !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -80px) !important;
  width: 80px !important;
  height: 80px !important;
  opacity: 0.12 !important;
  pointer-events: none !important;
  /* Rub-el-Hizb / khatam octagram: 8-pointed star */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='50,5 61,35 93,35 68,57 79,91 50,70 21,91 32,57 7,35 39,35' fill='%23C8912E'/%3E%3Crect x='30' y='30' width='40' height='40' transform='rotate(45 50 50)' fill='%23C8912E'/%3E%3C/svg%3E") !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
}

/* New Room Intro (first time entering a room or empty room) */
.mx_NewRoomIntro {
  padding: 8px 12px !important;
  background-color: #FAF8F3 !important;
}

/* Empty-state call to action area — branded */
.mx_RoomView_empty .mx_RoomView_empty_copyable,
.mx_RoomView_empty h2,
.mx_RoomView_empty p {
  font-family: 'Amiri', 'Georgia', serif !important;
  color: #0A2C17 !important;
}

/* "Owned by the Ummah. Not Big Tech." tagline under empty state.
   BUG-nemat-day2 (Jun 16): the old positioning (top:50%+30px translate) overlapped
   the bottom action button during the brief load transition when Element's flex layout
   hadn't applied yet. Changed to bottom-anchored (bottom:24px) so it always sits
   safely below the content area, never overlapping buttons regardless of timing. */
.mx_RoomView_empty::after,
.mx_HomePage::after {
  content: 'Owned by the Ummah. Not Big Tech.' !important;
  display: block !important;
  position: absolute !important;
  bottom: 24px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  top: auto !important;
  font-family: 'Instrument Sans', 'Inter', sans-serif !important;
  font-size: 13px !important;
  color: rgba(10,44,23,0.55) !important;
  letter-spacing: 0.02em !important;
  white-space: nowrap !important;
  pointer-events: none !important;
}

/* ====================================================================
   SECTION 5 — POLISH (system messages + links)
   ==================================================================== */
.mx_TextualEvent,
.mx_EventTile_info .mx_EventTile_content,
.mx_EventTile_info .mx_TextualEvent,
.mx_GenericEventListSummary_summary,
.mx_GenericEventListSummary_summary .mx_TextualEvent { color: #6f6149 !important; }
.mx_GenericEventListSummary_toggle,
.mx_EventTile .mx_AccessibleButton_kind_link_inline,
.mx_EventTile a { color: #a06f12 !important; }
.mx_GenericEventListSummary_toggle { font-weight: 600 !important; }
.mx_NewRoomIntro { padding: 8px 12px !important; }

/* ====================================================================
   SECTION 5B — CONTRAST FIXES (v6, Jun 15 @mehek report)
   These cover the "hard to read text in many places" complaint.
   Root cause: some Compound token vars were not overridden, leaving
   secondary/tertiary text in colours that are too similar to their bg.
   Apply to all themes (not scoped to UmmahChat-custom-only) because
   the built-in Light theme can also have contrast issues with our
   accent overrides.
   ==================================================================== */

/* Message sender name — must be forest-green on cream bg (AA contrast) */
.mx_EventTile .mx_DisambiguatedProfile,
.mx_EventTile .mx_SenderProfile,
.mx_EventTile .mx_DisambiguatedProfile_displayName,
.mx_EventTile .mx_SenderProfile_name {
  color: #0A2C17 !important;
  font-weight: 600 !important;
}

/* Timestamps + secondary info next to messages — readable on cream */
.mx_MessageTimestamp,
.mx_EventTile .mx_MessageTimestamp,
.mx_EventTile_line .mx_MessageTimestamp {
  color: #6b7a70 !important;
}

/* Room header title + topic text — dark on cream so AA passes */
.mx_RoomHeader_nametext,
.mx_LegacyRoomHeader_nametext,
.mx_RoomHeader_name,
.mx_RoomHeaderUnauthenticated_name,
[class*="_roomName_"]:not(.mx_LeftPanel *),
[class*="_roomHeaderName_"] {
  color: #0A2C17 !important;
  font-weight: 600 !important;
}
.mx_RoomHeader_topic,
.mx_LegacyRoomHeader_topic,
[class*="_topic_"] {
  color: #3d5245 !important;
}

/* Member list panel text — ensure readable on whatever bg it uses */
.mx_MemberTile .mx_MemberTile_name,
.mx_EntityTile_name,
.mx_MemberList .mx_MemberTile_name { color: #20302a !important; }

/* Right panel (user info, room settings) headings */
.mx_RightPanel .mx_UserInfo_profile_displayName,
.mx_RightPanel .mx_UserInfo_profile_mxid,
.mx_RightPanel [class*="_heading_"],
.mx_BaseCard_header { color: #0A2C17 !important; }

/* Input placeholder text — low contrast in default light Compound */
input::placeholder,
textarea::placeholder { color: #8fa896 !important; }

/* Dialog/modal body text — cream bg can wash out the default grey */
.mx_Dialog .mx_Dialog_content p,
.mx_Dialog .mx_Dialog_content li,
.mx_GenericModal .mx_Dialog_content { color: #20302a !important; }

/* ====================================================================
   SECTION 6 — DARK THEME COMPATIBILITY
   When user explicitly picks Dark theme (Element adds body.cpd-theme-dark),
   let Element's dark Compound vars take over. Only keep UMG accent colors.
   Fix v5: was html.cpd-theme-dark — class is on body, not html.
   ==================================================================== */
body.cpd-theme-dark {
  --cpd-color-text-action-accent: #4ade80 !important; /* lighter forest for dark bg */
  --cpd-color-bg-action-primary-rest: #166534 !important;
  --cpd-color-icon-accent-primary: #4ade80 !important;
}
/* In dark mode, let Element own backgrounds — don't fight it.
   body[data-ummahchat-theme] is also removed when dark theme fires (see index.html JS),
   so Section 2 sidebar rules are already inactive. These unsets are belt+suspenders. */
body.cpd-theme-dark .mx_LeftPanel,
body.cpd-theme-dark .mx_SpacePanel,
body.cpd-theme-dark .mx_RoomList,
body.cpd-theme-dark .mx_RoomView,
body.cpd-theme-dark .mx_RoomView_body,
body.cpd-theme-dark .mx_RoomHeader { background-color: unset !important; }
/* In dark mode the compose bar cream override also fights dark bg — revert it */
body.cpd-theme-dark .mx_MessageComposer,
body.cpd-theme-dark .mx_BasicMessageComposer { background-color: unset !important; }

/* ====================================================================
   SECTION 7 — LIGHT THEME COMPATIBILITY
   When user picks the built-in Light theme (not our custom theme),
   body[data-ummahchat-theme] is absent (removed by index.html observer),
   so Section 2 sidebar rules are already inactive. These unsets are
   belt+suspenders to neutralise any Section 4 cream overrides that look
   wrong on the stock light palette.
   Fix v5: was html.cpd-theme-light — class is on body, not html.
   ==================================================================== */
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_LeftPanel,
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_SpacePanel,
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_RoomList,
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_LeftPanel_outerWrapper,
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_RoomListPanel,
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_RoomSublist,
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_LeftPanel_roomListContainer,
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_RoomListHeader { background-color: unset !important; }
/* In built-in light theme, text colors go back to dark */
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_RoomTile_title,
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_RoomTile_subtitle,
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_RoomSublist_headerText,
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_RoomListHeader_title,
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_LeftPanel [class*="_label_"],
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_LeftPanel svg,
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_SpacePanel svg { color: unset !important; fill: unset !important; }
/* In built-in light theme, restore empty state text */
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_RoomView_empty::after,
body.cpd-theme-light:not([data-ummahchat-theme]) .mx_HomePage::after { color: rgba(10,44,23,0.55) !important; }

/* ====================================================================
   SECTION 8 — SUPPRESS BROKEN LOCATION/MAP FEATURE (Jun 16 2026)
   The "share location → drop pin" feature requires a map tile server
   (map_style_url) that we haven't stood up. Clicking the location icon
   shows "unable to load map". Tab's call: suppress the entry point
   entirely rather than stand up a tile server.
   Targeting: the LocationButton renders as a CollapsibleButton inside
   .mx_MessageComposerButtons with title="Location" (from i18n key
   "common|location"). The icon button uses class mx_MessageComposer_button.
   We hide all three surfaces: the composer button, any context-menu
   option showing "Location", and the live-location beacon button.
   ==================================================================== */

/* Location button in the message composer toolbar */
.mx_MessageComposerButtons [title="Location"],
.mx_MessageComposerButtons [aria-label="Location"] {
  display: none !important;
}

/* Location option in the composer overflow/attachment menu
   (IconizedContextMenuOption with "Location" label) */
.mx_IconizedContextMenu_option_body:has(> span:not([class])):is([id*="location"], [data-testid*="location"]),
[role="menuitem"][aria-label="Location"],
[role="option"][aria-label="Location"] {
  display: none !important;
}

/* Live location / beacon UI — hides the map picker modal and beacon status
   (mx_MLocationPicker, mx_BeaconStatus) in case the user somehow triggers it */
.mx_MLocationPicker,
.mx_BeaconStatus,
.mx_MBeaconBody,
.mx_BeaconViewDialog {
  display: none !important;
}

/* ====================================================================
   SECTION 9 — MOBILE POLISH (BUG-295, Jun 16 2026, @mehek audit)
   Items 3, 4, 5, 6, 7, 8 from the Jun 16 mobile audit.
   ==================================================================== */

/* ---- 9A: HOME ICON ACTIVE HIGHLIGHT (item 5) ----
   The selected SpaceButton (Home) renders a large gold square/box outline.
   Root cause: our active-space CSS sets outline + border-radius:12px on
   the button — on mobile the button is rendered bigger and the outline
   appears oversized. Shrink to a tighter ring without changing the gold
   colour.
   Additional: the Home button uses a different DOM path on mobile
   (it may render as [data-space-key="home"] or first .mx_SpaceButton
   inside .mx_SpacePanel).
   The 3px outline at outline-offset:1px is fine on desktop; on mobile
   the button is ~48px so the same outline looks proportionally large.
   Size it down to 2px + offset:0 + smaller border-radius for mobile. */
@media (max-width: 480px) {
  body[data-ummahchat-theme="active"] .mx_SpaceButton_active,
  body[data-ummahchat-theme="active"] .mx_SpaceItem_activeButton,
  body[data-ummahchat-theme="active"] .mx_SpacePanel [aria-current="true"] .mx_SpaceButton,
  body[data-ummahchat-theme="active"] .mx_SpacePanel [class*="_spaceButton_"][aria-selected="true"] {
    outline: 2px solid #C8912E !important;
    outline-offset: 0px !important;
    background-color: rgba(200,145,46,0.18) !important;
    border-radius: 10px !important;
  }
}

/* ---- 9B: SIDEBAR TEXT CONTRAST (item 4) ----
   On mobile (and desktop) the "Home" filter tabs and room names appear
   as low-contrast grey (#9E9E9E-ish) on the dark-green sidebar.
   WCAG AA requires ≥4.5:1 for normal text on dark bg.
   Force all sidebar text to #E8F0EA (near-white) for maximum contrast.
   The existing Section 2 rules cover .mx_RoomTile_title etc, but the
   new Compound-style tab chips (.mx_RoomListHeader filter pills) and
   the "Home" heading text may not be covered. */
body[data-ummahchat-theme="active"] .mx_RoomListHeader [class*="_filterContainer_"] button,
body[data-ummahchat-theme="active"] .mx_RoomListHeader [class*="_filter_"] button,
body[data-ummahchat-theme="active"] [class*="_filterChip_"],
body[data-ummahchat-theme="active"] [class*="_chip_"][class*="_selected_"],
body[data-ummahchat-theme="active"] .mx_RoomListHeader [role="tab"],
body[data-ummahchat-theme="active"] [class*="_roomListHeader_"] {
  color: #eaf2ec !important;
  border-color: rgba(234,242,236,0.25) !important;
}
/* Filter chip selected state — gold accent */
body[data-ummahchat-theme="active"] [class*="_chip_"][aria-selected="true"],
body[data-ummahchat-theme="active"] [class*="_filterChip_"][aria-selected="true"] {
  background-color: rgba(200,145,46,0.20) !important;
  border-color: rgba(200,145,46,0.50) !important;
  color: #FAF8F3 !important;
}
/* Room list empty state text (item 8 — the large empty area below rooms) */
body[data-ummahchat-theme="active"] [class*="_emptyTile_"],
body[data-ummahchat-theme="active"] [class*="_emptyState_"] { color: rgba(234,242,236,0.5) !important; }

/* ---- 9C: USER MENU AVATAR / USERNAME (items 3, 7) ----
   On mobile the SpacePanel avatar (top-left) is partially clipped —
   the left edge is cut off because the panel has padding-left and the
   avatar sits right at the edge. The username in the user profile
   dropdown is truncated to "I......" due to overflow:hidden on the
   container (our BUG-262 fix in inline styles sets max-width).
   Fixes:
   (a) On mobile, widen the space-panel avatar area (panel is narrower
       on mobile, ~64px vs desktop ~68px).
   (b) In the profile dropdown, allow the display name + MXID to wrap
       so a name like "Ilma" shows fully.
   (c) On mobile the user-menu popup itself may go off-screen right
       (it's fixed-position, left=0) — ensure it doesn't exceed viewport. */
@media (max-width: 480px) {
  /* Avatar in the left SpacePanel — no left-clip */
  .mx_SpacePanel .mx_UserMenu {
    padding-right: 0 !important;
    overflow: visible !important;
  }
  .mx_SpacePanel ._triggerButton_1yvpq_57 {
    max-width: none !important;
    padding-left: 4px !important;
  }
  /* User-menu popup — keep within viewport on mobile */
  .mx_ContextualMenu.mx_UserMenu_contextMenu,
  [class*="_menu_"][class*="_userMenu_"] {
    max-width: calc(100vw - 16px) !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
  }
}

/* Username / display-name in the dropdown: always show fully (items 3, 7) */
._container_1yvpq_15 section._profile_1yvpq_23 ._displayname_1yvpq_33 {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: unset !important;
  word-break: break-word !important;
  max-width: 200px !important;
}
/* MXID in the dropdown */
._container_1yvpq_15 section._profile_1yvpq_23 ._mxid_1yvpq_43,
._container_1yvpq_15 section._profile_1yvpq_23 [class*="_mxid_"] {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: unset !important;
  word-break: break-all !important;
  max-width: 200px !important;
}

/* ---- 9D: SETTINGS HORIZONTAL SCROLL (item 6) ----
   On mobile the Settings page content overflows horizontally because
   some panels (Appearance, Notifications) have fixed-width inner
   containers. Force all settings panels to stay within the viewport. */
.mx_SettingsPanel,
.mx_SettingsTab,
.mx_SettingsSection,
.mx_SettingsSubsection,
.mx_Settings_tabs,
[class*="_settingsPanel_"],
[class*="_settingsTab_"],
[class*="_settingsSection_"] {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  box-sizing: border-box !important;
}
@media (max-width: 480px) {
  .mx_SettingsPanel,
  .mx_SettingsTab,
  .mx_SettingsSection,
  .mx_SettingsSubsection,
  [class*="_settingsPanel_"],
  [class*="_settingsTab_"],
  [class*="_settingsSection_"] {
    width: 100% !important;
    overflow-x: hidden !important;
  }
  /* Prevent colour swatches / toggle rows from forcing horizontal scroll */
  .mx_ThemeSelectors,
  [class*="_themeSelectors_"],
  [class*="_themeSelector_"] {
    flex-wrap: wrap !important;
    overflow-x: hidden !important;
  }
}

/* ---- 9E: BOTTOM WHITE SPACE (item 8) ----
   The large empty area below the single room tile on mobile is
   Element's default home column background bleeding through as dark
   forest. It is not "white space" per se — it's just empty dark-green.
   There is no clean CSS fix to "fill" it with content. The visual
   improvement is to ensure the room list area reaches the bottom and
   a subtle gradient doesn't make it look like an abrupt cutoff.
   (Items 8 is a UX/content issue as much as a CSS one —
   more rooms will fix it organically.) */
@media (max-width: 480px) {
  body[data-ummahchat-theme="active"] .mx_RoomView,
  body[data-ummahchat-theme="active"] .mx_MainSplit,
  .mx_RoomView,
  .mx_MainSplit {
    min-height: 100vh !important;
  }
}

/* ====================================================================
   SECTION 10 — SETTINGS NAV CONTRAST (BUG-tafjeera-day1-item3, Jun 16)
   Root cause: the Settings left-nav uses the built-in Compound token
   --cpd-color-bg-interactive-hovered for the active (selected) tab
   highlight. This resolves to a very light grey (#f4f4f4 range) in
   Light/UmmahChat theme. Element renders the label text in
   --cpd-color-text-on-solid-primary (white) OR in a low-contrast
   color that reads white/near-white on that grey. Result: the selected
   tab label ("Appearance", "Account", etc.) is effectively invisible.
   Fix: force dark forest text on the selected item, and ensure the
   active-item background is our cream (#FAF8F3) with a left gold
   border so it's visually clear without a contrast problem.
   Targets: Element 1.12.20 uses both mx_TabbedView_tabLabel_active
   (old-style) and hashed Compound classes on [aria-selected="true"]
   within the vertical tab list inside .mx_UserSettingsDialog.
   ==================================================================== */

/* Settings left-nav: active item — dark text on cream, gold accent border */
.mx_UserSettingsDialog .mx_TabbedView_tabLabel_active,
.mx_UserSettingsDialog .mx_TabbedView_tabLabel_active .mx_TabbedView_tabLabel_text,
.mx_UserSettingsDialog [role="tab"][aria-selected="true"],
.mx_UserSettingsDialog [role="tab"][aria-selected="true"] span,
.mx_UserSettingsDialog [class*="_tabLabel_"][aria-selected="true"],
.mx_UserSettingsDialog [class*="_tabLabel_"][aria-selected="true"] span,
.mx_UserSettingsDialog [class*="_activeTab_"],
.mx_UserSettingsDialog [class*="_activeTab_"] span {
  color: #0A2C17 !important;
  background-color: #f0ebe0 !important;
  border-left: 3px solid #C8912E !important;
  font-weight: 600 !important;
}

/* Settings left-nav: non-active items — dark readable text (not light grey on white) */
.mx_UserSettingsDialog .mx_TabbedView_tabLabel,
.mx_UserSettingsDialog [role="tab"],
.mx_UserSettingsDialog [class*="_tabLabel_"] {
  color: #20302a !important;
}

/* Settings left-nav: hover state */
.mx_UserSettingsDialog .mx_TabbedView_tabLabel:hover,
.mx_UserSettingsDialog [role="tab"]:hover {
  background-color: rgba(22,101,52,0.07) !important;
  color: #0A2C17 !important;
}

/* Settings nav icon — force dark color so icons match the dark text */
.mx_UserSettingsDialog .mx_TabbedView_tabLabel .mx_TabbedView_maskedIcon,
.mx_UserSettingsDialog [role="tab"] svg,
.mx_UserSettingsDialog [class*="_tabLabel_"] svg {
  color: #166534 !important;
  fill: currentColor !important;
}

/* Active tab icon — gold accent */
.mx_UserSettingsDialog .mx_TabbedView_tabLabel_active .mx_TabbedView_maskedIcon,
.mx_UserSettingsDialog [role="tab"][aria-selected="true"] svg {
  color: #C8912E !important;
  fill: currentColor !important;
}

/* Ensure the settings content area (right panel) is cream-white */
.mx_UserSettingsDialog .mx_TabbedView_tabPanel,
.mx_UserSettingsDialog [class*="_tabPanel_"] {
  background-color: #FAF8F3 !important;
}

/* Settings section headings and body text — high contrast */
.mx_UserSettingsDialog .mx_SettingsSubsection_heading,
.mx_UserSettingsDialog .mx_SettingsSection_subHeading,
.mx_UserSettingsDialog [class*="_heading_"],
.mx_UserSettingsDialog [class*="_subHeading_"] {
  color: #0A2C17 !important;
}

/* ====================================================================
   SECTION 11 — THEME-SWITCH FOUC SUPPRESSOR (Issues 1+2, Jun 16 2026)
   When the user switches themes in Settings → Appearance, Element:
   (1) Sets link[data-mx-theme].disabled=true on the current theme
   (2) Sets link[data-mx-theme].disabled=false on the new theme
   Between steps 1 and 2 there is a ~frame-or-two gap where NEITHER
   theme's CSS applies, and our body[data-ummahchat-theme] attribute may
   not yet be updated (the body.class MutationObserver fires on the
   classList change, but the classList change happens AFTER the link
   swap). Result: the UI briefly shows an "unstyled" or wrong-theme
   state — the sidebar goes white/broken — before snapping to the new
   theme. Tafjeera described this as "crashes for a sec / looks broken
   and improperly formatted with overlapping elements."
   Fix: during the brief transition window, freeze the sidebar colors
   to avoid the jarring flash. We can't suppress the reflow entirely,
   but we can ensure the left panel never goes to a pure-white/blank
   state by setting a neutral dark fallback on the SpacePanel that
   applies BEFORE theme-class changes reach us.
   The key insight: when NEITHER cpd-theme-light NOR cpd-theme-dark is
   on body (the transition gap), our fallback on :root applies. So we
   give the space panel a neutral forest background on :root that
   matches both the UmmahChat theme and the built-in dark theme roughly.
   Also: add a CSS transition on the sidebar background so the color
   change is a short fade (100ms) rather than an instant jarring flash.
   ==================================================================== */

/* Smooth the background-color transition on the left panel during theme switches.
   100ms is long enough to hide the FOUC but short enough to feel instant. */
.mx_SpacePanel,
.mx_LeftPanel,
.mx_LeftPanel_outerWrapper,
.mx_RoomListPanel,
.mx_RoomList {
  transition: background-color 100ms ease !important;
}

/* Fallback: in the brief gap where no theme class is set on body,
   keep the SpacePanel in a neutral dark state (never flash pure white). */
.mx_SpacePanel {
  background-color: #0A2C17;
}

/* ====================================================================
   SECTION 12 — AVATAR CLIP FIX: COLLAPSED SPACEPANEL (Issue 6, Jun 16)
   Root cause: tafjeera Day 2 screenshot shows the profile picture is
   "half-visible when the expand icon is collapsed". The SpacePanel in
   collapsed state (mx_SpacePanel_collapsed or the toggle at left edge)
   makes the UserMenu trigger button smaller, and the overflow:hidden on
   .mx_SpacePanel .mx_UserMenu clips the avatar circle on its left edge.
   The Section 9C mobile fix sets overflow:visible on mobile but only
   for @media (max-width:480px). The collapsed SpacePanel can occur on
   desktop too when the user clicks the collapse chevron.
   Fix: When the SpacePanel is collapsed (class mx_SpacePanel_collapsed
   OR the toggle is visible / aria-expanded="false"), override the
   padding and overflow so the avatar is never clipped.
   The avatar container in collapsed state needs overflow:visible so
   the circle doesn't get cut on the left edge when padding-right:30px
   pushes the visible area inward.
   ==================================================================== */

/* Collapsed SpacePanel: avatar must not be clipped */
.mx_SpacePanel_collapsed .mx_UserMenu,
.mx_SpacePanel[data-collapsed="true"] .mx_UserMenu {
  overflow: visible !important;
  padding-right: 0 !important;
}
.mx_SpacePanel_collapsed .mx_UserMenu ._triggerButton_1yvpq_57,
.mx_SpacePanel[data-collapsed="true"] .mx_UserMenu ._triggerButton_1yvpq_57 {
  max-width: none !important;
  justify-content: center !important;
}

/* When SpacePanel is narrow (collapsed to icon-only width ~68px),
   center the avatar and give it full width */
@media (max-width: 68px), (max-device-width: 68px) {
  .mx_SpacePanel .mx_UserMenu {
    overflow: visible !important;
    padding-right: 0 !important;
  }
}

/* Belt-and-suspenders: avatar container — always show full circle.
   The clip-path:circle() ensures even under overflow:hidden the avatar
   is rendered as a circle and not chopped. */
.mx_SpacePanel ._triggerButton_1yvpq_57 > *:first-child {
  clip-path: circle(50% at 50% 50%) !important;
}

/* ====================================================================
   SECTION 13 — DM SEARCH / PEOPLE PICKER + START CHAT (BUG-311 polish)
   The "Send a message" / people-search dialog uses Compound classes.
   On UmmahChat theme: ensure the search box is cream, text is dark,
   and the dialog backdrop and panel are fully branded.
   ==================================================================== */

/* Search dialog / user-finder panel */
.mx_InviteDialog,
.mx_InviteDialog_content,
.mx_InviteDialog_addressBar,
[class*="_inviteDialog_"],
[class*="_dialog_"] .mx_InviteDialog {
  background-color: #FAF8F3 !important;
  color: #20302a !important;
}

.mx_InviteDialog_filterText,
.mx_InviteDialog_addressBar input,
[class*="_filterInput_"],
[class*="_searchBox_"] input {
  background-color: #fff !important;
  color: #20302a !important;
  border: 1px solid #d1c9b8 !important;
}

/* Suggested user tiles in the DM picker */
.mx_InviteDialog_roomTile,
[class*="_roomTile_"]:not(.mx_LeftPanel *) {
  color: #20302a !important;
}
.mx_InviteDialog_roomTile:hover,
[class*="_roomTile_"]:not(.mx_LeftPanel *):hover {
  background-color: #f0ebe0 !important;
}
.mx_InviteDialog_roomTile_name,
.mx_InviteDialog_roomTile_userId,
[class*="_tileName_"],
[class*="_tileSubtitle_"] {
  color: #20302a !important;
}

/* The "Go" / "Send DM" button in the people picker */
.mx_InviteDialog .mx_AccessibleButton_kind_primary {
  background-color: #166534 !important;
  color: #FAF8F3 !important;
}

/* ====================================================================
   SECTION 14 — ROOM HEADER COMPREHENSIVE POLISH (Jun 16 2026)
   Ensures room header (name, topic, call/search buttons) are all
   consistently styled on cream bg.
   ==================================================================== */

/* Call / video / search buttons in the header toolbar */
.mx_RoomHeader_button,
.mx_LegacyRoomHeader_button,
[class*="_headerButton_"],
[class*="_iconButton_"]:not(.mx_SpacePanel *):not(.mx_LeftPanel *) {
  color: #166534 !important;
}
.mx_RoomHeader_button:hover,
.mx_LegacyRoomHeader_button:hover,
[class*="_headerButton_"]:hover {
  background-color: rgba(22,101,52,0.08) !important;
}

/* Room avatar in header */
.mx_RoomHeader .mx_BaseAvatar,
.mx_LegacyRoomHeader .mx_BaseAvatar {
  border: 1.5px solid rgba(200,145,46,0.35) !important;
}

/* Verify badge (right panel / member list context) */
.mx_VerificationRequestBanner { display: none !important; }

/* ====================================================================
   SECTION 15 — RIGHT PANEL POLISH (member list, user info, room info)
   ==================================================================== */

/* Right panel background */
.mx_RightPanel,
.mx_BaseCard,
.mx_BaseCard_body,
[class*="_rightPanel_"],
[class*="_rightPanelPhase_"] {
  background-color: #FAF8F3 !important;
}

/* Member tile: name + MXID + avatar ring */
.mx_MemberTile,
.mx_EntityTile {
  color: #20302a !important;
}
.mx_MemberTile:hover,
.mx_EntityTile:hover {
  background-color: #f0ebe0 !important;
}
.mx_MemberTile .mx_MemberTile_name,
.mx_EntityTile_name,
.mx_MemberTile_name { color: #0A2C17 !important; font-weight: 500 !important; }
.mx_EntityTile_subLabel { color: #6b7a70 !important; }

/* Right panel base card header */
.mx_BaseCard_header {
  background-color: #FAF8F3 !important;
  border-bottom: 1px solid #e8e0d0 !important;
}
.mx_BaseCard_header h2,
.mx_BaseCard_header [class*="_heading_"] {
  color: #0A2C17 !important;
  font-weight: 600 !important;
}

/* User info card (click on an avatar => right panel) */
.mx_UserInfo {
  background-color: #FAF8F3 !important;
}
.mx_UserInfo_profile_displayName {
  color: #0A2C17 !important;
  font-weight: 700 !important;
}
.mx_UserInfo_profile_mxid {
  color: #6b7a70 !important;
}
/* E2EE device list in user info — hide (non-E2EE product) */
.mx_UserInfo_devices,
.mx_DeviceInfo,
.mx_DeviceInfoVerified { display: none !important; }

/* Room settings right panel */
.mx_RoomSummaryCard,
.mx_RoomSummaryCard_topic,
[class*="_summaryCard_"] { background-color: #FAF8F3 !important; color: #20302a !important; }

/* ====================================================================
   SECTION 16 — MODAL AND DIALOG POLISH
   Element uses mx_Dialog + mx_Dialog_border + Compound dialog classes.
   ==================================================================== */

.mx_Dialog,
.mx_Dialog_wrapper,
.mx_Dialog_border,
[class*="_dialog_"],
[class*="_dialogContent_"] {
  background-color: #FAF8F3 !important;
  color: #20302a !important;
}

/* Dialog title */
.mx_Dialog h2,
.mx_Dialog h3,
.mx_Dialog_title,
[class*="_dialogTitle_"],
[class*="_title_"][class*="_dialog_"] {
  color: #0A2C17 !important;
  font-weight: 700 !important;
}

/* Backdrop */
.mx_Dialog_background {
  background-color: rgba(10,44,23,0.6) !important;
}

/* Dialog close button */
.mx_Dialog_cancelButton,
.mx_Dialog_closeButton,
[class*="_closeButton_"] {
  color: #6b7a70 !important;
}
.mx_Dialog_cancelButton:hover,
.mx_Dialog_closeButton:hover { color: #0A2C17 !important; }

/* Dialog input fields */
.mx_Dialog input[type="text"],
.mx_Dialog input[type="email"],
.mx_Dialog input[type="password"],
.mx_Dialog textarea,
[class*="_dialog_"] input,
[class*="_dialog_"] textarea {
  background-color: #fff !important;
  border: 1px solid #d1c9b8 !important;
  color: #20302a !important;
}
.mx_Dialog input:focus,
.mx_Dialog textarea:focus {
  border-color: #166534 !important;
  outline: none !important;
  box-shadow: 0 0 0 2px rgba(22,101,52,0.15) !important;
}

/* Dialog action buttons */
.mx_Dialog_buttons .mx_AccessibleButton_kind_primary,
.mx_Dialog .mx_AccessibleButton_kind_primary {
  background-color: #166534 !important;
  color: #FAF8F3 !important;
}
.mx_Dialog_buttons .mx_AccessibleButton_kind_secondary,
.mx_Dialog .mx_AccessibleButton_kind_secondary {
  border-color: #166534 !important;
  color: #166534 !important;
}

/* ====================================================================
   SECTION 17 — SEARCH OVERLAY (Ctrl+K global search)
   ==================================================================== */
.mx_SpotlightDialog,
.mx_SpotlightDialog_wrapper,
[class*="_spotlightDialog_"] {
  background-color: #FAF8F3 !important;
}
.mx_SpotlightDialog_searchBox,
.mx_SpotlightDialog_searchBox input,
[class*="_searchBox_"] input {
  background-color: #fff !important;
  color: #20302a !important;
  border-bottom: 1px solid #e8e0d0 !important;
}
.mx_SpotlightDialog_option,
[class*="_option_"][class*="_spotlight_"] {
  color: #20302a !important;
}
.mx_SpotlightDialog_option:hover,
[class*="_option_"][class*="_spotlight_"]:hover {
  background-color: #f0ebe0 !important;
}
[class*="_optionSection_"],
.mx_SpotlightDialog_section h4 { color: #6b7a70 !important; font-size: 11px !important; text-transform: uppercase !important; letter-spacing: .08em !important; }

/* ====================================================================
   SECTION 18 — BRANDED NOTIFICATIONS + CALL BANNER
   (The mx_ToastContainer was fully suppressed in Section 0 for E2EE
    noise. Keep it hidden there. Only style non-suppressed alerts.)
   ==================================================================== */

/* Call invites / room invites (mx_IncomingLegacyCallToast is a separate component) */
.mx_IncomingLegacyCallToast,
.mx_IncomingCallToast,
[class*="_callToast_"] {
  background-color: #0A2C17 !important;
  color: #FAF8F3 !important;
  border: 1px solid #C8912E !important;
}

/* ====================================================================
   SECTION 19 — COMPOSER FULL POLISH
   ==================================================================== */

/* Composer container */
.mx_MessageComposer {
  background-color: #ffffff !important;
  border-top: 1px solid #e8e0d0 !important;
}

/* Reply preview strip */
.mx_ReplyPreview,
.mx_ReplyTile {
  background-color: #f0ebe0 !important;
  border-left: 3px solid #C8912E !important;
}
.mx_ReplyPreview_message { color: #20302a !important; }
.mx_ReplyPreview_header { color: #166534 !important; font-weight: 600 !important; }

/* Mention autocomplete / pill suggestions */
.mx_CompleteUserBar,
.mx_UserPillWithAvatar,
[class*="_mentionSuggestions_"],
[class*="_autocomplete_"] {
  background-color: #FAF8F3 !important;
  border: 1px solid #e8e0d0 !important;
  box-shadow: 0 4px 16px rgba(10,44,23,0.15) !important;
}
.mx_Autocomplete_Container .mx_Autocomplete_Completion {
  color: #20302a !important;
}
.mx_Autocomplete_Container .mx_Autocomplete_Completion_selected,
.mx_Autocomplete_Container .mx_Autocomplete_Completion:hover {
  background-color: #f0ebe0 !important;
}

/* Formatted mention pills (the @name chip inline in a message) */
.mx_UserPill,
.mx_RoomPill,
.mx_EventPill {
  background-color: rgba(22,101,52,0.12) !important;
  color: #0A2C17 !important;
  border: 1px solid rgba(22,101,52,0.25) !important;
}

/* ====================================================================
   SECTION 20 — EMOJI PICKER + REACTION PICKER
   ==================================================================== */
.mx_EmojiPicker,
.mx_ReactionPicker,
.mx_EmojiPicker_body,
[class*="_emojiPicker_"],
[class*="_reactionPicker_"] {
  background-color: #FAF8F3 !important;
  border: 1px solid #e8e0d0 !important;
  box-shadow: 0 4px 16px rgba(10,44,23,0.15) !important;
}
.mx_EmojiPicker_header,
.mx_EmojiPicker_search_container { background-color: #f0ebe0 !important; border-bottom: 1px solid #e8e0d0 !important; }
.mx_EmojiPicker_search { background-color: #fff !important; color: #20302a !important; }
.mx_EmojiPicker_category_label { color: #6b7a70 !important; }
.mx_EmojiPicker_item:hover { background-color: #f0ebe0 !important; }
/* Reaction row on messages */
.mx_ReactionsRow { margin-top: 4px !important; }
.mx_ReactionsRowButton {
  background-color: #FAF8F3 !important;
  border: 1px solid #d1c9b8 !important;
  color: #20302a !important;
}
.mx_ReactionsRowButton:hover { background-color: #f0ebe0 !important; }
.mx_ReactionsRowButton_selected { background-color: rgba(22,101,52,0.12) !important; border-color: #166534 !important; }

/* ====================================================================
   SECTION 21 — CONTEXT MENUS (MESSAGE ACTIONS, ROOM OPTIONS)
   ==================================================================== */
.mx_IconizedContextMenu,
.mx_ContextualMenu,
[class*="_contextMenu_"],
[class*="_menu_"]:not(.mx_LeftPanel *) {
  background-color: #FAF8F3 !important;
  border: 1px solid #e8e0d0 !important;
  box-shadow: 0 4px 24px rgba(10,44,23,0.18) !important;
  color: #20302a !important;
}
.mx_IconizedContextMenu_optionList .mx_IconizedContextMenu_option,
.mx_ContextualMenu_item,
[class*="_menuItem_"] {
  color: #20302a !important;
}
.mx_IconizedContextMenu_optionList .mx_IconizedContextMenu_option:hover,
.mx_ContextualMenu_item:hover,
[class*="_menuItem_"]:hover {
  background-color: #f0ebe0 !important;
}
/* Destructive items (Leave, Delete, Kick) */
.mx_IconizedContextMenu_option.mx_IconizedContextMenu_option_red,
.mx_ContextualMenu_item[class*="danger"],
[class*="_menuItem_"][class*="_danger_"] {
  color: #b91c1c !important;
}
/* Separator line */
.mx_IconizedContextMenu_separator { border-color: #e8e0d0 !important; }

/* ====================================================================
   SECTION 22 — TIMELINE POLISH: code blocks, quotes, read receipts
   ==================================================================== */

/* Code blocks */
.mx_EventTile_content code,
.mx_EventTile_content pre,
code, pre {
  background-color: #f0ebe0 !important;
  border: 1px solid #d1c9b8 !important;
  color: #0A2C17 !important;
  border-radius: 4px !important;
}

/* Block quote */
.mx_EventTile_content blockquote,
blockquote {
  border-left: 3px solid #C8912E !important;
  background-color: rgba(200,145,46,0.06) !important;
  color: #20302a !important;
}

/* Read receipts row */
.mx_EventTile_readAvatars { opacity: 0.85 !important; }
.mx_ReadReceiptGroup_container { margin-top: 2px !important; }

/* Image/video thumbnails in timeline */
.mx_MImageBody,
.mx_MVideoBody {
  border-radius: 8px !important;
  overflow: hidden !important;
}

/* URL preview card */
.mx_LinkPreviewWidget {
  border-left: 3px solid #C8912E !important;
  background-color: #f8f4ec !important;
}
.mx_LinkPreviewWidget_title { color: #0A2C17 !important; font-weight: 600 !important; }
.mx_LinkPreviewWidget_description { color: #6b7a70 !important; }

/* Typing indicator */
.mx_TypingIndicator { color: #6b7a70 !important; }
.mx_TypingIndicator_avatars { opacity: 0.9 !important; }

/* ====================================================================
   SECTION 23 — INTERN POLISH SWEEP (BUG-309/308/322/321, Jun 18 2026)
   ==================================================================== */

/* ---- BUG-309: HOME CAPTION CENTERING ----
   Root cause: mx_HomePage contains our welcome.html iframe PLUS Element's
   quick-action tiles (Start Chat, Browse Rooms, etc.) below it. The ::after
   pseudo-element on .mx_HomePage (bottom:24px, position:absolute) was rendered
   OVER those quick-action icons — it wasn't visible as a distinct caption.
   The welcome.html already carries amanah branding ("Straight talk: not E2EE").
   Fix: remove ::after from .mx_HomePage so there is no caption overlapping the
   quick-action buttons; keep the amanah caption on .mx_RoomView_empty where it
   genuinely adds value (empty chat view, no icons to overlap).
   The caption text is kept — it lives in the empty room-view state only.
   ----------------------------------------------------------------- */
.mx_HomePage::after {
  display: none !important;
}

/* ---- BUG-308: DESKTOP AVATAR CLIP WHEN SPACEPANEL COLLAPSED ----
   Element v1.12.20 uses several mechanisms to signal panel collapse:
     - Class mx_SpacePanel_collapsed on the SpacePanel itself (primary)
     - Inline style width changes
     - CSS variable --mx-SpacePanel-width approaching 0
   The Section 12 fix used .mx_SpacePanel_collapsed which may not fire on all
   Element builds. This additional block covers the case where the SpacePanel
   becomes narrow enough that overflow:hidden clips the avatar — we detect
   "narrow panel" via a max-width media query equivalent using the container
   query or a fixed-width threshold, and we also add [aria-expanded="false"]
   on the toggle button as a secondary hook.
   Belt-and-suspenders: also target when .mx_SpacePanel width ≤ 72px
   (collapsed icon-only width) by detecting the sibling toggle state. ---- */

/* When SpacePanel has the collapsed class OR the toggle shows collapsed state */
.mx_SpacePanel_collapsed .mx_UserMenu,
.mx_SpacePanel[data-collapsed="true"] .mx_UserMenu,
.mx_SpacePanel:has(.mx_SpacePanel_toggleCollapse[aria-expanded="false"]) .mx_UserMenu {
  overflow: visible !important;
  padding-right: 0 !important;
  min-width: 40px !important;
}
.mx_SpacePanel_collapsed ._triggerButton_1yvpq_57,
.mx_SpacePanel[data-collapsed="true"] ._triggerButton_1yvpq_57,
.mx_SpacePanel:has(.mx_SpacePanel_toggleCollapse[aria-expanded="false"]) ._triggerButton_1yvpq_57 {
  max-width: none !important;
  justify-content: center !important;
  overflow: visible !important;
}

/* ---- BUG-322 MOBILE: MESSAGE FIELD + SIDEBAR LOCK ----
   Three specific issues from the mobile audit:
   (a) Message compose field overflows the viewport bottom — the main split
       flex container needs min-height:0 and the composer is pushed off-screen
       by flex-grow. Fix: ensure the chat body uses flex properly so the
       composer anchors to the bottom within the viewport.
   (b) Closing the sidebar after picking a user → whole page horizontally
       scrollable + sidebar stuck. Root cause: the room-list panel stays
       in-flow after the user picker closes, causing a transient layout
       expansion. Fix: overflow-x:hidden on the app root and the main split.
   (c) User details hug the top bar — the main content area needs padding-top
       to clear the fixed header.
   ----------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Prevent horizontal scroll on the root app container */
  #matrixchat,
  .mx_MatrixChat,
  .mx_MatrixChat_wrapper,
  .mx_LoggedInView,
  [class*="_loggedInView_"] {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  /* The main layout wrapper — prevent overflow */
  .mx_MainSplit,
  [class*="_mainSplit_"] {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  /* Room view body — flex layout should fill height correctly */
  .mx_RoomView_body {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  /* Message composer — anchor to bottom of the flex container, full width */
  .mx_MessageComposer {
    flex-shrink: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }

  /* Left panel (room list) — when closed on mobile, should not create a
     horizontal scroll ghost. Element animates it in/out by translating;
     when translate causes overflow we need to contain it. */
  .mx_LeftPanel,
  .mx_LeftPanel_outerWrapper,
  [class*="_leftPanel_"] {
    max-width: 100vw !important;
  }

  /* Room view wrapper — ensure full height is used and nothing bleeds */
  .mx_RoomView,
  [class*="_roomView_"] {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  /* User details (right panel) padding from the top header */
  .mx_RightPanel,
  .mx_BaseCard {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }
}

/* ---- BUG-321: @MENTION PILL CLICK — ENSURE CLICKABLE ----
   Element's @mention pills (mx_UserPill) are rendered as <span> elements
   inside message bubbles. They should open a right-panel user info card
   on click. In some states a parent element's overflow:hidden or a
   pointer-events:none on an ancestor can silently consume the click.
   Fix: explicitly set pointer-events:all on the pill and its immediate
   children, and ensure z-index places it above any background overlays.
   Note: the handle-strip script only rewrites text nodes and does not
   change click handlers or data attributes. ---- */
.mx_UserPill,
.mx_RoomPill,
.mx_EventPill {
  pointer-events: all !important;
  cursor: pointer !important;
  position: relative !important;
  z-index: 1 !important;
}
.mx_UserPill:hover,
.mx_RoomPill:hover {
  background-color: rgba(22,101,52,0.22) !important;
  border-color: rgba(22,101,52,0.45) !important;
}

/* Mention pill in the composer input (autocomplete tokens) — also must be clickable */
.mx_UserPillWithAvatar,
[class*="_userPill_"],
[class*="_pill_"][class*="_mention_"] {
  pointer-events: all !important;
  cursor: pointer !important;
}
