/* FGG Hub — login + in-app polish */

html:has(.mx_AuthPage),
body:has(.mx_AuthPage),
body:has(.mx_AuthPage) .mx_AuthPage {
  height: 100dvh !important;
  max-height: 100dvh !important;
  overflow: auto !important;
}

.mx_AuthPage {
  background: url("/fgg_background.jpg?v=30") center center / cover no-repeat fixed !important;
  background-color: #060c1a !important;
  color: rgba(255, 255, 255, 0.82) !important;
  --cpd-color-text-primary: #f8fafc !important;
  --cpd-color-text-secondary: rgba(255, 255, 255, 0.72) !important;
  --cpd-color-text-placeholder: rgba(255, 255, 255, 0.45) !important;
  --cpd-color-text-disabled: rgba(255, 255, 255, 0.4) !important;
  --cpd-color-text-action-accent: #93c5fd !important;
}

.mx_AuthPage_modalBlur,
.mx_AuthPage_modal_withBlur::before,
.mx_AuthHeader,
.mx_AuthFooter,
.mx_MobileNudge,
.mx_AuthPage .mx_ServerPicker,
.mx_AuthPage .mx_AuthBody_editServerDetails,
.mx_AuthPage a[href*="matrix.org"],
.mx_AuthPage a[href*="element.io"],
.mx_AuthPage a[href*="matrix.to"] {
  display: none !important;
}

.mx_AuthPage_modal,
.mx_AuthPage_modal_withBlur,
.mx_AuthPage_modalContent {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
  border: none !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 100dvh !important;
  min-height: 0 !important;
  max-height: 100dvh !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  justify-content: safe center !important;
  position: relative !important;
  inset: auto !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: auto !important;
  gap: 0 !important;
  padding: 16px 0 !important;
  box-sizing: border-box !important;
}

.mx_AuthPage_modalContent {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  padding: 0 !important;
  flex: 0 0 auto !important;
}

.mx_AuthBody,
.mx_AuthBody_flex {
  background: rgba(8, 14, 28, 0.88) !important;
  backdrop-filter: blur(24px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 24px !important;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.75) !important;
  padding: 32px 32px 28px !important;
  width: min(440px, calc(100vw - 32px)) !important;
  max-width: 440px !important;
  height: auto !important;
  max-height: calc(100dvh - 32px) !important;
  min-height: 0 !important;
  flex: 0 0 auto !important;
  align-self: center !important;
  box-sizing: border-box !important;
  overflow: auto !important;
}

.mx_AuthBody::before {
  content: "";
  display: block;
  width: 220px;
  height: 72px;
  margin: 0 auto 18px;
  background: url("/fgg_logo_on_dark.png?v=16") no-repeat center center / contain;
}

.mx_AuthPage img[src="/fgg_logo.png"],
.mx_AuthPage img[src*="fgg_logo.png"]:not([src*="on_dark"]) {
  content: url("/fgg_logo_on_dark.png?v=16");
}

/* Envelope illustration on forgot-password — clashes with the FGG logo */
.mx_AuthBody_icon,
.mx_AuthBody_forgot-password > svg,
.mx_AuthPage .mx_AuthBody > svg.mx_AuthBody_icon {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
}

.mx_AuthPage h1 {
  color: #ffffff !important;
  font-weight: 600 !important;
  text-align: center !important;
}

.mx_AuthPage p,
.mx_AuthPage li,
.mx_AuthPage .mx_AuthBody p {
  color: rgba(255, 255, 255, 0.78) !important;
}

.mx_AuthPage .mx_Field {
  position: relative !important;
  margin: 0 0 12px !important;
  padding: 0 !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  border-radius: 12px !important;
  background: rgba(255, 255, 255, 0.08) !important;
  box-shadow: none !important;
  outline: none !important;
  overflow: hidden !important;
  min-height: 48px !important;
}

.mx_AuthPage .mx_AuthBody_fieldRow {
  display: flex !important;
  align-items: stretch !important;
  gap: 12px !important;
}

/* The register column is a flex child. If it shrinks to the viewport,
   the fields stay visible and paint on top of the footer. */
.mx_AuthPage .mx_Register_mainContent,
.mx_AuthPage .mx_Register_footerActions {
  flex: 0 0 auto !important;
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
}

.mx_AuthPage .mx_AuthBody_fieldRow > .mx_Field {
  flex: 1 1 0 !important;
  min-width: 0 !important;
  margin-bottom: 12px !important;
}

.mx_AuthPage .mx_Field:focus-within {
  border-color: #60a5fa !important;
  box-shadow: none !important;
}

.mx_AuthPage .mx_Field label,
.mx_AuthPage .mx_Field_label {
  display: none !important;
}

