/* JaChat — homepage action buttons */
.mx_HomePage_default .mx_HomePage_default_buttons .mx_AccessibleButton {
    background-color: #D57F22 !important;
}

.mx_HomePage_default .mx_HomePage_default_buttons .mx_AccessibleButton:hover,
.mx_HomePage_default .mx_HomePage_default_buttons .mx_AccessibleButton:focus-visible {
    background-color: #D57F22 !important;
    filter: brightness(0.92);
}

/* Hide "Explore Public Rooms" (private server, no public directory) */
.mx_HomePage_default .mx_HomePage_default_buttons .mx_HomePage_button_explore {
    display: none !important;
}

.mx_HomePage_default .mx_HomePage_default_buttons {
    grid-template-columns: repeat(2, 1fr) !important;
}

/* Registration disabled on Synapse — hide Create account (Element 1.12+ welcome bug) */
.mx_DefaultWelcome_buttons_register,
.mx_DefaultWelcome .mx_DefaultWelcome_buttons a[href="#/register"],
.mx_ButtonCreateAccount,
.mx_AuthBody a[href="#/register"],
.mx_Login a[href="#/register"] {
    display: none !important;
}

/* JaChat — M365-only login (hide password / homeserver form) */
.mx_AuthPage .mx_ServerPicker,
.mx_AuthPage .mx_Login_underlinedServerName,
.mx_AuthPage .mx_Field:has(#mx_LoginForm_username),
.mx_AuthPage .mx_Field:has(#mx_LoginForm_password),
.mx_AuthPage .mx_Login_submit,
.mx_AuthPage .mx_Login_forgot,
.mx_AuthPage .mx_AuthBody_forgot {
    display: none !important;
}

/* Animated auth logo — login sidebar */
.mx_AuthHeaderLogo {
    display: block !important;
    text-align: center;
    overflow: hidden;
    padding: 0.75rem 0.5rem 0.25rem;
}

.mx_AuthHeaderLogo img {
    width: 130px !important;
    height: auto !important;
    max-width: 100% !important;
    display: block;
    margin: 0 auto;
}

/* Welcome page — centered, slightly smaller than before */
.mx_DefaultWelcome_logo img,
.mx_WelcomePage_logo img {
    width: min(180px, 52vw) !important;
    height: auto !important;
    max-width: 100% !important;
    display: block;
    margin: 0 auto 0.5rem;
    padding: 0 0.5rem;
    box-sizing: border-box;
}

.mx_DefaultWelcome_logo {
    display: block !important;
    text-align: center;
    overflow: hidden;
}

/* Hide Matrix Spaces (JaChat: flat list of DMs + groups only).
   User menu (avatar / settings) lives inside .mx_SpacePanel — hide space UI only. */
.mx_SpacePanel .mx_SpaceItem,
.mx_SpacePanel .mx_SpaceItem_new,
.mx_SpacePanel .mx_SpaceTreeLevel,
.mx_SpacePanel .mx_SpaceButton,
.mx_SpacePanel .mx_SpaceButton_new,
.mx_SpacePanel .mx_SpaceButton_newCancel,
.mx_SpacePanel .mx_SpacePanel_toggleCollapse,
.mx_SpacePanel_contextMenu,
.mx_SpaceCreateMenu_wrapper,
.mx_SpaceCreateMenu_back,
.mx_SpaceRoomView,
.mx_SpaceHierarchy_list,
.mx_SpaceHierarchy_listHeader,
.mx_SpaceSettingsDialog,
.mx_SpaceSettingsDialog_content,
.mx_SpacePreferencesDialog,
.mx_SpaceBasicSettings,
.mx_SpaceSetupFirstRooms,
.mx_SpaceSetupPrivateInvite,
.mx_SpaceChildrenPicker,
.mx_SpacePill,
.mx_SpacePillButton,
.mx_AddExistingToSpace,
.mx_AddExistingToSpaceDialog,
.mx_AddExistingToSpaceDialog_wrapper,
.mx_CreateSubspaceDialog,
.mx_CreateSubspaceDialog_wrapper,
.mx_LeaveSpaceDialog,
.mx_LeaveSpaceDialog_wrapper,
.mx_ConfirmSpaceUserActionDialog,
.mx_ConfirmSpaceUserActionDialog_wrapper,
.mx_SubspaceSelector,
.mx_SpotlightDialog_metaspaceResult,
.mx_JoinRuleSettings_spacesWithAccess,
.mx_ManageRestrictedJoinRuleDialog_section_spaces {
    display: none !important;
}

/* Narrow strip: profile menu only (no space/home buttons) */
.mx_SpacePanel {
    width: 68px !important;
    min-width: 68px !important;
    flex: 0 0 68px !important;
}

.mx_SpacePanel .mx_UserMenu {
    display: block !important;
}

/* M365 SSO — QR device linking not supported by account provider */
.mx_SettingsSubsection:has(.mx_LoginWithQRSection) {
    display: none !important;
}

/* M365 SSO — phone numbers and local password not used */
.mx_SettingsSubsection:has(.mx_PhoneNumbers_country) {
    display: none !important;
}

.mx_SettingsSubsection:has(input[autocomplete="new-password"]) {
    display: none !important;
}

/* Identity server / discovery — not used on JaChat (M365 + fixed homeserver) */
.mx_SettingsSection:has(.mx_IdentityServerPicker) {
    display: none !important;
}

/* Help & About — hide Element stock credits (cover photo, Twemoji, …) */
.mx_SettingsSubsection:has(a[href*="backgrounds/lake.jpg"]) {
    display: none !important;
}

/* Labs — hidden (beta/experimental features not for end users) */
.mx_TabbedView_tabLabel[aria-controls="mx_tabpanel_USER_LABS_TAB"],
.mx_TabbedView_tabLabel:has(#mx_tabpanel_USER_LABS_TAB_label),
#mx_tabpanel_USER_LABS_TAB,
#mx_tabpanel_USER_LABS_TAB_label {
    display: none !important;
}

/*
 * Element's own identity reset deletes the account's key backup and recovery key before it asks for
 * the interactive auth that an intranet-only user cannot give, and then fails. The widget's Reset is
 * the one reset, so every way into Element's is closed at its last step or its entry:
 * - "Continue" of the reset page, which "Forgot recovery key?" (Settings, Encryption) and
 *   "Continue with reset" lead to. Compound gives the destructive button a hashed class, so it is
 *   found by that name part. The "delete key storage" page has the same buttons but two list items
 *   where the reset page has three, so the third item tells them apart. "Yes, dismiss" and "Go to
 *   Settings" in the key-storage dialog are not destructive and stay.
 * - "Can't confirm?" on the forced verification screen.
 * - Reset cryptographic identity in the Advanced panel.
 */
.mx_SetupEncryptionBody .mx_EncryptionCard_buttons > button[data-kind="secondary"],
.mx_EncryptionDetails > button[data-kind="tertiary"] {
    display: none !important;
}

/* Its own rule: a browser that cannot parse :has() drops only this one. */
.mx_EncryptionCard:has(ul > li:nth-child(3)) > .mx_EncryptionCard_buttons > button[data-kind="primary"][class*="_destructive_"] {
    display: none !important;
}