.mx_AuthPage input:not([type="checkbox"]):not([type="radio"]),
.mx_AuthPage .mx_Field input:not([type="checkbox"]):not([type="radio"]),
.mx_AuthPage textarea {
  display: block !important;
  width: 100% !important;
  height: 48px !important;
  margin: 0 !important;
  padding: 0 14px !important;
  background: transparent !important;
  border: none !important;
  border-radius: 12px !important;
  box-shadow: none !important;
  outline: none !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  caret-color: #ffffff !important;
}

.mx_AuthPage .mx_Field input::placeholder,
.mx_AuthPage .mx_Field input::-webkit-input-placeholder,
.mx_AuthPage textarea::placeholder {
  color: rgba(255, 255, 255, 0.45) !important;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.45) !important;
  opacity: 1 !important;
}

.mx_AuthPage input:-webkit-autofill,
.mx_AuthPage input:-webkit-autofill:hover,
.mx_AuthPage input:-webkit-autofill:focus,
.mx_AuthPage input:-webkit-autofill:active {
  -webkit-text-fill-color: #ffffff !important;
  caret-color: #ffffff !important;
  box-shadow: 0 0 0 1000px transparent inset !important;
  border: none !important;
  transition: background-color 99999s ease-out 0s !important;
}

.mx_AuthPage input:not([type="checkbox"]):not([type="radio"]):focus,
.mx_AuthPage .mx_Field input:not([type="checkbox"]):not([type="radio"]):focus {
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
}

.mx_AuthPage .mx_AccessibleButton_kind_primary,
.mx_AuthPage button[type="submit"] {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
  border: none !important;
  border-radius: 12px !important;
  box-shadow: 0 4px 18px rgba(37, 99, 235, 0.45) !important;
  color: #ffffff !important;
  font-weight: 600 !important;
}

.mx_AuthPage .mx_AuthBody_changeFlow {
  display: block !important;
  text-align: center !important;
  margin-top: 12px !important;
  color: rgba(255, 255, 255, 0.78) !important;
}

/* Compound keeps light-theme link tokens; those are invisible on the dark card. */
.mx_AuthPage a,
.mx_AuthPage a:visited,
.mx_AuthPage a:hover,
.mx_AuthPage .mx_AuthBody_changeFlow a,
.mx_AuthPage .mx_AuthBody_changeFlow button,
.mx_AuthPage .mx_AuthBody_changeFlow .mx_AccessibleButton,
.mx_AuthPage .mx_AuthBody_changeFlow [role="button"],
.mx_AuthPage .mx_AccessibleButton_kind_link,
.mx_AuthPage .mx_AccessibleButton_kind_link_inline,
.mx_AuthPage .mx_AccessibleButton_kind_link_sm,
.mx_AuthPage .mx_Login_forgot,
.mx_AuthPage .mx_AuthBody_forgotPassword,
.mx_AuthPage .mx_AuthBody_sign-in-instead-button,
.mx_AuthPage button.mx_AccessibleButton_kind_link,
.mx_AuthPage button.mx_AccessibleButton_kind_link_inline {
  color: #93c5fd !important;
}

.mx_AuthPage a:hover,
.mx_AuthPage .mx_AccessibleButton_kind_link:hover,
.mx_AuthPage .mx_AccessibleButton_kind_link_inline:hover,
.mx_AuthPage .mx_AuthBody_changeFlow a:hover,
.mx_AuthPage .mx_AuthBody_changeFlow .mx_AccessibleButton:hover {
  color: #bfdbfe !important;
}

.mx_AuthPage .mx_AccessibleButton_kind_link *,
.mx_AuthPage .mx_AccessibleButton_kind_link_inline *,
.mx_AuthPage .mx_AuthBody_changeFlow a *,
.mx_AuthPage .mx_Login_forgot * {
  color: inherit !important;
}

.mx_AuthPage .mx_AccessibleButton_kind_primary,
.mx_AuthPage .mx_AccessibleButton_kind_primary *,
.mx_AuthPage button[type="submit"],
.mx_AuthPage button[type="submit"] * {
  color: #ffffff !important;
}

.fgg-invite-decoy {
  position: absolute !important;
  left: -10000px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.fgg-invite-wrap {
  position: relative;
  margin: 0 0 12px !important;
}
.fgg-invite-hint {
  display: block;
  margin: -4px 0 14px;
  font-size: 12px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.55);
}

#fgg-help {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 30;
  width: 60px;
  height: 60px;
}

.fgg-help-btn {
  position: relative;
  z-index: 1;
  width: 60px;
  height: 60px;
  padding: 0;
  border: 1px solid rgba(186, 230, 253, 0.42);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, rgba(186, 230, 253, 0.42), transparent 52%),
    rgba(10, 18, 36, 0.9);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  color: #f8fbff;
  box-shadow:
    0 0 0 6px rgba(125, 211, 252, 0.12),
    0 0 28px rgba(125, 211, 252, 0.35),
    0 14px 36px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.fgg-help-btn:hover {
  color: #ffffff;
  border-color: rgba(191, 219, 254, 0.45);
}

.fgg-help-icon,
.fgg-help-close {
  width: 28px;
  height: 28px;
  grid-area: 1 / 1;
  filter: drop-shadow(0 0 8px rgba(186, 230, 253, 0.7));
}

.fgg-help-close {
  opacity: 0;
  transform: scale(0.7) rotate(-40deg);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.fgg-help-icon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

#fgg-help.is-open .fgg-help-icon {
  opacity: 0;
  transform: scale(0.7) rotate(40deg);
}

#fgg-help.is-open .fgg-help-close {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.fgg-help-pulse {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1.5px solid rgba(147, 197, 253, 0.55);
  box-shadow: 0 0 18px rgba(147, 197, 253, 0.28);
  animation: fgg-help-pulse 2.6s ease-out infinite;
  pointer-events: none;
}

.fgg-help-pulse--delay {
  animation-delay: 1.3s;
}

#fgg-help.is-open .fgg-help-pulse {
  animation: none;
  opacity: 0;
}

@keyframes fgg-help-pulse {
  0% {
    transform: scale(0.92);
    opacity: 0.75;
  }
  100% {
    transform: scale(1.55);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fgg-help-pulse {
    animation: none;
    opacity: 0.35;
  }
}

#fgg-onboard {
  position: absolute;
  right: 0;
  bottom: calc(100% + 14px);
  width: min(380px, calc(100vw - 32px));
  margin: 0;
  padding: 18px 22px 16px;
  background: rgba(8, 14, 28, 0.92);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
  color: rgba(255, 255, 255, 0.82);
  text-align: center;
  box-sizing: border-box;
  transform-origin: bottom right;
}

#fgg-onboard[hidden] {
  display: none !important;
}

.fgg-onboard-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #93c5fd;
}

.fgg-onboard-lead {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.86);
}

.fgg-onboard-lead strong,
.fgg-onboard-note strong {
  color: #ffffff;
  font-weight: 700;
}

.fgg-onboard-apps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 0 10px;
}

.fgg-onboard-app {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0 !important;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
}

.fgg-onboard-app:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff !important;
}

.fgg-onboard-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.58);
}

.fgg-consent {
  margin: 4px 0 16px;
  padding: 12px 14px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.fgg-consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.78);
}

.fgg-consent-row:last-child {
  margin-bottom: 0;
}

.fgg-consent-row input[type="checkbox"] {
  flex: 0 0 auto;
  width: 16px !important;
  height: 16px !important;
  margin: 3px 0 0 !important;
  padding: 0 !important;
  accent-color: #60a5fa;
  cursor: pointer;
}

.fgg-consent-row a {
  color: #93c5fd !important;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.fgg-legal-note {
  margin: 16px 0 0 !important;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px !important;
  line-height: 1.45 !important;
  color: rgba(255, 255, 255, 0.45) !important;
  text-align: center;
}

.fgg-legal-note a {
  color: #93c5fd !important;
}

/* Phones and short windows: scroll the page instead of crushing the card.
   Element sets contain:strict on #matrixchat, which freezes the page at the
   viewport height, so the form stacks on itself. */
@media (max-width: 760px), (max-height: 920px) {
  html:has(.mx_AuthPage),
  body:has(.mx_AuthPage) {
    height: auto !important;
    min-height: 100% !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body:has(.mx_AuthPage) #matrixchat {
    contain: none !important;
    height: auto !important;
    min-height: 100dvh !important;
    max-height: none !important;
    overflow: visible !important;
  }

  body:has(.mx_AuthPage) .mx_AuthPage {
    height: auto !important;
    min-height: 100dvh !important;
    max-height: none !important;
    overflow: visible !important;
    background-attachment: scroll !important;
  }

  .mx_AuthPage_modal,
  .mx_AuthPage_modal_withBlur,
  .mx_AuthPage_modalContent {
    height: auto !important;
    min-height: 100dvh !important;
    max-height: none !important;
    justify-content: center !important;
    justify-content: safe center !important;
    overflow: visible !important;
    padding: max(16px, env(safe-area-inset-top)) 0 max(16px, env(safe-area-inset-bottom)) !important;
  }

  .mx_AuthPage_modalContent {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 0 !important;
    flex: 0 0 auto !important;
  }

  .mx_AuthBody,
  .mx_AuthBody_flex {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    margin: 0 auto !important;
    padding: 22px 16px 18px !important;
  }

  .mx_AuthPage .mx_InteractiveTooltip {
    max-width: min(320px, calc(100vw - 48px)) !important;
    white-space: normal !important;
  }
}

@media (max-width: 760px) {
  .mx_AuthPage .mx_AuthBody_fieldRow {
    flex-direction: column !important;
    gap: 0 !important;
  }

  .mx_AuthPage .mx_AuthBody_fieldRow > .mx_Field {
    width: 100% !important;
    flex: none !important;
  }

  #fgg-help {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    bottom: auto;
    right: max(10px, env(safe-area-inset-right));
    width: 44px;
    height: 44px;
  }

  .fgg-help-btn {
    width: 44px;
    height: 44px;
  }

  .fgg-help-icon,
  .fgg-help-close {
    width: 22px;
    height: 22px;
  }

  #fgg-onboard {
    top: calc(100% + 12px);
    bottom: auto;
    right: 0;
    transform-origin: top right;
  }
}

.mx_AuthPage button[type="submit"][disabled],
.mx_AuthPage .mx_AccessibleButton_kind_primary[disabled],
.mx_AuthPage .fgg-register-wait {
  opacity: 0.55 !important;
  pointer-events: none !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
}

/* Email and username both work in the same field — hide the type picker. */
.mx_AuthPage .mx_Login_type_container,
.mx_AuthPage [data-testid="login-field-phone"],
.mx_AuthPage [value="login_field_phone"],
.mx_AuthPage input[type="tel"],
.mx_AuthPage .mx_Field:has(input[type="tel"]) {
  display: none !important;
}

.mx_UnsupportedBrowserDialog,
.mx_Dialog_wrapper:has(.mx_UnsupportedBrowserDialog),
.mx_Dialog_background:has(+ .mx_Dialog_wrapper .mx_UnsupportedBrowserDialog),
.mx_Toast_toast:has(a[href*="supported-environments"]),
.mx_Toast_toast:has(a[href*="element-hq/element-web"]) {
  display: none !important;
}

/* Spaces are folders, not chats — hide the create-space plus */
.mx_SpaceButton_new,
.mx_QuickMenu_CreateSpace,
.mx_CreateSpace,
.mx_Dialog_wrapper:has(.mx_CreateSpace) {
  display: none !important;
}

/* Company policy: no device-only encryption keys */
[data-testid="settings-tab-UserEncryptionTab"],
.mx_UserSettingsDialog .mx_SecureBackupPanel,
.mx_UserSettingsDialog .mx_RecoveryMethod,
.mx_SettingsTab:has(.mx_SecureBackupPanel) {
  display: none !important;
}

/* Cover auto-clicked post-login dialogs until the chat UI is ready. */
html.fgg-booting,
html.fgg-booting body {
  background: url("/fgg_background.jpg?v=30") center center / cover no-repeat fixed !important;
  background-color: #060c1a !important;
}

html.fgg-booting .mx_Dialog_wrapper,
html.fgg-booting .mx_Dialog_background,
html.fgg-booting .mx_Toast_toast,
html.fgg-booting .mx_Toast_container,
html.fgg-booting .mx_CompleteSecurity,
html.fgg-booting .mx_IncomingSasDialog,
html.fgg-booting .mx_SetupEncryptionBody,
html.fgg-booting .mx_MatrixChat,
html.fgg-booting .mx_HomePage,
html.fgg-booting #matrixchat,
html.fgg-booting .mx_LeftPanel,
html.fgg-booting .mx_SpacePanel,
html.fgg-booting .mx_ContextualMenu,
html.fgg-booting .mx_IconizedContextMenu,
html.fgg-booting .fgg-signout,
html.fgg-booting .mx_LoginSplashView_splashButtons,
html.fgg-booting .mx_AuthPage .mx_Spinner,
html.fgg-booting .mx_LoginSplashView_migrationProgress {
  opacity: 0 !important;
}

html.fgg-boot-cover .mx_AuthBody,
html.fgg-boot-cover .mx_AuthPage_modal,
html.fgg-boot-cover #fgg-help {
  opacity: 0 !important;
}

#fgg-boot {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483646 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  background: url("/fgg_background.jpg?v=30") center center / cover no-repeat fixed !important;
  background-color: #060c1a !important;
  pointer-events: none !important;
}

.fgg-boot-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 28px 36px;
  background: rgba(8, 14, 28, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.75);
}

.fgg-boot-spin {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #60a5fa;
  border-radius: 50%;
  animation: fgg-spin 0.8s linear infinite;
}

.fgg-boot-text {
  color: rgba(255, 255, 255, 0.88);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

@keyframes fgg-spin {
  to {
    transform: rotate(360deg);
  }
}
